Index: third_party/WebKit/Source/core/layout/ng/ng_exclusion.cc |
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_exclusion.cc b/third_party/WebKit/Source/core/layout/ng/ng_exclusion.cc |
index e5f711bacb67d42b1452d8de0fdf2610c7a8d14f..28e9a58601e6722e5a890ecdaf6803729ddd2eda 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/ng_exclusion.cc |
+++ b/third_party/WebKit/Source/core/layout/ng/ng_exclusion.cc |
@@ -17,6 +17,35 @@ String NGExclusion::ToString() const { |
type); |
} |
+bool NGExclusion::MaybeCombineWith(const NGExclusion& other) { |
+ if (other.rect.BlockEndOffset() < rect.BlockEndOffset()) |
+ return false; |
+ |
+ if (other.type != type) |
+ return false; |
+ |
+ switch (other.type) { |
+ case NGExclusion::kFloatLeft: { |
+ if (other.rect.offset == rect.InlineEndBlockStartOffset()) { |
+ rect.size = {other.rect.InlineSize() + rect.InlineSize(), |
+ other.rect.BlockSize()}; |
+ return true; |
+ } |
+ } |
+ case NGExclusion::kFloatRight: { |
+ if (rect.offset == other.rect.InlineEndBlockStartOffset()) { |
+ rect.offset = other.rect.offset; |
+ rect.size = {other.rect.InlineSize() + rect.InlineSize(), |
+ other.rect.BlockSize()}; |
+ return true; |
+ } |
+ } |
+ default: |
+ NOTREACHED(); |
+ return false; |
+ } |
+} |
+ |
std::ostream& operator<<(std::ostream& stream, const NGExclusion& value) { |
return stream << value.ToString(); |
} |