From a33e8a26bb7a89fc1b6c379ac7d018c12801bd48 Mon Sep 17 00:00:00 2001 From: rwlbuis Date: Wed, 27 Sep 2006 20:29:10 +0000 Subject: [PATCH] Reviewed by eseidel. http://bugzilla.opendarwin.org/show_bug.cgi?id=11015 SVG handles em units incorrectly Calculate viewport coordinates at layout time, since at this point the font size is known and lengths depending on font sizes can be calculated correctly. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16601 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 17 +++++++++++ .../svg/custom/viewport-em-expected.checksum | 1 + .../svg/custom/viewport-em-expected.png | Bin 0 -> 10483 bytes .../svg/custom/viewport-em-expected.txt | 19 ++++++++++++ LayoutTests/svg/custom/viewport-em.svg | 18 ++++++++++++ .../custom/viewport-update2-expected.checksum | 1 + .../svg/custom/viewport-update2-expected.png | Bin 0 -> 3250 bytes .../svg/custom/viewport-update2-expected.txt | 5 ++++ LayoutTests/svg/custom/viewport-update2.svg | 10 +++++++ WebCore/ChangeLog | 25 ++++++++++++++++ WebCore/kcanvas/RenderSVGContainer.cpp | 27 +++++++++++++++--- WebCore/kcanvas/RenderSVGContainer.h | 5 ++-- WebCore/ksvg2/svg/SVGLength.cpp | 10 +++++-- WebCore/ksvg2/svg/SVGMarkerElement.cpp | 1 - WebCore/ksvg2/svg/SVGSVGElement.cpp | 13 ++++++++- WebCore/ksvg2/svg/SVGSVGElement.h | 2 ++ 16 files changed, 144 insertions(+), 10 deletions(-) create mode 100644 LayoutTests/svg/custom/viewport-em-expected.checksum create mode 100644 LayoutTests/svg/custom/viewport-em-expected.png create mode 100644 LayoutTests/svg/custom/viewport-em-expected.txt create mode 100644 LayoutTests/svg/custom/viewport-em.svg create mode 100644 LayoutTests/svg/custom/viewport-update2-expected.checksum create mode 100644 LayoutTests/svg/custom/viewport-update2-expected.png create mode 100644 LayoutTests/svg/custom/viewport-update2-expected.txt create mode 100644 LayoutTests/svg/custom/viewport-update2.svg diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 61c1478c53ea..545b8fc1bb43 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,20 @@ +2006-09-27 Rob Buis + + Reviewed by eseidel. + + Testcases for: + http://bugzilla.opendarwin.org/show_bug.cgi?id=11015 + SVG handles em units incorrectly + + * svg/custom/viewport-em-expected.checksum: Added. + * svg/custom/viewport-em-expected.png: Added. + * svg/custom/viewport-em-expected.txt: Added. + * svg/custom/viewport-em.svg: Added. + * svg/custom/viewport-update2-expected.checksum: Added. + * svg/custom/viewport-update2-expected.png: Added. + * svg/custom/viewport-update2-expected.txt: Added. + * svg/custom/viewport-update2.svg: Added. + 2006-09-27 Eric Seidel Reviewed by darin. diff --git a/LayoutTests/svg/custom/viewport-em-expected.checksum b/LayoutTests/svg/custom/viewport-em-expected.checksum new file mode 100644 index 000000000000..725c13863525 --- /dev/null +++ b/LayoutTests/svg/custom/viewport-em-expected.checksum @@ -0,0 +1 @@ +8582cf4c7f667d677a8ce2bd274a4c8f \ No newline at end of file diff --git a/LayoutTests/svg/custom/viewport-em-expected.png b/LayoutTests/svg/custom/viewport-em-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..0f84d1ad76458fd4e8d04b78c498db3c9be0097b GIT binary patch literal 10483 zcmeHtd012Dx^FDIwcQrjJ)YJgLux^(1E7pDMr)O#LaK-eAx6p&ks(Ti5RwpDTd7q6 zgMf_DjesD7f+U6z;?OdaC^G~S6-byul#ql>?1A z@BMz$yDohb;A{Nnjemy0V8(u5e{~cFGx`h$d*{Ua?}5J*CVzhx2Kx-=_toBGDaFzW z;`NhJ-$~wJf~sl9l-b*iY_k9K)%wpYPcz=*HDYcJsEF$Gr}ts7Z?3?=ho3(JmG0T~&Yxhg zFAk)GfByRZUtqACpRRca2K#sGJ>aTu|EVu0$EMeyn457e_oE33OGesz?GIuC@m5q_ zZ*snyTd*Te*p-}L5594EL%n|IMdd9ND{-Hgj~QHC$`r4LFR~jwJ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fC3x#(EVvj${e0_M z9~n7Dv^|MWyKxVSkXD*LGE~)Q%^5b1*h!RR{{w_4?#QZHZI<_z4f`}w*4QVA) zPNorq+MVLtX`AO8lBE?EsWYVoPT2kS4^O4mHP8K!%i_6L9(LFLozDUoG9wQt(8&UR+|wCQ`+%TfuLqI#3D?O?7PCUq8}>QT2Xm zEtl&CjZ!q4lR)3(I7NOfvgvf75<^=RwQT&0?-0Cu;YNx5{_BroM4Aifz{^bQ6c~dC zY2irz1(P!!4pepfc$zi@v_uz(MoXdDNpSrblxah=C?RRX6i{Q4U_sR55@k1^x{6tH zqsoiMNwV*+Sn2N%3?(1RvYJSouXPY_$GE3tsG-3@0Z0>~q+=j>qJiviTC^(V0u%81 zMLJ0se;#%G$Kx(wG zFkW;ecv~$q*w|{ElrbE%t@HbL?;ZsSs$K;jnf7yb3vK{m-@x#2)MT3&%%^If4(~uW z`zREggx@joor2qMCZRas{Xr&{LVx0-@J3Ykz)@G_I@4oF2H}QerR;Rbi@>#jTQNe_5adj z{x^&IZx!;py&&*M8UN4kR{XJae=Oba@{-OUjr2z&{n1Fj`@3)dUmmL)hIKKqBYXbs U;lmR^a>4xe2Yglc<*D!g7j7HfLjV8( literal 0 HcmV?d00001 diff --git a/LayoutTests/svg/custom/viewport-em-expected.txt b/LayoutTests/svg/custom/viewport-em-expected.txt new file mode 100644 index 000000000000..ddc5324ad93c --- /dev/null +++ b/LayoutTests/svg/custom/viewport-em-expected.txt @@ -0,0 +1,19 @@ +layer at (0,0) size 800x600 + RenderView at (0,0) size 800x600 +layer at (0,0) size 800x226 + RenderBlock {html} at (0,0) size 800x226 + RenderBody {body} at (8,16) size 784x202 + RenderBlock {p} at (0,0) size 784x18 [color=#000080] + RenderText {#text} at (0,0) size 264x18 + text run at (0,0) width 264: "There should be two identical bars below." + RenderBlock {p} at (0,34) size 784x18 [color=#000080] + RenderText {#text} at (0,0) size 56x18 + text run at (0,0) width 56: "First bar:" + RenderBlock {div} at (0,68) size 160x40 [bgcolor=#000080] + RenderBlock {p} at (0,124) size 784x18 [color=#000080] + RenderText {#text} at (0,0) size 75x18 + text run at (0,0) width 75: "Second bar:" + RenderBlock (anonymous) at (0,158) size 784x44 + KCanvasContainer {svg} at (8,174) size 160x40 + KCanvasItem {rect} at (8,174) size 160x40 [fill={[type=SOLID] [color=#000080]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"] + RenderText {#text} at (0,0) size 0x0 diff --git a/LayoutTests/svg/custom/viewport-em.svg b/LayoutTests/svg/custom/viewport-em.svg new file mode 100644 index 000000000000..2782efdd80d7 --- /dev/null +++ b/LayoutTests/svg/custom/viewport-em.svg @@ -0,0 +1,18 @@ + + + 'em' widths + + + +

There should be two identical bars below.

+

First bar:

+
+

Second bar:

+ + + + + diff --git a/LayoutTests/svg/custom/viewport-update2-expected.checksum b/LayoutTests/svg/custom/viewport-update2-expected.checksum new file mode 100644 index 000000000000..3a4f1f7086de --- /dev/null +++ b/LayoutTests/svg/custom/viewport-update2-expected.checksum @@ -0,0 +1 @@ +16310588467cfc20d551635abc59b784 \ No newline at end of file diff --git a/LayoutTests/svg/custom/viewport-update2-expected.png b/LayoutTests/svg/custom/viewport-update2-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..3db2634a02cf66b801aa1b94cb06d666a42e429f GIT binary patch literal 3250 zcmeAS@N?(olHy`uVBq!ia0y~yU{+vYV2a>i1B%QlYbs!1;HmUx>!pa3a8bLNd4FxLMx^K&pTOb`U7DF?R(VB(NuWMW`QVHp)14Uo~qFq#oY sONP->akNGltqn(O!_nFhqc)t$o-~zbdBW+mdKI;Vst0LUJUAOHXW literal 0 HcmV?d00001 diff --git a/LayoutTests/svg/custom/viewport-update2-expected.txt b/LayoutTests/svg/custom/viewport-update2-expected.txt new file mode 100644 index 000000000000..9ba83a1fb970 --- /dev/null +++ b/LayoutTests/svg/custom/viewport-update2-expected.txt @@ -0,0 +1,5 @@ +layer at (0,0) size 800x600 + RenderView at (0,0) size 800x600 + KCanvasContainer {svg} at (-100,-100) size 300x300 + KCanvasItem {rect} at (-100,-100) size 300x300 [fill={[type=SOLID] [color=#FF0000]}] [data="M-100.00,-100.00L200.00,-100.00L200.00,200.00L-100.00,200.00"] + KCanvasItem {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"] diff --git a/LayoutTests/svg/custom/viewport-update2.svg b/LayoutTests/svg/custom/viewport-update2.svg new file mode 100644 index 000000000000..81851cc9288a --- /dev/null +++ b/LayoutTests/svg/custom/viewport-update2.svg @@ -0,0 +1,10 @@ + + + + + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 5608bbcd337a..cee112c3c007 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,28 @@ +2006-09-27 Rob Buis + + Reviewed by eseidel. + + http://bugzilla.opendarwin.org/show_bug.cgi?id=11015 + SVG handles em units incorrectly + + Calculate viewport coordinates at layout time, since + at this point the font size is known and lengths depending + on font sizes can be calculated correctly. + + * kcanvas/RenderSVGContainer.cpp: + (WebCore::RenderSVGContainer::layout): + (WebCore::RenderSVGContainer::viewport): + (WebCore::RenderSVGContainer::calcViewport): + * kcanvas/RenderSVGContainer.h: + * ksvg2/svg/SVGLength.cpp: + (WebCore::SVGLength::updateValue): + * ksvg2/svg/SVGMarkerElement.cpp: + (WebCore::SVGMarkerElement::createRenderer): + * ksvg2/svg/SVGSVGElement.cpp: + (WebCore::SVGSVGElement::createRenderer): + (WebCore::SVGSVGElement::attributeChanged): + * ksvg2/svg/SVGSVGElement.h: + 2006-09-27 Eric Seidel Reviewed by darin. diff --git a/WebCore/kcanvas/RenderSVGContainer.cpp b/WebCore/kcanvas/RenderSVGContainer.cpp index 6cbf52e12afe..86f1217c2f2b 100644 --- a/WebCore/kcanvas/RenderSVGContainer.cpp +++ b/WebCore/kcanvas/RenderSVGContainer.cpp @@ -30,6 +30,9 @@ #include "KRenderingDevice.h" #include "SVGStyledElement.h" #include "GraphicsContext.h" +#include "SVGLength.h" +#include "SVGMarkerElement.h" +#include "SVGSVGElement.h" #include "SVGStyledTransformableElement.h" namespace WebCore { @@ -99,6 +102,9 @@ void RenderSVGContainer::layout() ASSERT(needsLayout()); ASSERT(minMaxKnown()); + if (selfNeedsLayout()) + calcViewport(); + IntRect oldBounds; bool checkForRepaint = checkForRepaintDuringLayout(); if (selfNeedsLayout() && checkForRepaint) @@ -200,14 +206,27 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, int parentX, int parentY) paintInfo.p->restore(); } -void RenderSVGContainer::setViewport(const FloatRect& viewport) +FloatRect RenderSVGContainer::viewport() const { - m_viewport = viewport; + return m_viewport; } -FloatRect RenderSVGContainer::viewport() const +void RenderSVGContainer::calcViewport() { - return m_viewport; + SVGElement* svgelem = static_cast(element()); + if (svgelem->hasTagName(SVGNames::svgTag)) { + SVGSVGElement* svg = static_cast(element()); + double x = svg->x()->value(); + double y = svg->y()->value(); + double w = svg->width()->value(); + double h = svg->height()->value(); + m_viewport = FloatRect(x, y, w, h); + } else if (svgelem->hasTagName(SVGNames::markerTag)) { + SVGMarkerElement* svg = static_cast(element()); + double w = svg->markerWidth()->value(); + double h = svg->markerHeight()->value(); + m_viewport = FloatRect(0, 0, w, h); + } } void RenderSVGContainer::setViewBox(const FloatRect& viewBox) diff --git a/WebCore/kcanvas/RenderSVGContainer.h b/WebCore/kcanvas/RenderSVGContainer.h index a0af4a4da2ef..ca04d634caec 100644 --- a/WebCore/kcanvas/RenderSVGContainer.h +++ b/WebCore/kcanvas/RenderSVGContainer.h @@ -43,6 +43,7 @@ enum KCAlign { }; class KCanvasRenderingStyle; +class SVGElement; class RenderSVGContainer : public RenderContainer { @@ -81,8 +82,7 @@ public: virtual AffineTransform localTransform() const; void setLocalTransform(const AffineTransform&); - - void setViewport(const FloatRect&); + FloatRect viewport() const; void setViewBox(const FloatRect&); @@ -97,6 +97,7 @@ public: AffineTransform viewportTransform() const; private: + void calcViewport(); AffineTransform getAspectRatio(const FloatRect& logical, const FloatRect& physical) const; bool m_drawsContents : 1; diff --git a/WebCore/ksvg2/svg/SVGLength.cpp b/WebCore/ksvg2/svg/SVGLength.cpp index 4d8d1da69adc..7365a238a128 100644 --- a/WebCore/ksvg2/svg/SVGLength.cpp +++ b/WebCore/ksvg2/svg/SVGLength.cpp @@ -208,8 +208,13 @@ void SVGLength::updateValue(bool notify) break; case SVG_LENGTHTYPE_EMS: case SVG_LENGTHTYPE_EXS: - if (m_context && m_context->renderer()) { - RenderStyle *style = m_context->renderer()->style(); + { + RenderStyle *style = 0; + if (m_context && m_context->renderer()) + style = m_context->renderer()->style(); + else if (m_viewportElement && m_viewportElement->renderer()) + style = m_viewportElement->renderer()->style(); + if (style) { float useSize = style->fontSize(); ASSERT(useSize > 0); if (m_unitType == SVG_LENGTHTYPE_EMS) @@ -225,6 +230,7 @@ void SVGLength::updateValue(bool notify) m_requiresLayout = true; } break; + } case SVG_LENGTHTYPE_UNKNOWN: case SVG_LENGTHTYPE_NUMBER: case SVG_LENGTHTYPE_PERCENTAGE: diff --git a/WebCore/ksvg2/svg/SVGMarkerElement.cpp b/WebCore/ksvg2/svg/SVGMarkerElement.cpp index 9214a094d4a7..876f67e54edb 100644 --- a/WebCore/ksvg2/svg/SVGMarkerElement.cpp +++ b/WebCore/ksvg2/svg/SVGMarkerElement.cpp @@ -140,7 +140,6 @@ KCanvasMarker *SVGMarkerElement::canvasResource() RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle* style) { RenderSVGContainer* markerContainer = new (arena) RenderSVGContainer(this); - markerContainer->setViewport(FloatRect(0, 0, markerWidth()->value(), markerHeight()->value())); markerContainer->setViewBox(viewBox()); markerContainer->setAlign(KCAlign(preserveAspectRatio()->align() - 1)); markerContainer->setSlice(preserveAspectRatio()->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE); diff --git a/WebCore/ksvg2/svg/SVGSVGElement.cpp b/WebCore/ksvg2/svg/SVGSVGElement.cpp index 260e90f4509e..28e7b85c6784 100644 --- a/WebCore/ksvg2/svg/SVGSVGElement.cpp +++ b/WebCore/ksvg2/svg/SVGSVGElement.cpp @@ -370,7 +370,6 @@ RenderObject* SVGSVGElement::createRenderer(RenderArena* arena, RenderStyle*) RenderSVGContainer* rootContainer = new (arena) RenderSVGContainer(this); // FIXME: all this setup should be done after attributesChanged, not here. - rootContainer->setViewport(FloatRect(x()->value(), y()->value(), width()->value(), height()->value())); rootContainer->setViewBox(viewBox()); rootContainer->setAlign(KCAlign(preserveAspectRatio()->align() - 1)); rootContainer->setSlice(preserveAspectRatio()->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE); @@ -423,6 +422,18 @@ void SVGSVGElement::setCurrentTime(float /* seconds */) // TODO } +void SVGSVGElement::attributeChanged(Attribute* attr, bool preserveDecls) +{ + if (attr->name() == SVGNames::xAttr || + attr->name() == SVGNames::yAttr || + attr->name() == SVGNames::widthAttr || + attr->name() == SVGNames::heightAttr) + if (renderer()) + renderer()->setNeedsLayout(true); + + SVGStyledElement::attributeChanged(attr, preserveDecls); +} + } // vim:ts=4:noet diff --git a/WebCore/ksvg2/svg/SVGSVGElement.h b/WebCore/ksvg2/svg/SVGSVGElement.h index 706089c519cc..cf15bc306b67 100644 --- a/WebCore/ksvg2/svg/SVGSVGElement.h +++ b/WebCore/ksvg2/svg/SVGSVGElement.h @@ -129,6 +129,8 @@ namespace WebCore // 'virtual SVGZoomAndPan functions virtual void setZoomAndPan(unsigned short zoomAndPan); + virtual void attributeChanged(Attribute*, bool preserveDecls = false); + protected: virtual const SVGElement* contextElement() const { return this; } -- 2.36.0