+2008-11-19 Darin Fisher <darin@chromium.org>
+
+ Reviewed by Geoff Garen.
+
+ https://bugs.webkit.org/show_bug.cgi?id=22345
+ Define ScriptValue as a thin container for a JSC::Value*.
+
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/ScheduledAction.cpp:
+ * bindings/js/ScriptController.cpp:
+ (WebCore::ScriptController::evaluate):
+ * bindings/js/ScriptController.h:
+ * bindings/js/ScriptValue.cpp: Added.
+ (WebCore::ScriptValue::getString):
+ * bindings/js/ScriptValue.h: Added.
+ (WebCore::ScriptValue::ScriptValue):
+ (WebCore::ScriptValue::jsValue):
+ * dom/ScriptElement.cpp:
+ * dom/XMLTokenizer.cpp:
+ * dom/XMLTokenizerLibxml2.cpp:
+ * html/HTMLTokenizer.cpp:
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::executeIfJavaScriptURL):
+ (WebCore::FrameLoader::executeScript):
+ * loader/FrameLoader.h:
+
2008-11-19 Beth Dakin <bdakin@apple.com>
Reviewed by Justin Garcia.
RelativePath="..\bindings\js\ScriptControllerWin.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\bindings\js\ScriptValue.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="..\bindings\js\ScriptValue.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\bindings\js\StringSourceProvider.h"\r
>\r
933A14B90B7D1D5200A53FFD /* JSTextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A14B70B7D1D5200A53FFD /* JSTextEvent.h */; };
93442C9E0D2B335C00338FF9 /* HTMLTableRowsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */; };
93442CA00D2B336000338FF9 /* HTMLTableRowsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93442C9F0D2B336000338FF9 /* HTMLTableRowsCollection.cpp */; };
+ 934CC0E10ED39D6F00A658F2 /* ScriptValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */; };
+ 934CC0E20ED39D6F00A658F2 /* ScriptValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 934CC0E00ED39D6F00A658F2 /* ScriptValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
934D9BA50B8C116B007B42A9 /* WebCoreNSStringExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */; };
934D9BA70B8C1175007B42A9 /* WebCoreNSStringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
934F71380D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 934F71370D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp */; };
933A14B70B7D1D5200A53FFD /* JSTextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextEvent.h; sourceTree = "<group>"; };
93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTableRowsCollection.h; sourceTree = "<group>"; };
93442C9F0D2B336000338FF9 /* HTMLTableRowsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTableRowsCollection.cpp; sourceTree = "<group>"; };
+ 934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptValue.cpp; sourceTree = "<group>"; };
+ 934CC0E00ED39D6F00A658F2 /* ScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptValue.h; sourceTree = "<group>"; };
934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSStringExtras.mm; sourceTree = "<group>"; };
934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreNSStringExtras.h; sourceTree = "<group>"; };
934F71370D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticationChallengeBase.cpp; sourceTree = "<group>"; };
93B70D5309EB0C7C009D8468 /* ScriptController.cpp */,
A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */,
93B70D5409EB0C7C009D8468 /* ScriptController.h */,
+ 934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */,
+ 934CC0E00ED39D6F00A658F2 /* ScriptValue.h */,
65488D6A0DD5A83D009D83B2 /* StringSourceProvider.h */,
BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */,
BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */,
E108224B0EC3153A00E93953 /* WorkerTask.h in Headers */,
0FD723820EC8BD9300CA5DD7 /* FloatQuad.h in Headers */,
E14799A70ECDE3A400292BF3 /* WorkerMessagingProxy.h in Headers */,
+ 934CC0E20ED39D6F00A658F2 /* ScriptValue.h in Headers */,
0897C14D0ED2EBA500AE06DB /* WMLBRElement.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
E14799B40ECDE9D800292BF3 /* WorkerMessagingProxy.cpp in Sources */,
0897C14C0ED2EBA500AE06DB /* WMLBRElement.cpp in Sources */,
E182504F0ED2F20200499A8F /* FrameLoaderClient.cpp in Sources */,
+ 934CC0E10ED39D6F00A658F2 /* ScriptValue.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "JSDOMBinding.h"
#include "JSDOMWindow.h"
#include "ScriptController.h"
+#include "ScriptValue.h"
#include <runtime/JSLock.h>
using namespace JSC;
#include "PageGroup.h"
#include "PausedTimeouts.h"
#include "runtime_root.h"
+#include "ScriptValue.h"
#include "Settings.h"
#include "StringSourceProvider.h"
disconnectPlatformScriptObjects();
}
-JSValue* ScriptController::evaluate(const String& sourceURL, int baseLine, const String& str)
+ScriptValue ScriptController::evaluate(const String& sourceURL, int baseLine, const String& str)
{
// evaluate code. Returns the JS return value or 0
// if there was none, an error occured or the type couldn't be converted.
class HTMLPlugInElement;
class Frame;
class Node;
+class ScriptValue;
class String;
class Widget;
return m_windowShell->window();
}
- JSC::JSValue* evaluate(const String& sourceURL, int baseLine, const String& code);
+ ScriptValue evaluate(const String& sourceURL, int baseLine, const String& code);
PassRefPtr<EventListener> createInlineEventListener(const String& functionName, const String& code, Node*);
#if ENABLE(SVG)
--- /dev/null
+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptValue.h"
+
+#include "PlatformString.h"
+#include <runtime/JSLock.h>
+#include <runtime/Protect.h>
+#include <runtime/UString.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+bool ScriptValue::getString(String& result) const
+{
+ if (!m_value.get())
+ return false;
+ JSLock lock(false);
+ UString ustring;
+ if (!m_value->getString(ustring))
+ return false;
+ result = ustring;
+ return true;
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (c) 2008, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScriptValue_h
+#define ScriptValue_h
+
+#include <runtime/Protect.h>
+
+namespace WebCore {
+
+class String;
+
+class ScriptValue {
+public:
+ ScriptValue(JSC::JSValue* value = JSC::noValue()) : m_value(value) {}
+
+ JSC::JSValue* jsValue() const { return m_value.get(); }
+ bool getString(String& result) const;
+
+private:
+ JSC::ProtectedPtr<JSC::JSValue> m_value;
+};
+
+} // namespace WebCore
+
+#endif // ScriptValue_h
#include "FrameLoader.h"
#include "MIMETypeRegistry.h"
#include "ScriptController.h"
+#include "ScriptValue.h"
#include "StringHash.h"
#include "Text.h"
#include <wtf/StdLibExtras.h>
#include "HTMLScriptElement.h"
#include "HTMLStyleElement.h"
#include "ScriptController.h"
+#include "ScriptValue.h"
#include "ProcessingInstruction.h"
#include "ResourceError.h"
#include "ResourceHandle.h"
#include "HTMLStyleElement.h"
#include "HTMLTokenizer.h" // for decodeNamedEntity
#include "ScriptController.h"
+#include "ScriptValue.h"
#include "ProcessingInstruction.h"
#include "ResourceError.h"
#include "ResourceHandle.h"
#include "Page.h"
#include "PreloadScanner.h"
#include "ScriptController.h"
+#include "ScriptValue.h"
#include "SystemTime.h"
#include <wtf/ASCIICType.h>
#include "XMLTokenizer.h"
#include "JSDOMBinding.h"
#include "ScriptController.h"
+#include "ScriptValue.h"
#include <runtime/JSLock.h>
#include <runtime/JSObject.h>
#include <wtf/StdLibExtras.h>
#include "SVGViewSpec.h"
#endif
-using namespace JSC;
-
namespace WebCore {
#if ENABLE(SVG)
static double storedTimeOfLastCompletedLoad;
static FrameLoader::LocalLoadPolicy localLoadPolicy = FrameLoader::AllowLocalLoadsForLocalOnly;
-static bool getString(JSValue* result, String& string)
-{
- if (!result)
- return false;
- JSLock lock(false);
- UString ustring;
- if (!result->getString(ustring))
- return false;
- string = ustring;
- return true;
-}
-
bool isBackForwardLoadType(FrameLoadType type)
{
switch (type) {
return false;
String script = decodeURLEscapeSequences(url.string().substring(strlen("javascript:")));
- JSValue* result = executeScript(script, userGesture);
+ ScriptValue result = executeScript(script, userGesture);
String scriptResult;
- if (!getString(result, scriptResult))
+ if (!result.getString(scriptResult))
return true;
SecurityOrigin* currentSecurityOrigin = 0;
return true;
}
-JSValue* FrameLoader::executeScript(const String& script, bool forceUserGesture)
+ScriptValue FrameLoader::executeScript(const String& script, bool forceUserGesture)
{
return executeScript(forceUserGesture ? String() : m_URL.string(), 1, script);
}
-JSValue* FrameLoader::executeScript(const String& url, int baseLine, const String& script)
+ScriptValue FrameLoader::executeScript(const String& url, int baseLine, const String& script)
{
if (!m_frame->script()->isEnabled() || m_frame->script()->isPaused())
- return noValue();
+ return ScriptValue();
bool wasRunningScript = m_isRunningScript;
m_isRunningScript = true;
- JSValue* result = m_frame->script()->evaluate(url, baseLine, script);
+ ScriptValue result = m_frame->script()->evaluate(url, baseLine, script);
if (!wasRunningScript) {
m_isRunningScript = false;
class ResourceLoader;
class ResourceRequest;
class ResourceResponse;
+ class ScriptValue;
class SecurityOrigin;
class SharedBuffer;
class SubstituteData;
// Returns true if url is a JavaScript URL.
bool executeIfJavaScriptURL(const KURL& url, bool userGesture = false, bool replaceDocument = true);
- JSC::JSValue* executeScript(const String& url, int baseLine, const String& script);
- JSC::JSValue* executeScript(const String& script, bool forceUserGesture = false);
+ ScriptValue executeScript(const String& url, int baseLine, const String& script);
+ ScriptValue executeScript(const String& script, bool forceUserGesture = false);
void gotoAnchor();
bool gotoAnchor(const String& name); // returns true if the anchor was found
+2008-11-19 Darin Fisher <darin@chromium.org>
+
+ Reviewed by Geoff Garen.
+
+ https://bugs.webkit.org/show_bug.cgi?id=22345
+ Define ScriptValue as a thin container for a JSC::Value*.
+
+ * WebView/WebFrame.mm:
+ (-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
+ * WebView/WebView.mm:
+ (-[WebView aeDescByEvaluatingJavaScriptFromString:]):
+
2008-11-19 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
#import <WebCore/TypingCommand.h>
#import <WebCore/htmlediting.h>
#import <WebCore/ScriptController.h>
+#import <WebCore/ScriptValue.h>
#import <WebCore/markup.h>
#import <WebCore/visible_units.h>
#import <runtime/JSLock.h>
{
ASSERT(_private->coreFrame->document());
- JSValue* result = _private->coreFrame->loader()->executeScript(string, forceUserGesture);
+ JSValue* result = _private->coreFrame->loader()->executeScript(string, forceUserGesture).jsValue();
if (!_private->coreFrame) // In case the script removed our frame from the page.
return @"";
#import <WebCore/PlatformMouseEvent.h>
#import <WebCore/ProgressTracker.h>
#import <WebCore/ScriptController.h>
+#import <WebCore/ScriptValue.h>
#import <WebCore/SelectionController.h>
#import <WebCore/Settings.h>
#import <WebCore/TextResourceDecoder.h>
return nil;
if (!coreFrame->document())
return nil;
- JSValue* result = coreFrame->loader()->executeScript(script, true);
+ JSValue* result = coreFrame->loader()->executeScript(script, true).jsValue();
if (!result) // FIXME: pass errors
return 0;
JSLock lock(false);
+2008-11-19 Darin Fisher <darin@chromium.org>
+
+ Reviewed by Geoff Garen.
+
+ https://bugs.webkit.org/show_bug.cgi?id=22345
+ Define ScriptValue as a thin container for a JSC::Value*.
+
+ * WebView.cpp:
+ (WebView::stringByEvaluatingJavaScriptFromString):
+
2008-11-19 Adele Peterson <adele@apple.com>
Reviewed by Darin Adler.
#include <WebCore/RenderTheme.h>
#include <WebCore/ResourceHandle.h>
#include <WebCore/ResourceHandleClient.h>
+#include <WebCore/ScriptValue.h>
#include <WebCore/ScrollbarTheme.h>
#include <WebCore/SelectionController.h>
#include <WebCore/Settings.h>
if (!coreFrame)
return E_FAIL;
- JSC::JSValue* scriptExecutionResult = coreFrame->loader()->executeScript(WebCore::String(script), true);
- if(!scriptExecutionResult)
+ JSC::JSValue* scriptExecutionResult = coreFrame->loader()->executeScript(WebCore::String(script), true).jsValue();
+ if (!scriptExecutionResult)
return E_FAIL;
else if (scriptExecutionResult->isString()) {
JSLock lock(false);
+2008-11-19 Darin Fisher <darin@chromium.org>
+
+ Reviewed by Geoff Garen.
+
+ https://bugs.webkit.org/show_bug.cgi?id=22345
+ Define ScriptValue as a thin container for a JSC::Value*.
+
+ * WebFrame.cpp:
+ (wxWebFrame::RunScript):
+
2008-11-17 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig.
#include "FrameLoaderClientWx.h"
#include "ScriptController.h"
+#include "ScriptValue.h"
#include "JSDOMBinding.h"
#include <runtime/JSValue.h>
#include <runtime/UString.h>
{
wxString returnValue = wxEmptyString;
if (m_impl->frame) {
- JSC::JSValue* result = m_impl->frame->loader()->executeScript(javascript, true);
+ JSC::JSValue* result = m_impl->frame->loader()->executeScript(javascript, true).jsValue();
if (result)
returnValue = wxString(result->toString(m_impl->frame->script()->globalObject()->globalExec()).UTF8String().c_str(), wxConvUTF8);
}