Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
18761876 platform/graphics/FloatPolygon.cpp
18771877 platform/graphics/FloatQuad.cpp
18781878 platform/graphics/FloatRect.cpp
 1879 platform/graphics/FloatRoundedRect.cpp
18791880 platform/graphics/FloatSize.cpp
18801881 platform/graphics/Font.cpp
18811882 platform/graphics/FontCache.cpp

@@set(WebCore_SOURCES
22272228 rendering/mathml/RenderMathMLSquareRoot.cpp
22282229 rendering/mathml/RenderMathMLUnderOver.cpp
22292230
 2231 rendering/shapes/BoxShape.cpp
22302232 rendering/shapes/PolygonShape.cpp
22312233 rendering/shapes/RasterShape.cpp
22322234 rendering/shapes/RectangleShape.cpp

Source/WebCore/ChangeLog

 12013-11-19 Hans Muller <hmuller@adobe.com>
 2
 3 [CSS Shapes] Add BoxShape and FloatRoundingRect classes
 4 https://bugs.webkit.org/show_bug.cgi?id=124368
 5
 6 Added the BoxShape class. It's now used to represent shape-outside box
 7 values: [margin/border/padding/content]-box. BoxShape depends on a new
 8 FloatRoundedRect class, which is a float analog of the existing (int)
 9 RoundedRect class. The FloatRoundedRect class contains the same basic
 10 methods and accessors as BorderRect and adds a set of four methods,
 11 for example topLeftCorner(), that return a FloatRect that represents the
 12 bounds of one elliptical corner. I also added a method, xInterceptsAtY()
 13 that returns two X coordinates of the intersection between a horizontal
 14 line and the rounded rectangle.
 15
 16 Reviewed by NOBODY (OOPS!).
 17
 18 No new tests, this is just an internal refactoring.
 19
 20 * CMakeLists.txt:
 21 * GNUmakefile.list.am:
 22 * WebCore.vcxproj/WebCore.vcxproj:
 23 * WebCore.vcxproj/WebCore.vcxproj.filters:
 24 * WebCore.xcodeproj/project.pbxproj:
 25 * platform/graphics/FloatRoundedRect.cpp: Added.
 26 (WebCore::FloatRoundedRect::FloatRoundedRect):
 27 (WebCore::FloatRoundedRect::Radii::isZero):
 28 (WebCore::FloatRoundedRect::Radii::scale):
 29 (WebCore::FloatRoundedRect::Radii::expand):
 30 (WebCore::cornerRectIntercept):
 31 (WebCore::FloatRoundedRect::xInterceptsAtY):
 32 * platform/graphics/FloatRoundedRect.h: Added.
 33 (WebCore::FloatRoundedRect::Radii::Radii):
 34 (WebCore::FloatRoundedRect::Radii::setTopLeft):
 35 (WebCore::FloatRoundedRect::Radii::setTopRight):
 36 (WebCore::FloatRoundedRect::Radii::setBottomLeft):
 37 (WebCore::FloatRoundedRect::Radii::setBottomRight):
 38 (WebCore::FloatRoundedRect::Radii::topLeft):
 39 (WebCore::FloatRoundedRect::Radii::topRight):
 40 (WebCore::FloatRoundedRect::Radii::bottomLeft):
 41 (WebCore::FloatRoundedRect::Radii::bottomRight):
 42 (WebCore::FloatRoundedRect::Radii::expand):
 43 (WebCore::FloatRoundedRect::Radii::shrink):
 44 (WebCore::FloatRoundedRect::rect):
 45 (WebCore::FloatRoundedRect::radii):
 46 (WebCore::FloatRoundedRect::isRounded):
 47 (WebCore::FloatRoundedRect::isEmpty):
 48 (WebCore::FloatRoundedRect::setRect):
 49 (WebCore::FloatRoundedRect::setRadii):
 50 (WebCore::FloatRoundedRect::move):
 51 (WebCore::FloatRoundedRect::inflate):
 52 (WebCore::FloatRoundedRect::expandRadii):
 53 (WebCore::FloatRoundedRect::shrinkRadii):
 54 (WebCore::FloatRoundedRect::topLeftCorner):
 55 (WebCore::FloatRoundedRect::topRightCorner):
 56 (WebCore::FloatRoundedRect::bottomLeftCorner):
 57 (WebCore::FloatRoundedRect::bottomRightCorner):
 58 (WebCore::operator==):
 59 * rendering/shapes/BoxShape.cpp: Added.
 60 (WebCore::BoxShape::BoxShape):
 61 (WebCore::BoxShape::getExcludedIntervals):
 62 (WebCore::BoxShape::getIncludedIntervals):
 63 (WebCore::BoxShape::firstIncludedIntervalLogicalTop):
 64 * rendering/shapes/BoxShape.h: Added.
 65 * rendering/shapes/Shape.cpp:
 66 (WebCore::createBoxShape):
 67 (WebCore::Shape::createShape):
 68
1692013-11-20 Brady Eidson <beidson@apple.com>
270
371 Cleanup getOrEstablishIDBDatabaseMetadata and stub it out in WK2

Source/WebCore/GNUmakefile.list.am

@@webcore_sources += \
45394539 Source/WebCore/rendering/mathml/RenderMathMLScripts.h \
45404540 Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp \
45414541 Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h \
 4542 Source/WebCore/rendering/shapes/BoxShape.cpp \
 4543 Source/WebCore/rendering/shapes/BoxShape.h \
45424544 Source/WebCore/rendering/shapes/PolygonShape.cpp \
45434545 Source/WebCore/rendering/shapes/PolygonShape.h \
45444546 Source/WebCore/rendering/shapes/RasterShape.cpp \

@@platform_sources += \
57585760 Source/WebCore/platform/graphics/FloatQuad.h \
57595761 Source/WebCore/platform/graphics/FloatRect.cpp \
57605762 Source/WebCore/platform/graphics/FloatRect.h \
 5763 Source/WebCore/platform/graphics/FloatRoundedRect.cpp \
 5764 Source/WebCore/platform/graphics/FloatRoundedRect.h \
57615765 Source/WebCore/platform/graphics/FloatSize.cpp \
57625766 Source/WebCore/platform/graphics/FloatSize.h \
57635767 Source/WebCore/platform/graphics/FontBaseline.h \

Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

76157615 <ClCompile Include="..\platform\graphics\FloatPolygon.cpp" />
76167616 <ClCompile Include="..\platform\graphics\FloatQuad.cpp" />
76177617 <ClCompile Include="..\platform\graphics\FloatRect.cpp" />
 7618 <ClCompile Include="..\platform\graphics\FloatRoundedRect.cpp" />
76187619 <ClCompile Include="..\platform\graphics\FloatSize.cpp" />
76197620 <ClCompile Include="..\platform\graphics\Font.cpp" />
76207621 <ClCompile Include="..\platform\graphics\FontCache.cpp" />

1106411065 <ClCompile Include="..\rendering\TextPaintStyle.cpp" />
1106511066 <ClCompile Include="..\rendering\line\LineBreaker.cpp" />
1106611067 <ClCompile Include="..\rendering\line\LineInfo.cpp" />
 11068 <ClCompile Include="..\rendering\shapes\BoxShape.cpp" />
1106711069 <ClCompile Include="..\rendering\shapes\PolygonShape.cpp" />
1106811070 <ClCompile Include="..\rendering\shapes\RasterShape.cpp" />
1106911071 <ClCompile Include="..\rendering\shapes\RectangleShape.cpp" />

1917919181 <ClInclude Include="..\platform\graphics\FloatPolygon.h" />
1918019182 <ClInclude Include="..\platform\graphics\FloatQuad.h" />
1918119183 <ClInclude Include="..\platform\graphics\FloatRect.h" />
 19184 <ClInclude Include="..\platform\graphics\FloatRoundedRect.h" />
1918219185 <ClInclude Include="..\platform\graphics\FloatSize.h" />
1918319186 <ClInclude Include="..\platform\graphics\Font.h" />
1918419187 <ClInclude Include="..\platform\graphics\FontCache.h" />

1989119894 <ClInclude Include="..\rendering\line\LineInfo.h" />
1989219895 <ClInclude Include="..\rendering\line\LineInlineHeaders.h" />
1989319896 <ClInclude Include="..\rendering\line\LineLayoutState.h" />
 19897 <ClInclude Include="..\rendering\shapes\BoxShape.h" />
1989419898 <ClInclude Include="..\rendering\shapes\PolygonShape.h" />
1989519899 <ClInclude Include="..\rendering\shapes\RasterShape.h" />
1989619900 <ClInclude Include="..\rendering\shapes\RectangleShape.h" />

Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

50165016 <ClCompile Include="..\platform\graphics\FloatRect.cpp">
50175017 <Filter>platform\graphics</Filter>
50185018 </ClCompile>
 5019 <ClCompile Include="..\platform\graphics\FloatRoundedRect.cpp">
 5020 <Filter>platform\graphics</Filter>
 5021 </ClCompile>
50195022 <ClCompile Include="..\platform\graphics\FloatSize.cpp">
50205023 <Filter>platform\graphics</Filter>
50215024 </ClCompile>

68926895 <ClCompile Include="..\rendering\shapes\ShapeOutsideInfo.cpp">
68936896 <Filter>rendering\shapes</Filter>
68946897 </ClCompile>
 6898 <ClCompile Include="..\rendering\shapes\BoxShape.cpp">
 6899 <Filter>rendering\shapes</Filter>
 6900 </ClCompile>
68956901 <ClCompile Include="..\rendering\shapes\PolygonShape.cpp">
68966902 <Filter>rendering\shapes</Filter>
68976903 </ClCompile>

1279912805 <ClInclude Include="..\platform\graphics\FloatRect.h">
1280012806 <Filter>platform\graphics</Filter>
1280112807 </ClInclude>
 12808 <ClInclude Include="..\platform\graphics\FloatRoundedRect.h">
 12809 <Filter>platform\graphics</Filter>
 12810 </ClInclude>
1280212811 <ClInclude Include="..\platform\graphics\FloatSize.h">
1280312812 <Filter>platform\graphics</Filter>
1280412813 </ClInclude>

1467514684 <ClInclude Include="..\rendering\shapes\ShapeInterval.h">
1467614685 <Filter>rendering\shapes</Filter>
1467714686 </ClInclude>
 14687 <ClInclude Include="..\rendering\shapes\BoxShape.h">
 14688 <Filter>rendering\shapes</Filter>
 14689 </ClInclude>
1467814690 <ClInclude Include="..\rendering\shapes\RasterShape.h">
1467914691 <Filter>rendering\shapes</Filter>
1468014692 </ClInclude>

Source/WebCore/WebCore.xcodeproj/project.pbxproj

20422042 6C638895A96CCEE50C8C946C /* CachedResourceRequestInitiators.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */; settings = {ATTRIBUTES = (Private, ); }; };
20432043 6C638896A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */; };
20442044 6CDDE8D01770BB220016E072 /* RegionOversetState.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C70A81417707C49009A446E /* RegionOversetState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 2045 6E0E569B183BFFE600E0E8D5 /* FloatRoundedRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */; };
 2046 6E0E569C183BFFE600E0E8D5 /* FloatRoundedRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
20452047 6E21C6C01126338500A7BE02 /* GraphicsContext3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */; };
20462048 6E21C6C21126339900A7BE02 /* GraphicsContext3DCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */; };
20472049 6E3FAD3814733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */; };

20812083 6EC480A216EA638A00A48DCB /* FloatPolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EC480A016EA638A00A48DCB /* FloatPolygon.h */; settings = {ATTRIBUTES = (Private, ); }; };
20822084 6ED878C4147493F4004C3597 /* RenderTableCaption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6ED878C2147493F4004C3597 /* RenderTableCaption.cpp */; };
20832085 6ED878C5147493F4004C3597 /* RenderTableCaption.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED878C3147493F4004C3597 /* RenderTableCaption.h */; };
 2086 6ED8C379183BFF8C009E53BD /* BoxShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6ED8C377183BFF8C009E53BD /* BoxShape.cpp */; };
 2087 6ED8C37A183BFF8C009E53BD /* BoxShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED8C378183BFF8C009E53BD /* BoxShape.h */; settings = {ATTRIBUTES = (Private, ); }; };
20842088 6EE8A77210F803F3005A4A24 /* JSWebGLContextAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */; };
20852089 6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */; };
20862090 6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */; };

87788782 6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequestInitiators.h; sourceTree = "<group>"; };
87798783 6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequestInitiators.cpp; sourceTree = "<group>"; };
87808784 6C70A81417707C49009A446E /* RegionOversetState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegionOversetState.h; sourceTree = "<group>"; };
 8785 6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatRoundedRect.cpp; sourceTree = "<group>"; };
 8786 6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatRoundedRect.h; sourceTree = "<group>"; };
87818787 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3D.cpp; sourceTree = "<group>"; };
87828788 6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DCG.cpp; sourceTree = "<group>"; };
87838789 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLCompressedTextureS3TC.cpp; sourceTree = "<group>"; };

88218827 6EC480A016EA638A00A48DCB /* FloatPolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatPolygon.h; sourceTree = "<group>"; };
88228828 6ED878C2147493F4004C3597 /* RenderTableCaption.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTableCaption.cpp; sourceTree = "<group>"; };
88238829 6ED878C3147493F4004C3597 /* RenderTableCaption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTableCaption.h; sourceTree = "<group>"; };
 8830 6ED8C377183BFF8C009E53BD /* BoxShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoxShape.cpp; sourceTree = "<group>"; };
 8831 6ED8C378183BFF8C009E53BD /* BoxShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoxShape.h; sourceTree = "<group>"; };
88248832 6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextAttributes.cpp; sourceTree = "<group>"; };
88258833 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
88268834 7117445614BC34E200EE5FC8 /* SVGTextMetricsBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextMetricsBuilder.cpp; sourceTree = "<group>"; };

1914119149 B2A015910AF6CD53006BCE0E /* graphics */ = {
1914219150 isa = PBXGroup;
1914319151 children = (
 19152 6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */,
 19153 6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */,
1914419154 CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */,
1914519155 CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */,
1914619156 076F0D0812B8192700C26AA4 /* avfoundation */,

2160021610 FD08A879175D3926002CD360 /* shapes */ = {
2160121611 isa = PBXGroup;
2160221612 children = (
 21613 6ED8C377183BFF8C009E53BD /* BoxShape.cpp */,
 21614 6ED8C378183BFF8C009E53BD /* BoxShape.h */,
2160321615 FD08A87A175D3926002CD360 /* PolygonShape.cpp */,
2160421616 FD08A87B175D3926002CD360 /* PolygonShape.h */,
2160521617 6E84E9DE17668BAD00815B68 /* RasterShape.cpp */,

2194421956 isa = PBXHeadersBuildPhase;
2194521957 buildActionMask = 2147483647;
2194621958 files = (
 21959 6ED8C37A183BFF8C009E53BD /* BoxShape.h in Headers */,
 21960 6E0E569C183BFFE600E0E8D5 /* FloatRoundedRect.h in Headers */,
2194721961 9A1142041832D135000BB8AD /* ValueToString.h in Headers */,
2194821962 932AD70617EFA2C40038F8FF /* MainFrame.h in Headers */,
2194921963 FEDBFF16182B7A8D0017FA64 /* BreakpointID.h in Headers */,

2620326217 26C17A3F1491D2D400D12BA2 /* FileSystemIOS.mm in Sources */,
2620426218 CD3A495417A9CC9000274E42 /* MediaSourceBase.cpp in Sources */,
2620526219 514B3F760C722055000530DF /* FileSystemMac.mm in Sources */,
 26220 6ED8C379183BFF8C009E53BD /* BoxShape.cpp in Sources */,
2620626221 5160300B0CC4251200C8AC25 /* FileSystemPOSIX.cpp in Sources */,
2620726222 976D6C8D122B8A3D001FD1F7 /* FileThread.cpp in Sources */,
2620826223 BC5EB69E0E81DAEB00B25965 /* FillLayer.cpp in Sources */,

2808028095 49E911C30EF86D47009D0CAF /* TransformationMatrix.cpp in Sources */,
2808128096 494BC40D12AEDD9E00743BD2 /* TransformationMatrixCA.cpp in Sources */,
2808228097 B27535580B053814002CE64F /* TransformationMatrixCG.cpp in Sources */,
 28098 6E0E569B183BFFE600E0E8D5 /* FloatRoundedRect.cpp in Sources */,
2808328099 FB484F4C171F821E00040755 /* TransformFunctions.cpp in Sources */,
2808428100 49E911CF0EF86D47009D0CAF /* TransformOperations.cpp in Sources */,
2808528101 5DB1BC6B10715A6400EFAA49 /* TransformSourceLibxslt.cpp in Sources */,

Source/WebCore/platform/graphics/FloatRoundedRect.cpp

 1/*
 2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved.
 3 * Copyright (C) 2010 Google Inc. All rights reserved.
 4 * Copyright (C) 2013 Xidorn Quan (quanxunzhen@gmail.com)
 5 *
 6 * Redistribution and use in source and binary forms, with or without
 7 * modification, are permitted provided that the following conditions
 8 * are met:
 9 *
 10 * 1. Redistributions of source code must retain the above copyright
 11 * notice, this list of conditions and the following disclaimer.
 12 * 2. Redistributions in binary form must reproduce the above copyright
 13 * notice, this list of conditions and the following disclaimer in the
 14 * documentation and/or other materials provided with the distribution.
 15 *
 16 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 19 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 26 */
 27
 28#include "config.h"
 29#include "FloatRoundedRect.h"
 30
 31#include <algorithm>
 32
 33namespace WebCore {
 34
 35FloatRoundedRect::FloatRoundedRect(float x, float y, float width, float height)
 36 : m_rect(x, y, width, height)
 37{
 38}
 39
 40FloatRoundedRect::FloatRoundedRect(const FloatRect& rect, const Radii& radii)
 41 : m_rect(rect)
 42 , m_radii(radii)
 43{
 44}
 45
 46FloatRoundedRect::FloatRoundedRect(const FloatRect& rect, const FloatSize& topLeft, const FloatSize& topRight, const FloatSize& bottomLeft, const FloatSize& bottomRight)
 47 : m_rect(rect)
 48 , m_radii(topLeft, topRight, bottomLeft, bottomRight)
 49{
 50}
 51
 52bool FloatRoundedRect::Radii::isZero() const
 53{
 54 return m_topLeft.isZero() && m_topRight.isZero() && m_bottomLeft.isZero() && m_bottomRight.isZero();
 55}
 56
 57void FloatRoundedRect::Radii::scale(float factor)
 58{
 59 if (factor == 1)
 60 return;
 61
 62 // If either radius on a corner becomes zero, reset both radii on that corner.
 63 m_topLeft.scale(factor);
 64 if (!m_topLeft.width() || !m_topLeft.height())
 65 m_topLeft = FloatSize();
 66 m_topRight.scale(factor);
 67 if (!m_topRight.width() || !m_topRight.height())
 68 m_topRight = FloatSize();
 69 m_bottomLeft.scale(factor);
 70 if (!m_bottomLeft.width() || !m_bottomLeft.height())
 71 m_bottomLeft = FloatSize();
 72 m_bottomRight.scale(factor);
 73 if (!m_bottomRight.width() || !m_bottomRight.height())
 74 m_bottomRight = FloatSize();
 75
 76}
 77
 78void FloatRoundedRect::Radii::expand(float topWidth, float bottomWidth, float leftWidth, float rightWidth)
 79{
 80 if (m_topLeft.width() > 0 && m_topLeft.height() > 0) {
 81 m_topLeft.setWidth(std::max<float>(0, m_topLeft.width() + leftWidth));
 82 m_topLeft.setHeight(std::max<float>(0, m_topLeft.height() + topWidth));
 83 }
 84 if (m_topRight.width() > 0 && m_topRight.height() > 0) {
 85 m_topRight.setWidth(std::max<float>(0, m_topRight.width() + rightWidth));
 86 m_topRight.setHeight(std::max<float>(0, m_topRight.height() + topWidth));
 87 }
 88 if (m_bottomLeft.width() > 0 && m_bottomLeft.height() > 0) {
 89 m_bottomLeft.setWidth(std::max<float>(0, m_bottomLeft.width() + leftWidth));
 90 m_bottomLeft.setHeight(std::max<float>(0, m_bottomLeft.height() + bottomWidth));
 91 }
 92 if (m_bottomRight.width() > 0 && m_bottomRight.height() > 0) {
 93 m_bottomRight.setWidth(std::max<float>(0, m_bottomRight.width() + rightWidth));
 94 m_bottomRight.setHeight(std::max<float>(0, m_bottomRight.height() + bottomWidth));
 95 }
 96}
 97
 98static inline float cornerRectIntercept(float y, const FloatRect& cornerRect)
 99{
 100 ASSERT(cornerRect.height() > 0);
 101 return cornerRect.width() * sqrt(1 - (y * y) / (cornerRect.height() * cornerRect.height()));
 102}
 103
 104bool FloatRoundedRect::xInterceptsAtY(float y, float& minXIntercept, float& maxXIntercept) const
 105{
 106 if (y < rect().y() || y >= rect().maxY())
 107 return false;
 108
 109 const FloatRect& topLeftRect = topLeftCorner();
 110 const FloatRect& bottomLeftRect = bottomLeftCorner();
 111
 112 if (y >= topLeftRect.y() && y < topLeftRect.maxY())
 113 minXIntercept = topLeftRect.maxX() - cornerRectIntercept(topLeftRect.maxY() - y, topLeftRect);
 114 else if (y >= bottomLeftRect.y() && y < bottomLeftRect.maxY())
 115 minXIntercept = bottomLeftRect.maxX() - cornerRectIntercept(y - bottomLeftRect.y(), bottomLeftRect);
 116 else
 117 minXIntercept = m_rect.x();
 118
 119 const FloatRect& topRightRect = topRightCorner();
 120 const FloatRect& bottomRightRect = bottomRightCorner();
 121
 122 if (y >= topRightRect.y() && y < topRightRect.maxY())
 123 maxXIntercept = topRightRect.x() + cornerRectIntercept(topRightRect.maxY() - y, topRightRect);
 124 else if (y >= bottomRightRect.y() && y < bottomRightRect.maxY())
 125 maxXIntercept = bottomRightRect.x() + cornerRectIntercept(y - bottomRightRect.y(), bottomRightRect);
 126 else
 127 maxXIntercept = m_rect.maxX();
 128
 129 return true;
 130}
 131
 132} // namespace WebCore

Source/WebCore/platform/graphics/FloatRoundedRect.h

 1/*
 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above
 9 * copyright notice, this list of conditions and the following
 10 * disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above
 12 * copyright notice, this list of conditions and the following
 13 * disclaimer in the documentation and/or other materials
 14 * provided with the distribution.
 15 *
 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 20 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 27 * OF THE POSSIBILITY OF SUCH DAMAGE.
 28 */
 29
 30#ifndef FloatRoundedRect_h
 31#define FloatRoundedRect_h
 32
 33#include "FloatRect.h"
 34#include "FloatSize.h"
 35
 36namespace WebCore {
 37
 38class FloatRoundedRect {
 39public:
 40 class Radii {
 41 public:
 42 Radii() { }
 43 Radii(const FloatSize& topLeft, const FloatSize& topRight, const FloatSize& bottomLeft, const FloatSize& bottomRight)
 44 : m_topLeft(topLeft)
 45 , m_topRight(topRight)
 46 , m_bottomLeft(bottomLeft)
 47 , m_bottomRight(bottomRight)
 48 {
 49 }
 50
 51 void setTopLeft(const FloatSize& size) { m_topLeft = size; }
 52 void setTopRight(const FloatSize& size) { m_topRight = size; }
 53 void setBottomLeft(const FloatSize& size) { m_bottomLeft = size; }
 54 void setBottomRight(const FloatSize& size) { m_bottomRight = size; }
 55 const FloatSize& topLeft() const { return m_topLeft; }
 56 const FloatSize& topRight() const { return m_topRight; }
 57 const FloatSize& bottomLeft() const { return m_bottomLeft; }
 58 const FloatSize& bottomRight() const { return m_bottomRight; }
 59
 60 bool isZero() const;
 61
 62 void scale(float factor);
 63 void expand(float topWidth, float bottomWidth, float leftWidth, float rightWidth);
 64 void expand(float size) { expand(size, size, size, size); }
 65 void shrink(float topWidth, float bottomWidth, float leftWidth, float rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); }
 66 void shrink(float size) { shrink(size, size, size, size); }
 67
 68 private:
 69 FloatSize m_topLeft;
 70 FloatSize m_topRight;
 71 FloatSize m_bottomLeft;
 72 FloatSize m_bottomRight;
 73 };
 74
 75 explicit FloatRoundedRect(const FloatRect&, const Radii& = Radii());
 76 FloatRoundedRect(float x, float y, float width, float height);
 77 FloatRoundedRect(const FloatRect&, const FloatSize& topLeft, const FloatSize& topRight, const FloatSize& bottomLeft, const FloatSize& bottomRight);
 78
 79 const FloatRect& rect() const { return m_rect; }
 80 const Radii& radii() const { return m_radii; }
 81 bool isRounded() const { return !m_radii.isZero(); }
 82 bool isEmpty() const { return m_rect.isEmpty(); }
 83
 84 void setRect(const FloatRect& rect) { m_rect = rect; }
 85 void setRadii(const Radii& radii) { m_radii = radii; }
 86
 87 void move(const FloatSize& size) { m_rect.move(size); }
 88 void inflate(float size) { m_rect.inflate(size); }
 89 void expandRadii(float size) { m_radii.expand(size); }
 90 void shrinkRadii(float size) { m_radii.shrink(size); }
 91
 92 FloatRect topLeftCorner() const
 93 {
 94 return FloatRect(m_rect.x(), m_rect.y(), m_radii.topLeft().width(), m_radii.topLeft().height());
 95 }
 96 FloatRect topRightCorner() const
 97 {
 98 return FloatRect(m_rect.maxX() - m_radii.topRight().width(), m_rect.y(), m_radii.topRight().width(), m_radii.topRight().height());
 99 }
 100 FloatRect bottomLeftCorner() const
 101 {
 102 return FloatRect(m_rect.maxX() - m_radii.topRight().width(), m_rect.y(), m_radii.topRight().width(), m_radii.topRight().height());
 103 }
 104 FloatRect bottomRightCorner() const
 105 {
 106 return FloatRect(m_rect.maxX() - m_radii.bottomRight().width(), m_rect.maxY() - m_radii.bottomRight().height(), m_radii.bottomRight().width(), m_radii.bottomRight().height());
 107 }
 108
 109 bool xInterceptsAtY(float y, float& minXIntercept, float& maxXIntercept) const;
 110
 111private:
 112 FloatRect m_rect;
 113 Radii m_radii;
 114};
 115
 116inline bool operator==(const FloatRoundedRect::Radii& a, const FloatRoundedRect::Radii& b)
 117{
 118 return a.topLeft() == b.topLeft() && a.topRight() == b.topRight() && a.bottomLeft() == b.bottomLeft() && a.bottomRight() == b.bottomRight();
 119}
 120
 121inline bool operator==(const FloatRoundedRect& a, const FloatRoundedRect& b)
 122{
 123 return a.rect() == b.rect() && a.radii() == b.radii();
 124}
 125
 126} // namespace WebCore
 127
 128#endif // FloatRoundedRect_h

Source/WebCore/rendering/shapes/BoxShape.cpp

 1/*
 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above
 9 * copyright notice, this list of conditions and the following
 10 * disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above
 12 * copyright notice, this list of conditions and the following
 13 * disclaimer in the documentation and/or other materials
 14 * provided with the distribution.
 15 *
 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 20 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 27 * OF THE POSSIBILITY OF SUCH DAMAGE.
 28 */
 29
 30#include "config.h"
 31#include "BoxShape.h"
 32
 33#include <wtf/MathExtras.h>
 34
 35namespace WebCore {
 36
 37BoxShape::BoxShape(const FloatRoundedRect& bounds)
 38 : Shape()
 39 , m_bounds(bounds)
 40 , m_marginBounds(bounds)
 41 , m_paddingBounds(bounds)
 42{
 43 if (shapeMargin() > 0) {
 44 m_marginBounds.inflate(shapeMargin());
 45 m_marginBounds.expandRadii(shapeMargin());
 46 }
 47 if (shapePadding() > 0) {
 48 m_paddingBounds.inflate(-shapePadding());
 49 m_paddingBounds.expandRadii(-shapePadding());
 50 }
 51}
 52
 53void BoxShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
 54{
 55 if (m_marginBounds.isEmpty())
 56 return;
 57
 58 float y1 = logicalTop;
 59 float y2 = logicalTop + logicalHeight;
 60 const FloatRect& rect = m_marginBounds.rect();
 61
 62 if (y2 <= rect.y() || y1 >= rect.maxY())
 63 return;
 64
 65 if (!m_marginBounds.isRounded()) {
 66 result.append(LineSegment(m_marginBounds.rect().x(), m_marginBounds.rect().maxX()));
 67 return;
 68 }
 69
 70 float x1 = rect.maxX();
 71 float x2 = rect.x();
 72 float minXIntercept;
 73 float maxXIntercept;
 74
 75 if (m_marginBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) {
 76 x1 = std::min<float>(x1, minXIntercept);
 77 x2 = std::max<float>(x2, maxXIntercept);
 78 }
 79
 80 if (m_marginBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) {
 81 x1 = std::min<float>(x1, minXIntercept);
 82 x2 = std::max<float>(x2, maxXIntercept);
 83 }
 84
 85 ASSERT(x2 >= x1);
 86 result.append(LineSegment(x1, x2));
 87}
 88
 89void BoxShape::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const
 90{
 91 if (m_paddingBounds.isEmpty())
 92 return;
 93
 94 const FloatRect& rect = m_paddingBounds.rect();
 95 if (logicalTop < rect.y() || logicalTop + logicalHeight > rect.maxY())
 96 return;
 97
 98 // FIXME: this method is only a stub, https://bugs.webkit.org/show_bug.cgi?id=124605.
 99
 100 result.append(LineSegment(rect.x(), rect.maxX()));
 101}
 102
 103bool BoxShape::firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const LayoutSize&, LayoutUnit& result) const
 104{
 105 // FIXME: this method is only a stub, https://bugs.webkit.org/show_bug.cgi?id=124606.
 106
 107 result = minLogicalIntervalTop;
 108 return true;
 109}
 110
 111} // namespace WebCore

Source/WebCore/rendering/shapes/BoxShape.h

 1/*
 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above
 9 * copyright notice, this list of conditions and the following
 10 * disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above
 12 * copyright notice, this list of conditions and the following
 13 * disclaimer in the documentation and/or other materials
 14 * provided with the distribution.
 15 *
 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 20 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 27 * OF THE POSSIBILITY OF SUCH DAMAGE.
 28 */
 29
 30#ifndef BoxShape_h
 31#define BoxShape_h
 32
 33#include "FloatRoundedRect.h"
 34#include "Shape.h"
 35
 36namespace WebCore {
 37
 38class BoxShape : public Shape {
 39public:
 40 BoxShape(const FloatRoundedRect& bounds);
 41
 42 virtual LayoutRect shapeMarginLogicalBoundingBox() const OVERRIDE { return static_cast<LayoutRect>(m_marginBounds.rect()); }
 43 virtual LayoutRect shapePaddingLogicalBoundingBox() const OVERRIDE { return static_cast<LayoutRect>(m_paddingBounds.rect()); }
 44 virtual bool isEmpty() const OVERRIDE { return m_bounds.isEmpty(); }
 45 virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const OVERRIDE;
 46 virtual void getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const OVERRIDE;
 47 virtual bool firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const LayoutSize& minLogicalIntervalSize, LayoutUnit&) const OVERRIDE;
 48 virtual ShapeType type() const OVERRIDE { return Shape::RoundedRectangleType; }
 49
 50private:
 51 FloatRoundedRect m_bounds;
 52 FloatRoundedRect m_marginBounds;
 53 FloatRoundedRect m_paddingBounds;
 54};
 55
 56} // namespace WebCore
 57
 58#endif // BoxShape_h

Source/WebCore/rendering/shapes/Shape.cpp

3131#include "Shape.h"
3232
3333#include "BasicShapeFunctions.h"
 34#include "BoxShape.h"
3435#include "CachedImage.h"
3536#include "FloatSize.h"
3637#include "ImageBuffer.h"

4546
4647namespace WebCore {
4748
 49static PassOwnPtr<Shape> createBoxShape(const FloatRoundedRect& bounds)
 50{
 51 ASSERT(bounds.rect().width() >= 0 && bounds.rect().height() >= 0);
 52 return adoptPtr(new BoxShape(bounds));
 53}
 54
4855static PassOwnPtr<Shape> createRectangleShape(const FloatRect& bounds, const FloatSize& radii)
4956{
5057 ASSERT(bounds.width() >= 0 && bounds.height() >= 0 && radii.width() >= 0 && radii.height() >= 0);

@@PassOwnPtr<Shape> Shape::createShape(const StyleImage* styleImage, float thresho
248255
249256PassOwnPtr<Shape> Shape::createShape(const LayoutSize& logicalSize, const LayoutSize& logicalRadii, WritingMode writingMode, Length margin, Length padding)
250257{
251  FloatRect bounds(0, 0, logicalSize.width(), logicalSize.height());
 258 FloatRect rect(0, 0, logicalSize.width(), logicalSize.height());
252259 FloatSize radii(logicalRadii.width(), logicalRadii.height());
 260 FloatRoundedRect bounds(rect, radii, radii, radii, radii);
253261
254  OwnPtr<Shape> shape = createRectangleShape(bounds, radii);
 262 OwnPtr<Shape> shape = createBoxShape(bounds);
255263 shape->m_writingMode = writingMode;
256264 shape->m_margin = floatValueForLength(margin, 0);
257265 shape->m_padding = floatValueForLength(padding, 0);