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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/geometry/ng_box_strut.cc

Issue 2721613003: [LayoutNG] Move remaining ng_units structs to their own files (Closed)
Patch Set: Don't export NGBoxStrut for now Created 3 years, 9 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/geometry/ng_box_strut.h"
6
7 #include "wtf/text/WTFString.h"
8
9 namespace blink {
10
11 bool NGBoxStrut::IsEmpty() const {
12 return *this == NGBoxStrut();
13 }
14
15 bool NGBoxStrut::operator==(const NGBoxStrut& other) const {
16 return std::tie(other.inline_start, other.inline_end, other.block_start,
17 other.block_end) ==
18 std::tie(inline_start, inline_end, block_start, block_end);
19 }
20
21 // Converts physical dimensions to logical ones per
22 // https://drafts.csswg.org/css-writing-modes-3/#logical-to-physical
23 NGBoxStrut NGPhysicalBoxStrut::ConvertToLogical(NGWritingMode writing_mode,
24 TextDirection direction) const {
25 NGBoxStrut strut;
26 switch (writing_mode) {
27 case kHorizontalTopBottom:
28 strut = {left, right, top, bottom};
29 break;
30 case kVerticalRightLeft:
31 case kSidewaysRightLeft:
32 strut = {top, bottom, right, left};
33 break;
34 case kVerticalLeftRight:
35 strut = {top, bottom, left, right};
36 break;
37 case kSidewaysLeftRight:
38 strut = {bottom, top, left, right};
39 break;
40 }
41 if (direction == TextDirection::kRtl)
42 std::swap(strut.inline_start, strut.inline_end);
43 return strut;
44 }
45
46 String NGBoxStrut::ToString() const {
47 return String::format("Inline: (%d %d) Block: (%d %d)", inline_start.toInt(),
48 inline_end.toInt(), block_start.toInt(),
49 block_end.toInt());
50 }
51
52 std::ostream& operator<<(std::ostream& stream, const NGBoxStrut& value) {
53 return stream << value.ToString();
54 }
55
56 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698