Title: [163476] trunk/Source
Revision
163476
Author
[email protected]
Date
2014-02-05 13:54:49 -0800 (Wed, 05 Feb 2014)

Log Message

WK2: Caret, selections and autocorrection bubbles are incorrectly positioned when inside an iframe.
https://bugs.webkit.org/show_bug.cgi?id=128264
<rdar://problem/15986954>

Reviewed by Simon Fraser.

Source/WebCore: 

Adding new exported function.

* WebCore.exp.in:

Source/WebKit2: 

Everywhere we return rectangles to the UIProcess, we need to convert them
to root view coordinates. Also, we should allow hit testing to go into child
frames.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::selectWithGesture):
(WebKit::WebPage::updateSelectionWithTouches):
(WebKit::WebPage::convertSelectionRectsToRootView):
(WebKit::WebPage::requestAutocorrectionData):
(WebKit::WebPage::getPositionInformation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (163475 => 163476)


--- trunk/Source/WebCore/ChangeLog	2014-02-05 21:50:55 UTC (rev 163475)
+++ trunk/Source/WebCore/ChangeLog	2014-02-05 21:54:49 UTC (rev 163476)
@@ -1,3 +1,15 @@
+2014-02-05  Enrica Casucci  <[email protected]>
+
+        WK2: Caret, selections and autocorrection bubbles are incorrectly positioned when inside an iframe.
+        https://bugs.webkit.org/show_bug.cgi?id=128264
+        <rdar://problem/15986954>
+
+        Reviewed by Simon Fraser.
+
+        Adding new exported function.
+
+        * WebCore.exp.in:
+
 2014-02-05  Antti Koivisto  <[email protected]>
 
         ElementRuleCollector should not use StyleResolver::State

Modified: trunk/Source/WebCore/WebCore.exp.in (163475 => 163476)


--- trunk/Source/WebCore/WebCore.exp.in	2014-02-05 21:50:55 UTC (rev 163475)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-02-05 21:54:49 UTC (rev 163476)
@@ -1434,6 +1434,7 @@
 __ZNK7WebCore10ScrollView16windowToContentsERKNS_8IntPointE
 __ZNK7WebCore10ScrollView18contentsToRootViewERKNS_7IntRectE
 __ZNK7WebCore10ScrollView18contentsToRootViewERKNS_8IntPointE
+__ZNK7WebCore10ScrollView18rootViewToContentsERKNS_8IntPointE
 __ZNK7WebCore10ScrollView23rootViewToTotalContentsERKNS_8IntPointE
 __ZNK7WebCore10ScrollView30scrollOffsetRelativeToDocumentEv
 __ZNK7WebCore10StorageMap6lengthEv

Modified: trunk/Source/WebKit2/ChangeLog (163475 => 163476)


--- trunk/Source/WebKit2/ChangeLog	2014-02-05 21:50:55 UTC (rev 163475)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-05 21:54:49 UTC (rev 163476)
@@ -1,3 +1,25 @@
+2014-02-05  Enrica Casucci  <[email protected]>
+
+        WK2: Caret, selections and autocorrection bubbles are incorrectly positioned when inside an iframe.
+        https://bugs.webkit.org/show_bug.cgi?id=128264
+        <rdar://problem/15986954>
+
+        Reviewed by Simon Fraser.
+
+        Everywhere we return rectangles to the UIProcess, we need to convert them
+        to root view coordinates. Also, we should allow hit testing to go into child
+        frames.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::editorState):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::selectWithGesture):
+        (WebKit::WebPage::updateSelectionWithTouches):
+        (WebKit::WebPage::convertSelectionRectsToRootView):
+        (WebKit::WebPage::requestAutocorrectionData):
+        (WebKit::WebPage::getPositionInformation):
+
 2014-02-05  Dan Bernstein  <[email protected]>
 
         [Cocoa] WKRemoteObjectInterface fails with doubles, NSNull, and empty NSStrings

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (163475 => 163476)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-02-05 21:50:55 UTC (rev 163475)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-02-05 21:54:49 UTC (rev 163476)
@@ -666,16 +666,18 @@
             result.lastMarkedRect = result.firstMarkedRect;
         result.markedText = plainText(compositionRange.get());
     }
+    FrameView* view = frame.view();
     if (selection.isCaret()) {
-        result.caretRectAtStart = frame.selection().absoluteCaretBounds();
+        result.caretRectAtStart = view->contentsToRootView(frame.selection().absoluteCaretBounds());
         result.caretRectAtEnd = result.caretRectAtStart;
         if (m_shouldReturnWordAtSelection)
             result.wordAtSelection = plainText(wordRangeFromPosition(selection.start()).get());
     } else if (selection.isRange()) {
-        result.caretRectAtStart = VisiblePosition(selection.start()).absoluteCaretBounds();
-        result.caretRectAtEnd = VisiblePosition(selection.end()).absoluteCaretBounds();
+        result.caretRectAtStart = view->contentsToRootView(VisiblePosition(selection.start()).absoluteCaretBounds());
+        result.caretRectAtEnd = view->contentsToRootView(VisiblePosition(selection.end()).absoluteCaretBounds());
         RefPtr<Range> selectedRange = selection.toNormalizedRange();
         selectedRange->collectSelectionRects(result.selectionRects);
+        convertSelectionRectsToRootView(view, result.selectionRects);
         result.selectedTextLength = plainText(selectedRange.get(), TextIteratorDefaultBehavior, true).length();
     }
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (163475 => 163476)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-02-05 21:50:55 UTC (rev 163475)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-02-05 21:54:49 UTC (rev 163476)
@@ -707,6 +707,9 @@
     void didReceiveWebPageMessage(IPC::Connection*, IPC::MessageDecoder&);
     void didReceiveSyncWebPageMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
 
+#if PLATFORM(IOS)
+    static void convertSelectionRectsToRootView(WebCore::FrameView*, Vector<WebCore::SelectionRect>&);
+#endif
 #if !PLATFORM(MAC)
     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (163475 => 163476)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-02-05 21:50:55 UTC (rev 163475)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2014-02-05 21:54:49 UTC (rev 163476)
@@ -384,9 +384,9 @@
 void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, uint64_t callbackID)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
-    FloatPoint adjustedPoint(point);
+    IntPoint adjustedPoint(frame.view()->rootViewToContents(point));
 
-    IntPoint constrainedPoint = m_assistedNode ? constrainPoint(point, &frame, m_assistedNode.get()) : point;
+    IntPoint constrainedPoint = m_assistedNode ? constrainPoint(adjustedPoint, &frame, m_assistedNode.get()) : adjustedPoint;
     VisiblePosition position = frame.visiblePositionForPoint(constrainedPoint);
     if (position.isNull()) {
         send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, 0, callbackID));
@@ -578,7 +578,7 @@
 void WebPage::updateSelectionWithTouches(const IntPoint& point, uint32_t touches, bool baseIsStart, uint64_t callbackID)
 {
     Frame& frame = m_page->focusController().focusedOrMainFrame();
-    VisiblePosition position = frame.visiblePositionForPoint(point);
+    VisiblePosition position = frame.visiblePositionForPoint(frame.view()->rootViewToContents(point));
     if (position.isNull()) {
         send(Messages::WebPageProxy::TouchesCallback(point, touches, callbackID));
         return;
@@ -649,6 +649,14 @@
     frame.selection().setSelectedRange(wordRangeFromPosition(position).get(), position.affinity(), true);
 }
 
+void WebPage::convertSelectionRectsToRootView(FrameView* view, Vector<SelectionRect>& selectionRects)
+{
+    for (size_t i = 0; i < selectionRects.size(); ++i) {
+        SelectionRect& currentRect = selectionRects[i];
+        currentRect.setRect(view->contentsToRootView(currentRect.rect()));
+    }
+}
+
 void WebPage::requestAutocorrectionData(const String& textForAutocorrection, uint64_t callbackID)
 {
     RefPtr<Range> range;
@@ -674,6 +682,7 @@
     Vector<FloatRect> rectsForText;
     rectsForText.resize(selectionRects.size());
 
+    convertSelectionRectsToRootView(frame.view(), selectionRects);
     for (size_t i = 0; i < selectionRects.size(); i++)
         rectsForText[i] = selectionRects[i].rect();
 
@@ -852,13 +861,16 @@
     }
 
     if (!elementIsLinkOrImage) {
-        Frame& frame = m_page->mainFrame();
-        hitNode = frame.eventHandler().hitTestResultAtPoint((point), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent).innerNode();
-        if (hitNode->isTextNode()) {
-            VisiblePosition position = frame.visiblePositionForPoint(point);
+        HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint((point), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent | HitTestRequest::AllowChildFrameContent);
+        hitNode = result.innerNode();
+        if (hitNode && hitNode->isTextNode()) {
+            m_page->focusController().setFocusedFrame(result.innerNodeFrame());
+            FrameView* view = result.innerNodeFrame()->view();
+            VisiblePosition position = result.innerNodeFrame()->visiblePositionForPoint(view->rootViewToContents(point));
             RefPtr<Range> range = wordRangeFromPosition(position);
             if (range)
                 range->collectSelectionRects(info.selectionRects);
+            convertSelectionRectsToRootView(view, info.selectionRects);
         } else {
             // FIXME: implement the logic for the block selection.
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to