summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
authorFeng Qian <fqian@google.com>2009-04-24 16:01:03 -0700
committerFeng Qian <fqian@google.com>2009-04-24 16:01:03 -0700
commit109a58c31072b14f5b2c0493ed6c5a1855f82fd7 (patch)
tree134f7efdba4ea4d9b6dfb660bbcb47b4d54f9ad7 /WebCore
parentac888b0a574d343996d06d2b084eaebab7846d81 (diff)
downloadexternal_webkit-109a58c31072b14f5b2c0493ed6c5a1855f82fd7.zip
external_webkit-109a58c31072b14f5b2c0493ed6c5a1855f82fd7.tar.gz
external_webkit-109a58c31072b14f5b2c0493ed6c5a1855f82fd7.tar.bz2
Make WebCore built with V8.
Picked up several new files from Chrome port.
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/Android.derived.mk10
-rw-r--r--WebCore/Android.mk6
-rw-r--r--WebCore/JavaScriptCore.derived.mk19
-rw-r--r--WebCore/bindings/v8/V8DOMMap.cpp2
-rw-r--r--WebCore/bindings/v8/custom/V8CustomBinding.cpp1
-rw-r--r--WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp698
-rw-r--r--WebCore/bindings/v8/custom/V8DocumentCustom.cpp8
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp113
-rw-r--r--WebCore/bridge/jni/jni_utility.cpp5
-rw-r--r--WebCore/bridge/jni/jni_utility.h11
-rw-r--r--WebCore/dom/Document.cpp5
-rw-r--r--WebCore/dom/EventListener.h3
-rw-r--r--WebCore/inspector/InspectorController.h28
-rw-r--r--WebCore/loader/icon/IconDatabase.cpp4
-rw-r--r--WebCore/page/DOMWindow.idl4
-rw-r--r--WebCore/page/Frame.cpp2
-rw-r--r--WebCore/page/Geolocation.idl3
-rw-r--r--WebCore/page/android/InspectorControllerAndroid.cpp19
-rw-r--r--WebCore/platform/android/TemporaryLinkStubs.cpp10
-rw-r--r--WebCore/plugins/PluginView.cpp29
-rw-r--r--WebCore/plugins/PluginView.h4
-rw-r--r--WebCore/plugins/android/PluginViewAndroid.cpp22
22 files changed, 937 insertions, 69 deletions
diff --git a/WebCore/Android.derived.mk b/WebCore/Android.derived.mk
index 297fff6..9c56ec4 100644
--- a/WebCore/Android.derived.mk
+++ b/WebCore/Android.derived.mk
@@ -174,6 +174,16 @@ $(GEN): $(make_css_file_arrays) $(style_sheets)
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN) $(GEN:%.h=%.cpp)
+# XML attribute names
+
+GEN:= $(intermediates)/XMLNames.cpp
+$(GEN): PRIVATE_PATH := $(LOCAL_PATH)
+$(GEN): PRIVATE_CUSTOM_TOOL = perl -I $(PRIVATE_PATH)/bindings/scripts $< --attrs $(xml_attrs) --output $(dir $@)
+$(GEN): xml_attrs := $(LOCAL_PATH)/xml/xmlattrs.in
+$(GEN): $(LOCAL_PATH)/dom/make_names.pl $(xml_attrs)
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
# character set name table
#gen_inputs := \
diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index 347b29b..356aa1d 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -648,8 +648,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
plugins/npapi.cpp \
\
plugins/android/PluginDataAndroid.cpp \
- plugins/android/PluginPackageAndroid.cpp \
- plugins/android/PluginViewAndroid.cpp \
+ plugins/android/PluginPackageAndroid.cpp \
+ plugins/android/PluginViewAndroid.cpp \
\
rendering/AutoTableLayout.cpp \
rendering/CounterNode.cpp \
@@ -697,7 +697,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
rendering/RenderPartObject.cpp \
rendering/RenderPath.cpp \
rendering/RenderReplaced.cpp \
- rendering/RenderReplica.cpp \
+ rendering/RenderReplica.cpp
ifeq ($(ENABLE_SVG), true)
LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
diff --git a/WebCore/JavaScriptCore.derived.mk b/WebCore/JavaScriptCore.derived.mk
index 970c6bf..fa8e627 100644
--- a/WebCore/JavaScriptCore.derived.mk
+++ b/WebCore/JavaScriptCore.derived.mk
@@ -15,9 +15,10 @@
## limitations under the License.
##
-LOCAL_CFLAGS += -DWTF_USE_JSC
-
BINDING_C_INCLUDES := \
+ $(BASE_PATH)/WebCore/bridge \
+ $(BASE_PATH)/WebCore/bridge/c \
+ $(BASE_PATH)/WebCore/bridge/jni \
$(BASE_PATH)/WebCore/bindings/js \
$(BASE_PATH)/JavaScriptCore \
$(BASE_PATH)/JavaScriptCore/API \
@@ -32,11 +33,7 @@ BINDING_C_INCLUDES := \
$(BASE_PATH)/JavaScriptCore/profiler \
$(BASE_PATH)/JavaScriptCore/runtime \
$(BASE_PATH)/JavaScriptCore/wrec \
- $(BASE_PATH)/JavaScriptCore/wtf \
- $(BASE_PATH)/JavaScriptCore/wtf/unicode \
- $(BASE_PATH)/JavaScriptCore/wtf/unicode/icu \
$(BASE_PATH)/JavaScriptCore/ForwardingHeaders \
- $(base_intermediates)/JavaScriptCore \
$(base_intermediates)/JavaScriptCore/parser \
$(base_intermediates)/JavaScriptCore/runtime \
$(base_intermediates)/WebCore/bindings/js
@@ -669,16 +666,6 @@ $(GEN): $(LOCAL_PATH)/dom/make_names.pl $(svg_tags) $(svg_attrs)
LOCAL_GENERATED_SOURCES += $(GEN)
endif
-# XML attribute names
-
-GEN:= $(intermediates)/XMLNames.cpp
-$(GEN): PRIVATE_PATH := $(LOCAL_PATH)
-$(GEN): PRIVATE_CUSTOM_TOOL = perl -I $(PRIVATE_PATH)/bindings/scripts $< --attrs $(xml_attrs) --output $(dir $@)
-$(GEN): xml_attrs := $(LOCAL_PATH)/xml/xmlattrs.in
-$(GEN): $(LOCAL_PATH)/dom/make_names.pl $(xml_attrs)
- $(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
# XLink attribute names
ifeq ($(ENABLE_SVG), true)
diff --git a/WebCore/bindings/v8/V8DOMMap.cpp b/WebCore/bindings/v8/V8DOMMap.cpp
index 830320e..82d9e69 100644
--- a/WebCore/bindings/v8/V8DOMMap.cpp
+++ b/WebCore/bindings/v8/V8DOMMap.cpp
@@ -279,8 +279,10 @@ private:
InternalDOMWrapperMap<Node> m_staticDomNodeMap;
InternalDOMWrapperMap<void> m_staticDomObjectMap;
InternalDOMWrapperMap<void> m_staticActiveDomObjectMap;
+#if ENABLE(SVG)
InternalDOMWrapperMap<SVGElementInstance> m_staticDomSvgElementInstanceMap;
InternalDOMWrapperMap<void> m_staticDomSvgObjectWithContextMap;
+#endif
};
DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<NonMainThreadSpecificDOMData>, threadSpecificDOMData, ());
diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.cpp b/WebCore/bindings/v8/custom/V8CustomBinding.cpp
index 841382b..03361ea 100644
--- a/WebCore/bindings/v8/custom/V8CustomBinding.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomBinding.cpp
@@ -30,6 +30,7 @@
#include "config.h"
#include "V8CustomBinding.h"
+#include "V8Proxy.h"
#include "Element.h"
#include "Document.h"
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
new file mode 100644
index 0000000..d031a50
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -0,0 +1,698 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+#include "config.h"
+#include "DOMWindow.h"
+
+#include "V8Binding.h"
+#include "V8CustomBinding.h"
+#include "V8CustomEventListener.h"
+#include "V8Proxy.h"
+
+#include "DOMTimer.h"
+#include "Frame.h"
+#include "FrameLoadRequest.h"
+#include "FrameView.h"
+#include "Page.h"
+#include "PlatformScreen.h"
+#include "ScriptSourceCode.h"
+#include "Settings.h"
+#include "WindowFeatures.h"
+
+
+// Horizontal and vertical offset, from the parent content area, around newly
+// opened popups that don't specify a location.
+static const int popupTilePixels = 10;
+
+namespace WebCore {
+
+ACCESSOR_SETTER(DOMWindowLocation)
+{
+ v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This());
+ if (holder.IsEmpty())
+ return;
+
+ DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder);
+ WindowSetLocation(imp, toWebCoreString(value));
+}
+
+
+ACCESSOR_SETTER(DOMWindowOpener)
+{
+ DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder());
+
+ if (!V8Proxy::CanAccessFrame(imp->frame(), true))
+ return;
+
+ // Opener can be shadowed if it is in the same domain.
+ // Have a special handling of null value to behave
+ // like Firefox. See bug http://b/1224887 & http://b/791706.
+ if (value->IsNull()) {
+ // imp->frame() cannot be null,
+ // otherwise, SameOrigin check would have failed.
+ ASSERT(imp->frame());
+ imp->frame()->loader()->setOpener(0);
+ }
+
+ // Delete the accessor from this object.
+ info.Holder()->Delete(name);
+
+ // Put property on the front (this) object.
+ info.This()->Set(name, value);
+}
+
+CALLBACK_FUNC_DECL(DOMWindowAddEventListener)
+{
+ INC_STATS("DOM.DOMWindow.addEventListener()");
+ DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder());
+
+ if (!V8Proxy::CanAccessFrame(imp->frame(), true))
+ return v8::Undefined();
+
+ if (!imp->frame())
+ return v8::Undefined(); // DOMWindow could be disconnected from the frame
+
+ Document* doc = imp->frame()->document();
+ if (!doc)
+ return v8::Undefined();
+
+ // TODO: Check if there is not enough arguments
+ V8Proxy* proxy = V8Proxy::retrieve(imp->frame());
+ if (!proxy)
+ return v8::Undefined();
+
+ RefPtr<EventListener> listener = proxy->FindOrCreateV8EventListener(args[1], false);
+
+ if (listener) {
+ String eventType = toWebCoreString(args[0]);
+ bool useCapture = args[2]->BooleanValue();
+ doc->addWindowEventListener(eventType, listener, useCapture);
+ }
+
+ return v8::Undefined();
+}
+
+
+CALLBACK_FUNC_DECL(DOMWindowRemoveEventListener)
+{
+ INC_STATS("DOM.DOMWindow.removeEventListener()");
+ DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder());
+
+ if (!V8Proxy::CanAccessFrame(imp->frame(), true))
+ return v8::Undefined();
+
+ if (!imp->frame())
+ return v8::Undefined();
+
+ Document* doc = imp->frame()->document();
+ if (!doc)
+ return v8::Undefined();
+
+ V8Proxy* proxy = V8Proxy::retrieve(imp->frame());
+ if (!proxy)
+ return v8::Undefined();
+
+ RefPtr<EventListener> listener = proxy->FindV8EventListener(args[1], false);
+
+ if (listener) {
+ String eventType = toWebCoreString(args[0]);
+ bool useCapture = args[2]->BooleanValue();
+ doc->removeWindowEventListener(eventType, listener.get(), useCapture);
+ }
+
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(DOMWindowPostMessage)
+{
+ INC_STATS("DOM.DOMWindow.postMessage()");
+ DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder());
+
+ DOMWindow* source = V8Proxy::retrieveActiveFrame()->domWindow();
+ ASSERT(source->frame());
+
+ String uri = source->frame()->loader()->url().string();
+
+ v8::TryCatch tryCatch;
+
+ String message = toWebCoreString(args[0]);
+ MessagePort* port = 0;
+ String domain;
+
+ // This function has variable arguments and can either be:
+ // postMessage(message, port, domain);
+ // or
+ // postMessage(message, domain);
+ if (args.Length() > 2) {
+ if (V8Proxy::IsWrapperOfType(args[1], V8ClassIndex::MESSAGEPORT))
+ port = V8Proxy::ToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, args[1]);
+ domain = valueToStringWithNullOrUndefinedCheck(args[2]);
+ } else
+ domain = valueToStringWithNullOrUndefinedCheck(args[1]);
+
+ if (tryCatch.HasCaught())
+ return v8::Undefined();
+
+ ExceptionCode ec = 0;
+ window->postMessage(message, port, domain, source, ec);
+ if (ec)
+ V8Proxy::SetDOMException(ec);
+
+ return v8::Undefined();
+}
+
+
+static bool canShowModalDialogNow(const Frame* frame)
+{
+ // A frame can out live its page. See bug 1219613.
+ if (!frame || !frame->page())
+ return false;
+ return frame->page()->chrome()->canRunModalNow();
+}
+
+static bool allowPopUp()
+{
+ Frame* frame = V8Proxy::retrieveActiveFrame();
+
+ ASSERT(frame);
+ if (frame->script()->processingUserGesture())
+ return true;
+ Settings* settings = frame->settings();
+ return settings && settings->JavaScriptCanOpenWindowsAutomatically();
+}
+
+static HashMap<String, String> parseModalDialogFeatures(const String& featuresArg)
+{
+ HashMap<String, String> map;
+
+ Vector<String> features;
+ featuresArg.split(';', features);
+ Vector<String>::const_iterator end = features.end();
+ for (Vector<String>::const_iterator it = features.begin(); it != end; ++it) {
+ String featureString = *it;
+ int pos = featureString.find('=');
+ int colonPos = featureString.find(':');
+ if (pos >= 0 && colonPos >= 0)
+ continue; // ignore any strings that have both = and :
+ if (pos < 0)
+ pos = colonPos;
+ if (pos < 0) {
+ // null string for value means key without value
+ map.set(featureString.stripWhiteSpace().lower(), String());
+ } else {
+ String key = featureString.left(pos).stripWhiteSpace().lower();
+ String val = featureString.substring(pos + 1).stripWhiteSpace().lower();
+ int spacePos = val.find(' ');
+ if (spacePos != -1)
+ val = val.left(spacePos);
+ map.set(key, val);
+ }
+ }
+
+ return map;
+}
+
+
+static Frame* createWindow(Frame* openerFrame,
+ const String& url,
+ const String& frameName,
+ const WindowFeatures& windowFeatures,
+ v8::Local<v8::Value> dialogArgs)
+{
+ Frame* activeFrame = V8Proxy::retrieveActiveFrame();
+
+ ResourceRequest request;
+ if (activeFrame)
+ request.setHTTPReferrer(activeFrame->loader()->outgoingReferrer());
+ FrameLoadRequest frameRequest(request, frameName);
+
+ // FIXME: It's much better for client API if a new window starts with a URL,
+ // here where we know what URL we are going to open. Unfortunately, this
+ // code passes the empty string for the URL, but there's a reason for that.
+ // Before loading we have to set up the opener, openedByDOM,
+ // and dialogArguments values. Also, to decide whether to use the URL
+ // we currently do an allowsAccessFrom call using the window we create,
+ // which can't be done before creating it. We'd have to resolve all those
+ // issues to pass the URL instead of "".
+
+ bool created;
+ // We pass in the opener frame here so it can be used for looking up the
+ // frame name, in case the active frame is different from the opener frame,
+ // and the name references a frame relative to the opener frame, for example
+ // "_self" or "_parent".
+ Frame* newFrame = activeFrame->loader()->createWindow(openerFrame->loader(), frameRequest, windowFeatures, created);
+ if (!newFrame)
+ return 0;
+
+ newFrame->loader()->setOpener(openerFrame);
+ newFrame->loader()->setOpenedByDOM();
+
+ // Set dialog arguments on the global object of the new frame.
+ if (!dialogArgs.IsEmpty()) {
+ v8::Local<v8::Context> context = V8Proxy::GetContext(newFrame);
+ if (!context.IsEmpty()) {
+ v8::Context::Scope scope(context);
+ context->Global()->Set(v8::String::New("dialogArguments"), dialogArgs);
+ }
+ }
+
+ if (!parseURL(url).startsWith("javascript:", false)
+ || ScriptController::isSafeScript(newFrame)) {
+ KURL completedUrl =
+ url.isEmpty() ? KURL("") : activeFrame->document()->completeURL(url);
+ bool userGesture = activeFrame->script()->processingUserGesture();
+
+ if (created)
+ newFrame->loader()->changeLocation(completedUrl, activeFrame->loader()->outgoingReferrer(), false, false, userGesture);
+ else if (!url.isEmpty())
+ newFrame->loader()->scheduleLocationChange(completedUrl.string(), activeFrame->loader()->outgoingReferrer(), false, userGesture);
+ }
+
+ return newFrame;
+}
+
+
+
+CALLBACK_FUNC_DECL(DOMWindowShowModalDialog)
+{
+ INC_STATS("DOM.DOMWindow.showModalDialog()");
+ DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(
+ V8ClassIndex::DOMWINDOW, args.Holder());
+ Frame* frame = window->frame();
+
+ if (!frame || !V8Proxy::CanAccessFrame(frame, true))
+ return v8::Undefined();
+
+ if (!canShowModalDialogNow(frame) || !allowPopUp())
+ return v8::Undefined();
+
+ String url = valueToStringWithNullOrUndefinedCheck(args[0]);
+ v8::Local<v8::Value> dialogArgs = args[1];
+ String featureArgs = valueToStringWithNullOrUndefinedCheck(args[2]);
+
+ const HashMap<String, String> features = parseModalDialogFeatures(featureArgs);
+
+ const bool trusted = false;
+
+ FloatRect screenRect = screenAvailableRect(frame->view());
+
+ WindowFeatures windowFeatures;
+ // default here came from frame size of dialog in MacIE.
+ windowFeatures.width = WindowFeatures::floatFeature(features, "dialogwidth", 100, screenRect.width(), 620);
+ windowFeatures.widthSet = true;
+ // default here came from frame size of dialog in MacIE.
+ windowFeatures.height = WindowFeatures::floatFeature(features, "dialogheight", 100, screenRect.height(), 450);
+ windowFeatures.heightSet = true;
+
+ windowFeatures.x = WindowFeatures::floatFeature(features, "dialogleft", screenRect.x(), screenRect.right() - windowFeatures.width, -1);
+ windowFeatures.xSet = windowFeatures.x > 0;
+ windowFeatures.y = WindowFeatures::floatFeature(features, "dialogtop", screenRect.y(), screenRect.bottom() - windowFeatures.height, -1);
+ windowFeatures.ySet = windowFeatures.y > 0;
+
+ if (WindowFeatures::boolFeature(features, "center", true)) {
+ if (!windowFeatures.xSet) {
+ windowFeatures.x = screenRect.x() + (screenRect.width() - windowFeatures.width) / 2;
+ windowFeatures.xSet = true;
+ }
+ if (!windowFeatures.ySet) {
+ windowFeatures.y = screenRect.y() + (screenRect.height() - windowFeatures.height) / 2;
+ windowFeatures.ySet = true;
+ }
+ }
+
+ windowFeatures.dialog = true;
+ windowFeatures.resizable = WindowFeatures::boolFeature(features, "resizable");
+ windowFeatures.scrollbarsVisible = WindowFeatures::boolFeature(features, "scroll", true);
+ windowFeatures.statusBarVisible = WindowFeatures::boolFeature(features, "status", !trusted);
+ windowFeatures.menuBarVisible = false;
+ windowFeatures.toolBarVisible = false;
+ windowFeatures.locationBarVisible = false;
+ windowFeatures.fullscreen = false;
+
+ Frame* dialogFrame = createWindow(frame, url, "", windowFeatures, dialogArgs);
+ if (!dialogFrame)
+ return v8::Undefined();
+
+ // Hold on to the context of the dialog window long enough to retrieve the
+ // value of the return value property.
+ v8::Local<v8::Context> context = V8Proxy::GetContext(dialogFrame);
+
+ // Run the dialog.
+ dialogFrame->page()->chrome()->runModal();
+
+ // Extract the return value property from the dialog window.
+ v8::Local<v8::Value> returnValue;
+ if (!context.IsEmpty()) {
+ v8::Context::Scope scope(context);
+ returnValue = context->Global()->Get(v8::String::New("returnValue"));
+ }
+
+ if (!returnValue.IsEmpty())
+ return returnValue;
+
+ return v8::Undefined();
+}
+
+
+CALLBACK_FUNC_DECL(DOMWindowOpen)
+{
+ INC_STATS("DOM.DOMWindow.open()");
+ DOMWindow* parent = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, args.Holder());
+ Frame* frame = parent->frame();
+
+ if (!V8Proxy::CanAccessFrame(frame, true))
+ return v8::Undefined();
+
+ Frame* activeFrame = V8Proxy::retrieveActiveFrame();
+ if (!activeFrame)
+ return v8::Undefined();
+
+ Page* page = frame->page();
+ if (!page)
+ return v8::Undefined();
+
+ String urlString = valueToStringWithNullOrUndefinedCheck(args[0]);
+ AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1]));
+
+ // Because FrameTree::find() returns true for empty strings, we must check
+ // for empty framenames. Otherwise, illegitimate window.open() calls with
+ // no name will pass right through the popup blocker.
+ if (!allowPopUp() &&
+ (frameName.isEmpty() || !frame->tree()->find(frameName))) {
+ return v8::Undefined();
+ }
+
+ // Get the target frame for the special cases of _top and _parent. In those
+ // cases, we can schedule a location change right now and return early.
+ bool topOrParent = false;
+ if (frameName == "_top") {
+ frame = frame->tree()->top();
+ topOrParent = true;
+ } else if (frameName == "_parent") {
+ if (Frame* parent = frame->tree()->parent())
+ frame = parent;
+ topOrParent = true;
+ }
+ if (topOrParent) {
+ if (!activeFrame->loader()->shouldAllowNavigation(frame))
+ return v8::Undefined();
+
+ String completedUrl;
+ if (!urlString.isEmpty())
+ completedUrl = activeFrame->document()->completeURL(urlString);
+
+ if (!completedUrl.isEmpty() &&
+ (!parseURL(urlString).startsWith("javascript:", false)
+ || ScriptController::isSafeScript(frame))) {
+ bool userGesture = activeFrame->script()->processingUserGesture();
+ frame->loader()->scheduleLocationChange(completedUrl, activeFrame->loader()->outgoingReferrer(), false, userGesture);
+ }
+ return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
+ }
+
+ // In the case of a named frame or a new window, we'll use the
+ // createWindow() helper.
+
+ // Parse the values, and then work with a copy of the parsed values
+ // so we can restore the values we may not want to overwrite after
+ // we do the multiple monitor fixes.
+ WindowFeatures rawFeatures(valueToStringWithNullOrUndefinedCheck(args[2]));
+ WindowFeatures windowFeatures(rawFeatures);
+ FloatRect screenRect = screenAvailableRect(page->mainFrame()->view());
+
+ // Set default size and location near parent window if none were specified.
+ // These may be further modified by adjustWindowRect, below.
+ if (!windowFeatures.xSet) {
+ windowFeatures.x = parent->screenX() - screenRect.x() + popupTilePixels;
+ windowFeatures.xSet = true;
+ }
+ if (!windowFeatures.ySet) {
+ windowFeatures.y = parent->screenY() - screenRect.y() + popupTilePixels;
+ windowFeatures.ySet = true;
+ }
+ if (!windowFeatures.widthSet) {
+ windowFeatures.width = parent->innerWidth();
+ windowFeatures.widthSet = true;
+ }
+ if (!windowFeatures.heightSet) {
+ windowFeatures.height = parent->innerHeight();
+ windowFeatures.heightSet = true;
+ }
+
+ FloatRect windowRect(windowFeatures.x, windowFeatures.y, windowFeatures.width, windowFeatures.height);
+
+ // The new window's location is relative to its current screen, so shift
+ // it in case it's on a secondary monitor. See http://b/viewIssue?id=967905.
+ windowRect.move(screenRect.x(), screenRect.y());
+ WebCore::DOMWindow::adjustWindowRect(screenRect, windowRect, windowRect);
+
+ windowFeatures.x = windowRect.x();
+ windowFeatures.y = windowRect.y();
+ windowFeatures.height = windowRect.height();
+ windowFeatures.width = windowRect.width();
+
+ // If either of the origin coordinates weren't set in the original
+ // string, make sure they aren't set now.
+ if (!rawFeatures.xSet) {
+ windowFeatures.x = 0;
+ windowFeatures.xSet = false;
+ }
+ if (!rawFeatures.ySet) {
+ windowFeatures.y = 0;
+ windowFeatures.ySet = false;
+ }
+
+ frame = createWindow(frame, urlString, frameName, windowFeatures, v8::Local<v8::Value>());
+
+ if (!frame)
+ return v8::Undefined();
+
+ return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow());
+}
+
+
+INDEXED_PROPERTY_GETTER(DOMWindow)
+{
+ INC_STATS("DOM.DOMWindow.IndexedPropertyGetter");
+ v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This());
+ if (holder.IsEmpty())
+ return notHandledByInterceptor();
+
+ DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder);
+ if (!window)
+ return notHandledByInterceptor();
+
+ Frame* frame = window->frame();
+ if (!frame)
+ return notHandledByInterceptor();
+
+ Frame* child = frame->tree()->child(index);
+ if (child)
+ return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
+
+ return notHandledByInterceptor();
+}
+
+
+NAMED_PROPERTY_GETTER(DOMWindow)
+{
+ INC_STATS("DOM.DOMWindow.NamedPropertyGetter");
+ // The key must be a string.
+ if (!name->IsString())
+ return notHandledByInterceptor();
+
+ v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This());
+ if (holder.IsEmpty())
+ return notHandledByInterceptor();
+
+ DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder);
+ if (!window)
+ return notHandledByInterceptor();
+
+ String propName = toWebCoreString(name);
+
+ Frame* frame = window->frame();
+ // window is detached from a frame.
+ if (!frame)
+ return notHandledByInterceptor();
+
+ // Search sub-frames.
+ Frame* child = frame->tree()->child(propName);
+ if (child)
+ return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
+
+ // Search IDL functions defined in the prototype
+ v8::Handle<v8::Value> result = holder->GetRealNamedPropertyInPrototypeChain(name);
+ if (!result.IsEmpty())
+ return result;
+
+ // Lazy initialization map keeps global properties that can be lazily
+ // initialized. The value is the code to instantiate the property.
+ // It must return the value of property after initialization.
+ static HashMap<String, String> lazyInitMap;
+ if (lazyInitMap.isEmpty()) {
+ // "new Image()" does not appear to be well-defined in a spec, but Safari,
+ // Opera, and Firefox all consider it to always create an HTML image
+ // element, regardless of the current doctype.
+ lazyInitMap.set("Image",
+ "function Image() { \
+ return document.createElementNS( \
+ 'http://www.w3.org/1999/xhtml', 'img'); \
+ }; \
+ Image");
+ lazyInitMap.set("Option",
+ "function Option(text, value, defaultSelected, selected) { \
+ var option = document.createElement('option'); \
+ if (text == null) return option; \
+ option.text = text; \
+ if (value == null) return option; \
+ option.value = value; \
+ if (defaultSelected == null) return option; \
+ option.defaultSelected = defaultSelected; \
+ if (selected == null) return option; \
+ option.selected = selected; \
+ return option; \
+ }; \
+ Option");
+ }
+
+ String code = lazyInitMap.get(propName);
+ if (!code.isEmpty()) {
+ v8::Local<v8::Context> context = V8Proxy::GetContext(window->frame());
+ // Bail out if we cannot get the context for the frame.
+ if (context.IsEmpty())
+ return notHandledByInterceptor();
+
+ // switch to the target object's environment.
+ v8::Context::Scope scope(context);
+
+ // Set the property name to undefined to make sure that the
+ // property exists. This is necessary because this getter
+ // might be called when evaluating 'var RangeException = value'
+ // to figure out if we have a property named 'RangeException' before
+ // we set RangeException to the new value. In that case, we will
+ // evaluate 'var RangeException = {}' and enter an infinite loop.
+ // Setting the property name to undefined on the global object
+ // ensures that we do not have to ask this getter to figure out
+ // that we have the property.
+ //
+ // TODO(ager): We probably should implement the Has method
+ // for the interceptor instead of using the default Has method
+ // that calls Get.
+ context->Global()->Set(v8String(propName), v8::Undefined());
+ V8Proxy* proxy = V8Proxy::retrieve(window->frame());
+ ASSERT(proxy);
+
+ return proxy->evaluate(WebCore::ScriptSourceCode(code), 0);
+ }
+
+ // Search named items in the document.
+ Document* doc = frame->document();
+ if (doc) {
+ RefPtr<HTMLCollection> items = doc->windowNamedItems(propName);
+ if (items->length() >= 1) {
+ if (items->length() == 1)
+ return V8Proxy::NodeToV8Object(items->firstItem());
+ else
+ return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, items.get());
+ }
+ }
+
+ return notHandledByInterceptor();
+}
+
+
+void V8Custom::WindowSetLocation(DOMWindow* window, const String& v)
+{
+ if (!window->frame())
+ return;
+
+ Frame* activeFrame = ScriptController::retrieveActiveFrame();
+ if (!activeFrame)
+ return;
+
+ if (!activeFrame->loader()->shouldAllowNavigation(window->frame()))
+ return;
+
+ if (!parseURL(v).startsWith("javascript:", false)
+ || ScriptController::isSafeScript(window->frame())) {
+ String completedUrl = activeFrame->loader()->completeURL(v).string();
+
+ // FIXME: The JSC bindings pass !anyPageIsProcessingUserGesture() for
+ // the lockHistory parameter. We should probably do something similar.
+
+ window->frame()->loader()->scheduleLocationChange(completedUrl,
+ activeFrame->loader()->outgoingReferrer(), false, false,
+ activeFrame->script()->processingUserGesture());
+ }
+}
+
+
+CALLBACK_FUNC_DECL(DOMWindowSetTimeout)
+{
+ INC_STATS("DOM.DOMWindow.setTimeout()");
+ return WindowSetTimeoutImpl(args, true);
+}
+
+
+CALLBACK_FUNC_DECL(DOMWindowSetInterval)
+{
+ INC_STATS("DOM.DOMWindow.setInterval()");
+ return WindowSetTimeoutImpl(args, false);
+}
+
+
+void V8Custom::ClearTimeoutImpl(const v8::Arguments& args)
+{
+ v8::Handle<v8::Value> holder = args.Holder();
+ DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder);
+ if (!V8Proxy::CanAccessFrame(imp->frame(), true))
+ return;
+ ScriptExecutionContext* context = static_cast<ScriptExecutionContext*>(imp->frame()->document());
+ int handle = toInt32(args[0]);
+ DOMTimer::removeById(context, handle);
+}
+
+
+CALLBACK_FUNC_DECL(DOMWindowClearTimeout)
+{
+ INC_STATS("DOM.DOMWindow.clearTimeout");
+ ClearTimeoutImpl(args);
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(DOMWindowClearInterval)
+{
+ INC_STATS("DOM.DOMWindow.clearInterval");
+ ClearTimeoutImpl(args);
+ return v8::Undefined();
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
index 7f868f1..3eadce7 100644
--- a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
@@ -41,8 +41,11 @@
#include "V8CustomBinding.h"
#include "V8Node.h"
#include "V8Proxy.h"
+
+#if ENABLE(XPATH)
#include "V8XPathNSResolver.h"
#include "V8XPathResult.h"
+#endif
#include <wtf/RefPtr.h>
@@ -51,7 +54,7 @@ namespace WebCore {
CALLBACK_FUNC_DECL(DocumentEvaluate)
{
INC_STATS("DOM.Document.evaluate()");
-
+#if ENABLE(XPATH)
Document* document = V8Proxy::DOMWrapperToNode<Document>(args.Holder());
ExceptionCode ec = 0;
String expression = toWebCoreString(args[0]);
@@ -81,6 +84,9 @@ CALLBACK_FUNC_DECL(DocumentEvaluate)
return throwError(ec);
return V8Proxy::ToV8Object(V8ClassIndex::XPATHRESULT, result.get());
+#else
+ return throwError(NOT_SUPPORTED_ERR);
+#endif
}
CALLBACK_FUNC_DECL(DocumentGetCSSCanvasContext)
diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index bc04f7e..1d408b2 100644
--- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2009 Google Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009 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
@@ -58,19 +58,6 @@ NAMED_PROPERTY_DELETER(HTMLDocument)
return v8::True();
}
-NAMED_PROPERTY_SETTER(HTMLDocument)
-{
- INC_STATS("DOM.HTMLDocument.NamedPropertySetter");
- // Only handle document.all. We insert the value into the shadow
- // internal field from which the getter will retrieve it.
- String key = toWebCoreString(name);
- if (key == "all") {
- ASSERT(info.Holder()->InternalFieldCount() == kHTMLDocumentInternalFieldCount);
- info.Holder()->SetInternalField(kHTMLDocumentShadowIndex, value);
- }
- return notHandledByInterceptor();
-}
-
NAMED_PROPERTY_GETTER(HTMLDocument)
{
INC_STATS("DOM.HTMLDocument.NamedPropertyGetter");
@@ -87,13 +74,13 @@ NAMED_PROPERTY_GETTER(HTMLDocument)
return value;
}
- HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(info.Holder());
+ HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(info.Holder());
// Fast case for named elements that are not there.
- if (!imp->hasNamedItem(key.impl()) && !imp->hasExtraNamedItem(key.impl()))
+ if (!htmlDocument->hasNamedItem(key.impl()) && !htmlDocument->hasExtraNamedItem(key.impl()))
return v8::Handle<v8::Value>();
- RefPtr<HTMLCollection> items = imp->documentNamedItems(key);
+ RefPtr<HTMLCollection> items = htmlDocument->documentNamedItems(key);
if (!items->length())
return notHandledByInterceptor();
@@ -109,4 +96,96 @@ NAMED_PROPERTY_GETTER(HTMLDocument)
return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, items.get());
}
+// HTMLDocument ----------------------------------------------------------------
+
+// Concatenates "args" to a string. If args is empty, returns empty string.
+// Firefox/Safari/IE support non-standard arguments to document.write, ex:
+// document.write("a", "b", "c") --> document.write("abc")
+// document.write() --> document.write("")
+static String writeHelperGetString(const v8::Arguments& args)
+{
+ String str = "";
+ for (int i = 0; i < args.Length(); ++i)
+ str += toWebCoreString(args[i]);
+ return str;
+}
+
+CALLBACK_FUNC_DECL(HTMLDocumentWrite)
+{
+ INC_STATS("DOM.HTMLDocument.write()");
+ HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder());
+ Frame* frame = V8Proxy::retrieveActiveFrame();
+ ASSERT(frame);
+ htmlDocument->write(writeHelperGetString(args), frame->document());
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(HTMLDocumentWriteln)
+{
+ INC_STATS("DOM.HTMLDocument.writeln()");
+ HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder());
+ Frame* frame = V8Proxy::retrieveActiveFrame();
+ ASSERT(frame);
+ htmlDocument->writeln(writeHelperGetString(args), frame->document());
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(HTMLDocumentOpen)
+{
+ INC_STATS("DOM.HTMLDocument.open()");
+ HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder());
+
+ if (args.Length() > 2) {
+ if (Frame* frame = htmlDocument->frame()) {
+ // Fetch the global object for the frame.
+ v8::Local<v8::Context> context = V8Proxy::GetContext(frame);
+ // Bail out if we cannot get the context.
+ if (context.IsEmpty())
+ return v8::Undefined();
+ v8::Local<v8::Object> global = context->Global();
+ // Get the open property of the global object.
+ v8::Local<v8::Value> function = global->Get(v8::String::New("open"));
+ // If the open property is not a function throw a type error.
+ if (!function->IsFunction()) {
+ throwError("open is not a function");
+ return v8::Undefined();
+ }
+ // Wrap up the arguments and call the function.
+ v8::Local<v8::Value>* params = new v8::Local<v8::Value>[args.Length()];
+ for (int i = 0; i < args.Length(); i++)
+ params[i] = args[i];
+
+ V8Proxy* proxy = V8Proxy::retrieve(frame);
+ ASSERT(proxy);
+
+ v8::Local<v8::Value> result = proxy->CallFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params);
+ delete[] params;
+ return result;
+ }
+ }
+
+ Frame* frame = V8Proxy::retrieveActiveFrame();
+ htmlDocument->open(frame->document());
+ // Return the document.
+ return args.Holder();
+}
+
+ACCESSOR_GETTER(HTMLDocumentAll)
+{
+ INC_STATS("DOM.HTMLDocument.all._get");
+ v8::HandleScope scope;
+ v8::Handle<v8::Object> holder = info.Holder();
+ HTMLDocument* htmlDocument = V8Proxy::DOMWrapperToNode<HTMLDocument>(holder);
+ RefPtr<HTMLCollection> collection = WTF::getPtr(htmlDocument->all());
+ return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, WTF::getPtr(collection));
+}
+
+ACCESSOR_SETTER(HTMLDocumentAll)
+{
+ INC_STATS("DOM.HTMLDocument.all._set");
+ v8::Handle<v8::Object> holder = info.Holder();
+ ASSERT(info.Holder()->InternalFieldCount() == kHTMLDocumentInternalFieldCount);
+ info.Holder()->SetInternalField(kHTMLDocumentShadowIndex, value);
+}
+
} // namespace WebCore
diff --git a/WebCore/bridge/jni/jni_utility.cpp b/WebCore/bridge/jni/jni_utility.cpp
index 5dc4722..a1f4a2d 100644
--- a/WebCore/bridge/jni/jni_utility.cpp
+++ b/WebCore/bridge/jni/jni_utility.cpp
@@ -28,11 +28,14 @@
#if ENABLE(MAC_JAVA_BRIDGE)
+#if USE(JSC)
#include "jni_runtime.h"
#include "runtime_array.h"
#include "runtime_object.h"
#include <runtime/JSArray.h>
#include <runtime/JSLock.h>
+#endif
+
#include <dlfcn.h>
namespace JSC {
@@ -347,6 +350,7 @@ jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *sig
return result;
}
+#if USE(JSC)
static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray, const char* javaClassName)
{
JNIEnv *env = getJNIEnv();
@@ -576,6 +580,7 @@ jvalue convertValueToJValue(ExecState* exec, JSValuePtr value, JNIType _JNIType,
}
return result;
}
+#endif // USE(JSC)
} // end of namespace Bindings
diff --git a/WebCore/bridge/jni/jni_utility.h b/WebCore/bridge/jni/jni_utility.h
index e76570c..4330b1e 100644
--- a/WebCore/bridge/jni/jni_utility.h
+++ b/WebCore/bridge/jni/jni_utility.h
@@ -28,7 +28,9 @@
#if ENABLE(MAC_JAVA_BRIDGE)
+#if USE(JSC)
#include <runtime/JSValue.h>
+#endif
#include <JavaVM/jni.h>
// The order of these items can not be modified as they are tightly
@@ -53,8 +55,10 @@ typedef enum {
namespace JSC {
+#if USE(JSC)
class ExecState;
class JSObject;
+#endif
namespace Bindings {
@@ -72,7 +76,9 @@ JNIType JNITypeFromClassName(const char *name);
JNIType JNITypeFromPrimitiveType(char type);
const char *signatureFromPrimitiveType(JNIType type);
+#if USE(JSC)
jvalue convertValueToJValue(ExecState*, JSValuePtr, JNIType, const char* javaClassName);
+#endif
jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature);
@@ -279,9 +285,10 @@ T callJNIStaticMethod(jclass cls, const char* methodName, const char* methodSign
return result;
}
-
-bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValuePtr& exceptionDescription);
+#if USE(JSC)
+bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValuePtr& exceptionDescription);
+#endif
} // namespace Bindings
} // namespace JSC
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 2e2dd9a..e280c81 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -114,7 +114,9 @@
#include "XMLHttpRequest.h"
#include "XMLNames.h"
#include "XMLTokenizer.h"
+#if USE(JSC)
#include "JSDOMBinding.h"
+#endif
#include "ScriptController.h"
#include <wtf/CurrentTime.h>
#include <wtf/HashFunctions.h>
@@ -455,7 +457,10 @@ Document::~Document()
removeAllEventListeners();
+
+#if USE(JSC)
forgetAllDOMNodesForDocument(this);
+#endif
if (m_docChanged && changedDocuments)
changedDocuments->remove(this);
diff --git a/WebCore/dom/EventListener.h b/WebCore/dom/EventListener.h
index b7daa6d..1836fe6 100644
--- a/WebCore/dom/EventListener.h
+++ b/WebCore/dom/EventListener.h
@@ -48,8 +48,9 @@ namespace WebCore {
virtual bool virtualIsInline() const { return false; }
};
+#if USE(JSC)
inline void markIfNotNull(EventListener* listener) { if (listener) listener->mark(); }
-
+#endif
}
#endif
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index 96b5e6f..de0c7e9 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -33,7 +33,6 @@
#include "PlatformString.h"
#include "StringHash.h"
#include "Timer.h"
-#include <JavaScriptCore/JSContextRef.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
@@ -43,11 +42,13 @@
#include "JavaScriptDebugListener.h"
#endif
-
+#if USE(JSC)
+#include <JavaScriptCore/JSContextRef.h>
namespace JSC {
class Profile;
class UString;
}
+#endif
namespace WebCore {
@@ -176,10 +177,12 @@ public:
void clearConsoleMessages();
void toggleRecordButton(bool);
+#if USE(JSC)
void addProfile(PassRefPtr<JSC::Profile>, unsigned lineNumber, const JSC::UString& sourceURL);
void addProfileMessageToConsole(PassRefPtr<JSC::Profile> prpProfile, unsigned lineNumber, const JSC::UString& sourceURL);
void addScriptProfile(JSC::Profile* profile);
const ProfilesArray& profiles() const { return m_profiles; }
+#endif
void attachWindow();
void detachWindow();
@@ -192,8 +195,10 @@ public:
void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
void handleMousePressOnNode(Node*);
+#if USE(JSC)
JSContextRef scriptContext() const { return m_scriptContext; };
void setScriptContext(JSContextRef context) { m_scriptContext = context; };
+#endif
void inspectedWindowScriptObjectCleared(Frame*);
void windowScriptObjectAvailable();
@@ -214,8 +219,13 @@ public:
void didReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived);
void didFinishLoading(DocumentLoader*, unsigned long identifier);
void didFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&);
+#if USE(JSC)
void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const JSC::UString& sourceString);
void scriptImported(unsigned long identifier, const JSC::UString& sourceString);
+#elif USE(V8)
+ void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString);
+ void scriptImported(unsigned long identifier, const String& sourceString);
+#endif
#if ENABLE(DATABASE)
void didOpenDatabase(Database*, const String& domain, const String& name, const String& version);
@@ -266,15 +276,19 @@ private:
InspectorController(Page*, InspectorClient*);
void focusNode();
+#if USE(JSC)
void addConsoleMessage(JSC::ExecState*, ConsoleMessage*);
+#endif
void addResource(InspectorResource*);
void removeResource(InspectorResource*);
+#if USE(JSC)
JSObjectRef addScriptResource(InspectorResource*);
+ JSObjectRef addAndUpdateScriptResource(InspectorResource*);
+#endif
void removeScriptResource(InspectorResource*);
- JSObjectRef addAndUpdateScriptResource(InspectorResource*);
void updateScriptResourceRequest(InspectorResource*);
void updateScriptResourceResponse(InspectorResource*);
void updateScriptResourceType(InspectorResource*);
@@ -285,16 +299,20 @@ private:
void pruneResources(ResourcesMap*, DocumentLoader* loaderToKeep = 0);
void removeAllResources(ResourcesMap* map) { pruneResources(map); }
+#if USE(JSC)
JSValueRef callSimpleFunction(JSContextRef, JSObjectRef thisObject, const char* functionName) const;
JSValueRef callFunction(JSContextRef, JSObjectRef thisObject, const char* functionName, size_t argumentCount, const JSValueRef arguments[], JSValueRef& exception) const;
bool handleException(JSContextRef, JSValueRef exception, unsigned lineNumber) const;
+#endif
void showWindow();
#if ENABLE(JAVASCRIPT_DEBUGGER)
+#if USE(JSC)
virtual void didParseSource(JSC::ExecState*, const JSC::SourceCode&);
virtual void failedToParseSource(JSC::ExecState*, const JSC::SourceCode&, int errorLine, const JSC::UString& errorMessage);
+#endif
virtual void didPause();
#endif
@@ -307,7 +325,9 @@ private:
HashSet<String> m_knownResources;
FrameResourcesMap m_frameResources;
Vector<ConsoleMessage*> m_consoleMessages;
+#if USE(JSC)
ProfilesArray m_profiles;
+#endif
HashMap<String, double> m_times;
HashMap<String, unsigned> m_counts;
#if ENABLE(DATABASE)
@@ -316,9 +336,11 @@ private:
#if ENABLE(DOM_STORAGE)
DOMStorageResourcesSet m_domStorageResources;
#endif
+#if USE(JSC)
JSObjectRef m_scriptObject;
JSObjectRef m_controllerScriptObject;
JSContextRef m_scriptContext;
+#endif
bool m_windowVisible;
#if ENABLE(JAVASCRIPT_DEBUGGER)
bool m_debuggerEnabled;
diff --git a/WebCore/loader/icon/IconDatabase.cpp b/WebCore/loader/icon/IconDatabase.cpp
index 0521381..9d5bd20 100644
--- a/WebCore/loader/icon/IconDatabase.cpp
+++ b/WebCore/loader/icon/IconDatabase.cpp
@@ -106,7 +106,11 @@ static IconDatabaseClient* defaultClient()
IconDatabase* iconDatabase()
{
if (!sharedIconDatabase) {
+#if USE(JSC)
JSC::initializeThreading();
+#elif USE(V8)
+ // TODO(fqian): Do something for V8
+#endif
sharedIconDatabase = new IconDatabase;
}
return sharedIconDatabase;
diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl
index 6bb08a8..fd0cd55 100644
--- a/WebCore/page/DOMWindow.idl
+++ b/WebCore/page/DOMWindow.idl
@@ -395,9 +395,11 @@ module window {
#if defined(V8_BINDING)
// With JSC, these are added in JSDOMWindowBase.cpp.
attribute XMLHttpRequestConstructor XMLHttpRequest;
- attribute XSLTProcessorConstructor XSLTProcessor;
attribute MessageChannelConstructor MessageChannel;
attribute WebKitPointConstructor WebKitPoint;
+#if ENABLE_XSLT
+ attribute XSLTProcessorConstructor XSLTProcessor;
+#endif
#if ENABLE_WORKERS
attribute WorkerConstructor Worker;
#endif
diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp
index f0cd1ec..0d1a27f 100644
--- a/WebCore/page/Frame.cpp
+++ b/WebCore/page/Frame.cpp
@@ -1575,7 +1575,9 @@ void Frame::pageDestroyed()
if (page() && page()->focusController()->focusedFrame() == this)
page()->focusController()->setFocusedFrame(0);
+#if USE(JSC)
script()->clearWindowShell();
+#endif
// This will stop any JS timers
if (script()->haveWindowShell())
diff --git a/WebCore/page/Geolocation.idl b/WebCore/page/Geolocation.idl
index e125118..8a9fef9 100644
--- a/WebCore/page/Geolocation.idl
+++ b/WebCore/page/Geolocation.idl
@@ -28,10 +28,11 @@ module core {
interface Geolocation {
readonly attribute Geoposition lastPosition;
+#if !defined(V8_BINDING)
[Custom] void getCurrentPosition(in PositionCallback successCallback, in PositionErrorCallback errorCallback, in PositionOptions options);
[Custom] long watchPosition(in PositionCallback successCallback, in PositionErrorCallback errorCallback, in PositionOptions options);
-
+#endif
void clearWatch(in long watchId);
};
diff --git a/WebCore/page/android/InspectorControllerAndroid.cpp b/WebCore/page/android/InspectorControllerAndroid.cpp
index 8763df1..c480e94 100644
--- a/WebCore/page/android/InspectorControllerAndroid.cpp
+++ b/WebCore/page/android/InspectorControllerAndroid.cpp
@@ -30,8 +30,9 @@
#include "Frame.h"
#include "Node.h"
+#if USE(JSC)
#include "Profile.h"
-
+#endif
// This stub file was created to avoid building and linking in all the
// Inspector codebase. If you would like to enable the Inspector, do the
// following steps:
@@ -89,9 +90,17 @@ void InspectorController::didOpenDatabase(Database*, String const&, String const
bool InspectorController::enabled() const { return false; }
void InspectorController::inspect(Node*) {}
bool InspectorController::windowVisible() { return false; }
+#if USE(JSC)
void InspectorController::addProfile(PassRefPtr<JSC::Profile>, unsigned int, const JSC::UString&) {}
-void InspectorController::inspectedPageDestroyed() {}
void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const JSC::UString& sourceString) {}
+void InspectorController::failedToParseSource(JSC::ExecState* exec, const JSC::SourceCode& source, int errorLine, const JSC::UString& errorMessage) {}
+void InspectorController::didParseSource(JSC::ExecState* exec, const JSC::SourceCode& source) {}
+void InspectorController::scriptImported(unsigned long identifier, const JSC::UString& sourceString) {}
+#elif USE(V8)
+void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString) {}
+void InspectorController::scriptImported(unsigned long identifier, const String& sourceString) {}
+#endif
+void InspectorController::inspectedPageDestroyed() {}
void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame) {}
void InspectorController::startGroup(MessageSource source, ScriptCallStack* callFrame) {}
@@ -102,10 +111,10 @@ void InspectorController::count(const String& title, unsigned lineNumber, const
void InspectorController::mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) {}
void InspectorController::handleMousePressOnNode(Node*) {}
-void InspectorController::failedToParseSource(JSC::ExecState* exec, const JSC::SourceCode& source, int errorLine, const JSC::UString& errorMessage) {}
-void InspectorController::didParseSource(JSC::ExecState* exec, const JSC::SourceCode& source) {}
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
void InspectorController::didPause() {}
+#endif
-void InspectorController::scriptImported(unsigned long identifier, const JSC::UString& sourceString) {}
void InspectorController::startUserInitiatedProfiling(Timer<InspectorController>*) {}
} // namespace WebCore
diff --git a/WebCore/platform/android/TemporaryLinkStubs.cpp b/WebCore/platform/android/TemporaryLinkStubs.cpp
index 5d71dd0..458171d 100644
--- a/WebCore/platform/android/TemporaryLinkStubs.cpp
+++ b/WebCore/platform/android/TemporaryLinkStubs.cpp
@@ -61,12 +61,15 @@
#include "IconDatabase.h"
#include "IconLoader.h"
#include "IntPoint.h"
+
+#if USE(JSC)
#include "JavaScriptCallFrame.h"
#include "JavaScriptDebugServer.h"
#include "API/JSClassRef.h"
-#include "JavaScriptCallFrame.h"
#include "JavaScriptProfile.h"
#include "jni_utility.h"
+#endif
+
#include "KURL.h"
#include "Language.h"
#include "loader.h"
@@ -745,6 +748,7 @@ PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&)
}
+#if USE(JSC)
namespace JSC { namespace Bindings {
bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType,
jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValuePtr& exceptionDescription)
@@ -754,6 +758,7 @@ bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool
}
} } // namespace Bindings
+#endif
char* dirname(const char*)
{
@@ -839,6 +844,7 @@ void AXObjectCache::remove(RenderObject*)
notImplemented();
}
+#if USE(JSC)
using namespace JSC;
@@ -962,3 +968,5 @@ void JavaScriptDebugServer::willExecuteProgram(const DebuggerCallFrame&, int, in
{
notImplemented();
}
+#endif
+
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index 60287f6..57317a1 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -38,7 +38,6 @@
#include "Image.h"
#include "HTMLNames.h"
#include "HTMLPlugInElement.h"
-#include "JSDOMWindow.h"
#include "KeyboardEvent.h"
#include "MIMETypeRegistry.h"
#include "MouseEvent.h"
@@ -50,7 +49,6 @@
#include "PluginMessageThrottlerWin.h"
#endif
#include "PluginPackage.h"
-#include "JSDOMBinding.h"
#include "ScriptController.h"
#include "ScriptValue.h"
#include "PluginDatabase.h"
@@ -59,20 +57,28 @@
#include "PluginPackage.h"
#include "RenderBox.h"
#include "RenderObject.h"
-#include "c_instance.h"
#include "npruntime_impl.h"
-#include "runtime_root.h"
#include "Settings.h"
+
+#if USE(JSC)
+#include "JSDOMWindow.h"
+#include "JSDOMBinding.h"
+#include "c_instance.h"
+#include "runtime_root.h"
#include "runtime.h"
#include <runtime/JSLock.h>
#include <runtime/JSValue.h>
+#endif
+
#include <wtf/ASCIICType.h>
+#if USE(JSC)
using JSC::ExecState;
using JSC::JSLock;
using JSC::JSObject;
using JSC::JSValuePtr;
using JSC::UString;
+#endif
using std::min;
@@ -169,7 +175,9 @@ bool PluginView::start()
NPError npErr;
{
PluginView::setCurrentPluginView(this);
+#if USE(JSC)
JSC::JSLock::DropAllLocks dropAllLocks(false);
+#endif
setCallingPlugin(true);
npErr = m_plugin->pluginFuncs()->newp((NPMIMEType)m_mimeType.data(), m_instance, m_mode, m_paramCount, m_paramNames, m_paramValues, NULL);
setCallingPlugin(false);
@@ -212,6 +220,7 @@ static char* createUTF8String(const String& str)
return result;
}
+#if USE(JSC)
static bool getString(ScriptController* proxy, JSValuePtr result, String& string)
{
if (!proxy || !result || result.isUndefined())
@@ -225,6 +234,7 @@ static bool getString(ScriptController* proxy, JSValuePtr result, String& string
string = ustring;
return true;
}
+#endif
void PluginView::performRequest(PluginRequest* request)
{
@@ -251,7 +261,9 @@ void PluginView::performRequest(PluginRequest* request)
// FIXME: <rdar://problem/4807469> This should be sent when the document has finished loading
if (request->sendNotification()) {
PluginView::setCurrentPluginView(this);
+#if USE(JSC)
JSC::JSLock::DropAllLocks dropAllLocks(false);
+#endif
setCallingPlugin(true);
m_plugin->pluginFuncs()->urlnotify(m_instance, requestURL.string().utf8().data(), NPRES_DONE, request->notifyData());
setCallingPlugin(false);
@@ -264,7 +276,8 @@ void PluginView::performRequest(PluginRequest* request)
// Targeted JavaScript requests are only allowed on the frame that contains the JavaScript plugin
// and this has been made sure in ::load.
ASSERT(targetFrameName.isEmpty() || m_parentFrame->tree()->find(targetFrameName) == m_parentFrame);
-
+
+#if USE(JSC)
// Executing a script can cause the plugin view to be destroyed, so we keep a reference to the parent frame.
RefPtr<Frame> parentFrame = m_parentFrame;
JSValuePtr result = m_parentFrame->loader()->executeScript(jsString, request->shouldAllowPopups()).jsValue();
@@ -280,6 +293,7 @@ void PluginView::performRequest(PluginRequest* request)
m_streams.add(stream);
stream->sendJavaScriptStream(requestURL, cstr);
}
+#endif
}
void PluginView::requestTimerFired(Timer<PluginView>* timer)
@@ -484,6 +498,8 @@ void PluginView::setJavaScriptPaused(bool paused)
m_requestTimer.startOneShot(0);
}
+
+#if USE(JSC)
PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
@@ -513,8 +529,9 @@ PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
return instance.release();
#else
return 0;
-#endif
+#endif // NETSCAPE_PLUGIN_API
}
+#endif // JSC
void PluginView::disconnectStream(PluginStream* stream)
{
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index e895165..3821df6 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -58,11 +58,13 @@ typedef struct PluginWidgetAndroid* PlatformPluginWidget;
typedef PlatformWidget PlatformPluginWidget;
#endif
+#if USE(JSC)
namespace JSC {
namespace Bindings {
class Instance;
}
}
+#endif
namespace WebCore {
class Element;
@@ -124,7 +126,9 @@ namespace WebCore {
void setNPWindowRect(const IntRect&);
static PluginView* currentPluginView();
+#if USE(JSC)
PassRefPtr<JSC::Bindings::Instance> bindingInstance();
+#endif
PluginStatus status() const { return m_status; }
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp
index 09117ae..084765b 100644
--- a/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -50,19 +50,20 @@
#include "PlatformKeyboardEvent.h"
#include "PluginMainThreadScheduler.h"
#include "PluginPackage.h"
-// #include "kjs_binding.h"
-// #include "kjs_proxy.h"
#include "android_graphics.h"
#include "SkCanvas.h"
#include "npruntime_impl.h"
-#include "runtime_root.h"
+// #include "runtime_root.h"
#include "utils/SystemClock.h"
#include "ScriptController.h"
#include "Settings.h"
+
+#if USE(JSC)
#include <runtime/JSLock.h>
-// #include <kjs/value.h>
+#endif
+
#include <wtf/ASCIICType.h>
-#include "runtime.h"
+// #include "runtime.h"
#include "WebViewCore.h"
#include "PluginDebug.h"
@@ -131,12 +132,6 @@ static bool anp_getInterface(NPNVariable var, void* value, NPError* error) {
///////////////////////////////////////////////////////////////////////////////
-using JSC::ExecState;
-using JSC::Interpreter;
-using JSC::JSLock;
-using JSC::JSObject;
-using JSC::UString;
-
using std::min;
using namespace WTF;
@@ -330,7 +325,9 @@ void PluginView::setNPWindowRect(const IntRect& rect)
m_npWindow.clipRect.bottom = height;
if (m_plugin->pluginFuncs()->setwindow) {
+#if USE(JSC)
JSC::JSLock::DropAllLocks dropAllLocks(false);
+#endif
setCallingPlugin(true);
m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
setCallingPlugin(false);
@@ -355,8 +352,9 @@ void PluginView::stop()
ASSERT(m_streams.isEmpty());
m_isStarted = false;
-
+#if USE(JSC)
JSC::JSLock::DropAllLocks dropAllLocks(false);
+#endif
PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance);