Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_units.cc

Issue 2489953006: Utility routines for ng_units (Closed)
Patch Set: Added missing CORE_EXPORT Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 279ba7a495afd94ac777e28d457e878aa5ac4521..9eeb013444c07937f2cb49f21cd1344e1119a173 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_units.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_units.cc
@@ -8,6 +8,10 @@
namespace blink {
+LayoutUnit MinAndMaxContentSizes::ShrinkToFit(LayoutUnit available_size) const {
+ return std::min(max_content, std::max(min_content, available_size));
+}
+
NGPhysicalSize NGLogicalSize::ConvertToPhysical(NGWritingMode mode) const {
return mode == HorizontalTopBottom ? NGPhysicalSize(inline_size, block_size)
: NGPhysicalSize(block_size, inline_size);
@@ -139,6 +143,31 @@ bool NGBoxStrut::operator==(const NGBoxStrut& other) const {
std::tie(inline_start, inline_end, block_start, block_end);
}
+// Converts physical dimensions to logical ones per
+// https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical
+NGBoxStrut NGPhysicalBoxStrut::ConvertToLogical(NGWritingMode writing_mode,
+ TextDirection direction) const {
+ NGBoxStrut strut;
+ switch (writing_mode) {
+ case HorizontalTopBottom:
+ strut = {left, right, top, bottom};
+ break;
+ case VerticalRightLeft:
+ case SidewaysRightLeft:
+ strut = {top, bottom, right, left};
+ break;
+ case VerticalLeftRight:
+ strut = {top, bottom, left, right};
+ break;
+ case SidewaysLeftRight:
+ strut = {bottom, top, left, right};
+ break;
+ }
+ if (direction == RTL)
+ std::swap(strut.inline_start, strut.inline_end);
+ return strut;
+}
+
LayoutUnit NGMarginStrut::BlockEndSum() const {
return margin_block_end + negative_margin_block_end;
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_units.h ('k') | third_party/WebKit/Source/core/layout/ng/ng_units_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698