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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 2176043002: Collapse away nested anonymous blocks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@467579-3
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/block/collapse-nested-anonymous-block-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
index 8872d9016e7e66048e593dad232b9c7db6ef8038..3c64bb1b1655557d52426935af1fd89df81fb120 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -2403,6 +2403,11 @@ void LayoutBlockFlow::addChild(LayoutObject* newChild, LayoutObject* beforeChild
}
}
+static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block)
+{
+ return block->isAnonymousBlock() && !block->continuation() && !block->beingDestroyed() && !block->isRubyRun() && !block->isRubyBase();
+}
+
void LayoutBlockFlow::removeChild(LayoutObject* oldChild)
{
// No need to waste time in merging or removing empty anonymous blocks.
@@ -2428,11 +2433,12 @@ void LayoutBlockFlow::removeChild(LayoutObject* oldChild)
LayoutBlock::removeChild(oldChild);
LayoutObject* child = prev ? prev : next;
- if (mergedAnonymousBlocks && child && !child->previousSibling() && !child->nextSibling()) {
- // The removal has knocked us down to containing only a single anonymous
- // box. We can go ahead and pull the content right back up into our
+ if (child && child->isLayoutBlockFlow() && !child->previousSibling() && !child->nextSibling()) {
+ // If the removal has knocked us down to containing only a single anonymous
+ // box we can go ahead and pull the content right back up into our
// box.
- collapseAnonymousBlockChild(toLayoutBlockFlow(child));
+ if (mergedAnonymousBlocks || isMergeableAnonymousBlock(toLayoutBlockFlow(child)))
+ collapseAnonymousBlockChild(toLayoutBlockFlow(child));
}
if (!firstChild()) {
@@ -2554,11 +2560,6 @@ void LayoutBlockFlow::collapseAnonymousBlockChild(LayoutBlockFlow* child)
child->destroy();
}
-static bool isMergeableAnonymousBlock(const LayoutBlockFlow* block)
-{
- return block->isAnonymousBlock() && !block->continuation() && !block->beingDestroyed() && !block->isRubyRun() && !block->isRubyBase();
-}
-
bool LayoutBlockFlow::mergeSiblingContiguousAnonymousBlock(LayoutBlockFlow* siblingThatMayBeDeleted)
{
// Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings at this point. There
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/block/collapse-nested-anonymous-block-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698