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

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

Issue 2282213002: [LayoutNG] Introduce NGPhysicalFragment and make NGFragment a 'view' (Closed)
Patch Set: address comments. Created 4 years, 4 months 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
new file mode 100644
index 0000000000000000000000000000000000000000..44f760022bc010bdfed88877ce118e97db567795
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/ng/ng_units.cc
@@ -0,0 +1,64 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/layout/ng/ng_units.h"
+
+#include "core/layout/ng/ng_writing_mode.h"
+
+namespace blink {
+
+NGPhysicalSize NGLogicalSize::ConvertToPhysical(NGWritingMode mode) const {
+ return mode == HorizontalTopBottom ? NGPhysicalSize(inline_size, block_size)
+ : NGPhysicalSize(block_size, inline_size);
+}
+
+NGLogicalSize NGPhysicalSize::ConvertToLogical(NGWritingMode mode) const {
+ return mode == HorizontalTopBottom ? NGLogicalSize(width, height)
+ : NGLogicalSize(height, width);
+}
+
+NGPhysicalOffset NGLogicalOffset::ConvertToPhysical(
+ NGWritingMode mode,
+ NGDirection direction,
+ NGPhysicalSize container_size,
+ NGPhysicalSize inner_size) const {
+ switch (mode) {
+ case HorizontalTopBottom:
+ if (direction == LeftToRight)
+ return NGPhysicalOffset(inline_offset, block_offset);
+ else
+ return NGPhysicalOffset(
+ container_size.width - inline_offset - inner_size.width,
+ block_offset);
+ case VerticalRightLeft:
+ case SidewaysRightLeft:
+ if (direction == LeftToRight)
+ return NGPhysicalOffset(
+ container_size.width - block_offset - inner_size.width,
+ inline_offset);
+ else
+ return NGPhysicalOffset(
+ container_size.width - block_offset - inner_size.width,
+ container_size.height - inline_offset - inner_size.height);
+ case VerticalLeftRight:
+ if (direction == LeftToRight)
+ return NGPhysicalOffset(block_offset, inline_offset);
+ else
+ return NGPhysicalOffset(
+ block_offset,
+ container_size.height - inline_offset - inner_size.height);
+ case SidewaysLeftRight:
+ if (direction == LeftToRight)
+ return NGPhysicalOffset(
+ block_offset,
+ container_size.height - inline_offset - inner_size.height);
+ else
+ return NGPhysicalOffset(block_offset, inline_offset);
+ default:
+ ASSERT_NOT_REACHED();
+ return NGPhysicalOffset();
+ }
+}
+
+} // namespace blink
« 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