From 54cdeeebc7adcbcd900e8b6a141a8cae27d9a631 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Fri, 10 Jun 2011 16:52:27 +0100 Subject: Merge WebKit at branches/chromium/742 r88085: Initial merge by git. Change-Id: I0501b484b9528e31b0026e5ad64416dd6541cdde --- Source/WebCore/rendering/style/SVGRenderStyle.cpp | 6 +-- Source/WebCore/rendering/style/SVGRenderStyle.h | 50 ++++++++-------------- .../WebCore/rendering/style/SVGRenderStyleDefs.cpp | 44 ++++++++++--------- .../WebCore/rendering/style/SVGRenderStyleDefs.h | 14 +++--- 4 files changed, 48 insertions(+), 66 deletions(-) (limited to 'Source/WebCore/rendering/style') diff --git a/Source/WebCore/rendering/style/SVGRenderStyle.cpp b/Source/WebCore/rendering/style/SVGRenderStyle.cpp index 1ee1f36..28f80f2 100644 --- a/Source/WebCore/rendering/style/SVGRenderStyle.cpp +++ b/Source/WebCore/rendering/style/SVGRenderStyle.cpp @@ -169,9 +169,7 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const // Some stroke properties, requires relayouts, as the cached stroke boundaries need to be recalculated. if (stroke != other->stroke) { if (stroke->width != other->stroke->width - || stroke->paintType != other->stroke->paintType - || stroke->paintColor != other->stroke->paintColor - || stroke->paintUri != other->stroke->paintUri + || stroke->paint != other->stroke->paint || stroke->miterLimit != other->stroke->miterLimit || stroke->dashArray != other->stroke->dashArray || stroke->dashOffset != other->stroke->dashOffset) @@ -193,7 +191,7 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const } // If fill changes, we just need to repaint. Fill boundaries are not influenced by this, only by the Path, that RenderSVGPath contains. - if (fill->paintType != other->fill->paintType || fill->paintColor != other->fill->paintColor || fill->paintUri != other->fill->paintUri) + if (fill != other->fill) return StyleDifferenceRepaint; // If gradient stops change, we just need to repaint. Style updates are already handled through RenderSVGGradientSTop. diff --git a/Source/WebCore/rendering/style/SVGRenderStyle.h b/Source/WebCore/rendering/style/SVGRenderStyle.h index 88a48df..7f032e7 100644 --- a/Source/WebCore/rendering/style/SVGRenderStyle.h +++ b/Source/WebCore/rendering/style/SVGRenderStyle.h @@ -70,19 +70,15 @@ public: static SVGWritingMode initialWritingMode() { return WM_LRTB; } static EGlyphOrientation initialGlyphOrientationHorizontal() { return GO_0DEG; } static EGlyphOrientation initialGlyphOrientationVertical() { return GO_AUTO; } - static float initialFillOpacity() { return 1; } - static SVGPaint::SVGPaintType initialFillPaintType() { return SVGPaint::SVG_PAINTTYPE_RGBCOLOR; } - static Color initialFillPaintColor() { return Color::black; } - static String initialFillPaintUri() { return String(); } - static float initialStrokeOpacity() { return 1; } - static SVGPaint::SVGPaintType initialStrokePaintType() { return SVGPaint::SVG_PAINTTYPE_NONE; } - static Color initialStrokePaintColor() { return Color(); } - static String initialStrokePaintUri() { return String(); } + static float initialFillOpacity() { return 1.0f; } + static SVGPaint* initialFillPaint() { return SVGPaint::defaultFill(); } + static float initialStrokeOpacity() { return 1.0f; } + static SVGPaint* initialStrokePaint() { return SVGPaint::defaultStroke(); } static Vector initialStrokeDashArray() { return Vector(); } - static float initialStrokeMiterLimit() { return 4; } - static float initialStopOpacity() { return 1; } + static float initialStrokeMiterLimit() { return 4.0f; } + static float initialStopOpacity() { return 1.0f; } static Color initialStopColor() { return Color(0, 0, 0); } - static float initialFloodOpacity() { return 1; } + static float initialFloodOpacity() { return 1.0f; } static Color initialFloodColor() { return Color(0, 0, 0); } static Color initialLightingColor() { return Color(255, 255, 255); } static ShadowData* initialShadow() { return 0; } @@ -154,14 +150,10 @@ public: fill.access()->opacity = obj; } - void setFillPaint(SVGPaint::SVGPaintType type, const Color& color, const String& uri) + void setFillPaint(PassRefPtr obj) { - if (!(fill->paintType == type)) - fill.access()->paintType = type; - if (!(fill->paintColor == color)) - fill.access()->paintColor = color; - if (!(fill->paintUri == uri)) - fill.access()->paintUri = uri; + if (!(fill->paint == obj)) + fill.access()->paint = obj; } void setStrokeOpacity(float obj) @@ -170,14 +162,10 @@ public: stroke.access()->opacity = obj; } - void setStrokePaint(SVGPaint::SVGPaintType type, const Color& color, const String& uri) + void setStrokePaint(PassRefPtr obj) { - if (!(stroke->paintType == type)) - stroke.access()->paintType = type; - if (!(stroke->paintColor == color)) - stroke.access()->paintColor = color; - if (!(stroke->paintUri == uri)) - stroke.access()->paintUri = uri; + if (!(stroke->paint == obj)) + stroke.access()->paint = obj; } void setStrokeDashArray(const Vector& obj) @@ -305,13 +293,9 @@ public: EGlyphOrientation glyphOrientationHorizontal() const { return (EGlyphOrientation) svg_inherited_flags._glyphOrientationHorizontal; } EGlyphOrientation glyphOrientationVertical() const { return (EGlyphOrientation) svg_inherited_flags._glyphOrientationVertical; } float fillOpacity() const { return fill->opacity; } - const SVGPaint::SVGPaintType& fillPaintType() const { return fill->paintType; } - const Color& fillPaintColor() const { return fill->paintColor; } - const String& fillPaintUri() const { return fill->paintUri; } + SVGPaint* fillPaint() const { return fill->paint.get(); } float strokeOpacity() const { return stroke->opacity; } - const SVGPaint::SVGPaintType& strokePaintType() const { return stroke->paintType; } - const Color& strokePaintColor() const { return stroke->paintColor; } - const String& strokePaintUri() const { return stroke->paintUri; } + SVGPaint* strokePaint() const { return stroke->paint.get(); } Vector strokeDashArray() const { return stroke->dashArray; } float strokeMiterLimit() const { return stroke->miterLimit; } SVGLength strokeWidth() const { return stroke->width; } @@ -336,8 +320,8 @@ public: bool hasMasker() const { return !maskerResource().isEmpty(); } bool hasFilter() const { return !filterResource().isEmpty(); } bool hasMarkers() const { return !markerStartResource().isEmpty() || !markerMidResource().isEmpty() || !markerEndResource().isEmpty(); } - bool hasStroke() const { return strokePaintType() != SVGPaint::SVG_PAINTTYPE_NONE; } - bool hasFill() const { return fillPaintType() != SVGPaint::SVG_PAINTTYPE_NONE; } + bool hasStroke() const { return strokePaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE; } + bool hasFill() const { return fillPaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE; } bool isVerticalWritingMode() const { return writingMode() == WM_TBRL || writingMode() == WM_TB; } protected: diff --git a/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp b/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp index fb23e14..c30ae6d 100644 --- a/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp +++ b/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp @@ -37,27 +37,35 @@ namespace WebCore { StyleFillData::StyleFillData() : opacity(SVGRenderStyle::initialFillOpacity()) - , paintType(SVGRenderStyle::initialFillPaintType()) - , paintColor(SVGRenderStyle::initialFillPaintColor()) - , paintUri(SVGRenderStyle::initialFillPaintUri()) + , paint(SVGRenderStyle::initialFillPaint()) { } StyleFillData::StyleFillData(const StyleFillData& other) : RefCounted() , opacity(other.opacity) - , paintType(other.paintType) - , paintColor(other.paintColor) - , paintUri(other.paintUri) + , paint(other.paint) { } bool StyleFillData::operator==(const StyleFillData& other) const { - return opacity == other.opacity - && paintType == other.paintType - && paintColor == other.paintColor - && paintUri == other.paintUri; + if (opacity != other.opacity) + return false; + + if (!paint || !other.paint) + return paint == other.paint; + + if (paint->paintType() != other.paint->paintType()) + return false; + + if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI) + return paint->uri() == other.paint->uri(); + + if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR) + return paint->color() == other.paint->color(); + + return paint == other.paint; } StyleStrokeData::StyleStrokeData() @@ -66,9 +74,7 @@ StyleStrokeData::StyleStrokeData() , width(SVGRenderStyle::initialStrokeWidth()) , dashOffset(SVGRenderStyle::initialStrokeDashOffset()) , dashArray(SVGRenderStyle::initialStrokeDashArray()) - , paintType(SVGRenderStyle::initialStrokePaintType()) - , paintColor(SVGRenderStyle::initialStrokePaintColor()) - , paintUri(SVGRenderStyle::initialStrokePaintUri()) + , paint(SVGRenderStyle::initialStrokePaint()) { } @@ -79,22 +85,18 @@ StyleStrokeData::StyleStrokeData(const StyleStrokeData& other) , width(other.width) , dashOffset(other.dashOffset) , dashArray(other.dashArray) - , paintType(other.paintType) - , paintColor(other.paintColor) - , paintUri(other.paintUri) + , paint(other.paint) { } bool StyleStrokeData::operator==(const StyleStrokeData& other) const { - return width == other.width + return paint == other.paint + && width == other.width && opacity == other.opacity && miterLimit == other.miterLimit && dashOffset == other.dashOffset - && dashArray == other.dashArray - && paintType == other.paintType - && paintColor == other.paintColor - && paintUri == other.paintUri; + && dashArray == other.dashArray; } StyleStopData::StyleStopData() diff --git a/Source/WebCore/rendering/style/SVGRenderStyleDefs.h b/Source/WebCore/rendering/style/SVGRenderStyleDefs.h index 00358a0..de058a2 100644 --- a/Source/WebCore/rendering/style/SVGRenderStyleDefs.h +++ b/Source/WebCore/rendering/style/SVGRenderStyleDefs.h @@ -29,8 +29,9 @@ #define SVGRenderStyleDefs_h #if ENABLE(SVG) +#include "Color.h" +#include "PlatformString.h" #include "SVGLength.h" -#include "SVGPaint.h" #include "ShadowData.h" #include #include @@ -97,7 +98,7 @@ namespace WebCore { public: static PassRefPtr create() { return adoptRef(new StyleFillData); } PassRefPtr copy() const { return adoptRef(new StyleFillData(*this)); } - + bool operator==(const StyleFillData&) const; bool operator!=(const StyleFillData& other) const { @@ -105,9 +106,7 @@ namespace WebCore { } float opacity; - SVGPaint::SVGPaintType paintType; - Color paintColor; - String paintUri; + RefPtr paint; private: StyleFillData(); @@ -132,9 +131,7 @@ namespace WebCore { SVGLength dashOffset; Vector dashArray; - SVGPaint::SVGPaintType paintType; - Color paintColor; - String paintUri; + RefPtr paint; private: StyleStrokeData(); @@ -265,4 +262,5 @@ namespace WebCore { } // namespace WebCore #endif // ENABLE(SVG) + #endif // SVGRenderStyleDefs_h -- cgit v1.1