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

Side by Side Diff: Source/core/rendering/RenderBlock.cpp

Issue 253313005: Strip anonymous blocks when change in style removes need for them (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return oldStyle->borderTopWidth() != newStyle->borderTopWidth() 337 return oldStyle->borderTopWidth() != newStyle->borderTopWidth()
338 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth() 338 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth()
339 || oldStyle->paddingTop() != newStyle->paddingTop() 339 || oldStyle->paddingTop() != newStyle->paddingTop()
340 || oldStyle->paddingBottom() != newStyle->paddingBottom(); 340 || oldStyle->paddingBottom() != newStyle->paddingBottom();
341 } 341 }
342 342
343 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le) 343 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le)
344 { 344 {
345 RenderBox::styleDidChange(diff, oldStyle); 345 RenderBox::styleDidChange(diff, oldStyle);
346 346
347 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isRenderBlockFlow ())
348 toRenderBlock(parent())->removeAnonymousWrappersIfRequired();
349
347 RenderStyle* newStyle = style(); 350 RenderStyle* newStyle = style();
348 351
349 if (!isAnonymousBlock()) { 352 if (!isAnonymousBlock()) {
350 // Ensure that all of our continuation blocks pick up the new style. 353 // Ensure that all of our continuation blocks pick up the new style.
351 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) { 354 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) {
352 RenderBoxModelObject* nextCont = currCont->continuation(); 355 RenderBoxModelObject* nextCont = currCont->continuation();
353 currCont->setContinuation(0); 356 currCont->setContinuation(0);
354 currCont->setStyle(newStyle); 357 currCont->setStyle(newStyle);
355 currCont->setContinuation(nextCont); 358 currCont->setContinuation(nextCont);
356 } 359 }
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 return false; 1096 return false;
1094 1097
1095 if (!prev || !next) 1098 if (!prev || !next)
1096 return true; 1099 return true;
1097 1100
1098 // Make sure the types of the anonymous blocks match up. 1101 // Make sure the types of the anonymous blocks match up.
1099 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() 1102 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()
1100 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock(); 1103 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock();
1101 } 1104 }
1102 1105
1106 void RenderBlock::removeAnonymousWrappersIfRequired()
1107 {
1108 ASSERT(isRenderBlockFlow());
1109 Vector<RenderBox*, 16> blocksToRemove;
1110 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
1111 // There are still block children in the container, so any anonymous wra ppers are still needed.
1112 if (!child->isAnonymousBlock() && !child->isFloatingOrOutOfFlowPositione d())
1113 return;
1114 // We can't remove anonymous wrappers if they contain continuations as t his means there are block children present.
1115 if (child->isRenderBlock() && toRenderBlock(child)->continuation())
1116 return;
1117 // We are only interested in removing anonymous wrappers if there are in line siblings underneath them.
1118 if (!child->childrenInline())
rhogan 2014/11/10 19:22:57 This addresses the cause of the clusterfuzz crashe
1119 return;
1120 if (child->isAnonymousBlock())
1121 blocksToRemove.append(child);
1122 }
1123
1124 for (size_t i = 0; i < blocksToRemove.size(); i++)
1125 collapseAnonymousBlockChild(this, toRenderBlock(blocksToRemove[i]));
1126 }
1127
1103 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child) 1128 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child)
1104 { 1129 {
1105 // It's possible that this block's destruction may have been triggered by th e 1130 // It's possible that this block's destruction may have been triggered by th e
1106 // child's removal. Just bail if the anonymous child block is already being 1131 // child's removal. Just bail if the anonymous child block is already being
1107 // destroyed. See crbug.com/282088 1132 // destroyed. See crbug.com/282088
1108 if (child->beingDestroyed()) 1133 if (child->beingDestroyed())
1109 return; 1134 return;
1110 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 1135 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
1111 parent->setChildrenInline(child->childrenInline()); 1136 parent->setChildrenInline(child->childrenInline());
1112 RenderObject* nextSibling = child->nextSibling(); 1137 RenderObject* nextSibling = child->nextSibling();
(...skipping 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4361 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 4386 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
4362 { 4387 {
4363 showRenderObject(); 4388 showRenderObject();
4364 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 4389 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
4365 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 4390 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
4366 } 4391 }
4367 4392
4368 #endif 4393 #endif
4369 4394
4370 } // namespace blink 4395 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698