Returning incorrect marked text rects
https://bugs.webkit.org/show_bug.cgi?id=197758
<rdar://problem/46548586>

Reviewed by Tim Horton.

We are not returning marked text rects in the correct view coordinate space.
This is the same translation we are applying to the caret rects.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformEditorState const):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245195 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 0bf2ac4..ac08c1b 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,17 @@
+2019-05-10  Megan Gardner  <megan_gardner@apple.com>
+
+        Returning incorrect marked text rects
+        https://bugs.webkit.org/show_bug.cgi?id=197758
+        <rdar://problem/46548586>
+
+        Reviewed by Tim Horton.
+
+        We are not returning marked text rects in the correct view coordinate space.
+        This is the same translation we are applying to the caret rects. 
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::platformEditorState const):
+
 2019-05-10  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Let WebKit clients supply an application name for user agent in modern compatibility mode
diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
index e3ee326..b38db79 100644
--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
@@ -193,15 +193,16 @@
 
 void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePostLayoutDataHint shouldIncludePostLayoutData) const
 {
+    FrameView* view = frame.view();
     if (frame.editor().hasComposition()) {
         RefPtr<Range> compositionRange = frame.editor().compositionRange();
         Vector<WebCore::SelectionRect> compositionRects;
         if (compositionRange) {
             compositionRange->collectSelectionRects(compositionRects);
             if (compositionRects.size())
-                result.firstMarkedRect = compositionRects[0].rect();
+                result.firstMarkedRect = view->contentsToRootView(compositionRects[0].rect());
             if (compositionRects.size() > 1)
-                result.lastMarkedRect = compositionRects.last().rect();
+                result.lastMarkedRect = view->contentsToRootView(compositionRects.last().rect());
             else
                 result.lastMarkedRect = result.firstMarkedRect;
             result.markedText = plainTextReplacingNoBreakSpace(compositionRange.get());
@@ -223,7 +224,7 @@
     }
 
     auto& postLayoutData = result.postLayoutData();
-    FrameView* view = frame.view();
+    
     const VisibleSelection& selection = frame.selection().selection();
     postLayoutData.isStableStateUpdate = m_isInStableState;
     bool startNodeIsInsideFixedPosition = false;