| OLD | NEW |
| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // the ExecutionContext that fired the the event listener and the world | 113 // the ExecutionContext that fired the the event listener and the world |
| 114 // that installed the event listener. | 114 // that installed the event listener. |
| 115 v8::HandleScope handleScope(toIsolate(executionContext)); | 115 v8::HandleScope handleScope(toIsolate(executionContext)); |
| 116 v8::Local<v8::Context> v8Context = toV8Context(executionContext, world()); | 116 v8::Local<v8::Context> v8Context = toV8Context(executionContext, world()); |
| 117 if (v8Context.IsEmpty()) | 117 if (v8Context.IsEmpty()) |
| 118 return; | 118 return; |
| 119 ScriptState* scriptState = ScriptState::from(v8Context); | 119 ScriptState* scriptState = ScriptState::from(v8Context); |
| 120 if (!scriptState->contextIsValid()) | 120 if (!scriptState->contextIsValid()) |
| 121 return; | 121 return; |
| 122 | 122 |
| 123 if (executionContext->isDocument() && !toDocument(executionContext)->allowIn
lineEventHandlers(m_node, this, m_sourceURL, m_position.m_line)) { | 123 if (!executionContext->isDocument()) |
| 124 return; |
| 125 |
| 126 if (!toDocument(executionContext)->allowInlineEventHandlers(m_node, this, m_
sourceURL, m_position.m_line)) { |
| 124 clearListenerObject(); | 127 clearListenerObject(); |
| 125 return; | 128 return; |
| 126 } | 129 } |
| 127 | 130 |
| 128 if (hasExistingListenerObject()) | 131 if (hasExistingListenerObject()) |
| 129 return; | 132 return; |
| 130 | 133 |
| 131 ASSERT(executionContext->isDocument()); | |
| 132 | |
| 133 ScriptState::Scope scope(scriptState); | 134 ScriptState::Scope scope(scriptState); |
| 134 String listenerSource = InspectorInstrumentation::preprocessEventListener(t
oDocument(executionContext)->frame(), m_code, m_sourceURL, m_functionName); | 135 String listenerSource = InspectorInstrumentation::preprocessEventListener(t
oDocument(executionContext)->frame(), m_code, m_sourceURL, m_functionName); |
| 135 | 136 |
| 136 // FIXME: Remove the following 'with' hack. | 137 // FIXME: Remove the following 'with' hack. |
| 137 // | 138 // |
| 138 // Nodes other than the document object, when executing inline event | 139 // Nodes other than the document object, when executing inline event |
| 139 // handlers push document, form owner, and the target node on the scope chai
n. | 140 // handlers push document, form owner, and the target node on the scope chai
n. |
| 140 // We do this by using 'with' statement. | 141 // We do this by using 'with' statement. |
| 141 // See chrome/fast/forms/form-action.html | 142 // See chrome/fast/forms/form-action.html |
| 142 // chrome/fast/forms/selected-index-value.html | 143 // chrome/fast/forms/selected-index-value.html |
| (...skipping 16 matching lines...) Expand all Loading... |
| 159 "};" | 160 "};" |
| 160 "}}}})"; | 161 "}}}})"; |
| 161 | 162 |
| 162 v8::Handle<v8::String> codeExternalString = v8String(isolate(), code); | 163 v8::Handle<v8::String> codeExternalString = v8String(isolate(), code); |
| 163 | 164 |
| 164 v8::Local<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(co
deExternalString, isolate(), m_sourceURL, m_position); | 165 v8::Local<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(co
deExternalString, isolate(), m_sourceURL, m_position); |
| 165 if (result.IsEmpty()) | 166 if (result.IsEmpty()) |
| 166 return; | 167 return; |
| 167 | 168 |
| 168 // Call the outer function to get the inner function. | 169 // Call the outer function to get the inner function. |
| 169 ASSERT(result->IsFunction()); | 170 if (!result->IsFunction()) |
| 171 return; |
| 170 v8::Local<v8::Function> intermediateFunction = result.As<v8::Function>(); | 172 v8::Local<v8::Function> intermediateFunction = result.As<v8::Function>(); |
| 171 | 173 |
| 172 HTMLFormElement* formElement = 0; | 174 HTMLFormElement* formElement = 0; |
| 173 if (m_node && m_node->isHTMLElement()) | 175 if (m_node && m_node->isHTMLElement()) |
| 174 formElement = toHTMLElement(m_node)->formOwner(); | 176 formElement = toHTMLElement(m_node)->formOwner(); |
| 175 | 177 |
| 176 v8::Handle<v8::Object> nodeWrapper = toObjectWrapper<Node>(m_node, scriptSta
te); | 178 v8::Handle<v8::Object> nodeWrapper = toObjectWrapper<Node>(m_node, scriptSta
te); |
| 177 v8::Handle<v8::Object> formWrapper = toObjectWrapper<HTMLFormElement>(formEl
ement, scriptState); | 179 v8::Handle<v8::Object> formWrapper = toObjectWrapper<HTMLFormElement>(formEl
ement, scriptState); |
| 178 v8::Handle<v8::Object> documentWrapper = toObjectWrapper<Document>(m_node ?
m_node->ownerDocument() : 0, scriptState); | 180 v8::Handle<v8::Object> documentWrapper = toObjectWrapper<Document>(m_node ?
m_node->ownerDocument() : 0, scriptState); |
| 179 | 181 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // // Since we only parse once, there's no need to keep data used for parsin
g around anymore. | 219 // // Since we only parse once, there's no need to keep data used for parsin
g around anymore. |
| 218 // m_functionName = String(); | 220 // m_functionName = String(); |
| 219 // m_code = String(); | 221 // m_code = String(); |
| 220 // m_eventParameterName = String(); | 222 // m_eventParameterName = String(); |
| 221 // m_sourceURL = String(); | 223 // m_sourceURL = String(); |
| 222 | 224 |
| 223 setListenerObject(wrappedFunction); | 225 setListenerObject(wrappedFunction); |
| 224 } | 226 } |
| 225 | 227 |
| 226 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |