[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

krit at webkit.org krit at webkit.org
Wed Dec 22 14:51:53 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit ca99060666f3bfd3cc7aa657e49b0662d972fff6
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 22 17:43:31 2010 +0000

    2010-10-22  Cosmin Truta  <ctruta at chromium.org>
    
            Reviewed by Nikolas Zimmermann.
    
            getBoundingClientRect does not work with SVG <text>
            https://bugs.webkit.org/show_bug.cgi?id=46775
    
            Dispatched the calls from Element::getBoundingClientRect to getBBox
            through SVGElement::boundingBox.
            Recognized SVGTextElement in addition to SVGStyledLocatableElement
            as a class that provides getBBox.
            Fixed the result of zooming: adjusted the getBoundingClientRect rectangle
            for absolute zoom, even for SVG elements.
    
            Additional cleanup task:
            Removed redundant overloads of SVGStyledTransformableElement
            methods: nearestViewportElement, farthestViewportElement, getBBox.
            These methods are already inherited from SVGStyledLocatableElement.
    
            Test: css3/zoom-coords.xhtml
    
            * WebCore.xcodeproj/project.pbxproj: Set role of SVGLocatable.h to private.
            * dom/Element.cpp:
            (Element::getBoundingClientRect): Used SVGElement::boundingBox.
            Adjusted coordinates for absolute zoom, for all kinds of elements.
            * svg/SVGElement.cpp:
            * svg/SVGElement.h:
            (SVGElement::boundingBox): Added.
            * svg/SVGStyledTransformableElement.cpp:
            * svg/SVGStyledTransformableElement.h:
            (SVGStyledTransformableElement::nearestViewportElement): Removed.
            (SVGStyledTransformableElement::farthestViewportElement): Removed.
            (SVGStyledTransformableElement::getBBox): Removed.
    2010-10-22  Cosmin Truta  <ctruta at chromium.org>
    
            Reviewed by Nikolas Zimmermann.
    
            getBoundingClientRect does not work with SVG <text>
            https://bugs.webkit.org/show_bug.cgi?id=46775
    
            Added coordinate checks on various zoomed-in and zoomed-out
            XHTML and SVG elements, using getBoundingClientRect.
    
            * css3/zoom-coords.xhtml: Added.
            * css3/zoom-coords-expected.txt: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70317 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index cb0233c..b7b208b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-10-22  Cosmin Truta  <ctruta at chromium.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        getBoundingClientRect does not work with SVG <text>
+        https://bugs.webkit.org/show_bug.cgi?id=46775
+
+        Added coordinate checks on various zoomed-in and zoomed-out
+        XHTML and SVG elements, using getBoundingClientRect.
+
+        * css3/zoom-coords.xhtml: Added.
+        * css3/zoom-coords-expected.txt: Added.
+
 2010-10-22  Adam Roben  <aroben at apple.com>
 
         Update Windows html5lib results after r70293
diff --git a/LayoutTests/css3/zoom-coords-expected.txt b/LayoutTests/css3/zoom-coords-expected.txt
new file mode 100644
index 0000000..7162390
--- /dev/null
+++ b/LayoutTests/css3/zoom-coords-expected.txt
@@ -0,0 +1,78 @@
+Test
+Test
+This test checks getBoundingClientRect() on zoomed HTML and SVG elements
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Checking HTML elements:
+
+PASS div1.left is 0
+PASS div1.top is 0
+PASS div1.width is 100
+PASS div1.height is 50
+PASS div1.right is 100
+PASS div1.bottom is 50
+
+PASS div2.left is 0
+PASS div2.top is 200
+PASS div2.width is 200
+PASS div2.height is 100
+PASS div2.right is 200
+PASS div2.bottom is 300
+
+Checking SVG elements:
+
+PASS svg1.left is 0
+PASS svg1.top is 75
+PASS svg1.width is 150
+PASS svg1.height is 50
+PASS svg1.right is 150
+PASS svg1.bottom is 125
+PASS rect1.left is 0
+PASS rect1.top is 75
+PASS rect1.width is 100
+PASS rect1.height is 50
+PASS rect1.right is 100
+PASS rect1.bottom is 125
+PASS image1.left is 100
+PASS image1.top is 75
+PASS image1.width is 50
+PASS image1.height is 25
+PASS image1.right is 150
+PASS image1.bottom is 100
+PASS text1.left == 100 is true
+PASS text1.top >= 75 is true
+PASS text1.width > 0 is true
+PASS text1.height > 0 is true
+PASS text1.right > 100 is true
+PASS text1.bottom > 75 is true
+
+PASS svg2.left is 600
+PASS svg2.top is 400
+PASS svg2.width is 300
+PASS svg2.height is 100
+PASS svg2.right is 900
+PASS svg2.bottom is 500
+PASS rect2.left is 600
+PASS rect2.top is 400
+PASS rect2.width is 200
+PASS rect2.height is 100
+PASS rect2.right is 800
+PASS rect2.bottom is 500
+PASS image2.left is 800
+PASS image2.top is 400
+PASS image2.width is 100
+PASS image2.height is 50
+PASS image2.right is 900
+PASS image2.bottom is 450
+PASS text2.left == 800 is true
+PASS text2.top >= 400 is true
+PASS text2.width > 0 is true
+PASS text2.height > 0 is true
+PASS text2.right > 800 is true
+PASS text2.bottom > 400 is true
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/css3/zoom-coords.xhtml b/LayoutTests/css3/zoom-coords.xhtml
new file mode 100644
index 0000000..41f6a9d
--- /dev/null
+++ b/LayoutTests/css3/zoom-coords.xhtml
@@ -0,0 +1,126 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink">
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/>
+<style type="text/css">
+    body { margin:0px; border:0px; padding:0px; }
+    #div1, #svg1 { zoom:200%; }
+    #div2, #svg2 { zoom:50%; }
+</style>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+
+<div id="div1" style="width:100px;height:50px;background-color:blue;"></div>
+<div id="div2" style="width:200px;height:100px;background-color:green;"></div>
+<svg id="svg1" xmlns="http://www.w3.org/2000/svg"
+     width="150px" height="50px" viewBox="0 0 150 100"
+     preserveAspectRatio="none">
+  <rect id="rect1" x="0" y="0" width="100px" height="100px" fill="yellow" />
+  <image id="image1" x="100px" y="0" width="50px" height="50px" xlink:href="../svg/dom/resources/magnify.png" />
+  <text id="text1" x="100px" y="75px">Test</text>
+</svg><svg id="svg2" xmlns="http://www.w3.org/2000/svg"
+     width="300px" height="100px" viewBox="0 0 150 100"
+     preserveAspectRatio="none">
+  <rect id="rect2" x="0" y="0" width="100px" height="100px" fill="orange" />
+  <image id="image2" x="100px" y="0" width="50px" height="50px" xlink:href="../svg/dom/resources/magnify.png" />
+  <text id="text2" x="100px" y="75px">Test</text>
+</svg>
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+
+description("This test checks getBoundingClientRect() on zoomed HTML and SVG elements");
+
+debug("Checking HTML elements:");
+debug("");
+
+var div1 = document.getElementById("div1").getBoundingClientRect();
+shouldBe('div1.left', '0');
+shouldBe('div1.top', '0');
+shouldBe('div1.width', '100');
+shouldBe('div1.height', '50');
+shouldBe('div1.right', '100');
+shouldBe('div1.bottom', '50');
+debug("");
+
+var div2 = document.getElementById("div2").getBoundingClientRect();
+shouldBe('div2.left', '0');
+shouldBe('div2.top', '200');
+shouldBe('div2.width', '200');
+shouldBe('div2.height', '100');
+shouldBe('div2.right', '200');
+shouldBe('div2.bottom', '300');
+debug("");
+
+debug("Checking SVG elements:");
+debug("");
+
+var svg1 = document.getElementById("svg1").getBoundingClientRect();
+shouldBe('svg1.left', '0');
+shouldBe('svg1.top', '75');
+shouldBe('svg1.width', '150');
+shouldBe('svg1.height', '50');
+shouldBe('svg1.right', '150');
+shouldBe('svg1.bottom', '125');
+var rect1 = document.getElementById("rect1").getBoundingClientRect();
+shouldBe('rect1.left', '0');
+shouldBe('rect1.top', '75');
+shouldBe('rect1.width', '100');
+shouldBe('rect1.height', '50');
+shouldBe('rect1.right', '100');
+shouldBe('rect1.bottom', '125');
+var image1 = document.getElementById("image1").getBoundingClientRect();
+shouldBe('image1.left', '100');
+shouldBe('image1.top', '75');
+shouldBe('image1.width', '50');
+shouldBe('image1.height', '25');
+shouldBe('image1.right', '150');
+shouldBe('image1.bottom', '100');
+var text1 = document.getElementById("text1").getBoundingClientRect();
+shouldBe('text1.left == 100', 'true');
+shouldBe('text1.top >= 75', 'true');
+shouldBe('text1.width > 0', 'true');
+shouldBe('text1.height > 0', 'true');
+shouldBe('text1.right > 100', 'true');
+shouldBe('text1.bottom > 75', 'true');
+debug("");
+
+var svg2 = document.getElementById("svg2").getBoundingClientRect();
+shouldBe('svg2.left', '600');
+shouldBe('svg2.top', '400');
+shouldBe('svg2.width', '300');
+shouldBe('svg2.height', '100');
+shouldBe('svg2.right', '900');
+shouldBe('svg2.bottom', '500');
+var rect2 = document.getElementById("rect2").getBoundingClientRect();
+shouldBe('rect2.left', '600');
+shouldBe('rect2.top', '400');
+shouldBe('rect2.width', '200');
+shouldBe('rect2.height', '100');
+shouldBe('rect2.right', '800');
+shouldBe('rect2.bottom', '500');
+var image2 = document.getElementById("image2").getBoundingClientRect();
+shouldBe('image2.left', '800');
+shouldBe('image2.top', '400');
+shouldBe('image2.width', '100');
+shouldBe('image2.height', '50');
+shouldBe('image2.right', '900');
+shouldBe('image2.bottom', '450');
+var text2 = document.getElementById("text2").getBoundingClientRect();
+shouldBe('text2.left == 800', 'true');
+shouldBe('text2.top >= 400', 'true');
+shouldBe('text2.width > 0', 'true');
+shouldBe('text2.height > 0', 'true');
+shouldBe('text2.right > 800', 'true');
+shouldBe('text2.bottom > 400', 'true');
+debug("");
+
+successfullyParsed = true;
+
+</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index da71a3a..b4cfa76 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,37 @@
+2010-10-22  Cosmin Truta  <ctruta at chromium.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        getBoundingClientRect does not work with SVG <text>
+        https://bugs.webkit.org/show_bug.cgi?id=46775
+
+        Dispatched the calls from Element::getBoundingClientRect to getBBox
+        through SVGElement::boundingBox.
+        Recognized SVGTextElement in addition to SVGStyledLocatableElement
+        as a class that provides getBBox.
+        Fixed the result of zooming: adjusted the getBoundingClientRect rectangle
+        for absolute zoom, even for SVG elements.
+
+        Additional cleanup task:
+        Removed redundant overloads of SVGStyledTransformableElement
+        methods: nearestViewportElement, farthestViewportElement, getBBox.
+        These methods are already inherited from SVGStyledLocatableElement.
+
+        Test: css3/zoom-coords.xhtml
+
+        * WebCore.xcodeproj/project.pbxproj: Set role of SVGLocatable.h to private.
+        * dom/Element.cpp:
+        (Element::getBoundingClientRect): Used SVGElement::boundingBox.
+        Adjusted coordinates for absolute zoom, for all kinds of elements.
+        * svg/SVGElement.cpp:
+        * svg/SVGElement.h:
+        (SVGElement::boundingBox): Added.
+        * svg/SVGStyledTransformableElement.cpp:
+        * svg/SVGStyledTransformableElement.h:
+        (SVGStyledTransformableElement::nearestViewportElement): Removed.
+        (SVGStyledTransformableElement::farthestViewportElement): Removed.
+        (SVGStyledTransformableElement::getBBox): Removed.
+
 2010-10-22  Patrick Gansterer  <paroga at webkit.org>
 
         Reviewed by Adam Roben.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 098f916..9e3abd4 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4048,7 +4048,7 @@
 		B2227A3E0D00BF220071B782 /* SVGList.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278A80D00BF200071B782 /* SVGList.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B2227A3F0D00BF220071B782 /* SVGListTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278A90D00BF200071B782 /* SVGListTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B2227A400D00BF220071B782 /* SVGLocatable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278AA0D00BF200071B782 /* SVGLocatable.cpp */; };
-		B2227A410D00BF220071B782 /* SVGLocatable.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278AB0D00BF200071B782 /* SVGLocatable.h */; };
+		B2227A410D00BF220071B782 /* SVGLocatable.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278AB0D00BF200071B782 /* SVGLocatable.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B2227A430D00BF220071B782 /* SVGMarkerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278AD0D00BF200071B782 /* SVGMarkerElement.cpp */; };
 		B2227A440D00BF220071B782 /* SVGMarkerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278AE0D00BF200071B782 /* SVGMarkerElement.h */; };
 		B2227A460D00BF220071B782 /* SVGMaskElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278B00D00BF200071B782 /* SVGMaskElement.cpp */; };
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp
index 83e129e..da7bf38 100644
--- a/WebCore/dom/Element.cpp
+++ b/WebCore/dom/Element.cpp
@@ -52,13 +52,13 @@
 #include "RenderLayer.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
-#include "SVGStyledLocatableElement.h"
 #include "Settings.h"
 #include "TextIterator.h"
 #include "XMLNames.h"
 #include <wtf/text/CString.h>
 
 #if ENABLE(SVG)
+#include "SVGElement.h"
 #include "SVGNames.h"
 #endif
 
@@ -488,15 +488,12 @@ PassRefPtr<ClientRect> Element::getBoundingClientRect() const
 
     Vector<FloatQuad> quads;
 #if ENABLE(SVG)
-    if (isSVGElement()) {
+    if (isSVGElement() && renderer()) {
         // Get the bounding rectangle from the SVG model.
         const SVGElement* svgElement = static_cast<const SVGElement*>(this);
-        if (svgElement->isStyledLocatable()) {
-            if (renderer()) {
-                const FloatRect& localRect = static_cast<const SVGStyledLocatableElement*>(svgElement)->getBBox();
-                quads.append(renderer()->localToAbsoluteQuad(localRect));
-            }
-        }
+        FloatRect localRect;
+        if (svgElement->boundingBox(localRect))
+            quads.append(renderer()->localToAbsoluteQuad(localRect));
     } else
 #endif
     {
@@ -517,9 +514,7 @@ PassRefPtr<ClientRect> Element::getBoundingClientRect() const
         result.move(-visibleContentRect.x(), -visibleContentRect.y());
     }
 
-    if (renderBoxModelObject())
-        adjustIntRectForAbsoluteZoom(result, renderBoxModelObject());
-
+    adjustIntRectForAbsoluteZoom(result, renderer());
     return ClientRect::create(result);
 }
 
diff --git a/WebCore/svg/SVGElement.cpp b/WebCore/svg/SVGElement.cpp
index ea79e78..6c2c4a2 100644
--- a/WebCore/svg/SVGElement.cpp
+++ b/WebCore/svg/SVGElement.cpp
@@ -42,6 +42,8 @@
 #include "SVGElementRareData.h"
 #include "SVGNames.h"
 #include "SVGSVGElement.h"
+#include "SVGStyledLocatableElement.h"
+#include "SVGTextElement.h"
 #include "SVGURIReference.h"
 #include "SVGUseElement.h"
 #include "ScriptEventListener.h"
@@ -179,6 +181,19 @@ const HashSet<SVGElementInstance*>& SVGElement::instancesForElement() const
     return rareSVGData()->elementInstances();
 }
 
+bool SVGElement::boundingBox(FloatRect& rect, SVGLocatable::StyleUpdateStrategy styleUpdateStrategy) const
+{
+    if (isStyledLocatable()) {
+        rect = static_cast<const SVGStyledLocatableElement*>(this)->getBBox(styleUpdateStrategy);
+        return true;
+    }
+    if (hasTagName(SVGNames::textTag)) {
+        rect = static_cast<const SVGTextElement*>(this)->getBBox(styleUpdateStrategy);
+        return true;
+    }
+    return false;
+}
+
 void SVGElement::setCursorElement(SVGCursorElement* cursorElement)
 {
     ensureRareSVGData()->setCursorElement(cursorElement);
diff --git a/WebCore/svg/SVGElement.h b/WebCore/svg/SVGElement.h
index 5681284..517515f 100644
--- a/WebCore/svg/SVGElement.h
+++ b/WebCore/svg/SVGElement.h
@@ -24,6 +24,7 @@
 
 #if ENABLE(SVG)
 #include "SVGDocumentExtensions.h"
+#include "SVGLocatable.h"
 #include "StyledElement.h"
 
 namespace WebCore {
@@ -71,6 +72,8 @@ namespace WebCore {
 
         const HashSet<SVGElementInstance*>& instancesForElement() const;
 
+        bool boundingBox(FloatRect&, SVGLocatable::StyleUpdateStrategy = SVGLocatable::AllowStyleUpdate) const;
+
         void setCursorElement(SVGCursorElement*);
         void setCursorImageValue(CSSCursorImageValue*);
 
diff --git a/WebCore/svg/SVGStyledTransformableElement.cpp b/WebCore/svg/SVGStyledTransformableElement.cpp
index 9b34203..b1619ca 100644
--- a/WebCore/svg/SVGStyledTransformableElement.cpp
+++ b/WebCore/svg/SVGStyledTransformableElement.cpp
@@ -90,21 +90,6 @@ bool SVGStyledTransformableElement::isKnownAttribute(const QualifiedName& attrNa
            SVGStyledLocatableElement::isKnownAttribute(attrName);
 }
 
-SVGElement* SVGStyledTransformableElement::nearestViewportElement() const
-{
-    return SVGTransformable::nearestViewportElement(this);
-}
-
-SVGElement* SVGStyledTransformableElement::farthestViewportElement() const
-{
-    return SVGTransformable::farthestViewportElement(this);
-}
-
-FloatRect SVGStyledTransformableElement::getBBox(StyleUpdateStrategy styleUpdateStrategy) const
-{
-    return SVGTransformable::getBBox(this, styleUpdateStrategy);
-}
-
 RenderObject* SVGStyledTransformableElement::createRenderer(RenderArena* arena, RenderStyle*)
 {
     // By default, any subclass is expected to do path-based drawing
diff --git a/WebCore/svg/SVGStyledTransformableElement.h b/WebCore/svg/SVGStyledTransformableElement.h
index 5349cfa..cbb7da6 100644
--- a/WebCore/svg/SVGStyledTransformableElement.h
+++ b/WebCore/svg/SVGStyledTransformableElement.h
@@ -37,15 +37,11 @@ public:
 
     virtual AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) const;
     virtual AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) const;
-    virtual SVGElement* nearestViewportElement() const;
-    virtual SVGElement* farthestViewportElement() const;
 
     virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const { return SVGTransformable::localCoordinateSpaceTransform(mode); }
     virtual AffineTransform animatedLocalTransform() const;
     virtual AffineTransform* supplementalTransform();
 
-    virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) const;
-
     bool isKnownAttribute(const QualifiedName&);
 
     // "base class" methods for all the elements which render as paths

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list