[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
abarth at webkit.org
abarth at webkit.org
Wed Jan 20 22:13:04 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 616e28a937ffe2a8b3d8d2de1d330b6cfe983e8b
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 5 19:03:29 2010 +0000
2010-01-05 Adam Barth <abarth at webkit.org>
Reviewed by Dimitri Glazkov.
[V8] Move createWindow into generic bindings so it can be shared with JSC
https://bugs.webkit.org/show_bug.cgi?id=33201
This patch moves createWindow from V8-specific code into the generic
bindings so that is can be re-used by the JavaScriptCore bindings. I
haven't actually moved the JSC bindings over to using this yet.
Also, I organized the generic bindings a bit more as it's becoming
clearer how things are going to shape up. There are still some
question marks, but hopefully the answers will become clear as we
progress.
* WebCore.gyp/WebCore.gyp:
* WebCore.gypi:
* bindings/generic/BindingDOMWindow.h: Added.
(WebCore::::createWindow):
* bindings/generic/BindingSecurity.h: Renamed from WebCore/bindings/BindingSecurity.h.
(WebCore::BindingSecurity::BindingSecurity):
(WebCore::::canAccessWindow):
(WebCore::::canAccessFrame):
(WebCore::::checkNodeSecurity):
* bindings/generic/BindingSecurityBase.cpp: Renamed from WebCore/bindings/BindingSecurityBase.cpp.
(WebCore::BindingSecurityBase::getDOMWindow):
(WebCore::BindingSecurityBase::getFrame):
(WebCore::BindingSecurityBase::canAccess):
* bindings/generic/BindingSecurityBase.h: Renamed from WebCore/bindings/BindingSecurityBase.h.
* bindings/generic/GenericBinding.h: Renamed from WebCore/bindings/GenericBinding.h.
(WebCore::):
* bindings/v8/V8Binding.h:
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::showModalDialogCallback):
(WebCore::V8DOMWindow::openCallback):
* bindings/v8/specialization/V8BindingDOMWindow.h: Added.
(WebCore::V8BindingDOMWindow::storeDialogArgs):
* bindings/v8/specialization/V8BindingState.cpp: Renamed from WebCore/bindings/v8/V8BindingState.cpp.
(WebCore::::Only):
(WebCore::::getActiveWindow):
(WebCore::::immediatelyReportUnsafeAccessTo):
* bindings/v8/specialization/V8BindingState.h: Renamed from WebCore/bindings/v8/V8BindingState.h.
(WebCore::):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1dad3df..0508043 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,48 @@
+2010-01-05 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Dimitri Glazkov.
+
+ [V8] Move createWindow into generic bindings so it can be shared with JSC
+ https://bugs.webkit.org/show_bug.cgi?id=33201
+
+ This patch moves createWindow from V8-specific code into the generic
+ bindings so that is can be re-used by the JavaScriptCore bindings. I
+ haven't actually moved the JSC bindings over to using this yet.
+
+ Also, I organized the generic bindings a bit more as it's becoming
+ clearer how things are going to shape up. There are still some
+ question marks, but hopefully the answers will become clear as we
+ progress.
+
+ * WebCore.gyp/WebCore.gyp:
+ * WebCore.gypi:
+ * bindings/generic/BindingDOMWindow.h: Added.
+ (WebCore::::createWindow):
+ * bindings/generic/BindingSecurity.h: Renamed from WebCore/bindings/BindingSecurity.h.
+ (WebCore::BindingSecurity::BindingSecurity):
+ (WebCore::::canAccessWindow):
+ (WebCore::::canAccessFrame):
+ (WebCore::::checkNodeSecurity):
+ * bindings/generic/BindingSecurityBase.cpp: Renamed from WebCore/bindings/BindingSecurityBase.cpp.
+ (WebCore::BindingSecurityBase::getDOMWindow):
+ (WebCore::BindingSecurityBase::getFrame):
+ (WebCore::BindingSecurityBase::canAccess):
+ * bindings/generic/BindingSecurityBase.h: Renamed from WebCore/bindings/BindingSecurityBase.h.
+ * bindings/generic/GenericBinding.h: Renamed from WebCore/bindings/GenericBinding.h.
+ (WebCore::):
+ * bindings/v8/V8Binding.h:
+ * bindings/v8/custom/V8DOMWindowCustom.cpp:
+ (WebCore::V8DOMWindow::showModalDialogCallback):
+ (WebCore::V8DOMWindow::openCallback):
+ * bindings/v8/specialization/V8BindingDOMWindow.h: Added.
+ (WebCore::V8BindingDOMWindow::storeDialogArgs):
+ * bindings/v8/specialization/V8BindingState.cpp: Renamed from WebCore/bindings/v8/V8BindingState.cpp.
+ (WebCore::::Only):
+ (WebCore::::getActiveWindow):
+ (WebCore::::immediatelyReportUnsafeAccessTo):
+ * bindings/v8/specialization/V8BindingState.h: Renamed from WebCore/bindings/v8/V8BindingState.h.
+ (WebCore::):
+
2010-01-05 Dominic Mazzoni <dmazzoni at google.com>
Reviewed by Darin Adler.
diff --git a/WebCore/WebCore.gyp/WebCore.gyp b/WebCore/WebCore.gyp/WebCore.gyp
index 45de925..5483e75 100644
--- a/WebCore/WebCore.gyp/WebCore.gyp
+++ b/WebCore/WebCore.gyp/WebCore.gyp
@@ -107,8 +107,10 @@
'../accessibility',
'../accessibility/chromium',
'../bindings',
+ '../bindings/generic',
'../bindings/v8',
'../bindings/v8/custom',
+ '../bindings/v8/specialization',
'../bridge',
'../css',
'../dom',
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index a336693..38d2f11 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -434,10 +434,11 @@
'accessibility/win/AccessibilityObjectWin.cpp',
'accessibility/win/AccessibilityObjectWrapperWin.h',
'accessibility/wx/AccessibilityObjectWx.cpp',
- 'bindings/BindingSecurity.h',
- 'bindings/BindingSecurityBase.cpp',
- 'bindings/BindingSecurityBase.h',
- 'bindings/GenericBinding.h',
+ 'bindings/generic/BindingDOMWindow.h',
+ 'bindings/generic/BindingSecurity.h',
+ 'bindings/generic/BindingSecurityBase.cpp',
+ 'bindings/generic/BindingSecurityBase.h',
+ 'bindings/generic/GenericBinding.h',
'bindings/js/CachedScriptSourceProvider.h',
'bindings/js/DOMObjectWithSVGContext.h',
'bindings/js/GCController.cpp',
@@ -791,14 +792,15 @@
'bindings/v8/ScriptValue.cpp',
'bindings/v8/ScriptValue.h',
'bindings/v8/SerializedScriptValue.h',
+ 'bindings/v8/specialization/V8BindingDOMWindow.h',
+ 'bindings/v8/specialization/V8BindingState.cpp',
+ 'bindings/v8/specialization/V8BindingState.h',
'bindings/v8/StaticDOMDataStore.cpp',
'bindings/v8/StaticDOMDataStore.h',
'bindings/v8/V8AbstractEventListener.cpp',
'bindings/v8/V8AbstractEventListener.h',
'bindings/v8/V8Binding.cpp',
'bindings/v8/V8Binding.h',
- 'bindings/v8/V8BindingState.cpp',
- 'bindings/v8/V8BindingState.h',
'bindings/v8/V8Collection.cpp',
'bindings/v8/V8Collection.h',
'bindings/v8/V8ConsoleMessage.cpp',
diff --git a/WebCore/bindings/BindingSecurityBase.cpp b/WebCore/bindings/BindingSecurityBase.cpp
deleted file mode 100644
index 0c12a6f..0000000
--- a/WebCore/bindings/BindingSecurityBase.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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 "BindingSecurityBase.h"
-
-#include "DOMWindow.h"
-#include "Frame.h"
-#include "SecurityOrigin.h"
-
-namespace WebCore {
-
-DOMWindow* BindingSecurityBase::getDOMWindow(Frame* frame)
-{
- return frame->domWindow();
-}
-
-Frame* BindingSecurityBase::getFrame(Node* node)
-{
- return node->document()->frame();
-}
-
-// Same origin policy implementation:
-//
-// Same origin policy prevents JS code from domain A from accessing JS & DOM
-// objects in a different domain B. There are exceptions and several objects
-// are accessible by cross-domain code. For example, the window.frames object
-// is accessible by code from a different domain, but window.document is not.
-//
-// The JS binding code sets security check callbacks on a function template,
-// and accessing instances of the template calls the callback function.
-// The callback function enforces the same origin policy.
-//
-// Callback functions are expensive. Binding code should use a security token
-// string to do fast access checks for the common case where source and target
-// are in the same domain. A security token is a string object that represents
-// the protocol/url/port of a domain.
-//
-// There are special cases where security token matching is not enough.
-// For example, JS can set its domain to a super domain by calling
-// document.setDomain(...). In these cases, the binding code can reset
-// a context's security token to its global object so that the fast access
-// check will always fail.
-
-// Helper to check if the current execution context can access a target frame.
-// First it checks same domain policy using the lexical context.
-//
-// This is equivalent to KJS::Window::allowsAccessFrom(ExecState*).
-bool BindingSecurityBase::canAccess(DOMWindow* activeWindow,
- DOMWindow* targetWindow)
-{
- ASSERT(targetWindow);
-
- String message;
-
- if (activeWindow == targetWindow)
- return true;
-
- if (!activeWindow)
- return false;
-
- const SecurityOrigin* activeSecurityOrigin = activeWindow->securityOrigin();
- const SecurityOrigin* targetSecurityOrigin = targetWindow->securityOrigin();
-
- // We have seen crashes were the security origin of the target has not been
- // initialized. Defend against that.
- if (!targetSecurityOrigin)
- return false;
-
- if (activeSecurityOrigin->canAccess(targetSecurityOrigin))
- return true;
-
- // Allow access to a "about:blank" page if the dynamic context is a
- // detached context of the same frame as the blank page.
- if (targetSecurityOrigin->isEmpty() && activeWindow->frame() == targetWindow->frame())
- return true;
-
- return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/bindings/generic/BindingDOMWindow.h b/WebCore/bindings/generic/BindingDOMWindow.h
new file mode 100644
index 0000000..b968e2c
--- /dev/null
+++ b/WebCore/bindings/generic/BindingDOMWindow.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2010 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 BindingDOMWindow_h
+#define BindingDOMWindow_h
+
+#include "Frame.h"
+#include "FrameLoadRequest.h"
+#include "GenericBinding.h"
+#include "Page.h"
+
+namespace WebCore {
+
+template <class Binding>
+class BindingDOMWindow {
+public:
+ typedef typename Binding::Value BindingValue;
+
+ static Frame* createWindow(State<Binding>*,
+ Frame* callingFrame,
+ Frame* enteredFrame,
+ Frame* openerFrame,
+ const String& url,
+ const String& frameName,
+ const WindowFeatures& windowFeatures,
+ BindingValue dialogArgs);
+};
+
+// Implementations of templated methods must be in this file.
+
+template <class Binding>
+Frame* BindingDOMWindow<Binding>::createWindow(State<Binding>* state,
+ Frame* callingFrame,
+ Frame* enteredFrame,
+ Frame* openerFrame,
+ const String& url,
+ const String& frameName,
+ const WindowFeatures& windowFeatures,
+ BindingValue dialogArgs)
+{
+ ASSERT(callingFrame);
+ ASSERT(enteredFrame);
+
+ // Sandboxed iframes cannot open new auxiliary browsing contexts.
+ if (callingFrame && callingFrame->loader()->isSandboxed(SandboxNavigation))
+ return 0;
+
+ ResourceRequest request;
+
+ // For whatever reason, Firefox uses the entered frame to determine
+ // the outgoingReferrer. We replicate that behavior here.
+ String referrer = enteredFrame->loader()->outgoingReferrer();
+ request.setHTTPReferrer(referrer);
+ FrameLoader::addHTTPOriginIfNeeded(request, enteredFrame->loader()->outgoingOrigin());
+ 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 = callingFrame->loader()->createWindow(openerFrame->loader(), frameRequest, windowFeatures, created);
+ if (!newFrame)
+ return 0;
+
+ newFrame->loader()->setOpener(openerFrame);
+ newFrame->page()->setOpenedByDOM();
+
+ Binding::DOMWindow::storeDialogArgs(state, newFrame, dialogArgs);
+
+ if (!protocolIsJavaScript(url) || BindingSecurity<Binding>::canAccessFrame(state, newFrame, true)) {
+ KURL completedUrl =
+ url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(url);
+ bool userGesture = processingUserGesture();
+
+ if (created)
+ newFrame->loader()->changeLocation(completedUrl, referrer, false, false, userGesture);
+ else if (!url.isEmpty())
+ newFrame->redirectScheduler()->scheduleLocationChange(completedUrl.string(), referrer, false, userGesture);
+ }
+
+ return newFrame;
+}
+
+} // namespace WebCore
+
+#endif // BindingDOMWindow_h
diff --git a/WebCore/bindings/BindingSecurity.h b/WebCore/bindings/generic/BindingSecurity.h
similarity index 100%
rename from WebCore/bindings/BindingSecurity.h
rename to WebCore/bindings/generic/BindingSecurity.h
diff --git a/WebCore/bindings/generic/BindingSecurityBase.cpp b/WebCore/bindings/generic/BindingSecurityBase.cpp
new file mode 100644
index 0000000..1598781
--- /dev/null
+++ b/WebCore/bindings/generic/BindingSecurityBase.cpp
@@ -0,0 +1,108 @@
+/*
+ * 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 "BindingSecurityBase.h"
+
+#include "DOMWindow.h"
+#include "Frame.h"
+#include "SecurityOrigin.h"
+
+namespace WebCore {
+
+DOMWindow* BindingSecurityBase::getDOMWindow(Frame* frame)
+{
+ return frame->domWindow();
+}
+
+Frame* BindingSecurityBase::getFrame(Node* node)
+{
+ return node->document()->frame();
+}
+
+// Same origin policy implementation:
+//
+// Same origin policy prevents JS code from domain A from accessing JS & DOM
+// objects in a different domain B. There are exceptions and several objects
+// are accessible by cross-domain code. For example, the window.frames object
+// is accessible by code from a different domain, but window.document is not.
+//
+// The JS binding code sets security check callbacks on a function template,
+// and accessing instances of the template calls the callback function.
+// The callback function enforces the same origin policy.
+//
+// Callback functions are expensive. Binding code should use a security token
+// string to do fast access checks for the common case where source and target
+// are in the same domain. A security token is a string object that represents
+// the protocol/url/port of a domain.
+//
+// There are special cases where security token matching is not enough.
+// For example, JS can set its domain to a super domain by calling
+// document.setDomain(...). In these cases, the binding code can reset
+// a context's security token to its global object so that the fast access
+// check will always fail.
+
+// Helper to check if the current execution context can access a target frame.
+// First it checks same domain policy using the lexical context.
+//
+// This is equivalent to KJS::Window::allowsAccessFrom(ExecState*).
+bool BindingSecurityBase::canAccess(DOMWindow* activeWindow,
+ DOMWindow* targetWindow)
+{
+ ASSERT(targetWindow);
+
+ String message;
+
+ if (activeWindow == targetWindow)
+ return true;
+
+ if (!activeWindow)
+ return false;
+
+ const SecurityOrigin* activeSecurityOrigin = activeWindow->securityOrigin();
+ const SecurityOrigin* targetSecurityOrigin = targetWindow->securityOrigin();
+
+ // We have seen crashes were the security origin of the target has not been
+ // initialized. Defend against that.
+ if (!targetSecurityOrigin)
+ return false;
+
+ if (activeSecurityOrigin->canAccess(targetSecurityOrigin))
+ return true;
+
+ // Allow access to a "about:blank" page if the dynamic context is a
+ // detached context of the same frame as the blank page.
+ if (targetSecurityOrigin->isEmpty() && activeWindow->frame() == targetWindow->frame())
+ return true;
+
+ return false;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/BindingSecurityBase.h b/WebCore/bindings/generic/BindingSecurityBase.h
similarity index 100%
rename from WebCore/bindings/BindingSecurityBase.h
rename to WebCore/bindings/generic/BindingSecurityBase.h
diff --git a/WebCore/bindings/GenericBinding.h b/WebCore/bindings/generic/GenericBinding.h
similarity index 100%
rename from WebCore/bindings/GenericBinding.h
rename to WebCore/bindings/generic/GenericBinding.h
diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h
index aa4a326..8ceda65 100644
--- a/WebCore/bindings/v8/V8Binding.h
+++ b/WebCore/bindings/v8/V8Binding.h
@@ -44,11 +44,16 @@ namespace WebCore {
class EventListener;
class EventTarget;
+ class V8BindingDOMWindow;
// Instantiate binding template classes for V8.
- class V8Binding {};
+ class V8Binding {
+ public:
+ typedef v8::Handle<v8::Value> Value;
+ typedef V8BindingDOMWindow DOMWindow;
+ };
typedef BindingSecurity<V8Binding> V8BindingSecurity;
-
+
// A helper function extract native object pointer from a DOM wrapper
// and cast to the specified type.
void* v8DOMWrapperToNative(v8::Handle<v8::Object>);
diff --git a/WebCore/bindings/v8/V8BindingState.cpp b/WebCore/bindings/v8/V8BindingState.cpp
deleted file mode 100644
index 30f750d..0000000
--- a/WebCore/bindings/v8/V8BindingState.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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 "V8BindingState.h"
-
-#include "V8Proxy.h"
-#include <wtf/StdLibExtras.h>
-
-namespace WebCore {
-
-State<V8Binding>* State<V8Binding>::Only()
-{
- DEFINE_STATIC_LOCAL(State, globalV8BindingState, ());
- return &globalV8BindingState;
-}
-
-DOMWindow* State<V8Binding>::getActiveWindow()
-{
- v8::Local<v8::Context> activeContext = v8::Context::GetCalling();
- if (activeContext.IsEmpty()) {
- // There is a single activation record on the stack, so that must
- // be the activeContext.
- activeContext = v8::Context::GetCurrent();
- }
- return V8Proxy::retrieveWindow(activeContext);
-}
-
-void State<V8Binding>::immediatelyReportUnsafeAccessTo(Frame* target)
-{
- V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportNow);
-}
-
-} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index 6177bc8..922fa46 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -31,19 +31,11 @@
#include "config.h"
#include "V8DOMWindow.h"
-#include "V8Binding.h"
-#include "V8BindingState.h"
-#include "V8CustomBinding.h"
-#include "V8CustomEventListener.h"
-#include "V8MessagePortCustom.h"
-#include "V8Proxy.h"
-#include "V8Utilities.h"
-
#include "Base64.h"
#include "Chrome.h"
-#include "ExceptionCode.h"
#include "DOMTimer.h"
#include "DOMWindow.h"
+#include "ExceptionCode.h"
#include "Frame.h"
#include "FrameLoadRequest.h"
#include "FrameView.h"
@@ -58,6 +50,14 @@
#include "Settings.h"
#include "SharedWorkerRepository.h"
#include "Storage.h"
+#include "V8Binding.h"
+#include "V8BindingDOMWindow.h"
+#include "V8BindingState.h"
+#include "V8CustomBinding.h"
+#include "V8CustomEventListener.h"
+#include "V8MessagePortCustom.h"
+#include "V8Proxy.h"
+#include "V8Utilities.h"
#if ENABLE(WEB_SOCKETS)
#include "WebSocket.h"
#endif
@@ -547,77 +547,6 @@ static HashMap<String, String> parseModalDialogFeatures(const String& featuresAr
return map;
}
-
-static Frame* createWindow(Frame* callingFrame,
- Frame* enteredFrame,
- Frame* openerFrame,
- const String& url,
- const String& frameName,
- const WindowFeatures& windowFeatures,
- v8::Local<v8::Value> dialogArgs)
-{
- ASSERT(callingFrame);
- ASSERT(enteredFrame);
-
- // Sandboxed iframes cannot open new auxiliary browsing contexts.
- if (callingFrame && callingFrame->loader()->isSandboxed(SandboxNavigation))
- return 0;
-
- ResourceRequest request;
-
- // For whatever reason, Firefox uses the entered frame to determine
- // the outgoingReferrer. We replicate that behavior here.
- String referrer = enteredFrame->loader()->outgoingReferrer();
- request.setHTTPReferrer(referrer);
- FrameLoader::addHTTPOriginIfNeeded(request, enteredFrame->loader()->outgoingOrigin());
- 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 = callingFrame->loader()->createWindow(openerFrame->loader(), frameRequest, windowFeatures, created);
- if (!newFrame)
- return 0;
-
- newFrame->loader()->setOpener(openerFrame);
- newFrame->page()->setOpenedByDOM();
-
- // Set dialog arguments on the global object of the new frame.
- if (!dialogArgs.IsEmpty()) {
- v8::Local<v8::Context> context = V8Proxy::context(newFrame);
- if (!context.IsEmpty()) {
- v8::Context::Scope scope(context);
- context->Global()->Set(v8::String::New("dialogArguments"), dialogArgs);
- }
- }
-
- if (!protocolIsJavaScript(url) || ScriptController::isSafeScript(newFrame)) {
- KURL completedUrl =
- url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(url);
- bool userGesture = processingUserGesture();
-
- if (created)
- newFrame->loader()->changeLocation(completedUrl, referrer, false, false, userGesture);
- else if (!url.isEmpty())
- newFrame->redirectScheduler()->scheduleLocationChange(completedUrl.string(), referrer, false, userGesture);
- }
-
- return newFrame;
-}
-
-
-
v8::Handle<v8::Value> V8DOMWindow::showModalDialogCallback(const v8::Arguments& args)
{
INC_STATS("DOM.DOMWindow.showModalDialog()");
@@ -683,7 +612,7 @@ v8::Handle<v8::Value> V8DOMWindow::showModalDialogCallback(const v8::Arguments&
windowFeatures.locationBarVisible = false;
windowFeatures.fullscreen = false;
- Frame* dialogFrame = createWindow(callingFrame, enteredFrame, frame, url, "", windowFeatures, dialogArgs);
+ Frame* dialogFrame = V8BindingDOMWindow::createWindow(V8BindingState::Only(), callingFrame, enteredFrame, frame, url, "", windowFeatures, dialogArgs);
if (!dialogFrame)
return v8::Undefined();
@@ -826,7 +755,7 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args)
windowFeatures.ySet = false;
}
- frame = createWindow(callingFrame, enteredFrame, frame, urlString, frameName, windowFeatures, v8::Local<v8::Value>());
+ frame = V8BindingDOMWindow::createWindow(V8BindingState::Only(), callingFrame, enteredFrame, frame, urlString, frameName, windowFeatures, v8::Local<v8::Value>());
if (!frame)
return v8::Undefined();
diff --git a/WebCore/bindings/v8/specialization/V8BindingDOMWindow.h b/WebCore/bindings/v8/specialization/V8BindingDOMWindow.h
new file mode 100644
index 0000000..0c4069f
--- /dev/null
+++ b/WebCore/bindings/v8/specialization/V8BindingDOMWindow.h
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+#ifndef V8BindingDOMWindow_h
+#define V8BindingDOMWindow_h
+
+#include "BindingDOMWindow.h"
+#include "GenericBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+class V8Binding;
+
+class V8BindingDOMWindow : public BindingDOMWindow<V8Binding> {
+public:
+ static void storeDialogArgs(State<V8Binding>*, Frame* newFrame, v8::Handle<v8::Value> dialogArgs)
+ {
+ // Set dialog arguments on the global object of the new frame.
+ if (!dialogArgs.IsEmpty()) {
+ v8::Local<v8::Context> context = V8Proxy::context(newFrame);
+ if (!context.IsEmpty()) {
+ v8::Context::Scope scope(context);
+ context->Global()->Set(v8::String::New("dialogArguments"), dialogArgs);
+ }
+ }
+ }
+};
+
+} // namespace WebCore
+
+#endif // V8BindingDOMWindow_h
diff --git a/WebCore/bindings/v8/specialization/V8BindingState.cpp b/WebCore/bindings/v8/specialization/V8BindingState.cpp
new file mode 100644
index 0000000..4710271
--- /dev/null
+++ b/WebCore/bindings/v8/specialization/V8BindingState.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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 "V8BindingState.h"
+
+#include "V8Proxy.h"
+#include <wtf/StdLibExtras.h>
+
+namespace WebCore {
+
+State<V8Binding>* State<V8Binding>::Only()
+{
+ DEFINE_STATIC_LOCAL(State, globalV8BindingState, ());
+ return &globalV8BindingState;
+}
+
+DOMWindow* State<V8Binding>::getActiveWindow()
+{
+ v8::Local<v8::Context> activeContext = v8::Context::GetCalling();
+ if (activeContext.IsEmpty()) {
+ // There is a single activation record on the stack, so that must
+ // be the activeContext.
+ activeContext = v8::Context::GetCurrent();
+ }
+ return V8Proxy::retrieveWindow(activeContext);
+}
+
+void State<V8Binding>::immediatelyReportUnsafeAccessTo(Frame* target)
+{
+ V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportNow);
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/V8BindingState.h b/WebCore/bindings/v8/specialization/V8BindingState.h
similarity index 100%
rename from WebCore/bindings/v8/V8BindingState.h
rename to WebCore/bindings/v8/specialization/V8BindingState.h
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list