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

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

Issue 225783003: Remove ScriptState from NodeIterator, NodeFilter, NodeFilterCondition and TreeWalker (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/v8/V8NodeFilterCondition.cpp » ('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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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/NewScriptState.h"
34 #include "bindings/v8/ScopedPersistent.h" 35 #include "bindings/v8/ScopedPersistent.h"
35 #include "core/dom/NodeFilterCondition.h" 36 #include "core/dom/NodeFilterCondition.h"
36 #include <v8.h> 37 #include <v8.h>
37 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
38 39
39 namespace WebCore { 40 namespace WebCore {
40 41
41 class Node; 42 class Node;
42 class ScriptState; 43 class ExceptionState;
43 44
44 // V8NodeFilterCondition maintains a Javascript implemented callback for 45 // V8NodeFilterCondition maintains a Javascript implemented callback for
45 // filtering Node returned by NodeIterator/TreeWalker. 46 // filtering Node returned by NodeIterator/TreeWalker.
46 // A NodeFilterCondition is referenced by a NodeFilter, and A NodeFilter is 47 // A NodeFilterCondition is referenced by a NodeFilter, and A NodeFilter is
47 // referenced by a NodeIterator/TreeWalker. As V8NodeFilterCondition maintains 48 // referenced by a NodeIterator/TreeWalker. As V8NodeFilterCondition maintains
48 // a Javascript callback which may reference Document, we need to avoid circular 49 // a Javascript callback which may reference Document, we need to avoid circular
49 // reference spanning V8/Blink object space. 50 // reference spanning V8/Blink object space.
50 // To address this issue, V8NodeFilterCondition holds a weak reference to 51 // To address this issue, V8NodeFilterCondition holds a weak reference to
51 // |m_filter|, the Javascript value, and the whole reference is exposed to V8 to 52 // |m_filter|, the Javascript value, and the whole reference is exposed to V8 to
52 // let V8 GC handle collection of |m_filter|. 53 // let V8 GC handle collection of |m_filter|.
53 // (DOM) 54 // (DOM)
54 // NodeIterator ----RefPtr----> NodeFilter ----RefPtr----> NodeFilterCondition 55 // NodeIterator ----RefPtr----> NodeFilter ----RefPtr----> NodeFilterCondition
55 // | ^ | ^ | 56 // | ^ | ^ |
56 // weak | weak | ScopedPersistent(weak) 57 // weak | weak | ScopedPersistent(weak)
57 // | RefPtr | RefPtr | 58 // | RefPtr | RefPtr |
58 // v | v | v 59 // v | v | v
59 // NodeIterator --HiddenValue--> NodeFilter --HiddenValue--> JS Callback 60 // NodeIterator --HiddenValue--> NodeFilter --HiddenValue--> JS Callback
60 // (V8) 61 // (V8)
61 class V8NodeFilterCondition FINAL : public NodeFilterCondition { 62 class V8NodeFilterCondition FINAL : public NodeFilterCondition {
62 public: 63 public:
63 static PassRefPtr<V8NodeFilterCondition> create(v8::Handle<v8::Value> filter , v8::Handle<v8::Object> owner, v8::Isolate* isolate) 64 static PassRefPtr<V8NodeFilterCondition> create(v8::Handle<v8::Value> filter , v8::Handle<v8::Object> owner, v8::Isolate* isolate)
64 { 65 {
65 return adoptRef(new V8NodeFilterCondition(filter, owner, isolate)); 66 return adoptRef(new V8NodeFilterCondition(filter, owner, isolate));
66 } 67 }
67 68
68 virtual ~V8NodeFilterCondition(); 69 virtual ~V8NodeFilterCondition();
69 70
70 virtual short acceptNode(ScriptState*, Node*) const OVERRIDE; 71 virtual short acceptNode(Node*, ExceptionState&) const OVERRIDE;
71 72
72 private: 73 private:
73 // As the value |filter| is maintained by V8GC, the |owner| which references 74 // As the value |filter| is maintained by V8GC, the |owner| which references
74 // V8NodeFilterCondition, usually a wrapper of NodeFilter, is specified here 75 // V8NodeFilterCondition, usually a wrapper of NodeFilter, is specified here
75 // to hold a strong reference to |filter|. 76 // to hold a strong reference to |filter|.
76 V8NodeFilterCondition(v8::Handle<v8::Value> filter, v8::Handle<v8::Object> o wner, v8::Isolate*); 77 V8NodeFilterCondition(v8::Handle<v8::Value> filter, v8::Handle<v8::Object> o wner, v8::Isolate*);
77 78
78 static void setWeakCallback(const v8::WeakCallbackData<v8::Value, V8NodeFilt erCondition>&); 79 static void setWeakCallback(const v8::WeakCallbackData<v8::Value, V8NodeFilt erCondition>&);
79 80
81 RefPtr<NewScriptState> m_scriptState;
80 ScopedPersistent<v8::Value> m_filter; 82 ScopedPersistent<v8::Value> m_filter;
81 }; 83 };
82 84
83 } // namespace WebCore 85 } // namespace WebCore
84 86
85 #endif // V8NodeFilterCondition_h 87 #endif // V8NodeFilterCondition_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/v8/V8NodeFilterCondition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698