Changeset 23509 in webkit


Ignore:
Timestamp:
Jun 13, 2007 4:14:48 PM (17 years ago)
Author:
rwlbuis
Message:

Reviewed by Eric.

http://bugs.webkit.org/show_bug.cgi?id=12207
RenderSVGContainer should be split into multiple classes
http://bugs.webkit.org/show_bug.cgi?id=14125
KCanvasRenderingStyle should be removed

Introduce the RenderSVGRoot class and kill the KCanvas enums.

Location:
branches/feature-branch/WebCore
Files:
2 added
2 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-branch/WebCore/ChangeLog

    r22098 r23509  
     12007-06-14  Rob Buis  <buis@kde.org>
     2
     3        Reviewed by Eric.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=12207
     6        RenderSVGContainer should be split into multiple classes
     7        http://bugs.webkit.org/show_bug.cgi?id=14125
     8        KCanvasRenderingStyle should be removed
     9
     10        Introduce the RenderSVGRoot class and kill the KCanvas enums.
     11
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * ksvg2/css/SVGRenderStyle.cpp:
     14        (WebCore::SVGRenderStyle::cssPrimitiveToLength):
     15        * ksvg2/css/SVGRenderStyle.h:
     16        * ksvg2/misc/KCanvasRenderingStyle.cpp: Removed.
     17        * ksvg2/misc/KCanvasRenderingStyle.h: Removed.
     18        * ksvg2/svg/SVGMarkerElement.cpp:
     19        (WebCore::SVGMarkerElement::createRenderer):
     20        (WebCore::SVGMarkerElement::notifyAttributeChange):
     21        * ksvg2/svg/SVGSVGElement.cpp:
     22        (WebCore::SVGSVGElement::createRenderer):
     23        * ksvg2/svg/SVGSVGElement.h:
     24        * platform/graphics/svg/SVGPaintServer.cpp:
     25        (WebCore::sharedSolidPaintServer):
     26        (WebCore::SVGPaintServer::fillPaintServer):
     27        (WebCore::SVGPaintServer::strokePaintServer):
     28        (WebCore::dashArrayFromRenderingStyle):
     29        * platform/graphics/svg/SVGPaintServer.h:
     30        * platform/graphics/svg/cg/CgSupport.cpp:
     31        (WebCore::applyStrokeStyleToContext):
     32        * platform/graphics/svg/cg/RenderPathCg.cpp:
     33        (WebCore::RenderPath::strokeContains):
     34        * rendering/RenderPath.cpp:
     35        (WebCore::RenderPath::fillContains):
     36        (WebCore::fillAndStrokePath):
     37        (WebCore::RenderPath::drawMarkersIfNeeded):
     38        * rendering/RenderSVGContainer.cpp:
     39        (WebCore::RenderSVGContainer::requiresLayer):
     40        (WebCore::RenderSVGContainer::layout):
     41        (WebCore::RenderSVGContainer::applyContentTransforms):
     42        (WebCore::RenderSVGContainer::paint):
     43        (WebCore::RenderSVGContainer::setAlign):
     44        (WebCore::RenderSVGContainer::align):
     45        (WebCore::RenderSVGContainer::viewportTransform):
     46        (WebCore::RenderSVGContainer::absoluteTransform):
     47        (WebCore::RenderSVGContainer::getAspectRatio):
     48        * rendering/RenderSVGContainer.h:
     49        * rendering/RenderSVGInlineText.cpp:
     50        * rendering/RenderSVGRoot.cpp: Added.
     51        (WebCore::RenderSVGRoot::RenderSVGRoot):
     52        (WebCore::RenderSVGRoot::~RenderSVGRoot):
     53        (WebCore::RenderSVGRoot::localTransform):
     54        (WebCore::RenderSVGRoot::setLocalTransform):
     55        (WebCore::RenderSVGRoot::requiresLayer):
     56        (WebCore::RenderSVGRoot::lineHeight):
     57        (WebCore::RenderSVGRoot::baselinePosition):
     58        (WebCore::RenderSVGRoot::layout):
     59        (WebCore::RenderSVGRoot::applyContentTransforms):
     60        (WebCore::RenderSVGRoot::paint):
     61        (WebCore::RenderSVGRoot::viewport):
     62        (WebCore::RenderSVGRoot::calcViewport):
     63        (WebCore::RenderSVGRoot::setViewBox):
     64        (WebCore::RenderSVGRoot::viewBox):
     65        (WebCore::RenderSVGRoot::setAlign):
     66        (WebCore::RenderSVGRoot::align):
     67        (WebCore::RenderSVGRoot::viewportTransform):
     68        (WebCore::RenderSVGRoot::absoluteClippedOverflowRect):
     69        (WebCore::RenderSVGRoot::addFocusRingRects):
     70        (WebCore::RenderSVGRoot::absoluteRects):
     71        (WebCore::RenderSVGRoot::absoluteTransform):
     72        (WebCore::RenderSVGRoot::fillContains):
     73        (WebCore::RenderSVGRoot::strokeContains):
     74        (WebCore::RenderSVGRoot::relativeBBox):
     75        (WebCore::RenderSVGRoot::setSlice):
     76        (WebCore::RenderSVGRoot::slice):
     77        (WebCore::RenderSVGRoot::getAspectRatio):
     78        (WebCore::RenderSVGRoot::nodeAtPoint):
     79        * rendering/RenderSVGRoot.h: Added.
     80        (WebCore::RenderSVGRoot::isSVGContainer):
     81        (WebCore::RenderSVGRoot::renderName):
     82        * rendering/RenderSVGTSpan.cpp:
     83        * rendering/RenderSVGText.cpp:
     84        (WebCore::RenderSVGText::relativeBBox):
     85        * rendering/SVGRenderTreeAsText.cpp:
     86        (WebCore::operator<<):
     87        (WebCore::writeStyle):
     88        * rendering/SVGRootInlineBox.cpp:
     89        (WebCore::SVGRootInlineBox::paint):
     90        (WebCore::SVGRootInlineBox::paintInlineBoxes):
     91
    1922007-06-12  Nikolas Zimmermann  <zimmermann@kde.org>
    293
  • branches/feature-branch/WebCore/WebCore.xcodeproj/project.pbxproj

    r22028 r23509  
    19001900                A88AD40A095248F0001DD196 /* SVGZoomEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F7F5089701F300BA5114 /* SVGZoomEvent.cpp */; };
    19011901                A88AD40B095248F0001DD196 /* SVGZoomEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0F7F6089701F300BA5114 /* SVGZoomEvent.h */; };
    1902                 A88AD40C095248F0001DD196 /* KCanvasRenderingStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F6EB089701F100BA5114 /* KCanvasRenderingStyle.cpp */; };
    1903                 A88AD40D095248F0001DD196 /* KCanvasRenderingStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0F6EC089701F100BA5114 /* KCanvasRenderingStyle.h */; };
    19041902                A88AD40E095248F0001DD196 /* TimeScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F6EF089701F100BA5114 /* TimeScheduler.cpp */; };
    19051903                A88AD40F095248F0001DD196 /* TimeScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0F6F0089701F100BA5114 /* TimeScheduler.h */; };
     
    22592257                AA21ECCA0ABF0FBA002B834C /* CSSCursorImageValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA0978ED0ABAA6E100874480 /* CSSCursorImageValue.cpp */; };
    22602258                AA21ECCD0ABF0FC6002B834C /* CSSCursorImageValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AA0978EE0ABAA6E100874480 /* CSSCursorImageValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2259                AA31B5B40C1DFD1000AE7083 /* RenderSVGRoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA31B5B20C1DFD1000AE7083 /* RenderSVGRoot.cpp */; };
     2260                AA31B5B50C1DFD1000AE7083 /* RenderSVGRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = AA31B5B30C1DFD1000AE7083 /* RenderSVGRoot.h */; };
    22612261                AA4C3A760B2B1679002334A2 /* StyleElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA4C3A740B2B1679002334A2 /* StyleElement.cpp */; };
    22622262                AA4C3A770B2B1679002334A2 /* StyleElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AA4C3A750B2B1679002334A2 /* StyleElement.h */; };
     
    49884988                A89943260B42338700D7C802 /* BitmapImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitmapImage.h; sourceTree = "<group>"; };
    49894989                A89943270B42338700D7C802 /* BitmapImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitmapImage.cpp; sourceTree = "<group>"; };
    4990                 A8C0F6EB089701F100BA5114 /* KCanvasRenderingStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasRenderingStyle.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    4991                 A8C0F6EC089701F100BA5114 /* KCanvasRenderingStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasRenderingStyle.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    49924990                A8C0F6EF089701F100BA5114 /* TimeScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeScheduler.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    49934991                A8C0F6F0089701F100BA5114 /* TimeScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = TimeScheduler.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    53535351                AA0978ED0ABAA6E100874480 /* CSSCursorImageValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCursorImageValue.cpp; sourceTree = "<group>"; };
    53545352                AA0978EE0ABAA6E100874480 /* CSSCursorImageValue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSCursorImageValue.h; sourceTree = "<group>"; };
     5353                AA31B5B20C1DFD1000AE7083 /* RenderSVGRoot.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGRoot.cpp; sourceTree = "<group>"; };
     5354                AA31B5B30C1DFD1000AE7083 /* RenderSVGRoot.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSVGRoot.h; sourceTree = "<group>"; };
    53555355                AA4C3A740B2B1679002334A2 /* StyleElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StyleElement.cpp; sourceTree = "<group>"; };
    53565356                AA4C3A750B2B1679002334A2 /* StyleElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = StyleElement.h; sourceTree = "<group>"; };
     
    83068306                                AA882B2D0B4EF5EB006D26D1 /* PointerEventsHitRules.cpp */,
    83078307                                AA882B2E0B4EF5EB006D26D1 /* PointerEventsHitRules.h */,
    8308                                 A8C0F6EB089701F100BA5114 /* KCanvasRenderingStyle.cpp */,
    8309                                 A8C0F6EC089701F100BA5114 /* KCanvasRenderingStyle.h */,
    83108308                                A8C0F6EF089701F100BA5114 /* TimeScheduler.cpp */,
    83118309                                A8C0F6F0089701F100BA5114 /* TimeScheduler.h */,
     
    94869484                        isa = PBXGroup;
    94879485                        children = (
     9486                                AA31B5B20C1DFD1000AE7083 /* RenderSVGRoot.cpp */,
     9487                                AA31B5B30C1DFD1000AE7083 /* RenderSVGRoot.h */,
    94889488                                A8CFF04B0A154F09000A4234 /* AutoTableLayout.cpp */,
    94899489                                A8CFF0490A154F09000A4234 /* AutoTableLayout.h */,
     
    98659865                                A88AD404095248F0001DD196 /* SVGRenderStyleDefs.h in Headers */,
    98669866                                A88AD40B095248F0001DD196 /* SVGZoomEvent.h in Headers */,
    9867                                 A88AD40D095248F0001DD196 /* KCanvasRenderingStyle.h in Headers */,
    98689867                                A88AD40F095248F0001DD196 /* TimeScheduler.h in Headers */,
    98699868                                A88AD412095248F0001DD196 /* SVGAElement.h in Headers */,
     
    1130111300                                14C9A29A0BF04DB600D734A8 /* WebScriptObjectPendingPublic.h in Headers */,
    1130211301                                A8F4FB940C169E7B002AFED5 /* SVGRenderSupport.h in Headers */,
     11302                                AA31B5B50C1DFD1000AE7083 /* RenderSVGRoot.h in Headers */,
    1130311303                        );
    1130411304                        runOnlyForDeploymentPostprocessing = 0;
     
    1150611506                                A88AD403095248F0001DD196 /* SVGRenderStyleDefs.cpp in Sources */,
    1150711507                                A88AD40A095248F0001DD196 /* SVGZoomEvent.cpp in Sources */,
    11508                                 A88AD40C095248F0001DD196 /* KCanvasRenderingStyle.cpp in Sources */,
    1150911508                                A88AD40E095248F0001DD196 /* TimeScheduler.cpp in Sources */,
    1151011509                                A88AD411095248F0001DD196 /* SVGAElement.cpp in Sources */,
     
    1267812677                                AACF144D0BEC1EF000827982 /* TextBreakIteratorInternalICUMac.mm in Sources */,
    1267912678                                A8F4FB960C169E85002AFED5 /* SVGRenderSupport.cpp in Sources */,
     12679                                AA31B5B40C1DFD1000AE7083 /* RenderSVGRoot.cpp in Sources */,
    1268012680                        );
    1268112681                        runOnlyForDeploymentPostprocessing = 0;
  • branches/feature-branch/WebCore/ksvg2/css/SVGRenderStyle.cpp

    r19992 r23509  
    3030#if ENABLE(SVG)
    3131#include "SVGRenderStyle.h"
     32
     33#include "CSSPrimitiveValue.h"
     34#include "CSSValueList.h"
     35#include "RenderObject.h"
     36#include "RenderStyle.h"
     37#include "SVGStyledElement.h"
    3238
    3339namespace WebCore {
     
    116122}
    117123
     124double SVGRenderStyle::cssPrimitiveToLength(const RenderObject* item, CSSValue* value, double defaultValue)
     125{
     126    CSSPrimitiveValue* primitive = static_cast<CSSPrimitiveValue*>(value);
     127
     128    unsigned short cssType = (primitive ? primitive->primitiveType() : (unsigned short) CSSPrimitiveValue::CSS_UNKNOWN);
     129    if (!(cssType > CSSPrimitiveValue::CSS_UNKNOWN && cssType <= CSSPrimitiveValue::CSS_PC))
     130        return defaultValue;
     131
     132    if (cssType == CSSPrimitiveValue::CSS_PERCENTAGE) {
     133        SVGStyledElement* element = static_cast<SVGStyledElement*>(item->element());
     134        SVGElement* viewportElement = (element ? element->viewportElement() : 0);
     135        if (viewportElement) {
     136            double result = primitive->getFloatValue() / 100.0;
     137            return SVGLength::PercentageOfViewport(result, element, LengthModeOther);
     138        }
     139    }
     140
     141    return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()));
     142}
     143
    118144}
    119145
  • branches/feature-branch/WebCore/ksvg2/css/SVGRenderStyle.h

    r19992 r23509  
    3939
    4040namespace WebCore {
     41
     42    class RenderObject;
     43    class RenderStyle;
    4144
    4245    class SVGRenderStyle : public Shared<SVGRenderStyle> {   
     
    103106        bool hasStroke() const { return (strokePaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE); }
    104107        bool hasFill() const { return (fillPaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE); }
     108
     109        static double cssPrimitiveToLength(const RenderObject*, CSSValue*, double defaultValue = 0.0);
    105110
    106111    protected:
  • branches/feature-branch/WebCore/ksvg2/svg/SVGMarkerElement.cpp

    r21272 r23509  
    138138    RenderSVGContainer* markerContainer = new (arena) RenderSVGContainer(this);
    139139    markerContainer->setViewBox(viewBox());
    140     markerContainer->setAlign(KCAlign(preserveAspectRatio()->align() - 1));
     140    markerContainer->setAlign(SVGPreserveAspectRatio::SVGPreserveAspectRatioType(preserveAspectRatio()->align()));
    141141    markerContainer->setSlice(preserveAspectRatio()->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE);
    142142    markerContainer->setDrawsContents(false); // Marker contents will be explicitly drawn.
     
    154154    if (markerContainer) {
    155155        markerContainer->setViewBox(viewBox());
    156         markerContainer->setAlign(KCAlign(preserveAspectRatio()->align() - 1));
     156        markerContainer->setAlign(SVGPreserveAspectRatio::SVGPreserveAspectRatioType(preserveAspectRatio()->align()));
    157157        markerContainer->setSlice(preserveAspectRatio()->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE);
    158158    }
  • branches/feature-branch/WebCore/ksvg2/svg/SVGSVGElement.cpp

    r21895 r23509  
    3434#include "HTMLNames.h"
    3535#include "RenderSVGContainer.h"
     36#include "RenderSVGRoot.h"
    3637#include "SVGAngle.h"
    3738#include "SVGLength.h"
     
    357358RenderObject* SVGSVGElement::createRenderer(RenderArena* arena, RenderStyle*)
    358359{
    359     RenderSVGContainer* rootContainer = new (arena) RenderSVGContainer(this);
    360 
    361     // FIXME: All this setup should be done after attributesChanged, not here.
    362     rootContainer->setViewBox(viewBox());
    363     rootContainer->setAlign(KCAlign(preserveAspectRatio()->align() - 1));
    364     rootContainer->setSlice(preserveAspectRatio()->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE);
    365    
    366     return rootContainer;
     360    if (!parentNode()->isSVGElement()) {
     361        RenderSVGRoot* rootContainer = new (arena) RenderSVGRoot(this);
     362        // FIXME: All this setup should be done after attributesChanged, not here.
     363        rootContainer->setViewBox(viewBox());
     364        rootContainer->setAlign(SVGPreserveAspectRatio::SVGPreserveAspectRatioType(preserveAspectRatio()->align()));
     365        rootContainer->setSlice(preserveAspectRatio()->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE);
     366        return rootContainer;
     367    } else  {
     368        RenderSVGContainer* rootContainer = new (arena) RenderSVGContainer(this);
     369
     370        // FIXME: All this setup should be done after attributesChanged, not here.
     371        rootContainer->setViewBox(viewBox());
     372        rootContainer->setAlign(SVGPreserveAspectRatio::SVGPreserveAspectRatioType(preserveAspectRatio()->align()));
     373        rootContainer->setSlice(preserveAspectRatio()->meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE);
     374        return rootContainer;
     375    }
    367376}
    368377
  • branches/feature-branch/WebCore/ksvg2/svg/SVGSVGElement.h

    r21895 r23509  
    127127
    128128        friend class RenderSVGContainer;
     129        friend class RenderSVGRoot;
    129130        virtual bool hasRelativeValues() const;
    130131
  • branches/feature-branch/WebCore/platform/graphics/svg/SVGPaintServer.cpp

    r19855 r23509  
    2929#include "SVGPaintServer.h"
    3030
     31#include "RenderObject.h"
     32#include "RenderStyle.h"
     33#include "SVGPaintServerSolid.h"
     34#include "SVGStyledElement.h"
     35#include "SVGURIReference.h"
     36
    3137namespace WebCore {
    3238
     
    5359}
    5460
     61static SVGPaintServerSolid* sharedSolidPaintServer()
     62{
     63    static SVGPaintServerSolid* _sharedSolidPaintServer = 0;
     64    if (!_sharedSolidPaintServer)
     65        _sharedSolidPaintServer = new SVGPaintServerSolid();
     66    return _sharedSolidPaintServer;
     67}
     68
     69SVGPaintServer* SVGPaintServer::fillPaintServer(const RenderStyle* style, const RenderObject* item)
     70{
     71    if (!style->svgStyle()->hasFill())
     72        return 0;
     73
     74    SVGPaint* fill = style->svgStyle()->fillPaint();
     75
     76    SVGPaintServer* fillPaintServer = 0;
     77    if (fill->paintType() == SVGPaint::SVG_PAINTTYPE_URI) {
     78        AtomicString id(SVGURIReference::getTarget(fill->uri()));
     79        fillPaintServer = getPaintServerById(item->document(), id);
     80
     81        SVGElement* svgElement = static_cast<SVGElement*>(item->element());
     82        ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
     83
     84        if (item->isRenderPath() && fillPaintServer)
     85            fillPaintServer->addClient(static_cast<SVGStyledElement*>(svgElement));
     86        else if (!fillPaintServer)
     87            svgElement->document()->accessSVGExtensions()->addPendingResource(id, static_cast<SVGStyledElement*>(svgElement));
     88    } else {
     89        fillPaintServer = sharedSolidPaintServer();
     90        SVGPaintServerSolid* fillPaintServerSolid = static_cast<SVGPaintServerSolid*>(fillPaintServer);
     91        if (fill->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR)
     92            fillPaintServerSolid->setColor(style->color());
     93        else
     94            fillPaintServerSolid->setColor(fill->color());
     95        // FIXME: Ideally invalid colors would never get set on the RenderStyle and this could turn into an ASSERT
     96        if (!fillPaintServerSolid->color().isValid())
     97            fillPaintServer = 0;
     98    }
     99    if (!fillPaintServer) {
     100        // default value (black), see bug 11017
     101        fillPaintServer = sharedSolidPaintServer();
     102        static_cast<SVGPaintServerSolid*>(fillPaintServer)->setColor(Color::black);
     103    }
     104    return fillPaintServer;
     105}
     106
     107SVGPaintServer* SVGPaintServer::strokePaintServer(const RenderStyle* style, const RenderObject* item)
     108{
     109    if (!style->svgStyle()->hasStroke())
     110        return 0;
     111
     112    SVGPaint* stroke = style->svgStyle()->strokePaint();
     113
     114    SVGPaintServer* strokePaintServer = 0;
     115    if (stroke->paintType() == SVGPaint::SVG_PAINTTYPE_URI) {
     116        AtomicString id(SVGURIReference::getTarget(stroke->uri()));
     117        strokePaintServer = getPaintServerById(item->document(), id);
     118
     119        SVGElement* svgElement = static_cast<SVGElement*>(item->element());
     120        ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
     121 
     122        if (item->isRenderPath() && strokePaintServer)
     123            strokePaintServer->addClient(static_cast<SVGStyledElement*>(svgElement));
     124        else if (!strokePaintServer)
     125            svgElement->document()->accessSVGExtensions()->addPendingResource(id, static_cast<SVGStyledElement*>(svgElement));
     126    } else {
     127        strokePaintServer = sharedSolidPaintServer();
     128        SVGPaintServerSolid* strokePaintServerSolid = static_cast<SVGPaintServerSolid*>(strokePaintServer);
     129        if (stroke->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR)
     130            strokePaintServerSolid->setColor(style->color());
     131        else
     132            strokePaintServerSolid->setColor(stroke->color());
     133        // FIXME: Ideally invalid colors would never get set on the RenderStyle and this could turn into an ASSERT
     134        if (!strokePaintServerSolid->color().isValid())
     135            strokePaintServer = 0;
     136    }
     137
     138    return strokePaintServer;
     139}
     140
     141DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
     142{
     143    DashArray array;
     144   
     145    CSSValueList* dashes = style->svgStyle()->strokeDashArray();
     146    if (dashes) {
     147        CSSPrimitiveValue* dash = 0;
     148        unsigned long len = dashes->length();
     149        for (unsigned long i = 0; i < len; i++) {
     150            dash = static_cast<CSSPrimitiveValue*>(dashes->item(i));
     151            if (!dash)
     152                continue;
     153
     154            array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style)));
     155        }
     156    }
     157
     158    return array;
     159}
     160
    55161} // namespace WebCore
    56162
  • branches/feature-branch/WebCore/platform/graphics/svg/SVGPaintServer.h

    r19855 r23509  
    3838class QPen;
    3939#endif
    40    
     40
     41#if PLATFORM(CG)
     42    typedef Vector<CGFloat> DashArray;
     43#else
     44    typedef Vector<float> DashArray;
     45#endif
     46
    4147namespace WebCore {
    42    
     48
    4349    enum SVGPaintServerType {
    4450        // Painting mode
     
    7783        virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText = false) const = 0;
    7884
     85        static SVGPaintServer* strokePaintServer(const RenderStyle*, const RenderObject*);
     86        static SVGPaintServer* fillPaintServer(const RenderStyle*, const RenderObject*);
     87
    7988    protected:
    8089#if PLATFORM(CG)
     
    94103    SVGPaintServer* getPaintServerById(Document*, const AtomicString&);
    95104
     105    DashArray dashArrayFromRenderingStyle(const RenderStyle* style);
    96106} // namespace WebCore
    97107
  • branches/feature-branch/WebCore/platform/graphics/svg/cg/CgSupport.cpp

    r19855 r23509  
    3232
    3333#include "GraphicsContext.h"
    34 #include "KCanvasRenderingStyle.h"
    3534#include "RenderStyle.h"
     35#include "SVGPaintServer.h"
    3636#include <wtf/Assertions.h>
    3737#include "SVGRenderStyle.h"
     
    5454{
    5555    /* Shouldn't all these be in the stroke painter? */
    56     CGContextSetLineWidth(context, KSVGPainterFactory::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
     56    CGContextSetLineWidth(context, SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
    5757
    5858    CGContextSetLineCap(context, CGLineCapFromKC(style->svgStyle()->capStyle()));
     
    6161    CGContextSetMiterLimit(context, style->svgStyle()->strokeMiterLimit());
    6262
    63     const KCDashArray& dashes = KSVGPainterFactory::dashArrayFromRenderingStyle(style);
    64     double dashOffset = KSVGPainterFactory::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);
     63    const DashArray& dashes = dashArrayFromRenderingStyle(style);
     64    double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);
    6565
    6666    CGContextSetLineDash(context, dashOffset, dashes.data(), dashes.size());
  • branches/feature-branch/WebCore/platform/graphics/svg/cg/RenderPathCg.cpp

    r19855 r23509  
    3232
    3333#include <ApplicationServices/ApplicationServices.h>
    34 #include "KCanvasRenderingStyle.h"
    3534#include "CgSupport.h"
    3635#include "RenderPath.h"
     36#include "SVGPaintServer.h"
    3737#include "SVGRenderStyle.h"
    3838#include "SVGStyledElement.h"
     
    5454        return false;
    5555
    56     if (requiresStroke && !KSVGPainterFactory::strokePaintServer(style(), this))
     56    if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
    5757        return false;
    5858
  • branches/feature-branch/WebCore/rendering/RenderPath.cpp

    r22032 r23509  
    3030
    3131#include "GraphicsContext.h"
    32 #include "KCanvasRenderingStyle.h"
    3332#include "RenderSVGContainer.h"
    3433#include "PointerEventsHitRules.h"
     
    8079        return false;
    8180
    82     if (requiresFill && !KSVGPainterFactory::fillPaintServer(style(), this))
     81    if (requiresFill && !SVGPaintServer::fillPaintServer(style(), this))
    8382        return false;
    8483
     
    178177    context->beginPath();
    179178
    180     SVGPaintServer* fillPaintServer = KSVGPainterFactory::fillPaintServer(style, object);
     179    SVGPaintServer* fillPaintServer = SVGPaintServer::fillPaintServer(style, object);
    181180    if (fillPaintServer) {
    182181        context->addPath(path);
     
    184183    }
    185184   
    186     SVGPaintServer* strokePaintServer = KSVGPainterFactory::strokePaintServer(style, object);
     185    SVGPaintServer* strokePaintServer = SVGPaintServer::strokePaintServer(style, object);
    187186    if (strokePaintServer) {
    188187        context->addPath(path); // path is cleared when filled.
     
    416415        return FloatRect();
    417416
    418     double strokeWidth = KSVGPainterFactory::cssPrimitiveToLength(this, svgStyle->strokeWidth(), 1.0);
     417    double strokeWidth = SVGRenderStyle::cssPrimitiveToLength(this, svgStyle->strokeWidth(), 1.0);
    419418    DrawMarkersData data(context, startMarker, midMarker, strokeWidth);
    420419
  • branches/feature-branch/WebCore/rendering/RenderSVGContainer.cpp

    r22032 r23509  
    7676{
    7777    // Only allow an <svg> element to generate a layer when it's positioned in a non-SVG context
    78     return (isPositioned() || isRelPositioned()) && isOutermostSVG();
     78    return false;
    7979}
    8080
     
    8787{
    8888    return height() + marginTop() + marginBottom();
    89 }
    90 
    91 // This method should be temporary until a RenderSVGRoot class can be made
    92 // http://bugs.webkit.org/show_bug.cgi?id=12207
    93 bool RenderSVGContainer::isOutermostSVG() const
    94 {
    95     return parent() && !parent()->isSVGContainer();
    9689}
    9790
     
    128121
    129122    m_absoluteBounds = absoluteClippedOverflowRect();
    130     if (isOutermostSVG()) {
    131         SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
    132         m_width = m_width * svg->currentScale();
    133         m_height = m_height * svg->currentScale();
    134     }
    135123
    136124    if (selfNeedsLayout() && checkForRepaint)
     
    143131void RenderSVGContainer::applyContentTransforms(PaintInfo& paintInfo, int& parentX, int& parentY)
    144132{
    145     if (isOutermostSVG()) {
    146         // Translate from parent offsets (html renderers) to a relative transform (svg renderers)
    147         IntPoint origin;
    148         origin.move(parentX, parentY);
    149         origin.move(m_x, m_y);
    150         origin.move(borderLeft(), borderTop());
    151         origin.move(paddingLeft(), paddingTop());
    152         if (origin.x() || origin.y()) {
    153             paintInfo.context->concatCTM(AffineTransform().translate(origin.x(), origin.y()));
    154             paintInfo.rect.move(-origin.x(), -origin.y());
    155         }
    156         parentX = parentY = 0;
    157         SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
    158         paintInfo.context->concatCTM(AffineTransform().scale(svg->currentScale()));
    159     } else {
    160         // Only the root <svg> element should need any translations using the HTML/CSS system
    161         // parentX, parentY are also non-zero for first-level kids of these
    162         // CSS-transformed <svg> root-elements (due to RenderBox::paint) for any other element
    163         // they should be 0.   m_x, m_y should always be 0 for non-root svg containers
    164         ASSERT(m_x == 0);
    165         ASSERT(m_y == 0);
    166     }
     133    // Only the root <svg> element should need any translations using the HTML/CSS system
     134    // parentX, parentY are also non-zero for first-level kids of these
     135    // CSS-transformed <svg> root-elements (due to RenderBox::paint) for any other element
     136    // they should be 0.   m_x, m_y should always be 0 for non-root svg containers
     137    ASSERT(m_x == 0);
     138    ASSERT(m_y == 0);
    167139   
    168140    if (!viewport().isEmpty()) {
     
    174146    if (!localTransform().isIdentity())
    175147        paintInfo.context->concatCTM(localTransform());
    176     if (isOutermostSVG()) {
    177         SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
    178         paintInfo.context->concatCTM(AffineTransform().translate(svg->currentTranslate().x(), svg->currentTranslate().y()));
    179     }
    180148}
    181149
     
    184152    if (paintInfo.context->paintingDisabled() || !drawsContents())
    185153        return;
    186 
    187     // This should only exist for <svg> renderers
    188     if (isOutermostSVG() && hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
    189         paintBoxDecorations(paintInfo, m_x + parentX, m_y + parentY);
    190154
    191155    if (!firstChild()) {
     
    284248}
    285249
    286 void RenderSVGContainer::setAlign(KCAlign align)
     250void RenderSVGContainer::setAlign(SVGPreserveAspectRatio::SVGPreserveAspectRatioType align)
    287251{
    288252    m_align = align;
     
    291255}
    292256
    293 KCAlign RenderSVGContainer::align() const
     257SVGPreserveAspectRatio::SVGPreserveAspectRatioType RenderSVGContainer::align() const
    294258{
    295259    return m_align;
     
    301265    // do viewport translating anymore. Look into this while
    302266    //  fixing bug 12207.
    303     if (!viewBox().isEmpty()) {
    304         FloatRect viewportRect = viewport();
    305         if (isOutermostSVG())
    306             viewportRect = FloatRect(viewport().x(), viewport().y(), width(), height());
    307 
    308         return getAspectRatio(viewBox(), viewportRect);
    309     }
     267    if (!viewBox().isEmpty())
     268        return getAspectRatio(viewBox(), viewport());
    310269
    311270    return AffineTransform();
     
    342301{
    343302    AffineTransform ctm = RenderContainer::absoluteTransform();
    344     if (isOutermostSVG()) {
    345         SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
    346         ctm.scale(svg->currentScale());
    347         ctm.translate(svg->currentTranslate().x(), svg->currentTranslate().y());
    348     }
    349303    ctm.translate(viewport().x(), viewport().y());
    350304    return viewportTransform() * ctm;
     
    418372    float svgar = physWidth / physHeight;
    419373
    420     if (align() == ALIGN_NONE) {
     374    if (align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) {
    421375        temp.scale(physWidth / logicWidth, physHeight / logicHeight);
    422376        temp.translate(-logicX, -logicY);
     
    424378        temp.scale(physHeight / logicHeight, physHeight / logicHeight);
    425379
    426         if (align() == ALIGN_XMINYMIN || align() == ALIGN_XMINYMID || align() == ALIGN_XMINYMAX)
     380        if (align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX)
    427381            temp.translate(-logicX, -logicY);
    428         else if (align() == ALIGN_XMIDYMIN || align() == ALIGN_XMIDYMID || align() == ALIGN_XMIDYMAX)
     382        else if (align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID || align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX)
    429383            temp.translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight) / 2, -logicY);
    430384        else
     
    433387        temp.scale(physWidth / logicWidth, physWidth / logicWidth);
    434388
    435         if (align() == ALIGN_XMINYMIN || align() == ALIGN_XMIDYMIN || align() == ALIGN_XMAXYMIN)
     389        if (align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN)
    436390            temp.translate(-logicX, -logicY);
    437         else if (align() == ALIGN_XMINYMID || align() == ALIGN_XMIDYMID || align() == ALIGN_XMAXYMID)
     391        else if (align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID || align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID)
    438392            temp.translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth) / 2);
    439393        else
  • branches/feature-branch/WebCore/rendering/RenderSVGContainer.h

    r22032 r23509  
    2828#include "RenderContainer.h"
    2929#include "RenderPath.h"
     30#include "SVGPreserveAspectRatio.h"
    3031
    3132namespace WebCore {
    32 
    33 enum KCAlign {
    34     ALIGN_NONE = 0,
    35     ALIGN_XMINYMIN = 1,
    36     ALIGN_XMIDYMIN = 2,
    37     ALIGN_XMAXYMIN = 3,
    38     ALIGN_XMINYMID = 4,
    39     ALIGN_XMIDYMID = 5,
    40     ALIGN_XMAXYMID = 6,
    41     ALIGN_XMINYMAX = 7,
    42     ALIGN_XMIDYMAX = 8,
    43     ALIGN_XMAXYMAX = 9
    44 };
    4533
    4634class SVGElement;
     
    8573    FloatRect viewBox() const;
    8674
    87     void setAlign(KCAlign);
    88     KCAlign align() const;
     75    void setAlign(SVGPreserveAspectRatio::SVGPreserveAspectRatioType);
     76    SVGPreserveAspectRatio::SVGPreserveAspectRatioType align() const;
    8977
    9078    void setSlice(bool);
     
    9583    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    9684   
    97     bool isOutermostSVG() const;
    98 
    9985private:
    10086    void calcViewport();
     
    10894    FloatRect m_viewport;
    10995    FloatRect m_viewBox;
    110     KCAlign m_align;
     96    SVGPreserveAspectRatio::SVGPreserveAspectRatioType m_align;
    11197    IntRect m_absoluteBounds;
    11298};
  • branches/feature-branch/WebCore/rendering/RenderSVGInlineText.cpp

    r21863 r23509  
    3333#include "SVGInlineTextBox.h"
    3434#include "SVGRootInlineBox.h"
    35 #include "KCanvasRenderingStyle.h"
    3635
    3736namespace WebCore {
  • branches/feature-branch/WebCore/rendering/RenderSVGTSpan.cpp

    r19855 r23509  
    2727#include "RenderSVGTSpan.h"
    2828#include "GraphicsContext.h"
    29 #include "KCanvasRenderingStyle.h"
    3029#include "SVGRootInlineBox.h"
    3130#include "SVGInlineFlowBox.h"
  • branches/feature-branch/WebCore/rendering/RenderSVGText.cpp

    r21607 r23509  
    3030
    3131#include "GraphicsContext.h"
    32 #include "KCanvasRenderingStyle.h"
    3332#include "PointerEventsHitRules.h"
    3433#include "SVGLength.h"
     
    145144    // SVG needs to include the strokeWidth(), not the textStrokeWidth().
    146145    if (includeStroke && style()->svgStyle()->hasStroke())
    147         repaintRect.inflate(KSVGPainterFactory::cssPrimitiveToLength(this, style()->svgStyle()->strokeWidth(), 0.0));
     146        repaintRect.inflate(SVGRenderStyle::cssPrimitiveToLength(this, style()->svgStyle()->strokeWidth(), 0.0));
    148147
    149148    repaintRect.move(xPos(), yPos());
  • branches/feature-branch/WebCore/rendering/SVGRenderTreeAsText.cpp

    r21705 r23509  
    3434#include "InlineTextBox.h"
    3535#include "HTMLNames.h"
    36 #include "KCanvasRenderingStyle.h"
    3736#include "RenderSVGContainer.h"
    3837#include "RenderSVGInlineText.h"
     
    180179
    181180// FIXME: Maybe this should be in KCanvasRenderingStyle.cpp
    182 static TextStream& operator<<(TextStream& ts, const KCDashArray& a)
     181static TextStream& operator<<(TextStream& ts, const DashArray& a)
    183182{
    184183    ts << "{";
    185     KCDashArray::const_iterator end = a.end();
    186     for (KCDashArray::const_iterator it = a.begin(); it != end; ++it) {
     184    DashArray::const_iterator end = a.end();
     185    for (DashArray::const_iterator it = a.begin(); it != end; ++it) {
    187186        if (it != a.begin())
    188187            ts << ", ";
     
    240239    if (object.isRenderPath()) {
    241240        const RenderPath& path = static_cast<const RenderPath&>(object);
    242         SVGPaintServer* strokePaintServer = KSVGPainterFactory::strokePaintServer(style, &path);
     241        SVGPaintServer* strokePaintServer = SVGPaintServer::strokePaintServer(style, &path);
    243242        if (strokePaintServer) {
    244243            TextStreamSeparator s(" ");
     
    247246                ts << s << *strokePaintServer;
    248247
    249             double dashOffset = KSVGPainterFactory::cssPrimitiveToLength(&path, svgStyle->strokeDashOffset(), 0.0);
    250             const KCDashArray& dashArray = KSVGPainterFactory::dashArrayFromRenderingStyle(style);
    251             double strokeWidth = KSVGPainterFactory::cssPrimitiveToLength(&path, svgStyle->strokeWidth(), 1.0);
     248            double dashOffset = SVGRenderStyle::cssPrimitiveToLength(&path, svgStyle->strokeDashOffset(), 0.0);
     249            const DashArray& dashArray = dashArrayFromRenderingStyle(style);
     250            double strokeWidth = SVGRenderStyle::cssPrimitiveToLength(&path, svgStyle->strokeWidth(), 1.0);
    252251
    253252            if (svgStyle->strokeOpacity() != 1.0f)
     
    267266            ts << "}]";
    268267        }
    269         SVGPaintServer* fillPaintServer = KSVGPainterFactory::fillPaintServer(style, &path);
     268        SVGPaintServer* fillPaintServer = SVGPaintServer::fillPaintServer(style, &path);
    270269        if (fillPaintServer) {
    271270            TextStreamSeparator s(" ");
  • branches/feature-branch/WebCore/rendering/SVGRootInlineBox.cpp

    r22028 r23509  
    3131#include "GraphicsContext.h"
    3232#include "InlineTextBox.h"
    33 #include "KCanvasRenderingStyle.h"
    3433#include "Range.h"
    3534#include "SVGInlineFlowBox.h"
     
    134133    }
    135134
    136     SVGPaintServer* fillPaintServer = KSVGPainterFactory::fillPaintServer(object()->style(), object());
     135    SVGPaintServer* fillPaintServer = SVGPaintServer::fillPaintServer(object()->style(), object());
    137136    if (fillPaintServer) {
    138137        if (fillPaintServer->setup(pi.context, object(), ApplyToFillTargetType, true)) {
     
    145144    }
    146145
    147     SVGPaintServer* strokePaintServer = KSVGPainterFactory::strokePaintServer(object()->style(), object());
     146    SVGPaintServer* strokePaintServer = SVGPaintServer::strokePaintServer(object()->style(), object());
    148147    if (strokePaintServer) {
    149148        if (strokePaintServer->setup(pi.context, object(), ApplyToStrokeTargetType, true)) {
     
    10341033            Vector<SVGChar>::iterator savedIt = it;
    10351034   
    1036             SVGPaintServer* fillPaintServer = KSVGPainterFactory::fillPaintServer(object->style(), object);
     1035            SVGPaintServer* fillPaintServer = SVGPaintServer::fillPaintServer(object->style(), object);
    10371036            if (fillPaintServer) {
    10381037                if (fillPaintServer->setup(pi.context, object, ApplyToFillTargetType, true)) {
     
    10441043            }
    10451044
    1046             SVGPaintServer* strokePaintServer = KSVGPainterFactory::strokePaintServer(object->style(), object);
     1045            SVGPaintServer* strokePaintServer = SVGPaintServer::strokePaintServer(object->style(), object);
    10471046            if (strokePaintServer) {
    10481047                if (strokePaintServer->setup(pi.context, object, ApplyToStrokeTargetType, true)) {
Note: See TracChangeset for help on using the changeset viewer.