summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/rendering/style
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-16 16:25:10 +0100
committerBen Murdoch <benm@google.com>2011-05-23 18:54:14 +0100
commitab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb (patch)
treedb769fadd053248f85db67434a5b275224defef7 /Source/WebCore/rendering/style
parent52e2557aeb8477967e97fd24f20f8f407a10fa15 (diff)
downloadexternal_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.zip
external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.gz
external_webkit-ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb.tar.bz2
Merge WebKit at r76408: Initial merge by git.
Change-Id: I5b91decbd693ccbf5c1b8354b37cd68cc9a1ea53
Diffstat (limited to 'Source/WebCore/rendering/style')
-rw-r--r--Source/WebCore/rendering/style/BorderData.h3
-rw-r--r--Source/WebCore/rendering/style/ContentData.h3
-rw-r--r--Source/WebCore/rendering/style/CounterContent.h3
-rw-r--r--Source/WebCore/rendering/style/FillLayer.h3
-rw-r--r--Source/WebCore/rendering/style/RenderStyle.cpp94
-rw-r--r--Source/WebCore/rendering/style/RenderStyle.h17
-rw-r--r--Source/WebCore/rendering/style/ShadowData.h4
7 files changed, 55 insertions, 72 deletions
diff --git a/Source/WebCore/rendering/style/BorderData.h b/Source/WebCore/rendering/style/BorderData.h
index 03635d9..0e50edb 100644
--- a/Source/WebCore/rendering/style/BorderData.h
+++ b/Source/WebCore/rendering/style/BorderData.h
@@ -26,6 +26,7 @@
#define BorderData_h
#include "BorderValue.h"
+#include "IntRect.h"
#include "LengthSize.h"
#include "NinePieceImage.h"
@@ -109,7 +110,7 @@ public:
const LengthSize& topRight() const { return m_topRight; }
const LengthSize& bottomLeft() const { return m_bottomLeft; }
const LengthSize& bottomRight() const { return m_bottomRight; }
-
+
private:
BorderValue m_left;
BorderValue m_right;
diff --git a/Source/WebCore/rendering/style/ContentData.h b/Source/WebCore/rendering/style/ContentData.h
index 4f964a2..15f6912 100644
--- a/Source/WebCore/rendering/style/ContentData.h
+++ b/Source/WebCore/rendering/style/ContentData.h
@@ -33,7 +33,8 @@ namespace WebCore {
class StyleImage;
-struct ContentData : Noncopyable {
+struct ContentData {
+ WTF_MAKE_NONCOPYABLE(ContentData); WTF_MAKE_FAST_ALLOCATED;
public:
ContentData()
: m_type(CONTENT_NONE)
diff --git a/Source/WebCore/rendering/style/CounterContent.h b/Source/WebCore/rendering/style/CounterContent.h
index 52757ad..814039e 100644
--- a/Source/WebCore/rendering/style/CounterContent.h
+++ b/Source/WebCore/rendering/style/CounterContent.h
@@ -30,7 +30,8 @@
namespace WebCore {
-class CounterContent : public FastAllocBase {
+class CounterContent {
+ WTF_MAKE_FAST_ALLOCATED;
public:
CounterContent(const AtomicString& identifier, EListStyleType style, const AtomicString& separator)
: m_identifier(identifier)
diff --git a/Source/WebCore/rendering/style/FillLayer.h b/Source/WebCore/rendering/style/FillLayer.h
index 49fb294..847e8df 100644
--- a/Source/WebCore/rendering/style/FillLayer.h
+++ b/Source/WebCore/rendering/style/FillLayer.h
@@ -59,7 +59,8 @@ struct FillSize {
LengthSize size;
};
-class FillLayer : public FastAllocBase {
+class FillLayer {
+ WTF_MAKE_FAST_ALLOCATED;
public:
FillLayer(EFillLayerType);
~FillLayer();
diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp
index 4665e52..2836fb9 100644
--- a/Source/WebCore/rendering/style/RenderStyle.cpp
+++ b/Source/WebCore/rendering/style/RenderStyle.cpp
@@ -744,7 +744,19 @@ void RenderStyle::setBoxShadow(ShadowData* shadowData, bool add)
rareData->m_boxShadow.set(shadowData);
}
-static void constrainCornerRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight)
+static RoundedIntRect::Radii calcRadiiFor(const BorderData& border, int width, int height)
+{
+ return RoundedIntRect::Radii(IntSize(border.topLeft().width().calcValue(width),
+ border.topLeft().height().calcValue(height)),
+ IntSize(border.topRight().width().calcValue(width),
+ border.topRight().height().calcValue(height)),
+ IntSize(border.bottomLeft().width().calcValue(width),
+ border.bottomLeft().height().calcValue(height)),
+ IntSize(border.bottomRight().width().calcValue(width),
+ border.bottomRight().height().calcValue(height)));
+}
+
+static float calcConstraintScaleFor(const IntRect& rect, const RoundedIntRect::Radii& radii)
{
// Constrain corner radii using CSS3 rules:
// http://www.w3.org/TR/css3-background/#the-border-radius
@@ -753,75 +765,43 @@ static void constrainCornerRadiiForRect(const IntRect& r, IntSize& topLeft, IntS
unsigned radiiSum;
// top
- radiiSum = static_cast<unsigned>(topLeft.width()) + static_cast<unsigned>(topRight.width()); // Casts to avoid integer overflow.
- if (radiiSum > static_cast<unsigned>(r.width()))
- factor = min(static_cast<float>(r.width()) / radiiSum, factor);
+ radiiSum = static_cast<unsigned>(radii.topLeft().width()) + static_cast<unsigned>(radii.topRight().width()); // Casts to avoid integer overflow.
+ if (radiiSum > static_cast<unsigned>(rect.width()))
+ factor = std::min(static_cast<float>(rect.width()) / radiiSum, factor);
// bottom
- radiiSum = static_cast<unsigned>(bottomLeft.width()) + static_cast<unsigned>(bottomRight.width());
- if (radiiSum > static_cast<unsigned>(r.width()))
- factor = min(static_cast<float>(r.width()) / radiiSum, factor);
+ radiiSum = static_cast<unsigned>(radii.bottomLeft().width()) + static_cast<unsigned>(radii.bottomRight().width());
+ if (radiiSum > static_cast<unsigned>(rect.width()))
+ factor = std::min(static_cast<float>(rect.width()) / radiiSum, factor);
// left
- radiiSum = static_cast<unsigned>(topLeft.height()) + static_cast<unsigned>(bottomLeft.height());
- if (radiiSum > static_cast<unsigned>(r.height()))
- factor = min(static_cast<float>(r.height()) / radiiSum, factor);
+ radiiSum = static_cast<unsigned>(radii.topLeft().height()) + static_cast<unsigned>(radii.bottomLeft().height());
+ if (radiiSum > static_cast<unsigned>(rect.height()))
+ factor = std::min(static_cast<float>(rect.height()) / radiiSum, factor);
// right
- radiiSum = static_cast<unsigned>(topRight.height()) + static_cast<unsigned>(bottomRight.height());
- if (radiiSum > static_cast<unsigned>(r.height()))
- factor = min(static_cast<float>(r.height()) / radiiSum, factor);
+ radiiSum = static_cast<unsigned>(radii.topRight().height()) + static_cast<unsigned>(radii.bottomRight().height());
+ if (radiiSum > static_cast<unsigned>(rect.height()))
+ factor = std::min(static_cast<float>(rect.height()) / radiiSum, factor);
- // Scale all radii by f if necessary.
- if (factor < 1) {
- // If either radius on a corner becomes zero, reset both radii on that corner.
- topLeft.scale(factor);
- if (!topLeft.width() || !topLeft.height())
- topLeft = IntSize();
- topRight.scale(factor);
- if (!topRight.width() || !topRight.height())
- topRight = IntSize();
- bottomLeft.scale(factor);
- if (!bottomLeft.width() || !bottomLeft.height())
- bottomLeft = IntSize();
- bottomRight.scale(factor);
- if (!bottomRight.width() || !bottomRight.height())
- bottomRight = IntSize();
- }
+ ASSERT(factor <= 1);
+ return factor;
}
-void RenderStyle::getBorderRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const
+RoundedIntRect RenderStyle::getRoundedBorderFor(const IntRect& rect) const
{
- topLeft = IntSize(surround->border.topLeft().width().calcValue(r.width()), surround->border.topLeft().height().calcValue(r.height()));
- topRight = IntSize(surround->border.topRight().width().calcValue(r.width()), surround->border.topRight().height().calcValue(r.height()));
-
- bottomLeft = IntSize(surround->border.bottomLeft().width().calcValue(r.width()), surround->border.bottomLeft().height().calcValue(r.height()));
- bottomRight = IntSize(surround->border.bottomRight().width().calcValue(r.width()), surround->border.bottomRight().height().calcValue(r.height()));
-
- constrainCornerRadiiForRect(r, topLeft, topRight, bottomLeft, bottomRight);
+ RoundedIntRect::Radii radii = calcRadiiFor(surround->border, rect.width(), rect.height());
+ radii.scale(calcConstraintScaleFor(rect, radii));
+ return RoundedIntRect(rect, radii);
}
-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
+RoundedIntRect RenderStyle::getRoundedInnerBorderWithBorderWidths(const IntRect& innerRect, unsigned short topWidth,
+ unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth) const
{
- innerTopLeft = IntSize(surround->border.topLeft().width().calcValue(innerRect.width()), surround->border.topLeft().height().calcValue(innerRect.height()));
- innerTopRight = IntSize(surround->border.topRight().width().calcValue(innerRect.width()), surround->border.topRight().height().calcValue(innerRect.height()));
- innerBottomLeft = IntSize(surround->border.bottomLeft().width().calcValue(innerRect.width()), surround->border.bottomLeft().height().calcValue(innerRect.height()));
- innerBottomRight = IntSize(surround->border.bottomRight().width().calcValue(innerRect.width()), surround->border.bottomRight().height().calcValue(innerRect.height()));
-
-
- 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);
+ RoundedIntRect::Radii radii = calcRadiiFor(surround->border, innerRect.width(), innerRect.height());
+ radii.shrink(topWidth, bottomWidth, leftWidth, rightWidth);
+ radii.scale(calcConstraintScaleFor(innerRect, radii));
+ return RoundedIntRect(innerRect, radii);
}
const CounterDirectiveMap* RenderStyle::counterDirectives() const
diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h
index 14329bc..9d5239b 100644
--- a/Source/WebCore/rendering/style/RenderStyle.h
+++ b/Source/WebCore/rendering/style/RenderStyle.h
@@ -43,6 +43,8 @@
#include "NinePieceImage.h"
#include "OutlineValue.h"
#include "RenderStyleConstants.h"
+#include "RoundedIntRect.h"
+#include "ShadowData.h"
#include "StyleBackgroundData.h"
#include "StyleBoxData.h"
#include "StyleFlexibleBoxData.h"
@@ -862,13 +864,10 @@ public:
{
setBorderRadius(LengthSize(Length(s.width(), Fixed), Length(s.height(), Fixed)));
}
-
- 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;
+ RoundedIntRect getRoundedBorderFor(const IntRect&) const;
+ RoundedIntRect getRoundedInnerBorderWithBorderWidths(const IntRect&, unsigned short topWidth,
+ unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth) 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) }
@@ -1212,11 +1211,11 @@ public:
bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; }
void setChildrenAffectedByBackwardPositionalRules() { m_childrenAffectedByBackwardPositionalRules = true; }
bool firstChildState() const { return m_firstChildState; }
- void setFirstChildState() { m_firstChildState = true; }
+ void setFirstChildState() { m_unique = true; m_firstChildState = true; }
bool lastChildState() const { return m_lastChildState; }
- void setLastChildState() { m_lastChildState = true; }
+ void setLastChildState() { m_unique = true; m_lastChildState = true; }
unsigned childIndex() const { return m_childIndex; }
- void setChildIndex(unsigned index) { m_childIndex = index; }
+ void setChildIndex(unsigned index) { m_unique = true; m_childIndex = index; }
const Color visitedDependentColor(int colorProperty) const;
diff --git a/Source/WebCore/rendering/style/ShadowData.h b/Source/WebCore/rendering/style/ShadowData.h
index fb5926d..0be3fc1 100644
--- a/Source/WebCore/rendering/style/ShadowData.h
+++ b/Source/WebCore/rendering/style/ShadowData.h
@@ -26,7 +26,6 @@
#define ShadowData_h
#include "Color.h"
-#include <wtf/FastAllocBase.h>
namespace WebCore {
@@ -37,7 +36,8 @@ enum ShadowStyle { Normal, Inset };
// This struct holds information about shadows for the text-shadow and box-shadow properties.
-class ShadowData : public FastAllocBase {
+class ShadowData {
+ WTF_MAKE_FAST_ALLOCATED;
public:
ShadowData()
: m_x(0)