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

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_exclusion.cc

Issue 2733133002: Combine 2 exclusions in Layout Opportunity Tree if they shadow each other (Closed)
Patch Set: delete unreachable return statement 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 side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698