Title: [114962] trunk/Source
Revision
114962
Author
jchaffr...@webkit.org
Date
2012-04-23 16:49:34 -0700 (Mon, 23 Apr 2012)

Log Message

Cut dependency on RenderLayer::scrollRectToVisible outside rendering
https://bugs.webkit.org/show_bug.cgi?id=84607

Reviewed by Simon Fraser.

Source/WebCore:

Layering fix only, there should be no change behavior.

Because we don't have an accessor on RenderObject, a lot of the code needs
to know about RenderLayer. This is not necessary and exposes RenderLayer to
objects that shouldn't know about it.

This patch adds a RenderObject::scrollRectToVisible with the ad-hoc explanation
as to why it isn't on RenderBox (scrolling is a RenderBox concept).

* WebCore.exp.in:
* WebCore.order:
Updated to expose the new method.

* dom/Element.cpp:
(WebCore::Element::scrollIntoView):
(WebCore::Element::scrollIntoViewIfNeeded):
(WebCore::Element::updateFocusAppearance):
* editing/Editor.cpp:
(WebCore::Editor::findStringAndScrollToVisible):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::revealSelection):
* page/FrameView.cpp:
(WebCore::FrameView::scrollToAnchor):
Updated those call sites to use the new function.

* rendering/RenderLayer.h:
Removed ScrollBehavior.h #include and default argument values
as we are always called through RenderObject now.

* rendering/RenderObject.cpp:
(WebCore::RenderObject::scrollRectToVisible):
* rendering/RenderObject.h:
Added a new function that just forwards to the enclosing layer
if any. We return whether we actually tried to scroll to match
some call sites expectations.

Source/WebKit/mac:

* WebView/WebFrame.mm:
(-[WebFrame _scrollDOMRangeToVisible:]):
Updated to use RenderObject::scrollRectToVisible and not depend on RenderLayer.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114961 => 114962)


--- trunk/Source/WebCore/ChangeLog	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/ChangeLog	2012-04-23 23:49:34 UTC (rev 114962)
@@ -1,3 +1,46 @@
+2012-04-23  Julien Chaffraix  <jchaffr...@webkit.org>
+
+        Cut dependency on RenderLayer::scrollRectToVisible outside rendering
+        https://bugs.webkit.org/show_bug.cgi?id=84607
+
+        Reviewed by Simon Fraser.
+
+        Layering fix only, there should be no change behavior.
+
+        Because we don't have an accessor on RenderObject, a lot of the code needs
+        to know about RenderLayer. This is not necessary and exposes RenderLayer to
+        objects that shouldn't know about it.
+
+        This patch adds a RenderObject::scrollRectToVisible with the ad-hoc explanation
+        as to why it isn't on RenderBox (scrolling is a RenderBox concept).
+
+        * WebCore.exp.in:
+        * WebCore.order:
+        Updated to expose the new method.
+
+        * dom/Element.cpp:
+        (WebCore::Element::scrollIntoView):
+        (WebCore::Element::scrollIntoViewIfNeeded):
+        (WebCore::Element::updateFocusAppearance):
+        * editing/Editor.cpp:
+        (WebCore::Editor::findStringAndScrollToVisible):
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::revealSelection):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollToAnchor):
+        Updated those call sites to use the new function.
+
+        * rendering/RenderLayer.h:
+        Removed ScrollBehavior.h #include and default argument values
+        as we are always called through RenderObject now.
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::scrollRectToVisible):
+        * rendering/RenderObject.h:
+        Added a new function that just forwards to the enclosing layer
+        if any. We return whether we actually tried to scroll to match
+        some call sites expectations.
+
 2012-04-23  Zhenyao Mo  <z...@google.com>
 
         framebuffer binding should not be changed after canvas resize or compositing

Modified: trunk/Source/WebCore/WebCore.exp.in (114961 => 114962)


--- trunk/Source/WebCore/WebCore.exp.in	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-04-23 23:49:34 UTC (rev 114962)
@@ -220,7 +220,7 @@
 __ZN7WebCore11MemoryCache14evictResourcesEv
 __ZN7WebCore11MemoryCache19getOriginsWithCacheERN3WTF7HashSetINS1_6RefPtrINS_14SecurityOriginEEENS_18SecurityOriginHashENS1_10HashTraitsIS5_EEEE
 __ZN7WebCore11MemoryCache25removeResourcesWithOriginEPNS_14SecurityOriginE
-__ZN7WebCore11RenderLayer19scrollRectToVisibleERKNS_7IntRectERKNS_15ScrollAlignmentES6_
+__ZN7WebCore12RenderObject19scrollRectToVisibleERKNS_7IntRectERKNS_15ScrollAlignmentES6_
 __ZN7WebCore11URLWithDataEP6NSDataP5NSURL
 __ZN7WebCore11globalPointERK8_NSPointP8NSWindow
 __ZN7WebCore11memoryCacheEv

Modified: trunk/Source/WebCore/WebCore.order (114961 => 114962)


--- trunk/Source/WebCore/WebCore.order	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/WebCore.order	2012-04-23 23:49:34 UTC (rev 114962)
@@ -3618,7 +3618,7 @@
 __ZNK7WebCore10RenderView19mapLocalToContainerEPNS_20RenderBoxModelObjectEbbRNS_14TransformStateE
 __ZN7WebCore14TransformState7flattenEv
 __ZNK7WebCore13ContainerNode19getLowerRightCornerERNS_10FloatPointE
-__ZN7WebCore11RenderLayer19scrollRectToVisibleERKNS_7IntRectEbRKNS_15ScrollAlignmentES6_
+__ZN7WebCore12RenderObject19scrollRectToVisibleERKNS_7IntRectERKNS_15ScrollAlignmentES6_
 __ZNK7WebCore9RenderBox28canBeProgramaticallyScrolledEb
 __ZN7WebCore11RenderLayer15getRectToExposeERKNS_7IntRectES3_RKNS_15ScrollAlignmentES6_
 __ZNK7WebCore6Chrome18scrollRectIntoViewERKNS_7IntRectE

Modified: trunk/Source/WebCore/dom/Element.cpp (114961 => 114962)


--- trunk/Source/WebCore/dom/Element.cpp	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-04-23 23:49:34 UTC (rev 114962)
@@ -58,7 +58,6 @@
 #include "NodeRenderStyle.h"
 #include "NodeRenderingContext.h"
 #include "Page.h"
-#include "RenderLayer.h"
 #include "RenderRegion.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
@@ -269,9 +268,9 @@
     LayoutRect bounds = getRect();
     // Align to the top / bottom and to the closest edge.
     if (alignToTop)
-        renderer()->enclosingLayer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
+        renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
     else
-        renderer()->enclosingLayer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways);
+        renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways);
 }
 
 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
@@ -283,9 +282,9 @@
 
     LayoutRect bounds = getRect();
     if (centerIfNeeded)
-        renderer()->enclosingLayer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
+        renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
     else
-        renderer()->enclosingLayer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
+        renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
 }
 
 void Element::scrollByUnits(int units, ScrollGranularity granularity)
@@ -1614,7 +1613,7 @@
             frame->selection()->revealSelection();
         }
     } else if (renderer() && !renderer()->isWidget())
-        renderer()->enclosingLayer()->scrollRectToVisible(getRect());
+        renderer()->scrollRectToVisible(getRect());
 }
 
 void Element::blur()

Modified: trunk/Source/WebCore/editing/Editor.cpp (114961 => 114962)


--- trunk/Source/WebCore/editing/Editor.cpp	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/editing/Editor.cpp	2012-04-23 23:49:34 UTC (rev 114962)
@@ -70,7 +70,6 @@
 #include "TextCheckingHelper.h"
 #include "RemoveFormatCommand.h"
 #include "RenderBlock.h"
-#include "RenderLayer.h"
 #include "RenderPart.h"
 #include "RenderTextControl.h"
 #include "RenderedPosition.h"
@@ -2730,7 +2729,7 @@
     if (!nextMatch)
         return 0;
 
-    nextMatch->firstNode()->renderer()->enclosingLayer()->scrollRectToVisible(nextMatch->boundingBox(),
+    nextMatch->firstNode()->renderer()->scrollRectToVisible(nextMatch->boundingBox(),
         ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
 
     return nextMatch.release();

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (114961 => 114962)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2012-04-23 23:49:34 UTC (rev 114962)
@@ -50,7 +50,6 @@
 #include "InlineTextBox.h"
 #include "Page.h"
 #include "Range.h"
-#include "RenderLayer.h"
 #include "RenderText.h"
 #include "RenderTextControl.h"
 #include "RenderTheme.h"
@@ -1953,10 +1952,8 @@
         // FIXME: This code only handles scrolling the startContainer's layer, but
         // the selection rect could intersect more than just that.
         // See <rdar://problem/4799899>.
-        if (RenderLayer* layer = start.deprecatedNode()->renderer()->enclosingLayer()) {
-            layer->scrollRectToVisible(rect, alignment, alignment);
+        if (start.deprecatedNode()->renderer()->scrollRectToVisible(rect, alignment, alignment))
             updateAppearance();
-        }
     }
 }
 

Modified: trunk/Source/WebCore/page/FrameView.cpp (114961 => 114962)


--- trunk/Source/WebCore/page/FrameView.cpp	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/page/FrameView.cpp	2012-04-23 23:49:34 UTC (rev 114962)
@@ -2259,7 +2259,7 @@
 
     // Scroll nested layers and frames to reveal the anchor.
     // Align to the top and to the closest side (this matches other browsers).
-    anchorNode->renderer()->enclosingLayer()->scrollRectToVisible(rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
+    anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
 
     if (AXObjectCache::accessibilityEnabled())
         m_frame->document()->axObjectCache()->handleScrolledToAnchor(anchorNode.get());

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (114961 => 114962)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2012-04-23 23:49:34 UTC (rev 114962)
@@ -49,7 +49,6 @@
 #endif
 #include "PaintInfo.h"
 #include "RenderBox.h"
-#include "ScrollBehavior.h"
 #include "ScrollableArea.h"
 #include <wtf/OwnPtr.h>
 
@@ -301,7 +300,7 @@
     void scrollToXOffset(int x, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(x, scrollYOffset(), clamp); }
     void scrollToYOffset(int y, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(scrollXOffset(), y, clamp); }
 
-    void scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
+    void scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
 
     LayoutRect getRectToExpose(const LayoutRect& visibleRect, const LayoutRect& exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
 

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (114961 => 114962)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2012-04-23 23:49:34 UTC (rev 114962)
@@ -533,6 +533,16 @@
     return 0;
 }
 
+bool RenderObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
+{
+    RenderLayer* enclosingLayer = this->enclosingLayer();
+    if (!enclosingLayer)
+        return false;
+
+    enclosingLayer->scrollRectToVisible(rect, alignX, alignY);
+    return true;
+}
+
 RenderBox* RenderObject::enclosingBox() const
 {
     RenderObject* curr = const_cast<RenderObject*>(this);

Modified: trunk/Source/WebCore/rendering/RenderObject.h (114961 => 114962)


--- trunk/Source/WebCore/rendering/RenderObject.h	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2012-04-23 23:49:34 UTC (rev 114962)
@@ -35,6 +35,7 @@
 #include "PaintPhase.h"
 #include "RenderObjectChildList.h"
 #include "RenderStyle.h"
+#include "ScrollBehavior.h"
 #include "TextAffinity.h"
 #include "TransformationMatrix.h"
 #include <wtf/UnusedParam.h>
@@ -201,6 +202,9 @@
     void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
     RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
 
+    // Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s).
+    bool scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
+
     // Convenience function for getting to the nearest enclosing box of a RenderObject.
     RenderBox* enclosingBox() const;
     RenderBoxModelObject* enclosingBoxModelObject() const;

Modified: trunk/Source/WebKit/mac/ChangeLog (114961 => 114962)


--- trunk/Source/WebKit/mac/ChangeLog	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-04-23 23:49:34 UTC (rev 114962)
@@ -1,3 +1,14 @@
+2012-04-23  Julien Chaffraix  <jchaffr...@webkit.org>
+
+        Cut dependency on RenderLayer::scrollRectToVisible outside rendering
+        https://bugs.webkit.org/show_bug.cgi?id=84607
+
+        Reviewed by Simon Fraser.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _scrollDOMRangeToVisible:]):
+        Updated to use RenderObject::scrollRectToVisible and not depend on RenderLayer.
+
 2012-04-22  Jon Lee  <jon...@apple.com>
 
         Remove notifications support on Mac Lion.

Modified: trunk/Source/WebKit/mac/WebView/WebFrame.mm (114961 => 114962)


--- trunk/Source/WebKit/mac/WebView/WebFrame.mm	2012-04-23 23:22:03 UTC (rev 114961)
+++ trunk/Source/WebKit/mac/WebView/WebFrame.mm	2012-04-23 23:49:34 UTC (rev 114962)
@@ -80,7 +80,6 @@
 #import <WebCore/PlatformEventFactoryMac.h>
 #import <WebCore/PluginData.h>
 #import <WebCore/PrintContext.h>
-#import <WebCore/RenderLayer.h>
 #import <WebCore/RenderPart.h>
 #import <WebCore/RenderView.h>
 #import <WebCore/ReplaceSelectionCommand.h>
@@ -632,11 +631,8 @@
     NSRect rangeRect = [self _firstRectForDOMRange:range];    
     Node *startNode = core([range startContainer]);
         
-    if (startNode && startNode->renderer()) {
-        RenderLayer *layer = startNode->renderer()->enclosingLayer();
-        if (layer)
-            layer->scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
-    }
+    if (startNode && startNode->renderer())
+        startNode->renderer()->scrollRectToVisible(enclosingIntRect(rangeRect), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
 }
 
 - (BOOL)_needsLayout
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to