Index: third_party/WebKit/Source/core/layout/ng/ng_units.cc |
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_units.cc b/third_party/WebKit/Source/core/layout/ng/ng_units.cc |
index 2e515a8c53e60806a6cae10ef86e47ff8be4b791..6b4035c72f13af7af01fdfa7e65842ea7558745c 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/ng_units.cc |
+++ b/third_party/WebKit/Source/core/layout/ng/ng_units.cc |
@@ -134,6 +134,16 @@ String NGLogicalOffset::ToString() const { |
return String::format("%dx%d", inline_offset.toInt(), block_offset.toInt()); |
} |
+NGPhysicalOffset NGPhysicalOffset::operator+( |
+ const NGPhysicalOffset& other) const { |
+ return NGPhysicalOffset{this->left + other.left, this->top + other.top}; |
+} |
+ |
+NGPhysicalOffset& NGPhysicalOffset::operator+=(const NGPhysicalOffset& other) { |
+ *this = *this + other; |
+ return *this; |
+} |
+ |
bool NGBoxStrut::IsEmpty() const { |
return *this == NGBoxStrut(); |
} |
@@ -226,4 +236,27 @@ bool NGMarginStrut::operator==(const NGMarginStrut& other) const { |
negative_margin_block_start, negative_margin_block_end); |
} |
+NGStaticPosition NGStaticPosition::Create(NGWritingMode writing_mode, |
+ TextDirection direction, |
+ NGPhysicalOffset offset) { |
+ NGStaticPosition position; |
+ position.offset = offset; |
+ switch (writing_mode) { |
+ case kHorizontalTopBottom: |
+ position.type = (direction == LTR) ? kTopLeft : kTopRight; |
+ break; |
+ case kVerticalRightLeft: |
+ case kSidewaysRightLeft: |
+ position.type = (direction == LTR) ? kTopRight : kBottomRight; |
+ break; |
+ case kVerticalLeftRight: |
+ position.type = (direction == LTR) ? kTopLeft : kBottomLeft; |
+ break; |
+ case kSidewaysLeftRight: |
+ position.type = (direction == LTR) ? kBottomLeft : kTopLeft; |
+ break; |
+ } |
+ return position; |
+} |
+ |
} // namespace blink |