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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 updateListMarkerNumbers(); | 85 updateListMarkerNumbers(); |
86 } | 86 } |
87 | 87 |
88 void RenderListItem::willBeRemovedFromTree() | 88 void RenderListItem::willBeRemovedFromTree() |
89 { | 89 { |
90 RenderBlockFlow::willBeRemovedFromTree(); | 90 RenderBlockFlow::willBeRemovedFromTree(); |
91 | 91 |
92 updateListMarkerNumbers(); | 92 updateListMarkerNumbers(); |
93 } | 93 } |
94 | 94 |
95 static bool isList(const Node* node) | 95 static bool isList(const Node& node) |
96 { | 96 { |
97 return (node->hasTagName(ulTag) || node->hasTagName(olTag)); | 97 return isHTMLUListElement(node) || isHTMLOListElement(node); |
98 } | 98 } |
99 | 99 |
100 // Returns the enclosing list with respect to the DOM order. | 100 // Returns the enclosing list with respect to the DOM order. |
101 static Node* enclosingList(const RenderListItem* listItem) | 101 static Node* enclosingList(const RenderListItem* listItem) |
102 { | 102 { |
103 Node* listItemNode = listItem->node(); | 103 Node* listItemNode = listItem->node(); |
104 Node* firstNode = 0; | 104 Node* firstNode = 0; |
105 // We use parentNode because the enclosing list could be a ShadowRoot that's
not Element. | 105 // We use parentNode because the enclosing list could be a ShadowRoot that's
not Element. |
106 for (Node* parent = NodeRenderingTraversal::parent(listItemNode); parent; pa
rent = NodeRenderingTraversal::parent(parent)) { | 106 for (Node* parent = NodeRenderingTraversal::parent(listItemNode); parent; pa
rent = NodeRenderingTraversal::parent(parent)) { |
107 if (isList(parent)) | 107 if (isList(*parent)) |
108 return parent; | 108 return parent; |
109 if (!firstNode) | 109 if (!firstNode) |
110 firstNode = parent; | 110 firstNode = parent; |
111 } | 111 } |
112 | 112 |
113 // If there's no actual <ul> or <ol> list element, then the first found | 113 // If there's no actual <ul> or <ol> list element, then the first found |
114 // node acts as our list for purposes of determining what other list items | 114 // node acts as our list for purposes of determining what other list items |
115 // should be numbered as part of the same list. | 115 // should be numbered as part of the same list. |
116 return firstNode; | 116 return firstNode; |
117 } | 117 } |
118 | 118 |
119 // Returns the next list item with respect to the DOM order. | 119 // Returns the next list item with respect to the DOM order. |
120 static RenderListItem* nextListItem(const Node* listNode, const RenderListItem*
item = 0) | 120 static RenderListItem* nextListItem(const Node* listNode, const RenderListItem*
item = 0) |
121 { | 121 { |
122 if (!listNode) | 122 if (!listNode) |
123 return 0; | 123 return 0; |
124 | 124 |
125 const Node* current = item ? item->node() : listNode; | 125 const Node* current = item ? item->node() : listNode; |
126 ASSERT(current); | 126 ASSERT(current); |
127 ASSERT(!current->document().childNeedsDistributionRecalc()); | 127 ASSERT(!current->document().childNeedsDistributionRecalc()); |
128 current = NodeRenderingTraversal::next(current, listNode); | 128 current = NodeRenderingTraversal::next(current, listNode); |
129 | 129 |
130 while (current) { | 130 while (current) { |
131 if (isList(current)) { | 131 if (isList(*current)) { |
132 // We've found a nested, independent list: nothing to do here. | 132 // We've found a nested, independent list: nothing to do here. |
133 current = NodeRenderingTraversal::next(current, listNode); | 133 current = NodeRenderingTraversal::next(current, listNode); |
134 continue; | 134 continue; |
135 } | 135 } |
136 | 136 |
137 RenderObject* renderer = current->renderer(); | 137 RenderObject* renderer = current->renderer(); |
138 if (renderer && renderer->isListItem()) | 138 if (renderer && renderer->isListItem()) |
139 return toRenderListItem(renderer); | 139 return toRenderListItem(renderer); |
140 | 140 |
141 // FIXME: Can this be optimized to skip the children of the elements wit
hout a renderer? | 141 // FIXME: Can this be optimized to skip the children of the elements wit
hout a renderer? |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 return itemCount; | 188 return itemCount; |
189 } | 189 } |
190 | 190 |
191 inline int RenderListItem::calcValue() const | 191 inline int RenderListItem::calcValue() const |
192 { | 192 { |
193 if (m_hasExplicitValue) | 193 if (m_hasExplicitValue) |
194 return m_explicitValue; | 194 return m_explicitValue; |
195 | 195 |
196 Node* list = enclosingList(this); | 196 Node* list = enclosingList(this); |
197 HTMLOListElement* oListElement = (list && list->hasTagName(olTag)) ? toHTMLO
ListElement(list) : 0; | 197 HTMLOListElement* oListElement = isHTMLOListElement(list) ? toHTMLOListEleme
nt(list) : 0; |
198 int valueStep = 1; | 198 int valueStep = 1; |
199 if (oListElement && oListElement->isReversed()) | 199 if (oListElement && oListElement->isReversed()) |
200 valueStep = -1; | 200 valueStep = -1; |
201 | 201 |
202 // FIXME: This recurses to a possible depth of the length of the list. | 202 // FIXME: This recurses to a possible depth of the length of the list. |
203 // That's not good -- we need to change this to an iterative algorithm. | 203 // That's not good -- we need to change this to an iterative algorithm. |
204 if (RenderListItem* previousItem = previousListItem(list, this)) | 204 if (RenderListItem* previousItem = previousListItem(list, this)) |
205 return previousItem->value() + valueStep; | 205 return previousItem->value() + valueStep; |
206 | 206 |
207 if (oListElement) | 207 if (oListElement) |
(...skipping 27 matching lines...) Expand all Loading... |
235 if (currChild->isInline() && (!currChild->isRenderInline() || curr->gene
ratesLineBoxesForInlineChild(currChild))) | 235 if (currChild->isInline() && (!currChild->isRenderInline() || curr->gene
ratesLineBoxesForInlineChild(currChild))) |
236 return curr; | 236 return curr; |
237 | 237 |
238 if (currChild->isFloating() || currChild->isOutOfFlowPositioned()) | 238 if (currChild->isFloating() || currChild->isOutOfFlowPositioned()) |
239 continue; | 239 continue; |
240 | 240 |
241 if (!currChild->isRenderBlockFlow() || (currChild->isBox() && toRenderBo
x(currChild)->isWritingModeRoot())) | 241 if (!currChild->isRenderBlockFlow() || (currChild->isBox() && toRenderBo
x(currChild)->isWritingModeRoot())) |
242 break; | 242 break; |
243 | 243 |
244 if (curr->isListItem() && inQuirksMode && currChild->node() && | 244 if (curr->isListItem() && inQuirksMode && currChild->node() && |
245 (currChild->node()->hasTagName(ulTag)|| currChild->node()->hasTagNam
e(olTag))) | 245 (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*currC
hild->node()))) |
246 break; | 246 break; |
247 | 247 |
248 RenderObject* lineBox = getParentOfFirstLineBox(toRenderBlockFlow(currCh
ild), marker); | 248 RenderObject* lineBox = getParentOfFirstLineBox(toRenderBlockFlow(currCh
ild), marker); |
249 if (lineBox) | 249 if (lineBox) |
250 return lineBox; | 250 return lineBox; |
251 } | 251 } |
252 | 252 |
253 return 0; | 253 return 0; |
254 } | 254 } |
255 | 255 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 if (node()->document().childNeedsDistributionRecalc()) | 510 if (node()->document().childNeedsDistributionRecalc()) |
511 return; | 511 return; |
512 | 512 |
513 Node* listNode = enclosingList(this); | 513 Node* listNode = enclosingList(this); |
514 // The list node can be the shadow root which has no renderer. | 514 // The list node can be the shadow root which has no renderer. |
515 ASSERT(listNode); | 515 ASSERT(listNode); |
516 if (!listNode) | 516 if (!listNode) |
517 return; | 517 return; |
518 | 518 |
519 bool isListReversed = false; | 519 bool isListReversed = false; |
520 HTMLOListElement* oListElement = (listNode && listNode->hasTagName(olTag)) ?
toHTMLOListElement(listNode) : 0; | 520 HTMLOListElement* oListElement = isHTMLOListElement(listNode) ? toHTMLOListE
lement(listNode) : 0; |
521 if (oListElement) { | 521 if (oListElement) { |
522 oListElement->itemCountChanged(); | 522 oListElement->itemCountChanged(); |
523 isListReversed = oListElement->isReversed(); | 523 isListReversed = oListElement->isReversed(); |
524 } | 524 } |
525 for (RenderListItem* item = previousOrNextItem(isListReversed, listNode, thi
s); item; item = previousOrNextItem(isListReversed, listNode, item)) { | 525 for (RenderListItem* item = previousOrNextItem(isListReversed, listNode, thi
s); item; item = previousOrNextItem(isListReversed, listNode, item)) { |
526 if (!item->m_isValueUpToDate) { | 526 if (!item->m_isValueUpToDate) { |
527 // If an item has been marked for update before, we can safely | 527 // If an item has been marked for update before, we can safely |
528 // assume that all the following ones have too. | 528 // assume that all the following ones have too. |
529 // This gives us the opportunity to stop here and avoid | 529 // This gives us the opportunity to stop here and avoid |
530 // marking the same nodes again. | 530 // marking the same nodes again. |
531 break; | 531 break; |
532 } | 532 } |
533 item->updateValue(); | 533 item->updateValue(); |
534 } | 534 } |
535 } | 535 } |
536 | 536 |
537 } // namespace WebCore | 537 } // namespace WebCore |
OLD | NEW |