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

Unified Diff: Source/core/rendering/RenderBlock.cpp

Issue 875563003: Ensure that positioned objects' list is always in parent first order (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 | « LayoutTests/fast/dynamic/position-fixed-to-absolute-with-positioned-child-crash-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlock.cpp
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index 5f6519f77ca37901b568e9e161b136a5bb61ffc1..ef9da4cc129dc5eecf635f9e4c4c3e0338a767b3 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -1939,13 +1939,28 @@ void RenderBlock::insertIntoTrackedRendererMaps(RenderBox* descendant, TrackedDe
descendantSet = new TrackedRendererListHashSet;
descendantsMap->set(this, adoptPtr(descendantSet));
}
- bool added = descendantSet->add(descendant).isNewEntry;
- if (!added) {
+
+ if (descendantSet->contains(descendant)) {
ASSERT(containerMap->get(descendant));
ASSERT(containerMap->get(descendant)->contains(this));
return;
}
+ // Try to insert parent before child, as layoutPositionedObjects relies on 'parent first' ordering.
+ bool didInsertDescendant = false;
+ if (descendant->isRenderBlock()) {
+ TrackedRendererListHashSet::iterator end = descendantSet->end();
+ for (TrackedRendererListHashSet::iterator it = descendantSet->begin(); it != end; ++it) {
+ RenderBox* box = *it;
+ if (box->isDescendantOf(descendant)) {
Julien - ping for review 2015/01/27 14:47:46 This check is expensive as it involves walking the
alexanderk 2015/01/28 14:15:27 Right, isDescendantOf() is expensive. And optimiza
+ didInsertDescendant = descendantSet->insertBefore(box, descendant).isNewEntry;
+ break;
+ }
+ }
+ }
+ if (!didInsertDescendant)
+ descendantSet->add(descendant);
Julien - ping for review 2015/01/27 14:47:46 I think descendantSet->insertBefore() should be ab
alexanderk 2015/01/28 14:15:27 Unfortunately insertBefore() does not move already
+
HashSet<RenderBlock*>* containerSet = containerMap->get(descendant);
if (!containerSet) {
containerSet = new HashSet<RenderBlock*>;
« no previous file with comments | « LayoutTests/fast/dynamic/position-fixed-to-absolute-with-positioned-child-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698