+2006-02-11 Alexander Kellett <lypanov@kde.org>
+
+ Adding test case for
+
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=5360
+
+ * svg/custom/coords-relative-units-transforms.svg: Added.
+
2006-02-11 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Darin.
-6ea2114091241d3a1e574986dbfce171
\ No newline at end of file
+ad0f014e899b46bd1f956fd5ad57b21b
\ No newline at end of file
RenderSVGText {text} at (0,0) size 465x15
RenderText {TEXT} at (0,0) size 136x15
text run at (0,0) width 136: "Relative to font size (em)"
- KCanvasContainer {g} at (0,60) size 0x0
- KCanvasItem {rect} at (inf,inf) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data=""]
+ KCanvasContainer {g} at (20,120) size 200x1
+ KCanvasItem {rect} at (20,120) size 200x1 [fill={[type=SOLID] [color=#000000]}] [data="M20.00,60.00L220.00,60.00L220.00,61.00L20.00,61.00"]
RenderSVGText {text} at (0,0) size 465x15
RenderText {TEXT} at (0,0) size 30x15
text run at (0,0) width 30: "40 ex"
RenderSVGText {text} at (0,0) size 465x15
RenderText {TEXT} at (0,0) size 158x15
text run at (0,0) width 158: "Relative to font x-height (ex)"
- KCanvasContainer {g} at (0,60) size 0x0
- KCanvasItem {rect} at (inf,inf) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data=""]
+ KCanvasContainer {g} at (20,140) size 200x1
+ KCanvasItem {rect} at (20,140) size 200x1 [fill={[type=SOLID] [color=#000000]}] [data="M20.00,80.00L220.00,80.00L220.00,81.00L20.00,81.00"]
RenderSVGText {text} at (0,0) size 465x15
RenderText {TEXT} at (0,0) size 93x15
text run at (0,0) width 93: "41.67% = 200 px"
-54229441b75d2b2335567c7f780810e7
\ No newline at end of file
+32377a490808165b7bbc58a14fb0d7f8
\ No newline at end of file
-045d537ead570399e302b4bfa9fb7d1a
\ No newline at end of file
+849ef732548762d50ba82f256e7619f6
\ No newline at end of file
-10aae9bab31ed77a33002ea93e30908d
\ No newline at end of file
+8358f9bb800ec982bf0cad2861823a2a
\ No newline at end of file
-2f71b43ef49aa710c0aa321fb6b91760
\ No newline at end of file
+104ab2aafe4997ef18a53fe441445232
\ No newline at end of file
--- /dev/null
+0d34a3ea924e1b9aa960400fea3daa91
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+ KCanvasContainer {svg} at (0,0) size 400x200
+ KCanvasItem {rect} at (0,0) size 400x200 [stroke={[type=SOLID] [color=#0000FF] [stroke width=10.00]}] [data="M5.00,5.00L3995.00,5.00L3995.00,1995.00L5.00,1995.00"]
+ KCanvasContainer {g} at (36.16,38.08) size 327.00x125.08
+ KCanvasContainer {g} at (36.16,38.08) size 79.68x121.76 [transform={m=((1.00,0.00)(0.00,1.00)) t=(400.00,0.00)}]
+ RenderSVGText {text} at (0,0) size 785x364
+ RenderText {TEXT} at (0,0) size 436x364
+ text run at (0,0) width 329: "Abs."
+ text run at (0,182) width 436: "units:"
+ KCanvasItem {rect} at (38.08,38.08) size 39.84x21.84 [stroke={[type=SOLID] [color=#FF0000] [stroke width=38.40]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,400.00L360.00,400.00L360.00,580.00L0.00,580.00"]
+ KCanvasItem {rect} at (38.08,73.08) size 42.24x23.04 [stroke={[type=SOLID] [color=#FF0000] [stroke width=38.40]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,750.00L384.00,750.00L384.00,942.00L0.00,942.00"]
+ KCanvasContainer {g} at (36.16,116.16) size 79.68x43.68 [transform={m=((2.00,0.00)(0.00,2.00)) t=(0.00,0.00)}]
+ KCanvasItem {rect} at (36.16,116.16) size 79.68x43.68 [stroke={[type=SOLID] [color=#FF0000] [stroke width=38.40]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,600.00L360.00,600.00L360.00,780.00L0.00,780.00"]
+ KCanvasContainer {g} at (156.25,38.12) size 82.50x123.12 [transform={m=((1.00,0.00)(0.00,1.00)) t=(1600.00,0.00)}]
+ RenderSVGText {text} at (0,0) size 785x182
+ RenderText {TEXT} at (0,0) size 778x182
+ text run at (0,0) width 778: "Rel. units:"
+ KCanvasItem {rect} at (158.12,38.12) size 41.25x22.50 [stroke={[type=SOLID] [color=#FF0000] [stroke width=37.50]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,400.00L375.00,400.00L375.00,587.50L0.00,587.50"]
+ KCanvasItem {rect} at (158.12,73.12) size 41.25x22.50 [stroke={[type=SOLID] [color=#FF0000] [stroke width=37.50]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,750.00L375.00,750.00L375.00,937.50L0.00,937.50"]
+ KCanvasContainer {g} at (156.25,116.25) size 82.50x45 [transform={m=((2.00,0.00)(0.00,2.00)) t=(0.00,0.00)}]
+ KCanvasItem {rect} at (156.25,116.25) size 82.50x45 [stroke={[type=SOLID] [color=#FF0000] [stroke width=37.50]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,600.00L375.00,600.00L375.00,787.50L0.00,787.50"]
+ KCanvasContainer {g} at (276.84,38.42) size 86.32x124.74 [transform={m=((1.00,0.00)(0.00,1.00)) t=(2800.00,0.00)}]
+ RenderSVGText {text} at (0,0) size 785x182
+ RenderText {TEXT} at (0,0) size 982x182
+ text run at (0,0) width 982: "Percentages:"
+ KCanvasItem {rect} at (278.42,38.42) size 43.16x23.16 [stroke={[type=SOLID] [color=#FF0000] [stroke width=31.62]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,400.00L400.00,400.00L400.00,600.00L0.00,600.00"]
+ KCanvasItem {rect} at (278.42,73.42) size 43.16x23.16 [stroke={[type=SOLID] [color=#FF0000] [stroke width=31.62]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,750.00L400.00,750.00L400.00,950.00L0.00,950.00"]
+ KCanvasContainer {g} at (276.84,116.84) size 86.32x46.32 [transform={m=((2.00,0.00)(0.00,2.00)) t=(0.00,0.00)}]
+ KCanvasItem {rect} at (276.84,116.84) size 86.32x46.32 [stroke={[type=SOLID] [color=#FF0000] [stroke width=31.62]}] [fill={[type=SOLID] [color=#0000FF]}] [data="M0.00,600.00L400.00,600.00L400.00,800.00L0.00,800.00"]
--- /dev/null
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="400px" height="200px" viewBox="0 0 4000 2000"
+ xmlns="http://www.w3.org/2000/svg" version="1.1">
+ <title>Example Units</title>
+ <desc>Illustrates various units options</desc>
+
+ <!-- Frame the picture -->
+ <rect x="5" y="5" width="3990" height="1990"
+ fill="none" stroke="blue" stroke-width="10"/>
+
+ <g fill="blue" stroke="red" font-family="Verdana" font-size="150">
+ <!-- Absolute unit specifiers -->
+ <g transform="translate(400,0)">
+ <text x="-50" y="300" fill="black" stroke="none">Abs. units:</text>
+ <rect x="0" y="400" width="4in" height="2in" stroke-width=".4in"/>
+ <rect x="0" y="750" width="384" height="192" stroke-width="38.4"/>
+ <g transform="scale(2)">
+ <rect x="0" y="600" width="4in" height="2in" stroke-width=".4in"/>
+ </g>
+ </g>
+
+ <!-- Relative unit specifiers -->
+ <g transform="translate(1600,0)">
+ <text x="-50" y="300" fill="black" stroke="none">Rel. units:</text>
+ <rect x="0" y="400" width="2.5em" height="1.25em" stroke-width=".25em"/>
+ <rect x="0" y="750" width="375" height="187.5" stroke-width="37.5"/>
+ <g transform="scale(2)">
+ <rect x="0" y="600" width="2.5em" height="1.25em" stroke-width=".25em"/>
+ </g>
+ </g>
+
+ <!-- Percentages -->
+ <g transform="translate(2800,0)">
+ <text x="-50" y="300" fill="black" stroke="none">Percentages:</text>
+ <rect x="0" y="400" width="10%" height="10%" stroke-width="1%"/>
+ <rect x="0" y="750" width="400" height="200" stroke-width="31.62"/>
+ <g transform="scale(2)">
+ <rect x="0" y="600" width="10%" height="10%" stroke-width="1%"/>
+ </g>
+ </g>
+ </g>
+</svg>
+
+2006-02-11 Alexander Kellett <lypanov@kde.org>
+
+ Reviewed by eseidel.
+
+ - Fixing http://bugzilla.opendarwin.org/show_bug.cgi?id=6942
+ Implement support for "em" and "ex" relative lengths.
+
+ - Layout tests changes:
+ Fixed: svg/W3C-SVG-1.1/coords-units-03-b.svg
+ New: svg/custom/coords-relative-units-transforms.svg
+
+ * ksvg2/svg/SVGLengthImpl.cpp:
+ (SVGLengthImpl::SVGLengthImpl):
+ (SVGLengthImpl::value):
+ (SVGLengthImpl::updateValue):
+ (SVGLengthImpl::updateValueInSpecifiedUnits):
+ * ksvg2/svg/SVGLengthImpl.h:
+
2006-02-11 Darin Adler <darin@apple.com>
Rubber-stamped by Eric.
m_bboxRelative = false;
m_unitType = SVG_LENGTHTYPE_UNKNOWN;
+
+ m_requiresLayout = false;
}
SVGLengthImpl::~SVGLengthImpl()
float SVGLengthImpl::value() const
{
+ if (m_requiresLayout)
+ const_cast<SVGLengthImpl*>(this)->updateValue(false);
+
if(m_unitType != SVG_LENGTHTYPE_PERCENTAGE)
return m_value;
return 90.0;
}
-void SVGLengthImpl::updateValue()
+void SVGLengthImpl::updateValue(bool notify)
{
switch(m_unitType)
{
case SVG_LENGTHTYPE_PC:
m_value = (m_valueInSpecifiedUnits / 6.0) * dpi();
break;
- case SVG_LENGTHTYPE_EMS: // Be careful here, always recheck coords-units-BE-01.svg after touching (Niko)
+ case SVG_LENGTHTYPE_EMS:
case SVG_LENGTHTYPE_EXS:
- if(m_context)
- {
- /* FIXME: EMS/EXS handling
- KCanvasRenderingStyle *style = context->style();
- KCFontProperties *fontProperites = style->fontProperties();
-
- bool sizeLocal = (style->getFontSize() != -1);
- bool familyLocal = (style->getFontFamily() && style->getFontFamily()->getFirst());
-
- SVGStylableImpl *parentStyle = 0;
- if((!sizeLocal || !familyLocal) && context) {
- parentStyle = dynamic_cast<SVGStylableImpl *>(context->ownerDoc()->getElementFromHandle(context->parentNode().handle()));
-
- // Look up font-size in a SAFE way, because at this place
- // processStyle() has NOT yet been called, so we need
- // a different solution (Niko)
- QString useFont = "Arial";
- double useSize = 12;
-
- if(sizeLocal)
- useSize = style->getFontSize();
- else if(parentStyle && parentStyle->getFontSize() != -1)
- useSize = parentStyle->getFontSize();
-
- if(familyLocal)
- useFont = style->getFontFamily()->getFirst()->qstring();
- else if(parentStyle && parentStyle->getFontFamily() && parentStyle->getFontFamily()->getFirst())
- useFont = parentStyle->getFontFamily()->getFirst()->qstring();
-
- if(unitType == SVG_LENGTHTYPE_EMS)
- value = valueInSpecifiedUnits * useSize;
- else
- {
- // Easiest way, use qfont (Niko)
- QFont font(useFont);
- font.setPixelSize(static_cast<int>(useSize));
-
- QFontMetrics fm(font);
- value = valueInSpecifiedUnits * fm.boundingRect('x').height();
+ if (m_context && m_context->renderer()) {
+ khtml::RenderStyle *style = m_context->renderer()->style();
+ float useSize = style->font().pixelSize();
+ ASSERT(useSize > 0);
+ if (m_unitType == SVG_LENGTHTYPE_EMS)
+ m_value = m_valueInSpecifiedUnits * useSize;
+ else {
+ float xHeight = style->fontMetrics().xHeight();
+ // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg
+ // if this causes problems in real world cases maybe it would be best to remove this
+ m_value = m_valueInSpecifiedUnits * ceil(xHeight);
}
+ m_requiresLayout = false;
+ } else {
+ m_requiresLayout = true;
}
-
- break;*/
- }
+ break;
}
-
- if(m_context)
+ if (notify && m_context)
m_context->notifyAttributeChange();
}
-bool SVGLengthImpl::updateValueInSpecifiedUnits()
+bool SVGLengthImpl::updateValueInSpecifiedUnits(bool notify)
{
if(m_unitType == SVG_LENGTHTYPE_UNKNOWN)
return false;
break;
};
- if(m_context)
+ if (notify && m_context)
m_context->notifyAttributeChange();
return true;
void setContext(const SVGStyledElementImpl *context);
private:
- bool updateValueInSpecifiedUnits();
- void updateValue();
+ bool updateValueInSpecifiedUnits(bool notify = true);
+ void updateValue(bool notify = true);
double dpi() const;
LengthMode m_mode : 2;
bool m_bboxRelative : 1;
unsigned short m_unitType : 4;
+ bool m_requiresLayout : 1;
const SVGStyledElementImpl *m_context;
const SVGElementImpl *m_viewportElement;