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 10 matching lines...) Expand all Loading... |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #include "core/layout/LayoutListItem.h" | 24 #include "core/layout/LayoutListItem.h" |
25 | 25 |
26 #include "core/HTMLNames.h" | 26 #include "core/HTMLNames.h" |
27 #include "core/dom/shadow/FlatTreeTraversal.h" | 27 #include "core/dom/shadow/FlatTreeTraversal.h" |
28 #include "core/html/HTMLOListElement.h" | 28 #include "core/html/HTMLOListElement.h" |
29 #include "core/layout/LayoutListMarker.h" | 29 #include "core/layout/LayoutListMarker.h" |
30 #include "core/paint/ListItemPainter.h" | 30 #include "core/paint/ListItemPainter.h" |
| 31 #include "wtf/SaturatedArithmetic.h" |
31 #include "wtf/StdLibExtras.h" | 32 #include "wtf/StdLibExtras.h" |
32 #include "wtf/text/StringBuilder.h" | 33 #include "wtf/text/StringBuilder.h" |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 using namespace HTMLNames; | 37 using namespace HTMLNames; |
37 | 38 |
38 LayoutListItem::LayoutListItem(Element* element) | 39 LayoutListItem::LayoutListItem(Element* element) |
39 : LayoutBlockFlow(element), | 40 : LayoutBlockFlow(element), |
40 m_marker(nullptr), | 41 m_marker(nullptr), |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 Node* list = enclosingList(this); | 221 Node* list = enclosingList(this); |
221 HTMLOListElement* oListElement = | 222 HTMLOListElement* oListElement = |
222 isHTMLOListElement(list) ? toHTMLOListElement(list) : nullptr; | 223 isHTMLOListElement(list) ? toHTMLOListElement(list) : nullptr; |
223 int valueStep = 1; | 224 int valueStep = 1; |
224 if (oListElement && oListElement->isReversed()) | 225 if (oListElement && oListElement->isReversed()) |
225 valueStep = -1; | 226 valueStep = -1; |
226 | 227 |
227 // FIXME: This recurses to a possible depth of the length of the list. | 228 // FIXME: This recurses to a possible depth of the length of the list. |
228 // That's not good -- we need to change this to an iterative algorithm. | 229 // That's not good -- we need to change this to an iterative algorithm. |
229 if (LayoutListItem* previousItem = previousListItem(list, this)) | 230 if (LayoutListItem* previousItem = previousListItem(list, this)) |
230 return previousItem->value() + valueStep; | 231 return SaturatedAddition(previousItem->value(), valueStep); |
231 | 232 |
232 if (oListElement) | 233 if (oListElement) |
233 return oListElement->start(); | 234 return oListElement->start(); |
234 | 235 |
235 return 1; | 236 return 1; |
236 } | 237 } |
237 | 238 |
238 void LayoutListItem::updateValueNow() const { | 239 void LayoutListItem::updateValueNow() const { |
239 m_value = calcValue(); | 240 m_value = calcValue(); |
240 m_isValueUpToDate = true; | 241 m_isValueUpToDate = true; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 // assume that all the following ones have too. | 541 // assume that all the following ones have too. |
541 // This gives us the opportunity to stop here and avoid | 542 // This gives us the opportunity to stop here and avoid |
542 // marking the same nodes again. | 543 // marking the same nodes again. |
543 break; | 544 break; |
544 } | 545 } |
545 item->updateValue(); | 546 item->updateValue(); |
546 } | 547 } |
547 } | 548 } |
548 | 549 |
549 } // namespace blink | 550 } // namespace blink |
OLD | NEW |