| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ASSERT(!current->document().childNeedsDistributionRecalc()); | 122 ASSERT(!current->document().childNeedsDistributionRecalc()); |
| 123 current = NodeRenderingTraversal::next(*current, listNode); | 123 current = NodeRenderingTraversal::next(*current, listNode); |
| 124 | 124 |
| 125 while (current) { | 125 while (current) { |
| 126 if (isList(*current)) { | 126 if (isList(*current)) { |
| 127 // We've found a nested, independent list: nothing to do here. | 127 // We've found a nested, independent list: nothing to do here. |
| 128 current = NodeRenderingTraversal::nextSkippingChildren(*current, lis
tNode); | 128 current = NodeRenderingTraversal::nextSkippingChildren(*current, lis
tNode); |
| 129 continue; | 129 continue; |
| 130 } | 130 } |
| 131 | 131 |
| 132 RenderObject* renderer = current->renderer(); | 132 LayoutObject* renderer = current->renderer(); |
| 133 if (renderer && renderer->isListItem()) | 133 if (renderer && renderer->isListItem()) |
| 134 return toRenderListItem(renderer); | 134 return toRenderListItem(renderer); |
| 135 | 135 |
| 136 // FIXME: Can this be optimized to skip the children of the elements wit
hout a renderer? | 136 // FIXME: Can this be optimized to skip the children of the elements wit
hout a renderer? |
| 137 current = NodeRenderingTraversal::next(*current, listNode); | 137 current = NodeRenderingTraversal::next(*current, listNode); |
| 138 } | 138 } |
| 139 | 139 |
| 140 return 0; | 140 return 0; |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Returns the previous list item with respect to the DOM order. | 143 // Returns the previous list item with respect to the DOM order. |
| 144 static RenderListItem* previousListItem(const Node* listNode, const RenderListIt
em* item) | 144 static RenderListItem* previousListItem(const Node* listNode, const RenderListIt
em* item) |
| 145 { | 145 { |
| 146 Node* current = item->node(); | 146 Node* current = item->node(); |
| 147 ASSERT(current); | 147 ASSERT(current); |
| 148 ASSERT(!current->document().childNeedsDistributionRecalc()); | 148 ASSERT(!current->document().childNeedsDistributionRecalc()); |
| 149 for (current = NodeRenderingTraversal::previous(*current, listNode); current
&& current != listNode; current = NodeRenderingTraversal::previous(*current, li
stNode)) { | 149 for (current = NodeRenderingTraversal::previous(*current, listNode); current
&& current != listNode; current = NodeRenderingTraversal::previous(*current, li
stNode)) { |
| 150 RenderObject* renderer = current->renderer(); | 150 LayoutObject* renderer = current->renderer(); |
| 151 if (!renderer || (renderer && !renderer->isListItem())) | 151 if (!renderer || (renderer && !renderer->isListItem())) |
| 152 continue; | 152 continue; |
| 153 Node* otherList = enclosingList(toRenderListItem(renderer)); | 153 Node* otherList = enclosingList(toRenderListItem(renderer)); |
| 154 // This item is part of our current list, so it's what we're looking for
. | 154 // This item is part of our current list, so it's what we're looking for
. |
| 155 if (listNode == otherList) | 155 if (listNode == otherList) |
| 156 return toRenderListItem(renderer); | 156 return toRenderListItem(renderer); |
| 157 // We found ourself inside another list; lets skip the rest of it. | 157 // We found ourself inside another list; lets skip the rest of it. |
| 158 // Use nextIncludingPseudo() here because the other list itself may actu
ally | 158 // Use nextIncludingPseudo() here because the other list itself may actu
ally |
| 159 // be a list item itself. We need to examine it, so we do this to counte
ract | 159 // be a list item itself. We need to examine it, so we do this to counte
ract |
| 160 // the previousIncludingPseudo() that will be done by the loop. | 160 // the previousIncludingPseudo() that will be done by the loop. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 { | 209 { |
| 210 m_value = calcValue(); | 210 m_value = calcValue(); |
| 211 m_isValueUpToDate = true; | 211 m_isValueUpToDate = true; |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool RenderListItem::isEmpty() const | 214 bool RenderListItem::isEmpty() const |
| 215 { | 215 { |
| 216 return lastChild() == m_marker; | 216 return lastChild() == m_marker; |
| 217 } | 217 } |
| 218 | 218 |
| 219 static RenderObject* getParentOfFirstLineBox(RenderBlockFlow* curr, RenderObject
* marker) | 219 static LayoutObject* getParentOfFirstLineBox(RenderBlockFlow* curr, LayoutObject
* marker) |
| 220 { | 220 { |
| 221 RenderObject* firstChild = curr->firstChild(); | 221 LayoutObject* firstChild = curr->firstChild(); |
| 222 if (!firstChild) | 222 if (!firstChild) |
| 223 return 0; | 223 return 0; |
| 224 | 224 |
| 225 bool inQuirksMode = curr->document().inQuirksMode(); | 225 bool inQuirksMode = curr->document().inQuirksMode(); |
| 226 for (RenderObject* currChild = firstChild; currChild; currChild = currChild-
>nextSibling()) { | 226 for (LayoutObject* currChild = firstChild; currChild; currChild = currChild-
>nextSibling()) { |
| 227 if (currChild == marker) | 227 if (currChild == marker) |
| 228 continue; | 228 continue; |
| 229 | 229 |
| 230 if (currChild->isInline() && (!currChild->isRenderInline() || curr->gene
ratesLineBoxesForInlineChild(currChild))) | 230 if (currChild->isInline() && (!currChild->isRenderInline() || curr->gene
ratesLineBoxesForInlineChild(currChild))) |
| 231 return curr; | 231 return curr; |
| 232 | 232 |
| 233 if (currChild->isFloating() || currChild->isOutOfFlowPositioned()) | 233 if (currChild->isFloating() || currChild->isOutOfFlowPositioned()) |
| 234 continue; | 234 continue; |
| 235 | 235 |
| 236 if (!currChild->isRenderBlockFlow() || (currChild->isBox() && toRenderBo
x(currChild)->isWritingModeRoot())) | 236 if (!currChild->isRenderBlockFlow() || (currChild->isBox() && toRenderBo
x(currChild)->isWritingModeRoot())) |
| 237 break; | 237 break; |
| 238 | 238 |
| 239 if (curr->isListItem() && inQuirksMode && currChild->node() && | 239 if (curr->isListItem() && inQuirksMode && currChild->node() && |
| 240 (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*currC
hild->node()))) | 240 (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*currC
hild->node()))) |
| 241 break; | 241 break; |
| 242 | 242 |
| 243 RenderObject* lineBox = getParentOfFirstLineBox(toRenderBlockFlow(currCh
ild), marker); | 243 LayoutObject* lineBox = getParentOfFirstLineBox(toRenderBlockFlow(currCh
ild), marker); |
| 244 if (lineBox) | 244 if (lineBox) |
| 245 return lineBox; | 245 return lineBox; |
| 246 } | 246 } |
| 247 | 247 |
| 248 return 0; | 248 return 0; |
| 249 } | 249 } |
| 250 | 250 |
| 251 void RenderListItem::updateValue() | 251 void RenderListItem::updateValue() |
| 252 { | 252 { |
| 253 if (!m_hasExplicitValue) { | 253 if (!m_hasExplicitValue) { |
| 254 m_isValueUpToDate = false; | 254 m_isValueUpToDate = false; |
| 255 if (m_marker) | 255 if (m_marker) |
| 256 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); | 256 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 static RenderObject* firstNonMarkerChild(RenderObject* parent) | 260 static LayoutObject* firstNonMarkerChild(LayoutObject* parent) |
| 261 { | 261 { |
| 262 RenderObject* result = parent->slowFirstChild(); | 262 LayoutObject* result = parent->slowFirstChild(); |
| 263 while (result && result->isListMarker()) | 263 while (result && result->isListMarker()) |
| 264 result = result->nextSibling(); | 264 result = result->nextSibling(); |
| 265 return result; | 265 return result; |
| 266 } | 266 } |
| 267 | 267 |
| 268 void RenderListItem::updateMarkerLocationAndInvalidateWidth() | 268 void RenderListItem::updateMarkerLocationAndInvalidateWidth() |
| 269 { | 269 { |
| 270 ASSERT(m_marker); | 270 ASSERT(m_marker); |
| 271 | 271 |
| 272 // FIXME: We should not modify the structure of the render tree | 272 // FIXME: We should not modify the structure of the render tree |
| 273 // during layout. crbug.com/370461 | 273 // during layout. crbug.com/370461 |
| 274 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 274 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
| 275 if (updateMarkerLocation()) { | 275 if (updateMarkerLocation()) { |
| 276 // If the marker is inside we need to redo the preferred width calculati
ons | 276 // If the marker is inside we need to redo the preferred width calculati
ons |
| 277 // as the size of the item now includes the size of the list marker. | 277 // as the size of the item now includes the size of the list marker. |
| 278 if (m_marker->isInside()) | 278 if (m_marker->isInside()) |
| 279 containingBlock()->updateLogicalWidth(); | 279 containingBlock()->updateLogicalWidth(); |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| 283 bool RenderListItem::updateMarkerLocation() | 283 bool RenderListItem::updateMarkerLocation() |
| 284 { | 284 { |
| 285 ASSERT(m_marker); | 285 ASSERT(m_marker); |
| 286 RenderObject* markerParent = m_marker->parent(); | 286 LayoutObject* markerParent = m_marker->parent(); |
| 287 RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker); | 287 LayoutObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker); |
| 288 if (!lineBoxParent) { | 288 if (!lineBoxParent) { |
| 289 // If the marker is currently contained inside an anonymous box, then we | 289 // If the marker is currently contained inside an anonymous box, then we |
| 290 // are the only item in that anonymous box (since no line box parent was | 290 // are the only item in that anonymous box (since no line box parent was |
| 291 // found). It's ok to just leave the marker where it is in this case. | 291 // found). It's ok to just leave the marker where it is in this case. |
| 292 if (markerParent && markerParent->isAnonymousBlock()) | 292 if (markerParent && markerParent->isAnonymousBlock()) |
| 293 lineBoxParent = markerParent; | 293 lineBoxParent = markerParent; |
| 294 else | 294 else |
| 295 lineBoxParent = this; | 295 lineBoxParent = this; |
| 296 } | 296 } |
| 297 | 297 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 // assume that all the following ones have too. | 514 // assume that all the following ones have too. |
| 515 // This gives us the opportunity to stop here and avoid | 515 // This gives us the opportunity to stop here and avoid |
| 516 // marking the same nodes again. | 516 // marking the same nodes again. |
| 517 break; | 517 break; |
| 518 } | 518 } |
| 519 item->updateValue(); | 519 item->updateValue(); |
| 520 } | 520 } |
| 521 } | 521 } |
| 522 | 522 |
| 523 } // namespace blink | 523 } // namespace blink |
| OLD | NEW |