Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: Source/bindings/v8/V8NodeFilterCondition.h

Issue 285213003: Oilpan: move Node traversal objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Drop nullptr type conversions Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/v8/V8Binding.cpp ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef V8NodeFilterCondition_h 31 #ifndef V8NodeFilterCondition_h
32 #define V8NodeFilterCondition_h 32 #define V8NodeFilterCondition_h
33 33
34 #include "bindings/v8/ScopedPersistent.h" 34 #include "bindings/v8/ScopedPersistent.h"
35 #include "bindings/v8/ScriptState.h" 35 #include "bindings/v8/ScriptState.h"
36 #include "core/dom/NodeFilterCondition.h" 36 #include "core/dom/NodeFilterCondition.h"
37 #include "platform/heap/Handle.h"
37 #include <v8.h> 38 #include <v8.h>
38 #include "wtf/PassRefPtr.h" 39 #include "wtf/PassRefPtr.h"
39 40
40 namespace WebCore { 41 namespace WebCore {
41 42
42 class Node; 43 class Node;
43 class ExceptionState; 44 class ExceptionState;
44 45
45 // V8NodeFilterCondition maintains a Javascript implemented callback for 46 // V8NodeFilterCondition maintains a Javascript implemented callback for
46 // filtering Node returned by NodeIterator/TreeWalker. 47 // filtering Node returned by NodeIterator/TreeWalker.
47 // A NodeFilterCondition is referenced by a NodeFilter, and A NodeFilter is 48 // A NodeFilterCondition is referenced by a NodeFilter, and A NodeFilter is
48 // referenced by a NodeIterator/TreeWalker. As V8NodeFilterCondition maintains 49 // referenced by a NodeIterator/TreeWalker. As V8NodeFilterCondition maintains
49 // a Javascript callback which may reference Document, we need to avoid circular 50 // a Javascript callback which may reference Document, we need to avoid circular
50 // reference spanning V8/Blink object space. 51 // reference spanning V8/Blink object space.
51 // To address this issue, V8NodeFilterCondition holds a weak reference to 52 // To address this issue, V8NodeFilterCondition holds a weak reference to
52 // |m_filter|, the Javascript value, and the whole reference is exposed to V8 to 53 // |m_filter|, the Javascript value, and the whole reference is exposed to V8 to
53 // let V8 GC handle collection of |m_filter|. 54 // let V8 GC handle collection of |m_filter|.
54 // (DOM) 55 // (DOM)
55 // NodeIterator ----RefPtr----> NodeFilter ----RefPtr----> NodeFilterCondition 56 // NodeIterator ----RefPtr----> NodeFilter ----RefPtr----> NodeFilterCondition
56 // | ^ | ^ | 57 // | ^ | ^ |
57 // weak | weak | ScopedPersistent(weak) 58 // weak | weak | ScopedPersistent(weak)
58 // | RefPtr | RefPtr | 59 // | RefPtr | RefPtr |
59 // v | v | v 60 // v | v | v
60 // NodeIterator --HiddenValue--> NodeFilter --HiddenValue--> JS Callback 61 // NodeIterator --HiddenValue--> NodeFilter --HiddenValue--> JS Callback
61 // (V8) 62 // (V8)
62 class V8NodeFilterCondition FINAL : public NodeFilterCondition { 63 class V8NodeFilterCondition FINAL : public NodeFilterCondition {
63 public: 64 public:
64 static PassRefPtr<V8NodeFilterCondition> create(v8::Handle<v8::Value> filter , v8::Handle<v8::Object> owner, v8::Isolate* isolate) 65 static PassRefPtrWillBeRawPtr<V8NodeFilterCondition> create(v8::Handle<v8::V alue> filter, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
65 { 66 {
66 return adoptRef(new V8NodeFilterCondition(filter, owner, isolate)); 67 return adoptRefWillBeNoop(new V8NodeFilterCondition(filter, owner, isola te));
67 } 68 }
68 69
69 virtual ~V8NodeFilterCondition(); 70 virtual ~V8NodeFilterCondition();
70 71
71 virtual short acceptNode(Node*, ExceptionState&) const OVERRIDE; 72 virtual short acceptNode(Node*, ExceptionState&) const OVERRIDE;
72 73
73 private: 74 private:
74 // As the value |filter| is maintained by V8GC, the |owner| which references 75 // As the value |filter| is maintained by V8GC, the |owner| which references
75 // V8NodeFilterCondition, usually a wrapper of NodeFilter, is specified here 76 // V8NodeFilterCondition, usually a wrapper of NodeFilter, is specified here
76 // to hold a strong reference to |filter|. 77 // to hold a strong reference to |filter|.
77 V8NodeFilterCondition(v8::Handle<v8::Value> filter, v8::Handle<v8::Object> o wner, v8::Isolate*); 78 V8NodeFilterCondition(v8::Handle<v8::Value> filter, v8::Handle<v8::Object> o wner, v8::Isolate*);
78 79
79 static void setWeakCallback(const v8::WeakCallbackData<v8::Value, V8NodeFilt erCondition>&); 80 static void setWeakCallback(const v8::WeakCallbackData<v8::Value, V8NodeFilt erCondition>&);
80 81
81 RefPtr<ScriptState> m_scriptState; 82 RefPtr<ScriptState> m_scriptState;
82 ScopedPersistent<v8::Value> m_filter; 83 ScopedPersistent<v8::Value> m_filter;
83 }; 84 };
84 85
85 } // namespace WebCore 86 } // namespace WebCore
86 87
87 #endif // V8NodeFilterCondition_h 88 #endif // V8NodeFilterCondition_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Binding.cpp ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698