summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/style/RenderStyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/rendering/style/RenderStyle.cpp')
-rw-r--r--WebCore/rendering/style/RenderStyle.cpp88
1 files changed, 71 insertions, 17 deletions
diff --git a/WebCore/rendering/style/RenderStyle.cpp b/WebCore/rendering/style/RenderStyle.cpp
index fe53d30..f3a2cd9 100644
--- a/WebCore/rendering/style/RenderStyle.cpp
+++ b/WebCore/rendering/style/RenderStyle.cpp
@@ -32,6 +32,8 @@
#include <wtf/StdLibExtras.h>
#include <algorithm>
+using namespace std;
+
namespace WebCore {
inline RenderStyle* defaultStyle()
@@ -56,14 +58,7 @@ PassRefPtr<RenderStyle> RenderStyle::clone(const RenderStyle* other)
}
RenderStyle::RenderStyle()
- : box(defaultStyle()->box)
- , visual(defaultStyle()->visual)
- , background(defaultStyle()->background)
- , surround(defaultStyle()->surround)
- , rareNonInheritedData(defaultStyle()->rareNonInheritedData)
- , rareInheritedData(defaultStyle()->rareInheritedData)
- , inherited(defaultStyle()->inherited)
- , m_pseudoState(PseudoUnknown)
+ : m_pseudoState(PseudoUnknown)
, m_affectedByAttributeSelectors(false)
, m_unique(false)
, m_affectedByEmpty(false)
@@ -76,6 +71,13 @@ RenderStyle::RenderStyle()
, m_firstChildState(false)
, m_lastChildState(false)
, m_childIndex(0)
+ , box(defaultStyle()->box)
+ , visual(defaultStyle()->visual)
+ , background(defaultStyle()->background)
+ , surround(defaultStyle()->surround)
+ , rareNonInheritedData(defaultStyle()->rareNonInheritedData)
+ , rareInheritedData(defaultStyle()->rareInheritedData)
+ , inherited(defaultStyle()->inherited)
#if ENABLE(SVG)
, m_svgStyle(defaultStyle()->m_svgStyle)
#endif
@@ -119,15 +121,6 @@ RenderStyle::RenderStyle(bool)
RenderStyle::RenderStyle(const RenderStyle& o)
: RefCounted<RenderStyle>()
- , inherited_flags(o.inherited_flags)
- , noninherited_flags(o.noninherited_flags)
- , box(o.box)
- , visual(o.visual)
- , background(o.background)
- , surround(o.surround)
- , rareNonInheritedData(o.rareNonInheritedData)
- , rareInheritedData(o.rareInheritedData)
- , inherited(o.inherited)
, m_pseudoState(o.m_pseudoState)
, m_affectedByAttributeSelectors(false)
, m_unique(false)
@@ -141,9 +134,18 @@ RenderStyle::RenderStyle(const RenderStyle& o)
, m_firstChildState(false)
, m_lastChildState(false)
, m_childIndex(0)
+ , box(o.box)
+ , visual(o.visual)
+ , background(o.background)
+ , surround(o.surround)
+ , rareNonInheritedData(o.rareNonInheritedData)
+ , rareInheritedData(o.rareInheritedData)
+ , inherited(o.inherited)
#if ENABLE(SVG)
, m_svgStyle(o.m_svgStyle)
#endif
+ , inherited_flags(o.inherited_flags)
+ , noninherited_flags(o.noninherited_flags)
{
}
@@ -709,6 +711,58 @@ 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
+{
+ 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
+
+ float factor = 1;
+ 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);
+
+ // 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);
+
+ // 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);
+
+ // 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);
+
+ // 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();
+ }
+}
+
const CounterDirectiveMap* RenderStyle::counterDirectives() const
{
return rareNonInheritedData->m_counterDirectives.get();