Title: [173320] trunk/Source
Revision
173320
Author
[email protected]
Date
2014-09-05 11:54:37 -0700 (Fri, 05 Sep 2014)

Log Message

ScrollablArea::handleWheelEvent() should return early if the ScrollableArea is not 
actually scrollable
https://bugs.webkit.org/show_bug.cgi?id=136558

Reviewed by Simon Fraser.

Source/WebCore:

This patch requires adding a new virtual function to ScrollableArea called 
isScrollableOrRubberbandable(). Unfortunately, there is already a virtual function 
of that name that exists on RenderLayerModelObject, which is only problematic 
because RenderListBox inherits from both RenderLayerModelObject and 
ScrollableArea. This patch resolves that conflict in the simplest way, by re-
naming the RenderLayerModelObject version of the function to 
isScrollableOrRubberbandableBox(). It’s a little unfortunate, but simpler than the 
other solutions I came up with.

New ScrollableArea virtual function.
* page/FrameView.cpp:
(WebCore::FrameView::isScrollableOrRubberbandable):
* page/FrameView.h:

The point of the whole patch! Return early if you can’t scroll or rubber band.
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::handleWheelEvent):

New ScrollableArea virtual function.
* platform/ScrollableArea.h:
* platform/win/PopupMenuWin.h:

Re-name.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::isScrollableOrRubberbandableBox):
(WebCore::RenderBox::isScrollableOrRubberbandable): Deleted.
* rendering/RenderBox.h:

Implement new ScrollableArea virtual function, and adapt to the re-name.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::isScrollableOrRubberbandable):
(WebCore::RenderLayer::hasScrollableOrRubberbandableAncestor):
* rendering/RenderLayer.h:

Re-name.
* rendering/RenderLayerModelObject.h:
(WebCore::RenderLayerModelObject::isScrollableOrRubberbandableBox):
(WebCore::RenderLayerModelObject::isScrollableOrRubberbandable): Deleted.

Implement ScrollableArea virtual function.
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::isScrollableOrRubberbandable):
* rendering/RenderListBox.h:

Re-name.
* rendering/RenderView.cpp:
(WebCore::RenderView::isScrollableOrRubberbandableBox):
(WebCore::RenderView::isScrollableOrRubberbandable): Deleted.
* rendering/RenderView.h:

Source/WebKit2:

New ScrollableArea virtual function.
* WebProcess/Plugins/PDF/PDFPlugin.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (173319 => 173320)


--- trunk/Source/WebCore/ChangeLog	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/ChangeLog	2014-09-05 18:54:37 UTC (rev 173320)
@@ -1,3 +1,61 @@
+2014-09-05  Beth Dakin  <[email protected]>
+
+        ScrollablArea::handleWheelEvent() should return early if the ScrollableArea is not 
+        actually scrollable
+        https://bugs.webkit.org/show_bug.cgi?id=136558
+
+        Reviewed by Simon Fraser.
+
+        This patch requires adding a new virtual function to ScrollableArea called 
+        isScrollableOrRubberbandable(). Unfortunately, there is already a virtual function 
+        of that name that exists on RenderLayerModelObject, which is only problematic 
+        because RenderListBox inherits from both RenderLayerModelObject and 
+        ScrollableArea. This patch resolves that conflict in the simplest way, by re-
+        naming the RenderLayerModelObject version of the function to 
+        isScrollableOrRubberbandableBox(). It’s a little unfortunate, but simpler than the 
+        other solutions I came up with.
+
+        New ScrollableArea virtual function.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::isScrollableOrRubberbandable):
+        * page/FrameView.h:
+
+        The point of the whole patch! Return early if you can’t scroll or rubber band.
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::handleWheelEvent):
+
+        New ScrollableArea virtual function.
+        * platform/ScrollableArea.h:
+        * platform/win/PopupMenuWin.h:
+
+        Re-name.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::isScrollableOrRubberbandableBox):
+        (WebCore::RenderBox::isScrollableOrRubberbandable): Deleted.
+        * rendering/RenderBox.h:
+
+        Implement new ScrollableArea virtual function, and adapt to the re-name.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::isScrollableOrRubberbandable):
+        (WebCore::RenderLayer::hasScrollableOrRubberbandableAncestor):
+        * rendering/RenderLayer.h:
+
+        Re-name.
+        * rendering/RenderLayerModelObject.h:
+        (WebCore::RenderLayerModelObject::isScrollableOrRubberbandableBox):
+        (WebCore::RenderLayerModelObject::isScrollableOrRubberbandable): Deleted.
+
+        Implement ScrollableArea virtual function.
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::isScrollableOrRubberbandable):
+        * rendering/RenderListBox.h:
+
+        Re-name.
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::isScrollableOrRubberbandableBox):
+        (WebCore::RenderView::isScrollableOrRubberbandable): Deleted.
+        * rendering/RenderView.h:
+
 2014-06-06  Jer Noble  <[email protected]>
 
         Refactoring: make MediaTime the primary time type for audiovisual times.

Modified: trunk/Source/WebCore/page/FrameView.cpp (173319 => 173320)


--- trunk/Source/WebCore/page/FrameView.cpp	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/page/FrameView.cpp	2014-09-05 18:54:37 UTC (rev 173320)
@@ -3339,6 +3339,11 @@
     return true;
 }
 
+bool FrameView::isScrollableOrRubberbandable()
+{
+    return frame().isMainFrame() ? isScrollable(Scrollability::ScrollableOrRubberbandable) : isScrollable(Scrollability::Scrollable);
+}
+
 bool FrameView::hasScrollableOrRubberbandableAncestor()
 {
     if (frame().isMainFrame())

Modified: trunk/Source/WebCore/page/FrameView.h (173319 => 173320)


--- trunk/Source/WebCore/page/FrameView.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/page/FrameView.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -403,6 +403,8 @@
     // callers use Scrollability::ScrollableOrRubberbandable.
     enum class Scrollability { Scrollable, ScrollableOrRubberbandable };
     bool isScrollable(Scrollability definitionOfScrollable = Scrollability::Scrollable);
+
+    virtual bool isScrollableOrRubberbandable() override;
     virtual bool hasScrollableOrRubberbandableAncestor() override;
 
     enum ScrollbarModesCalculationStrategy { RulesFromWebContentOnly, AnyRule };

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (173319 => 173320)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2014-09-05 18:54:37 UTC (rev 173320)
@@ -185,6 +185,9 @@
 
 bool ScrollableArea::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
+    if (!isScrollableOrRubberbandable())
+        return false;
+
     return scrollAnimator()->handleWheelEvent(wheelEvent);
 }
 

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (173319 => 173320)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -207,6 +207,7 @@
     // Note that this only returns scrollable areas that can actually be scrolled.
     virtual ScrollableArea* enclosingScrollableArea() const = 0;
 
+    virtual bool isScrollableOrRubberbandable() = 0;
     virtual bool hasScrollableOrRubberbandableAncestor() = 0;
 
     // Returns the bounding box of this scrollable area, in the coordinate system of the enclosing scroll view.

Modified: trunk/Source/WebCore/platform/win/PopupMenuWin.h (173319 => 173320)


--- trunk/Source/WebCore/platform/win/PopupMenuWin.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/platform/win/PopupMenuWin.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -95,6 +95,7 @@
     virtual void invalidateScrollCornerRect(const IntRect&) override { }
     virtual bool isActive() const override { return true; }
     ScrollableArea* enclosingScrollableArea() const override { return 0; }
+    virtual bool isScrollableOrRubberbandable() override { return true; }
     virtual bool hasScrollableOrRubberbandableAncestor() override { return true; }
     virtual bool isScrollCornerVisible() const override { return false; }
     virtual IntRect scrollCornerRect() const override { return IntRect(); }

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2014-09-05 18:54:37 UTC (rev 173320)
@@ -843,7 +843,7 @@
     return canBeProgramaticallyScrolled() && (scrollHeight() != clientHeight() || scrollWidth() != clientWidth());
 }
 
-bool RenderBox::isScrollableOrRubberbandable() const
+bool RenderBox::isScrollableOrRubberbandableBox() const
 {
     return canBeScrolledAndHasScrollableArea();
 }

Modified: trunk/Source/WebCore/rendering/RenderBox.h (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderBox.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -662,7 +662,7 @@
     bool includeVerticalScrollbarSize() const;
     bool includeHorizontalScrollbarSize() const;
 
-    virtual bool isScrollableOrRubberbandable() const override;
+    virtual bool isScrollableOrRubberbandableBox() const override;
 
     // Returns true if we did a full repaint
     bool repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer* layers, bool drawingBackground);

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-09-05 18:54:37 UTC (rev 173320)
@@ -3056,10 +3056,15 @@
     return 0;
 }
 
+bool RenderLayer::isScrollableOrRubberbandable()
+{
+    return renderer().isScrollableOrRubberbandableBox();
+}
+
 bool RenderLayer::hasScrollableOrRubberbandableAncestor()
 {
     for (RenderLayer* nextLayer = parentLayerCrossFrame(this); nextLayer; nextLayer = parentLayerCrossFrame(nextLayer)) {
-        if (nextLayer->renderer().isScrollableOrRubberbandable())
+        if (nextLayer->isScrollableOrRubberbandable())
             return true;
     }
 

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -439,6 +439,7 @@
     virtual Scrollbar* horizontalScrollbar() const override { return m_hBar.get(); }
     virtual Scrollbar* verticalScrollbar() const override { return m_vBar.get(); }
     virtual ScrollableArea* enclosingScrollableArea() const override;
+    virtual bool isScrollableOrRubberbandable() override;
     virtual bool hasScrollableOrRubberbandableAncestor() override;
 #if ENABLE(CSS_SCROLL_SNAP)
     virtual void updateSnapOffsets() override;

Modified: trunk/Source/WebCore/rendering/RenderLayerModelObject.h (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderLayerModelObject.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderLayerModelObject.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -49,7 +49,7 @@
     // The query rect is given in local coordinate system.
     virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { return false; }
 
-    virtual bool isScrollableOrRubberbandable() const { return false; }
+    virtual bool isScrollableOrRubberbandableBox() const { return false; }
 
 protected:
     RenderLayerModelObject(Element&, PassRef<RenderStyle>, unsigned baseTypeFlags);

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2014-09-05 18:54:37 UTC (rev 173320)
@@ -787,6 +787,11 @@
     return 0;
 }
 
+bool RenderListBox::isScrollableOrRubberbandable()
+{
+    return m_vBar;
+}
+
 bool RenderListBox::hasScrollableOrRubberbandableAncestor()
 {
     return enclosingLayer() && enclosingLayer()->hasScrollableOrRubberbandableAncestor();

Modified: trunk/Source/WebCore/rendering/RenderListBox.h (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderListBox.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderListBox.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -131,6 +131,7 @@
     virtual bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
 
     virtual ScrollableArea* enclosingScrollableArea() const override;
+    virtual bool isScrollableOrRubberbandable() override;
     virtual bool hasScrollableOrRubberbandableAncestor() override;
     virtual IntRect scrollableAreaBoundingBox() const override;
 

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2014-09-05 18:54:37 UTC (rev 173320)
@@ -708,7 +708,7 @@
         rect = LayoutRect(layer()->transform()->mapRect(snapRectToDevicePixels(rect, document().deviceScaleFactor())));
 }
 
-bool RenderView::isScrollableOrRubberbandable() const
+bool RenderView::isScrollableOrRubberbandableBox() const
 {
     // The main frame might be allowed to rubber-band even if there is no content to scroll to. This is unique to
     // the main frame; subframes and overflow areas have to have content that can be scrolled to in order to rubber-band.

Modified: trunk/Source/WebCore/rendering/RenderView.h (173319 => 173320)


--- trunk/Source/WebCore/rendering/RenderView.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebCore/rendering/RenderView.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -299,7 +299,7 @@
     friend class LayoutStateMaintainer;
     friend class LayoutStateDisabler;
 
-    virtual bool isScrollableOrRubberbandable() const override;
+    virtual bool isScrollableOrRubberbandableBox() const override;
 
     void splitSelectionBetweenSubtrees(RenderObject* start, int startPos, RenderObject* end, int endPos, SelectionRepaintMode blockRepaintMode);
     void clearSubtreeSelection(const SelectionSubtreeRoot&, SelectionRepaintMode, OldSelectionData&);

Modified: trunk/Source/WebKit2/ChangeLog (173319 => 173320)


--- trunk/Source/WebKit2/ChangeLog	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebKit2/ChangeLog	2014-09-05 18:54:37 UTC (rev 173320)
@@ -1,3 +1,14 @@
+2014-09-05  Beth Dakin  <[email protected]>
+
+        ScrollablArea::handleWheelEvent() should return early if the ScrollableArea is not 
+        actually scrollable
+        https://bugs.webkit.org/show_bug.cgi?id=136558
+
+        Reviewed by Simon Fraser.
+
+        New ScrollableArea virtual function.
+        * WebProcess/Plugins/PDF/PDFPlugin.h:
+
 2014-09-04  Gyuyoung Kim  <[email protected]>
 
         Unreviewed, speculative build fix on GTK port since r173305.

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (173319 => 173320)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h	2014-09-05 18:42:34 UTC (rev 173319)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h	2014-09-05 18:54:37 UTC (rev 173320)
@@ -175,6 +175,7 @@
     // ScrollableArea functions.
     virtual WebCore::IntRect scrollCornerRect() const override;
     virtual WebCore::ScrollableArea* enclosingScrollableArea() const override;
+    virtual bool isScrollableOrRubberbandable() override { return true; }
     virtual bool hasScrollableOrRubberbandableAncestor() override { return true; }
     virtual WebCore::IntRect scrollableAreaBoundingBox() const override;
     virtual void setScrollOffset(const WebCore::IntPoint&) override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to