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

Side by Side Diff: Source/core/layout/LayoutInline.cpp

Issue 1224933002: Combine outline and focus ring code paths (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix empty focus ring on Mac Created 5 years, 3 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/layout/LayoutBlock.cpp ('k') | Source/core/layout/LayoutObject.cpp » ('j') | 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 LayoutInline* LayoutInline::createAnonymous(Document* document) 62 LayoutInline* LayoutInline::createAnonymous(Document* document)
63 { 63 {
64 LayoutInline* layoutObject = new LayoutInline(nullptr); 64 LayoutInline* layoutObject = new LayoutInline(nullptr);
65 layoutObject->setDocumentForAnonymous(document); 65 layoutObject->setDocumentForAnonymous(document);
66 return layoutObject; 66 return layoutObject;
67 } 67 }
68 68
69 void LayoutInline::willBeDestroyed() 69 void LayoutInline::willBeDestroyed()
70 { 70 {
71 #if ENABLE(ASSERT)
72 // Make sure we do not retain "this" in the continuation outline table map o f our containing blocks.
73 if (parent() && style()->visibility() == VISIBLE && style()->hasOutline()) {
74 bool containingBlockPaintsContinuationOutline = continuation() || isInli neElementContinuation();
75 if (containingBlockPaintsContinuationOutline) {
76 if (LayoutBlock* cb = containingBlock()) {
77 if (LayoutBlock* cbCb = cb->containingBlock())
78 ASSERT(!cbCb->paintsContinuationOutline(this));
79 }
80 }
81 }
82 #endif
83
84 // Make sure to destroy anonymous children first while they are still connec ted to the rest of the tree, so that they will 71 // Make sure to destroy anonymous children first while they are still connec ted to the rest of the tree, so that they will
85 // properly dirty line boxes that they are removed from. Effects that do :b efore/:after only on hover could crash otherwise. 72 // properly dirty line boxes that they are removed from. Effects that do :b efore/:after only on hover could crash otherwise.
86 children()->destroyLeftoverChildren(); 73 children()->destroyLeftoverChildren();
87 74
88 // Destroy our continuation before anything other than anonymous children. 75 // Destroy our continuation before anything other than anonymous children.
89 // The reason we don't destroy it before anonymous children is that they may 76 // The reason we don't destroy it before anonymous children is that they may
90 // have continuations of their own that are anonymous children of our contin uation. 77 // have continuations of their own that are anonymous children of our contin uation.
91 LayoutBoxModelObject* continuation = this->continuation(); 78 LayoutBoxModelObject* continuation = this->continuation();
92 if (continuation) { 79 if (continuation) {
93 continuation->destroy(); 80 continuation->destroy();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 static LayoutObject* inFlowPositionedInlineAncestor(LayoutObject* p) 132 static LayoutObject* inFlowPositionedInlineAncestor(LayoutObject* p)
146 { 133 {
147 while (p && p->isLayoutInline()) { 134 while (p && p->isLayoutInline()) {
148 if (p->isInFlowPositioned()) 135 if (p->isInFlowPositioned())
149 return p; 136 return p;
150 p = p->parent(); 137 p = p->parent();
151 } 138 }
152 return nullptr; 139 return nullptr;
153 } 140 }
154 141
155 static void updateStyleOfAnonymousBlockContinuations(LayoutObject* block, const ComputedStyle& newStyle, const ComputedStyle& oldStyle, LayoutObject* containing BlockOfEndOfContinuation) 142 static void updateInFlowPositionOfAnonymousBlockContinuations(LayoutObject* bloc k, const ComputedStyle& newStyle, const ComputedStyle& oldStyle, LayoutObject* c ontainingBlockOfEndOfContinuation)
156 { 143 {
157 // If an inline's outline or in-flow positioning has changed then any descen dant blocks will need to change their styles accordingly.
158 bool updateOutline = !newStyle.isOutlineEquivalent(&oldStyle);
159 bool updatePosition = newStyle.position() != oldStyle.position() && (newStyl e.hasInFlowPosition() || oldStyle.hasInFlowPosition());
160 if (!updateOutline && !updatePosition)
161 return;
162
163 for (; block && block != containingBlockOfEndOfContinuation && block->isAnon ymousBlock(); block = block->nextSibling()) { 144 for (; block && block != containingBlockOfEndOfContinuation && block->isAnon ymousBlock(); block = block->nextSibling()) {
164 if (!toLayoutBlock(block)->isAnonymousBlockContinuation()) 145 if (!toLayoutBlock(block)->isAnonymousBlockContinuation())
165 continue; 146 continue;
166 147
148 // If we are no longer in-flow positioned but our descendant block(s) st ill have an in-flow positioned ancestor then
149 // their containing anonymous block should keep its in-flow positioning.
150 if (oldStyle.hasInFlowPosition() && inFlowPositionedInlineAncestor(toLay outBlock(block)->inlineElementContinuation()))
151 continue;
152
167 RefPtr<ComputedStyle> newBlockStyle = ComputedStyle::clone(block->styleR ef()); 153 RefPtr<ComputedStyle> newBlockStyle = ComputedStyle::clone(block->styleR ef());
168 154 newBlockStyle->setPosition(newStyle.position());
169 if (updateOutline)
170 newBlockStyle->setOutlineFromStyle(newStyle);
171
172 if (updatePosition) {
173 // If we are no longer in-flow positioned but our descendant block(s ) still have an in-flow positioned ancestor then
174 // their containing anonymous block should keep its in-flow position ing.
175 if (oldStyle.hasInFlowPosition() && inFlowPositionedInlineAncestor(t oLayoutBlock(block)->inlineElementContinuation()))
176 continue;
177 newBlockStyle->setPosition(newStyle.position());
178 }
179
180 block->setStyle(newBlockStyle); 155 block->setStyle(newBlockStyle);
181 } 156 }
182 } 157 }
183 158
184 void LayoutInline::styleDidChange(StyleDifference diff, const ComputedStyle* old Style) 159 void LayoutInline::styleDidChange(StyleDifference diff, const ComputedStyle* old Style)
185 { 160 {
186 LayoutBoxModelObject::styleDidChange(diff, oldStyle); 161 LayoutBoxModelObject::styleDidChange(diff, oldStyle);
187 162
188 // Ensure that all of the split inlines pick up the new style. We 163 // Ensure that all of the split inlines pick up the new style. We
189 // only do this if we're an inline, since we don't want to propagate 164 // only do this if we're an inline, since we don't want to propagate
190 // a block's style to the other inlines. 165 // a block's style to the other inlines.
191 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before 166 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before
192 // and after the block share the same style, but the block doesn't 167 // and after the block share the same style, but the block doesn't
193 // need to pass its style on to anyone else. 168 // need to pass its style on to anyone else.
194 const ComputedStyle& newStyle = styleRef(); 169 const ComputedStyle& newStyle = styleRef();
195 LayoutInline* continuation = inlineElementContinuation(); 170 LayoutInline* continuation = inlineElementContinuation();
196 LayoutInline* endOfContinuation = nullptr; 171 LayoutInline* endOfContinuation = nullptr;
197 for (LayoutInline* currCont = continuation; currCont; currCont = currCont->i nlineElementContinuation()) { 172 for (LayoutInline* currCont = continuation; currCont; currCont = currCont->i nlineElementContinuation()) {
198 LayoutBoxModelObject* nextCont = currCont->continuation(); 173 LayoutBoxModelObject* nextCont = currCont->continuation();
199 currCont->setContinuation(nullptr); 174 currCont->setContinuation(nullptr);
200 currCont->setStyle(mutableStyle()); 175 currCont->setStyle(mutableStyle());
201 currCont->setContinuation(nextCont); 176 currCont->setContinuation(nextCont);
202 endOfContinuation = currCont; 177 endOfContinuation = currCont;
203 } 178 }
204 179
205 if (continuation && oldStyle) { 180 if (continuation && oldStyle) {
206 ASSERT(endOfContinuation); 181 ASSERT(endOfContinuation);
207 LayoutObject* block = containingBlock()->nextSibling(); 182 LayoutObject* block = containingBlock()->nextSibling();
208 if (block && block->isAnonymousBlock()) 183 // If an inline's in-flow positioning has changed then any descendant bl ocks will need to change their styles accordingly.
209 updateStyleOfAnonymousBlockContinuations(block, newStyle, *oldStyle, endOfContinuation->containingBlock()); 184 if (block && block->isAnonymousBlock()
185 && newStyle.position() != oldStyle->position()
186 && (newStyle.hasInFlowPosition() || oldStyle->hasInFlowPosition()))
187 updateInFlowPositionOfAnonymousBlockContinuations(block, newStyle, * oldStyle, endOfContinuation->containingBlock());
210 } 188 }
211 189
212 if (!alwaysCreateLineBoxes()) { 190 if (!alwaysCreateLineBoxes()) {
213 bool alwaysCreateLineBoxesNew = hasSelfPaintingLayer() || hasBoxDecorati onBackground() || newStyle.hasPadding() || newStyle.hasMargin() || newStyle.hasO utline(); 191 bool alwaysCreateLineBoxesNew = hasSelfPaintingLayer() || hasBoxDecorati onBackground() || newStyle.hasPadding() || newStyle.hasMargin() || newStyle.hasO utline();
214 if (oldStyle && alwaysCreateLineBoxesNew) { 192 if (oldStyle && alwaysCreateLineBoxesNew) {
215 dirtyLineBoxes(false); 193 dirtyLineBoxes(false);
216 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Sty leChange); 194 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Sty leChange);
217 } 195 }
218 setAlwaysCreateLineBoxes(alwaysCreateLineBoxesNew); 196 setAlwaysCreateLineBoxes(alwaysCreateLineBoxesNew);
219 } 197 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // inline into continuations. This involves creating an anonymous block box to hold 307 // inline into continuations. This involves creating an anonymous block box to hold
330 // |newChild|. We then make that block box a continuation of this inlin e. We take all of 308 // |newChild|. We then make that block box a continuation of this inlin e. We take all of
331 // the children after |beforeChild| and put them in a clone of this obje ct. 309 // the children after |beforeChild| and put them in a clone of this obje ct.
332 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWith Display(styleRef(), BLOCK); 310 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWith Display(styleRef(), BLOCK);
333 311
334 // If inside an inline affected by in-flow positioning the block needs t o be affected by it too. 312 // If inside an inline affected by in-flow positioning the block needs t o be affected by it too.
335 // Giving the block a layer like this allows it to collect the x/y offse ts from inline parents later. 313 // Giving the block a layer like this allows it to collect the x/y offse ts from inline parents later.
336 if (LayoutObject* positionedAncestor = inFlowPositionedInlineAncestor(th is)) 314 if (LayoutObject* positionedAncestor = inFlowPositionedInlineAncestor(th is))
337 newStyle->setPosition(positionedAncestor->style()->position()); 315 newStyle->setPosition(positionedAncestor->style()->position());
338 316
339 // Push outline style to the block continuation.
340 if (!newStyle->isOutlineEquivalent(style()))
341 newStyle->setOutlineFromStyle(*style());
342
343 LayoutBlockFlow* newBox = LayoutBlockFlow::createAnonymous(&document()); 317 LayoutBlockFlow* newBox = LayoutBlockFlow::createAnonymous(&document());
344 newBox->setStyle(newStyle.release()); 318 newBox->setStyle(newStyle.release());
345 LayoutBoxModelObject* oldContinuation = continuation(); 319 LayoutBoxModelObject* oldContinuation = continuation();
346 setContinuation(newBox); 320 setContinuation(newBox);
347 321
348 splitFlow(beforeChild, newBox, newChild, oldContinuation); 322 splitFlow(beforeChild, newBox, newChild, oldContinuation);
349 return; 323 return;
350 } 324 }
351 325
352 LayoutBoxModelObject::addChild(newChild, beforeChild); 326 LayoutBoxModelObject::addChild(newChild, beforeChild);
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 } 1415 }
1442 1416
1443 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain tInvalidationContainer) const 1417 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain tInvalidationContainer) const
1444 { 1418 {
1445 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine r); 1419 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine r);
1446 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) 1420 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox())
1447 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); 1421 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box);
1448 } 1422 }
1449 1423
1450 } // namespace blink 1424 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlock.cpp ('k') | Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698