[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

bweinstein at apple.com bweinstein at apple.com
Thu Apr 8 00:42:52 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit b8133c3815543668789dd5daea4f377401799d11
Author: bweinstein at apple.com <bweinstein at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Dec 18 21:57:19 2009 +0000

    Fixes <http://webkit.org/b/32613>.
    REGRESSION (r52008): Middle-clicking on a linked image starts a pan scroll,
    but should follow the link instead.
    
    Reviewed by Adam Roben.
    
    WebCore:
    
    The node itself isn't the only possible node that can be a link (that was the
    original check), any of its ancestors could be links as well, we need to climb
    up the tree to see. Created a new function (enclosingAnchorNode), that finds a
    node's enclosing anchor element (if it exists), that we can share between RenderLayer
    and Node, and also added tests that test pan scrolling behavior in image maps.
    
    Tests: platform/win/fast/events/panScroll-image-no-scroll.html
           platform/win/fast/events/panScroll-imageMap-href-no-scroll.html
           platform/win/fast/events/panScroll-imageMap-noHref-scroll.html
    
    * dom/Node.cpp:
    (WebCore::Node::enclosingAnchorNode):
    (WebCore::Node::defaultEventHandler):
    * dom/Node.h:
    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::hitTest):
    
    LayoutTests:
    
    Added tests that test pan scrolling behavior when you middle click on images with
    links, and if you click on parts on image maps that are links, and that aren't.
    
    * platform/win/fast/events/panScroll-image-no-scroll-expected.txt: Added.
    * platform/win/fast/events/panScroll-image-no-scroll.html: Added.
    * platform/win/fast/events/panScroll-imageMap-href-no-scroll-expected.txt: Added.
    * platform/win/fast/events/panScroll-imageMap-href-no-scroll.html: Added.
    * platform/win/fast/events/panScroll-imageMap-noHref-scroll-expected.txt: Added.
    * platform/win/fast/events/panScroll-imageMap-noHref-scroll.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52341 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index aaa8c69..50e6e16 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2009-12-18  Brian Weinstein  <bweinstein at apple.com>
+
+        Reviewed by Adam Roben.
+        
+        Fixes <http://webkit.org/b/32613>.
+        REGRESSION (r52008): Middle-clicking on a linked image starts a pan scroll,
+        but should follow the link instead.
+
+        Added tests that test pan scrolling behavior when you middle click on images with
+        links, and if you click on parts on image maps that are links, and that aren't.
+
+        * platform/win/fast/events/panScroll-image-no-scroll-expected.txt: Added.
+        * platform/win/fast/events/panScroll-image-no-scroll.html: Added.
+        * platform/win/fast/events/panScroll-imageMap-href-no-scroll-expected.txt: Added.
+        * platform/win/fast/events/panScroll-imageMap-href-no-scroll.html: Added.
+        * platform/win/fast/events/panScroll-imageMap-noHref-scroll-expected.txt: Added.
+        * platform/win/fast/events/panScroll-imageMap-noHref-scroll.html: Added.
+
 2009-12-18  Kenneth Russell  <kbr at google.com>
 
         Reviewed by Darin Fisher.
diff --git a/LayoutTests/platform/win/fast/events/panScroll-image-no-scroll-expected.txt b/LayoutTests/platform/win/fast/events/panScroll-image-no-scroll-expected.txt
new file mode 100644
index 0000000..f800e37
--- /dev/null
+++ b/LayoutTests/platform/win/fast/events/panScroll-image-no-scroll-expected.txt
@@ -0,0 +1,4 @@
+
+Test for bug 32399 This tests that middle clicking on an image within a link doesn't start to scroll.
+
+Success! Div with overflow was not scrolled
diff --git a/LayoutTests/platform/win/fast/events/panScroll-image-no-scroll.html b/LayoutTests/platform/win/fast/events/panScroll-image-no-scroll.html
new file mode 100644
index 0000000..8d716a2
--- /dev/null
+++ b/LayoutTests/platform/win/fast/events/panScroll-image-no-scroll.html
@@ -0,0 +1,40 @@
+<html>
+    <head>
+        <title>Pan Scrolling Test</title>
+    </head>
+    <body>
+        <script>
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.waitUntilDone();
+            }
+        </script>
+        <div id="overflow" style="width:500px; height:150px; overflow:auto; border:2px solid red; padding:10px">
+            <a href="#"><img src="" width="100px" height="100px"></img></a>
+            <h1>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32399">bug 32399</a> This tests that middle
+            clicking on an image within a link doesn't start to scroll.</h1>
+        </div>
+        <p>
+        <div id="console"></div>
+        <script>
+            if (window.eventSender)
+            {
+                eventSender.mouseMoveTo(50, 50);
+                eventSender.mouseDown(1);
+                eventSender.mouseUp(1);
+                eventSender.mouseMoveTo(50, 200);
+                setTimeout(finished, 500);
+            }
+            
+            function finished()
+            {
+                if (!document.getElementById('overflow').scrollTop)
+                    document.getElementById('console').innerHTML = "Success! Div with overflow was not scrolled";
+                else
+                    document.getElementById('console').innerHTML = "Fail! Div with overflow was scrolled";
+                
+                window.layoutTestController.notifyDone();
+            }
+        </script>
+    </body>
+</html>
diff --git a/LayoutTests/platform/win/fast/events/panScroll-imageMap-href-no-scroll-expected.txt b/LayoutTests/platform/win/fast/events/panScroll-imageMap-href-no-scroll-expected.txt
new file mode 100644
index 0000000..a265360
--- /dev/null
+++ b/LayoutTests/platform/win/fast/events/panScroll-imageMap-href-no-scroll-expected.txt
@@ -0,0 +1,4 @@
+ 
+Test for bug 32613 This tests that middle clicking on the part of an image map that does have a link will not scroll.
+
+Success! Div with overflow was not scrolled
diff --git a/LayoutTests/platform/win/fast/events/panScroll-imageMap-href-no-scroll.html b/LayoutTests/platform/win/fast/events/panScroll-imageMap-href-no-scroll.html
new file mode 100644
index 0000000..09db446
--- /dev/null
+++ b/LayoutTests/platform/win/fast/events/panScroll-imageMap-href-no-scroll.html
@@ -0,0 +1,44 @@
+<html>
+    <head>
+        <title>Pan Scrolling Test</title>
+    </head>
+    <body>
+        <script>
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.waitUntilDone();
+            }
+        </script>
+        <div id="overflow" style="width:500px; height:150px; overflow:auto; border:2px solid red; padding:10px">
+            <map name="navMap">
+                <area shape=rect coords="0,0,100,50" href=""> 
+            </map>
+            <img border="2" width="100" height="100" usemap="#navmap" ismap>
+            <h1>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32613">bug 32613</a> This tests that middle
+            clicking on the part of an image map that does have a link will not scroll.</h1>
+        </div>
+        <p>
+        <div id="console"></div>
+        <script>
+            if (window.eventSender)
+            {
+                // 50, 50 is inside the area part of the map with the href.
+                eventSender.mouseMoveTo(50, 50);
+                eventSender.mouseDown(1);
+                eventSender.mouseMoveTo(50, 200);
+                setTimeout(finished, 500);
+            }
+            
+            function finished()
+            {
+                eventSender.mouseUp(1);
+                if (!document.getElementById('overflow').scrollTop)
+                    document.getElementById('console').innerHTML = "Success! Div with overflow was not scrolled";
+                else
+                    document.getElementById('console').innerHTML = "Fail! Div with overflow was scrolled";
+                
+                window.layoutTestController.notifyDone();
+            }
+        </script>
+    </body>
+</html>
diff --git a/LayoutTests/platform/win/fast/events/panScroll-imageMap-noHref-scroll-expected.txt b/LayoutTests/platform/win/fast/events/panScroll-imageMap-noHref-scroll-expected.txt
new file mode 100644
index 0000000..8355580
--- /dev/null
+++ b/LayoutTests/platform/win/fast/events/panScroll-imageMap-noHref-scroll-expected.txt
@@ -0,0 +1,4 @@
+ 
+Test for bug 32613 This tests that middle clicking on the part of an image map that doesn't have a link will scroll.
+
+Success! Div with overflow was scrolled
diff --git a/LayoutTests/platform/win/fast/events/panScroll-imageMap-noHref-scroll.html b/LayoutTests/platform/win/fast/events/panScroll-imageMap-noHref-scroll.html
new file mode 100644
index 0000000..bfaf9e2
--- /dev/null
+++ b/LayoutTests/platform/win/fast/events/panScroll-imageMap-noHref-scroll.html
@@ -0,0 +1,44 @@
+<html>
+    <head>
+        <title>Pan Scrolling Test</title>
+    </head>
+    <body>
+        <script>
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.waitUntilDone();
+            }
+        </script>
+        <div id="overflow" style="width:500px; height:150px; overflow:auto; border:2px solid red; padding:10px">
+            <map name="navMap">
+                <area shape=rect coords="0,0,100,50" href=""> 
+            </map>
+            <img border="2" width="100" height="100" usemap="#navmap" ismap>
+            <h1>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32613">bug 32613</a> This tests that middle
+            clicking on the part of an image map that doesn't have a link will scroll.</h1>
+        </div>
+        <p>
+        <div id="console"></div>
+        <script>
+            if (window.eventSender)
+            {
+                // 50, 100 is not inside the area part of the map with the href (but is in the image map).
+                eventSender.mouseMoveTo(50, 100);
+                eventSender.mouseDown(1);
+                eventSender.mouseMoveTo(50, 200);
+                setTimeout(finished, 500);
+            }
+            
+            function finished()
+            {
+                eventSender.mouseUp(1);
+                if (!document.getElementById('overflow').scrollTop)
+                    document.getElementById('console').innerHTML = "Success! Div with overflow was scrolled";
+                else
+                    document.getElementById('console').innerHTML = "Fail! Div with overflow was not scrolled";
+                
+                window.layoutTestController.notifyDone();
+            }
+        </script>
+    </body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index dafce65..f86d32c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2009-12-18  Brian Weinstein  <bweinstein at apple.com>
+
+        Reviewed by Adam Roben.
+
+        Fixes <http://webkit.org/b/32613>.
+        REGRESSION (r52008): Middle-clicking on a linked image starts a pan scroll,
+        but should follow the link instead.
+
+        The node itself isn't the only possible node that can be a link (that was the
+        original check), any of its ancestors could be links as well, we need to climb
+        up the tree to see. Created a new function (enclosingAnchorNode), that finds a
+        node's enclosing anchor element (if it exists), that we can share between RenderLayer
+        and Node, and also added tests that test pan scrolling behavior in image maps.
+
+        Tests: platform/win/fast/events/panScroll-image-no-scroll.html
+               platform/win/fast/events/panScroll-imageMap-href-no-scroll.html
+               platform/win/fast/events/panScroll-imageMap-noHref-scroll.html
+
+        * dom/Node.cpp:
+        (WebCore::Node::enclosingAnchorNode):
+        (WebCore::Node::defaultEventHandler):
+        * dom/Node.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::hitTest):
+
 2009-12-18  Benjamin Otte  <otte at gnome.org>
 
         Reviewed by Xan Lopez.
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index 490d015..057adf0 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -2288,6 +2288,19 @@ ContainerNode* Node::eventParentNode()
     return static_cast<ContainerNode*>(parent);
 }
 
+Node* Node::enclosingLinkEventParentOrSelf()
+{
+    for (Node* node = this; node; node = node->eventParentNode()) {
+        // For imagemaps, the enclosing link node is the associated area element not the image itself.
+        // So we don't let images be the enclosingLinkNode, even though isLink sometimes returns true
+        // for them.
+        if (node->isLink() && !node->hasTagName(imgTag))
+            return node;
+    }
+
+    return 0;
+}
+
 // --------
 
 ScriptExecutionContext* Node::scriptExecutionContext() const
@@ -2831,9 +2844,11 @@ void Node::defaultEventHandler(Event* event)
 #if ENABLE(PAN_SCROLLING)
     } else if (eventType == eventNames().mousedownEvent) {
         MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
-        if (mouseEvent->button() == MiddleButton && !this->isLink()) {
-            RenderObject* renderer = this->renderer();
+        if (mouseEvent->button() == MiddleButton) {
+            if (enclosingLinkEventParentOrSelf())
+                return;
 
+            RenderObject* renderer = this->renderer();
             while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->canBeScrolledAndHasScrollableArea()))
                 renderer = renderer->parent();
 
diff --git a/WebCore/dom/Node.h b/WebCore/dom/Node.h
index 843643b..5714df5 100644
--- a/WebCore/dom/Node.h
+++ b/WebCore/dom/Node.h
@@ -201,6 +201,9 @@ public:
     // The node's parent for the purpose of event capture and bubbling.
     virtual ContainerNode* eventParentNode();
 
+    // Returns the enclosing event parent node (or self) that, when clicked, would trigger a navigation.
+    Node* enclosingLinkEventParentOrSelf();
+
     // Node ancestors when concerned about event flow
     void eventAncestors(Vector<RefPtr<ContainerNode> > &ancestors);
 
diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp
index cbd7a78..4b7d635 100644
--- a/WebCore/rendering/RenderLayer.cpp
+++ b/WebCore/rendering/RenderLayer.cpp
@@ -2346,15 +2346,10 @@ bool RenderLayer::hitTest(const HitTestRequest& request, HitTestResult& result)
         }
     }
 
-    // Now determine if the result is inside an anchor; make sure an image map wins if
-    // it already set URLElement and only use the innermost.
+    // Now determine if the result is inside an anchor - if the urlElement isn't already set.
     Node* node = result.innerNode();
-    while (node) {
-        // for imagemaps, URLElement is the associated area element not the image itself
-        if (node->isLink() && !result.URLElement() && !node->hasTagName(imgTag))
-            result.setURLElement(static_cast<Element*>(node));
-        node = node->eventParentNode();
-    }
+    if (node && !result.URLElement())
+        result.setURLElement(static_cast<Element*>(node->enclosingLinkEventParentOrSelf()));
 
     // Next set up the correct :hover/:active state along the new chain.
     updateHoverActiveState(request, result);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list