| Index: Source/core/rendering/style/RenderStyle.cpp
|
| diff --git a/Source/core/rendering/style/RenderStyle.cpp b/Source/core/rendering/style/RenderStyle.cpp
|
| index f1230077c8fa4ee75a4b250e81a0f95d5ce1a66a..e61d06c4e5c4a7e77e0f337bb29b65520c57431f 100644
|
| --- a/Source/core/rendering/style/RenderStyle.cpp
|
| +++ b/Source/core/rendering/style/RenderStyle.cpp
|
| @@ -37,6 +37,7 @@
|
| #include "platform/LengthFunctions.h"
|
| #include "platform/fonts/Font.h"
|
| #include "platform/fonts/FontSelector.h"
|
| +#include "platform/geometry/FloatRoundedRect.h"
|
| #include "wtf/MathExtras.h"
|
|
|
| using namespace std;
|
| @@ -926,38 +927,6 @@ static RoundedRect::Radii calcRadiiFor(const BorderData& border, IntSize size)
|
| valueForLength(border.bottomRight().height(), size.height())));
|
| }
|
|
|
| -static float calcConstraintScaleFor(const IntRect& rect, const RoundedRect::Radii& radii)
|
| -{
|
| - // 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>(radii.topLeft().width()) + static_cast<unsigned>(radii.topRight().width()); // Casts to avoid integer overflow.
|
| - if (radiiSum > static_cast<unsigned>(rect.width()))
|
| - factor = min(static_cast<float>(rect.width()) / radiiSum, factor);
|
| -
|
| - // bottom
|
| - radiiSum = static_cast<unsigned>(radii.bottomLeft().width()) + static_cast<unsigned>(radii.bottomRight().width());
|
| - if (radiiSum > static_cast<unsigned>(rect.width()))
|
| - factor = min(static_cast<float>(rect.width()) / radiiSum, factor);
|
| -
|
| - // left
|
| - radiiSum = static_cast<unsigned>(radii.topLeft().height()) + static_cast<unsigned>(radii.bottomLeft().height());
|
| - if (radiiSum > static_cast<unsigned>(rect.height()))
|
| - factor = min(static_cast<float>(rect.height()) / radiiSum, factor);
|
| -
|
| - // right
|
| - radiiSum = static_cast<unsigned>(radii.topRight().height()) + static_cast<unsigned>(radii.bottomRight().height());
|
| - if (radiiSum > static_cast<unsigned>(rect.height()))
|
| - factor = min(static_cast<float>(rect.height()) / radiiSum, factor);
|
| -
|
| - ASSERT(factor <= 1);
|
| - return factor;
|
| -}
|
| -
|
| StyleImage* RenderStyle::listStyleImage() const { return rareInheritedData->listStyleImage.get(); }
|
| void RenderStyle::setListStyleImage(PassRefPtr<StyleImage> v)
|
| {
|
| @@ -981,7 +950,7 @@ RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, bool
|
| RoundedRect roundedRect(snappedBorderRect);
|
| if (hasBorderRadius()) {
|
| RoundedRect::Radii radii = calcRadiiFor(surround->border, snappedBorderRect.size());
|
| - radii.scale(calcConstraintScaleFor(snappedBorderRect, radii));
|
| + radii.scale(calcBorderRadiiConstraintScaleFor(borderRect, radii));
|
| roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
|
| }
|
| return roundedRect;
|
| @@ -1625,4 +1594,36 @@ void RenderStyle::setBorderImageOutset(const BorderImageLengthBox& outset)
|
| surround.access()->border.m_image.setOutset(outset);
|
| }
|
|
|
| +float calcBorderRadiiConstraintScaleFor(const FloatRect& rect, const FloatRoundedRect::Radii& radii)
|
| +{
|
| + // Constrain corner radii using CSS3 rules:
|
| + // http://www.w3.org/TR/css3-background/#the-border-radius
|
| +
|
| + float factor = 1;
|
| + float radiiSum;
|
| +
|
| + // top
|
| + radiiSum = radii.topLeft().width() + radii.topRight().width(); // Casts to avoid integer overflow.
|
| + if (radiiSum > rect.width())
|
| + factor = std::min(rect.width() / radiiSum, factor);
|
| +
|
| + // bottom
|
| + radiiSum = radii.bottomLeft().width() + radii.bottomRight().width();
|
| + if (radiiSum > rect.width())
|
| + factor = std::min(rect.width() / radiiSum, factor);
|
| +
|
| + // left
|
| + radiiSum = radii.topLeft().height() + radii.bottomLeft().height();
|
| + if (radiiSum > rect.height())
|
| + factor = std::min(rect.height() / radiiSum, factor);
|
| +
|
| + // right
|
| + radiiSum = radii.topRight().height() + radii.bottomRight().height();
|
| + if (radiiSum > rect.height())
|
| + factor = std::min(rect.height() / radiiSum, factor);
|
| +
|
| + ASSERT(factor <= 1);
|
| + return factor;
|
| +}
|
| +
|
| } // namespace WebCore
|
|
|