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

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 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()->isRenderBlockFl ow())
esprehn 2014/05/19 20:54:58 You don't need these nested parens, it's all &&
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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 return false; 1048 return false;
1046 1049
1047 if (!prev || !next) 1050 if (!prev || !next)
1048 return true; 1051 return true;
1049 1052
1050 // Make sure the types of the anonymous blocks match up. 1053 // Make sure the types of the anonymous blocks match up.
1051 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() 1054 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()
1052 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock(); 1055 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB lock();
1053 } 1056 }
1054 1057
1058 void RenderBlock::removeAnonymousWrappersIfRequired()
1059 {
1060 RenderBlock* child = toRenderBlock(firstChildBox());
esprehn 2014/05/19 20:54:58 How do you know this cast is safe?
1061 while (child && (child->isAnonymousBlock() || child->isFloatingOrOutOfFlowPo sitioned())) {
1062 RenderBlock* next = toRenderBlock(child->nextSiblingBox());
esprehn 2014/05/19 20:54:58 ditto
1063 // A continuation means the wrappers are still required.
1064 if (next && next->continuation())
1065 return;
1066 if (child->isAnonymousBlock())
1067 collapseAnonymousBlockChild(this, child);
1068 // |child| may have been destroyed.
1069 child = next;
1070 }
1071 }
1072
1055 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child) 1073 void RenderBlock::collapseAnonymousBlockChild(RenderBlock* parent, RenderBlock* child)
1056 { 1074 {
1057 // It's possible that this block's destruction may have been triggered by th e 1075 // It's possible that this block's destruction may have been triggered by th e
1058 // child's removal. Just bail if the anonymous child block is already being 1076 // child's removal. Just bail if the anonymous child block is already being
1059 // destroyed. See crbug.com/282088 1077 // destroyed. See crbug.com/282088
1060 if (child->beingDestroyed()) 1078 if (child->beingDestroyed())
1061 return; 1079 return;
1062 parent->setNeedsLayoutAndPrefWidthsRecalc(); 1080 parent->setNeedsLayoutAndPrefWidthsRecalc();
1063 parent->setChildrenInline(child->childrenInline()); 1081 parent->setChildrenInline(child->childrenInline());
1064 RenderObject* nextSibling = child->nextSibling(); 1082 RenderObject* nextSibling = child->nextSibling();
(...skipping 3927 matching lines...) Expand 10 before | Expand all | Expand 10 after
4992 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5010 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
4993 { 5011 {
4994 showRenderObject(); 5012 showRenderObject();
4995 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5013 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
4996 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5014 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
4997 } 5015 }
4998 5016
4999 #endif 5017 #endif
5000 5018
5001 } // namespace WebCore 5019 } // 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