Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / style / SVGRenderStyle.cpp
index 947c39d..0a66df6 100644 (file)
@@ -40,7 +40,6 @@ SVGRenderStyle::SVGRenderStyle()
 
     fill = defaultStyle->fill;
     stroke = defaultStyle->stroke;
-    text = defaultStyle->text;
     stops = defaultStyle->stops;
     misc = defaultStyle->misc;
     inheritedResources = defaultStyle->inheritedResources;
@@ -55,7 +54,6 @@ SVGRenderStyle::SVGRenderStyle(CreateDefaultType)
 
     fill.init();
     stroke.init();
-    text.init();
     stops.init();
     misc.init();
     inheritedResources.init();
@@ -67,7 +65,6 @@ SVGRenderStyle::SVGRenderStyle(const SVGRenderStyle& other)
 {
     fill = other.fill;
     stroke = other.stroke;
-    text = other.text;
     stops = other.stops;
     misc = other.misc;
     inheritedResources = other.inheritedResources;
@@ -85,7 +82,6 @@ bool SVGRenderStyle::operator==(const SVGRenderStyle& other) const
 {
     return fill == other.fill
         && stroke == other.stroke
-        && text == other.text
         && stops == other.stops
         && misc == other.misc
         && inheritedResources == other.inheritedResources
@@ -98,7 +94,6 @@ bool SVGRenderStyle::inheritedNotEqual(const SVGRenderStyle* other) const
 {
     return fill != other->fill
         || stroke != other->stroke
-        || text != other->text
         || inheritedResources != other->inheritedResources
         || svg_inherited_flags != other->svg_inherited_flags;
 }
@@ -110,7 +105,6 @@ void SVGRenderStyle::inheritFrom(const SVGRenderStyle* svgInheritParent)
 
     fill = svgInheritParent->fill;
     stroke = svgInheritParent->stroke;
-    text = svgInheritParent->text;
     inheritedResources = svgInheritParent->inheritedResources;
 
     svg_inherited_flags = svgInheritParent->svg_inherited_flags;
@@ -126,19 +120,25 @@ void SVGRenderStyle::copyNonInheritedFrom(const SVGRenderStyle* other)
 
 StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
 {
-    // NOTE: All comparisions that may return StyleDifferenceLayout have to go before those who return StyleDifferenceRepaint
+    StyleDifference styleDifference;
 
-    // If kerning changes, we need a relayout, to force SVGCharacterData to be recalculated in the SVGRootInlineBox.
-    if (text != other->text)
-        return StyleDifferenceLayout;
+    if (diffNeedsLayout(other))
+        styleDifference.setNeedsFullLayout();
+    if (diffNeedsRepaint(other))
+        styleDifference.setNeedsRepaintObject();
 
+    return styleDifference;
+}
+
+bool SVGRenderStyle::diffNeedsLayout(const SVGRenderStyle* other) const
+{
     // If resources change, we need a relayout, as the presence of resources influences the repaint rect.
     if (resources != other->resources)
-        return StyleDifferenceLayout;
+        return true;
 
     // If markers change, we need a relayout, as marker boundaries are cached in RenderSVGPath.
     if (inheritedResources != other->inheritedResources)
-        return StyleDifferenceLayout;
+        return true;
 
     // All text related properties influence layout.
     if (svg_inherited_flags._textAnchor != other->svg_inherited_flags._textAnchor
@@ -148,20 +148,23 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
         || svg_noninherited_flags.f._alignmentBaseline != other->svg_noninherited_flags.f._alignmentBaseline
         || svg_noninherited_flags.f._dominantBaseline != other->svg_noninherited_flags.f._dominantBaseline
         || svg_noninherited_flags.f._baselineShift != other->svg_noninherited_flags.f._baselineShift)
-        return StyleDifferenceLayout;
+        return true;
 
     // Text related properties influence layout.
-    bool miscNotEqual = misc != other->misc;
-    if (miscNotEqual && misc->baselineShiftValue != other->misc->baselineShiftValue)
-        return StyleDifferenceLayout;
+    if (misc->baselineShiftValue != other->misc->baselineShiftValue)
+        return true;
 
     // These properties affect the cached stroke bounding box rects.
     if (svg_inherited_flags._capStyle != other->svg_inherited_flags._capStyle
         || svg_inherited_flags._joinStyle != other->svg_inherited_flags._joinStyle)
-        return StyleDifferenceLayout;
+        return true;
+
+    // vector-effect changes require a re-layout.
+    if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags.f._vectorEffect)
+        return true;
 
     // Some stroke properties, requires relayouts, as the cached stroke boundaries need to be recalculated.
-    if (stroke != other->stroke) {
+    if (stroke.get() != other->stroke.get()) {
         if (stroke->width != other->stroke->width
             || stroke->paintType != other->stroke->paintType
             || stroke->paintColor != other->stroke->paintColor
@@ -172,35 +175,37 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
             || stroke->visitedLinkPaintColor != other->stroke->visitedLinkPaintColor
             || stroke->visitedLinkPaintUri != other->stroke->visitedLinkPaintUri
             || stroke->visitedLinkPaintType != other->stroke->visitedLinkPaintType)
-            return StyleDifferenceLayout;
-
-        // Only the stroke-opacity case remains, where we only need a repaint.
-        ASSERT(stroke->opacity != other->stroke->opacity);
-        return StyleDifferenceRepaint;
+            return true;
     }
 
-    // vector-effect changes require a re-layout.
-    if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags.f._vectorEffect)
-        return StyleDifferenceLayout;
+    return false;
+}
 
-    // NOTE: All comparisions below may only return StyleDifferenceRepaint
+bool SVGRenderStyle::diffNeedsRepaint(const SVGRenderStyle* other) const
+{
+    if (stroke->opacity != other->stroke->opacity)
+        return true;
 
     // Painting related properties only need repaints.
-    if (miscNotEqual) {
+    if (misc.get() != other->misc.get()) {
         if (misc->floodColor != other->misc->floodColor
             || misc->floodOpacity != other->misc->floodOpacity
             || misc->lightingColor != other->misc->lightingColor)
-            return StyleDifferenceRepaint;
+            return true;
     }
 
     // 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 || fill->opacity != other->fill->opacity)
-        return StyleDifferenceRepaint;
+    if (fill.get() != other->fill.get()) {
+        if (fill->paintType != other->fill->paintType
+            || fill->paintColor != other->fill->paintColor
+            || fill->paintUri != other->fill->paintUri
+            || fill->opacity != other->fill->opacity)
+            return true;
+    }
 
     // If gradient stops change, we just need to repaint. Style updates are already handled through RenderSVGGradientSTop.
     if (stops != other->stops)
-        return StyleDifferenceRepaint;
+        return true;
 
     // Changes of these flags only cause repaints.
     if (svg_inherited_flags._colorRendering != other->svg_inherited_flags._colorRendering
@@ -210,15 +215,15 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
         || svg_inherited_flags._colorInterpolation != other->svg_inherited_flags._colorInterpolation
         || svg_inherited_flags._colorInterpolationFilters != other->svg_inherited_flags._colorInterpolationFilters
         || svg_inherited_flags._paintOrder != other->svg_inherited_flags._paintOrder)
-        return StyleDifferenceRepaint;
+        return true;
 
     if (svg_noninherited_flags.f.bufferedRendering != other->svg_noninherited_flags.f.bufferedRendering)
-        return StyleDifferenceRepaint;
+        return true;
 
     if (svg_noninherited_flags.f.maskType != other->svg_noninherited_flags.f.maskType)
-        return StyleDifferenceRepaint;
+        return true;
 
-    return StyleDifferenceEqual;
+    return false;
 }
 
 EPaintOrderType SVGRenderStyle::paintOrderType(unsigned index) const