cleanup: Change some code to be cleaner, more readable and style conforming
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 20:59:10 +0000 (20:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 20:59:10 +0000 (20:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103543

Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2012-11-28
Reviewed by Antonio Gomes.

Use more appropriate function name and more meaningful variable names to make the code cleaner.
This is covered by existing tests. This does not make any behavioural changes, so no new tests.

* page/EventHandler.cpp:
(WebCore::closestScrollableNodeInDocumentIfPossible):
(WebCore::EventHandler::handleWheelEvent):

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

Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp

index 78e7bf4..2d97c52 100644 (file)
@@ -1,3 +1,17 @@
+2012-11-28  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        cleanup: Change some code to be cleaner, more readable and style conforming
+        https://bugs.webkit.org/show_bug.cgi?id=103543
+
+        Reviewed by Antonio Gomes.
+
+        Use more appropriate function name and more meaningful variable names to make the code cleaner.
+        This is covered by existing tests. This does not make any behavioural changes, so no new tests.
+
+        * page/EventHandler.cpp:
+        (WebCore::closestScrollableNodeInDocumentIfPossible):
+        (WebCore::EventHandler::handleWheelEvent):
+
 2012-11-28  Alexandru Chiculita  <achicu@adobe.com>
 
         [CSS Regions] Crash when using hover and first-letter inside a flow-thread
index db7b143..fd4c78b 100644 (file)
@@ -279,18 +279,16 @@ static inline bool scrollNode(float delta, ScrollGranularity granularity, Scroll
     return enclosingBox->scroll(delta < 0 ? negativeDirection : positiveDirection, granularity, absDelta, stopNode);
 }
 
-static Node* getClosestScrollableNodeInDocumentIfPossible(Node* node)
+static Node* closestScrollableNodeInDocumentIfPossible(Node* node)
 {
-    Node* firstNode = node;
-    while (node) {
-        if (node->isDocumentNode())
-            return firstNode;
-        RenderObject* renderer = node->renderer();
+    for (Node* scrollableNode = node; scrollableNode; scrollableNode = scrollableNode->parentNode()) {
+        if (scrollableNode->isDocumentNode())
+            break;
+        RenderObject* renderer = scrollableNode->renderer();
         if (renderer && renderer->isBox() && toRenderBox(renderer)->canBeScrolledAndHasScrollableArea())
-            return node;
-        node = node->parentNode();
+            return scrollableNode;
     }
-    return firstNode;
+    return node;
 }
 
 #if ENABLE(GESTURE_EVENTS)
@@ -2447,7 +2445,7 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e)
 
     if (useLatchedWheelEventNode) {
         if (!m_latchedWheelEventNode) {
-            m_latchedWheelEventNode = getClosestScrollableNodeInDocumentIfPossible(result.innerNode());
+            m_latchedWheelEventNode = closestScrollableNodeInDocumentIfPossible(result.innerNode());
             m_widgetIsLatched = result.isOverWidget();
         }