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, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. |
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 } | 260 } |
261 | 261 |
262 static RenderObject* firstNonMarkerChild(RenderObject* parent) | 262 static RenderObject* firstNonMarkerChild(RenderObject* parent) |
263 { | 263 { |
264 RenderObject* result = parent->slowFirstChild(); | 264 RenderObject* result = parent->slowFirstChild(); |
265 while (result && result->isListMarker()) | 265 while (result && result->isListMarker()) |
266 result = result->nextSibling(); | 266 result = result->nextSibling(); |
267 return result; | 267 return result; |
268 } | 268 } |
269 | 269 |
270 void RenderListItem::updateMarkerLocation() | 270 void RenderListItem::updateMarkerAndInvalidateWidth() |
271 { | 271 { |
272 // Sanity check the location of our marker. | 272 ASSERT(m_marker); |
273 if (m_marker) { | |
274 RenderObject* markerParent = m_marker->parent(); | |
275 RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker); | |
276 if (!lineBoxParent) { | |
277 // If the marker is currently contained inside an anonymous box, | |
278 // then we are the only item in that anonymous box (since no line bo x | |
279 // parent was found). It's ok to just leave the marker where it is | |
280 // in this case. | |
281 if (markerParent && markerParent->isAnonymousBlock()) | |
282 lineBoxParent = markerParent; | |
283 else | |
284 lineBoxParent = this; | |
285 } | |
286 | 273 |
287 if (markerParent != lineBoxParent || m_marker->preferredLogicalWidthsDir ty()) { | 274 // FIXME: We should not modify the structure of the render tree |
288 // FIXME: We should not modify the structure of the render tree | 275 // during layout. crbug.com/370461 |
289 // during layout. crbug.com/370461 | 276 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
290 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 277 // Removing and adding the marker can trigger repainting in |
278 // containers other than ourselves, so we need to disable LayoutState. | |
279 ForceHorriblySlowRectMapping slowRectMapping(*this); | |
280 if (updateMarker()) { | |
281 // If the marker is inside we need to redo the preferred width calculati ons | |
282 // as the size of the item now includes the size of the list marker. | |
283 if (m_marker->isInside()) | |
284 containingBlock()->updateLogicalWidth(); | |
285 } | |
286 } | |
291 | 287 |
292 // Removing and adding the marker can trigger repainting in | 288 bool RenderListItem::updateMarker() |
293 // containers other than ourselves, so we need to disable LayoutStat e. | 289 { |
294 ForceHorriblySlowRectMapping slowRectMapping(*this); | 290 ASSERT(m_marker); |
295 updateFirstLetter(); | 291 RenderObject* markerParent = m_marker->parent(); |
296 m_marker->remove(); | 292 RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker); |
297 if (markerParent) | 293 if (!lineBoxParent) { |
298 markerParent->dirtyLinesFromChangedChild(m_marker); | 294 // If the marker is currently contained inside an anonymous box, then we |
leviw_travelin_and_unemployed
2014/07/02 18:07:14
I'm suspicious of this line being removed entirely
pdr.
2014/07/02 18:39:30
I agree, lets do this as a followup. Added a fixme
| |
299 if (!lineBoxParent) | 295 // are the only item in that anonymous box (since no line box parent was |
300 lineBoxParent = this; | 296 // found). It's ok to just leave the marker where it is in this case. |
301 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent) ); | 297 if (markerParent && markerParent->isAnonymousBlock()) |
302 m_marker->updateMarginsAndContent(); | 298 lineBoxParent = markerParent; |
303 // If markerParent is an anonymous block that has lost all its child ren, destroy it. | 299 else |
304 if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlo ck(markerParent)->firstChild() && !toRenderBlock(markerParent)->continuation()) | 300 lineBoxParent = this; |
305 markerParent->destroy(); | 301 } |
306 | 302 |
307 // If the marker is inside we need to redo the preferred width calcu lations | 303 if (markerParent != lineBoxParent) { |
308 // as the size of the item now includes the size of the list marker. | 304 updateFirstLetter(); |
309 if (m_marker->isInside()) | 305 m_marker->remove(); |
310 containingBlock()->updateLogicalWidth(); | 306 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent)); |
311 } | 307 m_marker->updateMarginsAndContent(); |
308 // If markerParent is an anonymous block with no children, destroy it. | |
309 if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlock(m arkerParent)->firstChild() && !toRenderBlock(markerParent)->continuation()) | |
310 markerParent->destroy(); | |
311 return true; | |
312 } | 312 } |
313 | |
314 return false; | |
313 } | 315 } |
314 | 316 |
315 void RenderListItem::layout() | 317 void RenderListItem::layout() |
316 { | 318 { |
317 ASSERT(needsLayout()); | 319 ASSERT(needsLayout()); |
318 | 320 |
319 // The marker must be autosized before calling updateMarkerLocation. | |
320 // It cannot be done in the parent's beginLayout because it is not yet in th e render tree. | |
321 if (m_marker) { | 321 if (m_marker) { |
322 FastTextAutosizer* textAutosizer = document().fastTextAutosizer(); | 322 // The marker must be autosized before calling |
323 if (textAutosizer) | 323 // updateMarkerAndInvalidateWidth. It cannot be done in the parent's |
324 // beginLayout because it is not yet in the render tree. | |
325 if (FastTextAutosizer* textAutosizer = document().fastTextAutosizer()) | |
324 textAutosizer->inflateListItem(this, m_marker); | 326 textAutosizer->inflateListItem(this, m_marker); |
327 | |
328 updateMarkerAndInvalidateWidth(); | |
325 } | 329 } |
326 | 330 |
327 updateMarkerLocation(); | |
328 RenderBlockFlow::layout(); | 331 RenderBlockFlow::layout(); |
329 } | 332 } |
330 | 333 |
331 void RenderListItem::addOverflowFromChildren() | 334 void RenderListItem::addOverflowFromChildren() |
332 { | 335 { |
333 RenderBlockFlow::addOverflowFromChildren(); | 336 RenderBlockFlow::addOverflowFromChildren(); |
334 positionListMarker(); | 337 positionListMarker(); |
335 } | 338 } |
336 | 339 |
337 void RenderListItem::positionListMarker() | 340 void RenderListItem::positionListMarker() |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 { | 471 { |
469 ASSERT(node()); | 472 ASSERT(node()); |
470 | 473 |
471 if (!m_hasExplicitValue) | 474 if (!m_hasExplicitValue) |
472 return; | 475 return; |
473 m_hasExplicitValue = false; | 476 m_hasExplicitValue = false; |
474 m_isValueUpToDate = false; | 477 m_isValueUpToDate = false; |
475 explicitValueChanged(); | 478 explicitValueChanged(); |
476 } | 479 } |
477 | 480 |
481 void RenderListItem::setNotInList(bool notInList) | |
482 { | |
483 m_notInList = notInList; | |
484 if (m_marker) | |
485 updateMarker(); | |
486 } | |
487 | |
478 static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, Rende rListItem* item) | 488 static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, Rende rListItem* item) |
479 { | 489 { |
480 return isListReversed ? previousListItem(list, item) : nextListItem(list, it em); | 490 return isListReversed ? previousListItem(list, item) : nextListItem(list, it em); |
481 } | 491 } |
482 | 492 |
483 void RenderListItem::updateListMarkerNumbers() | 493 void RenderListItem::updateListMarkerNumbers() |
484 { | 494 { |
485 // If distribution recalc is needed, updateListMarkerNumber will be re-invok ed | 495 // If distribution recalc is needed, updateListMarkerNumber will be re-invok ed |
486 // after distribution is calculated. | 496 // after distribution is calculated. |
487 if (node()->document().childNeedsDistributionRecalc()) | 497 if (node()->document().childNeedsDistributionRecalc()) |
(...skipping 22 matching lines...) Expand all Loading... | |
510 // assume that all the following ones have too. | 520 // assume that all the following ones have too. |
511 // This gives us the opportunity to stop here and avoid | 521 // This gives us the opportunity to stop here and avoid |
512 // marking the same nodes again. | 522 // marking the same nodes again. |
513 break; | 523 break; |
514 } | 524 } |
515 item->updateValue(); | 525 item->updateValue(); |
516 } | 526 } |
517 } | 527 } |
518 | 528 |
519 } // namespace WebCore | 529 } // namespace WebCore |
OLD | NEW |