Diff
Modified: trunk/Source/WebCore/ChangeLog (291406 => 291407)
--- trunk/Source/WebCore/ChangeLog 2022-03-17 14:46:39 UTC (rev 291406)
+++ trunk/Source/WebCore/ChangeLog 2022-03-17 15:13:14 UTC (rev 291407)
@@ -1,3 +1,47 @@
+2022-03-17 Oriol Brufau <obru...@igalia.com>
+
+ Clarify code for logical-to-physical mappings, and add physical-to-logical mappings
+ https://bugs.webkit.org/show_bug.cgi?id=237967
+
+ Reviewed by Darin Adler.
+
+ The code for logical-to-physical mappings wasn't easy to understand, e.g.
+ mapLogicalSideToPhysicalSide used to cast a LogicalBoxSide enum into a
+ BoxSide enum, and then maybe casting it into an int and back to BoxSide.
+ So the code relied on the arbitrary order of the enum values, and it was
+ hard to grasp what was going on.
+
+ This patch makes these mappings much clearer, and also adds the inverse
+ physical-to-logical mappings. Being able to convert a physical property
+ into its logical equivalent will be needed for bug 236199.
+
+ No new tests because there is no change in behavior.
+
+ Tests in imported/w3c/web-platform-tests/css/css-logical/ ensure that
+ this patch doesn't break logical-to-physical mappings.
+ Some new API tests ensure that the physical-to-logical mappings
+ are the correct inverse.
+
+ Tests: WritingMode.LogicalBoxSide
+ WritingMode.BoxSide
+ WritingMode.LogicalBoxCorner
+ WritingMode.BoxCorner
+ WritingMode.LogicalBoxAxis
+ WritingMode.BoxAxis
+
+ * css/CSSProperty.h:
+ * css/makeprop.pl:
+ * platform/text/WritingMode.h:
+ (WebCore::mapLogicalSideToPhysicalSide):
+ (WebCore::mapPhysicalSideToLogicalSide):
+ (WebCore::mapLogicalCornerToPhysicalCorner):
+ (WebCore::mapPhysicalCornerToLogicalCorner):
+ (WebCore::mapLogicalAxisToPhysicalAxis):
+ (WebCore::mapPhysicalAxisToLogicalAxis):
+ (WebCore::isHorizontalPhysicalSide): Deleted.
+ (WebCore::mirrorPhysicalSide): Deleted.
+ (WebCore::rotatePhysicalSide): Deleted.
+
2022-03-17 Nikolas Zimmermann <nzimmerm...@igalia.com>
Build broken on macOS Monterey 12.3 - PassKitSPI related error
Modified: trunk/Source/WebCore/css/CSSProperty.h (291406 => 291407)
--- trunk/Source/WebCore/css/CSSProperty.h 2022-03-17 14:46:39 UTC (rev 291406)
+++ trunk/Source/WebCore/css/CSSProperty.h 2022-03-17 15:13:14 UTC (rev 291407)
@@ -77,6 +77,7 @@
void wrapValueInCommaSeparatedList();
static CSSPropertyID resolveDirectionAwareProperty(CSSPropertyID, TextDirection, WritingMode);
+ static CSSPropertyID unresolvePhysicalProperty(CSSPropertyID, TextDirection, WritingMode);
static bool isInheritedProperty(CSSPropertyID);
static Vector<String> aliasesForProperty(CSSPropertyID);
static bool isDirectionAwareProperty(CSSPropertyID);
Modified: trunk/Source/WebCore/css/makeprop.pl (291406 => 291407)
--- trunk/Source/WebCore/css/makeprop.pl 2022-03-17 14:46:39 UTC (rev 291406)
+++ trunk/Source/WebCore/css/makeprop.pl 2022-03-17 15:13:14 UTC (rev 291407)
@@ -716,7 +716,7 @@
CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyID, TextDirection direction, WritingMode writingMode)
{
- const TextFlow& textflow = makeTextFlow(writingMode, direction);
+ auto textflow = makeTextFlow(writingMode, direction);
switch (propertyID) {
EOF
@@ -741,6 +741,32 @@
}
}
+CSSPropertyID CSSProperty::unresolvePhysicalProperty(CSSPropertyID propertyID, TextDirection direction, WritingMode writingMode)
+{
+ auto textflow = makeTextFlow(writingMode, direction);
+ switch (propertyID) {
+EOF
+
+for my $logicalPropertyGroup (values %logicalPropertyGroups) {
+ while (my ($resolver, $name) = each %{ $logicalPropertyGroup->{"physical"} }) {
+ my $kind = $logicalPropertyGroup->{"kind"};
+ my $kindId = nameToId($kind);
+ my $resolverEnum = "Box" . $kindId . "::" . nameToId($resolver);
+ my $logicals = $logicalPropertyGroupResolvers{"logical"}->{$kind};
+ my @properties = map { "CSSProperty" . $nameToId{$logicalPropertyGroup->{"logical"}{$_}} } @{ $logicals };
+ print GPERF " case CSSPropertyID::CSSProperty" . $nameToId{$name} . ": {\n";
+ print GPERF " static constexpr CSSPropertyID properties[" . scalar(@properties) . "] = { " . join(", ", @properties) . " };\n";
+ print GPERF " return properties[static_cast<size_t>(mapPhysical" . $kindId . "ToLogical" . $kindId . "(textflow, " . $resolverEnum . "))];\n";
+ print GPERF " }\n";
+ }
+}
+
+print GPERF << "EOF";
+ default:
+ return propertyID;
+ }
+}
+
bool CSSProperty::isDescriptorOnly(CSSPropertyID id)
{
switch (id) {
Modified: trunk/Source/WebCore/platform/text/WritingMode.h (291406 => 291407)
--- trunk/Source/WebCore/platform/text/WritingMode.h 2022-03-17 14:46:39 UTC (rev 291406)
+++ trunk/Source/WebCore/platform/text/WritingMode.h 2022-03-17 15:13:14 UTC (rev 291407)
@@ -128,6 +128,9 @@
Left
};
+// The mapping is with the first start/end giving the block axis side,
+// and the second the inline-axis side, e.g LogicalBoxCorner::StartEnd is
+// the corner between LogicalBoxSide::BlockStart and LogicalBoxSide::InlineEnd.
enum class LogicalBoxCorner : uint8_t {
StartStart,
StartEnd,
@@ -135,8 +138,6 @@
EndEnd
};
-// The mapping is with the first start/end giving the block axis side,
-// and the second the inline-axis side, i.e. patterned as 'border-block-inline-radius'.
enum class BoxCorner : uint8_t {
TopLeft,
TopRight,
@@ -156,64 +157,77 @@
constexpr std::array<BoxSide, 4> allBoxSides = { BoxSide::Top, BoxSide::Right, BoxSide::Bottom, BoxSide::Left };
-constexpr inline bool isHorizontalPhysicalSide(BoxSide physicalSide)
+constexpr BoxSide mapLogicalSideToPhysicalSide(TextFlow textflow, LogicalBoxSide logicalSide)
{
- return physicalSide == BoxSide::Left || physicalSide == BoxSide::Right;
+ bool isBlock = logicalSide == LogicalBoxSide::BlockStart || logicalSide == LogicalBoxSide::BlockEnd;
+ bool isStart = logicalSide == LogicalBoxSide::BlockStart || logicalSide == LogicalBoxSide::InlineStart;
+ bool isNormalStart = isStart != (isBlock ? isFlippedTextFlow(textflow) : isReversedTextFlow(textflow));
+ bool isVertical = isBlock != isVerticalTextFlow(textflow);
+ if (isVertical)
+ return isNormalStart ? BoxSide::Top : BoxSide::Bottom;
+ return isNormalStart ? BoxSide::Left : BoxSide::Right;
}
-constexpr inline BoxSide mirrorPhysicalSide(BoxSide physicalSide)
+constexpr BoxSide mapLogicalSideToPhysicalSide(WritingMode writingMode, LogicalBoxSide logicalSide)
{
- // top <-> bottom and left <-> right conversion
- return static_cast<BoxSide>((static_cast<int>(physicalSide) + 2) % 4);
+ // Set the direction such that side is mirrored if isFlippedWritingMode() is true
+ TextDirection direction = isFlippedWritingMode(writingMode) ? TextDirection::RTL : TextDirection::LTR;
+ return mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), logicalSide);
}
-constexpr inline BoxSide rotatePhysicalSide(BoxSide physicalSide)
+constexpr LogicalBoxSide mapPhysicalSideToLogicalSide(TextFlow textflow, BoxSide side)
{
- // top <-> left and right <-> bottom conversion
- bool horizontalSide = isHorizontalPhysicalSide(physicalSide);
- return static_cast<BoxSide>((static_cast<int>(physicalSide) + (horizontalSide ? 1 : 3)) % 4);
+ bool isNormalStart = side == BoxSide::Top || side == BoxSide::Left;
+ bool isVertical = side == BoxSide::Top || side == BoxSide::Bottom;
+ bool isBlock = isVertical != isVerticalTextFlow(textflow);
+ if (isBlock) {
+ bool isBlockStart = isNormalStart != isFlippedTextFlow(textflow);
+ return isBlockStart ? LogicalBoxSide::BlockStart : LogicalBoxSide::BlockEnd;
+ }
+ bool isInlineStart = isNormalStart != isReversedTextFlow(textflow);
+ return isInlineStart ? LogicalBoxSide::InlineStart : LogicalBoxSide::InlineEnd;
}
-constexpr inline BoxSide mapLogicalSideToPhysicalSide(TextFlow textflow, LogicalBoxSide logicalSide)
+constexpr BoxCorner mapLogicalCornerToPhysicalCorner(TextFlow textflow, LogicalBoxCorner logicalBoxCorner)
{
- BoxSide physicalSide = static_cast<BoxSide>(logicalSide);
- bool horizontalSide = isHorizontalPhysicalSide(physicalSide);
-
- if (isVerticalTextFlow(textflow))
- physicalSide = rotatePhysicalSide(physicalSide);
-
- if ((horizontalSide && isReversedTextFlow(textflow)) || (!horizontalSide && isFlippedTextFlow(textflow)))
- physicalSide = mirrorPhysicalSide(physicalSide);
-
- return physicalSide;
+ bool isBlockStart = logicalBoxCorner == LogicalBoxCorner::StartStart || logicalBoxCorner == LogicalBoxCorner::StartEnd;
+ bool isInlineStart = logicalBoxCorner == LogicalBoxCorner::StartStart || logicalBoxCorner == LogicalBoxCorner::EndStart;
+ bool isNormalBlockStart = isBlockStart != isFlippedTextFlow(textflow);
+ bool isNormalInlineStart = isInlineStart != isReversedTextFlow(textflow);
+ bool usingVerticalTextFlow = isVerticalTextFlow(textflow);
+ bool isTop = usingVerticalTextFlow ? isNormalInlineStart : isNormalBlockStart;
+ bool isLeft = usingVerticalTextFlow ? isNormalBlockStart : isNormalInlineStart;
+ if (isTop)
+ return isLeft ? BoxCorner::TopLeft : BoxCorner::TopRight;
+ return isLeft ? BoxCorner::BottomLeft : BoxCorner::BottomRight;
}
-constexpr inline BoxSide mapLogicalSideToPhysicalSide(WritingMode writingMode, LogicalBoxSide logicalSide)
+constexpr LogicalBoxCorner mapPhysicalCornerToLogicalCorner(TextFlow textflow, BoxCorner boxCorner)
{
- // Set the direction such that side is mirrored if isFlippedWritingMode() is true
- TextDirection direction = isFlippedWritingMode(writingMode) ? TextDirection::RTL : TextDirection::LTR;
- return mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), logicalSide);
+ bool isTop = boxCorner == BoxCorner::TopLeft || boxCorner == BoxCorner::TopRight;
+ bool isLeft = boxCorner == BoxCorner::TopLeft || boxCorner == BoxCorner::BottomLeft;
+ bool usingVerticalTextFlow = isVerticalTextFlow(textflow);
+ bool isNormalBlockStart = usingVerticalTextFlow ? isLeft : isTop;
+ bool isNormalInlineStart = usingVerticalTextFlow ? isTop : isLeft;
+ bool isBlockStart = isNormalBlockStart != isFlippedTextFlow(textflow);
+ bool isInlineStart = isNormalInlineStart != isReversedTextFlow(textflow);
+ if (isBlockStart)
+ return isInlineStart ? LogicalBoxCorner::StartStart : LogicalBoxCorner::StartEnd;
+ return isInlineStart ? LogicalBoxCorner::EndStart : LogicalBoxCorner::EndEnd;
}
-constexpr inline BoxCorner mapLogicalCornerToPhysicalCorner(TextFlow textflow, LogicalBoxCorner logicalBoxCorner)
+constexpr BoxAxis mapLogicalAxisToPhysicalAxis(TextFlow textflow, LogicalBoxAxis logicalAxis)
{
- bool isBlockStart = logicalBoxCorner == LogicalBoxCorner::StartStart || logicalBoxCorner == LogicalBoxCorner::StartEnd;
- bool isInlineStart = logicalBoxCorner == LogicalBoxCorner::StartStart || logicalBoxCorner == LogicalBoxCorner::EndStart;
- if (isBlockStart == isFlippedTextFlow(textflow)) {
- if (isInlineStart == isReversedTextFlow(textflow))
- return BoxCorner::BottomRight;
- } else if (isInlineStart != isReversedTextFlow(textflow))
- return BoxCorner::TopLeft;
- if (isBlockStart == isFlippedLinesTextFlow(textflow))
- return BoxCorner::BottomLeft;
- return BoxCorner::TopRight;
+ bool isBlock = logicalAxis == LogicalBoxAxis::Block;
+ bool isVertical = isBlock != isVerticalTextFlow(textflow);
+ return isVertical ? BoxAxis::Vertical : BoxAxis::Horizontal;
}
-constexpr inline BoxAxis mapLogicalAxisToPhysicalAxis(TextFlow textflow, LogicalBoxAxis logicalAxis)
+constexpr LogicalBoxAxis mapPhysicalAxisToLogicalAxis(TextFlow textflow, BoxAxis axis)
{
- if (isVerticalTextFlow(textflow))
- return logicalAxis == LogicalBoxAxis::Inline ? BoxAxis::Vertical : BoxAxis::Horizontal;
- return logicalAxis == LogicalBoxAxis::Inline ? BoxAxis::Horizontal : BoxAxis::Vertical;
+ bool isVertical = axis == BoxAxis::Vertical;
+ bool isBlock = isVertical != isVerticalTextFlow(textflow);
+ return isBlock ? LogicalBoxAxis::Block : LogicalBoxAxis::Inline;
}
} // namespace WebCore
Modified: trunk/Tools/ChangeLog (291406 => 291407)
--- trunk/Tools/ChangeLog 2022-03-17 14:46:39 UTC (rev 291406)
+++ trunk/Tools/ChangeLog 2022-03-17 15:13:14 UTC (rev 291407)
@@ -1,3 +1,17 @@
+2022-03-17 Oriol Brufau <obru...@igalia.com>
+
+ Clarify code for logical-to-physical mappings, and add physical-to-logical mappings
+ https://bugs.webkit.org/show_bug.cgi?id=237967
+
+ Reviewed by Darin Adler.
+
+ Add tests.
+
+ * TestWebKitAPI/CMakeLists.txt:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebCore/WritingModeTests.cpp: Added.
+ (TestWebKitAPI::TEST):
+
2022-03-17 Aakash Jain <aakash_j...@apple.com>
XSS in EWS App
Modified: trunk/Tools/TestWebKitAPI/CMakeLists.txt (291406 => 291407)
--- trunk/Tools/TestWebKitAPI/CMakeLists.txt 2022-03-17 14:46:39 UTC (rev 291406)
+++ trunk/Tools/TestWebKitAPI/CMakeLists.txt 2022-03-17 15:13:14 UTC (rev 291407)
@@ -198,6 +198,7 @@
Tests/WebCore/TimeRanges.cpp
Tests/WebCore/TransformationMatrix.cpp
Tests/WebCore/URLParserTextEncoding.cpp
+ Tests/WebCore/WritingModeTests.cpp
)
set(TestWebCore_LIBRARIES
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (291406 => 291407)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-03-17 14:46:39 UTC (rev 291406)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-03-17 15:13:14 UTC (rev 291407)
@@ -189,6 +189,7 @@
33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; };
33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */; };
+ 3545E58927E2AD1300F1910E /* WritingModeTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3545E58827E2AD1200F1910E /* WritingModeTests.cpp */; };
37137E4B21124D01002BEEA4 /* AttrStyle.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 3760C4F221124BD000233ACC /* AttrStyle.html */; };
374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 374B7A5F1DF36EEE00ACCB6C /* BundleEditingDelegatePlugIn.mm */; };
378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */; };
@@ -1933,6 +1934,7 @@
33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCanceledNoServerRedirectCallback.cpp; sourceTree = "<group>"; };
33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCanceledNoServerRedirectCallback_Bundle.cpp; sourceTree = "<group>"; };
33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "mouse-move-listener.html"; sourceTree = "<group>"; };
+ 3545E58827E2AD1200F1910E /* WritingModeTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WritingModeTests.cpp; sourceTree = "<group>"; };
370CE2291F57343400E7410B /* WKContentViewTargetForAction.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentViewTargetForAction.mm; sourceTree = "<group>"; };
371195AA1FE5797700A1FB92 /* WKWebViewAlwaysShowsScroller.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewAlwaysShowsScroller.mm; sourceTree = "<group>"; };
37119A7F20CCB695002C6DC9 /* WebKitTargetConditionals.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WebKitTargetConditionals.xcconfig; sourceTree = "<group>"; };
@@ -3849,6 +3851,7 @@
7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */,
57D1D75E21DCB7A80093E86A /* U2fCommandConstructorTest.cpp */,
E3A1E77E21B25B39008C6007 /* URLParserTextEncoding.cpp */,
+ 3545E58827E2AD1200F1910E /* WritingModeTests.cpp */,
5C581D3127C8A01C006B3BC4 /* YouTubePluginReplacement.cpp */,
);
path = WebCore;
@@ -5960,6 +5963,7 @@
E520A36B25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm in Sources */,
7C74C8FA22DFBA9600DA2DAB /* WTFStringUtilities.cpp in Sources */,
C14D304624B4C3BA00480387 /* XPCEndpoint.mm in Sources */,
+ 3545E58927E2AD1300F1910E /* WritingModeTests.cpp in Sources */,
5C581D3227C8A01C006B3BC4 /* YouTubePluginReplacement.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/WritingModeTests.cpp (0 => 291407)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/WritingModeTests.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/WritingModeTests.cpp 2022-03-17 15:13:14 UTC (rev 291407)
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2022 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+#include "config.h"
+
+#include <WebCore/WritingMode.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+constexpr std::array<TextFlow, 8> allTextFlows = {
+ InlineEastBlockSouth,
+ InlineWestBlockSouth,
+ InlineEastBlockNorth,
+ InlineWestBlockNorth,
+ InlineSouthBlockEast,
+ InlineSouthBlockWest,
+ InlineNorthBlockEast,
+ InlineNorthBlockWest,
+};
+
+TEST(WritingMode, LogicalBoxSide)
+{
+ auto mapBackAndForth = [](TextFlow textFlow, LogicalBoxSide logicalSide) {
+ return mapPhysicalSideToLogicalSide(textFlow, mapLogicalSideToPhysicalSide(textFlow, logicalSide));
+ };
+ for (TextFlow textFlow : allTextFlows) {
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxSide::BlockStart), LogicalBoxSide::BlockStart) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxSide::BlockEnd), LogicalBoxSide::BlockEnd) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxSide::InlineStart), LogicalBoxSide::InlineStart) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxSide::InlineEnd), LogicalBoxSide::InlineEnd) << "with textFlow=" << textFlow;
+ }
+}
+
+TEST(WritingMode, BoxSide)
+{
+ auto mapBackAndForth = [](TextFlow textFlow, BoxSide side) {
+ return mapLogicalSideToPhysicalSide(textFlow, mapPhysicalSideToLogicalSide(textFlow, side));
+ };
+ for (TextFlow textFlow : allTextFlows) {
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxSide::Top), BoxSide::Top) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxSide::Right), BoxSide::Right) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxSide::Bottom), BoxSide::Bottom) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxSide::Left), BoxSide::Left) << "with textFlow=" << textFlow;
+ }
+}
+
+TEST(WritingMode, LogicalBoxCorner)
+{
+ auto mapBackAndForth = [](TextFlow textFlow, LogicalBoxCorner logicalCorner) {
+ return mapPhysicalCornerToLogicalCorner(textFlow, mapLogicalCornerToPhysicalCorner(textFlow, logicalCorner));
+ };
+ for (TextFlow textFlow : allTextFlows) {
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxCorner::StartStart), LogicalBoxCorner::StartStart) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxCorner::StartEnd), LogicalBoxCorner::StartEnd) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxCorner::EndStart), LogicalBoxCorner::EndStart) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxCorner::EndEnd), LogicalBoxCorner::EndEnd) << "with textFlow=" << textFlow;
+ }
+}
+
+TEST(WritingMode, BoxCorner)
+{
+ auto mapBackAndForth = [](TextFlow textFlow, BoxCorner corner) {
+ return mapLogicalCornerToPhysicalCorner(textFlow, mapPhysicalCornerToLogicalCorner(textFlow, corner));
+ };
+ for (TextFlow textFlow : allTextFlows) {
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxCorner::TopLeft), BoxCorner::TopLeft) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxCorner::TopRight), BoxCorner::TopRight) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxCorner::BottomRight), BoxCorner::BottomRight) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxCorner::BottomLeft), BoxCorner::BottomLeft) << "with textFlow=" << textFlow;
+ }
+}
+
+TEST(WritingMode, LogicalBoxAxis)
+{
+ auto mapBackAndForth = [](TextFlow textFlow, LogicalBoxAxis logicalAxis) {
+ return mapPhysicalAxisToLogicalAxis(textFlow, mapLogicalAxisToPhysicalAxis(textFlow, logicalAxis));
+ };
+ for (TextFlow textFlow : allTextFlows) {
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxAxis::Block), LogicalBoxAxis::Block) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, LogicalBoxAxis::Inline), LogicalBoxAxis::Inline) << "with textFlow=" << textFlow;
+ }
+}
+
+TEST(WritingMode, BoxAxis)
+{
+ auto mapBackAndForth = [](TextFlow textFlow, BoxAxis axis) {
+ return mapLogicalAxisToPhysicalAxis(textFlow, mapPhysicalAxisToLogicalAxis(textFlow, axis));
+ };
+ for (TextFlow textFlow : allTextFlows) {
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxAxis::Horizontal), BoxAxis::Horizontal) << "with textFlow=" << textFlow;
+ EXPECT_EQ(mapBackAndForth(textFlow, BoxAxis::Vertical), BoxAxis::Vertical) << "with textFlow=" << textFlow;
+ }
+}
+
+}