| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // 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 19 matching lines...) Expand all Loading... |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" | 31 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptController.h" | 33 #include "bindings/core/v8/ScriptController.h" |
| 34 #include "bindings/core/v8/V8Binding.h" | 34 #include "bindings/core/v8/V8Binding.h" |
| 35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
| 36 #include "core/frame/FrameConsole.h" | 36 #include "core/frame/FrameConsole.h" |
| 37 #include "core/frame/FrameHost.h" | 37 #include "core/frame/FrameHost.h" |
| 38 #include "core/frame/LocalDOMWindow.h" | 38 #include "core/frame/LocalDOMWindow.h" |
| 39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 40 #include "core/inspector/ConsoleMessage.h" |
| 40 #include "core/inspector/ScriptCallStack.h" | 41 #include "core/inspector/ScriptCallStack.h" |
| 41 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
| 42 | 43 |
| 43 namespace blink { | 44 namespace blink { |
| 44 | 45 |
| 45 PassRefPtrWillBeRawPtr<V8CustomXPathNSResolver> V8CustomXPathNSResolver::create(
v8::Handle<v8::Object> resolver, v8::Isolate* isolate) | 46 PassRefPtrWillBeRawPtr<V8CustomXPathNSResolver> V8CustomXPathNSResolver::create(
v8::Handle<v8::Object> resolver, v8::Isolate* isolate) |
| 46 { | 47 { |
| 47 return adoptRefWillBeNoop(new V8CustomXPathNSResolver(resolver, isolate)); | 48 return adoptRefWillBeNoop(new V8CustomXPathNSResolver(resolver, isolate)); |
| 48 } | 49 } |
| 49 | 50 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 61 // Check if the resolver has a function property named lookupNamespaceURI. | 62 // Check if the resolver has a function property named lookupNamespaceURI. |
| 62 if (m_resolver->Has(lookupNamespaceURIName)) { | 63 if (m_resolver->Has(lookupNamespaceURIName)) { |
| 63 v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespa
ceURIName); | 64 v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespa
ceURIName); |
| 64 if (lookupNamespaceURI->IsFunction()) | 65 if (lookupNamespaceURI->IsFunction()) |
| 65 lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamesp
aceURI); | 66 lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamesp
aceURI); |
| 66 } | 67 } |
| 67 | 68 |
| 68 if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) { | 69 if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) { |
| 69 LocalFrame* frame = callingDOMWindow(m_isolate)->frame(); | 70 LocalFrame* frame = callingDOMWindow(m_isolate)->frame(); |
| 70 if (frame && frame->host()) | 71 if (frame && frame->host()) |
| 71 frame->console().addMessage(JSMessageSource, ErrorMessageLevel, "XPa
thNSResolver does not have a lookupNamespaceURI method."); | 72 frame->console().addMessage(ConsoleMessage::create(JSMessageSource,
ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.")
); |
| 72 return nullAtom; | 73 return nullAtom; |
| 73 } | 74 } |
| 74 | 75 |
| 75 // Catch exceptions from calling the namespace resolver. | 76 // Catch exceptions from calling the namespace resolver. |
| 76 v8::TryCatch tryCatch; | 77 v8::TryCatch tryCatch; |
| 77 tryCatch.SetVerbose(true); // Print exceptions to console. | 78 tryCatch.SetVerbose(true); // Print exceptions to console. |
| 78 | 79 |
| 79 const int argc = 1; | 80 const int argc = 1; |
| 80 v8::Handle<v8::Value> argv[argc] = { v8String(m_isolate, prefix) }; | 81 v8::Handle<v8::Value> argv[argc] = { v8String(m_isolate, prefix) }; |
| 81 v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::H
andle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; | 82 v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::H
andle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; |
| 82 | 83 |
| 83 v8::Handle<v8::Value> retval = ScriptController::callFunction(callingExecuti
onContext(m_isolate), function, m_resolver, argc, argv, m_isolate); | 84 v8::Handle<v8::Value> retval = ScriptController::callFunction(callingExecuti
onContext(m_isolate), function, m_resolver, argc, argv, m_isolate); |
| 84 | 85 |
| 85 // Eat exceptions from namespace resolver and return an empty string. This w
ill most likely cause NamespaceError. | 86 // Eat exceptions from namespace resolver and return an empty string. This w
ill most likely cause NamespaceError. |
| 86 if (tryCatch.HasCaught()) | 87 if (tryCatch.HasCaught()) |
| 87 return nullAtom; | 88 return nullAtom; |
| 88 | 89 |
| 89 TOSTRING_DEFAULT(V8StringResource<TreatNullAsNullString>, returnString, retv
al, nullAtom); | 90 TOSTRING_DEFAULT(V8StringResource<TreatNullAsNullString>, returnString, retv
al, nullAtom); |
| 90 return returnString; | 91 return returnString; |
| 91 } | 92 } |
| 92 | 93 |
| 93 void V8CustomXPathNSResolver::trace(Visitor* visitor) | 94 void V8CustomXPathNSResolver::trace(Visitor* visitor) |
| 94 { | 95 { |
| 95 XPathNSResolver::trace(visitor); | 96 XPathNSResolver::trace(visitor); |
| 96 } | 97 } |
| 97 | 98 |
| 98 } // namespace blink | 99 } // namespace blink |
| OLD | NEW |