OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if (filter->IsFunction()) | 74 if (filter->IsFunction()) |
75 callback = v8::Handle<v8::Function>::Cast(filter); | 75 callback = v8::Handle<v8::Function>::Cast(filter); |
76 else { | 76 else { |
77 v8::Local<v8::Value> value = filter->ToObject()->Get(v8AtomicString(isol
ate, "acceptNode")); | 77 v8::Local<v8::Value> value = filter->ToObject()->Get(v8AtomicString(isol
ate, "acceptNode")); |
78 if (value.IsEmpty() || !value->IsFunction()) { | 78 if (value.IsEmpty() || !value->IsFunction()) { |
79 throwTypeError("NodeFilter object does not have an acceptNode functi
on", isolate); | 79 exceptionState.throwTypeError("NodeFilter object does not have an ac
ceptNode function"); |
80 return NodeFilter::FILTER_REJECT; | 80 return NodeFilter::FILTER_REJECT; |
81 } | 81 } |
82 callback = v8::Handle<v8::Function>::Cast(value); | 82 callback = v8::Handle<v8::Function>::Cast(value); |
83 } | 83 } |
84 | 84 |
85 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu
e>[1]); | 85 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu
e>[1]); |
86 v8::Handle<v8::Object> context = m_scriptState->context()->Global(); | 86 v8::Handle<v8::Object> context = m_scriptState->context()->Global(); |
87 info[0] = toV8(node, context, isolate); | 87 info[0] = toV8(node, context, isolate); |
88 | 88 |
89 v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState-
>executionContext(), callback, context, 1, info.get(), isolate); | 89 v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState-
>executionContext(), callback, context, 1, info.get(), isolate); |
90 | 90 |
91 if (exceptionCatcher.HasCaught()) { | 91 if (exceptionCatcher.HasCaught()) { |
92 exceptionState.rethrowV8Exception(exceptionCatcher.Exception()); | 92 exceptionState.rethrowV8Exception(exceptionCatcher.Exception()); |
93 return NodeFilter::FILTER_REJECT; | 93 return NodeFilter::FILTER_REJECT; |
94 } | 94 } |
95 | 95 |
96 ASSERT(!result.IsEmpty()); | 96 ASSERT(!result.IsEmpty()); |
97 | 97 |
98 return result->Int32Value(); | 98 return result->Int32Value(); |
99 } | 99 } |
100 | 100 |
101 void V8NodeFilterCondition::setWeakCallback(const v8::WeakCallbackData<v8::Value
, V8NodeFilterCondition>& data) | 101 void V8NodeFilterCondition::setWeakCallback(const v8::WeakCallbackData<v8::Value
, V8NodeFilterCondition>& data) |
102 { | 102 { |
103 data.GetParameter()->m_filter.clear(); | 103 data.GetParameter()->m_filter.clear(); |
104 } | 104 } |
105 | 105 |
106 } // namespace WebCore | 106 } // namespace WebCore |
OLD | NEW |