Changeset 100075 in webkit


Ignore:
Timestamp:
Nov 12, 2011 2:39:17 AM (12 years ago)
Author:
Nikolas Zimmermann
Message:

2011-11-12 Nikolas Zimmermann <nzimmermann@rim.com>

Finish SVGLengthContext conversion in svg/
https://bugs.webkit.org/show_bug.cgi?id=72105

Reviewed by Antti Koivisto.

Make SVGLengthContext(const SVGElement*) explicit, adapt all remaining call sites.
Now that this process is finished, SVGLengthContext can be shared across renders,
so that its possible to override the length context in a single place. This will
be done in future patches.

Doesn't affect any tests yet.

  • bindings/js/JSSVGLengthCustom.cpp: (WebCore::JSSVGLength::value): (WebCore::JSSVGLength::setValue): (WebCore::JSSVGLength::convertToSpecifiedUnits):
  • bindings/scripts/CodeGeneratorObjC.pm: (GenerateImplementation):
  • bindings/v8/custom/V8SVGLengthCustom.cpp: (WebCore::V8SVGLength::valueAccessorGetter): (WebCore::V8SVGLength::valueAccessorSetter): (WebCore::V8SVGLength::convertToSpecifiedUnitsCallback):
  • css/CSSCursorImageValue.cpp: (WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
  • rendering/svg/RenderSVGForeignObject.cpp: (WebCore::RenderSVGForeignObject::layout):
  • rendering/svg/RenderSVGImage.cpp: (WebCore::RenderSVGImage::updateFromElement):
  • rendering/svg/RenderSVGPath.cpp: (WebCore::RenderSVGPath::zeroLengthSubpathRect): (WebCore::RenderSVGPath::calculateMarkerBoundsIfNeeded):
  • rendering/svg/RenderSVGResourceMarker.cpp: (WebCore::RenderSVGResourceMarker::referencePoint): (WebCore::RenderSVGResourceMarker::calcViewport):
  • rendering/svg/RenderSVGText.cpp: (WebCore::RenderSVGText::strokeBoundingBox):
  • rendering/svg/RenderSVGViewportContainer.cpp: (WebCore::RenderSVGViewportContainer::calcViewport):
  • rendering/svg/SVGRenderSupport.cpp: (WebCore::SVGRenderSupport::applyStrokeStyleToContext):
  • rendering/svg/SVGRenderTreeAsText.cpp: (WebCore::writeStyle): (WebCore::operator<<):
  • rendering/svg/SVGShadowTreeElements.cpp: (WebCore::SVGShadowTreeContainerElement::containerTranslation):
  • rendering/svg/SVGTextChunkBuilder.cpp: (WebCore::SVGTextChunkBuilder::addTextChunk):
  • rendering/svg/SVGTextLayoutAttributesBuilder.cpp: (WebCore::extractFloatValuesFromSVGLengthList):
  • rendering/svg/SVGTextLayoutEngine.cpp: (WebCore::SVGTextLayoutEngine::parentDefinesTextLength): (WebCore::SVGTextLayoutEngine::beginTextPathLayout):
  • rendering/svg/SVGTextLayoutEngineBaseline.cpp: (WebCore::SVGTextLayoutEngineBaseline::calculateBaselineShift):
  • rendering/svg/SVGTextLayoutEngineSpacing.cpp: (WebCore::SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing):
  • svg/SVGElement.h:
  • svg/SVGLengthContext.cpp: (WebCore::SVGLengthContext::determineViewport):
  • svg/SVGLengthContext.h:
  • svg/SVGSVGElement.cpp: (WebCore::SVGSVGElement::viewport): (WebCore::SVGSVGElement::localCoordinateSpaceTransform): (WebCore::SVGSVGElement::currentViewBoxRect):
  • svg/SVGUseElement.cpp: (WebCore::SVGUseElement::toClipPath):
Location:
trunk/Source/WebCore
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r100073 r100075  
     12011-11-12  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Finish SVGLengthContext conversion in svg/
     4        https://bugs.webkit.org/show_bug.cgi?id=72105
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Make SVGLengthContext(const SVGElement*) explicit, adapt all remaining call sites.
     9        Now that this process is finished, SVGLengthContext can be shared across renders,
     10        so that its possible to override the length context in a single place. This will
     11        be done in future patches.
     12
     13        Doesn't affect any tests yet.
     14
     15        * bindings/js/JSSVGLengthCustom.cpp:
     16        (WebCore::JSSVGLength::value):
     17        (WebCore::JSSVGLength::setValue):
     18        (WebCore::JSSVGLength::convertToSpecifiedUnits):
     19        * bindings/scripts/CodeGeneratorObjC.pm:
     20        (GenerateImplementation):
     21        * bindings/v8/custom/V8SVGLengthCustom.cpp:
     22        (WebCore::V8SVGLength::valueAccessorGetter):
     23        (WebCore::V8SVGLength::valueAccessorSetter):
     24        (WebCore::V8SVGLength::convertToSpecifiedUnitsCallback):
     25        * css/CSSCursorImageValue.cpp:
     26        (WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
     27        * rendering/svg/RenderSVGForeignObject.cpp:
     28        (WebCore::RenderSVGForeignObject::layout):
     29        * rendering/svg/RenderSVGImage.cpp:
     30        (WebCore::RenderSVGImage::updateFromElement):
     31        * rendering/svg/RenderSVGPath.cpp:
     32        (WebCore::RenderSVGPath::zeroLengthSubpathRect):
     33        (WebCore::RenderSVGPath::calculateMarkerBoundsIfNeeded):
     34        * rendering/svg/RenderSVGResourceMarker.cpp:
     35        (WebCore::RenderSVGResourceMarker::referencePoint):
     36        (WebCore::RenderSVGResourceMarker::calcViewport):
     37        * rendering/svg/RenderSVGText.cpp:
     38        (WebCore::RenderSVGText::strokeBoundingBox):
     39        * rendering/svg/RenderSVGViewportContainer.cpp:
     40        (WebCore::RenderSVGViewportContainer::calcViewport):
     41        * rendering/svg/SVGRenderSupport.cpp:
     42        (WebCore::SVGRenderSupport::applyStrokeStyleToContext):
     43        * rendering/svg/SVGRenderTreeAsText.cpp:
     44        (WebCore::writeStyle):
     45        (WebCore::operator<<):
     46        * rendering/svg/SVGShadowTreeElements.cpp:
     47        (WebCore::SVGShadowTreeContainerElement::containerTranslation):
     48        * rendering/svg/SVGTextChunkBuilder.cpp:
     49        (WebCore::SVGTextChunkBuilder::addTextChunk):
     50        * rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
     51        (WebCore::extractFloatValuesFromSVGLengthList):
     52        * rendering/svg/SVGTextLayoutEngine.cpp:
     53        (WebCore::SVGTextLayoutEngine::parentDefinesTextLength):
     54        (WebCore::SVGTextLayoutEngine::beginTextPathLayout):
     55        * rendering/svg/SVGTextLayoutEngineBaseline.cpp:
     56        (WebCore::SVGTextLayoutEngineBaseline::calculateBaselineShift):
     57        * rendering/svg/SVGTextLayoutEngineSpacing.cpp:
     58        (WebCore::SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing):
     59        * svg/SVGElement.h:
     60        * svg/SVGLengthContext.cpp:
     61        (WebCore::SVGLengthContext::determineViewport):
     62        * svg/SVGLengthContext.h:
     63        * svg/SVGSVGElement.cpp:
     64        (WebCore::SVGSVGElement::viewport):
     65        (WebCore::SVGSVGElement::localCoordinateSpaceTransform):
     66        (WebCore::SVGSVGElement::currentViewBoxRect):
     67        * svg/SVGUseElement.cpp:
     68        (WebCore::SVGUseElement::toClipPath):
     69
    1702011-11-12  Patrick Gansterer  <paroga@webkit.org>
    271
  • trunk/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp

    r99645 r100075  
    2626#include "SVGAnimatedProperty.h"
    2727#include "SVGException.h"
     28#include "SVGLengthContext.h"
    2829#include <runtime/Error.h>
    2930
     
    3637    SVGLength& podImp = impl()->propertyReference();
    3738    ExceptionCode ec = 0;
    38     float value = podImp.value(impl()->contextElement(), ec);
     39    SVGLengthContext lengthContext(impl()->contextElement());
     40    float value = podImp.value(lengthContext, ec);
    3941    if (ec) {
    4042        setDOMException(exec, ec);
     
    6062
    6163    ExceptionCode ec = 0;
    62     podImp.setValue(value.toFloat(exec), impl()->contextElement(), ec);
     64    SVGLengthContext lengthContext(impl()->contextElement());
     65    podImp.setValue(value.toFloat(exec), lengthContext, ec);
    6366    if (ec) {
    6467        setDOMException(exec, ec);
     
    8790
    8891    ExceptionCode ec = 0;
    89     podImp.convertToSpecifiedUnits(unitType, impl()->contextElement(), ec);
     92    SVGLengthContext lengthContext(impl()->contextElement());
     93    podImp.convertToSpecifiedUnits(unitType, lengthContext, ec);
    9094    if (ec) {
    9195        setDOMException(exec, ec);
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm

    r99645 r100075  
    12051205                # TODO: Handle special case for DOMSVGLength. We do need Custom code support for this.
    12061206                if ($svgPropertyType eq "WebCore::SVGLength" and $attributeName eq "value") {
    1207                     $getterContentHead = "value(IMPL->contextElement(), ";
     1207                    $getterContentHead = "value(WebCore::SVGLengthContext(IMPL->contextElement()), ";
    12081208                }
    12091209            }
     
    14071407                        # FIXME: Special case for DOMSVGLength. We do need Custom code support for this.
    14081408                        if ($svgPropertyType eq "WebCore::SVGLength" and $attributeName eq "value") {
    1409                             push(@implContent, "    podImpl.$coreSetterName($arg, IMPL->contextElement()$ec);\n");
     1409                            push(@implContent, "    podImpl.$coreSetterName($arg, WebCore::SVGLengthContext(IMPL->contextElement())$ec);\n");
    14101410                        } else {
    14111411                            push(@implContent, "    podImpl.$coreSetterName($arg$ec);\n");
     
    15411541            my $svgLengthConvertToSpecifiedUnits = ($svgPropertyType and $svgPropertyType eq "WebCore::SVGLength" and $functionName eq "convertToSpecifiedUnits");
    15421542
    1543             push(@parameterNames, "IMPL->contextElement()") if $svgLengthConvertToSpecifiedUnits;
     1543            push(@parameterNames, "WebCore::SVGLengthContext(IMPL->contextElement())") if $svgLengthConvertToSpecifiedUnits;
    15441544            push(@parameterNames, "ec") if $raisesExceptions;
    15451545
  • trunk/Source/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp

    r99645 r100075  
    3535
    3636#include "ExceptionCode.h"
     37#include "SVGLengthContext.h"
    3738#include "SVGPropertyTearOff.h"
    3839#include "V8Binding.h"
     
    4748    SVGLength& imp = wrapper->propertyReference();
    4849    ExceptionCode ec = 0;
    49     float value = imp.value(wrapper->contextElement(), ec);
     50    SVGLengthContext lengthContext(wrapper->contextElement());
     51    float value = imp.value(lengthContext, ec);
    5052    if (UNLIKELY(ec)) {
    5153        V8Proxy::setDOMException(ec);
     
    7173    SVGLength& imp = wrapper->propertyReference();
    7274    ExceptionCode ec = 0;
    73     imp.setValue(static_cast<float>(value->NumberValue()), wrapper->contextElement(), ec);
     75    SVGLengthContext lengthContext(wrapper->contextElement());
     76    imp.setValue(static_cast<float>(value->NumberValue()), lengthContext, ec);
    7477    if (UNLIKELY(ec))
    7578        V8Proxy::setDOMException(ec);
     
    9396    ExceptionCode ec = 0;
    9497    EXCEPTION_BLOCK(int, unitType, toUInt32(args[0]));
    95     imp.convertToSpecifiedUnits(unitType, wrapper->contextElement(), ec);
     98    SVGLengthContext lengthContext(wrapper->contextElement());
     99    imp.convertToSpecifiedUnits(unitType, lengthContext, ec);
    96100    if (UNLIKELY(ec))
    97101        V8Proxy::setDOMException(ec);
  • trunk/Source/WebCore/css/CSSCursorImageValue.cpp

    r99468 r100075  
    3131#if ENABLE(SVG)
    3232#include "SVGCursorElement.h"
     33#include "SVGLengthContext.h"
    3334#include "SVGNames.h"
    3435#include "SVGURIReference.h"
     
    9394    if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, element->document())) {
    9495        // FIXME: This will override hot spot specified in CSS, which is probably incorrect.
    95         float x = roundf(cursorElement->x().value(0));
     96        SVGLengthContext lengthContext(0);
     97        float x = roundf(cursorElement->x().value(lengthContext));
    9698        m_hotSpot.setX(static_cast<int>(x));
    9799
    98         float y = roundf(cursorElement->y().value(0));
     100        float y = roundf(cursorElement->y().value(lengthContext));
    99101        m_hotSpot.setY(static_cast<int>(y));
    100102
  • trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp

    r100045 r100075  
    135135
    136136    // Cache viewport boundaries
    137     FloatPoint viewportLocation(foreign->x().value(foreign), foreign->y().value(foreign));
    138     m_viewport = FloatRect(viewportLocation, FloatSize(foreign->width().value(foreign), foreign->height().value(foreign)));
     137    SVGLengthContext lengthContext(foreign);
     138    FloatPoint viewportLocation(foreign->x().value(lengthContext), foreign->y().value(lengthContext));
     139    m_viewport = FloatRect(viewportLocation, FloatSize(foreign->width().value(lengthContext), foreign->height().value(lengthContext)));
    139140    if (!updateCachedBoundariesInParents)
    140141        updateCachedBoundariesInParents = oldViewport != m_viewport;
  • trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp

    r98852 r100075  
    9898
    9999    FloatRect oldBoundaries = m_objectBoundingBox;
    100     m_objectBoundingBox = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image));
     100    SVGLengthContext lengthContext(image);
     101    m_objectBoundingBox = FloatRect(image->x().value(lengthContext), image->y().value(lengthContext), image->width().value(lengthContext), image->height().value(lengthContext));
    101102    if (m_objectBoundingBox != oldBoundaries) {
    102103        m_updateCachedRepaintRect = true;
  • trunk/Source/WebCore/rendering/svg/RenderSVGPath.cpp

    r99833 r100075  
    164164{
    165165    SVGElement* svgElement = static_cast<SVGElement*>(node());
    166     float strokeWidth = style()->svgStyle()->strokeWidth().value(svgElement);
     166    SVGLengthContext lengthContext(svgElement);
     167    float strokeWidth = style()->svgStyle()->strokeWidth().value(lengthContext);
    167168    return FloatRect(m_fillBoundingBox.x() - strokeWidth / 2, m_fillBoundingBox.y() - strokeWidth / 2, strokeWidth, strokeWidth);
    168169}
     
    346347        return FloatRect();
    347348
    348     return m_markerLayoutInfo.calculateBoundaries(markerStart, markerMid, markerEnd, svgStyle->strokeWidth().value(svgElement), m_path);
     349    SVGLengthContext lengthContext(svgElement);
     350    return m_markerLayoutInfo.calculateBoundaries(markerStart, markerMid, markerEnd, svgStyle->strokeWidth().value(lengthContext), m_path);
    349351}
    350352
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMarker.cpp

    r95901 r100075  
    9898    ASSERT(marker);
    9999
    100     return FloatPoint(marker->refX().value(marker), marker->refY().value(marker));
     100    SVGLengthContext lengthContext(marker);
     101    return FloatPoint(marker->refX().value(lengthContext), marker->refY().value(lengthContext));
    101102}
    102103
     
    164165    SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(node());
    165166    ASSERT(marker);
    166 
    167     float w = marker->markerWidth().value(marker);
    168     float h = marker->markerHeight().value(marker);
     167   
     168    SVGLengthContext lengthContext(marker);
     169    float w = marker->markerWidth().value(lengthContext);
     170    float h = marker->markerHeight().value(lengthContext);
    169171    m_viewport = FloatRect(0, 0, w, h);
    170172}
  • trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp

    r96859 r100075  
    256256    ASSERT(node());
    257257    ASSERT(node()->isSVGElement());
    258     strokeBoundaries.inflate(svgStyle->strokeWidth().value(static_cast<SVGElement*>(node())));
     258    SVGLengthContext lengthContext(static_cast<SVGElement*>(node()));
     259    strokeBoundaries.inflate(svgStyle->strokeWidth().value(lengthContext));
    259260    return strokeBoundaries;
    260261}
  • trunk/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp

    r77140 r100075  
    4646void RenderSVGViewportContainer::calcViewport()
    4747{
    48      SVGElement* element = static_cast<SVGElement*>(node());
    49      if (element->hasTagName(SVGNames::svgTag)) {
    50          SVGSVGElement* svg = static_cast<SVGSVGElement*>(element);
     48    SVGElement* element = static_cast<SVGElement*>(node());
     49    if (!element->hasTagName(SVGNames::svgTag))
     50        return;
     51    SVGSVGElement* svg = static_cast<SVGSVGElement*>(element);
     52    FloatRect oldViewport = m_viewport;
    5153
    52          FloatRect oldViewport = m_viewport;
    53          m_viewport = FloatRect(svg->x().value(svg)
    54                                 , svg->y().value(svg)
    55                                 , svg->width().value(svg)
    56                                 , svg->height().value(svg));
     54    SVGLengthContext lengthContext(element);
     55    m_viewport = FloatRect(svg->x().value(lengthContext), svg->y().value(lengthContext), svg->width().value(lengthContext), svg->height().value(lengthContext));
    5756
    58         if (oldViewport != m_viewport)
    59             setNeedsBoundariesUpdate();
    60     }
     57    if (oldViewport != m_viewport)
     58        setNeedsBoundariesUpdate();
    6159}
    6260
  • trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp

    r100073 r100075  
    349349    ASSERT(svgStyle);
    350350
    351     SVGElement* lengthContext = static_cast<SVGElement*>(object->node());
     351    SVGLengthContext lengthContext(static_cast<SVGElement*>(object->node()));
    352352    context->setStrokeThickness(svgStyle->strokeWidth().value(lengthContext));
    353353    context->setLineCap(svgStyle->capStyle());
  • trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp

    r99854 r100075  
    301301            writeSVGPaintingResource(ts, strokePaintingResource);
    302302
    303             SVGElement* element = static_cast<SVGElement*>(path.node());
    304             double dashOffset = svgStyle->strokeDashOffset().value(element);
    305             double strokeWidth = svgStyle->strokeWidth().value(element);
     303            SVGLengthContext lengthContext(static_cast<SVGElement*>(path.node()));
     304            double dashOffset = svgStyle->strokeDashOffset().value(lengthContext);
     305            double strokeWidth = svgStyle->strokeWidth().value(lengthContext);
    306306            const Vector<SVGLength>& dashes = svgStyle->strokeDashArray();
    307307
     
    309309            const Vector<SVGLength>::const_iterator end = dashes.end();
    310310            for (Vector<SVGLength>::const_iterator it = dashes.begin(); it != end; ++it)
    311                 dashArray.append((*it).value(element));
     311                dashArray.append((*it).value(lengthContext));
    312312
    313313            writeIfNotDefault(ts, "opacity", svgStyle->strokeOpacity(), 1.0f);
     
    353353    ASSERT(path.node()->isSVGElement());
    354354    SVGElement* svgElement = static_cast<SVGElement*>(path.node());
     355    SVGLengthContext lengthContext(svgElement);
    355356
    356357    if (svgElement->hasTagName(SVGNames::rectTag)) {
    357358        SVGRectElement* element = static_cast<SVGRectElement*>(svgElement);
    358         writeNameValuePair(ts, "x", element->x().value(element));
    359         writeNameValuePair(ts, "y", element->y().value(element));
    360         writeNameValuePair(ts, "width", element->width().value(element));
    361         writeNameValuePair(ts, "height", element->height().value(element));
     359        writeNameValuePair(ts, "x", element->x().value(lengthContext));
     360        writeNameValuePair(ts, "y", element->y().value(lengthContext));
     361        writeNameValuePair(ts, "width", element->width().value(lengthContext));
     362        writeNameValuePair(ts, "height", element->height().value(lengthContext));
    362363    } else if (svgElement->hasTagName(SVGNames::lineTag)) {
    363364        SVGLineElement* element = static_cast<SVGLineElement*>(svgElement);
    364         writeNameValuePair(ts, "x1", element->x1().value(element));
    365         writeNameValuePair(ts, "y1", element->y1().value(element));
    366         writeNameValuePair(ts, "x2", element->x2().value(element));
    367         writeNameValuePair(ts, "y2", element->y2().value(element));
     365        writeNameValuePair(ts, "x1", element->x1().value(lengthContext));
     366        writeNameValuePair(ts, "y1", element->y1().value(lengthContext));
     367        writeNameValuePair(ts, "x2", element->x2().value(lengthContext));
     368        writeNameValuePair(ts, "y2", element->y2().value(lengthContext));
    368369    } else if (svgElement->hasTagName(SVGNames::ellipseTag)) {
    369370        SVGEllipseElement* element = static_cast<SVGEllipseElement*>(svgElement);
    370         writeNameValuePair(ts, "cx", element->cx().value(element));
    371         writeNameValuePair(ts, "cy", element->cy().value(element));
    372         writeNameValuePair(ts, "rx", element->rx().value(element));
    373         writeNameValuePair(ts, "ry", element->ry().value(element));
     371        writeNameValuePair(ts, "cx", element->cx().value(lengthContext));
     372        writeNameValuePair(ts, "cy", element->cy().value(lengthContext));
     373        writeNameValuePair(ts, "rx", element->rx().value(lengthContext));
     374        writeNameValuePair(ts, "ry", element->ry().value(lengthContext));
    374375    } else if (svgElement->hasTagName(SVGNames::circleTag)) {
    375376        SVGCircleElement* element = static_cast<SVGCircleElement*>(svgElement);
    376         writeNameValuePair(ts, "cx", element->cx().value(element));
    377         writeNameValuePair(ts, "cy", element->cy().value(element));
    378         writeNameValuePair(ts, "r", element->r().value(element));
     377        writeNameValuePair(ts, "cx", element->cx().value(lengthContext));
     378        writeNameValuePair(ts, "cy", element->cy().value(lengthContext));
     379        writeNameValuePair(ts, "r", element->r().value(lengthContext));
    379380    } else if (svgElement->hasTagName(SVGNames::polygonTag) || svgElement->hasTagName(SVGNames::polylineTag)) {
    380381        SVGPolyElement* element = static_cast<SVGPolyElement*>(svgElement);
  • trunk/Source/WebCore/rendering/svg/SVGShadowTreeElements.cpp

    r96803 r100075  
    5454FloatSize SVGShadowTreeContainerElement::containerTranslation() const
    5555{
    56     return FloatSize(m_xOffset.value(this), m_yOffset.value(this));
     56    SVGLengthContext lengthContext(this);
     57    return FloatSize(m_xOffset.value(lengthContext), m_yOffset.value(lengthContext));
    5758}
    5859
  • trunk/Source/WebCore/rendering/svg/SVGTextChunkBuilder.cpp

    r95901 r100075  
    2626#include "SVGElement.h"
    2727#include "SVGInlineTextBox.h"
     28#include "SVGLengthContext.h"
    2829
    2930namespace WebCore {
     
    128129    float desiredTextLength = 0;
    129130    if (SVGTextContentElement* textContentElement = SVGTextContentElement::elementFromRenderer(textRenderer->parent())) {
    130         desiredTextLength = textContentElement->specifiedTextLength().value(textContentElement);
     131        SVGLengthContext lengthContext(textContentElement);
     132        desiredTextLength = textContentElement->specifiedTextLength().value(lengthContext);
    131133
    132134        switch (textContentElement->lengthAdjust()) {
  • trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp

    r95901 r100075  
    6161}
    6262
    63 static inline void extractFloatValuesFromSVGLengthList(SVGElement* lengthContext, const SVGLengthList& list, Vector<float>& floatValues, unsigned textContentLength)
    64 {
    65     ASSERT(lengthContext);
     63static inline void extractFloatValuesFromSVGLengthList(SVGElement* contextElement, const SVGLengthList& list, Vector<float>& floatValues, unsigned textContentLength)
     64{
     65    ASSERT(contextElement);
    6666
    6767    unsigned length = list.size();
     
    7070    floatValues.reserveCapacity(length);
    7171
     72    SVGLengthContext lengthContext(contextElement);
    7273    for (unsigned i = 0; i < length; ++i) {
    7374        const SVGLength& length = list.at(i);
  • trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp

    r95901 r100075  
    2727#include "SVGElement.h"
    2828#include "SVGInlineTextBox.h"
     29#include "SVGLengthContext.h"
    2930#include "SVGTextLayoutEngineBaseline.h"
    3031#include "SVGTextLayoutEngineSpacing.h"
     
    156157    while (currentParent) {
    157158        if (SVGTextContentElement* textContentElement = SVGTextContentElement::elementFromRenderer(currentParent)) {
    158             if (textContentElement->lengthAdjust() == SVGLengthAdjustSpacing && textContentElement->specifiedTextLength().value(textContentElement) > 0)
     159            SVGLengthContext lengthContext(textContentElement);
     160            if (textContentElement->lengthAdjust() == SVGLengthAdjustSpacing && textContentElement->specifiedTextLength().value(lengthContext) > 0)
    159161                return true;
    160162        }
     
    211213
    212214    if (SVGTextContentElement* textContentElement = SVGTextContentElement::elementFromRenderer(textPath)) {
     215        SVGLengthContext lengthContext(textContentElement);
    213216        lengthAdjust = textContentElement->lengthAdjust();
    214         desiredTextLength = textContentElement->specifiedTextLength().value(textContentElement);
     217        desiredTextLength = textContentElement->specifiedTextLength().value(lengthContext);
    215218    }
    216219
  • trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp

    r95901 r100075  
    2525#include "Font.h"
    2626#include "RenderObject.h"
     27#include "SVGLengthContext.h"
    2728#include "SVGRenderStyle.h"
    2829#include "SVGTextMetrics.h"
     
    3637}
    3738
    38 float SVGTextLayoutEngineBaseline::calculateBaselineShift(const SVGRenderStyle* style, SVGElement* lengthContext) const
     39float SVGTextLayoutEngineBaseline::calculateBaselineShift(const SVGRenderStyle* style, SVGElement* contextElement) const
    3940{
    4041    if (style->baselineShift() == BS_LENGTH) {
     
    4344            return baselineShiftValueLength.valueAsPercentage() * m_font.pixelSize();
    4445
     46        SVGLengthContext lengthContext(contextElement);
    4547        return baselineShiftValueLength.value(lengthContext);
    4648    }
  • trunk/Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp

    r95901 r100075  
    2424
    2525#include "Font.h"
     26#include "SVGLengthContext.h"
    2627#include "SVGRenderStyle.h"
    2728
     
    8384}
    8485
    85 float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderStyle* style, SVGElement* lengthContext, const UChar* currentCharacter)
     86float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderStyle* style, SVGElement* contextElement, const UChar* currentCharacter)
    8687{
    8788    float kerning = 0;
     
    8990    if (kerningLength.unitType() == LengthTypePercentage)
    9091        kerning = kerningLength.valueAsPercentage() * m_font.pixelSize();
    91     else
     92    else {
     93        SVGLengthContext lengthContext(contextElement);
    9294        kerning = kerningLength.value(lengthContext);
     95    }
    9396
    9497    const UChar* lastCharacter = m_lastCharacter;
  • trunk/Source/WebCore/svg/SVGElement.h

    r99561 r100075  
    2424
    2525#if ENABLE(SVG)
    26 #include "SVGLengthContext.h"
    2726#include "SVGLocatable.h"
    2827#include "SVGParsingError.h"
     
    6362    virtual bool isGradientStop() const { return false; }
    6463    virtual bool isTextContent() const { return false; }
    65 
    66     // FIXME: This is a temporary construct to aid reducing the impact of introducing SVGLengthContext.
    67     // It will be removed once all code that uses x().value(this) is gone.
    68     operator SVGLengthContext() const { return SVGLengthContext(this); }
    6964
    7065    // For SVGTests
  • trunk/Source/WebCore/svg/SVGLengthContext.cpp

    r99669 r100075  
    312312        FloatRect viewBox = svg->currentViewBoxRect();
    313313        if (viewBox.isEmpty()) {
    314             width = svg->width().value(svg);
    315             height = svg->height().value(svg);
     314            SVGLengthContext viewportContext(svg);
     315            width = svg->width().value(viewportContext);
     316            height = svg->height().value(viewportContext);
    316317        } else {
    317318            width = viewBox.width();
  • trunk/Source/WebCore/svg/SVGLengthContext.h

    r99645 r100075  
    5454class SVGLengthContext {
    5555public:
    56     SVGLengthContext(const SVGElement*);
     56    explicit SVGLengthContext(const SVGElement*);
    5757
    5858    template<typename T>
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r99539 r100075  
    145145FloatRect SVGSVGElement::viewport() const
    146146{
     147    // FIXME: This method doesn't follow the spec and is basically untested. Parent documents are not considered here.
     148    SVGLengthContext lengthContext(this);
    147149    FloatRect viewRectangle;
    148150    if (!isOutermostSVG())
    149         viewRectangle.setLocation(FloatPoint(x().value(this), y().value(this)));
    150 
    151     viewRectangle.setSize(FloatSize(width().value(this), height().value(this)));   
     151        viewRectangle.setLocation(FloatPoint(x().value(lengthContext), y().value(lengthContext)));
     152
     153    viewRectangle.setSize(FloatSize(width().value(lengthContext), height().value(lengthContext)));   
    152154    return viewBoxToViewTransform(viewRectangle.width(), viewRectangle.height()).mapRect(viewRectangle);
    153155}
     
    453455AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const
    454456{
     457    // This method resolves length manually, w/o involving the render tree. This is desired, as getCTM()/getScreenCTM()/.. have to work without a renderer.
     458    SVGLengthContext lengthContext(this);
     459
    455460    AffineTransform viewBoxTransform;
    456461    if (attributes()->getAttributeItem(SVGNames::viewBoxAttr))
    457         viewBoxTransform = viewBoxToViewTransform(width().value(this), height().value(this));
     462        viewBoxTransform = viewBoxToViewTransform(width().value(lengthContext), height().value(lengthContext));
    458463
    459464    AffineTransform transform;
    460465    if (!isOutermostSVG())
    461         transform.translate(x().value(this), y().value(this));
     466        transform.translate(x().value(lengthContext), y().value(lengthContext));
    462467    else if (mode == SVGLocatable::ScreenScope) {
    463468        if (RenderObject* renderer = this->renderer()) {
     
    554559FloatRect SVGSVGElement::currentViewBoxRect(CalculateViewBoxMode mode) const
    555560{
     561    // This method resolves length manually, w/o involving the render tree. This is desired, as getCTM()/getScreenCTM()/.. have to work without a renderer.
     562    SVGLengthContext lengthContext(this);
     563
    556564    // FIXME: The interaction of 'currentView' and embedding SVGs in other documents, is untested and unspecified.
    557565    if (useCurrentView()) {
     
    569577        // should always synthesize a viewBox if we're embedded through a SVGImage.
    570578        if (hasFixedSize && isEmbeddedThroughSVGImage)
    571             return FloatRect(0, 0, width().value(this), height().value(this));
     579            return FloatRect(0, 0, width().value(lengthContext), height().value(lengthContext));
    572580        return FloatRect();
    573581    }
     
    577585    // embedded document sees specified viewBox only.
    578586    if (hasFixedSize && mode == CalculateViewBoxInHostDocument)
    579         return FloatRect(0, 0, width().value(this), height().value(this));
     587        return FloatRect(0, 0, width().value(lengthContext), height().value(lengthContext));
    580588
    581589    return useViewBox;
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r100046 r100075  
    4040#include "SVGElementInstanceList.h"
    4141#include "SVGGElement.h"
     42#include "SVGLengthContext.h"
    4243#include "SVGNames.h"
    4344#include "SVGSMILElement.h"
     
    679680        else {
    680681            static_cast<SVGStyledTransformableElement*>(n)->toClipPath(path);
    681             path.translate(FloatSize(x().value(this), y().value(this)));
     682            // FIXME: Avoid manual resolution of x/y here. Its potentially harmful.
     683            SVGLengthContext lengthContext(this);
     684            path.translate(FloatSize(x().value(lengthContext), y().value(lengthContext)));
    682685            path.transform(animatedLocalTransform());
    683686        }
Note: See TracChangeset for help on using the changeset viewer.