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

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
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 return oldStyle->borderTopWidth() != newStyle->borderTopWidth() 338 return oldStyle->borderTopWidth() != newStyle->borderTopWidth()
339 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth() 339 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth()
340 || oldStyle->paddingTop() != newStyle->paddingTop() 340 || oldStyle->paddingTop() != newStyle->paddingTop()
341 || oldStyle->paddingBottom() != newStyle->paddingBottom(); 341 || oldStyle->paddingBottom() != newStyle->paddingBottom();
342 } 342 }
343 343
344 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le) 344 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le)
345 { 345 {
346 RenderBox::styleDidChange(diff, oldStyle); 346 RenderBox::styleDidChange(diff, oldStyle);
347 347
348 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isRenderBlockFlow ())
349 toRenderBlock(parent())->removeAnonymousWrappersIfRequired();
350
348 RenderStyle* newStyle = style(); 351 RenderStyle* newStyle = style();
349 352
350 if (!isAnonymousBlock()) { 353 if (!isAnonymousBlock()) {
351 // Ensure that all of our continuation blocks pick up the new style. 354 // Ensure that all of our continuation blocks pick up the new style.
352 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) { 355 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) {
353 RenderBoxModelObject* nextCont = currCont->continuation(); 356 RenderBoxModelObject* nextCont = currCont->continuation();
354 currCont->setContinuation(0); 357 currCont->setContinuation(0);
355 currCont->setStyle(newStyle); 358 currCont->setStyle(newStyle);
356 currCont->setContinuation(nextCont); 359 currCont->setContinuation(nextCont);
357 } 360 }
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 return false; 1097 return false;
1095 1098
1096 if (!prev || !next) 1099 if (!prev || !next)
1097 return true; 1100 return true;
1098 1101
1099 // Make sure the types of the anonymous blocks match up. 1102 // Make sure the types of the anonymous blocks match up.
1100 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() 1103 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()
1101 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock(); 1104 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock();
1102 } 1105 }
1103 1106
1107 void RenderBlock::removeAnonymousWrappersIfRequired()
1108 {
1109 ASSERT(isRenderBlockFlow());
1110 Vector<RenderBox*, 16> blocksToRemove;
1111 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
1112 // There are still block children in the container, so any anonymous wra ppers are still needed.
1113 if (!child->isAnonymousBlock() && !child->isFloatingOrOutOfFlowPositione d())
1114 return;
1115 // We can't remove anonymous wrappers if they contain continuations as t his means there are block children present.
1116 if (child->isRenderBlock() && toRenderBlock(child)->continuation())
1117 return;
1118 // We are only interested in removing anonymous wrappers if there are in line siblings underneath them.
1119 if (!child->childrenInline())
1120 return;
1121 if (child->isAnonymousBlock())
1122 blocksToRemove.append(child);
1123 }
1124
1125 for (size_t i = 0; i < blocksToRemove.size(); i++)
1126 collapseAnonymousBlockChild(this, toRenderBlock(blocksToRemove[i]));
1127 }
1128
1104 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child) 1129 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child)
1105 { 1130 {
1106 // It's possible that this block's destruction may have been triggered by th e 1131 // It's possible that this block's destruction may have been triggered by th e
1107 // child's removal. Just bail if the anonymous child block is already being 1132 // child's removal. Just bail if the anonymous child block is already being
1108 // destroyed. See crbug.com/282088 1133 // destroyed. See crbug.com/282088
1109 if (child->beingDestroyed()) 1134 if (child->beingDestroyed())
1110 return; 1135 return;
1111 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 1136 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
1112 parent->setChildrenInline(child->childrenInline()); 1137 parent->setChildrenInline(child->childrenInline());
1113 RenderObject* nextSibling = child->nextSibling(); 1138 RenderObject* nextSibling = child->nextSibling();
(...skipping 3270 matching lines...) Expand 10 before | Expand all | Expand 10 after
4384 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 4409 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
4385 { 4410 {
4386 showRenderObject(); 4411 showRenderObject();
4387 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 4412 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
4388 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 4413 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
4389 } 4414 }
4390 4415
4391 #endif 4416 #endif
4392 4417
4393 } // namespace blink 4418 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698