Commit 7fa2f31b authored by oliver's avatar oliver
Browse files

2007-05-21 Oliver Hunt <oliver@apple.com>

LayoutTests:

        Reviewed by Sam.
        
        Layout test for http://bugs.webkit.org/show_bug.cgi?id=13789

        * svg/custom/getscreenctm-in-mixed-content-expected.checksum: Added.
        * svg/custom/getscreenctm-in-mixed-content-expected.png: Added.
        * svg/custom/getscreenctm-in-mixed-content-expected.txt: Added.
        * svg/custom/getscreenctm-in-mixed-content.xhtml: Added.

WebCore:

        Reviewed by Sam.
        
        Fix for http://bugs.webkit.org/show_bug.cgi?id=13789 
        -- SVGLocatable::getScreenCTM() faulty
        
        Needed to update SVGLength to handle the case where the SVGElement is
        not the root document element -- we do this by falling back on the 
        renderer for the context.
        
        For <svg> elements embedded as mixed content in xhtml we consider the
        absolutePosition of the parent to be the origin for the <svg> element.

        * ksvg2/svg/SVGLength.cpp:
        (WebCore::SVGLength::PercentageOfViewport):
        * ksvg2/svg/SVGSVGElement.cpp:
        (WebCore::SVGSVGElement::getScreenCTM):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21636 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 428cde24
2007-05-21 Oliver Hunt <oliver@apple.com>
Reviewed by Sam.
Layout test for http://bugs.webkit.org/show_bug.cgi?id=13789
* svg/custom/getscreenctm-in-mixed-content-expected.checksum: Added.
* svg/custom/getscreenctm-in-mixed-content-expected.png: Added.
* svg/custom/getscreenctm-in-mixed-content-expected.txt: Added.
* svg/custom/getscreenctm-in-mixed-content.xhtml: Added.
2007-05-21 Sam Weinig <sam@webkit.org>
 
Reviewed by Darin.
b6ff8b384f7a21823ff3fde367dbd621
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x52
RenderBlock {html} at (0,0) size 800x52
RenderBody {body} at (8,8) size 784x36
RenderText {#text} at (0,0) size 170x18
text run at (0,0) width 170: "This tests the behaviour of "
RenderInline {code} at (0,0) size 224x15
RenderText {#text} at (170,2) size 224x15
text run at (170,2) width 224: "SVGLocatable::getScreenCTM()"
RenderText {#text} at (394,0) size 113x18
text run at (394,0) width 113: " in mixed content "
RenderBR {br} at (507,0) size 0x18
RenderText {#text} at (0,18) size 315x18
text run at (0,18) width 315: "If the test passes you should see a green rectangle."
layer at (30,100) size 400x204
RenderBlock (positioned) {div} at (30,100) size 400x200
RenderSVGContainer {svg} at (38,108) size 400x200
RenderPath {rect} at (38,108) size 400x200 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L200.00,0.00L200.00,100.00L0.00,100.00"]
RenderText {#text} at (0,0) size 0x0
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scalable Search Box</title>
<script>
<![CDATA[
var testMatrix;
var expectedMatrix = {
a: 2,
b: 0,
c: 0,
d: 2,
e: 30,
f: 100
};
function runTest () {
var rect = document.getElementById('rect');
try {
testMatrix = rect.getScreenCTM();
}
// end script here
catch (error) {
logError('.getScreenCTM() seems to be unimplemented');
return;
}
// check equality of matrices
if (areMatricesEqual(testMatrix, expectedMatrix)) {
rect.setAttributeNS(null, 'fill', 'green');
}
// explain error
else {
logError('Expected matrix ' + printMatrix(expectedMatrix));
logError('Got matrix ' + printMatrix(testMatrix));
}
}
function areMatricesEqual (m1, m2) {
return (
m1.a == m2.a &&
m1.b == m2.b &&
m1.c == m2.c &&
m1.d == m2.d &&
m1.e == m2.e &&
m1.f == m2.f
);
}
function printMatrix (m) {
return '[' + [m.a, m.b, m.c, m.d, m.e, m.f].join(', ') + ']';
}
function logError (msg) {
var output = document.getElementById('error')
var text = document.createTextNode(msg);
var br = document.createElementNS('http://www.w3.org/1999/xhtml', 'br');
output.appendChild(text);
output.appendChild(br);
}
]]>
</script>
</head>
<body onload="runTest()">
<div style="position: absolute; left: 30px; top: 100px; width: 400px; height: 200px;">
<svg id="svgRoot" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 100" preserveAspectRatio="xMinYMin meet">
<rect id="rect" width="100%" height="100%" fill="red" />
</svg>
</div>
<div id="error" style="position: absolute; left: 30px; top: 330px; color: red" />
This tests the behaviour of <code>SVGLocatable::getScreenCTM()</code> in mixed content <br />
If the test passes you should see a green rectangle.
</body>
</html>
\ No newline at end of file
2007-05-21 Oliver Hunt <oliver@apple.com>
Reviewed by Sam.
Fix for http://bugs.webkit.org/show_bug.cgi?id=13789
-- SVGLocatable::getScreenCTM() faulty
Needed to update SVGLength to handle the case where the SVGElement is
not the root document element -- we do this by falling back on the
renderer for the context.
For <svg> elements embedded as mixed content in xhtml we consider the
absolutePosition of the parent to be the origin for the <svg> element.
* ksvg2/svg/SVGLength.cpp:
(WebCore::SVGLength::PercentageOfViewport):
* ksvg2/svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getScreenCTM):
2007-05-21 Timothy Hatcher <timothy@apple.com>
 
Reviewed by Adam.
/*
Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005, 2006 Rob Buis <buis@kde.org>
2007 Apple Inc. All rights reserved.
This file is part of the KDE project
......@@ -293,6 +294,11 @@ float SVGLength::PercentageOfViewport(float value, const SVGStyledElement* conte
width = svg->width().value();
height = svg->height().value();
}
} else if (context->parent() && !context->parent()->isSVGElement()) {
if (RenderObject* renderer = context->renderer()) {
width = renderer->width();
height = renderer->height();
}
}
if (mode == LengthModeWidth)
......
/*
Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
2007 Apple Inc. All rights reserved.
This file is part of the KDE project
......@@ -335,8 +336,25 @@ AffineTransform SVGSVGElement::getCTM() const
AffineTransform SVGSVGElement::getScreenCTM() const
{
// FIXME: This assumes that any <svg> element not immediately descending from another SVGElement
// has *no* svg ancestors
document()->updateLayoutIgnorePendingStylesheets();
float rootX = x().value();
float rootY = y().value();
if (RenderObject* renderer = this->renderer()) {
renderer = renderer->parent();
if (renderer && !(renderer->element() && renderer->element()->isSVGElement())) {
int tx = 0;
int ty = 0;
renderer->absolutePosition(tx, ty, true);
rootX += tx;
rootY += ty;
}
}
AffineTransform mat = SVGStyledLocatableElement::getScreenCTM();
mat.translate(x().value(), y().value());
mat.translate(rootX, rootY);
if (attributes()->getNamedItem(SVGNames::viewBoxAttr)) {
AffineTransform viewBox = viewBoxToViewTransform(width().value(), height().value());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment