Title: [200972] trunk/Source/WebKit2
- Revision
- 200972
- Author
- [email protected]
- Date
- 2016-05-16 15:20:16 -0700 (Mon, 16 May 2016)
Log Message
Text selection is basically impossible on plain text pages.
https://bugs.webkit.org/show_bug.cgi?id=157681
rdar://problem/26065660
Reviewed by Darin Adler.
When dealing with a plain text file, the rules for deciding whether
a position is selectable should be different and we should never
switch to block selection.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::shouldSwitchToBlockModeForHandle):
(WebKit::rectIsTooBigForSelection): Added helper function.
(WebKit::WebPage::selectTextWithGranularityAtPoint):
(WebKit::WebPage::getPositionInformation):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (200971 => 200972)
--- trunk/Source/WebKit2/ChangeLog 2016-05-16 22:00:30 UTC (rev 200971)
+++ trunk/Source/WebKit2/ChangeLog 2016-05-16 22:20:16 UTC (rev 200972)
@@ -1,3 +1,21 @@
+2016-05-13 Enrica Casucci <[email protected]>
+
+ Text selection is basically impossible on plain text pages.
+ https://bugs.webkit.org/show_bug.cgi?id=157681
+ rdar://problem/26065660
+
+ Reviewed by Darin Adler.
+
+ When dealing with a plain text file, the rules for deciding whether
+ a position is selectable should be different and we should never
+ switch to block selection.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::shouldSwitchToBlockModeForHandle):
+ (WebKit::rectIsTooBigForSelection): Added helper function.
+ (WebKit::WebPage::selectTextWithGranularityAtPoint):
+ (WebKit::WebPage::getPositionInformation):
+
2016-05-16 Chelsea Pugh <[email protected]>
[iOS] Remove dispatch_after in -[WKFormInputSession setSuggestions:]
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (200971 => 200972)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-05-16 22:00:30 UTC (rev 200971)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-05-16 22:20:16 UTC (rev 200972)
@@ -1658,6 +1658,8 @@
bool WebPage::shouldSwitchToBlockModeForHandle(const IntPoint& handlePoint, SelectionHandlePosition handlePosition)
{
+ if (!m_blockRectForTextSelection.height())
+ return false;
switch (handlePosition) {
case SelectionHandlePosition::Top:
return handlePoint.y() < m_blockRectForTextSelection.y();
@@ -1859,6 +1861,12 @@
return range;
}
+static inline bool rectIsTooBigForSelection(const IntRect& blockRect, const Frame& frame)
+{
+ const float factor = 0.97;
+ return blockRect.height() > frame.view()->unobscuredContentRect().height() * factor;
+}
+
void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithAssistedNode, uint64_t callbackID)
{
const Frame& frame = m_page->focusController().focusedOrMainFrame();
@@ -1867,9 +1875,17 @@
m_blockSelectionDesiredSize.setWidth(blockSelectionStartWidth);
m_blockSelectionDesiredSize.setHeight(blockSelectionStartHeight);
m_currentBlockSelection = nullptr;
- RefPtr<Range> paragraphRange = enclosingTextUnitOfGranularity(visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode), ParagraphGranularity, DirectionForward);
- if (paragraphRange && !paragraphRange->collapsed())
- m_blockRectForTextSelection = selectionBoxForRange(paragraphRange.get());
+ auto* renderer = range->startContainer().renderer();
+ if (renderer->style().preserveNewline())
+ m_blockRectForTextSelection = renderer->absoluteBoundingBoxRect(true);
+ else {
+ auto* paragraphRange = enclosingTextUnitOfGranularity(visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithAssistedNode), ParagraphGranularity, DirectionForward).get();
+ if (paragraphRange && !paragraphRange->collapsed())
+ m_blockRectForTextSelection = selectionBoxForRange(paragraphRange);
+ }
+
+ if (rectIsTooBigForSelection(m_blockRectForTextSelection, frame))
+ m_blockRectForTextSelection.setHeight(0);
}
if (range)
@@ -2388,8 +2404,9 @@
if (attachment.file())
info.url = ""
} else {
- const static CGFloat factor = 0.97;
- info.isSelectable = renderer->style().userSelect() != SELECT_NONE && info.bounds.height() < result.innerNodeFrame()->view()->unobscuredContentRect().height() * factor;
+ info.isSelectable = renderer->style().userSelect() != SELECT_NONE;
+ if (info.isSelectable && !hitNode->isTextNode())
+ info.isSelectable = !rectIsTooBigForSelection(info.bounds, *result.innerNodeFrame());
}
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes