OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 27 matching lines...) Expand all Loading... |
38 // Maps elements to the observer watching them. At most one per | 38 // Maps elements to the observer watching them. At most one per |
39 // element at a time. | 39 // element at a time. |
40 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Element>, RawPtrWillBeMember<Cu
stomElementObserver> > ElementObserverMap; | 40 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Element>, RawPtrWillBeMember<Cu
stomElementObserver> > ElementObserverMap; |
41 | 41 |
42 static ElementObserverMap& elementObservers() | 42 static ElementObserverMap& elementObservers() |
43 { | 43 { |
44 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ElementObserverMap>, map, (adoptP
trWillBeNoop(new ElementObserverMap()))); | 44 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ElementObserverMap>, map, (adoptP
trWillBeNoop(new ElementObserverMap()))); |
45 return *map; | 45 return *map; |
46 } | 46 } |
47 | 47 |
48 void CustomElementObserver::notifyElementDidFinishParsingChildren(Element* eleme
nt) | |
49 { | |
50 ElementObserverMap::iterator it = elementObservers().find(element); | |
51 if (it == elementObservers().end()) | |
52 return; | |
53 it->value->elementDidFinishParsingChildren(element); | |
54 } | |
55 | |
56 void CustomElementObserver::notifyElementWasDestroyed(Element* element) | 48 void CustomElementObserver::notifyElementWasDestroyed(Element* element) |
57 { | 49 { |
58 ElementObserverMap::iterator it = elementObservers().find(element); | 50 ElementObserverMap::iterator it = elementObservers().find(element); |
59 if (it == elementObservers().end()) | 51 if (it == elementObservers().end()) |
60 return; | 52 return; |
61 it->value->elementWasDestroyed(element); | 53 it->value->elementWasDestroyed(element); |
62 } | 54 } |
63 | 55 |
64 void CustomElementObserver::observe(Element* element) | 56 void CustomElementObserver::observe(Element* element) |
65 { | 57 { |
66 ElementObserverMap::AddResult result = elementObservers().add(element, this)
; | 58 ElementObserverMap::AddResult result = elementObservers().add(element, this)
; |
67 ASSERT_UNUSED(result, result.isNewEntry); | 59 ASSERT_UNUSED(result, result.isNewEntry); |
68 } | 60 } |
69 | 61 |
70 void CustomElementObserver::unobserve(Element* element) | 62 void CustomElementObserver::unobserve(Element* element) |
71 { | 63 { |
72 CustomElementObserver* observer = elementObservers().take(element); | 64 CustomElementObserver* observer = elementObservers().take(element); |
73 ASSERT_UNUSED(observer, observer == this); | 65 ASSERT_UNUSED(observer, observer == this); |
74 } | 66 } |
75 | 67 |
76 } // namespace blink | 68 } // namespace blink |
OLD | NEW |