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

Side by Side Diff: Source/bindings/core/v8/V8NodeFilterCondition.cpp

Issue 932633002: Call NodeFilter.acceptNode() with correct this value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 | « LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js ('k') | no next file » | 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) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 v8::HandleScope handleScope(isolate); 64 v8::HandleScope handleScope(isolate);
65 v8::Handle<v8::Value> filter = m_filter.newLocal(isolate); 65 v8::Handle<v8::Value> filter = m_filter.newLocal(isolate);
66 66
67 ASSERT(filter.IsEmpty() || filter->IsObject()); 67 ASSERT(filter.IsEmpty() || filter->IsObject());
68 if (filter.IsEmpty()) 68 if (filter.IsEmpty())
69 return NodeFilter::FILTER_ACCEPT; 69 return NodeFilter::FILTER_ACCEPT;
70 70
71 v8::TryCatch exceptionCatcher; 71 v8::TryCatch exceptionCatcher;
72 72
73 v8::Handle<v8::Function> callback; 73 v8::Handle<v8::Function> callback;
74 v8::Handle<v8::Value> receiver;
74 if (filter->IsFunction()) { 75 if (filter->IsFunction()) {
75 callback = v8::Handle<v8::Function>::Cast(filter); 76 callback = v8::Handle<v8::Function>::Cast(filter);
77 receiver = v8::Undefined(isolate);
76 } else { 78 } else {
77 v8::Local<v8::Value> value = filter->ToObject(isolate)->Get(v8AtomicStri ng(isolate, "acceptNode")); 79 v8::Local<v8::Value> value = filter->ToObject(isolate)->Get(v8AtomicStri ng(isolate, "acceptNode"));
78 if (value.IsEmpty() || !value->IsFunction()) { 80 if (value.IsEmpty() || !value->IsFunction()) {
79 exceptionState.throwTypeError("NodeFilter object does not have an ac ceptNode function"); 81 exceptionState.throwTypeError("NodeFilter object does not have an ac ceptNode function");
80 return NodeFilter::FILTER_REJECT; 82 return NodeFilter::FILTER_REJECT;
81 } 83 }
82 callback = v8::Handle<v8::Function>::Cast(value); 84 callback = v8::Handle<v8::Function>::Cast(value);
85 receiver = filter;
83 } 86 }
84 87
85 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu e>[1]); 88 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu e>[1]);
86 v8::Handle<v8::Object> context = m_scriptState->context()->Global(); 89 info[0] = toV8(node, m_scriptState->context()->Global(), isolate);
87 info[0] = toV8(node, context, isolate);
88 90
89 v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState- >executionContext(), callback, context, 1, info.get(), isolate); 91 v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState- >executionContext(), callback, receiver, 1, info.get(), isolate);
90 92
91 if (exceptionCatcher.HasCaught()) { 93 if (exceptionCatcher.HasCaught()) {
92 exceptionState.rethrowV8Exception(exceptionCatcher.Exception()); 94 exceptionState.rethrowV8Exception(exceptionCatcher.Exception());
93 return NodeFilter::FILTER_REJECT; 95 return NodeFilter::FILTER_REJECT;
94 } 96 }
95 97
96 ASSERT(!result.IsEmpty()); 98 ASSERT(!result.IsEmpty());
97 99
98 return result->Int32Value(); 100 return result->Int32Value();
99 } 101 }
100 102
101 void V8NodeFilterCondition::setWeakCallback(const v8::WeakCallbackData<v8::Value , V8NodeFilterCondition>& data) 103 void V8NodeFilterCondition::setWeakCallback(const v8::WeakCallbackData<v8::Value , V8NodeFilterCondition>& data)
102 { 104 {
103 data.GetParameter()->m_filter.clear(); 105 data.GetParameter()->m_filter.clear();
104 } 106 }
105 107
106 } // namespace blink 108 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/TreeWalker/script-tests/acceptNode-filter.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698