- Revision
- 107893
- Author
- [email protected]
- Date
- 2012-02-15 23:16:34 -0800 (Wed, 15 Feb 2012)
Log Message
Repaint issues on changing 'viewBox' of inner SVG
https://bugs.webkit.org/show_bug.cgi?id=77903
Source/WebCore:
Patch by Bear Travis <[email protected]> on 2012-02-15
Reviewed by Nikolas Zimmermann.
Do not update the child viewbox/viewport transform to its parent
coordinate system until after layout has stored the old bounds for
repainting purposes.
Test: svg/repaint/inner-svg-change-viewBox-contract.svg
* rendering/svg/RenderSVGViewportContainer.cpp:
(WebCore::RenderSVGViewportContainer::RenderSVGViewportContainer):
(WebCore::RenderSVGViewportContainer::calcViewport):
(WebCore):
(WebCore::RenderSVGViewportContainer::calculateLocalTransform):
(WebCore::RenderSVGViewportContainer::localToParentTransform):
* rendering/svg/RenderSVGViewportContainer.h:
(WebCore::RenderSVGViewportContainer::setNeedsTransformUpdate):
(RenderSVGViewportContainer):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::svgAttributeChanged):
LayoutTests:
Adding test for 77903. When setting the viewbox on an inner svg
element causes the content to become smaller, make sure that the
area behind the content is redrawn.
Patch by Bear Travis <[email protected]> on 2012-02-15
Reviewed by Nikolas Zimmermann.
* platform/chromium/test_expectations.txt:
* svg/repaint/inner-svg-change-viewBox-contract-expected.png: Added.
* svg/repaint/inner-svg-change-viewBox-contract-expected.txt: Added.
* svg/repaint/inner-svg-change-viewBox-contract.svg: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (107892 => 107893)
--- trunk/LayoutTests/ChangeLog 2012-02-16 07:14:09 UTC (rev 107892)
+++ trunk/LayoutTests/ChangeLog 2012-02-16 07:16:34 UTC (rev 107893)
@@ -1,3 +1,19 @@
+2012-02-15 Bear Travis <[email protected]>
+
+ Repaint issues on changing 'viewBox' of inner SVG
+ https://bugs.webkit.org/show_bug.cgi?id=77903
+
+ Adding test for 77903. When setting the viewbox on an inner svg
+ element causes the content to become smaller, make sure that the
+ area behind the content is redrawn.
+
+ Reviewed by Nikolas Zimmermann.
+
+ * platform/chromium/test_expectations.txt:
+ * svg/repaint/inner-svg-change-viewBox-contract-expected.png: Added.
+ * svg/repaint/inner-svg-change-viewBox-contract-expected.txt: Added.
+ * svg/repaint/inner-svg-change-viewBox-contract.svg: Added.
+
2012-02-15 Csaba Osztrogonác <[email protected]>
[Qt] Unreviewed gardening after r107811.
Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (107892 => 107893)
--- trunk/LayoutTests/platform/chromium/test_expectations.txt 2012-02-16 07:14:09 UTC (rev 107892)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt 2012-02-16 07:16:34 UTC (rev 107893)
@@ -969,6 +969,9 @@
// SVG TESTS
// -----------------------------------------------------------------
+// New test, needs a rebaseline
+BUGWK77903 : svg/repaint/inner-svg-change-viewBox-contract.svg = IMAGE IMAGE+TEXT
+
// Need rebaselining after bug 64591
BUGWK64591 : compositing/repaint/become-overlay-composited-layer.html = PASS FAIL
Added: trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract-expected.png (0 => 107893)
--- trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract-expected.png (rev 0)
+++ trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract-expected.png 2012-02-16 07:16:34 UTC (rev 107893)
@@ -0,0 +1,5 @@
+\x89PNG
+
+
+IHDR X \x9Av\x82p )tEXtchecksum 7e8cadd5bf5a7b9e107a6f7e16fa2da0\x97\x97\x8Av \x86IDATx\x9C\xED\xD9\xD1 \xC30A9\xA4G\xA5w.w\xB12\xD1L\xEEk\xB9k\xDCc
+\xDE\xE3v\x8E7\x99\xF3\xB7{ \xC0_\xF9\xEC \x9CC\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @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 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8<`\xA68R\x90\x87K IEND\xAEB`\x82
\ No newline at end of file
Added: trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract-expected.txt (0 => 107893)
--- trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract-expected.txt 2012-02-16 07:16:34 UTC (rev 107893)
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 300x300
+ RenderSVGRoot {svg} at (0,0) size 200x200
+ RenderSVGRect {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#0000FF]}] [x=0.00] [y=0.00] [width=200.00] [height=200.00]
+ RenderSVGViewportContainer {svg} at (0,0) size 100x100
+ RenderSVGRect {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
Added: trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract.svg (0 => 107893)
--- trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract.svg (rev 0)
+++ trunk/LayoutTests/svg/repaint/inner-svg-change-viewBox-contract.svg 2012-02-16 07:16:34 UTC (rev 107893)
@@ -0,0 +1,14 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
+ width="300" height="300" _onload_="runRepaintTest()">
+<script xlink:href="" />
+<script><![CDATA[
+function repaintTest() {
+ document.getElementById("inner").setAttribute("viewBox", "0 0 200 200");
+}
+]]></script>
+<!-- blue rect's lower right edges should be visible after viewbox resizing -->
+<rect width="200" height="200" fill="blue"/>
+<svg id="inner" width="200" height="200" viewBox="0 0 100 100" preserveAspectRatio="none">
+ <rect width="100" height="100" fill="green"/>
+</svg>
+</svg>
Modified: trunk/Source/WebCore/ChangeLog (107892 => 107893)
--- trunk/Source/WebCore/ChangeLog 2012-02-16 07:14:09 UTC (rev 107892)
+++ trunk/Source/WebCore/ChangeLog 2012-02-16 07:16:34 UTC (rev 107893)
@@ -1,3 +1,28 @@
+2012-02-15 Bear Travis <[email protected]>
+
+ Repaint issues on changing 'viewBox' of inner SVG
+ https://bugs.webkit.org/show_bug.cgi?id=77903
+
+ Reviewed by Nikolas Zimmermann.
+
+ Do not update the child viewbox/viewport transform to its parent
+ coordinate system until after layout has stored the old bounds for
+ repainting purposes.
+
+ Test: svg/repaint/inner-svg-change-viewBox-contract.svg
+
+ * rendering/svg/RenderSVGViewportContainer.cpp:
+ (WebCore::RenderSVGViewportContainer::RenderSVGViewportContainer):
+ (WebCore::RenderSVGViewportContainer::calcViewport):
+ (WebCore):
+ (WebCore::RenderSVGViewportContainer::calculateLocalTransform):
+ (WebCore::RenderSVGViewportContainer::localToParentTransform):
+ * rendering/svg/RenderSVGViewportContainer.h:
+ (WebCore::RenderSVGViewportContainer::setNeedsTransformUpdate):
+ (RenderSVGViewportContainer):
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::svgAttributeChanged):
+
2012-02-15 Anders Carlsson <[email protected]>
Fix unused parameter warnings.
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp (107892 => 107893)
--- trunk/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp 2012-02-16 07:14:09 UTC (rev 107892)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp 2012-02-16 07:16:34 UTC (rev 107893)
@@ -35,6 +35,7 @@
RenderSVGViewportContainer::RenderSVGViewportContainer(SVGStyledElement* node)
: RenderSVGContainer(node)
, m_isLayoutSizeChanged(false)
+ , m_needsTransformUpdate(true)
{
}
@@ -63,10 +64,22 @@
SVGLengthContext lengthContext(element);
m_viewport = FloatRect(svg->x().value(lengthContext), svg->y().value(lengthContext), svg->width().value(lengthContext), svg->height().value(lengthContext));
- if (oldViewport != m_viewport)
+ if (oldViewport != m_viewport) {
setNeedsBoundariesUpdate();
+ setNeedsTransformUpdate();
+ }
}
+bool RenderSVGViewportContainer::calculateLocalTransform()
+{
+ if (!m_needsTransformUpdate)
+ return false;
+
+ m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_viewport.y()) * viewportTransform();
+ m_needsTransformUpdate = false;
+ return true;
+}
+
AffineTransform RenderSVGViewportContainer::viewportTransform() const
{
if (node()->hasTagName(SVGNames::svgTag)) {
@@ -77,14 +90,6 @@
return AffineTransform();
}
-const AffineTransform& RenderSVGViewportContainer::localToParentTransform() const
-{
- m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_viewport.y()) * viewportTransform();
- return m_localToParentTransform;
- // If this class were ever given a localTransform(), then the above would read:
- // return viewportTranslation * localTransform() * viewportTransform()
-}
-
bool RenderSVGViewportContainer::pointIsInsideViewportClip(const FloatPoint& pointInParent)
{
// Respect the viewport clip (which is in parent coords)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h (107892 => 107893)
--- trunk/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h 2012-02-16 07:14:09 UTC (rev 107892)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGViewportContainer.h 2012-02-16 07:16:34 UTC (rev 107893)
@@ -38,6 +38,7 @@
bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; }
virtual void determineIfLayoutSizeChanged();
+ virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
private:
virtual bool isSVGContainer() const { return true; }
@@ -45,9 +46,10 @@
virtual const char* renderName() const { return "RenderSVGViewportContainer"; }
AffineTransform viewportTransform() const;
- virtual const AffineTransform& localToParentTransform() const;
+ virtual const AffineTransform& localToParentTransform() const { return m_localToParentTransform; }
virtual void calcViewport();
+ virtual bool calculateLocalTransform();
virtual void applyViewportClip(PaintInfo&);
virtual bool pointIsInsideViewportClip(const FloatPoint& pointInParent);
@@ -55,6 +57,7 @@
FloatRect m_viewport;
mutable AffineTransform m_localToParentTransform;
bool m_isLayoutSizeChanged : 1;
+ bool m_needsTransformUpdate : 1;
};
inline RenderSVGViewportContainer* toRenderSVGViewportContainer(RenderObject* object)
Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (107892 => 107893)
--- trunk/Source/WebCore/svg/SVGSVGElement.cpp 2012-02-16 07:14:09 UTC (rev 107892)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp 2012-02-16 07:16:34 UTC (rev 107893)
@@ -37,6 +37,7 @@
#include "FrameTree.h"
#include "FrameView.h"
#include "HTMLNames.h"
+#include "RenderObject.h"
#include "RenderPart.h"
#include "RenderSVGResource.h"
#include "RenderSVGModelObject.h"
@@ -286,25 +287,29 @@
void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName)
{
- bool updateRelativeLengths = false;
+ bool updateRelativeLengthsOrViewBox = false;
if (attrName == SVGNames::widthAttr
|| attrName == SVGNames::heightAttr
|| attrName == SVGNames::xAttr
- || attrName == SVGNames::yAttr
- || SVGFitToViewBox::isKnownAttribute(attrName)) {
- updateRelativeLengths = true;
+ || attrName == SVGNames::yAttr) {
+ updateRelativeLengthsOrViewBox = true;
updateRelativeLengthsInformation();
}
+ if (SVGFitToViewBox::isKnownAttribute(attrName)) {
+ updateRelativeLengthsOrViewBox = true;
+ if (RenderObject* object = renderer())
+ object->setNeedsTransformUpdate();
+ }
+
SVGElementInstance::InvalidationGuard invalidationGuard(this);
if (SVGTests::handleAttributeChange(this, attrName))
return;
- if (updateRelativeLengths
+ if (updateRelativeLengthsOrViewBox
|| SVGLangSpace::isKnownAttribute(attrName)
|| SVGExternalResourcesRequired::isKnownAttribute(attrName)
- || SVGZoomAndPan::isKnownAttribute(attrName)
- || attrName == SVGNames::viewBoxAttr) {
+ || SVGZoomAndPan::isKnownAttribute(attrName)) {
if (renderer())
RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer());
return;