OLD | NEW |
---|---|
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 } | 155 } |
156 return 0; | 156 return 0; |
157 } | 157 } |
158 | 158 |
159 static void updateStyleOfAnonymousBlockContinuations(RenderObject* block, const RenderStyle* newStyle, const RenderStyle* oldStyle) | 159 static void updateStyleOfAnonymousBlockContinuations(RenderObject* block, const RenderStyle* newStyle, const RenderStyle* oldStyle) |
160 { | 160 { |
161 for (;block && block->isAnonymousBlock(); block = block->nextSibling()) { | 161 for (;block && block->isAnonymousBlock(); block = block->nextSibling()) { |
162 if (!toRenderBlock(block)->isAnonymousBlockContinuation()) | 162 if (!toRenderBlock(block)->isAnonymousBlockContinuation()) |
163 continue; | 163 continue; |
164 | 164 |
165 RefPtr<RenderStyle> newBlockStyle; | |
166 | |
165 if (!block->style()->isOutlineEquivalent(newStyle)) { | 167 if (!block->style()->isOutlineEquivalent(newStyle)) { |
166 RefPtr<RenderStyle> blockStyle = RenderStyle::clone(block->style()); | 168 newBlockStyle = RenderStyle::clone(block->style()); |
167 blockStyle->setOutlineFromStyle(*newStyle); | 169 newBlockStyle->setOutlineFromStyle(*newStyle); |
168 block->setStyle(blockStyle); | |
169 } | 170 } |
170 | 171 |
171 if (block->style()->position() != newStyle->position()) { | 172 if (block->style()->position() != newStyle->position()) { |
172 // If we are no longer in-flow positioned but our descendant block(s ) still have an in-flow positioned ancestor then | 173 // If we are no longer in-flow positioned but our descendant block(s ) still have an in-flow positioned ancestor then |
173 // their containing anonymous block should keep its in-flow position ing. | 174 // their containing anonymous block should keep its in-flow position ing. |
174 if (oldStyle->hasInFlowPosition() | 175 if (oldStyle->hasInFlowPosition() |
175 && inFlowPositionedInlineAncestor(toRenderBlock(block)->inlineEl ementContinuation())) | 176 && inFlowPositionedInlineAncestor(toRenderBlock(block)->inlineEl ementContinuation())) |
176 continue; | 177 continue; |
177 // FIXME: We should share blockStyle with the outline case, but it f ails layout tests | 178 if (!newBlockStyle) |
178 // for dynamic position change of inlines containing block continuat ions. crbug.com/405222. | 179 newBlockStyle = RenderStyle::clone(block->style()); |
179 RefPtr<RenderStyle> blockStyle = RenderStyle::createAnonymousStyleWi thDisplay(block->style(), BLOCK); | 180 newBlockStyle->setPosition(newStyle->position()); |
180 blockStyle->setPosition(newStyle->position()); | |
181 block->setStyle(blockStyle); | |
182 } | 181 } |
182 | |
183 if (newBlockStyle) | |
184 block->setStyle(newBlockStyle); | |
183 } | 185 } |
184 } | 186 } |
185 | 187 |
186 void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle) | 188 void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle) |
187 { | 189 { |
188 RenderBoxModelObject::styleDidChange(diff, oldStyle); | 190 RenderBoxModelObject::styleDidChange(diff, oldStyle); |
189 | 191 |
190 // Ensure that all of the split inlines pick up the new style. We | 192 // Ensure that all of the split inlines pick up the new style. We |
191 // only do this if we're an inline, since we don't want to propagate | 193 // only do this if we're an inline, since we don't want to propagate |
192 // a block's style to the other inlines. | 194 // a block's style to the other inlines. |
193 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before | 195 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before |
194 // and after the block share the same style, but the block doesn't | 196 // and after the block share the same style, but the block doesn't |
195 // need to pass its style on to anyone else. | 197 // need to pass its style on to anyone else. |
196 RenderStyle* newStyle = style(); | 198 RenderStyle* newStyle = style(); |
197 RenderInline* continuation = inlineElementContinuation(); | 199 RenderInline* continuation = inlineElementContinuation(); |
198 for (RenderInline* currCont = continuation; currCont; currCont = currCont->i nlineElementContinuation()) { | 200 for (RenderInline* currCont = continuation; currCont; currCont = currCont->i nlineElementContinuation()) { |
199 RenderBoxModelObject* nextCont = currCont->continuation(); | 201 RenderBoxModelObject* nextCont = currCont->continuation(); |
200 currCont->setContinuation(0); | 202 currCont->setContinuation(0); |
201 currCont->setStyle(newStyle); | 203 currCont->setStyle(newStyle); |
202 currCont->setContinuation(nextCont); | 204 currCont->setContinuation(nextCont); |
203 } | 205 } |
204 | 206 |
205 // If an inline's in-flow positioning has changed then any descendant blocks will need to change their in-flow positioning accordingly. | 207 // If an inline's outline or in-flow positioning has changed then any descen dant blocks will need to change their styles accordingly. |
206 // Do this by updating the position of the descendant blocks' containing ano nymous blocks - there may be more than one. | 208 // Do this by updating the styles of the descendant blocks' containing anony mous blocks - there may be more than one. |
207 if (continuation && oldStyle | 209 if (continuation && oldStyle |
208 && (!newStyle->isOutlineEquivalent(oldStyle) | 210 && (!newStyle->isOutlineEquivalent(oldStyle) |
209 || (newStyle->position() != oldStyle->position() && (newStyle->hasIn FlowPosition() || oldStyle->hasInFlowPosition())))) { | 211 || (newStyle->position() != oldStyle->position() && (newStyle->hasIn FlowPosition() || oldStyle->hasInFlowPosition())))) { |
210 // If any descendant blocks exist then they will be in the next anonymou s block and its siblings. | 212 // If any descendant blocks exist then they will be in the next anonymou s block and its siblings. |
211 RenderObject* block = containingBlock()->nextSibling(); | 213 RenderObject* block = containingBlock()->nextSibling(); |
212 if (block && block->isAnonymousBlock()) | 214 if (block && block->isAnonymousBlock()) |
213 updateStyleOfAnonymousBlockContinuations(block, newStyle, oldStyle); | 215 updateStyleOfAnonymousBlockContinuations(block, newStyle, oldStyle); |
214 } | 216 } |
215 | 217 |
216 if (!alwaysCreateLineBoxes()) { | 218 if (!alwaysCreateLineBoxes()) { |
217 bool alwaysCreateLineBoxesNew = hasSelfPaintingLayer() || hasBoxDecorati onBackground() || newStyle->hasPadding() || newStyle->hasMargin() || newStyle->h asOutline(); | 219 bool alwaysCreateLineBoxesNew = hasSelfPaintingLayer() || hasBoxDecorati onBackground() || newStyle->hasPadding() || newStyle->hasMargin() || newStyle->h asOutline(); |
218 if (oldStyle && alwaysCreateLineBoxesNew) { | 220 if (oldStyle && alwaysCreateLineBoxesNew) { |
219 dirtyLineBoxes(false); | 221 dirtyLineBoxes(false); |
220 setNeedsLayoutAndFullPaintInvalidation(); | 222 setNeedsLayoutAndFullPaintInvalidation(); |
221 } | 223 } |
222 setAlwaysCreateLineBoxes(alwaysCreateLineBoxesNew); | 224 setAlwaysCreateLineBoxes(alwaysCreateLineBoxesNew); |
223 } | 225 } |
224 } | 226 } |
225 | 227 |
226 void RenderInline::setContinuation(RenderBoxModelObject* continuation) | |
227 { | |
228 RenderBoxModelObject::setContinuation(continuation); | |
229 if (continuation && continuation->isAnonymousBlock() && !continuation->style ()->isOutlineEquivalent(style())) { | |
230 // Push outline style to the block continuation. | |
231 RefPtr<RenderStyle> blockStyle = RenderStyle::clone(continuation->style( )); | |
232 blockStyle->setOutlineFromStyle(*style()); | |
233 continuation->setStyle(blockStyle); | |
234 } | |
235 // FIXME: What if continuation is added when the inline has relative positio n? crbug.com/405222. | |
236 } | |
237 | |
238 void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout) | 228 void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout) |
239 { | 229 { |
240 // Once we have been tainted once, just assume it will happen again. This wa y effects like hover highlighting that change the | 230 // Once we have been tainted once, just assume it will happen again. This wa y effects like hover highlighting that change the |
241 // background color will only cause a layout on the first rollover. | 231 // background color will only cause a layout on the first rollover. |
242 if (alwaysCreateLineBoxes()) | 232 if (alwaysCreateLineBoxes()) |
243 return; | 233 return; |
244 | 234 |
245 RenderStyle* parentStyle = parent()->style(); | 235 RenderStyle* parentStyle = parent()->style(); |
246 RenderInline* parentRenderInline = parent()->isRenderInline() ? toRenderInli ne(parent()) : 0; | 236 RenderInline* parentRenderInline = parent()->isRenderInline() ? toRenderInli ne(parent()) : 0; |
247 bool checkFonts = document().inNoQuirksMode(); | 237 bool checkFonts = document().inNoQuirksMode(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 // inline into continuations. This involves creating an anonymous block box to hold | 332 // inline into continuations. This involves creating an anonymous block box to hold |
343 // |newChild|. We then make that block box a continuation of this inlin e. We take all of | 333 // |newChild|. We then make that block box a continuation of this inlin e. We take all of |
344 // the children after |beforeChild| and put them in a clone of this obje ct. | 334 // the children after |beforeChild| and put them in a clone of this obje ct. |
345 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisp lay(style(), BLOCK); | 335 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisp lay(style(), BLOCK); |
346 | 336 |
347 // If inside an inline affected by in-flow positioning the block needs t o be affected by it too. | 337 // If inside an inline affected by in-flow positioning the block needs t o be affected by it too. |
348 // Giving the block a layer like this allows it to collect the x/y offse ts from inline parents later. | 338 // Giving the block a layer like this allows it to collect the x/y offse ts from inline parents later. |
349 if (RenderObject* positionedAncestor = inFlowPositionedInlineAncestor(th is)) | 339 if (RenderObject* positionedAncestor = inFlowPositionedInlineAncestor(th is)) |
350 newStyle->setPosition(positionedAncestor->style()->position()); | 340 newStyle->setPosition(positionedAncestor->style()->position()); |
351 | 341 |
342 if (!newStyle->isOutlineEquivalent(style())) | |
Julien - ping for review
2014/09/05 19:57:35
I would put a comment here to explain why this is
Xianzhu
2014/09/05 22:04:16
Done.
| |
343 newStyle->setOutlineFromStyle(*style()); | |
344 | |
352 RenderBlockFlow* newBox = RenderBlockFlow::createAnonymous(&document()); | 345 RenderBlockFlow* newBox = RenderBlockFlow::createAnonymous(&document()); |
353 newBox->setStyle(newStyle.release()); | 346 newBox->setStyle(newStyle.release()); |
354 RenderBoxModelObject* oldContinuation = continuation(); | 347 RenderBoxModelObject* oldContinuation = continuation(); |
355 setContinuation(newBox); | 348 setContinuation(newBox); |
356 | 349 |
357 splitFlow(beforeChild, newBox, newChild, oldContinuation); | 350 splitFlow(beforeChild, newBox, newChild, oldContinuation); |
358 return; | 351 return; |
359 } | 352 } |
360 | 353 |
361 RenderBoxModelObject::addChild(newChild, beforeChild); | 354 RenderBoxModelObject::addChild(newChild, beforeChild); |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1607 container = this; | 1600 container = this; |
1608 | 1601 |
1609 FloatPoint absPos = container->localToAbsolute(); | 1602 FloatPoint absPos = container->localToAbsolute(); |
1610 region.bounds.setX(absPos.x() + region.bounds.x()); | 1603 region.bounds.setX(absPos.x() + region.bounds.x()); |
1611 region.bounds.setY(absPos.y() + region.bounds.y()); | 1604 region.bounds.setY(absPos.y() + region.bounds.y()); |
1612 | 1605 |
1613 regions.append(region); | 1606 regions.append(region); |
1614 } | 1607 } |
1615 | 1608 |
1616 } // namespace blink | 1609 } // namespace blink |
OLD | NEW |