OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 2 * Copyright (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #include "core/HTMLNames.h" | 24 #include "core/HTMLNames.h" |
25 #include "core/dom/Element.h" | 25 #include "core/dom/Element.h" |
26 #include "core/dom/ElementTraversal.h" | 26 #include "core/dom/ElementTraversal.h" |
27 #include "core/html/HTMLOListElement.h" | 27 #include "core/html/HTMLOListElement.h" |
28 #include "core/layout/CounterNode.h" | 28 #include "core/layout/CounterNode.h" |
29 #include "core/layout/LayoutListItem.h" | 29 #include "core/layout/LayoutListItem.h" |
30 #include "core/layout/LayoutView.h" | 30 #include "core/layout/LayoutView.h" |
31 #include "core/layout/ListMarkerText.h" | 31 #include "core/layout/ListMarkerText.h" |
32 #include "core/style/ComputedStyle.h" | 32 #include "core/style/ComputedStyle.h" |
| 33 #include "wtf/PtrUtil.h" |
33 #include "wtf/StdLibExtras.h" | 34 #include "wtf/StdLibExtras.h" |
| 35 #include <memory> |
34 | 36 |
35 #ifndef NDEBUG | 37 #ifndef NDEBUG |
36 #include <stdio.h> | 38 #include <stdio.h> |
37 #endif | 39 #endif |
38 | 40 |
39 namespace blink { | 41 namespace blink { |
40 | 42 |
41 using namespace HTMLNames; | 43 using namespace HTMLNames; |
42 | 44 |
43 typedef HashMap<AtomicString, RefPtr<CounterNode>> CounterMap; | 45 typedef HashMap<AtomicString, RefPtr<CounterNode>> CounterMap; |
44 typedef HashMap<const LayoutObject*, OwnPtr<CounterMap>> CounterMaps; | 46 typedef HashMap<const LayoutObject*, std::unique_ptr<CounterMap>> CounterMaps; |
45 | 47 |
46 static CounterNode* makeCounterNodeIfNeeded(LayoutObject&, const AtomicString& i
dentifier, bool alwaysCreateCounter); | 48 static CounterNode* makeCounterNodeIfNeeded(LayoutObject&, const AtomicString& i
dentifier, bool alwaysCreateCounter); |
47 | 49 |
48 // See class definition as to why we have this map. | 50 // See class definition as to why we have this map. |
49 static CounterMaps& counterMaps() | 51 static CounterMaps& counterMaps() |
50 { | 52 { |
51 DEFINE_STATIC_LOCAL(CounterMaps, staticCounterMaps, ()); | 53 DEFINE_STATIC_LOCAL(CounterMaps, staticCounterMaps, ()); |
52 return staticCounterMaps; | 54 return staticCounterMaps; |
53 } | 55 } |
54 | 56 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 RefPtr<CounterNode> newParent = nullptr; | 334 RefPtr<CounterNode> newParent = nullptr; |
333 RefPtr<CounterNode> newPreviousSibling = nullptr; | 335 RefPtr<CounterNode> newPreviousSibling = nullptr; |
334 RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value); | 336 RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value); |
335 if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousS
ibling)) | 337 if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousS
ibling)) |
336 newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifi
er); | 338 newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifi
er); |
337 CounterMap* nodeMap; | 339 CounterMap* nodeMap; |
338 if (object.hasCounterNodeMap()) { | 340 if (object.hasCounterNodeMap()) { |
339 nodeMap = counterMaps().get(&object); | 341 nodeMap = counterMaps().get(&object); |
340 } else { | 342 } else { |
341 nodeMap = new CounterMap; | 343 nodeMap = new CounterMap; |
342 counterMaps().set(&object, adoptPtr(nodeMap)); | 344 counterMaps().set(&object, wrapUnique(nodeMap)); |
343 object.setHasCounterNodeMap(true); | 345 object.setHasCounterNodeMap(true); |
344 } | 346 } |
345 nodeMap->set(identifier, newNode); | 347 nodeMap->set(identifier, newNode); |
346 if (newNode->parent()) | 348 if (newNode->parent()) |
347 return newNode.get(); | 349 return newNode.get(); |
348 // Checking if some nodes that were previously counter tree root nodes | 350 // Checking if some nodes that were previously counter tree root nodes |
349 // should become children of this node now. | 351 // should become children of this node now. |
350 CounterMaps& maps = counterMaps(); | 352 CounterMaps& maps = counterMaps(); |
351 Element* stayWithin = parentElement(object); | 353 Element* stayWithin = parentElement(object); |
352 bool skipDescendants; | 354 bool skipDescendants; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 fprintf(stderr, " "); | 627 fprintf(stderr, " "); |
626 fprintf(stderr, "%p N:%p P:%p PS:%p NS:%p C:%p\n", | 628 fprintf(stderr, "%p N:%p P:%p PS:%p NS:%p C:%p\n", |
627 current, current->node(), current->parent(), current->previousSiblin
g(), | 629 current, current->node(), current->parent(), current->previousSiblin
g(), |
628 current->nextSibling(), current->hasCounterNodeMap() ? | 630 current->nextSibling(), current->hasCounterNodeMap() ? |
629 counterName ? blink::counterMaps().get(current)->get(identifier) : (
blink::CounterNode*)1 : (blink::CounterNode*)0); | 631 counterName ? blink::counterMaps().get(current)->get(identifier) : (
blink::CounterNode*)1 : (blink::CounterNode*)0); |
630 } | 632 } |
631 fflush(stderr); | 633 fflush(stderr); |
632 } | 634 } |
633 | 635 |
634 #endif // NDEBUG | 636 #endif // NDEBUG |
OLD | NEW |