Title: [86695] trunk
Revision
86695
Author
[email protected]
Date
2011-05-17 12:26:11 -0700 (Tue, 17 May 2011)

Log Message

2011-05-17  Andreas Kling  <[email protected]>

        Reviewed by Kenneth Rohde Christiansen.

        Area element doesn't update region when dynamically altered.
        https://bugs.webkit.org/show_bug.cgi?id=54636

        * fast/images/imagemap-dynamic-area-updates-expected.txt: Added.
        * fast/images/imagemap-dynamic-area-updates.html: Added.
        * fast/images/script-tests/imagemap-dynamic-area-updates.js: Added.
        (setArea):
        (checkForArea):
2011-05-17  Andreas Kling  <[email protected]>

        Reviewed by Kenneth Rohde Christiansen.

        Area element doesn't update region when dynamically altered.
        https://bugs.webkit.org/show_bug.cgi?id=54636

        Recompute the clickable region after the "shape" or "coords" attribute
        of an area element is changed.

        Test: fast/images/imagemap-dynamic-area-updates.html

        * html/HTMLAreaElement.cpp:
        (WebCore::HTMLAreaElement::parseMappedAttribute):
        (WebCore::HTMLAreaElement::invalidateCachedRegion):
        * html/HTMLAreaElement.h:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (86694 => 86695)


--- trunk/LayoutTests/ChangeLog	2011-05-17 19:00:51 UTC (rev 86694)
+++ trunk/LayoutTests/ChangeLog	2011-05-17 19:26:11 UTC (rev 86695)
@@ -1,3 +1,16 @@
+2011-05-17  Andreas Kling  <[email protected]>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Area element doesn't update region when dynamically altered.
+        https://bugs.webkit.org/show_bug.cgi?id=54636
+
+        * fast/images/imagemap-dynamic-area-updates-expected.txt: Added.
+        * fast/images/imagemap-dynamic-area-updates.html: Added.
+        * fast/images/script-tests/imagemap-dynamic-area-updates.js: Added.
+        (setArea):
+        (checkForArea):
+
 2011-05-09  Luiz Agostini  <[email protected]>
 
         Reviewed by Kenneth Rohde Christiansen.

Added: trunk/LayoutTests/fast/images/imagemap-dynamic-area-updates-expected.txt (0 => 86695)


--- trunk/LayoutTests/fast/images/imagemap-dynamic-area-updates-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/images/imagemap-dynamic-area-updates-expected.txt	2011-05-17 19:26:11 UTC (rev 86695)
@@ -0,0 +1,24 @@
+Test that when image map areas have their shape or coordinate dynamically altered, the clickable region changes.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS setArea('default', ''); checkForArea(50, 50) is true
+PASS setArea('rect', '0, 0, 100, 100'); checkForArea(50, 50) is true
+PASS setArea('rect', '0, 0, 100, 100'); checkForArea(150, 150) is false
+PASS setArea('rect', '200, 200, 300, 300'); checkForArea(50, 50) is false
+PASS setArea('rect', '200, 200, 300, 300'); checkForArea(250, 250) is true
+PASS setArea('circle', '100, 100, 50'); checkForArea(100, 100) is true
+PASS setArea('circle', '100, 100, 50'); checkForArea(120, 100) is true
+PASS setArea('circle', '100, 100, 50'); checkForArea(200, 100) is false
+PASS setArea('circle', '300, 300, 50'); checkForArea(100, 100) is false
+PASS setArea('circle', '300, 300, 50'); checkForArea(300, 300) is true
+PASS setArea('circle', '300, 300, 50'); checkForArea(320, 300) is true
+PASS setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(150, 150) is true
+PASS setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(100, 150) is false
+PASS setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(300, 300) is false
+PASS setArea('default', ''); checkForArea(300, 300) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/images/imagemap-dynamic-area-updates.html (0 => 86695)


--- trunk/LayoutTests/fast/images/imagemap-dynamic-area-updates.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/imagemap-dynamic-area-updates.html	2011-05-17 19:26:11 UTC (rev 86695)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/images/script-tests/imagemap-dynamic-area-updates.js (0 => 86695)


--- trunk/LayoutTests/fast/images/script-tests/imagemap-dynamic-area-updates.js	                        (rev 0)
+++ trunk/LayoutTests/fast/images/script-tests/imagemap-dynamic-area-updates.js	2011-05-17 19:26:11 UTC (rev 86695)
@@ -0,0 +1,72 @@
+description("Test that when image map areas have their shape or coordinate dynamically altered, the clickable region changes.");
+
+if (!window.eventSender)
+    debug("This test will only work properly inside DRT.");
+
+var image = document.createElement('img');
+image.setAttribute('usemap', '#m');
+image.style.width = '400px';
+image.style.height = '400px';
+image.style.border = '1px solid red';
+image.style.position = 'absolute';
+image.style.left = '0';
+image.style.top = '0';
+
+area = document.createElement('area');
+area.setAttribute('href', '#');
+area.setAttribute('onclick', 'areaClicked = true; return false;');
+
+areaClicked = false;
+
+var map = document.createElement('map');
+map.setAttribute('name', 'm');
+map.appendChild(area);
+
+document.body.appendChild(image);
+document.body.appendChild(map);
+
+function setArea(shape, coords)
+{
+    area.setAttribute('shape', shape);
+    area.setAttribute('coords', coords);
+}
+
+function checkForArea(x, y)
+{
+    if (!window.eventSender)
+        return false;
+
+    areaClicked = false;
+
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+
+    return areaClicked;
+}
+
+shouldBe("setArea('default', ''); checkForArea(50, 50)", "true");
+
+shouldBe("setArea('rect', '0, 0, 100, 100'); checkForArea(50, 50)", "true");
+shouldBe("setArea('rect', '0, 0, 100, 100'); checkForArea(150, 150)", "false");
+
+shouldBe("setArea('rect', '200, 200, 300, 300'); checkForArea(50, 50)", "false");
+shouldBe("setArea('rect', '200, 200, 300, 300'); checkForArea(250, 250)", "true");
+
+shouldBe("setArea('circle', '100, 100, 50'); checkForArea(100, 100)", "true");
+shouldBe("setArea('circle', '100, 100, 50'); checkForArea(120, 100)", "true");
+shouldBe("setArea('circle', '100, 100, 50'); checkForArea(200, 100)", "false");
+
+shouldBe("setArea('circle', '300, 300, 50'); checkForArea(100, 100)", "false");
+shouldBe("setArea('circle', '300, 300, 50'); checkForArea(300, 300)", "true");
+shouldBe("setArea('circle', '300, 300, 50'); checkForArea(320, 300)", "true");
+
+shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(150, 150)", "true");
+shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(100, 150)", "false");
+shouldBe("setArea('poly', '100, 100, 200, 100, 200, 200'); checkForArea(300, 300)", "false");
+
+shouldBe("setArea('default', ''); checkForArea(300, 300)", "true");
+
+document.body.removeChild(image);
+
+var successfullyParsed = true;

Modified: trunk/Source/WebCore/ChangeLog (86694 => 86695)


--- trunk/Source/WebCore/ChangeLog	2011-05-17 19:00:51 UTC (rev 86694)
+++ trunk/Source/WebCore/ChangeLog	2011-05-17 19:26:11 UTC (rev 86695)
@@ -1,3 +1,20 @@
+2011-05-17  Andreas Kling  <[email protected]>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Area element doesn't update region when dynamically altered.
+        https://bugs.webkit.org/show_bug.cgi?id=54636
+
+        Recompute the clickable region after the "shape" or "coords" attribute
+        of an area element is changed.
+
+        Test: fast/images/imagemap-dynamic-area-updates.html
+
+        * html/HTMLAreaElement.cpp:
+        (WebCore::HTMLAreaElement::parseMappedAttribute):
+        (WebCore::HTMLAreaElement::invalidateCachedRegion):
+        * html/HTMLAreaElement.h:
+
 2011-05-09  Luiz Agostini  <[email protected]>
 
         Reviewed by Kenneth Rohde Christiansen.

Modified: trunk/Source/WebCore/html/HTMLAreaElement.cpp (86694 => 86695)


--- trunk/Source/WebCore/html/HTMLAreaElement.cpp	2011-05-17 19:00:51 UTC (rev 86694)
+++ trunk/Source/WebCore/html/HTMLAreaElement.cpp	2011-05-17 19:26:11 UTC (rev 86695)
@@ -63,14 +63,21 @@
             m_shape = Poly;
         else if (equalIgnoringCase(attr->value(), "rect"))
             m_shape = Rect;
+        invalidateCachedRegion();
     } else if (attr->name() == coordsAttr) {
         m_coords = newCoordsArray(attr->value().string(), m_coordsLen);
+        invalidateCachedRegion();
     } else if (attr->name() == altAttr || attr->name() == accesskeyAttr) {
         // Do nothing.
     } else
         HTMLAnchorElement::parseMappedAttribute(attr);
 }
 
+void HTMLAreaElement::invalidateCachedRegion()
+{
+    m_lastSize = IntSize(-1, -1);
+}
+
 bool HTMLAreaElement::mapMouseEvent(int x, int y, const IntSize& size, HitTestResult& result)
 {
     if (m_lastSize != size) {

Modified: trunk/Source/WebCore/html/HTMLAreaElement.h (86694 => 86695)


--- trunk/Source/WebCore/html/HTMLAreaElement.h	2011-05-17 19:00:51 UTC (rev 86694)
+++ trunk/Source/WebCore/html/HTMLAreaElement.h	2011-05-17 19:26:11 UTC (rev 86695)
@@ -61,6 +61,7 @@
     
     enum Shape { Default, Poly, Rect, Circle, Unknown };
     Path getRegion(const IntSize&) const;
+    void invalidateCachedRegion();
 
     OwnPtr<Path> m_region;
     OwnArrayPtr<Length> m_coords;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to