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

Side by Side Diff: Source/bindings/v8/custom/V8CustomXPathNSResolver.cpp

Issue 108543003: Consistently use AtomicString for namespaceURI / prefix (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years 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
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 V8CustomXPathNSResolver::V8CustomXPathNSResolver(v8::Handle<v8::Object> resolver , v8::Isolate* isolate) 51 V8CustomXPathNSResolver::V8CustomXPathNSResolver(v8::Handle<v8::Object> resolver , v8::Isolate* isolate)
52 : m_resolver(resolver) 52 : m_resolver(resolver)
53 , m_isolate(isolate) 53 , m_isolate(isolate)
54 { 54 {
55 } 55 }
56 56
57 V8CustomXPathNSResolver::~V8CustomXPathNSResolver() 57 V8CustomXPathNSResolver::~V8CustomXPathNSResolver()
58 { 58 {
59 } 59 }
60 60
61 String V8CustomXPathNSResolver::lookupNamespaceURI(const String& prefix) 61 AtomicString V8CustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
62 { 62 {
63 v8::Handle<v8::Function> lookupNamespaceURIFunc; 63 v8::Handle<v8::Function> lookupNamespaceURIFunc;
64 v8::Handle<v8::String> lookupNamespaceURIName = v8AtomicString(m_isolate, "l ookupNamespaceURI"); 64 v8::Handle<v8::String> lookupNamespaceURIName = v8AtomicString(m_isolate, "l ookupNamespaceURI");
65 65
66 // Check if the resolver has a function property named lookupNamespaceURI. 66 // Check if the resolver has a function property named lookupNamespaceURI.
67 if (m_resolver->Has(lookupNamespaceURIName)) { 67 if (m_resolver->Has(lookupNamespaceURIName)) {
68 v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespa ceURIName); 68 v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespa ceURIName);
69 if (lookupNamespaceURI->IsFunction()) 69 if (lookupNamespaceURI->IsFunction())
70 lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamesp aceURI); 70 lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamesp aceURI);
71 } 71 }
72 72
73 if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) { 73 if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) {
74 Frame* frame = activeDOMWindow()->frame(); 74 Frame* frame = activeDOMWindow()->frame();
75 if (frame && frame->page()) 75 if (frame && frame->page())
76 frame->page()->console().addMessage(JSMessageSource, ErrorMessageLev el, "XPathNSResolver does not have a lookupNamespaceURI method."); 76 frame->page()->console().addMessage(JSMessageSource, ErrorMessageLev el, "XPathNSResolver does not have a lookupNamespaceURI method.");
77 return String(); 77 return nullAtom;
78 } 78 }
79 79
80 // Catch exceptions from calling the namespace resolver. 80 // Catch exceptions from calling the namespace resolver.
81 v8::TryCatch tryCatch; 81 v8::TryCatch tryCatch;
82 tryCatch.SetVerbose(true); // Print exceptions to console. 82 tryCatch.SetVerbose(true); // Print exceptions to console.
83 83
84 const int argc = 1; 84 const int argc = 1;
85 v8::Handle<v8::Value> argv[argc] = { v8String(m_isolate, prefix) }; 85 v8::Handle<v8::Value> argv[argc] = { v8String(m_isolate, prefix) };
86 v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::H andle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc; 86 v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::H andle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc;
87 87
88 v8::Handle<v8::Value> retval = ScriptController::callFunction(activeExecutio nContext(), function, m_resolver, argc, argv, m_isolate); 88 v8::Handle<v8::Value> retval = ScriptController::callFunction(activeExecutio nContext(), function, m_resolver, argc, argv, m_isolate);
89 89
90 // Eat exceptions from namespace resolver and return an empty string. This w ill most likely cause NamespaceError. 90 // Eat exceptions from namespace resolver and return an empty string. This w ill most likely cause NamespaceError.
91 if (tryCatch.HasCaught()) 91 if (tryCatch.HasCaught())
92 return String(); 92 return nullAtom;
93 93
94 return toWebCoreStringWithNullCheck(retval); 94 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<WithNullCheck>, retu rnString, retval, nullAtom);
95 return returnString;
95 } 96 }
96 97
97 } // namespace WebCore 98 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698