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

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

Issue 313033002: Rethrow exception when swallowing it is not intended. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 6 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/V8BindingMacros.h ('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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 v8::Isolate* isolate = m_scriptState->isolate(); 62 v8::Isolate* isolate = m_scriptState->isolate();
63 ASSERT(!m_scriptState->context().IsEmpty()); 63 ASSERT(!m_scriptState->context().IsEmpty());
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 V8RethrowTryCatchScope rethrow(exceptionCatcher);
Jens Widell 2014/06/17 13:46:10 Is the re-throwing here (despite also returning th
yhirano 2014/06/17 13:53:13 I need ReThrow at L80. The current code doesn't ca
Jens Widell 2014/06/17 14:07:20 Oh, I had missed that the function returned at L80
yhirano 2014/06/18 07:17:52 OK, I changed L79 at PS6. It changes error message
Jens Widell 2014/06/18 07:26:06 The new error message (looking at the *-expected.t
yhirano 2014/06/18 07:31:36 Its not needed and I removed it at PS6.
Jens Widell 2014/06/18 07:36:30 Cool! :-)
72 73
73 v8::Handle<v8::Function> callback; 74 v8::Handle<v8::Function> callback;
74 if (filter->IsFunction()) 75 if (filter->IsFunction())
75 callback = v8::Handle<v8::Function>::Cast(filter); 76 callback = v8::Handle<v8::Function>::Cast(filter);
76 else { 77 else {
77 v8::Local<v8::Value> value = filter->ToObject()->Get(v8AtomicString(isol ate, "acceptNode")); 78 v8::Local<v8::Value> value = filter->ToObject()->Get(v8AtomicString(isol ate, "acceptNode"));
78 if (value.IsEmpty() || !value->IsFunction()) { 79 if (value.IsEmpty() || !value->IsFunction()) {
79 throwTypeError("NodeFilter object does not have an acceptNode functi on", isolate); 80 throwTypeError("NodeFilter object does not have an acceptNode functi on", isolate);
80 return NodeFilter::FILTER_REJECT; 81 return NodeFilter::FILTER_REJECT;
81 } 82 }
82 callback = v8::Handle<v8::Function>::Cast(value); 83 callback = v8::Handle<v8::Function>::Cast(value);
83 } 84 }
84 85
85 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu e>[1]); 86 OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Valu e>[1]);
86 v8::Handle<v8::Object> context = m_scriptState->context()->Global(); 87 v8::Handle<v8::Object> context = m_scriptState->context()->Global();
87 info[0] = toV8(node, context, isolate); 88 info[0] = toV8(node, context, isolate);
88 89
89 v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState- >executionContext(), callback, context, 1, info.get(), isolate); 90 v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState- >executionContext(), callback, context, 1, info.get(), isolate);
90 91
91 if (exceptionCatcher.HasCaught()) { 92 if (exceptionCatcher.HasCaught()) {
92 exceptionState.rethrowV8Exception(exceptionCatcher.Exception());
Jens Widell 2014/06/13 11:22:06 In core/dom/{NodeIterator,TreeWalker}.cpp, the pas
Jens Widell 2014/06/13 11:46:06 See this TC: http://software.hixie.ch/utilities/js
yhirano 2014/06/16 11:30:10 Thanks, done.
Jens Widell 2014/06/16 11:56:39 I haven't tested, but I'd guess the callers work a
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
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8BindingMacros.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698