[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e
abarth at webkit.org
abarth at webkit.org
Fri Jan 21 14:38:05 UTC 2011
The following commit has been merged in the debian/experimental branch:
commit 4625d4b9c4c10ccb447ac7fc38b468c38feb0db3
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Dec 23 17:45:08 2010 +0000
2010-12-23 Adam Barth <abarth at webkit.org>
Reviewed by Darin Adler.
Move V8 to WebCore's implementation of showModalDialog
https://bugs.webkit.org/show_bug.cgi?id=51527
This code is basically verbatim translation from the JavaScriptCore
bindings. The only intentional difference is in the world selection
for the dialog's frame. I suspect JavaScriptCore's bindings have a
subtle bug there.
In this patch, I also remove a bunch of now-unneeded code in the
generic bindings.
* bindings/generic/BindingDOMWindow.h:
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::DialogHandler::dialogCreated):
(WebCore::setUpDialog):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::DialogHandler::DialogHandler):
(WebCore::DialogHandler::dialogCreated):
(WebCore::DialogHandler::returnValue):
(WebCore::setUpDialog):
(WebCore::V8DOMWindow::showModalDialogCallback):
(WebCore::V8DOMWindow::openCallback):
* bindings/v8/specialization/V8BindingDOMWindow.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74563 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8b74fc6..8a5ef8d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2010-12-23 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Move V8 to WebCore's implementation of showModalDialog
+ https://bugs.webkit.org/show_bug.cgi?id=51527
+
+ This code is basically verbatim translation from the JavaScriptCore
+ bindings. The only intentional difference is in the world selection
+ for the dialog's frame. I suspect JavaScriptCore's bindings have a
+ subtle bug there.
+
+ In this patch, I also remove a bunch of now-unneeded code in the
+ generic bindings.
+
+ * bindings/generic/BindingDOMWindow.h:
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::DialogHandler::dialogCreated):
+ (WebCore::setUpDialog):
+ * bindings/v8/custom/V8DOMWindowCustom.cpp:
+ (WebCore::DialogHandler::DialogHandler):
+ (WebCore::DialogHandler::dialogCreated):
+ (WebCore::DialogHandler::returnValue):
+ (WebCore::setUpDialog):
+ (WebCore::V8DOMWindow::showModalDialogCallback):
+ (WebCore::V8DOMWindow::openCallback):
+ * bindings/v8/specialization/V8BindingDOMWindow.h:
+
2010-12-23 Alexander Pavlov <apavlov at chromium.org>
Reviewed by Joseph Pecoraro.
diff --git a/WebCore/bindings/generic/BindingDOMWindow.h b/WebCore/bindings/generic/BindingDOMWindow.h
index 04e3e7b..41959d1 100644
--- a/WebCore/bindings/generic/BindingDOMWindow.h
+++ b/WebCore/bindings/generic/BindingDOMWindow.h
@@ -31,238 +31,9 @@
#ifndef BindingDOMWindow_h
#define BindingDOMWindow_h
-#include "DOMWindow.h"
-#include "Frame.h"
-#include "FrameLoadRequest.h"
-#include "FrameLoader.h"
-#include "FrameView.h"
-#include "GenericBinding.h"
-#include "Page.h"
-#include "PlatformScreen.h"
-#include "ScriptController.h"
-#include "SecurityOrigin.h"
-#include "WindowFeatures.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);
-
- static WebCore::DOMWindow* open(State<Binding>*,
- WebCore::DOMWindow* parent,
- const String& url,
- const String& frameName,
- const WindowFeatures& rawFeatures);
-
-private:
- // Horizontal and vertical offset, from the parent content area,
- // around newly opened popups that don't specify a location.
- static const int popupTilePixels = 10;
-};
-
-// 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);
-
- 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(callingFrame->document()->securityOrigin(), 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 the opener frame for the lookupFrame in case the active frame is different from
- // the opener frame, and the name references a frame relative to the opener frame.
- Frame* newFrame = WebCore::createWindow(callingFrame, openerFrame, 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(state, url);
- if (created) {
- newFrame->loader()->changeLocation(callingFrame->document()->securityOrigin(),
- completedUrl, referrer, false, false);
- } else if (!url.isEmpty()) {
- newFrame->navigationScheduler()->scheduleLocationChange(callingFrame->document()->securityOrigin(),
- completedUrl.string(), referrer, false, false);
- }
- }
-
- return newFrame;
-}
-
-template<class Binding>
-WebCore::DOMWindow* BindingDOMWindow<Binding>::open(State<Binding>* state,
- WebCore::DOMWindow* parent,
- const String& urlString,
- const String& frameName,
- const WindowFeatures& rawFeatures)
-{
- Frame* frame = parent->frame();
-
- if (!BindingSecurity<Binding>::canAccessFrame(state, frame, true))
- return 0;
-
- Frame* firstFrame = state->firstFrame();
- if (!firstFrame)
- return 0;
-
- Frame* activeFrame = state->activeFrame();
- // We may not have a calling context if we are invoked by a plugin
- // via NPAPI.
- if (!activeFrame)
- activeFrame = firstFrame;
-
- Page* page = frame->page();
- if (!page)
- return 0;
-
- // 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 (!BindingSecurity<Binding>::allowPopUp(state)
- && (frameName.isEmpty() || !frame->tree()->find(frameName))) {
- return 0;
- }
-
- // 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 (!BindingSecurity<Binding>::shouldAllowNavigation(state, frame))
- return 0;
-
- String completedUrl;
- if (!urlString.isEmpty())
- completedUrl = completeURL(state, urlString);
-
- if (!completedUrl.isEmpty()
- && (!protocolIsJavaScript(completedUrl)
- || BindingSecurity<Binding>::canAccessFrame(state, frame, true))) {
- // For whatever reason, Firefox uses the first frame to determine
- // the outgoingReferrer. We replicate that behavior here.
- String referrer = firstFrame->loader()->outgoingReferrer();
-
- frame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
- completedUrl, referrer, false, false);
- }
- return frame->domWindow();
- }
-
- // In the case of a named frame or a new window, we'll use the
- // createWindow() helper.
-
- // 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 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 or dimensions 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;
- }
- if (!rawFeatures.widthSet) {
- windowFeatures.width = 0;
- windowFeatures.widthSet = false;
- }
- if (!rawFeatures.heightSet) {
- windowFeatures.height = 0;
- windowFeatures.heightSet = false;
- }
-
- frame = createWindow(state, activeFrame, firstFrame, frame, urlString, frameName, windowFeatures, Binding::emptyScriptValue());
-
- if (!frame)
- return 0;
-
- return frame->domWindow();
-}
+// FIXME: Remove this file.
} // namespace WebCore
diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 5b16ff5..6434877 100644
--- a/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -706,6 +706,8 @@ private:
inline void DialogHandler::dialogCreated(DOMWindow* dialog)
{
+ // FIXME: This looks like a leak between the normal world and an isolated
+ // world if dialogArguments comes from an isolated world.
m_globalObject = toJSDOMWindow(dialog->frame(), normalWorld(m_exec->globalData()));
if (JSValue dialogArguments = m_exec->argument(1))
m_globalObject->putDirect(Identifier(m_exec, "dialogArguments"), dialogArguments);
@@ -722,9 +724,9 @@ inline JSValue DialogHandler::returnValue() const
return slot.getValue(m_exec, identifier);
}
-static void setUpDialog(DOMWindow* dialog, void* context)
+static void setUpDialog(DOMWindow* dialog, void* handler)
{
- static_cast<DialogHandler*>(context)->dialogCreated(dialog);
+ static_cast<DialogHandler*>(handler)->dialogCreated(dialog);
}
JSValue JSDOMWindow::showModalDialog(ExecState* exec)
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index dc953b4..cf1b1e5 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -378,134 +378,69 @@ v8::Handle<v8::Value> V8DOMWindow::captureEventsCallback(const v8::Arguments& ar
return v8::Undefined();
}
-static bool canShowModalDialogNow(const Frame* frame)
+class DialogHandler {
+public:
+ explicit DialogHandler(v8::Handle<v8::Value> dialogArguments)
+ : m_dialogArguments(dialogArguments)
+ {
+ }
+
+ void dialogCreated(DOMWindow*);
+ v8::Handle<v8::Value> returnValue() const;
+
+private:
+ v8::Handle<v8::Value> m_dialogArguments;
+ v8::Handle<v8::Context> m_dialogContext;
+};
+
+inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame)
{
- // A frame can out live its page. See bug 1219613.
- if (!frame || !frame->page())
- return false;
- return frame->page()->chrome()->canRunModalNow();
+ m_dialogContext = V8Proxy::context(dialogFrame->frame());
+ if (m_dialogContext.IsEmpty())
+ return;
+ if (m_dialogArguments.IsEmpty())
+ return;
+ v8::Context::Scope scope(m_dialogContext);
+ m_dialogContext->Global()->Set(v8::String::New("dialogArguments"), m_dialogArguments);
}
-static HashMap<String, String> parseModalDialogFeatures(const String& featuresArg)
+inline v8::Handle<v8::Value> DialogHandler::returnValue() const
{
- 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);
- }
- }
+ if (m_dialogContext.IsEmpty())
+ return v8::Undefined();
+ v8::Context::Scope scope(m_dialogContext);
+ v8::Handle<v8::Value> returnValue = m_dialogContext->Global()->Get(v8::String::New("returnValue"));
+ if (returnValue.IsEmpty())
+ return v8::Undefined();
+ return returnValue;
+}
- return map;
+static void setUpDialog(DOMWindow* dialog, void* handler)
+{
+ static_cast<DialogHandler*>(handler)->dialogCreated(dialog);
}
v8::Handle<v8::Value> V8DOMWindow::showModalDialogCallback(const v8::Arguments& args)
{
INC_STATS("DOM.DOMWindow.showModalDialog()");
+ DOMWindow* impl = V8DOMWindow::toNative(args.Holder());
- String url = toWebCoreStringWithNullOrUndefinedCheck(args[0]);
- v8::Local<v8::Value> dialogArgs = args[1];
- String featureArgs = toWebCoreStringWithNullOrUndefinedCheck(args[2]);
-
- DOMWindow* window = V8DOMWindow::toNative(args.Holder());
- Frame* frame = window->frame();
-
- if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), frame, true))
- return v8::Undefined();
-
- Frame* callingFrame = V8Proxy::retrieveFrameForCallingContext();
- if (!callingFrame)
- return v8::Undefined();
-
- Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
- if (!enteredFrame)
- return v8::Undefined();
-
- if (!canShowModalDialogNow(frame) || !V8BindingSecurity::allowPopUp(V8BindingState::Only()))
- return v8::Undefined();
-
- 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 = V8BindingDOMWindow::createWindow(V8BindingState::Only(), callingFrame, enteredFrame, frame, url, "", windowFeatures, dialogArgs);
- if (!dialogFrame)
- return v8::Undefined();
+ V8BindingState* state = V8BindingState::Only();
- // 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::context(dialogFrame);
+ DOMWindow* activeWindow = state->activeWindow();
+ DOMWindow* firstWindow = state->firstWindow();
- // Run the dialog.
- dialogFrame->page()->chrome()->runModal();
+ // FIXME: Handle exceptions properly.
+ String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]);
+ String dialogFeaturesString = toWebCoreStringWithNullOrUndefinedCheck(args[2]);
- // 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"));
- }
+ DialogHandler handler(args[1]);
- if (!returnValue.IsEmpty())
- return returnValue;
+ impl->showModalDialog(urlString, dialogFeaturesString, activeWindow, firstWindow, setUpDialog, &handler);
- return v8::Undefined();
+ return handler.returnValue();
}
-
v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args)
{
INC_STATS("DOM.DOMWindow.open()");
@@ -516,9 +451,10 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args)
DOMWindow* activeWindow = state->activeWindow();
DOMWindow* firstWindow = state->firstWindow();
- EXCEPTION_BLOCK(String, urlString, toWebCoreStringWithNullOrUndefinedCheck(args[0]));
- EXCEPTION_BLOCK(AtomicString, frameName, (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1])));
- EXCEPTION_BLOCK(String, windowFeaturesString, toWebCoreStringWithNullOrUndefinedCheck(args[2]));
+ // FIXME: Handle exceptions properly.
+ String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]);
+ AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1]));
+ String windowFeaturesString = toWebCoreStringWithNullOrUndefinedCheck(args[2]);
RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeWindow, firstWindow);
if (!openedWindow)
diff --git a/WebCore/bindings/v8/specialization/V8BindingDOMWindow.h b/WebCore/bindings/v8/specialization/V8BindingDOMWindow.h
index 0c4069f..0dc516d 100644
--- a/WebCore/bindings/v8/specialization/V8BindingDOMWindow.h
+++ b/WebCore/bindings/v8/specialization/V8BindingDOMWindow.h
@@ -31,28 +31,9 @@
#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);
- }
- }
- }
-};
+// FIXME: Remove this file.
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list