Diff
Modified: trunk/Source/WebCore/ChangeLog (221865 => 221866)
--- trunk/Source/WebCore/ChangeLog 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/ChangeLog 2017-09-11 17:57:55 UTC (rev 221866)
@@ -1,3 +1,93 @@
+2017-09-11 Alex Christensen <[email protected]>
+
+ Modernize BoxExtent into RectEdges
+ https://bugs.webkit.org/show_bug.cgi?id=176437
+
+ Reviewed by Simon Fraser.
+
+ And give it its own header.
+ No change in behavior.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSProperty.cpp:
+ (WebCore::resolveToPhysicalProperty):
+ (WebCore::CSSProperty::resolveDirectionAwareProperty):
+ * platform/LengthBox.h:
+ (WebCore::LengthBox::LengthBox):
+ (WebCore::BoxExtent::BoxExtent): Deleted.
+ (WebCore::BoxExtent::at): Deleted.
+ (WebCore::BoxExtent::top): Deleted.
+ (WebCore::BoxExtent::right): Deleted.
+ (WebCore::BoxExtent::bottom): Deleted.
+ (WebCore::BoxExtent::left): Deleted.
+ (WebCore::BoxExtent::at const): Deleted.
+ (WebCore::BoxExtent::top const): Deleted.
+ (WebCore::BoxExtent::right const): Deleted.
+ (WebCore::BoxExtent::bottom const): Deleted.
+ (WebCore::BoxExtent::left const): Deleted.
+ (WebCore::BoxExtent::setAt): Deleted.
+ (WebCore::BoxExtent::setTop): Deleted.
+ (WebCore::BoxExtent::setRight): Deleted.
+ (WebCore::BoxExtent::setBottom): Deleted.
+ (WebCore::BoxExtent::setLeft): Deleted.
+ (WebCore::BoxExtent::before): Deleted.
+ (WebCore::BoxExtent::after): Deleted.
+ (WebCore::BoxExtent::start): Deleted.
+ (WebCore::BoxExtent::end): Deleted.
+ (WebCore::BoxExtent::before const): Deleted.
+ (WebCore::BoxExtent::after const): Deleted.
+ (WebCore::BoxExtent::start const): Deleted.
+ (WebCore::BoxExtent::end const): Deleted.
+ (WebCore::BoxExtent::setBefore): Deleted.
+ (WebCore::BoxExtent::setAfter): Deleted.
+ (WebCore::BoxExtent::setStart): Deleted.
+ (WebCore::BoxExtent::setEnd): Deleted.
+ (WebCore::BoxExtent::operator== const): Deleted.
+ (WebCore::BoxExtent::operator!= const): Deleted.
+ * platform/RectEdges.h: Added.
+ (WebCore::RectEdges::RectEdges):
+ (WebCore::RectEdges::at):
+ (WebCore::RectEdges::top):
+ (WebCore::RectEdges::right):
+ (WebCore::RectEdges::bottom):
+ (WebCore::RectEdges::left):
+ (WebCore::RectEdges::at const):
+ (WebCore::RectEdges::top const):
+ (WebCore::RectEdges::right const):
+ (WebCore::RectEdges::bottom const):
+ (WebCore::RectEdges::left const):
+ (WebCore::RectEdges::setAt):
+ (WebCore::RectEdges::setTop):
+ (WebCore::RectEdges::setRight):
+ (WebCore::RectEdges::setBottom):
+ (WebCore::RectEdges::setLeft):
+ (WebCore::RectEdges::before):
+ (WebCore::RectEdges::after):
+ (WebCore::RectEdges::start):
+ (WebCore::RectEdges::end):
+ (WebCore::RectEdges::before const):
+ (WebCore::RectEdges::after const):
+ (WebCore::RectEdges::start const):
+ (WebCore::RectEdges::end const):
+ (WebCore::RectEdges::setBefore):
+ (WebCore::RectEdges::setAfter):
+ (WebCore::RectEdges::setStart):
+ (WebCore::RectEdges::setEnd):
+ (WebCore::RectEdges::operator== const):
+ (WebCore::RectEdges::operator!= const):
+ * platform/graphics/ca/TileController.cpp:
+ (WebCore::TileController::setHasMargins):
+ * platform/graphics/ca/TileController.h:
+ * platform/text/WritingMode.h:
+ (WebCore::isHorizontalPhysicalSide):
+ * rendering/style/NinePieceImage.cpp:
+ (WebCore::NinePieceImage::isEmptyPieceRect):
+ * rendering/style/NinePieceImage.h:
+ (WebCore::imagePieceHorizontalSide):
+ (WebCore::imagePieceVerticalSide):
+ * rendering/style/RenderStyle.cpp:
+ (WebCore::RenderStyle::getShadowInsetExtent const):
+
2017-09-11 Yoshiaki Jitsukawa <[email protected]>
[WinCairo] Fix the wincairo build after r221839
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (221865 => 221866)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-09-11 17:57:55 UTC (rev 221866)
@@ -2730,6 +2730,7 @@
5CE5D9AC1DB89A0600CE7A8D /* JSTextEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CE5D9A91DB899FC00CE7A8D /* JSTextEncoder.cpp */; };
5CE5D9AD1DB89A0E00CE7A8D /* TextDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CE5D9A01DB897C300CE7A8D /* TextDecoder.cpp */; };
5CE5D9AE1DB89A1300CE7A8D /* TextEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CE5D9A31DB897C300CE7A8D /* TextEncoder.cpp */; };
+ 5CEEE4361F5F8F210014A5F5 /* RectEdges.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C97A3361F5F7A6500105207 /* RectEdges.h */; settings = {ATTRIBUTES = (Private, ); }; };
5CFC4350192409E300A0D3B5 /* PointerLockController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CFC434E192406A900A0D3B5 /* PointerLockController.cpp */; };
5D21A80213ECE5DF00BB7064 /* WebVTTParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D21A80013ECE5DF00BB7064 /* WebVTTParser.cpp */; };
5D21A80313ECE5DF00BB7064 /* WebVTTParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D21A80113ECE5DF00BB7064 /* WebVTTParser.h */; };
@@ -10607,6 +10608,7 @@
5C6E653F1D5CEDC900F7862E /* URLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParser.cpp; sourceTree = "<group>"; };
5C6E65401D5CEDC900F7862E /* URLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLParser.h; sourceTree = "<group>"; };
5C7C88D71D0F1F2B009D2F6D /* SocketProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketProvider.h; sourceTree = "<group>"; };
+ 5C97A3361F5F7A6500105207 /* RectEdges.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RectEdges.h; sourceTree = "<group>"; };
5C9B860B1C21E3C600110F36 /* NetworkLoadMetrics.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkLoadMetrics.mm; sourceTree = "<group>"; };
5C9EF16F1DFF719900A452E3 /* XPathGrammar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathGrammar.cpp; sourceTree = "<group>"; };
5C9EF1701DFF719900A452E3 /* XPathGrammar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathGrammar.h; sourceTree = "<group>"; };
@@ -24540,6 +24542,7 @@
ABC128760B33AA6D00C693D5 /* PopupMenuClient.h */,
BC3BE12A0E98092F00835588 /* PopupMenuStyle.h */,
0081FEFD16B0A244008AAA7A /* PublicSuffix.h */,
+ 5C97A3361F5F7A6500105207 /* RectEdges.h */,
9831AE49154225A200FE2644 /* ReferrerPolicy.h */,
CDFC360318CA61C20026E56F /* RemoteCommandListener.cpp */,
CDFC360418CA61C20026E56F /* RemoteCommandListener.h */,
@@ -29520,6 +29523,7 @@
91B952241F58A58F00931DC2 /* RecordingSwizzleTypes.h in Headers */,
BC4368E80C226E32005EFB5F /* Rect.h in Headers */,
FD45A958175D414C00C21EC8 /* RectangleShape.h in Headers */,
+ 5CEEE4361F5F8F210014A5F5 /* RectEdges.h in Headers */,
9831AE4A154225C900FE2644 /* ReferrerPolicy.h in Headers */,
BCAB418213E356E800D8AAF3 /* Region.h in Headers */,
6CDDE8D01770BB220016E072 /* RegionOversetState.h in Headers */,
Modified: trunk/Source/WebCore/css/CSSProperty.cpp (221865 => 221866)
--- trunk/Source/WebCore/css/CSSProperty.cpp 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/css/CSSProperty.cpp 2017-09-11 17:57:55 UTC (rev 221866)
@@ -54,7 +54,7 @@
static CSSPropertyID resolveToPhysicalProperty(TextDirection direction, WritingMode writingMode, LogicalBoxSide logicalSide, const StylePropertyShorthand& shorthand)
{
- return shorthand.properties()[mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), logicalSide)];
+ return shorthand.properties()[static_cast<size_t>(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), logicalSide))];
}
enum LogicalExtent { LogicalWidth, LogicalHeight };
@@ -77,53 +77,53 @@
{
switch (propertyID) {
case CSSPropertyWebkitMarginEnd:
- return resolveToPhysicalProperty(direction, writingMode, EndSide, marginShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, marginShorthand());
case CSSPropertyWebkitMarginStart:
- return resolveToPhysicalProperty(direction, writingMode, StartSide, marginShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, marginShorthand());
case CSSPropertyWebkitMarginBefore:
- return resolveToPhysicalProperty(direction, writingMode, BeforeSide, marginShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, marginShorthand());
case CSSPropertyWebkitMarginAfter:
- return resolveToPhysicalProperty(direction, writingMode, AfterSide, marginShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, marginShorthand());
case CSSPropertyWebkitPaddingEnd:
- return resolveToPhysicalProperty(direction, writingMode, EndSide, paddingShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, paddingShorthand());
case CSSPropertyWebkitPaddingStart:
- return resolveToPhysicalProperty(direction, writingMode, StartSide, paddingShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, paddingShorthand());
case CSSPropertyWebkitPaddingBefore:
- return resolveToPhysicalProperty(direction, writingMode, BeforeSide, paddingShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, paddingShorthand());
case CSSPropertyWebkitPaddingAfter:
- return resolveToPhysicalProperty(direction, writingMode, AfterSide, paddingShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, paddingShorthand());
case CSSPropertyWebkitBorderEnd:
- return resolveToPhysicalProperty(direction, writingMode, EndSide, borderDirections());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, borderDirections());
case CSSPropertyWebkitBorderStart:
- return resolveToPhysicalProperty(direction, writingMode, StartSide, borderDirections());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, borderDirections());
case CSSPropertyWebkitBorderBefore:
- return resolveToPhysicalProperty(direction, writingMode, BeforeSide, borderDirections());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, borderDirections());
case CSSPropertyWebkitBorderAfter:
- return resolveToPhysicalProperty(direction, writingMode, AfterSide, borderDirections());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, borderDirections());
case CSSPropertyWebkitBorderEndColor:
- return resolveToPhysicalProperty(direction, writingMode, EndSide, borderColorShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, borderColorShorthand());
case CSSPropertyWebkitBorderStartColor:
- return resolveToPhysicalProperty(direction, writingMode, StartSide, borderColorShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, borderColorShorthand());
case CSSPropertyWebkitBorderBeforeColor:
- return resolveToPhysicalProperty(direction, writingMode, BeforeSide, borderColorShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, borderColorShorthand());
case CSSPropertyWebkitBorderAfterColor:
- return resolveToPhysicalProperty(direction, writingMode, AfterSide, borderColorShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, borderColorShorthand());
case CSSPropertyWebkitBorderEndStyle:
- return resolveToPhysicalProperty(direction, writingMode, EndSide, borderStyleShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, borderStyleShorthand());
case CSSPropertyWebkitBorderStartStyle:
- return resolveToPhysicalProperty(direction, writingMode, StartSide, borderStyleShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, borderStyleShorthand());
case CSSPropertyWebkitBorderBeforeStyle:
- return resolveToPhysicalProperty(direction, writingMode, BeforeSide, borderStyleShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, borderStyleShorthand());
case CSSPropertyWebkitBorderAfterStyle:
- return resolveToPhysicalProperty(direction, writingMode, AfterSide, borderStyleShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, borderStyleShorthand());
case CSSPropertyWebkitBorderEndWidth:
- return resolveToPhysicalProperty(direction, writingMode, EndSide, borderWidthShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, borderWidthShorthand());
case CSSPropertyWebkitBorderStartWidth:
- return resolveToPhysicalProperty(direction, writingMode, StartSide, borderWidthShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, borderWidthShorthand());
case CSSPropertyWebkitBorderBeforeWidth:
- return resolveToPhysicalProperty(direction, writingMode, BeforeSide, borderWidthShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, borderWidthShorthand());
case CSSPropertyWebkitBorderAfterWidth:
- return resolveToPhysicalProperty(direction, writingMode, AfterSide, borderWidthShorthand());
+ return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, borderWidthShorthand());
case CSSPropertyWebkitLogicalWidth: {
const CSSPropertyID properties[2] = { CSSPropertyWidth, CSSPropertyHeight };
return resolveToPhysicalProperty(writingMode, LogicalWidth, properties);
Modified: trunk/Source/WebCore/platform/LengthBox.h (221865 => 221866)
--- trunk/Source/WebCore/platform/LengthBox.h 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/platform/LengthBox.h 2017-09-11 17:57:55 UTC (rev 221866)
@@ -22,107 +22,13 @@
#pragma once
#include "Length.h"
+#include "RectEdges.h"
#include "WritingMode.h"
-#include <array>
namespace WebCore {
-template<typename T> class BoxExtent {
+class LengthBox : public RectEdges<Length> {
public:
- BoxExtent()
- : m_sides({ { 0, 0, 0, 0 } })
- {
- }
-
- BoxExtent(const T& top, const T& right, const T& bottom, const T& left)
- : m_sides({ { top, right, bottom, left } })
- {
- }
-
- BoxExtent(T&& top, T&& right, T&& bottom, T&& left)
- : m_sides({ { std::forward<T>(top), std::forward<T>(right), std::forward<T>(bottom), std::forward<T>(left) } })
- {
- }
-
- T& at(PhysicalBoxSide side) { return m_sides[side]; }
- T& top() { return at(TopSide); }
- T& right() { return at(RightSide); }
- T& bottom() { return at(BottomSide); }
- T& left() { return at(LeftSide); }
-
- const T& at(PhysicalBoxSide side) const { return m_sides[side]; }
- const T& top() const { return at(TopSide); }
- const T& right() const { return at(RightSide); }
- const T& bottom() const { return at(BottomSide); }
- const T& left() const { return at(LeftSide); }
-
- void setAt(PhysicalBoxSide side, const T& v) { at(side) = v; }
- void setTop(const T& top) { setAt(TopSide, top); }
- void setRight(const T& right) { setAt(RightSide, right); }
- void setBottom(const T& bottom) { setAt(BottomSide, bottom); }
- void setLeft(const T& left) { setAt(LeftSide, left); }
-
- T& before(WritingMode writingMode)
- {
- return at(mapLogicalSideToPhysicalSide(writingMode, BeforeSide));
- }
-
- T& after(WritingMode writingMode)
- {
- return at(mapLogicalSideToPhysicalSide(writingMode, AfterSide));
- }
-
- T& start(WritingMode writingMode, TextDirection direction = LTR)
- {
- return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), StartSide));
- }
-
- T& end(WritingMode writingMode, TextDirection direction = LTR)
- {
- return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), EndSide));
- }
-
- const T& before(WritingMode writingMode) const
- {
- return at(mapLogicalSideToPhysicalSide(writingMode, BeforeSide));
- }
-
- const T& after(WritingMode writingMode) const
- {
- return at(mapLogicalSideToPhysicalSide(writingMode, AfterSide));
- }
-
- const T& start(WritingMode writingMode, TextDirection direction = LTR) const
- {
- return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), StartSide));
- }
-
- const T& end(WritingMode writingMode, TextDirection direction = LTR) const
- {
- return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), EndSide));
- }
-
- void setBefore(const T& before, WritingMode writingMode) { this->before(writingMode) = before; }
- void setAfter(const T& after, WritingMode writingMode) { this->after(writingMode) = after; }
- void setStart(const T& start, WritingMode writingMode, TextDirection direction = LTR) { this->start(writingMode, direction) = start; }
- void setEnd(const T& end, WritingMode writingMode, TextDirection direction = LTR) { this->end(writingMode, direction) = end; }
-
- bool operator==(const BoxExtent& other) const
- {
- return m_sides == other.m_sides;
- }
-
- bool operator!=(const BoxExtent& other) const
- {
- return m_sides != other.m_sides;
- }
-
-protected:
- std::array<T, 4> m_sides;
-};
-
-class LengthBox : public BoxExtent<Length> {
-public:
LengthBox()
: LengthBox(Auto)
{
@@ -129,22 +35,22 @@
}
explicit LengthBox(LengthType type)
- : BoxExtent(Length(type), Length(type), Length(type), Length(type))
+ : RectEdges(Length(type), Length(type), Length(type), Length(type))
{
}
explicit LengthBox(int v)
- : BoxExtent(Length(v, Fixed), Length(v, Fixed), Length(v, Fixed), Length(v, Fixed))
+ : RectEdges(Length(v, Fixed), Length(v, Fixed), Length(v, Fixed), Length(v, Fixed))
{
}
LengthBox(int top, int right, int bottom, int left)
- : BoxExtent(Length(top, Fixed), Length(right, Fixed), Length(bottom, Fixed), Length(left, Fixed))
+ : RectEdges(Length(top, Fixed), Length(right, Fixed), Length(bottom, Fixed), Length(left, Fixed))
{
}
LengthBox(Length&& top, Length&& right, Length&& bottom, Length&& left)
- : BoxExtent { WTFMove(top), WTFMove(right), WTFMove(bottom), WTFMove(left) }
+ : RectEdges { WTFMove(top), WTFMove(right), WTFMove(bottom), WTFMove(left) }
{
}
@@ -154,8 +60,8 @@
}
};
-using LayoutBoxExtent = BoxExtent<LayoutUnit>;
-using FloatBoxExtent = BoxExtent<float>;
+using LayoutBoxExtent = RectEdges<LayoutUnit>;
+using FloatBoxExtent = RectEdges<float>;
WTF::TextStream& operator<<(WTF::TextStream&, const LengthBox&);
WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const FloatBoxExtent&);
Added: trunk/Source/WebCore/platform/RectEdges.h (0 => 221866)
--- trunk/Source/WebCore/platform/RectEdges.h (rev 0)
+++ trunk/Source/WebCore/platform/RectEdges.h 2017-09-11 17:57:55 UTC (rev 221866)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2017 Apple 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 INC. ``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 INC. OR
+ * 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.
+ */
+
+#pragma once
+
+#include "WritingMode.h"
+#include <array>
+
+namespace WebCore {
+
+template<typename T> class RectEdges {
+public:
+ RectEdges() = default;
+
+ template<typename U>
+ RectEdges(U&& top, U&& right, U&& bottom, U&& left)
+ : m_sides({ { std::forward<T>(top), std::forward<T>(right), std::forward<T>(bottom), std::forward<T>(left) } })
+ { }
+
+ T& at(PhysicalBoxSide side) { return m_sides[static_cast<size_t>(side)]; }
+ T& top() { return at(PhysicalBoxSide::Top); }
+ T& right() { return at(PhysicalBoxSide::Right); }
+ T& bottom() { return at(PhysicalBoxSide::Bottom); }
+ T& left() { return at(PhysicalBoxSide::Left); }
+
+ const T& at(PhysicalBoxSide side) const { return m_sides[static_cast<size_t>(side)]; }
+ const T& top() const { return at(PhysicalBoxSide::Top); }
+ const T& right() const { return at(PhysicalBoxSide::Right); }
+ const T& bottom() const { return at(PhysicalBoxSide::Bottom); }
+ const T& left() const { return at(PhysicalBoxSide::Left); }
+
+ void setAt(PhysicalBoxSide side, const T& v) { at(side) = v; }
+ void setTop(const T& top) { setAt(PhysicalBoxSide::Top, top); }
+ void setRight(const T& right) { setAt(PhysicalBoxSide::Right, right); }
+ void setBottom(const T& bottom) { setAt(PhysicalBoxSide::Bottom, bottom); }
+ void setLeft(const T& left) { setAt(PhysicalBoxSide::Left, left); }
+
+ T& before(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::Before)); }
+ T& after(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::After)); }
+ T& start(WritingMode writingMode, TextDirection direction = LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::Start)); }
+ T& end(WritingMode writingMode, TextDirection direction = LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::End)); }
+
+ const T& before(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::Before)); }
+ const T& after(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::After)); }
+ const T& start(WritingMode writingMode, TextDirection direction = LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::Start)); }
+ const T& end(WritingMode writingMode, TextDirection direction = LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::End)); }
+
+ void setBefore(const T& before, WritingMode writingMode) { this->before(writingMode) = before; }
+ void setAfter(const T& after, WritingMode writingMode) { this->after(writingMode) = after; }
+ void setStart(const T& start, WritingMode writingMode, TextDirection direction = LTR) { this->start(writingMode, direction) = start; }
+ void setEnd(const T& end, WritingMode writingMode, TextDirection direction = LTR) { this->end(writingMode, direction) = end; }
+
+ bool operator==(const RectEdges& other) const { return m_sides == other.m_sides; }
+ bool operator!=(const RectEdges& other) const { return m_sides != other.m_sides; }
+
+private:
+ std::array<T, 4> m_sides {{0, 0, 0, 0}};
+};
+
+}
Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (221865 => 221866)
--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp 2017-09-11 17:57:55 UTC (rev 221866)
@@ -667,7 +667,7 @@
void TileController::setHasMargins(bool marginTop, bool marginBottom, bool marginLeft, bool marginRight)
{
- BoxExtent<bool> marginEdges(marginTop, marginRight, marginBottom, marginLeft);
+ RectEdges<bool> marginEdges(marginTop, marginRight, marginBottom, marginLeft);
if (marginEdges == m_marginEdges)
return;
Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (221865 => 221866)
--- trunk/Source/WebCore/platform/graphics/ca/TileController.h 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h 2017-09-11 17:57:55 UTC (rev 221866)
@@ -219,7 +219,7 @@
// of those tiles will be equivalent to the width of the other tiles in the grid. m_marginRight and
// m_marginLeft are the width in pixels of the right and left margin tiles, respectively. The height of
// those tiles will be equivalent to the height of the other tiles in the grid.
- BoxExtent<bool> m_marginEdges;
+ RectEdges<bool> m_marginEdges;
bool m_isInWindow { false };
bool m_scrollingPerformanceLoggingEnabled { false };
Modified: trunk/Source/WebCore/platform/text/WritingMode.h (221865 => 221866)
--- trunk/Source/WebCore/platform/text/WritingMode.h 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/platform/text/WritingMode.h 2017-09-11 17:57:55 UTC (rev 221866)
@@ -29,8 +29,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WritingMode_h
-#define WritingMode_h
+#pragma once
namespace WebCore {
@@ -113,24 +112,23 @@
return isVerticalWritingMode(writingMode) != isFlippedWritingMode(writingMode);
}
-enum LogicalBoxSide {
- BeforeSide,
- EndSide,
- AfterSide,
- StartSide
+enum class LogicalBoxSide : uint8_t {
+ Before,
+ End,
+ After,
+ Start
};
-enum PhysicalBoxSide {
- NilSide = -1,
- TopSide,
- RightSide,
- BottomSide,
- LeftSide
+enum class PhysicalBoxSide : uint8_t {
+ Top,
+ Right,
+ Bottom,
+ Left
};
inline bool isHorizontalPhysicalSide(PhysicalBoxSide physicalSide)
{
- return physicalSide == LeftSide || physicalSide == RightSide;
+ return physicalSide == PhysicalBoxSide::Left || physicalSide == PhysicalBoxSide::Right;
}
inline PhysicalBoxSide mirrorPhysicalSide(PhysicalBoxSide physicalSide)
@@ -168,5 +166,3 @@
}
} // namespace WebCore
-
-#endif // WritingMode_h
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.cpp (221865 => 221866)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.cpp 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.cpp 2017-09-11 17:57:55 UTC (rev 221866)
@@ -100,9 +100,9 @@
if (piece == MiddlePiece)
return false;
- PhysicalBoxSide horizontalSide = imagePieceHorizontalSide(piece);
- PhysicalBoxSide verticalSide = imagePieceVerticalSide(piece);
- return !((horizontalSide == NilSide || slices.at(horizontalSide)) && (verticalSide == NilSide || slices.at(verticalSide)));
+ auto horizontalSide = imagePieceHorizontalSide(piece);
+ auto verticalSide = imagePieceVerticalSide(piece);
+ return !((!horizontalSide || slices.at(*horizontalSide)) && (!verticalSide || slices.at(*verticalSide)));
}
bool NinePieceImage::isEmptyPieceRect(ImagePiece piece, const Vector<FloatRect>& destinationRects, const Vector<FloatRect>& sourceRects)
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.h (221865 => 221866)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.h 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.h 2017-09-11 17:57:55 UTC (rev 221866)
@@ -76,26 +76,26 @@
return piece == LeftPiece || piece == RightPiece || piece == MiddlePiece;
}
-inline PhysicalBoxSide imagePieceHorizontalSide(ImagePiece piece)
+inline std::optional<PhysicalBoxSide> imagePieceHorizontalSide(ImagePiece piece)
{
if (piece == TopLeftPiece || piece == TopPiece || piece == TopRightPiece)
- return TopSide;
+ return PhysicalBoxSide::Top;
if (piece == BottomLeftPiece || piece == BottomPiece || piece == BottomRightPiece)
- return BottomSide;
+ return PhysicalBoxSide::Bottom;
- return NilSide;
+ return std::nullopt;
}
-inline PhysicalBoxSide imagePieceVerticalSide(ImagePiece piece)
+inline std::optional<PhysicalBoxSide> imagePieceVerticalSide(ImagePiece piece)
{
if (piece == TopLeftPiece || piece == LeftPiece || piece == BottomLeftPiece)
- return LeftSide;
+ return PhysicalBoxSide::Left;
if (piece == TopRightPiece || piece == RightPiece || piece == BottomRightPiece)
- return RightSide;
+ return PhysicalBoxSide::Right;
- return NilSide;
+ return std::nullopt;
}
class NinePieceImage {
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (221865 => 221866)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2017-09-11 17:57:55 UTC (rev 221866)
@@ -1720,7 +1720,7 @@
left = std::max<LayoutUnit>(left, shadow->x() + extentAndSpread);
}
- return LayoutBoxExtent(top, right, bottom, left);
+ return LayoutBoxExtent(WTFMove(top), WTFMove(right), WTFMove(bottom), WTFMove(left));
}
void RenderStyle::getShadowHorizontalExtent(const ShadowData* shadow, LayoutUnit &left, LayoutUnit &right) const
Modified: trunk/Source/WebKit/ChangeLog (221865 => 221866)
--- trunk/Source/WebKit/ChangeLog 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebKit/ChangeLog 2017-09-11 17:57:55 UTC (rev 221866)
@@ -1,3 +1,17 @@
+2017-09-11 Alex Christensen <[email protected]>
+
+ Modernize BoxExtent into RectEdges
+ https://bugs.webkit.org/show_bug.cgi?id=176437
+
+ Reviewed by Simon Fraser.
+
+ * Scripts/webkit/messages.py:
+ (class_template_headers):
+ * Shared/WebCoreArgumentCoders.h:
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2017-09-11 Andy Estes <[email protected]>
[Mac] Upstream QTKit-related WebKitSystemInterface functions
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (221865 => 221866)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2017-09-11 17:57:55 UTC (rev 221866)
@@ -292,7 +292,7 @@
template_string = template_string.strip()
class_template_types = {
- 'WebCore::BoxExtent': {'headers': ['<WebCore/LengthBox.h>'], 'argument_coder_headers': ['"WebCoreArgumentCoders.h"']},
+ 'WebCore::RectEdges': {'headers': ['<WebCore/RectEdges.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'HashMap': {'headers': ['<wtf/HashMap.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'std::optional': {'headers': ['<wtf/Optional.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'OptionSet': {'headers': ['<wtf/OptionSet.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (221865 => 221866)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2017-09-11 17:57:55 UTC (rev 221866)
@@ -55,6 +55,7 @@
#include <WebCore/Path.h>
#include <WebCore/PluginData.h>
#include <WebCore/ProtectionSpace.h>
+#include <WebCore/RectEdges.h>
#include <WebCore/Region.h>
#include <WebCore/ResourceError.h>
#include <WebCore/ResourceLoadStatistics.h>
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (221865 => 221866)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h 2017-09-11 17:57:55 UTC (rev 221866)
@@ -45,10 +45,6 @@
class Seconds;
}
-namespace PAL {
-class SessionID;
-}
-
namespace WebCore {
class AffineTransform;
class AuthenticationChallenge;
@@ -103,7 +99,6 @@
struct MimeClassInfo;
struct PasteboardImage;
struct PasteboardURL;
-struct PasteboardWebContent;
struct PluginInfo;
struct RecentSearch;
struct ResourceLoadStatistics;
@@ -113,19 +108,15 @@
struct ViewportAttributes;
struct WindowFeatures;
-template <typename> class BoxExtent;
-using FloatBoxExtent = BoxExtent<float>;
-}
+template <typename> class RectEdges;
+using FloatBoxExtent = RectEdges<float>;
#if PLATFORM(COCOA)
-namespace WebCore {
class MachSendRight;
struct KeypressCommand;
-}
#endif
#if PLATFORM(IOS)
-namespace WebCore {
class FloatQuad;
class SelectionRect;
struct Highlight;
@@ -132,51 +123,37 @@
struct PasteboardImage;
struct PasteboardWebContent;
struct ViewportArguments;
-}
#endif
#if USE(SOUP)
-namespace WebCore {
struct SoupNetworkProxySettings;
-}
#endif
#if PLATFORM(WPE)
-namespace WebCore {
-struct PasteboardWebContents;
-}
+struct PasteboardWebContent;
#endif
#if ENABLE(CONTENT_FILTERING)
-namespace WebCore {
class ContentFilterUnblockHandler;
-}
#endif
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-namespace WebCore {
class MediaPlaybackTargetContext;
-}
#endif
#if ENABLE(MEDIA_SESSION)
-namespace WebCore {
class MediaSessionMetadata;
-}
#endif
#if ENABLE(MEDIA_STREAM)
-namespace WebCore {
class CaptureDevice;
struct MediaConstraints;
-}
#endif
#if ENABLE(INDEXED_DATABASE)
-namespace WebCore {
using IDBKeyPath = Variant<String, Vector<String>>;
+#endif
}
-#endif
namespace IPC {
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (221865 => 221866)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2017-09-11 17:57:55 UTC (rev 221866)
@@ -170,8 +170,8 @@
enum class NotificationDirection;
enum class ShouldSample;
-template <typename> class BoxExtent;
-using FloatBoxExtent = BoxExtent<float>;
+template <typename> class RectEdges;
+using FloatBoxExtent = RectEdges<float>;
}
#if PLATFORM(GTK)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (221865 => 221866)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2017-09-11 17:57:55 UTC (rev 221866)
@@ -384,7 +384,7 @@
#if PLATFORM(IOS)
DynamicViewportUpdateChangedTarget(double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t dynamicViewportSizeUpdateID)
CouldNotRestorePageState()
- RestorePageState(std::optional<WebCore::FloatPoint> scrollPosition, WebCore::FloatPoint scrollOrigin, WebCore::BoxExtent<float> obscuredInsetsOnSave, double scale)
+ RestorePageState(std::optional<WebCore::FloatPoint> scrollPosition, WebCore::FloatPoint scrollOrigin, WebCore::RectEdges<float> obscuredInsetsOnSave, double scale)
RestorePageCenterAndScale(std::optional<WebCore::FloatPoint> unobscuredCenter, double scale)
DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector<WebCore::FloatQuad> geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (221865 => 221866)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2017-09-11 17:47:44 UTC (rev 221865)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2017-09-11 17:57:55 UTC (rev 221866)
@@ -44,7 +44,7 @@
SetViewportConfigurationMinimumLayoutSize(WebCore::FloatSize size)
SetMaximumUnobscuredSize(WebCore::FloatSize size)
SetDeviceOrientation(int32_t deviceOrientation)
- DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, WebCore::BoxExtent<float> targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
+ DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, WebCore::RectEdges<float> targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
HandleTap(WebCore::IntPoint point, uint64_t lastLayerTreeTransactionId)