Title: [259987] trunk/Source
Revision
259987
Author
[email protected]
Date
2020-04-12 12:31:08 -0700 (Sun, 12 Apr 2020)

Log Message

Fix some strange uses of start/endOfDocument
https://bugs.webkit.org/show_bug.cgi?id=210408

Reviewed by Wenson Hsieh.

Source/WebCore:

* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity):
Call startOfDocument and endOfDocument without unnecessarily turning a Position
into a VisiblePostion, since those functions just require any node from the document.

Source/WebKit:

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::replaceDictatedText): Pass the document to startOfDocument,
rather than getting the documentelement, because the function works on any
node, so there's no reason to write code to get a particular one.
(WebKit::WebPage::applyAutocorrectionInternal): Ditto.

Source/WebKitLegacy/ios:

* WebCoreSupport/WebFrameIOS.mm:
(-[WebFrame moveSelectionToStart]): Call startOfDocument on the document;
there is no need to pass a particular VisiblePosition, since all it gets
from the VisiblePosition is the document.
(-[WebFrame moveSelectionToEnd]): Ditto, for endOfDocument.
(-[WebFrame startPosition]): Call startOfDocument on the document rather
than using code to find the document element, since the function works
on any node.
(-[WebFrame endPosition]): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259986 => 259987)


--- trunk/Source/WebCore/ChangeLog	2020-04-12 19:28:02 UTC (rev 259986)
+++ trunk/Source/WebCore/ChangeLog	2020-04-12 19:31:08 UTC (rev 259987)
@@ -1,3 +1,15 @@
+2020-04-12  Darin Adler  <[email protected]>
+
+        Fix some strange uses of start/endOfDocument
+        https://bugs.webkit.org/show_bug.cgi?id=210408
+
+        Reviewed by Wenson Hsieh.
+
+        * editing/VisibleSelection.cpp:
+        (WebCore::VisibleSelection::setStartAndEndFromBaseAndExtentRespectingGranularity):
+        Call startOfDocument and endOfDocument without unnecessarily turning a Position
+        into a VisiblePostion, since those functions just require any node from the document.
+
 2020-04-12  Zalan Bujtas  <[email protected]>
 
         [LFC][TFC] Add support for column spanners

Modified: trunk/Source/WebCore/editing/VisibleSelection.cpp (259986 => 259987)


--- trunk/Source/WebCore/editing/VisibleSelection.cpp	2020-04-12 19:28:02 UTC (rev 259986)
+++ trunk/Source/WebCore/editing/VisibleSelection.cpp	2020-04-12 19:31:08 UTC (rev 259987)
@@ -383,8 +383,8 @@
             break;
         }
         case DocumentBoundary:
-            m_start = startOfDocument(VisiblePosition(m_start, m_affinity)).deepEquivalent();
-            m_end = endOfDocument(VisiblePosition(m_end, m_affinity)).deepEquivalent();
+            m_start = startOfDocument(m_start.document()).deepEquivalent();
+            m_end = endOfDocument(m_end.document()).deepEquivalent();
             break;
         case ParagraphBoundary:
             m_start = startOfParagraph(VisiblePosition(m_start, m_affinity)).deepEquivalent();

Modified: trunk/Source/WebKit/ChangeLog (259986 => 259987)


--- trunk/Source/WebKit/ChangeLog	2020-04-12 19:28:02 UTC (rev 259986)
+++ trunk/Source/WebKit/ChangeLog	2020-04-12 19:31:08 UTC (rev 259987)
@@ -1,3 +1,16 @@
+2020-04-12  Darin Adler  <[email protected]>
+
+        Fix some strange uses of start/endOfDocument
+        https://bugs.webkit.org/show_bug.cgi?id=210408
+
+        Reviewed by Wenson Hsieh.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::replaceDictatedText): Pass the document to startOfDocument,
+        rather than getting the documentelement, because the function works on any
+        node, so there's no reason to write code to get a particular one.
+        (WebKit::WebPage::applyAutocorrectionInternal): Ditto.
+
 2020-04-12  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Use gdk_window_move_to_rect() to position popup menus

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (259986 => 259987)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-04-12 19:28:02 UTC (rev 259986)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-04-12 19:31:08 UTC (rev 259987)
@@ -2308,7 +2308,7 @@
     for (size_t i = 0; i < oldText.length(); ++i)
         position = position.previous();
     if (position.isNull())
-        position = startOfDocument(static_cast<Node*>(frame.document()->documentElement()));
+        position = startOfDocument(frame.document());
     auto range = Range::create(*frame.document(), position, frame.selection().selection().start());
 
     if (plainTextForContext(range.ptr()) != oldText)
@@ -2416,7 +2416,7 @@
             for (size_t i = 0; i < originalText.length(); ++i)
                 position = position.previous();
             if (position.isNull())
-                position = startOfDocument(static_cast<Node*>(frame.document()->documentElement()));
+                position = startOfDocument(frame.document());
             range = Range::create(*frame.document(), position, frame.selection().selection().start());
             textForRange = plainTextForContext(range.get());
             unsigned loopCount = 0;

Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (259986 => 259987)


--- trunk/Source/WebKitLegacy/ios/ChangeLog	2020-04-12 19:28:02 UTC (rev 259986)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog	2020-04-12 19:31:08 UTC (rev 259987)
@@ -1,3 +1,20 @@
+2020-04-12  Darin Adler  <[email protected]>
+
+        Fix some strange uses of start/endOfDocument
+        https://bugs.webkit.org/show_bug.cgi?id=210408
+
+        Reviewed by Wenson Hsieh.
+
+        * WebCoreSupport/WebFrameIOS.mm:
+        (-[WebFrame moveSelectionToStart]): Call startOfDocument on the document;
+        there is no need to pass a particular VisiblePosition, since all it gets
+        from the VisiblePosition is the document.
+        (-[WebFrame moveSelectionToEnd]): Ditto, for endOfDocument.
+        (-[WebFrame startPosition]): Call startOfDocument on the document rather
+        than using code to find the document element, since the function works
+        on any node.
+        (-[WebFrame endPosition]): Ditto.
+
 2020-04-10  Darin Adler  <[email protected]>
 
         Move more from live range to SimpleRange: callers of absoluteTextRects

Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm (259986 => 259987)


--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm	2020-04-12 19:28:02 UTC (rev 259986)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm	2020-04-12 19:31:08 UTC (rev 259987)
@@ -597,18 +597,14 @@
 
 - (void)moveSelectionToStart
 {
-    Frame *frame = [self coreFrame];
-    FrameSelection& frameSelection = frame->selection();
-    VisiblePosition start = startOfDocument(frameSelection.selection().start());
-    frameSelection.moveTo(start);
+    auto& frame = *self.coreFrame;
+    frame.selection().moveTo(startOfDocument(frame.document()));
 }
 
 - (void)moveSelectionToEnd
 {
-    Frame *frame = [self coreFrame];
-    FrameSelection& frameSelection = frame->selection();
-    VisiblePosition end =  endOfDocument(frameSelection.selection().end());
-    frameSelection.moveTo(end);
+    auto& frame = *self.coreFrame;
+    frame.selection().moveTo(endOfDocument(frame.document()));
 }
 
 - (void)moveSelectionToPoint:(CGPoint)point
@@ -808,16 +804,12 @@
 
 - (WebVisiblePosition *)startPosition
 {
-    Frame *frame = [self coreFrame];
-    Element *rootElement = frame->document()->documentElement();
-    return [WebVisiblePosition _wrapVisiblePosition:startOfDocument(static_cast<Node*>(rootElement))];
+    return [WebVisiblePosition _wrapVisiblePosition:startOfDocument(self.coreFrame->document())];
 }
 
 - (WebVisiblePosition *)endPosition
 {
-    Frame *frame = [self coreFrame];
-    Element *rootElement = frame->document()->documentElement();
-    return [WebVisiblePosition _wrapVisiblePosition:endOfDocument(static_cast<Node*>(rootElement))];
+    return [WebVisiblePosition _wrapVisiblePosition:endOfDocument(self.coreFrame->document())];
 }
 
 - (BOOL)renderedCharactersExceed:(NSUInteger)threshold
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to