Title: [166630] trunk
Revision
166630
Author
[email protected]
Date
2014-04-01 21:49:28 -0700 (Tue, 01 Apr 2014)

Log Message

willReveal edge events should be hooked up for overflow:scroll
https://bugs.webkit.org/show_bug.cgi?id=131071
-and corresponding-
<rdar://problem/16190392>

Reviewed by Sam Weinig.

Source/WebCore: 

This patch moves the will reveal logic from FrameView to Document so that it can 
be shared for RenderLayers.

This is mostly just a moved function, but now the function takes an Element* that 
represents the target of the event if the target is not the window.
* dom/Document.cpp:
(WebCore::Document::sendWillRevealEdgeEventsIfNeeded):
* dom/Document.h:

No longer implement sendWillRevealEdgeEventsIfNeeded() on FrameView or 
ScrollableArea at all. Call into Document instead.
* page/FrameView.cpp:
(WebCore::FrameView::scrollPositionChanged):
(WebCore::FrameView::sendWillRevealEdgeEventsIfNeeded): Deleted.
* page/FrameView.h:
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::sendWillRevealEdgeEventsIfNeeded): Deleted.

Call sendWillRevealEdgeEventsIfNeeded() after sending scroll events. 
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo):

LayoutTests: 

* fast/events/will-reveal-edge-on-div-expected.txt: Added.
* fast/events/will-reveal-edge-on-div.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (166629 => 166630)


--- trunk/LayoutTests/ChangeLog	2014-04-02 03:36:29 UTC (rev 166629)
+++ trunk/LayoutTests/ChangeLog	2014-04-02 04:49:28 UTC (rev 166630)
@@ -1,3 +1,15 @@
+2014-04-01  Beth Dakin  <[email protected]>
+
+        willReveal edge events should be hooked up for overflow:scroll
+        https://bugs.webkit.org/show_bug.cgi?id=131071
+        -and corresponding-
+        <rdar://problem/16190392>
+
+        Reviewed by Sam Weinig.
+
+        * fast/events/will-reveal-edge-on-div-expected.txt: Added.
+        * fast/events/will-reveal-edge-on-div.html: Added.
+
 2014-04-01  Jon Honeycutt  <[email protected]>
 
         Crash in WebCore::RenderLayer::FilterInfo::updateReferenceFilterClients

Added: trunk/LayoutTests/fast/events/will-reveal-edge-on-div-expected.txt (0 => 166630)


--- trunk/LayoutTests/fast/events/will-reveal-edge-on-div-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/will-reveal-edge-on-div-expected.txt	2014-04-02 04:49:28 UTC (rev 166630)
@@ -0,0 +1,10 @@
+This tests that we can listen for webkitwillrevealbottom, webkitwillrevealtop, webkitwillrevealleft, and webkitwillrevealright
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+All edges were revealed!
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/will-reveal-edge-on-div.html (0 => 166630)


--- trunk/LayoutTests/fast/events/will-reveal-edge-on-div.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/will-reveal-edge-on-div.html	2014-04-02 04:49:28 UTC (rev 166630)
@@ -0,0 +1,83 @@
+<html>
+<script src=""
+
+<style>
+#scrolly-div {
+    width:200px;
+    height:200px;
+    border:2px solid black;
+    overflow:scroll;
+}
+
+.big {
+    background-color:purple;
+    width:600px;
+    height:600px;
+}
+</style>
+
+<script type="text/_javascript_">
+description('This tests that we can listen for webkitwillrevealbottom, webkitwillrevealtop, webkitwillrevealleft, and webkitwillrevealright');
+
+var triggeredWillRevealBottom = false;
+var triggeredWillRevealTop = false;
+var triggeredWillRevealRight = false;
+var triggeredWillRevealLeft = false;
+
+function bottomRevealed()
+{
+    triggeredWillRevealBottom = true;
+    var scrolly = document.getElementById("scrolly-div");
+    scrolly.scrollTop = 0;
+    checkComplete();
+}
+
+function topRevealed()
+{
+    triggeredWillRevealTop = true;
+    var scrolly = document.getElementById("scrolly-div");
+    scrolly.scrollLeft = 600;
+    checkComplete();
+}
+
+function rightRevealed()
+{
+    triggeredWillRevealRight = true;
+    var scrolly = document.getElementById("scrolly-div");
+    scrolly.scrollLeft = 0;
+    checkComplete();
+}
+
+function leftRevealed()
+{
+    triggeredWillRevealLeft = true;
+    checkComplete();
+}
+
+function checkComplete()
+{
+    if (triggeredWillRevealBottom && triggeredWillRevealTop && triggeredWillRevealRight && triggeredWillRevealLeft) {
+        debug('All edges were revealed!');
+        finishJSTest();
+    }
+}
+
+var jsTestIsAsync = true;
+
+function runTest() {
+    var scrolly = document.getElementById("scrolly-div");
+    scrolly.addEventListener('webkitwillrevealbottom', bottomRevealed, false);
+    scrolly.addEventListener('webkitwillrevealtop', topRevealed, false);
+    scrolly.addEventListener('webkitwillrevealright', rightRevealed, false);
+    scrolly.addEventListener('webkitwillrevealleft', leftRevealed, false);
+    scrolly.scrollTop = 600;
+}
+</script>
+
+<body _onload_="runTest()">
+    <div id="scrolly-div">
+        <div class="big"></div>
+    </div>
+    <script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (166629 => 166630)


--- trunk/Source/WebCore/ChangeLog	2014-04-02 03:36:29 UTC (rev 166629)
+++ trunk/Source/WebCore/ChangeLog	2014-04-02 04:49:28 UTC (rev 166630)
@@ -1,3 +1,34 @@
+2014-04-01  Beth Dakin  <[email protected]>
+
+        willReveal edge events should be hooked up for overflow:scroll
+        https://bugs.webkit.org/show_bug.cgi?id=131071
+        -and corresponding-
+        <rdar://problem/16190392>
+
+        Reviewed by Sam Weinig.
+
+        This patch moves the will reveal logic from FrameView to Document so that it can 
+        be shared for RenderLayers.
+
+        This is mostly just a moved function, but now the function takes an Element* that 
+        represents the target of the event if the target is not the window.
+        * dom/Document.cpp:
+        (WebCore::Document::sendWillRevealEdgeEventsIfNeeded):
+        * dom/Document.h:
+
+        No longer implement sendWillRevealEdgeEventsIfNeeded() on FrameView or 
+        ScrollableArea at all. Call into Document instead.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollPositionChanged):
+        (WebCore::FrameView::sendWillRevealEdgeEventsIfNeeded): Deleted.
+        * page/FrameView.h:
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::sendWillRevealEdgeEventsIfNeeded): Deleted.
+
+        Call sendWillRevealEdgeEventsIfNeeded() after sending scroll events. 
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollTo):
+
 2014-04-01  Jon Honeycutt  <[email protected]>
 
         Crash in WebCore::RenderLayer::FilterInfo::updateReferenceFilterClients

Modified: trunk/Source/WebCore/dom/Document.cpp (166629 => 166630)


--- trunk/Source/WebCore/dom/Document.cpp	2014-04-02 03:36:29 UTC (rev 166629)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-04-02 04:49:28 UTC (rev 166630)
@@ -5617,7 +5617,78 @@
     m_scriptedAnimationController.clear();
 }
 #endif
+    
+void Document::sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition, const IntRect& visibleRect, const IntSize& contentsSize, Element* target)
+{
+    // For each edge (top, bottom, left and right), send the will reveal edge event for that direction
+    // if newPosition is at or beyond the notification point, if the scroll direction is heading in the
+    // direction of that edge point, and if oldPosition is before the notification point (which indicates
+    // that this is the first moment that we know we crossed the magic line).
+    
+#if ENABLE(WILL_REVEAL_EDGE_EVENTS)
+    
+    int willRevealBottomNotificationPoint = std::max(0, contentsSize.height() - 2 *  visibleRect.height());
+    int willRevealTopNotificationPoint = visibleRect.height();
 
+    // Bottom edge.
+    if (newPosition.y() >= willRevealBottomNotificationPoint && newPosition.y() > oldPosition.y()
+        && willRevealBottomNotificationPoint >= oldPosition.y()) {
+        RefPtr<Event> willRevealEvent = Event::create(eventNames().webkitwillrevealbottomEvent, false, false);
+        if (!target)
+            enqueueWindowEvent(willRevealEvent.release());
+        else {
+            willRevealEvent->setTarget(target);
+            m_eventQueue.enqueueEvent(willRevealEvent.release());
+        }
+    }
+
+    // Top edge.
+    if (newPosition.y() <= willRevealTopNotificationPoint && newPosition.y() < oldPosition.y()
+        && willRevealTopNotificationPoint <= oldPosition.y()) {
+        RefPtr<Event> willRevealEvent = Event::create(eventNames().webkitwillrevealtopEvent, false, false);
+        if (!target)
+            enqueueWindowEvent(willRevealEvent.release());
+        else {
+            willRevealEvent->setTarget(target);
+            m_eventQueue.enqueueEvent(willRevealEvent.release());
+        }
+    }
+
+    int willRevealRightNotificationPoint = std::max(0, contentsSize.width() - 2 * visibleRect.width());
+    int willRevealLeftNotificationPoint = visibleRect.width();
+
+    // Right edge.
+    if (newPosition.x() >= willRevealRightNotificationPoint && newPosition.x() > oldPosition.x()
+        && willRevealRightNotificationPoint >= oldPosition.x()) {
+        RefPtr<Event> willRevealEvent = Event::create(eventNames().webkitwillrevealrightEvent, false, false);
+        if (!target)
+            enqueueWindowEvent(willRevealEvent.release());
+        else {
+            willRevealEvent->setTarget(target);
+            m_eventQueue.enqueueEvent(willRevealEvent.release());
+        }
+    }
+
+    // Left edge.
+    if (newPosition.x() <= willRevealLeftNotificationPoint && newPosition.x() < oldPosition.x()
+        && willRevealLeftNotificationPoint <= oldPosition.x()) {
+        RefPtr<Event> willRevealEvent = Event::create(eventNames().webkitwillrevealleftEvent, false, false);
+        if (!target)
+            enqueueWindowEvent(willRevealEvent.release());
+        else {
+            willRevealEvent->setTarget(target);
+            m_eventQueue.enqueueEvent(willRevealEvent.release());
+        }
+    }
+#else
+    UNUSED_PARAM(oldPosition);
+    UNUSED_PARAM(newPosition);
+    UNUSED_PARAM(visibleRect);
+    UNUSED_PARAM(contentsSize);
+    UNUSED_PARAM(target);
+#endif
+}
+
 #if !PLATFORM(IOS)
 #if ENABLE(TOUCH_EVENTS)
 PassRefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force, ExceptionCode&) const

Modified: trunk/Source/WebCore/dom/Document.h (166629 => 166630)


--- trunk/Source/WebCore/dom/Document.h	2014-04-02 03:36:29 UTC (rev 166629)
+++ trunk/Source/WebCore/dom/Document.h	2014-04-02 04:49:28 UTC (rev 166630)
@@ -1174,6 +1174,8 @@
     void serviceScriptedAnimations(double monotonicAnimationStartTime);
 #endif
 
+    void sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition, const IntRect& visibleRect, const IntSize& contentsSize, Element* target = nullptr);
+
     virtual EventTarget* errorEventTarget() override;
     virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<Inspector::ScriptCallStack>) override;
 

Modified: trunk/Source/WebCore/page/FrameView.cpp (166629 => 166630)


--- trunk/Source/WebCore/page/FrameView.cpp	2014-04-02 03:36:29 UTC (rev 166629)
+++ trunk/Source/WebCore/page/FrameView.cpp	2014-04-02 04:49:28 UTC (rev 166630)
@@ -2009,9 +2009,10 @@
 {
     frame().eventHandler().sendScrollEvent();
     frame().eventHandler().dispatchFakeMouseMoveEventSoon();
+    
+    if (Document* document = frame().document())
+        document->sendWillRevealEdgeEventsIfNeeded(oldPosition, newPosition, visibleContentRect(), contentsSize());
 
-    sendWillRevealEdgeEventsIfNeeded(oldPosition, newPosition);
-
     if (RenderView* renderView = this->renderView()) {
         renderView->resumePausedImageAnimationsIfNeeded();
         if (renderView->usesCompositing())
@@ -2798,59 +2799,6 @@
 #endif
 }
 
-void FrameView::sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition)
-{
-    // For each edge (top, bottom, left and right), send the will reveal edge event for that direction
-    // if newPosition is at or beyond the notification point, if the scroll direction is heading in the
-    // direction of that edge point, and if oldPosition is before the notification point (which indicates
-    // that this is the first moment that we know we crossed the magic line).
-
-#if ENABLE(WILL_REVEAL_EDGE_EVENTS)
-    Document* document = frame().document();
-    if (!document)
-        return;
-
-    IntRect visibleRect = visibleContentRect();
-
-    int willRevealBottomNotificationPoint = std::max(0, contentsHeight() - 2 *  visibleRect.height());
-    int willRevealTopNotificationPoint = visibleRect.height();
-
-    // Bottom edge.
-    if (newPosition.y() >= willRevealBottomNotificationPoint && newPosition.y() > oldPosition.y()
-        && willRevealBottomNotificationPoint >= oldPosition.y()) {
-        RefPtr<Event> willRevealEvent = Event::create(eventNames().webkitwillrevealbottomEvent, false, false);
-        document->enqueueWindowEvent(willRevealEvent.release());
-    }
-
-    // Top edge.
-    if (newPosition.y() <= willRevealTopNotificationPoint && newPosition.y() < oldPosition.y()
-        && willRevealTopNotificationPoint <= oldPosition.y()) {
-        RefPtr<Event> willRevealEvent = Event::create(eventNames().webkitwillrevealtopEvent, false, false);
-        document->enqueueWindowEvent(willRevealEvent.release());
-    }
-
-    int willRevealRightNotificationPoint = std::max(0, contentsWidth() - 2 * visibleRect.width());
-    int willRevealLeftNotificationPoint = visibleRect.width();
-
-    // Right edge.
-    if (newPosition.x() >= willRevealRightNotificationPoint && newPosition.x() > oldPosition.x()
-        && willRevealRightNotificationPoint >= oldPosition.x()) {
-        RefPtr<Event> willRevealEvent = Event::create(eventNames().webkitwillrevealrightEvent, false, false);
-        document->enqueueWindowEvent(willRevealEvent.release());
-    }
-
-    // Left edge.
-    if (newPosition.x() <= willRevealLeftNotificationPoint && newPosition.x() < oldPosition.x()
-        && willRevealLeftNotificationPoint <= oldPosition.x()) {
-        RefPtr<Event> willRevealEvent = Event::create(eventNames().webkitwillrevealleftEvent, false, false);
-        document->enqueueWindowEvent(willRevealEvent.release());
-    }
-#else
-    UNUSED_PARAM(oldPosition);
-    UNUSED_PARAM(newPosition);
-#endif
-}
-
 void FrameView::willStartLiveResize()
 {
     ScrollView::willStartLiveResize();

Modified: trunk/Source/WebCore/page/FrameView.h (166629 => 166630)


--- trunk/Source/WebCore/page/FrameView.h	2014-04-02 03:36:29 UTC (rev 166629)
+++ trunk/Source/WebCore/page/FrameView.h	2014-04-02 04:49:28 UTC (rev 166630)
@@ -560,8 +560,6 @@
     virtual GraphicsLayer* layerForOverhangAreas() const override;
 #endif
 
-    void sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition);
-
     // Override scrollbar notifications to update the AXObject cache.
     virtual void didAddScrollbar(Scrollbar*, ScrollbarOrientation) override;
     virtual void willRemoveScrollbar(Scrollbar*, ScrollbarOrientation) override;

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (166629 => 166630)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2014-04-02 03:36:29 UTC (rev 166629)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2014-04-02 04:49:28 UTC (rev 166630)
@@ -255,8 +255,6 @@
     bool hasLayerForVerticalScrollbar() const;
     bool hasLayerForScrollCorner() const;
 
-    virtual void sendWillRevealEdgeEventsIfNeeded(const IntPoint&, const IntPoint&) { }
-
 private:
     virtual IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const;
     void scrollPositionChanged(const IntPoint&);

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (166629 => 166630)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-04-02 03:36:29 UTC (rev 166629)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-04-02 04:49:28 UTC (rev 166630)
@@ -2307,6 +2307,8 @@
 #endif
         return;
     }
+    
+    IntPoint oldPosition = IntPoint(m_scrollOffset);
     m_scrollOffset = newScrollOffset;
 
     InspectorInstrumentation::willScrollLayer(&renderer().frame());
@@ -2360,9 +2362,11 @@
 #endif
         renderer().repaintUsingContainer(repaintContainer, m_repaintRect);
 
-    // Schedule the scroll DOM event.
-    if (Element* element = renderer().element())
+    // Schedule the scroll and scroll-related DOM events.
+    if (Element* element = renderer().element()) {
         element->document().eventQueue().enqueueOrDispatchScrollEvent(*element);
+        element->document().sendWillRevealEdgeEventsIfNeeded(oldPosition, IntPoint(newScrollOffset), visibleContentRect(), contentsSize(), element);
+    }
 
     InspectorInstrumentation::didScrollLayer(&frame);
     if (scrollsOverflow())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to