Title: [136623] trunk/Source/WebCore
Revision
136623
Author
[email protected]
Date
2012-12-04 20:25:52 -0800 (Tue, 04 Dec 2012)

Log Message

[V8] V8Binding::v8ExternalString() is redundant
https://bugs.webkit.org/show_bug.cgi?id=103979

Reviewed by Adam Barth.

v8String(), v8StringOrNull() and v8StringOrUndefined() are enough.
We can remove V8Binding::v8ExternalString().

No tests. No change in behavior.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNormalAttrGetter):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::compileAndRunScript):
* bindings/v8/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::compileScript):
* bindings/v8/V8Binding.h:
(WebCore):
(WebCore::v8String):
(WebCore::v8StringOrNull):
(WebCore::v8StringOrUndefined):
* bindings/v8/V8LazyEventListener.cpp:
(WebCore::V8LazyEventListener::prepareListenerObject):
* bindings/v8/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::evaluate):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (136622 => 136623)


--- trunk/Source/WebCore/ChangeLog	2012-12-05 04:22:29 UTC (rev 136622)
+++ trunk/Source/WebCore/ChangeLog	2012-12-05 04:25:52 UTC (rev 136623)
@@ -1,5 +1,33 @@
 2012-12-04  Kentaro Hara  <[email protected]>
 
+        [V8] V8Binding::v8ExternalString() is redundant
+        https://bugs.webkit.org/show_bug.cgi?id=103979
+
+        Reviewed by Adam Barth.
+
+        v8String(), v8StringOrNull() and v8StringOrUndefined() are enough.
+        We can remove V8Binding::v8ExternalString().
+
+        No tests. No change in behavior.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateNormalAttrGetter):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::compileAndRunScript):
+        * bindings/v8/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::compileScript):
+        * bindings/v8/V8Binding.h:
+        (WebCore):
+        (WebCore::v8String):
+        (WebCore::v8StringOrNull):
+        (WebCore::v8StringOrUndefined):
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListener::prepareListenerObject):
+        * bindings/v8/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::evaluate):
+
+2012-12-04  Kentaro Hara  <[email protected]>
+
         [V8] Remove v8NonStringValueToWebCoreString() and v8NonStringValueToAtomicWebCoreString()
         https://bugs.webkit.org/show_bug.cgi?id=103981
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (136622 => 136623)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-12-05 04:22:29 UTC (rev 136622)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-12-05 04:25:52 UTC (rev 136623)
@@ -948,7 +948,7 @@
             my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
             AddToImplIncludes("${namespace}.h");
             push(@implContentDecls, "    Element* imp = V8Element::toNative(info.Holder());\n");
-            push(@implContentDecls, "    return v8ExternalString(imp->getAttribute(${namespace}::${contentAttributeName}Attr), info.GetIsolate());\n");
+            push(@implContentDecls, "    return v8String(imp->getAttribute(${namespace}::${contentAttributeName}Attr), info.GetIsolate());\n");
             push(@implContentDecls, "}\n\n");
             push(@implContentDecls, "#endif // ${conditionalString}\n\n") if $conditionalString;
             return;

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (136622 => 136623)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-12-05 04:22:29 UTC (rev 136622)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-12-05 04:25:52 UTC (rev 136623)
@@ -262,7 +262,7 @@
         tryCatch.SetVerbose(true);
 
         // Compile the script.
-        v8::Local<v8::String> code = v8ExternalString(source.source());
+        v8::Handle<v8::String> code = v8String(source.source());
 #if PLATFORM(CHROMIUM)
         TRACE_EVENT_BEGIN0("v8", "v8.compile");
 #endif

Modified: trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp (136622 => 136623)


--- trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp	2012-12-05 04:22:29 UTC (rev 136622)
+++ trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp	2012-12-05 04:25:52 UTC (rev 136623)
@@ -435,10 +435,10 @@
         return;
     v8::Context::Scope contextScope(context);
 
-    v8::Local<v8::String> code = v8ExternalString(_expression_);
+    v8::Handle<v8::String> code = v8String(_expression_);
     v8::TryCatch tryCatch;
 
-    v8::ScriptOrigin origin(v8ExternalString(sourceURL), v8Integer(0), v8Integer(0));
+    v8::ScriptOrigin origin(v8String(sourceURL), v8Integer(0), v8Integer(0));
     v8::Handle<v8::Script> script = v8::Script::New(code, &origin);
 
     if (tryCatch.HasCaught()) {

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (136622 => 136623)


--- trunk/Source/WebCore/bindings/v8/V8Binding.h	2012-12-05 04:22:29 UTC (rev 136622)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h	2012-12-05 04:25:52 UTC (rev 136623)
@@ -141,10 +141,11 @@
         return stringResource;
     }
 
+    // Convert a string to a V8 string.
     // Return a V8 external string that shares the underlying buffer with the given
     // WebCore string. The reference counting mechanism is used to keep the
     // underlying buffer alive while the string is still live in the V8 engine.
-    inline v8::Local<v8::String> v8ExternalString(const String& string, v8::Isolate* isolate = 0)
+    inline v8::Handle<v8::String> v8String(const String& string, v8::Isolate* isolate = 0)
     {
         StringImpl* stringImpl = string.impl();
         if (!stringImpl)
@@ -154,12 +155,16 @@
         return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(stringImpl, isolate);
     }
 
-    // Convert a string to a V8 string.
-    inline v8::Handle<v8::String> v8String(const String& string, v8::Isolate* isolate = 0)
+    inline v8::Handle<v8::Value> v8StringOrNull(const String& str, v8::Isolate* isolate = 0)
     {
-        return v8ExternalString(string, isolate);
+        return str.isNull() ? v8::Handle<v8::Value>(v8::Null()) : v8::Handle<v8::Value>(v8String(str, isolate));
     }
 
+    inline v8::Handle<v8::Value> v8StringOrUndefined(const String& str, v8::Isolate* isolate = 0)
+    {
+        return str.isNull() ? v8::Handle<v8::Value>(v8::Undefined()) : v8::Handle<v8::Value>(v8String(str, isolate));
+    }
+
     inline v8::Handle<v8::Integer> v8Integer(int value, v8::Isolate* isolate = 0)
     {
         if (UNLIKELY(!isolate))
@@ -405,16 +410,6 @@
         return isolate ? v8Boolean(value, isolate) : v8Boolean(value);
     }
 
-    inline v8::Handle<v8::Value> v8StringOrNull(const String& str, v8::Isolate* isolate = 0)
-    {
-        return str.isNull() ? v8::Handle<v8::Value>(v8::Null()) : v8::Handle<v8::Value>(v8String(str, isolate));
-    }
-
-    inline v8::Handle<v8::Value> v8StringOrUndefined(const String& str, v8::Isolate* isolate = 0)
-    {
-        return str.isNull() ? v8::Handle<v8::Value>(v8::Undefined()) : v8::Handle<v8::Value>(v8String(str, isolate));
-    }
-
     inline double toWebCoreDate(v8::Handle<v8::Value> object)
     {
         return (object->IsDate() || object->IsNumber()) ? object->NumberValue() : std::numeric_limits<double>::quiet_NaN();

Modified: trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp (136622 => 136623)


--- trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-12-05 04:22:29 UTC (rev 136622)
+++ trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-12-05 04:25:52 UTC (rev 136623)
@@ -155,7 +155,7 @@
             "};"
         "}}}})";
 
-    v8::Handle<v8::String> codeExternalString = v8ExternalString(code);
+    v8::Handle<v8::String> codeExternalString = v8String(code);
 
     v8::Handle<v8::Script> script = ScriptSourceCode::compileScript(codeExternalString, m_sourceURL, m_position);
     if (script.IsEmpty())
@@ -220,7 +220,7 @@
         toStringFunction = toStringTemplate->GetFunction();
     if (!toStringFunction.IsEmpty()) {
         String toStringString = "function " + m_functionName + "(" + m_eventParameterName + ") {\n  " + m_code + "\n}";
-        wrappedFunction->SetHiddenValue(V8HiddenPropertyName::toStringString(), v8ExternalString(toStringString));
+        wrappedFunction->SetHiddenValue(V8HiddenPropertyName::toStringString(), v8String(toStringString));
         wrappedFunction->Set(v8::String::NewSymbol("toString"), toStringFunction);
     }
 

Modified: trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp (136622 => 136623)


--- trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp	2012-12-05 04:22:29 UTC (rev 136622)
+++ trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp	2012-12-05 04:25:52 UTC (rev 136623)
@@ -155,7 +155,7 @@
 
     v8::TryCatch block;
 
-    v8::Local<v8::String> scriptString = v8ExternalString(script);
+    v8::Handle<v8::String> scriptString = v8String(script);
     v8::Handle<v8::Script> compiledScript = ScriptSourceCode::compileScript(scriptString, fileName, scriptStartPosition);
     v8::Local<v8::Value> result = ScriptRunner::runCompiledScript(compiledScript, m_workerContext);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to