Remove redundant RenderObject::selectionRoot and dependencies
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Sep 2017 04:31:29 +0000 (04:31 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Sep 2017 04:31:29 +0000 (04:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177696

Reviewed by Ryosuke Niwa.

There's only one selection root (RenderView).

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionState):
(WebCore::InlineTextBox::selectionStartEnd const):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::selectionRoot const): Deleted.
(WebCore::RenderObject::selectionStartEnd const): Deleted.
* rendering/RenderObject.h:
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::isSelected const):
* rendering/RenderText.cpp:
(WebCore::RenderText::collectSelectionRectsForLineBoxes):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::setSelectionState):
* rendering/RenderView.h:
* rendering/SelectionSubtreeRoot.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222677 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderTextLineBoxes.cpp
Source/WebCore/rendering/RenderView.h

index 8923495..1be1834 100644 (file)
@@ -1,3 +1,28 @@
+2017-09-29  Zalan Bujtas  <zalan@apple.com>
+
+        Remove redundant RenderObject::selectionRoot and dependencies
+        https://bugs.webkit.org/show_bug.cgi?id=177696
+
+        Reviewed by Ryosuke Niwa.
+
+        There's only one selection root (RenderView).
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::selectionState):
+        (WebCore::InlineTextBox::selectionStartEnd const):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::selectionRoot const): Deleted.
+        (WebCore::RenderObject::selectionStartEnd const): Deleted.
+        * rendering/RenderObject.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::isSelected const):
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::collectSelectionRectsForLineBoxes):
+        * rendering/RenderTextLineBoxes.cpp:
+        (WebCore::RenderTextLineBoxes::setSelectionState):
+        * rendering/RenderView.h:
+        * rendering/SelectionSubtreeRoot.h:
+
 2017-09-29  Chris Dumez  <cdumez@apple.com>
 
         http/tests/preconnect/link-rel-preconnect-https.html is flaky
index 361cc43..b64fceb 100644 (file)
@@ -145,7 +145,7 @@ RenderObject::SelectionState InlineTextBox::selectionState()
     RenderObject::SelectionState state = renderer().selectionState();
     if (state == RenderObject::SelectionStart || state == RenderObject::SelectionEnd || state == RenderObject::SelectionBoth) {
         unsigned startPos, endPos;
-        renderer().selectionStartEnd(startPos, endPos);
+        renderer().view().getSelectionStartEnd(startPos, endPos);
         // The position after a hard line break is considered to be past its end.
         ASSERT(start() + len() >= (isLineBreak() ? 1 : 0));
         unsigned lastSelectable = start() + len() - (isLineBreak() ? 1 : 0);
@@ -641,7 +641,7 @@ std::pair<unsigned, unsigned> InlineTextBox::selectionStartEnd() const
     
     unsigned start;
     unsigned end;
-    renderer().selectionStartEnd(start, end);
+    renderer().view().getSelectionStartEnd(start, end);
     if (selectionState == RenderObject::SelectionStart)
         end = renderer().textLength();
     else if (selectionState == RenderObject::SelectionEnd)
index cb50029..6147384 100644 (file)
@@ -1202,26 +1202,6 @@ void RenderObject::outputRenderSubTreeAndMark(TextStream& stream, const RenderOb
 
 #endif // NDEBUG
 
-SelectionSubtreeRoot& RenderObject::selectionRoot() const
-{
-    RenderFragmentedFlow* fragmentedFlow = enclosingFragmentedFlow();
-    if (!fragmentedFlow)
-        return view();
-
-    if (is<RenderMultiColumnFlow>(*fragmentedFlow)) {
-        if (!fragmentedFlow->containingBlock())
-            return view();
-        return fragmentedFlow->containingBlock()->selectionRoot();
-    }
-    ASSERT_NOT_REACHED();
-    return view();
-}
-
-void RenderObject::selectionStartEnd(unsigned& spos, unsigned& epos) const
-{
-    selectionRoot().selectionData().selectionStartEndPositions(spos, epos);
-}
-
 FloatPoint RenderObject::localToAbsolute(const FloatPoint& localPoint, MapCoordinatesFlags mode, bool* wasFixed) const
 {
     TransformState transformState(TransformState::ApplyTransformDirection, localPoint);
index c38416d..5792c92 100644 (file)
@@ -752,9 +752,6 @@ public:
     void imageChanged(CachedImage*, const IntRect* = nullptr) override;
     virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) { }
 
-    SelectionSubtreeRoot& selectionRoot() const;
-    void selectionStartEnd(unsigned& spos, unsigned& epos) const;
-    
     void removeFromParent();
 
     CSSAnimationController& animation() const;
index a9db934..640a7ba 100644 (file)
@@ -651,7 +651,7 @@ bool RenderReplaced::isSelected() const
         return true;
 
     unsigned selectionStart, selectionEnd;
-    selectionStartEnd(selectionStart, selectionEnd);
+    view().getSelectionStartEnd(selectionStart, selectionEnd);
     if (s == SelectionStart)
         return selectionStart == 0;
         
index 403d188..df13319 100644 (file)
@@ -1447,7 +1447,7 @@ LayoutRect RenderText::collectSelectionRectsForLineBoxes(const RenderLayerModelO
         startPos = 0;
         endPos = textLength();
     } else {
-        selectionStartEnd(startPos, endPos);
+        view().getSelectionStartEnd(startPos, endPos);
         if (selectionState() == SelectionStart)
             endPos = textLength();
         else if (selectionState() == SelectionEnd)
index 2c48921..c250a4d 100644 (file)
@@ -30,6 +30,7 @@
 #include "InlineTextBox.h"
 #include "RenderBlock.h"
 #include "RenderStyle.h"
+#include "RenderView.h"
 #include "RootInlineBox.h"
 
 namespace WebCore {
@@ -446,7 +447,7 @@ void RenderTextLineBoxes::setSelectionState(RenderText& renderer, RenderObject::
     }
 
     unsigned start, end;
-    renderer.selectionStartEnd(start, end);
+    renderer.view().getSelectionStartEnd(start, end);
     if (state == RenderObject::SelectionStart) {
         end = renderer.textLength();
 
index d68d7ae..581888d 100644 (file)
@@ -93,6 +93,7 @@ public:
     RenderObject* selectionUnsplitEnd() const { return m_selectionUnsplitEnd; }
     IntRect selectionBounds(bool clipToVisibleContent = true) const;
     void repaintSelection() const;
+    void getSelectionStartEnd(unsigned& start, unsigned& end) const { selectionData().selectionStartEndPositions(start, end); }
 
     bool printing() const;