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

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, 7 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 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 return oldStyle->borderTopWidth() != newStyle->borderTopWidth() 324 return oldStyle->borderTopWidth() != newStyle->borderTopWidth()
325 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth() 325 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth()
326 || oldStyle->paddingTop() != newStyle->paddingTop() 326 || oldStyle->paddingTop() != newStyle->paddingTop()
327 || oldStyle->paddingBottom() != newStyle->paddingBottom(); 327 || oldStyle->paddingBottom() != newStyle->paddingBottom();
328 } 328 }
329 329
330 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le) 330 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le)
331 { 331 {
332 RenderBox::styleDidChange(diff, oldStyle); 332 RenderBox::styleDidChange(diff, oldStyle);
333 333
334 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isRenderBlockFlow ())
335 toRenderBlock(parent())->removeAnonymousWrappersIfRequired();
336
334 RenderStyle* newStyle = style(); 337 RenderStyle* newStyle = style();
335 338
336 if (!isAnonymousBlock()) { 339 if (!isAnonymousBlock()) {
337 // Ensure that all of our continuation blocks pick up the new style. 340 // Ensure that all of our continuation blocks pick up the new style.
338 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) { 341 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) {
339 RenderBoxModelObject* nextCont = currCont->continuation(); 342 RenderBoxModelObject* nextCont = currCont->continuation();
340 currCont->setContinuation(0); 343 currCont->setContinuation(0);
341 currCont->setStyle(newStyle); 344 currCont->setStyle(newStyle);
342 currCont->setContinuation(nextCont); 345 currCont->setContinuation(nextCont);
343 } 346 }
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 return false; 1076 return false;
1074 1077
1075 if (!prev || !next) 1078 if (!prev || !next)
1076 return true; 1079 return true;
1077 1080
1078 // Make sure the types of the anonymous blocks match up. 1081 // Make sure the types of the anonymous blocks match up.
1079 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() 1082 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()
1080 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock(); 1083 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock();
1081 } 1084 }
1082 1085
1086 void RenderBlock::removeAnonymousWrappersIfRequired()
esprehn 2014/05/27 20:05:03 Should this method be in RenderBlockFlow instead?
1087 {
1088 Vector<RenderBox*> blocksToRemove;
esprehn 2014/05/27 20:05:03 Add inline capacity, I'd go with 8 or 16.
1089 RenderBox* child = firstChildBox();
1090 while (child) {
1091 // There are still block children in the container, so any anonymous wra ppers are still needed.
1092 if (!child->isAnonymousBlock() && !child->isFloatingOrOutOfFlowPositione d())
1093 return;
1094 // We can't remove anonymous wrappers if they contain continuations as t his means there are block children present.
1095 if (child->isRenderBlock() && toRenderBlock(child)->continuation())
1096 return;
1097 if (child->isAnonymousBlock())
1098 blocksToRemove.append(child);
1099 child = child->nextSiblingBox();
esprehn 2014/05/27 20:05:03 This should be a for() loop now.
1100 }
1101
1102 for (unsigned i = 0; i < blocksToRemove.size(); i++)
esprehn 2014/05/27 20:05:03 size_t
1103 collapseAnonymousBlockChild(this, toRenderBlock(blocksToRemove[i]));
1104 }
1105
1083 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child) 1106 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child)
1084 { 1107 {
1085 // It's possible that this block's destruction may have been triggered by th e 1108 // It's possible that this block's destruction may have been triggered by th e
1086 // child's removal. Just bail if the anonymous child block is already being 1109 // child's removal. Just bail if the anonymous child block is already being
1087 // destroyed. See crbug.com/282088 1110 // destroyed. See crbug.com/282088
1088 if (child->beingDestroyed()) 1111 if (child->beingDestroyed())
1089 return; 1112 return;
1090 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullRepaint(); 1113 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullRepaint();
1091 parent->setChildrenInline(child->childrenInline()); 1114 parent->setChildrenInline(child->childrenInline());
1092 RenderObject* nextSibling = child->nextSibling(); 1115 RenderObject* nextSibling = child->nextSibling();
(...skipping 3924 matching lines...) Expand 10 before | Expand all | Expand 10 after
5017 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5040 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5018 { 5041 {
5019 showRenderObject(); 5042 showRenderObject();
5020 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5043 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5021 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5044 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5022 } 5045 }
5023 5046
5024 #endif 5047 #endif
5025 5048
5026 } // namespace WebCore 5049 } // namespace WebCore
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