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

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
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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 return oldStyle->borderTopWidth() != newStyle->borderTopWidth() 321 return oldStyle->borderTopWidth() != newStyle->borderTopWidth()
322 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth() 322 || oldStyle->borderBottomWidth() != newStyle->borderBottomWidth()
323 || oldStyle->paddingTop() != newStyle->paddingTop() 323 || oldStyle->paddingTop() != newStyle->paddingTop()
324 || oldStyle->paddingBottom() != newStyle->paddingBottom(); 324 || oldStyle->paddingBottom() != newStyle->paddingBottom();
325 } 325 }
326 326
327 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le) 327 void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty le)
328 { 328 {
329 RenderBox::styleDidChange(diff, oldStyle); 329 RenderBox::styleDidChange(diff, oldStyle);
330 330
331 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isRenderBlockFlow ())
332 toRenderBlock(parent())->removeAnonymousWrappersIfRequired();
333
331 RenderStyle* newStyle = style(); 334 RenderStyle* newStyle = style();
332 335
333 if (!isAnonymousBlock()) { 336 if (!isAnonymousBlock()) {
334 // Ensure that all of our continuation blocks pick up the new style. 337 // Ensure that all of our continuation blocks pick up the new style.
335 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) { 338 for (RenderBlock* currCont = blockElementContinuation(); currCont; currC ont = currCont->blockElementContinuation()) {
336 RenderBoxModelObject* nextCont = currCont->continuation(); 339 RenderBoxModelObject* nextCont = currCont->continuation();
337 currCont->setContinuation(0); 340 currCont->setContinuation(0);
338 currCont->setStyle(newStyle); 341 currCont->setStyle(newStyle);
339 currCont->setContinuation(nextCont); 342 currCont->setContinuation(nextCont);
340 } 343 }
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 return false; 1073 return false;
1071 1074
1072 if (!prev || !next) 1075 if (!prev || !next)
1073 return true; 1076 return true;
1074 1077
1075 // Make sure the types of the anonymous blocks match up. 1078 // Make sure the types of the anonymous blocks match up.
1076 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() 1079 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()
1077 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock(); 1080 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock();
1078 } 1081 }
1079 1082
1083 void RenderBlock::removeAnonymousWrappersIfRequired()
1084 {
1085 RenderBox* child = firstChildBox();
1086 while (child && (child->isAnonymousBlock() || child->isFloatingOrOutOfFlowPo sitioned())) {
1087 RenderBox* next = child->nextSiblingBox();
1088 // A continuation means the wrappers are still required.
1089 if (next && next->isRenderBlock() && toRenderBlock(next)->continuation() )
1090 return;
1091 if (child->isAnonymousBlock())
1092 collapseAnonymousBlockChild(this, toRenderBlock(child));
1093 // |child| may have been destroyed.
1094 child = next;
1095 }
1096 }
1097
1080 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child) 1098 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child)
1081 { 1099 {
1082 // It's possible that this block's destruction may have been triggered by th e 1100 // It's possible that this block's destruction may have been triggered by th e
1083 // child's removal. Just bail if the anonymous child block is already being 1101 // child's removal. Just bail if the anonymous child block is already being
1084 // destroyed. See crbug.com/282088 1102 // destroyed. See crbug.com/282088
1085 if (child->beingDestroyed()) 1103 if (child->beingDestroyed())
1086 return; 1104 return;
1087 parent->setNeedsLayoutAndPrefWidthsRecalc(); 1105 parent->setNeedsLayoutAndPrefWidthsRecalc();
1088 parent->setChildrenInline(child->childrenInline()); 1106 parent->setChildrenInline(child->childrenInline());
1089 RenderObject* nextSibling = child->nextSibling(); 1107 RenderObject* nextSibling = child->nextSibling();
(...skipping 3895 matching lines...) Expand 10 before | Expand all | Expand 10 after
4985 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5003 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
4986 { 5004 {
4987 showRenderObject(); 5005 showRenderObject();
4988 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5006 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
4989 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5007 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
4990 } 5008 }
4991 5009
4992 #endif 5010 #endif
4993 5011
4994 } // namespace WebCore 5012 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698