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 firstNode = parent; | 122 firstNode = parent; |
123 } | 123 } |
124 | 124 |
125 // If there's no actual <ul> or <ol> list element, then the first found | 125 // If there's no actual <ul> or <ol> list element, then the first found |
126 // node acts as our list for purposes of determining what other list items | 126 // node acts as our list for purposes of determining what other list items |
127 // should be numbered as part of the same list. | 127 // should be numbered as part of the same list. |
128 return firstNode; | 128 return firstNode; |
129 } | 129 } |
130 | 130 |
131 // Returns the next list item with respect to the DOM order. | 131 // Returns the next list item with respect to the DOM order. |
132 static LayoutListItem* nextListItem(const Node* listNode, const LayoutListItem*
item = 0) | 132 static LayoutListItem* nextListItem(const Node* listNode, const LayoutListItem*
item = nullptr) |
133 { | 133 { |
134 if (!listNode) | 134 if (!listNode) |
135 return 0; | 135 return nullptr; |
136 | 136 |
137 const Node* current = item ? item->node() : listNode; | 137 const Node* current = item ? item->node() : listNode; |
138 ASSERT(current); | 138 ASSERT(current); |
139 ASSERT(!current->document().childNeedsDistributionRecalc()); | 139 ASSERT(!current->document().childNeedsDistributionRecalc()); |
140 current = LayoutTreeBuilderTraversal::next(*current, listNode); | 140 current = LayoutTreeBuilderTraversal::next(*current, listNode); |
141 | 141 |
142 while (current) { | 142 while (current) { |
143 if (isList(*current)) { | 143 if (isList(*current)) { |
144 // We've found a nested, independent list: nothing to do here. | 144 // We've found a nested, independent list: nothing to do here. |
145 current = LayoutTreeBuilderTraversal::nextSkippingChildren(*current,
listNode); | 145 current = LayoutTreeBuilderTraversal::nextSkippingChildren(*current,
listNode); |
146 continue; | 146 continue; |
147 } | 147 } |
148 | 148 |
149 LayoutObject* layoutObject = current->layoutObject(); | 149 LayoutObject* layoutObject = current->layoutObject(); |
150 if (layoutObject && layoutObject->isListItem()) | 150 if (layoutObject && layoutObject->isListItem()) |
151 return toLayoutListItem(layoutObject); | 151 return toLayoutListItem(layoutObject); |
152 | 152 |
153 // FIXME: Can this be optimized to skip the children of the elements wit
hout a layoutObject? | 153 // FIXME: Can this be optimized to skip the children of the elements wit
hout a layoutObject? |
154 current = LayoutTreeBuilderTraversal::next(*current, listNode); | 154 current = LayoutTreeBuilderTraversal::next(*current, listNode); |
155 } | 155 } |
156 | 156 |
157 return 0; | 157 return nullptr; |
158 } | 158 } |
159 | 159 |
160 // Returns the previous list item with respect to the DOM order. | 160 // Returns the previous list item with respect to the DOM order. |
161 static LayoutListItem* previousListItem(const Node* listNode, const LayoutListIt
em* item) | 161 static LayoutListItem* previousListItem(const Node* listNode, const LayoutListIt
em* item) |
162 { | 162 { |
163 Node* current = item->node(); | 163 Node* current = item->node(); |
164 ASSERT(current); | 164 ASSERT(current); |
165 ASSERT(!current->document().childNeedsDistributionRecalc()); | 165 ASSERT(!current->document().childNeedsDistributionRecalc()); |
166 for (current = LayoutTreeBuilderTraversal::previous(*current, listNode); cur
rent && current != listNode; current = LayoutTreeBuilderTraversal::previous(*cur
rent, listNode)) { | 166 for (current = LayoutTreeBuilderTraversal::previous(*current, listNode); cur
rent && current != listNode; current = LayoutTreeBuilderTraversal::previous(*cur
rent, listNode)) { |
167 LayoutObject* layoutObject = current->layoutObject(); | 167 LayoutObject* layoutObject = current->layoutObject(); |
168 if (!layoutObject || (layoutObject && !layoutObject->isListItem())) | 168 if (!layoutObject || (layoutObject && !layoutObject->isListItem())) |
169 continue; | 169 continue; |
170 Node* otherList = enclosingList(toLayoutListItem(layoutObject)); | 170 Node* otherList = enclosingList(toLayoutListItem(layoutObject)); |
171 // This item is part of our current list, so it's what we're looking for
. | 171 // This item is part of our current list, so it's what we're looking for
. |
172 if (listNode == otherList) | 172 if (listNode == otherList) |
173 return toLayoutListItem(layoutObject); | 173 return toLayoutListItem(layoutObject); |
174 // We found ourself inside another list; lets skip the rest of it. | 174 // We found ourself inside another list; lets skip the rest of it. |
175 // Use nextIncludingPseudo() here because the other list itself may actu
ally | 175 // Use nextIncludingPseudo() here because the other list itself may actu
ally |
176 // be a list item itself. We need to examine it, so we do this to counte
ract | 176 // be a list item itself. We need to examine it, so we do this to counte
ract |
177 // the previousIncludingPseudo() that will be done by the loop. | 177 // the previousIncludingPseudo() that will be done by the loop. |
178 if (otherList) | 178 if (otherList) |
179 current = LayoutTreeBuilderTraversal::next(*otherList, listNode); | 179 current = LayoutTreeBuilderTraversal::next(*otherList, listNode); |
180 } | 180 } |
181 return 0; | 181 return nullptr; |
182 } | 182 } |
183 | 183 |
184 void LayoutListItem::updateItemValuesForOrderedList(const HTMLOListElement* list
Node) | 184 void LayoutListItem::updateItemValuesForOrderedList(const HTMLOListElement* list
Node) |
185 { | 185 { |
186 ASSERT(listNode); | 186 ASSERT(listNode); |
187 | 187 |
188 for (LayoutListItem* listItem = nextListItem(listNode); listItem; listItem =
nextListItem(listNode, listItem)) | 188 for (LayoutListItem* listItem = nextListItem(listNode); listItem; listItem =
nextListItem(listNode, listItem)) |
189 listItem->updateValue(); | 189 listItem->updateValue(); |
190 } | 190 } |
191 | 191 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 bool LayoutListItem::isEmpty() const | 231 bool LayoutListItem::isEmpty() const |
232 { | 232 { |
233 return lastChild() == m_marker; | 233 return lastChild() == m_marker; |
234 } | 234 } |
235 | 235 |
236 static LayoutObject* getParentOfFirstLineBox(LayoutBlockFlow* curr, LayoutObject
* marker) | 236 static LayoutObject* getParentOfFirstLineBox(LayoutBlockFlow* curr, LayoutObject
* marker) |
237 { | 237 { |
238 LayoutObject* firstChild = curr->firstChild(); | 238 LayoutObject* firstChild = curr->firstChild(); |
239 if (!firstChild) | 239 if (!firstChild) |
240 return 0; | 240 return nullptr; |
241 | 241 |
242 bool inQuirksMode = curr->document().inQuirksMode(); | 242 bool inQuirksMode = curr->document().inQuirksMode(); |
243 for (LayoutObject* currChild = firstChild; currChild; currChild = currChild-
>nextSibling()) { | 243 for (LayoutObject* currChild = firstChild; currChild; currChild = currChild-
>nextSibling()) { |
244 if (currChild == marker) | 244 if (currChild == marker) |
245 continue; | 245 continue; |
246 | 246 |
247 if (currChild->isInline() && (!currChild->isLayoutInline() || curr->gene
ratesLineBoxesForInlineChild(currChild))) | 247 if (currChild->isInline() && (!currChild->isLayoutInline() || curr->gene
ratesLineBoxesForInlineChild(currChild))) |
248 return curr; | 248 return curr; |
249 | 249 |
250 if (currChild->isFloating() || currChild->isOutOfFlowPositioned()) | 250 if (currChild->isFloating() || currChild->isOutOfFlowPositioned()) |
251 continue; | 251 continue; |
252 | 252 |
253 if (!currChild->isLayoutBlockFlow() || (currChild->isBox() && toLayoutBo
x(currChild)->isWritingModeRoot())) | 253 if (!currChild->isLayoutBlockFlow() || (currChild->isBox() && toLayoutBo
x(currChild)->isWritingModeRoot())) |
254 break; | 254 break; |
255 | 255 |
256 if (curr->isListItem() && inQuirksMode && currChild->node() | 256 if (curr->isListItem() && inQuirksMode && currChild->node() |
257 && (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*cu
rrChild->node()))) | 257 && (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*cu
rrChild->node()))) |
258 break; | 258 break; |
259 | 259 |
260 LayoutObject* lineBox = getParentOfFirstLineBox(toLayoutBlockFlow(currCh
ild), marker); | 260 LayoutObject* lineBox = getParentOfFirstLineBox(toLayoutBlockFlow(currCh
ild), marker); |
261 if (lineBox) | 261 if (lineBox) |
262 return lineBox; | 262 return lineBox; |
263 } | 263 } |
264 | 264 |
265 return 0; | 265 return nullptr; |
266 } | 266 } |
267 | 267 |
268 void LayoutListItem::updateValue() | 268 void LayoutListItem::updateValue() |
269 { | 269 { |
270 if (!m_hasExplicitValue) { | 270 if (!m_hasExplicitValue) { |
271 m_isValueUpToDate = false; | 271 m_isValueUpToDate = false; |
272 if (m_marker) | 272 if (m_marker) |
273 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
LayoutInvalidationReason::ListValueChange); | 273 m_marker->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
LayoutInvalidationReason::ListValueChange); |
274 } | 274 } |
275 } | 275 } |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 // assume that all the following ones have too. | 498 // assume that all the following ones have too. |
499 // This gives us the opportunity to stop here and avoid | 499 // This gives us the opportunity to stop here and avoid |
500 // marking the same nodes again. | 500 // marking the same nodes again. |
501 break; | 501 break; |
502 } | 502 } |
503 item->updateValue(); | 503 item->updateValue(); |
504 } | 504 } |
505 } | 505 } |
506 | 506 |
507 } // namespace blink | 507 } // namespace blink |
OLD | NEW |