| 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" | |
| 34 #include "wtf/StdLibExtras.h" | 33 #include "wtf/StdLibExtras.h" |
| 35 #include <memory> | |
| 36 | 34 |
| 37 #ifndef NDEBUG | 35 #ifndef NDEBUG |
| 38 #include <stdio.h> | 36 #include <stdio.h> |
| 39 #endif | 37 #endif |
| 40 | 38 |
| 41 namespace blink { | 39 namespace blink { |
| 42 | 40 |
| 43 using namespace HTMLNames; | 41 using namespace HTMLNames; |
| 44 | 42 |
| 45 typedef HashMap<AtomicString, RefPtr<CounterNode>> CounterMap; | 43 typedef HashMap<AtomicString, RefPtr<CounterNode>> CounterMap; |
| 46 typedef HashMap<const LayoutObject*, std::unique_ptr<CounterMap>> CounterMaps; | 44 typedef HashMap<const LayoutObject*, OwnPtr<CounterMap>> CounterMaps; |
| 47 | 45 |
| 48 static CounterNode* makeCounterNodeIfNeeded(LayoutObject&, const AtomicString& i
dentifier, bool alwaysCreateCounter); | 46 static CounterNode* makeCounterNodeIfNeeded(LayoutObject&, const AtomicString& i
dentifier, bool alwaysCreateCounter); |
| 49 | 47 |
| 50 // See class definition as to why we have this map. | 48 // See class definition as to why we have this map. |
| 51 static CounterMaps& counterMaps() | 49 static CounterMaps& counterMaps() |
| 52 { | 50 { |
| 53 DEFINE_STATIC_LOCAL(CounterMaps, staticCounterMaps, ()); | 51 DEFINE_STATIC_LOCAL(CounterMaps, staticCounterMaps, ()); |
| 54 return staticCounterMaps; | 52 return staticCounterMaps; |
| 55 } | 53 } |
| 56 | 54 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 RefPtr<CounterNode> newParent = nullptr; | 332 RefPtr<CounterNode> newParent = nullptr; |
| 335 RefPtr<CounterNode> newPreviousSibling = nullptr; | 333 RefPtr<CounterNode> newPreviousSibling = nullptr; |
| 336 RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value); | 334 RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value); |
| 337 if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousS
ibling)) | 335 if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousS
ibling)) |
| 338 newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifi
er); | 336 newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifi
er); |
| 339 CounterMap* nodeMap; | 337 CounterMap* nodeMap; |
| 340 if (object.hasCounterNodeMap()) { | 338 if (object.hasCounterNodeMap()) { |
| 341 nodeMap = counterMaps().get(&object); | 339 nodeMap = counterMaps().get(&object); |
| 342 } else { | 340 } else { |
| 343 nodeMap = new CounterMap; | 341 nodeMap = new CounterMap; |
| 344 counterMaps().set(&object, wrapUnique(nodeMap)); | 342 counterMaps().set(&object, adoptPtr(nodeMap)); |
| 345 object.setHasCounterNodeMap(true); | 343 object.setHasCounterNodeMap(true); |
| 346 } | 344 } |
| 347 nodeMap->set(identifier, newNode); | 345 nodeMap->set(identifier, newNode); |
| 348 if (newNode->parent()) | 346 if (newNode->parent()) |
| 349 return newNode.get(); | 347 return newNode.get(); |
| 350 // Checking if some nodes that were previously counter tree root nodes | 348 // Checking if some nodes that were previously counter tree root nodes |
| 351 // should become children of this node now. | 349 // should become children of this node now. |
| 352 CounterMaps& maps = counterMaps(); | 350 CounterMaps& maps = counterMaps(); |
| 353 Element* stayWithin = parentElement(object); | 351 Element* stayWithin = parentElement(object); |
| 354 bool skipDescendants; | 352 bool skipDescendants; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 fprintf(stderr, " "); | 625 fprintf(stderr, " "); |
| 628 fprintf(stderr, "%p N:%p P:%p PS:%p NS:%p C:%p\n", | 626 fprintf(stderr, "%p N:%p P:%p PS:%p NS:%p C:%p\n", |
| 629 current, current->node(), current->parent(), current->previousSiblin
g(), | 627 current, current->node(), current->parent(), current->previousSiblin
g(), |
| 630 current->nextSibling(), current->hasCounterNodeMap() ? | 628 current->nextSibling(), current->hasCounterNodeMap() ? |
| 631 counterName ? blink::counterMaps().get(current)->get(identifier) : (
blink::CounterNode*)1 : (blink::CounterNode*)0); | 629 counterName ? blink::counterMaps().get(current)->get(identifier) : (
blink::CounterNode*)1 : (blink::CounterNode*)0); |
| 632 } | 630 } |
| 633 fflush(stderr); | 631 fflush(stderr); |
| 634 } | 632 } |
| 635 | 633 |
| 636 #endif // NDEBUG | 634 #endif // NDEBUG |
| OLD | NEW |