OLD | NEW |
| (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_exclusion.h" | |
6 | |
7 #include "wtf/text/WTFString.h" | |
8 | |
9 namespace blink { | |
10 | |
11 bool NGExclusion::operator==(const NGExclusion& other) const { | |
12 return std::tie(other.rect, other.type) == std::tie(rect, type); | |
13 } | |
14 | |
15 String NGExclusion::ToString() const { | |
16 return String::format("Rect: %s Type: %d", rect.ToString().ascii().data(), | |
17 type); | |
18 } | |
19 | |
20 std::ostream& operator<<(std::ostream& stream, const NGExclusion& value) { | |
21 return stream << value.ToString(); | |
22 } | |
23 | |
24 NGExclusions::NGExclusions() | |
25 : last_left_float(nullptr), last_right_float(nullptr) {} | |
26 | |
27 NGExclusions::NGExclusions(const NGExclusions& other) { | |
28 for (const auto& exclusion : other.storage) | |
29 Add(*exclusion); | |
30 } | |
31 | |
32 void NGExclusions::Add(const NGExclusion& exclusion) { | |
33 storage.push_back(WTF::makeUnique<NGExclusion>(exclusion)); | |
34 if (exclusion.type == NGExclusion::kFloatLeft) { | |
35 last_left_float = storage.rbegin()->get(); | |
36 } else if (exclusion.type == NGExclusion::kFloatRight) { | |
37 last_right_float = storage.rbegin()->get(); | |
38 } | |
39 } | |
40 | |
41 inline NGExclusions& NGExclusions::operator=(const NGExclusions& other) { | |
42 storage.clear(); | |
43 last_left_float = nullptr; | |
44 last_right_float = nullptr; | |
45 for (const auto& exclusion : other.storage) | |
46 Add(*exclusion); | |
47 return *this; | |
48 } | |
49 | |
50 } // namespace blink | |
OLD | NEW |