summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/style
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/rendering/style')
-rw-r--r--WebCore/rendering/style/RenderStyle.cpp46
-rw-r--r--WebCore/rendering/style/RenderStyle.h7
-rw-r--r--WebCore/rendering/style/SVGRenderStyle.cpp84
-rw-r--r--WebCore/rendering/style/SVGRenderStyle.h6
-rw-r--r--WebCore/rendering/style/StyleRareNonInheritedData.cpp6
-rw-r--r--WebCore/rendering/style/StyleRareNonInheritedData.h13
6 files changed, 148 insertions, 14 deletions
diff --git a/WebCore/rendering/style/RenderStyle.cpp b/WebCore/rendering/style/RenderStyle.cpp
index 40f7a27..a386fc6 100644
--- a/WebCore/rendering/style/RenderStyle.cpp
+++ b/WebCore/rendering/style/RenderStyle.cpp
@@ -299,11 +299,8 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
changedContextSensitiveProperties = ContextSensitivePropertyNone;
#if ENABLE(SVG)
- // This is horribly inefficient. Eventually we'll have to integrate
- // this more directly by calling: Diff svgDiff = svgStyle->diff(other)
- // and then checking svgDiff and returning from the appropriate places below.
if (m_svgStyle != other->m_svgStyle)
- return StyleDifferenceLayout;
+ return m_svgStyle->diff(other->m_svgStyle.get());
#endif
if (m_box->width() != other->m_box->width() ||
@@ -739,14 +736,8 @@ void RenderStyle::setBoxShadow(ShadowData* shadowData, bool add)
rareData->m_boxShadow.set(shadowData);
}
-void RenderStyle::getBorderRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const
+static void constrainCornerRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight)
{
- topLeft = surround->border.topLeft();
- topRight = surround->border.topRight();
-
- bottomLeft = surround->border.bottomLeft();
- bottomRight = surround->border.bottomRight();
-
// Constrain corner radii using CSS3 rules:
// http://www.w3.org/TR/css3-background/#the-border-radius
@@ -791,6 +782,39 @@ void RenderStyle::getBorderRadiiForRect(const IntRect& r, IntSize& topLeft, IntS
}
}
+void RenderStyle::getBorderRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const
+{
+ topLeft = surround->border.topLeft();
+ topRight = surround->border.topRight();
+
+ bottomLeft = surround->border.bottomLeft();
+ bottomRight = surround->border.bottomRight();
+
+ constrainCornerRadiiForRect(r, topLeft, topRight, bottomLeft, bottomRight);
+}
+
+void RenderStyle::getInnerBorderRadiiForRectWithBorderWidths(const IntRect& innerRect, unsigned short topWidth, unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth, IntSize& innerTopLeft, IntSize& innerTopRight, IntSize& innerBottomLeft, IntSize& innerBottomRight) const
+{
+ innerTopLeft = surround->border.topLeft();
+ innerTopRight = surround->border.topRight();
+ innerBottomLeft = surround->border.bottomLeft();
+ innerBottomRight = surround->border.bottomRight();
+
+ innerTopLeft.setWidth(max(0, innerTopLeft.width() - leftWidth));
+ innerTopLeft.setHeight(max(0, innerTopLeft.height() - topWidth));
+
+ innerTopRight.setWidth(max(0, innerTopRight.width() - rightWidth));
+ innerTopRight.setHeight(max(0, innerTopRight.height() - topWidth));
+
+ innerBottomLeft.setWidth(max(0, innerBottomLeft.width() - leftWidth));
+ innerBottomLeft.setHeight(max(0, innerBottomLeft.height() - bottomWidth));
+
+ innerBottomRight.setWidth(max(0, innerBottomRight.width() - rightWidth));
+ innerBottomRight.setHeight(max(0, innerBottomRight.height() - bottomWidth));
+
+ constrainCornerRadiiForRect(innerRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight);
+}
+
const CounterDirectiveMap* RenderStyle::counterDirectives() const
{
return rareNonInheritedData->m_counterDirectives.get();
diff --git a/WebCore/rendering/style/RenderStyle.h b/WebCore/rendering/style/RenderStyle.h
index 2914fcf..748842b 100644
--- a/WebCore/rendering/style/RenderStyle.h
+++ b/WebCore/rendering/style/RenderStyle.h
@@ -704,6 +704,7 @@ public:
Length perspectiveOriginX() const { return rareNonInheritedData->m_perspectiveOriginX; }
Length perspectiveOriginY() const { return rareNonInheritedData->m_perspectiveOriginY; }
LengthSize pageSize() const { return rareNonInheritedData->m_pageSize; }
+ PageSizeType pageSizeType() const { return rareNonInheritedData->m_pageSizeType; }
#if USE(ACCELERATED_COMPOSITING)
// When set, this ensures that styles compare as different. Used during accelerated animations.
@@ -794,6 +795,10 @@ public:
}
void getBorderRadiiForRect(const IntRect&, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const;
+ void getInnerBorderRadiiForRectWithBorderWidths(const IntRect&, unsigned short topWidth,
+ unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth,
+ IntSize& innerTopLeft, IntSize& innerTopRight, IntSize& innerBottomLeft,
+ IntSize& innerBottomRight) const;
void setBorderLeftWidth(unsigned short v) { SET_VAR(surround, border.m_left.m_width, v) }
void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.m_left.m_style, v) }
@@ -1035,6 +1040,8 @@ public:
void setPerspectiveOriginX(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginX, l); }
void setPerspectiveOriginY(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginY, l); }
void setPageSize(LengthSize s) { SET_VAR(rareNonInheritedData, m_pageSize, s); }
+ void setPageSizeType(PageSizeType t) { SET_VAR(rareNonInheritedData, m_pageSizeType, t); }
+ void resetPageSizeType() { SET_VAR(rareNonInheritedData, m_pageSizeType, PAGE_SIZE_AUTO); }
#if USE(ACCELERATED_COMPOSITING)
void setIsRunningAcceleratedAnimation(bool b = true) { SET_VAR(rareNonInheritedData, m_runningAcceleratedAnimation, b); }
diff --git a/WebCore/rendering/style/SVGRenderStyle.cpp b/WebCore/rendering/style/SVGRenderStyle.cpp
index f4e6cb5..93e50cc 100644
--- a/WebCore/rendering/style/SVGRenderStyle.cpp
+++ b/WebCore/rendering/style/SVGRenderStyle.cpp
@@ -126,6 +126,90 @@ void SVGRenderStyle::inheritFrom(const SVGRenderStyle* svgInheritParent)
svg_inherited_flags = svgInheritParent->svg_inherited_flags;
}
+StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const
+{
+ // NOTE: All comparisions that may return StyleDifferenceLayout have to go before those who return StyleDifferenceRepaint
+
+ // If kerning changes, we need a relayout, to force SVGCharacterData to be recalculated in the SVGRootInlineBox.
+ if (text != other->text)
+ return StyleDifferenceLayout;
+
+ // If resources change, we need a relayout, as the presence of resources influences the repaint rect.
+ if (resources != other->resources)
+ return StyleDifferenceLayout;
+
+ // If markers change, we need a relayout, as marker boundaries are cached in RenderPath.
+ if (inheritedResources != other->inheritedResources)
+ return StyleDifferenceLayout;
+
+ // All text related properties influence layout.
+ if (svg_inherited_flags._textAnchor != other->svg_inherited_flags._textAnchor
+ || svg_inherited_flags._writingMode != other->svg_inherited_flags._writingMode
+ || svg_inherited_flags._glyphOrientationHorizontal != other->svg_inherited_flags._glyphOrientationHorizontal
+ || svg_inherited_flags._glyphOrientationVertical != other->svg_inherited_flags._glyphOrientationVertical
+ || 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;
+
+ // Text related properties influence layout.
+ bool miscNotEqual = misc != other->misc;
+ if (miscNotEqual && misc->baselineShiftValue != other->misc->baselineShiftValue)
+ return StyleDifferenceLayout;
+
+ // 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;
+
+ // 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->miterLimit != other->stroke->miterLimit
+ || stroke->dashArray != other->stroke->dashArray
+ || stroke->dashOffset != other->stroke->dashOffset)
+ return StyleDifferenceLayout;
+
+ // Only these two cases remain, where we only need a repaint.
+ ASSERT(stroke->paint != other->stroke->paint || stroke->opacity != other->stroke->opacity);
+ return StyleDifferenceRepaint;
+ }
+
+ // NOTE: All comparisions below may only return StyleDifferenceRepaint
+
+ // Painting related properties only need repaints.
+ if (miscNotEqual) {
+ if (misc->floodColor != other->misc->floodColor
+ || misc->floodOpacity != other->misc->floodOpacity
+ || misc->lightingColor != other->misc->lightingColor)
+ return StyleDifferenceRepaint;
+ }
+
+ // If fill changes, we just need to repaint. Fill boundaries are not influenced by this, only by the Path, that RenderPath contains.
+ if (fill != other->fill)
+ return StyleDifferenceRepaint;
+
+ // If gradient stops change, we just need to repaint. Style updates are already handled through RenderSVGGradientSTop.
+ if (stops != other->stops)
+ return StyleDifferenceRepaint;
+
+ // Changes of these flags only cause repaints.
+ if (svg_inherited_flags._colorRendering != other->svg_inherited_flags._colorRendering
+ || svg_inherited_flags._imageRendering != other->svg_inherited_flags._imageRendering
+ || svg_inherited_flags._shapeRendering != other->svg_inherited_flags._shapeRendering
+ || svg_inherited_flags._clipRule != other->svg_inherited_flags._clipRule
+ || svg_inherited_flags._fillRule != other->svg_inherited_flags._fillRule
+ || svg_inherited_flags._colorInterpolation != other->svg_inherited_flags._colorInterpolation
+ || svg_inherited_flags._colorInterpolationFilters != other->svg_inherited_flags._colorInterpolationFilters)
+ return StyleDifferenceRepaint;
+
+ // FIXME: vector-effect is not taken into account in the layout-phase. Once this is fixed, we should relayout here.
+ if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags.f._vectorEffect)
+ return StyleDifferenceRepaint;
+
+ return StyleDifferenceEqual;
+}
+
float SVGRenderStyle::cssPrimitiveToLength(const RenderObject* item, CSSValue* value, float defaultValue)
{
CSSPrimitiveValue* primitive = static_cast<CSSPrimitiveValue*>(value);
diff --git a/WebCore/rendering/style/SVGRenderStyle.h b/WebCore/rendering/style/SVGRenderStyle.h
index b0bef61..c87dd2b 100644
--- a/WebCore/rendering/style/SVGRenderStyle.h
+++ b/WebCore/rendering/style/SVGRenderStyle.h
@@ -28,6 +28,7 @@
#include "DataRef.h"
#include "GraphicsTypes.h"
#include "Path.h"
+#include "RenderStyleConstants.h"
#include "SVGPaint.h"
#include "SVGRenderStyleDefs.h"
@@ -36,7 +37,6 @@ namespace WebCore {
class FloatRect;
class IntRect;
class RenderObject;
-class RenderStyle;
class SVGRenderStyle : public RefCounted<SVGRenderStyle> {
public:
@@ -50,7 +50,9 @@ public:
// FIXME: These functions should move to ShadowData.
void inflateForShadow(IntRect&) const;
void inflateForShadow(FloatRect&) const;
-
+
+ StyleDifference diff(const SVGRenderStyle*) const;
+
bool operator==(const SVGRenderStyle&) const;
bool operator!=(const SVGRenderStyle& o) const { return !(*this == o); }
diff --git a/WebCore/rendering/style/StyleRareNonInheritedData.cpp b/WebCore/rendering/style/StyleRareNonInheritedData.cpp
index e3367d1..d5c9536 100644
--- a/WebCore/rendering/style/StyleRareNonInheritedData.cpp
+++ b/WebCore/rendering/style/StyleRareNonInheritedData.cpp
@@ -59,6 +59,8 @@ StyleRareNonInheritedData::StyleRareNonInheritedData()
#if ENABLE(XBL)
, bindingURI(0)
#endif
+ , m_pageSize()
+ , m_pageSizeType(PAGE_SIZE_AUTO)
{
}
@@ -98,6 +100,8 @@ StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInherited
#if ENABLE(XBL)
, bindingURI(o.bindingURI ? o.bindingURI->copy() : 0)
#endif
+ , m_pageSize(o.m_pageSize)
+ , m_pageSizeType(o.m_pageSizeType)
{
}
@@ -156,6 +160,8 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
&& (m_perspective == o.m_perspective)
&& (m_perspectiveOriginX == o.m_perspectiveOriginX)
&& (m_perspectiveOriginY == o.m_perspectiveOriginY)
+ && (m_pageSize == o.m_pageSize)
+ && (m_pageSizeType == o.m_pageSizeType)
;
}
diff --git a/WebCore/rendering/style/StyleRareNonInheritedData.h b/WebCore/rendering/style/StyleRareNonInheritedData.h
index 74e736c..1025d81 100644
--- a/WebCore/rendering/style/StyleRareNonInheritedData.h
+++ b/WebCore/rendering/style/StyleRareNonInheritedData.h
@@ -40,7 +40,6 @@ namespace WebCore {
class AnimationList;
class CSSStyleSelector;
-class LengthSize;
class ShadowData;
class StyleFlexibleBoxData;
class StyleMarqueeData;
@@ -49,6 +48,7 @@ class StyleReflection;
class StyleTransformData;
struct ContentData;
+struct LengthSize;
#if ENABLE(DASHBOARD_SUPPORT)
struct StyleDashboardRegion;
@@ -58,6 +58,16 @@ struct StyleDashboardRegion;
class BindingURI;
#endif
+// Page size type.
+// StyleRareNonInheritedData::m_pageSize is meaningful only when
+// StyleRareNonInheritedData::m_pageSizeType is PAGE_SIZE_RESOLVED.
+enum PageSizeType {
+ PAGE_SIZE_AUTO, // size: auto
+ PAGE_SIZE_AUTO_LANDSCAPE, // size: landscape
+ PAGE_SIZE_AUTO_PORTRAIT, // size: portrait
+ PAGE_SIZE_RESOLVED // Size is fully resolved.
+};
+
// This struct is for rarely used non-inherited CSS3, CSS2, and WebKit-specific properties.
// By grouping them together, we save space, and only allocate this object when someone
// actually uses one of these properties.
@@ -125,6 +135,7 @@ public:
Length m_perspectiveOriginY;
LengthSize m_pageSize;
+ PageSizeType m_pageSizeType;
#if ENABLE(XBL)
OwnPtr<BindingURI> bindingURI; // The XBL binding URI list.