[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
morrita at google.com
morrita at google.com
Sun Feb 20 23:09:04 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit 1da9327bd294f549d7f3fa3b15cacbea58331438
Author: morrita at google.com <morrita at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 18 08:59:01 2011 +0000
2011-01-17 MORITA Hajime <morrita at google.com>
Reviewed by Simon Fraser.
Refactoring: Extract RoundedIntRect class
https://bugs.webkit.org/show_bug.cgi?id=51664
RoundedIntRect is a pair of rect and four IntSize objects which represent
corner radii of the rectangle. IntSize is grouped into RoundedIntRect::Radii.
Now RenderStyle::getRoundedBorderFor() and RenderStyle::getRoundedInnerBorderWithBorderWidths()
return RoundedIntRect and GraphicsContext::addRoundedRectClip(), GraphicsContext::fillRoundedRect()
and other functions accept RoundedIntRect as an argument.
No new tests. No behavioral change.
* Android.mk:
* CMakeLists.txt:
* WebCore.gypi:
* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::addRoundedRectClip):
(WebCore::GraphicsContext::clipOutRoundedRect):
(WebCore::GraphicsContext::fillRoundedRect):
* platform/graphics/GraphicsContext.h:
* platform/graphics/RoundedIntRect.cpp: Added.
(WebCore::RoundedIntRect::Radii::isZero):
(WebCore::RoundedIntRect::Radii::scale):
(WebCore::RoundedIntRect::Radii::expand):
(WebCore::RoundedIntRect::Radii::includeLogicalEdges):
(WebCore::RoundedIntRect::Radii::excludeLogicalEdges):
(WebCore::RoundedIntRect::RoundedIntRect):
(WebCore::RoundedIntRect::includeLogicalEdges):
(WebCore::RoundedIntRect::excludeLogicalEdges):
* platform/graphics/RoundedIntRect.h: Added.
(WebCore::RoundedIntRect::Radii::Radii):
(WebCore::RoundedIntRect::Radii::setTopLeft):
(WebCore::RoundedIntRect::Radii::setTopRight):
(WebCore::RoundedIntRect::Radii::setBottomLeft):
(WebCore::RoundedIntRect::Radii::setBottomRight):
(WebCore::RoundedIntRect::Radii::topLeft):
(WebCore::RoundedIntRect::Radii::topRight):
(WebCore::RoundedIntRect::Radii::bottomLeft):
(WebCore::RoundedIntRect::Radii::bottomRight):
(WebCore::RoundedIntRect::Radii::expand):
(WebCore::RoundedIntRect::Radii::shrink):
(WebCore::RoundedIntRect::location):
(WebCore::RoundedIntRect::size):
(WebCore::RoundedIntRect::x):
(WebCore::RoundedIntRect::y):
(WebCore::RoundedIntRect::width):
(WebCore::RoundedIntRect::height):
(WebCore::RoundedIntRect::right):
(WebCore::RoundedIntRect::bottom):
(WebCore::RoundedIntRect::rect):
(WebCore::RoundedIntRect::radii):
(WebCore::RoundedIntRect::isRounded):
(WebCore::RoundedIntRect::isEmpty):
(WebCore::RoundedIntRect::setRect):
(WebCore::RoundedIntRect::setRadii):
(WebCore::RoundedIntRect::move):
(WebCore::RoundedIntRect::inflate):
(WebCore::RoundedIntRect::inflateWithRadii):
(WebCore::RoundedIntRect::expandRadii):
(WebCore::RoundedIntRect::shrinkRadii):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::pushContentsClip):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
(WebCore::RenderBoxModelObject::paintBorder):
(WebCore::RenderBoxModelObject::clipBorderSidePolygon):
(WebCore::RenderBoxModelObject::paintBoxShadow):
* rendering/RenderBoxModelObject.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::drawBoxSideFromPath):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::paint):
* rendering/RenderThemeChromiumWin.cpp:
(WebCore::RenderThemeChromiumWin::paintTextFieldInternal):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMenuListButtonGradients):
(WebCore::RenderThemeMac::paintSliderTrack):
* rendering/RenderThemeSafari.cpp:
(WebCore::RenderThemeSafari::paintMenuListButtonGradients):
(WebCore::RenderThemeSafari::paintSliderTrack):
* rendering/RenderThemeWinCE.cpp:
(WebCore::RenderThemeWinCE::paintSearchFieldCancelButton):
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::paint):
* rendering/style/BorderData.h:
* rendering/style/RenderStyle.cpp:
(WebCore::calcRadiiFor):
(WebCore::calcConstraintScaleFor):
(WebCore::RenderStyle::getRoundedBorderFor):
(WebCore::RenderStyle::getRoundedInnerBorderWithBorderWidths):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::setBorderRadius):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76004 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index 9ca484a..4251338 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -531,6 +531,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/Path.cpp \
platform/graphics/PathTraversalState.cpp \
platform/graphics/Pattern.cpp \
+ platform/graphics/RoundedIntRect.cpp \
platform/graphics/SegmentedFontData.cpp \
platform/graphics/SimpleFontData.cpp \
platform/graphics/StringTruncator.cpp \
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index 8050b48..765e413 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -1350,6 +1350,7 @@ SET(WebCore_SOURCES
platform/graphics/Path.cpp
platform/graphics/PathTraversalState.cpp
platform/graphics/Pattern.cpp
+ platform/graphics/RoundedIntRect.cpp
platform/graphics/SegmentedFontData.cpp
platform/graphics/SimpleFontData.cpp
platform/graphics/StringTruncator.cpp
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 404a4a3..3dd6c6c 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,101 @@
+2011-01-17 MORITA Hajime <morrita at google.com>
+
+ Reviewed by Simon Fraser.
+
+ Refactoring: Extract RoundedIntRect class
+ https://bugs.webkit.org/show_bug.cgi?id=51664
+
+ RoundedIntRect is a pair of rect and four IntSize objects which represent
+ corner radii of the rectangle. IntSize is grouped into RoundedIntRect::Radii.
+ Now RenderStyle::getRoundedBorderFor() and RenderStyle::getRoundedInnerBorderWithBorderWidths()
+ return RoundedIntRect and GraphicsContext::addRoundedRectClip(), GraphicsContext::fillRoundedRect()
+ and other functions accept RoundedIntRect as an argument.
+
+ No new tests. No behavioral change.
+
+ * Android.mk:
+ * CMakeLists.txt:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::addRoundedRectClip):
+ (WebCore::GraphicsContext::clipOutRoundedRect):
+ (WebCore::GraphicsContext::fillRoundedRect):
+ * platform/graphics/GraphicsContext.h:
+ * platform/graphics/RoundedIntRect.cpp: Added.
+ (WebCore::RoundedIntRect::Radii::isZero):
+ (WebCore::RoundedIntRect::Radii::scale):
+ (WebCore::RoundedIntRect::Radii::expand):
+ (WebCore::RoundedIntRect::Radii::includeLogicalEdges):
+ (WebCore::RoundedIntRect::Radii::excludeLogicalEdges):
+ (WebCore::RoundedIntRect::RoundedIntRect):
+ (WebCore::RoundedIntRect::includeLogicalEdges):
+ (WebCore::RoundedIntRect::excludeLogicalEdges):
+ * platform/graphics/RoundedIntRect.h: Added.
+ (WebCore::RoundedIntRect::Radii::Radii):
+ (WebCore::RoundedIntRect::Radii::setTopLeft):
+ (WebCore::RoundedIntRect::Radii::setTopRight):
+ (WebCore::RoundedIntRect::Radii::setBottomLeft):
+ (WebCore::RoundedIntRect::Radii::setBottomRight):
+ (WebCore::RoundedIntRect::Radii::topLeft):
+ (WebCore::RoundedIntRect::Radii::topRight):
+ (WebCore::RoundedIntRect::Radii::bottomLeft):
+ (WebCore::RoundedIntRect::Radii::bottomRight):
+ (WebCore::RoundedIntRect::Radii::expand):
+ (WebCore::RoundedIntRect::Radii::shrink):
+ (WebCore::RoundedIntRect::location):
+ (WebCore::RoundedIntRect::size):
+ (WebCore::RoundedIntRect::x):
+ (WebCore::RoundedIntRect::y):
+ (WebCore::RoundedIntRect::width):
+ (WebCore::RoundedIntRect::height):
+ (WebCore::RoundedIntRect::right):
+ (WebCore::RoundedIntRect::bottom):
+ (WebCore::RoundedIntRect::rect):
+ (WebCore::RoundedIntRect::radii):
+ (WebCore::RoundedIntRect::isRounded):
+ (WebCore::RoundedIntRect::isEmpty):
+ (WebCore::RoundedIntRect::setRect):
+ (WebCore::RoundedIntRect::setRadii):
+ (WebCore::RoundedIntRect::move):
+ (WebCore::RoundedIntRect::inflate):
+ (WebCore::RoundedIntRect::inflateWithRadii):
+ (WebCore::RoundedIntRect::expandRadii):
+ (WebCore::RoundedIntRect::shrinkRadii):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::pushContentsClip):
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+ (WebCore::RenderBoxModelObject::paintBorder):
+ (WebCore::RenderBoxModelObject::clipBorderSidePolygon):
+ (WebCore::RenderBoxModelObject::paintBoxShadow):
+ * rendering/RenderBoxModelObject.h:
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::drawBoxSideFromPath):
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::paint):
+ * rendering/RenderThemeChromiumWin.cpp:
+ (WebCore::RenderThemeChromiumWin::paintTextFieldInternal):
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::paintMenuListButtonGradients):
+ (WebCore::RenderThemeMac::paintSliderTrack):
+ * rendering/RenderThemeSafari.cpp:
+ (WebCore::RenderThemeSafari::paintMenuListButtonGradients):
+ (WebCore::RenderThemeSafari::paintSliderTrack):
+ * rendering/RenderThemeWinCE.cpp:
+ (WebCore::RenderThemeWinCE::paintSearchFieldCancelButton):
+ * rendering/RenderWidget.cpp:
+ (WebCore::RenderWidget::paint):
+ * rendering/style/BorderData.h:
+ * rendering/style/RenderStyle.cpp:
+ (WebCore::calcRadiiFor):
+ (WebCore::calcConstraintScaleFor):
+ (WebCore::RenderStyle::getRoundedBorderFor):
+ (WebCore::RenderStyle::getRoundedInnerBorderWithBorderWidths):
+ * rendering/style/RenderStyle.h:
+ (WebCore::InheritedFlags::setBorderRadius):
+
2011-01-17 Rob Buis <rwlbuis at gmail.com>
Reviewed by Kent Tamura.
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index f4a239f..84f8837 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -2942,6 +2942,8 @@
'platform/graphics/PathTraversalState.h',
'platform/graphics/Pattern.cpp',
'platform/graphics/Pattern.h',
+ 'platform/graphics/RoundedIntRect.cpp',
+ 'platform/graphics/RoundedIntRect.h',
'platform/graphics/SegmentedFontData.cpp',
'platform/graphics/SegmentedFontData.h',
'platform/graphics/SimpleFontData.cpp',
diff --git a/Source/WebCore/WebCore.pro b/Source/WebCore/WebCore.pro
index d37cdc7..de12297 100644
--- a/Source/WebCore/WebCore.pro
+++ b/Source/WebCore/WebCore.pro
@@ -1210,6 +1210,7 @@ SOURCES += \
platform/graphics/Path.cpp \
platform/graphics/PathTraversalState.cpp \
platform/graphics/Pattern.cpp \
+ platform/graphics/RoundedIntRect.cpp \
platform/graphics/SegmentedFontData.cpp \
platform/graphics/SimpleFontData.cpp \
platform/graphics/TiledBackingStore.cpp \
@@ -2129,6 +2130,7 @@ HEADERS += \
platform/graphics/Path.h \
platform/graphics/PathTraversalState.h \
platform/graphics/Pattern.h \
+ platform/graphics/RoundedIntRect.h \
platform/graphics/qt/FontCustomPlatformData.h \
platform/graphics/qt/ImageDecoderQt.h \
platform/graphics/qt/StillImageQt.h \
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index ed86c67..215f820 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -3163,6 +3163,8 @@
A622A8FF122C44A600A785B3 /* GenericBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F9122C44A600A785B3 /* GenericBinding.h */; };
A718760E0B2A120100A16ECE /* DragActions.h in Headers */ = {isa = PBXBuildFile; fileRef = A718760D0B2A120100A16ECE /* DragActions.h */; settings = {ATTRIBUTES = (Private, ); }; };
A71878900B2D04AC00A16ECE /* DragControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */; };
+ A73F95FE12C97BFE0031AAF9 /* RoundedIntRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73F95FC12C97BFE0031AAF9 /* RoundedIntRect.cpp */; };
+ A73F95FF12C97BFE0031AAF9 /* RoundedIntRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A73F95FD12C97BFE0031AAF9 /* RoundedIntRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
A75E497610752ACB00C9B896 /* SerializedScriptValue.h in Headers */ = {isa = PBXBuildFile; fileRef = A75E497410752ACB00C9B896 /* SerializedScriptValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
A75E497710752ACB00C9B896 /* SerializedScriptValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */; };
A75E8B880E1DE2D6007F2481 /* FEBlend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75E8B800E1DE2D6007F2481 /* FEBlend.cpp */; };
@@ -9533,6 +9535,8 @@
A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = "<group>"; };
A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragControllerMac.mm; sourceTree = "<group>"; };
A71A70C911AFB02000989D6D /* HTMLMeterElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLMeterElement.idl; sourceTree = "<group>"; };
+ A73F95FC12C97BFE0031AAF9 /* RoundedIntRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RoundedIntRect.cpp; sourceTree = "<group>"; };
+ A73F95FD12C97BFE0031AAF9 /* RoundedIntRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoundedIntRect.h; sourceTree = "<group>"; };
A75E497410752ACB00C9B896 /* SerializedScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedScriptValue.h; sourceTree = "<group>"; };
A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerializedScriptValue.cpp; sourceTree = "<group>"; };
A75E8B800E1DE2D6007F2481 /* FEBlend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FEBlend.cpp; path = filters/FEBlend.cpp; sourceTree = "<group>"; };
@@ -17460,6 +17464,8 @@
A88DD4860B4629A300C02990 /* PathTraversalState.h */,
A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */,
A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
+ A73F95FC12C97BFE0031AAF9 /* RoundedIntRect.cpp */,
+ A73F95FD12C97BFE0031AAF9 /* RoundedIntRect.h */,
371F4FFB0D25E7F300ECE0D5 /* SegmentedFontData.cpp */,
371F4FFA0D25E7F300ECE0D5 /* SegmentedFontData.h */,
B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */,
@@ -21725,6 +21731,7 @@
FD3160AD12B026F700C1A359 /* ReverbInputBuffer.h in Headers */,
BC74DA371013F3F7007987AD /* RGBColor.h in Headers */,
A8CFF5E10A155A05000A4234 /* RootInlineBox.h in Headers */,
+ A73F95FF12C97BFE0031AAF9 /* RoundedIntRect.h in Headers */,
49E911C90EF86D47009D0CAF /* RotateTransformOperation.h in Headers */,
1C63A2480F71646600C09D5A /* RunLoopTimer.h in Headers */,
1A569D1F0D7E2B82007C3983 /* runtime_array.h in Headers */,
@@ -24516,6 +24523,7 @@
FD3160AC12B026F700C1A359 /* ReverbInputBuffer.cpp in Sources */,
BC74DA381013F3F7007987AD /* RGBColor.cpp in Sources */,
A8CFF5E70A155A05000A4234 /* RootInlineBox.cpp in Sources */,
+ A73F95FE12C97BFE0031AAF9 /* RoundedIntRect.cpp in Sources */,
49E911C80EF86D47009D0CAF /* RotateTransformOperation.cpp in Sources */,
1C63A2490F71646600C09D5A /* RunLoopTimerCF.cpp in Sources */,
1A569D1E0D7E2B82007C3983 /* runtime_array.cpp in Sources */,
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp
index 61b778c..e7ea881 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp
@@ -31,6 +31,7 @@
#include "Generator.h"
#include "ImageBuffer.h"
#include "IntRect.h"
+#include "RoundedIntRect.h"
using namespace std;
@@ -536,25 +537,23 @@ void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorS
image->draw(this, styleColorSpace, dest, src, op, useLowQualityScale);
}
-void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
- const IntSize& bottomLeft, const IntSize& bottomRight)
+void GraphicsContext::addRoundedRectClip(const RoundedIntRect& rect)
{
if (paintingDisabled())
return;
Path path;
- path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
+ path.addRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight());
clip(path);
}
-void GraphicsContext::clipOutRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
- const IntSize& bottomLeft, const IntSize& bottomRight)
+void GraphicsContext::clipOutRoundedRect(const RoundedIntRect& rect)
{
if (paintingDisabled())
return;
Path path;
- path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
+ path.addRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight());
clipOut(path);
}
@@ -585,6 +584,11 @@ void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator)
generator.fill(this, rect);
}
+void GraphicsContext::fillRoundedRect(const RoundedIntRect& rect, const Color& color, ColorSpace colorSpace)
+{
+ fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);
+}
+
void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation)
{
m_state.compositeOperator = compositeOperation;
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h
index 8588523..a459b37 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.h
+++ b/Source/WebCore/platform/graphics/GraphicsContext.h
@@ -120,6 +120,7 @@ namespace WebCore {
class GraphicsContextPlatformPrivate;
class ImageBuffer;
class IntRect;
+ class RoundedIntRect;
class KURL;
class SharedGraphicsContext3D;
class TextRun;
@@ -282,6 +283,7 @@ namespace WebCore {
void fillRect(const FloatRect&, const Color&, ColorSpace);
void fillRect(const FloatRect&, Generator&);
void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
+ void fillRoundedRect(const RoundedIntRect&, const Color&, ColorSpace);
void clearRect(const FloatRect&);
@@ -310,10 +312,10 @@ namespace WebCore {
InterpolationQuality imageInterpolationQuality() const;
void clip(const FloatRect&);
- void addRoundedRectClip(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
+ void addRoundedRectClip(const RoundedIntRect&);
void addInnerRoundedRectClip(const IntRect&, int thickness);
void clipOut(const IntRect&);
- void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
+ void clipOutRoundedRect(const RoundedIntRect&);
void clipPath(const Path&, WindRule);
void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
void clipToImageBuffer(ImageBuffer*, const FloatRect&);
diff --git a/Source/WebCore/platform/graphics/RoundedIntRect.cpp b/Source/WebCore/platform/graphics/RoundedIntRect.cpp
new file mode 100644
index 0000000..4e80c9a
--- /dev/null
+++ b/Source/WebCore/platform/graphics/RoundedIntRect.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RoundedIntRect.h"
+
+#include "IntRect.h"
+#include <algorithm>
+
+namespace WebCore {
+
+bool RoundedIntRect::Radii::isZero() const
+{
+ return m_topLeft.isZero() && m_topRight.isZero() && m_bottomLeft.isZero() && m_bottomRight.isZero();
+}
+
+void RoundedIntRect::Radii::scale(float factor)
+{
+ if (factor == 1)
+ return;
+
+ // If either radius on a corner becomes zero, reset both radii on that corner.
+ m_topLeft.scale(factor);
+ if (!m_topLeft.width() || !m_topLeft.height())
+ m_topLeft = IntSize();
+ m_topRight.scale(factor);
+ if (!m_topRight.width() || !m_topRight.height())
+ m_topRight = IntSize();
+ m_bottomLeft.scale(factor);
+ if (!m_bottomLeft.width() || !m_bottomLeft.height())
+ m_bottomLeft = IntSize();
+ m_bottomRight.scale(factor);
+ if (!m_bottomRight.width() || !m_bottomRight.height())
+ m_bottomRight = IntSize();
+
+}
+
+void RoundedIntRect::Radii::expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth)
+{
+ m_topLeft.setWidth(std::max(0, m_topLeft.width() + leftWidth));
+ m_topLeft.setHeight(std::max(0, m_topLeft.height() + topWidth));
+
+ m_topRight.setWidth(std::max(0, m_topRight.width() + rightWidth));
+ m_topRight.setHeight(std::max(0, m_topRight.height() + topWidth));
+
+ m_bottomLeft.setWidth(std::max(0, m_bottomLeft.width() + leftWidth));
+ m_bottomLeft.setHeight(std::max(0, m_bottomLeft.height() + bottomWidth));
+
+ m_bottomRight.setWidth(std::max(0, m_bottomRight.width() + rightWidth));
+ m_bottomRight.setHeight(std::max(0, m_bottomRight.height() + bottomWidth));
+}
+
+void RoundedIntRect::Radii::includeLogicalEdges(const RoundedIntRect::Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
+{
+ if (includeLogicalLeftEdge) {
+ if (isHorizontal)
+ m_bottomLeft = edges.bottomLeft();
+ else
+ m_topRight = edges.topRight();
+ m_topLeft = edges.topLeft();
+ }
+
+ if (includeLogicalRightEdge) {
+ if (isHorizontal)
+ m_topRight = edges.topRight();
+ else
+ m_bottomLeft = edges.bottomLeft();
+ m_bottomRight = edges.bottomRight();
+ }
+}
+
+void RoundedIntRect::Radii::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge)
+{
+ if (excludeLogicalLeftEdge) {
+ if (isHorizontal)
+ m_bottomLeft = IntSize();
+ else
+ m_topRight = IntSize();
+ m_topLeft = IntSize();
+ }
+
+ if (excludeLogicalRightEdge) {
+ if (isHorizontal)
+ m_topRight = IntSize();
+ else
+ m_bottomLeft = IntSize();
+ m_bottomRight = IntSize();
+ }
+}
+
+RoundedIntRect::RoundedIntRect(int x, int y, int width, int height)
+ : m_rect(x, y, width, height)
+{
+}
+
+RoundedIntRect::RoundedIntRect(const IntRect& rect, const Radii& radii)
+ : m_rect(rect)
+ , m_radii(radii)
+{
+}
+
+RoundedIntRect::RoundedIntRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight)
+ : m_rect(rect)
+ , m_radii(topLeft, topRight, bottomLeft, bottomRight)
+{
+}
+
+void RoundedIntRect::includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
+{
+ m_radii.includeLogicalEdges(edges, isHorizontal, includeLogicalLeftEdge, includeLogicalRightEdge);
+}
+
+void RoundedIntRect::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge)
+{
+ m_radii.excludeLogicalEdges(isHorizontal, excludeLogicalLeftEdge, excludeLogicalRightEdge);
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/RoundedIntRect.h b/Source/WebCore/platform/graphics/RoundedIntRect.h
new file mode 100644
index 0000000..39b7fb4
--- /dev/null
+++ b/Source/WebCore/platform/graphics/RoundedIntRect.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RoundedIntRect_h
+#define RoundedIntRect_h
+
+#include "IntRect.h"
+
+namespace WebCore {
+
+
+class RoundedIntRect {
+public:
+ class Radii {
+ public:
+ Radii() {}
+ Radii(const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight)
+ : m_topLeft(topLeft)
+ , m_topRight(topRight)
+ , m_bottomLeft(bottomLeft)
+ , m_bottomRight(bottomRight)
+ {
+ }
+
+ void setTopLeft(const IntSize& size) { m_topLeft = size; }
+ void setTopRight(const IntSize& size) { m_topRight = size; }
+ void setBottomLeft(const IntSize& size) { m_bottomLeft = size; }
+ void setBottomRight(const IntSize& size) { m_bottomRight = size; }
+ const IntSize& topLeft() const { return m_topLeft; }
+ const IntSize& topRight() const { return m_topRight; }
+ const IntSize& bottomLeft() const { return m_bottomLeft; }
+ const IntSize& bottomRight() const { return m_bottomRight; }
+
+ bool isZero() const;
+
+ void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
+ void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge);
+
+ void scale(float factor);
+ void expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth);
+ void expand(int size) { expand(size, size, size, size); }
+ void shrink(int topWidth, int bottomWidth, int leftWidth, int rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); }
+ void shrink(int size) { shrink(size, size, size, size); }
+
+ private:
+ IntSize m_topLeft;
+ IntSize m_topRight;
+ IntSize m_bottomLeft;
+ IntSize m_bottomRight;
+ };
+
+ explicit RoundedIntRect(const IntRect&, const Radii& = Radii());
+ RoundedIntRect(int x, int y, int width, int height);
+ RoundedIntRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
+
+ IntPoint location() const { return m_rect.location(); }
+ IntSize size() const { return m_rect.size(); }
+
+ int x() const { return m_rect.x(); }
+ int y() const { return m_rect.y(); }
+ int width() const { return m_rect.width(); }
+ int height() const { return m_rect.height(); }
+ int right() const { return m_rect.right(); }
+ int bottom() const { return m_rect.bottom(); }
+
+ const IntRect& rect() const { return m_rect; }
+ const Radii& radii() const { return m_radii; }
+ bool isRounded() const { return !m_radii.isZero(); }
+ bool isEmpty() const { return m_rect.isEmpty(); }
+
+ void setRect(const IntRect& rect) { m_rect = rect; }
+ void setRadii(const Radii& radii) { m_radii = radii; }
+
+ void move(const IntSize size) { m_rect.move(size); }
+ void inflate(int size) { m_rect.inflate(size); }
+ void inflateWithRadii(int size) { m_rect.inflate(size); m_radii.expand(size); }
+ void expandRadii(int size) { m_radii.expand(size); }
+ void shrinkRadii(int size) { m_radii.shrink(size); }
+
+ void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
+ void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge);
+
+private:
+ IntRect m_rect;
+ Radii m_radii;
+};
+
+} // namespace WebCore
+
+#endif // RoundedIntRect_h
diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp
index 3d367aa..f20aa0e 100644
--- a/Source/WebCore/rendering/RenderBox.cpp
+++ b/Source/WebCore/rendering/RenderBox.cpp
@@ -1067,14 +1067,8 @@ bool RenderBox::pushContentsClip(PaintInfo& paintInfo, int tx, int ty)
}
IntRect clipRect(isControlClip ? controlClipRect(tx, ty) : overflowClipRect(tx, ty));
paintInfo.context->save();
- if (style()->hasBorderRadius()) {
- IntSize topLeft, topRight, bottomLeft, bottomRight;
- IntRect borderRect = IntRect(tx, ty, width(), height());
- style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
-
- paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
- }
-
+ if (style()->hasBorderRadius())
+ paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(IntRect(tx, ty, width(), height())));
paintInfo.context->clip(clipRect);
return true;
}
diff --git a/Source/WebCore/rendering/RenderBoxModelObject.cpp b/Source/WebCore/rendering/RenderBoxModelObject.cpp
index 5098306..11771a7 100644
--- a/Source/WebCore/rendering/RenderBoxModelObject.cpp
+++ b/Source/WebCore/rendering/RenderBoxModelObject.cpp
@@ -547,26 +547,9 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
context->save();
- IntSize topLeft, topRight, bottomLeft, bottomRight;
- style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
-
- if (!includeLeftEdge) {
- topLeft = IntSize();
- if (box->isHorizontal())
- bottomLeft = IntSize();
- else
- topRight = IntSize();
- }
-
- if (!includeRightEdge) {
- if (box->isHorizontal())
- topRight = IntSize();
- else
- bottomLeft = IntSize();
- bottomRight = IntSize();
- }
-
- context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
+ RoundedIntRect border = style()->getRoundedBorderFor(borderRect);
+ border.excludeLogicalEdges(box->isHorizontal(), !includeLeftEdge, !includeRightEdge);
+ context->addRoundedRectClip(border);
clippedToBorderRadius = true;
}
@@ -1024,62 +1007,32 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
bool renderRight = rightStyle > BHIDDEN && !rightTransparent && (!horizontal || includeLogicalRightEdge);
bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent && (horizontal || includeLogicalRightEdge);
- bool renderRadii = false;
Path roundedPath;
- IntSize topLeft, topRight, bottomLeft, bottomRight;
- IntRect borderRect(tx, ty, w, h);
+ RoundedIntRect border(tx, ty, w, h);
if (style->hasBorderRadius()) {
- IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius;
- style->getBorderRadiiForRect(borderRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+ border.includeLogicalEdges(style->getRoundedBorderFor(border.rect()).radii(),
+ horizontal, includeLogicalLeftEdge, includeLogicalRightEdge);
int leftWidth = (!horizontal || includeLogicalLeftEdge) ? style->borderLeftWidth() : 0;
int rightWidth = (!horizontal || includeLogicalRightEdge) ? style->borderRightWidth() : 0;
int topWidth = (horizontal || includeLogicalLeftEdge) ? style->borderTopWidth() : 0;
int bottomWidth = (horizontal || includeLogicalRightEdge) ? style->borderBottomWidth() : 0;
- IntRect innerBorderRect = borderInnerRect(borderRect, topWidth, bottomWidth, leftWidth, rightWidth);
- IntSize innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius;
-
- style->getInnerBorderRadiiForRectWithBorderWidths(innerBorderRect, topWidth, bottomWidth, leftWidth, rightWidth, innerTopLeftRadius, innerTopRightRadius, innerBottomLeftRadius, innerBottomRightRadius);
-
- IntSize innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight;
-
- if (includeLogicalLeftEdge) {
- topLeft = topLeftRadius;
- innerTopLeft = innerTopLeftRadius;
- if (horizontal) {
- bottomLeft = bottomLeftRadius;
- innerBottomLeft = innerBottomLeftRadius;
- } else {
- topRight = topRightRadius;
- innerTopRight = innerTopRightRadius;
- }
- }
-
- if (includeLogicalRightEdge) {
- if (horizontal) {
- topRight = topRightRadius;
- innerTopRight = innerTopRightRadius;
- } else {
- bottomLeft = bottomLeftRadius;
- innerBottomLeft = innerBottomLeftRadius;
- }
- bottomRight = bottomRightRadius;
- innerBottomRight = innerBottomRightRadius;
- }
+ RoundedIntRect inner(borderInnerRect(border.rect(), topWidth, bottomWidth, leftWidth, rightWidth));
+ inner.includeLogicalEdges(style->getRoundedInnerBorderWithBorderWidths(inner.rect(), topWidth, bottomWidth, leftWidth, rightWidth).radii(),
+ horizontal, includeLogicalLeftEdge, includeLogicalRightEdge);
- renderRadii = !topLeft.isZero() || !topRight.isZero() || !bottomLeft.isZero() || !bottomRight.isZero();
-
- if (renderRadii) {
+ if (border.isRounded()) {
// Clip to the inner and outer radii rects.
graphicsContext->save();
- graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
- graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight);
- roundedPath.addRoundedRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
+ graphicsContext->addRoundedRectClip(border);
+ graphicsContext->clipOutRoundedRect(inner);
+ roundedPath.addRoundedRect(border.rect(), border.radii().topLeft(), border.radii().topRight(), border.radii().bottomLeft(), border.radii().bottomRight());
}
}
+ bool renderRadii = border.isRounded();
bool upperLeftBorderStylesMatch = renderLeft && (topStyle == leftStyle) && (topColor == leftColor);
bool upperRightBorderStylesMatch = renderRight && (topStyle == rightStyle) && (topColor == rightColor) && (topStyle != OUTSET) && (topStyle != RIDGE) && (topStyle != INSET) && (topStyle != GROOVE);
bool lowerLeftBorderStylesMatch = renderLeft && (bottomStyle == leftStyle) && (bottomColor == leftColor) && (bottomStyle != OUTSET) && (bottomStyle != RIDGE) && (bottomStyle != INSET) && (bottomStyle != GROOVE);
@@ -1089,11 +1042,11 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
int x = tx;
int x2 = tx + w;
- if (renderRadii && borderWillArcInnerEdge(topLeft, topRight, style->borderLeftWidth(), style->borderRightWidth(), style->borderTopWidth())) {
+ if (renderRadii && borderWillArcInnerEdge(border.radii().topLeft(), border.radii().topRight(), style->borderLeftWidth(), style->borderRightWidth(), style->borderTopWidth())) {
graphicsContext->save();
- clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSTop, upperLeftBorderStylesMatch, upperRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
+ clipBorderSidePolygon(graphicsContext, border, BSTop, upperLeftBorderStylesMatch, upperRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
float thickness = max(max(style->borderTopWidth(), style->borderLeftWidth()), style->borderRightWidth());
- drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderTopWidth(), thickness, BSTop, style, topColor, topStyle);
+ drawBoxSideFromPath(graphicsContext, border.rect(), roundedPath, style->borderTopWidth(), thickness, BSTop, style, topColor, topStyle);
graphicsContext->restore();
} else {
bool ignoreLeft = (topColor == leftColor && topTransparent == leftTransparent && topStyle >= OUTSET
@@ -1110,11 +1063,11 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
int x = tx;
int x2 = tx + w;
- if (renderRadii && borderWillArcInnerEdge(bottomLeft, bottomRight, style->borderLeftWidth(), style->borderRightWidth(), style->borderBottomWidth())) {
+ if (renderRadii && borderWillArcInnerEdge(border.radii().bottomLeft(), border.radii().bottomRight(), style->borderLeftWidth(), style->borderRightWidth(), style->borderBottomWidth())) {
graphicsContext->save();
- clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSBottom, lowerLeftBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
+ clipBorderSidePolygon(graphicsContext, border, BSBottom, lowerLeftBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
float thickness = max(max(style->borderBottomWidth(), style->borderLeftWidth()), style->borderRightWidth());
- drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderBottomWidth(), thickness, BSBottom, style, bottomColor, bottomStyle);
+ drawBoxSideFromPath(graphicsContext, border.rect(), roundedPath, style->borderBottomWidth(), thickness, BSBottom, style, bottomColor, bottomStyle);
graphicsContext->restore();
} else {
bool ignoreLeft = (bottomColor == leftColor && bottomTransparent == leftTransparent && bottomStyle >= OUTSET
@@ -1133,11 +1086,11 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
int y = ty;
int y2 = ty + h;
- if (renderRadii && borderWillArcInnerEdge(bottomLeft, topLeft, style->borderBottomWidth(), style->borderTopWidth(), style->borderLeftWidth())) {
+ if (renderRadii && borderWillArcInnerEdge(border.radii().bottomLeft(), border.radii().topLeft(), style->borderBottomWidth(), style->borderTopWidth(), style->borderLeftWidth())) {
graphicsContext->save();
- clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSLeft, upperLeftBorderStylesMatch, lowerLeftBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
+ clipBorderSidePolygon(graphicsContext, border, BSLeft, upperLeftBorderStylesMatch, lowerLeftBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
float thickness = max(max(style->borderLeftWidth(), style->borderTopWidth()), style->borderBottomWidth());
- drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderLeftWidth(), thickness, BSLeft, style, leftColor, leftStyle);
+ drawBoxSideFromPath(graphicsContext, border.rect(), roundedPath, style->borderLeftWidth(), thickness, BSLeft, style, leftColor, leftStyle);
graphicsContext->restore();
} else {
bool ignoreTop = (topColor == leftColor && topTransparent == leftTransparent && leftStyle >= OUTSET
@@ -1152,11 +1105,11 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}
if (renderRight) {
- if (renderRadii && borderWillArcInnerEdge(bottomRight, topRight, style->borderBottomWidth(), style->borderTopWidth(), style->borderRightWidth())) {
+ if (renderRadii && borderWillArcInnerEdge(border.radii().bottomRight(), border.radii().topRight(), style->borderBottomWidth(), style->borderTopWidth(), style->borderRightWidth())) {
graphicsContext->save();
- clipBorderSidePolygon(graphicsContext, borderRect, topLeft, topRight, bottomLeft, bottomRight, BSRight, upperRightBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
+ clipBorderSidePolygon(graphicsContext, border, BSRight, upperRightBorderStylesMatch, lowerRightBorderStylesMatch, style, includeLogicalLeftEdge, includeLogicalRightEdge);
float thickness = max(max(style->borderRightWidth(), style->borderTopWidth()), style->borderBottomWidth());
- drawBoxSideFromPath(graphicsContext, borderRect, roundedPath, style->borderRightWidth(), thickness, BSRight, style, rightColor, rightStyle);
+ drawBoxSideFromPath(graphicsContext, border.rect(), roundedPath, style->borderRightWidth(), thickness, BSRight, style, rightColor, rightStyle);
graphicsContext->restore();
} else {
bool ignoreTop = ((topColor == rightColor) && (topTransparent == rightTransparent)
@@ -1209,65 +1162,43 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
bool renderRight = rightStyle > BHIDDEN && !rightTransparent && (!horizontal || includeLogicalRightEdge);
bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent && (horizontal || includeLogicalRightEdge);
- bool renderRadii = false;
- IntSize topLeft, topRight, bottomLeft, bottomRight;
+ RoundedIntRect border(tx, ty, w, h);
if (style->hasBorderRadius()) {
- IntRect borderRect = IntRect(tx, ty, w, h);
-
- IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius;
- style->getBorderRadiiForRect(borderRect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
-
- if (includeLogicalLeftEdge) {
- topLeft = topLeftRadius;
- if (horizontal)
- bottomLeft = bottomLeftRadius;
- else
- topRight = topRightRadius;
- }
-
- if (includeLogicalRightEdge) {
- if (horizontal)
- topRight = topRightRadius;
- else
- bottomLeft = bottomLeftRadius;
- bottomRight = bottomRightRadius;
- }
-
- renderRadii = !topLeft.isZero() || !topRight.isZero() || !bottomLeft.isZero() || !bottomRight.isZero();
-
- if (renderRadii) {
- // Clip to the rounded rectangle.
+ border.includeLogicalEdges(style->getRoundedBorderFor(border.rect()).radii(),
+ horizontal, includeLogicalLeftEdge, includeLogicalRightEdge);
+ if (border.isRounded()) {
graphicsContext->save();
- graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
+ graphicsContext->addRoundedRectClip(border);
}
}
int firstAngleStart, secondAngleStart, firstAngleSpan, secondAngleSpan;
float thickness;
+ bool renderRadii = border.isRounded();
bool upperLeftBorderStylesMatch = renderLeft && (topStyle == leftStyle) && (topColor == leftColor);
bool upperRightBorderStylesMatch = renderRight && (topStyle == rightStyle) && (topColor == rightColor) && (topStyle != OUTSET) && (topStyle != RIDGE) && (topStyle != INSET) && (topStyle != GROOVE);
bool lowerLeftBorderStylesMatch = renderLeft && (bottomStyle == leftStyle) && (bottomColor == leftColor) && (bottomStyle != OUTSET) && (bottomStyle != RIDGE) && (bottomStyle != INSET) && (bottomStyle != GROOVE);
bool lowerRightBorderStylesMatch = renderRight && (bottomStyle == rightStyle) && (bottomColor == rightColor);
if (renderTop) {
- bool ignore_left = (renderRadii && topLeft.width() > 0) ||
- (topColor == leftColor && topTransparent == leftTransparent && topStyle >= OUTSET &&
- (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET));
-
- bool ignore_right = (renderRadii && topRight.width() > 0) ||
- (topColor == rightColor && topTransparent == rightTransparent && topStyle >= OUTSET &&
- (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET));
+ bool ignoreLeft = (renderRadii && border.radii().topLeft().width() > 0)
+ || (topColor == leftColor && topTransparent == leftTransparent && topStyle >= OUTSET
+ && (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET));
+
+ bool ignoreRight = (renderRadii && border.radii().topRight().width() > 0)
+ || (topColor == rightColor && topTransparent == rightTransparent && topStyle >= OUTSET
+ && (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET));
int x = tx;
int x2 = tx + w;
if (renderRadii) {
- x += topLeft.width();
- x2 -= topRight.width();
+ x += border.radii().topLeft().width();
+ x2 -= border.radii().topRight().width();
}
drawLineForBoxSide(graphicsContext, x, ty, x2, ty + style->borderTopWidth(), BSTop, topColor, topStyle,
- ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth());
+ ignoreLeft ? 0 : style->borderLeftWidth(), ignoreRight ? 0 : style->borderRightWidth());
if (renderRadii) {
int leftY = ty;
@@ -1277,15 +1208,15 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
// with the arc-drawing function.
thickness = style->borderTopWidth() * 2;
- if (topLeft.width()) {
+ if (border.radii().topLeft().width()) {
int leftX = tx;
// The inner clip clips inside the arc. This is especially important for 1px borders.
- bool applyLeftInnerClip = (style->borderLeftWidth() < topLeft.width())
- && (style->borderTopWidth() < topLeft.height())
+ bool applyLeftInnerClip = (style->borderLeftWidth() < border.radii().topLeft().width())
+ && (style->borderTopWidth() < border.radii().topLeft().height())
&& (topStyle != DOUBLE || style->borderTopWidth() > 6);
if (applyLeftInnerClip) {
graphicsContext->save();
- graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, topLeft.width() * 2, topLeft.height() * 2),
+ graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, border.radii().topLeft().width() * 2, border.radii().topLeft().height() * 2),
style->borderTopWidth());
}
@@ -1293,20 +1224,20 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
firstAngleSpan = upperLeftBorderStylesMatch ? 90 : 45;
// Draw upper left arc
- drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, topLeft, firstAngleStart, firstAngleSpan,
+ drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, border.radii().topLeft(), firstAngleStart, firstAngleSpan,
BSTop, topColor, topStyle, true);
if (applyLeftInnerClip)
graphicsContext->restore();
}
- if (topRight.width()) {
- int rightX = tx + w - topRight.width() * 2;
- bool applyRightInnerClip = (style->borderRightWidth() < topRight.width())
- && (style->borderTopWidth() < topRight.height())
+ if (border.radii().topRight().width()) {
+ int rightX = tx + w - border.radii().topRight().width() * 2;
+ bool applyRightInnerClip = (style->borderRightWidth() < border.radii().topRight().width())
+ && (style->borderTopWidth() < border.radii().topRight().height())
&& (topStyle != DOUBLE || style->borderTopWidth() > 6);
if (applyRightInnerClip) {
graphicsContext->save();
- graphicsContext->addInnerRoundedRectClip(IntRect(rightX, leftY, topRight.width() * 2, topRight.height() * 2),
+ graphicsContext->addInnerRoundedRectClip(IntRect(rightX, leftY, border.radii().topRight().width() * 2, border.radii().topRight().height() * 2),
style->borderTopWidth());
}
@@ -1319,7 +1250,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}
// Draw upper right arc
- drawArcForBoxSide(graphicsContext, rightX, leftY, thickness, topRight, secondAngleStart, secondAngleSpan,
+ drawArcForBoxSide(graphicsContext, rightX, leftY, thickness, border.radii().topRight(), secondAngleStart, secondAngleSpan,
BSTop, topColor, topStyle, false);
if (applyRightInnerClip)
graphicsContext->restore();
@@ -1328,36 +1259,36 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}
if (renderBottom) {
- bool ignore_left = (renderRadii && bottomLeft.width() > 0) ||
- (bottomColor == leftColor && bottomTransparent == leftTransparent && bottomStyle >= OUTSET &&
- (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET));
+ bool ignoreLeft = (renderRadii && border.radii().bottomLeft().width() > 0)
+ || (bottomColor == leftColor && bottomTransparent == leftTransparent && bottomStyle >= OUTSET
+ && (leftStyle == DOTTED || leftStyle == DASHED || leftStyle == SOLID || leftStyle == OUTSET));
- bool ignore_right = (renderRadii && bottomRight.width() > 0) ||
- (bottomColor == rightColor && bottomTransparent == rightTransparent && bottomStyle >= OUTSET &&
- (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET));
+ bool ignoreRight = (renderRadii && border.radii().bottomRight().width() > 0)
+ || (bottomColor == rightColor && bottomTransparent == rightTransparent && bottomStyle >= OUTSET
+ && (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET));
int x = tx;
int x2 = tx + w;
if (renderRadii) {
- x += bottomLeft.width();
- x2 -= bottomRight.width();
+ x += border.radii().bottomLeft().width();
+ x2 -= border.radii().bottomRight().width();
}
drawLineForBoxSide(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bottomColor, bottomStyle,
- ignore_left ? 0 : style->borderLeftWidth(), ignore_right ? 0 : style->borderRightWidth());
+ ignoreLeft ? 0 : style->borderLeftWidth(), ignoreRight ? 0 : style->borderRightWidth());
if (renderRadii) {
thickness = style->borderBottomWidth() * 2;
- if (bottomLeft.width()) {
+ if (border.radii().bottomLeft().width()) {
int leftX = tx;
- int leftY = ty + h - bottomLeft.height() * 2;
- bool applyLeftInnerClip = (style->borderLeftWidth() < bottomLeft.width())
- && (style->borderBottomWidth() < bottomLeft.height())
+ int leftY = ty + h - border.radii().bottomLeft().height() * 2;
+ bool applyLeftInnerClip = (style->borderLeftWidth() < border.radii().bottomLeft().width())
+ && (style->borderBottomWidth() < border.radii().bottomLeft().height())
&& (bottomStyle != DOUBLE || style->borderBottomWidth() > 6);
if (applyLeftInnerClip) {
graphicsContext->save();
- graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, bottomLeft.width() * 2, bottomLeft.height() * 2),
+ graphicsContext->addInnerRoundedRectClip(IntRect(leftX, leftY, border.radii().bottomLeft().width() * 2, border.radii().bottomLeft().height() * 2),
style->borderBottomWidth());
}
@@ -1370,21 +1301,21 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}
// Draw lower left arc
- drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, bottomLeft, firstAngleStart, firstAngleSpan,
+ drawArcForBoxSide(graphicsContext, leftX, leftY, thickness, border.radii().bottomLeft(), firstAngleStart, firstAngleSpan,
BSBottom, bottomColor, bottomStyle, true);
if (applyLeftInnerClip)
graphicsContext->restore();
}
- if (bottomRight.width()) {
- int rightY = ty + h - bottomRight.height() * 2;
- int rightX = tx + w - bottomRight.width() * 2;
- bool applyRightInnerClip = (style->borderRightWidth() < bottomRight.width())
- && (style->borderBottomWidth() < bottomRight.height())
+ if (border.radii().bottomRight().width()) {
+ int rightY = ty + h - border.radii().bottomRight().height() * 2;
+ int rightX = tx + w - border.radii().bottomRight().width() * 2;
+ bool applyRightInnerClip = (style->borderRightWidth() < border.radii().bottomRight().width())
+ && (style->borderBottomWidth() < border.radii().bottomRight().height())
&& (bottomStyle != DOUBLE || style->borderBottomWidth() > 6);
if (applyRightInnerClip) {
graphicsContext->save();
- graphicsContext->addInnerRoundedRectClip(IntRect(rightX, rightY, bottomRight.width() * 2, bottomRight.height() * 2),
+ graphicsContext->addInnerRoundedRectClip(IntRect(rightX, rightY, border.radii().bottomRight().width() * 2, border.radii().bottomRight().height() * 2),
style->borderBottomWidth());
}
@@ -1392,7 +1323,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
secondAngleSpan = lowerRightBorderStylesMatch ? 90 : 45;
// Draw lower right arc
- drawArcForBoxSide(graphicsContext, rightX, rightY, thickness, bottomRight, secondAngleStart, secondAngleSpan,
+ drawArcForBoxSide(graphicsContext, rightX, rightY, thickness, border.radii().bottomRight(), secondAngleStart, secondAngleSpan,
BSBottom, bottomColor, bottomStyle, false);
if (applyRightInnerClip)
graphicsContext->restore();
@@ -1401,36 +1332,36 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}
if (renderLeft) {
- bool ignore_top = (renderRadii && topLeft.height() > 0) ||
- (topColor == leftColor && topTransparent == leftTransparent && leftStyle >= OUTSET &&
- (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET));
+ bool ignoreTop = (renderRadii && border.radii().topLeft().height() > 0)
+ || (topColor == leftColor && topTransparent == leftTransparent && leftStyle >= OUTSET
+ && (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET));
- bool ignore_bottom = (renderRadii && bottomLeft.height() > 0) ||
- (bottomColor == leftColor && bottomTransparent == leftTransparent && leftStyle >= OUTSET &&
- (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET));
+ bool ignoreBottom = (renderRadii && border.radii().bottomLeft().height() > 0)
+ || (bottomColor == leftColor && bottomTransparent == leftTransparent && leftStyle >= OUTSET
+ && (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET));
int y = ty;
int y2 = ty + h;
if (renderRadii) {
- y += topLeft.height();
- y2 -= bottomLeft.height();
+ y += border.radii().topLeft().height();
+ y2 -= border.radii().bottomLeft().height();
}
drawLineForBoxSide(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, leftColor, leftStyle,
- ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth());
+ ignoreTop ? 0 : style->borderTopWidth(), ignoreBottom ? 0 : style->borderBottomWidth());
if (renderRadii && (!upperLeftBorderStylesMatch || !lowerLeftBorderStylesMatch)) {
int topX = tx;
thickness = style->borderLeftWidth() * 2;
- if (!upperLeftBorderStylesMatch && topLeft.width()) {
+ if (!upperLeftBorderStylesMatch && border.radii().topLeft().width()) {
int topY = ty;
- bool applyTopInnerClip = (style->borderLeftWidth() < topLeft.width())
- && (style->borderTopWidth() < topLeft.height())
+ bool applyTopInnerClip = (style->borderLeftWidth() < border.radii().topLeft().width())
+ && (style->borderTopWidth() < border.radii().topLeft().height())
&& (leftStyle != DOUBLE || style->borderLeftWidth() > 6);
if (applyTopInnerClip) {
graphicsContext->save();
- graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topLeft.width() * 2, topLeft.height() * 2),
+ graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, border.radii().topLeft().width() * 2, border.radii().topLeft().height() * 2),
style->borderLeftWidth());
}
@@ -1438,20 +1369,20 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
firstAngleSpan = 45;
// Draw top left arc
- drawArcForBoxSide(graphicsContext, topX, topY, thickness, topLeft, firstAngleStart, firstAngleSpan,
+ drawArcForBoxSide(graphicsContext, topX, topY, thickness, border.radii().topLeft(), firstAngleStart, firstAngleSpan,
BSLeft, leftColor, leftStyle, true);
if (applyTopInnerClip)
graphicsContext->restore();
}
- if (!lowerLeftBorderStylesMatch && bottomLeft.width()) {
- int bottomY = ty + h - bottomLeft.height() * 2;
- bool applyBottomInnerClip = (style->borderLeftWidth() < bottomLeft.width())
- && (style->borderBottomWidth() < bottomLeft.height())
+ if (!lowerLeftBorderStylesMatch && border.radii().bottomLeft().width()) {
+ int bottomY = ty + h - border.radii().bottomLeft().height() * 2;
+ bool applyBottomInnerClip = (style->borderLeftWidth() < border.radii().bottomLeft().width())
+ && (style->borderBottomWidth() < border.radii().bottomLeft().height())
&& (leftStyle != DOUBLE || style->borderLeftWidth() > 6);
if (applyBottomInnerClip) {
graphicsContext->save();
- graphicsContext->addInnerRoundedRectClip(IntRect(topX, bottomY, bottomLeft.width() * 2, bottomLeft.height() * 2),
+ graphicsContext->addInnerRoundedRectClip(IntRect(topX, bottomY, border.radii().bottomLeft().width() * 2, border.radii().bottomLeft().height() * 2),
style->borderLeftWidth());
}
@@ -1459,7 +1390,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
secondAngleSpan = 45;
// Draw bottom left arc
- drawArcForBoxSide(graphicsContext, topX, bottomY, thickness, bottomLeft, secondAngleStart, secondAngleSpan,
+ drawArcForBoxSide(graphicsContext, topX, bottomY, thickness, border.radii().bottomLeft(), secondAngleStart, secondAngleSpan,
BSLeft, leftColor, leftStyle, false);
if (applyBottomInnerClip)
graphicsContext->restore();
@@ -1468,38 +1399,38 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}
if (renderRight) {
- bool ignore_top = (renderRadii && topRight.height() > 0) ||
- ((topColor == rightColor) && (topTransparent == rightTransparent) &&
- (rightStyle >= DOTTED || rightStyle == INSET) &&
- (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET));
+ bool ignoreTop = (renderRadii && border.radii().topRight().height() > 0)
+ || ((topColor == rightColor) && (topTransparent == rightTransparent)
+ && (rightStyle >= DOTTED || rightStyle == INSET)
+ && (topStyle == DOTTED || topStyle == DASHED || topStyle == SOLID || topStyle == OUTSET));
- bool ignore_bottom = (renderRadii && bottomRight.height() > 0) ||
- ((bottomColor == rightColor) && (bottomTransparent == rightTransparent) &&
- (rightStyle >= DOTTED || rightStyle == INSET) &&
- (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET));
+ bool ignoreBottom = (renderRadii && border.radii().bottomRight().height() > 0)
+ || ((bottomColor == rightColor) && (bottomTransparent == rightTransparent)
+ && (rightStyle >= DOTTED || rightStyle == INSET)
+ && (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET));
int y = ty;
int y2 = ty + h;
if (renderRadii) {
- y += topRight.height();
- y2 -= bottomRight.height();
+ y += border.radii().topRight().height();
+ y2 -= border.radii().bottomRight().height();
}
drawLineForBoxSide(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rightColor, rightStyle,
- ignore_top ? 0 : style->borderTopWidth(), ignore_bottom ? 0 : style->borderBottomWidth());
+ ignoreTop ? 0 : style->borderTopWidth(), ignoreBottom ? 0 : style->borderBottomWidth());
if (renderRadii && (!upperRightBorderStylesMatch || !lowerRightBorderStylesMatch)) {
thickness = style->borderRightWidth() * 2;
- if (!upperRightBorderStylesMatch && topRight.width()) {
- int topX = tx + w - topRight.width() * 2;
+ if (!upperRightBorderStylesMatch && border.radii().topRight().width()) {
+ int topX = tx + w - border.radii().topRight().width() * 2;
int topY = ty;
- bool applyTopInnerClip = (style->borderRightWidth() < topRight.width())
- && (style->borderTopWidth() < topRight.height())
+ bool applyTopInnerClip = (style->borderRightWidth() < border.radii().topRight().width())
+ && (style->borderTopWidth() < border.radii().topRight().height())
&& (rightStyle != DOUBLE || style->borderRightWidth() > 6);
if (applyTopInnerClip) {
graphicsContext->save();
- graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, topRight.width() * 2, topRight.height() * 2),
+ graphicsContext->addInnerRoundedRectClip(IntRect(topX, topY, border.radii().topRight().width() * 2, border.radii().topRight().height() * 2),
style->borderRightWidth());
}
@@ -1507,21 +1438,21 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
firstAngleSpan = 45;
// Draw top right arc
- drawArcForBoxSide(graphicsContext, topX, topY, thickness, topRight, firstAngleStart, firstAngleSpan,
+ drawArcForBoxSide(graphicsContext, topX, topY, thickness, border.radii().topRight(), firstAngleStart, firstAngleSpan,
BSRight, rightColor, rightStyle, true);
if (applyTopInnerClip)
graphicsContext->restore();
}
- if (!lowerRightBorderStylesMatch && bottomRight.width()) {
- int bottomX = tx + w - bottomRight.width() * 2;
- int bottomY = ty + h - bottomRight.height() * 2;
- bool applyBottomInnerClip = (style->borderRightWidth() < bottomRight.width())
- && (style->borderBottomWidth() < bottomRight.height())
+ if (!lowerRightBorderStylesMatch && border.radii().bottomRight().width()) {
+ int bottomX = tx + w - border.radii().bottomRight().width() * 2;
+ int bottomY = ty + h - border.radii().bottomRight().height() * 2;
+ bool applyBottomInnerClip = (style->borderRightWidth() < border.radii().bottomRight().width())
+ && (style->borderBottomWidth() < border.radii().bottomRight().height())
&& (rightStyle != DOUBLE || style->borderRightWidth() > 6);
if (applyBottomInnerClip) {
graphicsContext->save();
- graphicsContext->addInnerRoundedRectClip(IntRect(bottomX, bottomY, bottomRight.width() * 2, bottomRight.height() * 2),
+ graphicsContext->addInnerRoundedRectClip(IntRect(bottomX, bottomY, border.radii().bottomRight().width() * 2, border.radii().bottomRight().height() * 2),
style->borderRightWidth());
}
@@ -1529,7 +1460,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
secondAngleSpan = 45;
// Draw bottom right arc
- drawArcForBoxSide(graphicsContext, bottomX, bottomY, thickness, bottomRight, secondAngleStart, secondAngleSpan,
+ drawArcForBoxSide(graphicsContext, bottomX, bottomY, thickness, border.radii().bottomRight(), secondAngleStart, secondAngleSpan,
BSRight, rightColor, rightStyle, false);
if (applyBottomInnerClip)
graphicsContext->restore();
@@ -1542,15 +1473,15 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}
#endif
-void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContext, const IntRect& box, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight,
+void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContext, const RoundedIntRect& border,
const BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle* style,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
FloatPoint quad[4];
- int tx = box.x();
- int ty = box.y();
- int w = box.width();
- int h = box.height();
+ int tx = border.rect().x();
+ int ty = border.rect().y();
+ int w = border.rect().width();
+ int h = border.rect().height();
bool horizontal = style->isHorizontalWritingMode();
int leftWidth = (!horizontal || includeLogicalLeftEdge) ? style->borderLeftWidth() : 0;
@@ -1563,26 +1494,26 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContex
switch (side) {
case BSTop:
quad[0] = FloatPoint(tx, ty);
- quad[1] = FloatPoint(tx + max(topLeft.width(), leftWidth), ty + max(topLeft.height(), topWidth));
- quad[2] = FloatPoint(tx + w - max(topRight.width(), rightWidth), ty + max(topRight.height(), topWidth));
+ quad[1] = FloatPoint(tx + max(border.radii().topLeft().width(), leftWidth), ty + max(border.radii().topLeft().height(), topWidth));
+ quad[2] = FloatPoint(tx + w - max(border.radii().topRight().width(), rightWidth), ty + max(border.radii().topRight().height(), topWidth));
quad[3] = FloatPoint(tx + w, ty);
break;
case BSLeft:
quad[0] = FloatPoint(tx, ty);
- quad[1] = FloatPoint(tx + max(topLeft.width(), leftWidth), ty + max(topLeft.height(), topWidth));
- quad[2] = FloatPoint(tx + max(bottomLeft.width(), leftWidth), ty + h - max(bottomLeft.height(), bottomWidth));
+ quad[1] = FloatPoint(tx + max(border.radii().topLeft().width(), leftWidth), ty + max(border.radii().topLeft().height(), topWidth));
+ quad[2] = FloatPoint(tx + max(border.radii().bottomLeft().width(), leftWidth), ty + h - max(border.radii().bottomLeft().height(), bottomWidth));
quad[3] = FloatPoint(tx, ty + h);
break;
case BSBottom:
quad[0] = FloatPoint(tx, ty + h);
- quad[1] = FloatPoint(tx + max(bottomLeft.width(), leftWidth), ty + h - max(bottomLeft.height(), bottomWidth));
- quad[2] = FloatPoint(tx + w - max(bottomRight.width(), rightWidth), ty + h - max(bottomRight.height(), bottomWidth));
+ quad[1] = FloatPoint(tx + max(border.radii().bottomLeft().width(), leftWidth), ty + h - max(border.radii().bottomLeft().height(), bottomWidth));
+ quad[2] = FloatPoint(tx + w - max(border.radii().bottomRight().width(), rightWidth), ty + h - max(border.radii().bottomRight().height(), bottomWidth));
quad[3] = FloatPoint(tx + w, ty + h);
break;
case BSRight:
quad[0] = FloatPoint(tx + w, ty);
- quad[1] = FloatPoint(tx + w - max(topRight.width(), rightWidth), ty + max(topRight.height(), topWidth));
- quad[2] = FloatPoint(tx + w - max(bottomRight.width(), rightWidth), ty + h - max(bottomRight.height(), bottomWidth));
+ quad[1] = FloatPoint(tx + w - max(border.radii().topRight().width(), rightWidth), ty + max(border.radii().topRight().height(), topWidth));
+ quad[2] = FloatPoint(tx + w - max(border.radii().bottomRight().width(), rightWidth), ty + h - max(border.radii().bottomRight().height(), bottomWidth));
quad[3] = FloatPoint(tx + w, ty + h);
break;
default:
@@ -1613,18 +1544,6 @@ void RenderBoxModelObject::clipBorderSidePolygon(GraphicsContext* graphicsContex
graphicsContext->clipConvexPolygon(4, secondQuad, !secondEdgeMatches);
}
-static inline void uniformlyExpandBorderRadii(int delta, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight)
-{
- topLeft.expand(delta, delta);
- topLeft.clampNegativeToZero();
- topRight.expand(delta, delta);
- topRight.clampNegativeToZero();
- bottomLeft.expand(delta, delta);
- bottomLeft.clampNegativeToZero();
- bottomRight.expand(delta, delta);
- bottomRight.clampNegativeToZero();
-}
-
void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int ty, int w, int h, const RenderStyle* s, ShadowStyle shadowStyle, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
// FIXME: Deal with border-image. Would be great to use border-image as a mask.
@@ -1632,61 +1551,19 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
if (context->paintingDisabled())
return;
- IntRect rect(tx, ty, w, h);
- IntSize topLeft;
- IntSize topRight;
- IntSize bottomLeft;
- IntSize bottomRight;
-
+ RoundedIntRect border(tx, ty, w, h);
bool hasBorderRadius = s->hasBorderRadius();
bool isHorizontal = s->isHorizontalWritingMode();
if (hasBorderRadius && (includeLogicalLeftEdge || includeLogicalRightEdge)) {
- IntSize topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius;
- s->getBorderRadiiForRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
-
- if (includeLogicalLeftEdge) {
- if (shadowStyle == Inset) {
- topLeftRadius.expand(-borderLeft(), -borderTop());
- topLeftRadius.clampNegativeToZero();
- if (isHorizontal) {
- bottomLeftRadius.expand(-borderLeft(), -borderBottom());
- bottomLeftRadius.clampNegativeToZero();
- } else {
- topRightRadius.expand(-borderRight(), -borderTop());
- topRightRadius.clampNegativeToZero();
- }
- }
- topLeft = topLeftRadius;
- if (isHorizontal)
- bottomLeft = bottomLeftRadius;
- else
- topRight = topRightRadius;
- }
- if (includeLogicalRightEdge) {
- if (shadowStyle == Inset) {
- if (isHorizontal) {
- topRightRadius.expand(-borderRight(), -borderTop());
- topRightRadius.clampNegativeToZero();
- } else {
- bottomLeftRadius.expand(-borderLeft(), -borderBottom());
- bottomLeftRadius.clampNegativeToZero();
- }
- bottomRightRadius.expand(-borderRight(), -borderBottom());
- bottomRightRadius.clampNegativeToZero();
- }
- if (isHorizontal)
- topRight = topRightRadius;
- else
- bottomLeft = bottomLeftRadius;
- bottomRight = bottomRightRadius;
- }
- }
-
- if (shadowStyle == Inset) {
- rect.move(includeLogicalLeftEdge || !isHorizontal ? borderLeft() : 0, includeLogicalLeftEdge || isHorizontal ? borderTop() : 0);
- rect.setWidth(rect.width() - ((includeLogicalLeftEdge || !isHorizontal) ? borderLeft() : 0) - ((includeLogicalRightEdge || !isHorizontal) ? borderRight() : 0));
- rect.setHeight(rect.height() - ((includeLogicalLeftEdge || isHorizontal) ? borderTop() : 0) - ((includeLogicalRightEdge || isHorizontal) ? borderBottom() : 0));
+ border = (shadowStyle == Inset) ? s->getRoundedInnerBorderWithBorderWidths(border.rect(), borderTop(), borderBottom(), borderLeft(), borderRight()) : s->getRoundedBorderFor(border.rect());
+ border.includeLogicalEdges(border.radii(), isHorizontal, includeLogicalLeftEdge, includeLogicalRightEdge);
}
+
+ if (shadowStyle == Inset)
+ border.setRect(IntRect(border.rect().x() + (includeLogicalLeftEdge || !isHorizontal ? borderLeft() : 0),
+ border.rect().y() + (includeLogicalLeftEdge || isHorizontal ? borderTop() : 0),
+ border.rect().width() - ((includeLogicalLeftEdge || !isHorizontal) ? borderLeft() : 0) - ((includeLogicalRightEdge || !isHorizontal) ? borderRight() : 0),
+ border.rect().height() - ((includeLogicalLeftEdge || isHorizontal) ? borderTop() : 0) - ((includeLogicalRightEdge || isHorizontal) ? borderBottom() : 0)));
bool hasOpaqueBackground = s->visitedDependentColor(CSSPropertyBackgroundColor).isValid() && s->visitedDependentColor(CSSPropertyBackgroundColor).alpha() == 255;
for (const ShadowData* shadow = s->boxShadow(); shadow; shadow = shadow->next()) {
@@ -1699,12 +1576,12 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
const Color& shadowColor = shadow->color();
if (shadow->style() == Normal) {
- IntRect fillRect(rect);
+ RoundedIntRect fillRect = border;
fillRect.inflate(shadowSpread);
if (fillRect.isEmpty())
continue;
- IntRect shadowRect(rect);
+ IntRect shadowRect(border.rect());
shadowRect.inflate(shadowBlur + shadowSpread);
shadowRect.move(shadowOffset);
@@ -1719,32 +1596,23 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
if (hasBorderRadius) {
- IntRect rectToClipOut = rect;
- IntSize topLeftToClipOut = topLeft;
- IntSize topRightToClipOut = topRight;
- IntSize bottomLeftToClipOut = bottomLeft;
- IntSize bottomRightToClipOut = bottomRight;
-
- IntSize topLeftToFill = topLeft;
- IntSize topRightToFill = topRight;
- IntSize bottomLeftToFill = bottomLeft;
- IntSize bottomRightToFill = bottomRight;
- if (shadowSpread < 0)
- uniformlyExpandBorderRadii(shadowSpread, topLeftToFill, topRightToFill, bottomLeftToFill, bottomRightToFill);
+ RoundedIntRect rectToClipOut = border;
// If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
// when painting the shadow. On the other hand, it introduces subpixel gaps along the
// corners. Those are avoided by insetting the clipping path by one pixel.
if (hasOpaqueBackground) {
- rectToClipOut.inflate(-1);
- uniformlyExpandBorderRadii(-1, topLeftToClipOut, topRightToClipOut, bottomLeftToClipOut, bottomRightToClipOut);
+ rectToClipOut.inflateWithRadii(-1);
}
if (!rectToClipOut.isEmpty())
- context->clipOutRoundedRect(rectToClipOut, topLeftToClipOut, topRightToClipOut, bottomLeftToClipOut, bottomRightToClipOut);
- context->fillRoundedRect(fillRect, topLeftToFill, topRightToFill, bottomLeftToFill, bottomRightToFill, Color::black, s->colorSpace());
+ context->clipOutRoundedRect(rectToClipOut);
+
+ if (shadowSpread < 0)
+ fillRect.expandRadii(shadowSpread);
+ context->fillRoundedRect(fillRect, Color::black, s->colorSpace());
} else {
- IntRect rectToClipOut = rect;
+ IntRect rectToClipOut = border.rect();
// If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
// when painting the shadow. On the other hand, it introduces subpixel gaps along the
@@ -1759,20 +1627,20 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
if (!rectToClipOut.isEmpty())
context->clipOut(rectToClipOut);
- context->fillRect(fillRect, Color::black, s->colorSpace());
+ context->fillRect(fillRect.rect(), Color::black, s->colorSpace());
}
context->restore();
} else {
// Inset shadow.
- IntRect holeRect(rect);
+ IntRect holeRect(border.rect());
holeRect.inflate(-shadowSpread);
if (holeRect.isEmpty()) {
if (hasBorderRadius)
- context->fillRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight, shadowColor, s->colorSpace());
+ context->fillRoundedRect(border, shadowColor, s->colorSpace());
else
- context->fillRect(rect, shadowColor, s->colorSpace());
+ context->fillRect(border.rect(), shadowColor, s->colorSpace());
continue;
}
@@ -1794,7 +1662,7 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
Color fillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), 255);
- IntRect outerRect(rect);
+ IntRect outerRect(border.rect());
outerRect.inflateX(w - 2 * shadowSpread);
outerRect.inflateY(h - 2 * shadowSpread);
@@ -1802,11 +1670,11 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
Path path;
if (hasBorderRadius) {
- path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
+ path.addRoundedRect(border.rect(), border.radii().topLeft(), border.radii().topRight(), border.radii().bottomLeft(), border.radii().bottomRight());
context->clip(path);
path.clear();
} else
- context->clip(rect);
+ context->clip(border.rect());
IntSize extraOffset(2 * w + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
context->translate(extraOffset.width(), extraOffset.height());
@@ -1816,8 +1684,8 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int
if (hasBorderRadius) {
if (shadowSpread > 0)
- uniformlyExpandBorderRadii(-shadowSpread, topLeft, topRight, bottomLeft, bottomRight);
- path.addRoundedRect(holeRect, topLeft, topRight, bottomLeft, bottomRight);
+ border.shrinkRadii(shadowSpread);
+ path.addRoundedRect(holeRect, border.radii().topLeft(), border.radii().topRight(), border.radii().bottomLeft(), border.radii().bottomRight());
} else
path.addRect(holeRect);
diff --git a/Source/WebCore/rendering/RenderBoxModelObject.h b/Source/WebCore/rendering/RenderBoxModelObject.h
index 8f9f465..f6bcb94 100644
--- a/Source/WebCore/rendering/RenderBoxModelObject.h
+++ b/Source/WebCore/rendering/RenderBoxModelObject.h
@@ -134,8 +134,8 @@ private:
IntSize calculateFillTileSize(const FillLayer*, IntSize scaledSize) const;
- void clipBorderSidePolygon(GraphicsContext*, const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft,
- const IntSize& bottomRight, const BoxSide side, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle* style,
+ void clipBorderSidePolygon(GraphicsContext*, const RoundedIntRect& border,
+ const BoxSide, bool firstEdgeMatches, bool secondEdgeMatches, const RenderStyle*,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
friend class RenderView;
diff --git a/Source/WebCore/rendering/RenderObject.cpp b/Source/WebCore/rendering/RenderObject.cpp
index 97ac5c3..5b39e0d 100644
--- a/Source/WebCore/rendering/RenderObject.cpp
+++ b/Source/WebCore/rendering/RenderObject.cpp
@@ -979,36 +979,24 @@ void RenderObject::drawBoxSideFromPath(GraphicsContext* graphicsContext, IntRect
innerBorderLeftWidth += 1;
// Get the inner border rects for both the outer border line and the inner border line
- IntRect outerBorderInnerRect = borderInnerRect(borderRect, outerBorderTopWidth, outerBorderBottomWidth,
- outerBorderLeftWidth, outerBorderRightWidth);
- IntRect innerBorderInnerRect = borderInnerRect(borderRect, innerBorderTopWidth, innerBorderBottomWidth,
- innerBorderLeftWidth, innerBorderRightWidth);
-
- // Get the inner radii for the outer border line
- IntSize outerBorderTopLeftInnerRadius, outerBorderTopRightInnerRadius, outerBorderBottomLeftInnerRadius,
- outerBorderBottomRightInnerRadius;
- style->getInnerBorderRadiiForRectWithBorderWidths(outerBorderInnerRect, outerBorderTopWidth, outerBorderBottomWidth,
- outerBorderLeftWidth, outerBorderRightWidth, outerBorderTopLeftInnerRadius, outerBorderTopRightInnerRadius,
- outerBorderBottomLeftInnerRadius, outerBorderBottomRightInnerRadius);
-
- // Get the inner radii for the inner border line
- IntSize innerBorderTopLeftInnerRadius, innerBorderTopRightInnerRadius, innerBorderBottomLeftInnerRadius,
- innerBorderBottomRightInnerRadius;
- style->getInnerBorderRadiiForRectWithBorderWidths(innerBorderInnerRect, innerBorderTopWidth, innerBorderBottomWidth,
- innerBorderLeftWidth, innerBorderRightWidth, innerBorderTopLeftInnerRadius, innerBorderTopRightInnerRadius,
- innerBorderBottomLeftInnerRadius, innerBorderBottomRightInnerRadius);
// Draw inner border line
graphicsContext->save();
- graphicsContext->addRoundedRectClip(innerBorderInnerRect, innerBorderTopLeftInnerRadius,
- innerBorderTopRightInnerRadius, innerBorderBottomLeftInnerRadius, innerBorderBottomRightInnerRadius);
+ IntRect innerBorderInnerRect = borderInnerRect(borderRect, innerBorderTopWidth, innerBorderBottomWidth,
+ innerBorderLeftWidth, innerBorderRightWidth);
+ RoundedIntRect innerClip = style->getRoundedInnerBorderWithBorderWidths(innerBorderInnerRect, innerBorderTopWidth, innerBorderBottomWidth,
+ innerBorderLeftWidth, innerBorderRightWidth);
+ graphicsContext->addRoundedRectClip(innerClip);
drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, SOLID);
graphicsContext->restore();
// Draw outer border line
graphicsContext->save();
- graphicsContext->clipOutRoundedRect(outerBorderInnerRect, outerBorderTopLeftInnerRadius,
- outerBorderTopRightInnerRadius, outerBorderBottomLeftInnerRadius, outerBorderBottomRightInnerRadius);
+ IntRect outerBorderInnerRect = borderInnerRect(borderRect, outerBorderTopWidth, outerBorderBottomWidth,
+ outerBorderLeftWidth, outerBorderRightWidth);
+ RoundedIntRect outerClip = style->getRoundedInnerBorderWithBorderWidths(outerBorderInnerRect, outerBorderTopWidth, outerBorderBottomWidth,
+ outerBorderLeftWidth, outerBorderRightWidth);
+ graphicsContext->clipOutRoundedRect(outerClip);
drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, SOLID);
graphicsContext->restore();
@@ -1030,18 +1018,14 @@ void RenderObject::drawBoxSideFromPath(GraphicsContext* graphicsContext, IntRect
IntRect halfBorderRect = borderInnerRect(borderRect, style->borderLeftWidth() / 2, style->borderBottomWidth() / 2,
style->borderLeftWidth() / 2, style->borderRightWidth() / 2);
- IntSize topLeftHalfRadius, topRightHalfRadius, bottomLeftHalfRadius, bottomRightHalfRadius;
- style->getInnerBorderRadiiForRectWithBorderWidths(halfBorderRect, style->borderLeftWidth() / 2,
- style->borderBottomWidth() / 2, style->borderLeftWidth() / 2, style->borderRightWidth() / 2,
- topLeftHalfRadius, topRightHalfRadius, bottomLeftHalfRadius, bottomRightHalfRadius);
-
// Paint full border
drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, s1);
// Paint inner only
graphicsContext->save();
- graphicsContext->addRoundedRectClip(halfBorderRect, topLeftHalfRadius, topRightHalfRadius,
- bottomLeftHalfRadius, bottomRightHalfRadius);
+ RoundedIntRect clipRect = style->getRoundedInnerBorderWithBorderWidths(halfBorderRect, style->borderLeftWidth() / 2, style->borderBottomWidth() / 2,
+ style->borderLeftWidth() / 2, style->borderRightWidth() / 2);
+ graphicsContext->addRoundedRectClip(clipRect);
drawBoxSideFromPath(graphicsContext, borderRect, borderPath, thickness, drawThickness, s, style, c, s2);
graphicsContext->restore();
diff --git a/Source/WebCore/rendering/RenderReplaced.cpp b/Source/WebCore/rendering/RenderReplaced.cpp
index 974a8d0..0d72f95 100644
--- a/Source/WebCore/rendering/RenderReplaced.cpp
+++ b/Source/WebCore/rendering/RenderReplaced.cpp
@@ -135,11 +135,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
else {
// Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
paintInfo.context->save();
-
- IntSize topLeft, topRight, bottomLeft, bottomRight;
- style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
-
- paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
+ paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(borderRect));
}
}
diff --git a/Source/WebCore/rendering/RenderThemeChromiumWin.cpp b/Source/WebCore/rendering/RenderThemeChromiumWin.cpp
index 5b41ea2..572aa2f 100644
--- a/Source/WebCore/rendering/RenderThemeChromiumWin.cpp
+++ b/Source/WebCore/rendering/RenderThemeChromiumWin.cpp
@@ -676,9 +676,7 @@ bool RenderThemeChromiumWin::paintTextFieldInternal(RenderObject* o,
// background (themed or filled) appropriately.
// FIXME: make sure we do the right thing if css background-clip is set.
i.context->save();
- IntSize topLeft, topRight, bottomLeft, bottomRight;
- o->style()->getBorderRadiiForRect(r, topLeft, topRight, bottomLeft, bottomRight);
- i.context->addRoundedRectClip(r, topLeft, topRight, bottomLeft, bottomRight);
+ i.context->addRoundedRectClip(o->style()->getRoundedBorderFor(r));
}
{
const ThemeData& themeData = getThemeData(o);
diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm
index 0764093..605e958 100644
--- a/Source/WebCore/rendering/RenderThemeMac.mm
+++ b/Source/WebCore/rendering/RenderThemeMac.mm
@@ -1033,14 +1033,8 @@ void RenderThemeMac::paintMenuListButtonGradients(RenderObject* o, const PaintIn
paintInfo.context->save();
- IntSize topLeftRadius;
- IntSize topRightRadius;
- IntSize bottomLeftRadius;
- IntSize bottomRightRadius;
-
- o->style()->getBorderRadiiForRect(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
-
- int radius = topLeftRadius.width();
+ RoundedIntRect border = o->style()->getRoundedBorderFor(r);
+ int radius = border.radii().topLeft().width();
CGColorSpaceRef cspace = deviceRGBColorSpaceRef();
@@ -1063,27 +1057,27 @@ void RenderThemeMac::paintMenuListButtonGradients(RenderObject* o, const PaintIn
RetainPtr<CGShadingRef> rightShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.right(), r.y()), CGPointMake(r.right() - radius, r.y()), mainFunction.get(), false, false));
paintInfo.context->save();
CGContextClipToRect(context, r);
- paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+ paintInfo.context->addRoundedRectClip(border);
CGContextDrawShading(context, mainShading.get());
paintInfo.context->restore();
paintInfo.context->save();
CGContextClipToRect(context, topGradient);
- paintInfo.context->addRoundedRectClip(enclosingIntRect(topGradient), topLeftRadius, topRightRadius, IntSize(), IntSize());
+ paintInfo.context->addRoundedRectClip(RoundedIntRect(enclosingIntRect(topGradient), border.radii().topLeft(), border.radii().topRight(), IntSize(), IntSize()));
CGContextDrawShading(context, topShading.get());
paintInfo.context->restore();
if (!bottomGradient.isEmpty()) {
paintInfo.context->save();
CGContextClipToRect(context, bottomGradient);
- paintInfo.context->addRoundedRectClip(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bottomLeftRadius, bottomRightRadius);
+ paintInfo.context->addRoundedRectClip(RoundedIntRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), border.radii().bottomLeft(), border.radii().bottomRight()));
CGContextDrawShading(context, bottomShading.get());
paintInfo.context->restore();
}
paintInfo.context->save();
CGContextClipToRect(context, r);
- paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+ paintInfo.context->addRoundedRectClip(border);
CGContextDrawShading(context, leftShading.get());
CGContextDrawShading(context, rightShading.get());
paintInfo.context->restore();
@@ -1304,9 +1298,7 @@ bool RenderThemeMac::paintSliderTrack(RenderObject* o, const PaintInfo& paintInf
mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.x(), bounds.y()), CGPointMake(bounds.x(), bounds.bottom()), mainFunction.get(), false, false));
IntSize radius(trackRadius, trackRadius);
- paintInfo.context->addRoundedRectClip(bounds,
- radius, radius,
- radius, radius);
+ paintInfo.context->addRoundedRectClip(RoundedIntRect(bounds, radius, radius, radius, radius));
CGContextDrawShading(context, mainShading.get());
paintInfo.context->restore();
diff --git a/Source/WebCore/rendering/RenderThemeSafari.cpp b/Source/WebCore/rendering/RenderThemeSafari.cpp
index 3c1dedc..47f627e 100644
--- a/Source/WebCore/rendering/RenderThemeSafari.cpp
+++ b/Source/WebCore/rendering/RenderThemeSafari.cpp
@@ -752,14 +752,8 @@ void RenderThemeSafari::paintMenuListButtonGradients(RenderObject* o, const Pain
paintInfo.context->save();
- IntSize topLeftRadius;
- IntSize topRightRadius;
- IntSize bottomLeftRadius;
- IntSize bottomRightRadius;
-
- o->style()->getBorderRadiiForRect(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
-
- int radius = topLeftRadius.width();
+ RoundedIntRect bound = o->style()->getRoundedBorderFor(r);
+ int radius = bound.radii().topLeft().width();
CGColorSpaceRef cspace = deviceRGBColorSpaceRef();
@@ -781,28 +775,28 @@ void RenderThemeSafari::paintMenuListButtonGradients(RenderObject* o, const Pain
RetainPtr<CGShadingRef> rightShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.right(), r.y()), CGPointMake(r.right() - radius, r.y()), mainFunction.get(), false, false));
paintInfo.context->save();
- CGContextClipToRect(context, r);
- paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+ CGContextClipToRect(context, bound.rect());
+ paintInfo.context->addRoundedRectClip(bound);
CGContextDrawShading(context, mainShading.get());
paintInfo.context->restore();
paintInfo.context->save();
CGContextClipToRect(context, topGradient);
- paintInfo.context->addRoundedRectClip(enclosingIntRect(topGradient), topLeftRadius, topRightRadius, IntSize(), IntSize());
+ paintInfo.context->addRoundedRectClip(RoundedIntRect(enclosingIntRect(topGradient), bound.radii().topLeft(), bound.radii().topRight(), IntSize(), IntSize()));
CGContextDrawShading(context, topShading.get());
paintInfo.context->restore();
if (!bottomGradient.isEmpty()) {
paintInfo.context->save();
CGContextClipToRect(context, bottomGradient);
- paintInfo.context->addRoundedRectClip(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bottomLeftRadius, bottomRightRadius);
+ paintInfo.context->addRoundedRectClip(RoundedIntRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bound.radii().bottomLeft(), bound.radii().bottomRight()));
CGContextDrawShading(context, bottomShading.get());
paintInfo.context->restore();
}
paintInfo.context->save();
- CGContextClipToRect(context, r);
- paintInfo.context->addRoundedRectClip(r, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+ CGContextClipToRect(context, bound.rect());
+ paintInfo.context->addRoundedRectClip(bound);
CGContextDrawShading(context, leftShading.get());
CGContextDrawShading(context, rightShading.get());
paintInfo.context->restore();
@@ -958,34 +952,35 @@ const int trackRadius = 2;
bool RenderThemeSafari::paintSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
- IntRect bounds = r;
-
- if (o->style()->appearance() == SliderHorizontalPart) {
- bounds.setHeight(trackWidth);
- bounds.setY(r.y() + r.height() / 2 - trackWidth / 2);
- } else if (o->style()->appearance() == SliderVerticalPart) {
- bounds.setWidth(trackWidth);
- bounds.setX(r.x() + r.width() / 2 - trackWidth / 2);
- }
+ IntSize radius(trackRadius, trackRadius);
+ RoundedIntRect bounds(r, radius, radius, radius, radius);
+
+ if (o->style()->appearance() == SliderHorizontalPart)
+ bounds.setRect(IntRect(r.x(),
+ r.y() + r.height() / 2 - trackWidth / 2,
+ r.width(),
+ trackWidth));
+ else if (o->style()->appearance() == SliderVerticalPart)
+ bounds.setRect(IntRect(r.x() + r.width() / 2 - trackWidth / 2,
+ r.y(),
+ trackWidth,
+ r.height()));
CGContextRef context = paintInfo.context->platformContext();
CGColorSpaceRef cspace = deviceRGBColorSpaceRef();
paintInfo.context->save();
- CGContextClipToRect(context, bounds);
+ CGContextClipToRect(context, bounds.rect());
struct CGFunctionCallbacks mainCallbacks = { 0, TrackGradientInterpolate, NULL };
RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &mainCallbacks));
RetainPtr<CGShadingRef> mainShading;
if (o->style()->appearance() == SliderVerticalPart)
- mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.x(), bounds.bottom()), CGPointMake(bounds.right(), bounds.bottom()), mainFunction.get(), false, false));
+ mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.rect().x(), bounds.rect().bottom()), CGPointMake(bounds.rect().right(), bounds.rect().bottom()), mainFunction.get(), false, false));
else
- mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.x(), bounds.y()), CGPointMake(bounds.x(), bounds.bottom()), mainFunction.get(), false, false));
+ mainShading.adoptCF(CGShadingCreateAxial(cspace, CGPointMake(bounds.rect().x(), bounds.rect().y()), CGPointMake(bounds.rect().x(), bounds.rect().bottom()), mainFunction.get(), false, false));
- IntSize radius(trackRadius, trackRadius);
- paintInfo.context->addRoundedRectClip(bounds,
- radius, radius,
- radius, radius);
+ paintInfo.context->addRoundedRectClip(bounds);
CGContextDrawShading(context, mainShading.get());
paintInfo.context->restore();
diff --git a/Source/WebCore/rendering/RenderThemeWinCE.cpp b/Source/WebCore/rendering/RenderThemeWinCE.cpp
index 2c55f31..d4bff96 100644
--- a/Source/WebCore/rendering/RenderThemeWinCE.cpp
+++ b/Source/WebCore/rendering/RenderThemeWinCE.cpp
@@ -378,7 +378,7 @@ bool RenderThemeWinCE::paintSearchFieldCancelButton(RenderObject* o, const Paint
int y = r.y() + (r.height() - cancelSize.height()) / 2 + 1;
IntRect cancelBounds(IntPoint(x, y), cancelSize);
paintInfo.context->save();
- paintInfo.context->addRoundedRectClip(cancelBounds, cancelRadius, cancelRadius, cancelRadius, cancelRadius);
+ paintInfo.context->addRoundedRectClip(RoundedIntRect(cancelBounds, cancelRadius, cancelRadius, cancelRadius, cancelRadius));
paintInfo.context->fillRect(cancelBounds, buttonColor, ColorSpaceDeviceRGB);
// Draw the 'x'
diff --git a/Source/WebCore/rendering/RenderWidget.cpp b/Source/WebCore/rendering/RenderWidget.cpp
index 22283a0..d4b8ba6 100644
--- a/Source/WebCore/rendering/RenderWidget.cpp
+++ b/Source/WebCore/rendering/RenderWidget.cpp
@@ -275,11 +275,7 @@ void RenderWidget::paint(PaintInfo& paintInfo, int tx, int ty)
// Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
paintInfo.context->save();
-
- IntSize topLeft, topRight, bottomLeft, bottomRight;
- style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);
-
- paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
+ paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(borderRect));
}
if (m_widget) {
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/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 1d7aada..1ef981a 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"
@@ -846,13 +848,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) }
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list