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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/layout/ng/ng_units.h"
6
7 #include "core/layout/ng/ng_writing_mode.h"
8
9 namespace blink {
10
11 NGPhysicalSize NGLogicalSize::ConvertToPhysical(NGWritingMode mode) const {
12 return mode == HorizontalTopBottom ? NGPhysicalSize(inline_size, block_size)
13 : NGPhysicalSize(block_size, inline_size);
14 }
15
16 NGLogicalSize NGPhysicalSize::ConvertToLogical(NGWritingMode mode) const {
17 return mode == HorizontalTopBottom ? NGLogicalSize(width, height)
18 : NGLogicalSize(height, width);
19 }
20
21 NGPhysicalOffset NGLogicalOffset::ConvertToPhysical(
22 NGWritingMode mode,
23 NGDirection direction,
24 NGPhysicalSize container_size,
25 NGPhysicalSize inner_size) const {
26 switch (mode) {
27 case HorizontalTopBottom:
28 if (direction == LeftToRight)
29 return NGPhysicalOffset(inline_offset, block_offset);
30 else
31 return NGPhysicalOffset(
32 container_size.width - inline_offset - inner_size.width,
33 block_offset);
34 case VerticalRightLeft:
35 case SidewaysRightLeft:
36 if (direction == LeftToRight)
37 return NGPhysicalOffset(
38 container_size.width - block_offset - inner_size.width,
39 inline_offset);
40 else
41 return NGPhysicalOffset(
42 container_size.width - block_offset - inner_size.width,
43 container_size.height - inline_offset - inner_size.height);
44 case VerticalLeftRight:
45 if (direction == LeftToRight)
46 return NGPhysicalOffset(block_offset, inline_offset);
47 else
48 return NGPhysicalOffset(
49 block_offset,
50 container_size.height - inline_offset - inner_size.height);
51 case SidewaysLeftRight:
52 if (direction == LeftToRight)
53 return NGPhysicalOffset(
54 block_offset,
55 container_size.height - inline_offset - inner_size.height);
56 else
57 return NGPhysicalOffset(block_offset, inline_offset);
58 default:
59 ASSERT_NOT_REACHED();
60 return NGPhysicalOffset();
61 }
62 }
63
64 } // namespace blink
OLDNEW
« 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