| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/ng/ng_exclusion.h" | 5 #include "core/layout/ng/ng_exclusion.h" |
| 6 | 6 |
| 7 #include "wtf/text/WTFString.h" | 7 #include "wtf/text/WTFString.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 bool NGExclusion::operator==(const NGExclusion& other) const { | 11 bool NGExclusion::operator==(const NGExclusion& other) const { |
| 12 return std::tie(other.rect, other.type) == std::tie(rect, type); | 12 return std::tie(other.rect, other.type) == std::tie(rect, type); |
| 13 } | 13 } |
| 14 | 14 |
| 15 String NGExclusion::ToString() const { | 15 String NGExclusion::ToString() const { |
| 16 return String::format("Rect: %s Type: %d", rect.ToString().ascii().data(), | 16 return String::format("Rect: %s Type: %d", rect.ToString().ascii().data(), |
| 17 type); | 17 type); |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool NGExclusion::MaybeCombineWith(const NGExclusion& other) { | |
| 21 if (other.rect.BlockEndOffset() < rect.BlockEndOffset()) | |
| 22 return false; | |
| 23 | |
| 24 if (other.type != type) | |
| 25 return false; | |
| 26 | |
| 27 switch (other.type) { | |
| 28 case NGExclusion::kFloatLeft: { | |
| 29 if (other.rect.offset == rect.InlineEndBlockStartOffset()) { | |
| 30 rect.size = {other.rect.InlineSize() + rect.InlineSize(), | |
| 31 other.rect.BlockSize()}; | |
| 32 return true; | |
| 33 } | |
| 34 } | |
| 35 case NGExclusion::kFloatRight: { | |
| 36 if (rect.offset == other.rect.InlineEndBlockStartOffset()) { | |
| 37 rect.offset = other.rect.offset; | |
| 38 rect.size = {other.rect.InlineSize() + rect.InlineSize(), | |
| 39 other.rect.BlockSize()}; | |
| 40 return true; | |
| 41 } | |
| 42 } | |
| 43 default: | |
| 44 NOTREACHED(); | |
| 45 return false; | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 std::ostream& operator<<(std::ostream& stream, const NGExclusion& value) { | 20 std::ostream& operator<<(std::ostream& stream, const NGExclusion& value) { |
| 50 return stream << value.ToString(); | 21 return stream << value.ToString(); |
| 51 } | 22 } |
| 52 | 23 |
| 53 NGExclusions::NGExclusions() | 24 NGExclusions::NGExclusions() |
| 54 : last_left_float(nullptr), last_right_float(nullptr) {} | 25 : last_left_float(nullptr), last_right_float(nullptr) {} |
| 55 | 26 |
| 56 NGExclusions::NGExclusions(const NGExclusions& other) { | 27 NGExclusions::NGExclusions(const NGExclusions& other) { |
| 57 for (const auto& exclusion : other.storage) | 28 for (const auto& exclusion : other.storage) |
| 58 Add(*exclusion); | 29 Add(*exclusion); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 70 inline NGExclusions& NGExclusions::operator=(const NGExclusions& other) { | 41 inline NGExclusions& NGExclusions::operator=(const NGExclusions& other) { |
| 71 storage.clear(); | 42 storage.clear(); |
| 72 last_left_float = nullptr; | 43 last_left_float = nullptr; |
| 73 last_right_float = nullptr; | 44 last_right_float = nullptr; |
| 74 for (const auto& exclusion : other.storage) | 45 for (const auto& exclusion : other.storage) |
| 75 Add(*exclusion); | 46 Add(*exclusion); |
| 76 return *this; | 47 return *this; |
| 77 } | 48 } |
| 78 | 49 |
| 79 } // namespace blink | 50 } // namespace blink |
| OLD | NEW |