Changeset 64991 in webkit


Ignore:
Timestamp:
Aug 9, 2010 10:50:41 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-08-09 Dominic Cooney <dominicc@google.com>

Reviewed by Adam Barth.

Moves window.open logic into the generic bindings.

This patch moves window.open logic from V8 into the generic
bindings so it could be shared with JSC. JSC sharing is not in
this patch. This patch is of the same flavor/intent as 33201.

https://bugs.webkit.org/show_bug.cgi?id=41392

  • bindings/generic/BindingDOMWindow.h: (WebCore::::createWindow): (WebCore::::open): (WebCore::::completeURL):
  • bindings/generic/BindingSecurity.h: (WebCore::::allowPopUp): (WebCore::::shouldAllowNavigation):
  • bindings/v8/V8Binding.h: (WebCore::V8Binding::emptyScriptValue):
  • bindings/v8/V8Utilities.cpp: (WebCore::transferHiddenDependency): (WebCore::processingUserGesture): (WebCore::shouldAllowNavigation): (WebCore::completeURL):
  • bindings/v8/custom/V8ArrayBufferCustom.cpp:
  • bindings/v8/custom/V8DOMWindowCustom.cpp: (WebCore::V8DOMWindow::showModalDialogCallback): (WebCore::V8DOMWindow::openCallback):
  • bindings/v8/specialization/V8BindingState.cpp: (WebCore::::getActiveFrame): (WebCore::::getFirstFrame): (WebCore::::processingUserGesture):
  • bindings/v8/specialization/V8BindingState.h: (WebCore::):
Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64987 r64991  
     12010-08-09  Dominic Cooney  <dominicc@google.com>
     2
     3        Reviewed by Adam Barth.
     4
     5        Moves window.open logic into the generic bindings.
     6
     7        This patch moves window.open logic from V8 into the generic
     8        bindings so it could be shared with JSC. JSC sharing is not in
     9        this patch. This patch is of the same flavor/intent as 33201.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=41392
     12
     13        * bindings/generic/BindingDOMWindow.h:
     14        (WebCore::::createWindow):
     15        (WebCore::::open):
     16        (WebCore::::completeURL):
     17        * bindings/generic/BindingSecurity.h:
     18        (WebCore::::allowPopUp):
     19        (WebCore::::shouldAllowNavigation):
     20        * bindings/v8/V8Binding.h:
     21        (WebCore::V8Binding::emptyScriptValue):
     22        * bindings/v8/V8Utilities.cpp:
     23        (WebCore::transferHiddenDependency):
     24        (WebCore::processingUserGesture):
     25        (WebCore::shouldAllowNavigation):
     26        (WebCore::completeURL):
     27        * bindings/v8/custom/V8ArrayBufferCustom.cpp:
     28        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     29        (WebCore::V8DOMWindow::showModalDialogCallback):
     30        (WebCore::V8DOMWindow::openCallback):
     31        * bindings/v8/specialization/V8BindingState.cpp:
     32        (WebCore::::getActiveFrame):
     33        (WebCore::::getFirstFrame):
     34        (WebCore::::processingUserGesture):
     35        * bindings/v8/specialization/V8BindingState.h:
     36        (WebCore::):
     37
    1382010-08-09  Marcus Bulach  <bulach@chromium.org>
    239
  • trunk/WebCore/bindings/generic/BindingDOMWindow.h

    r60036 r64991  
    11/*
    22 * Copyright (C) 2010 Google Inc. All rights reserved.
    3  * 
     3 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  * 
     7 *
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    3232#define BindingDOMWindow_h
    3333
     34#include "DOMWindow.h"
    3435#include "Frame.h"
    3536#include "FrameLoadRequest.h"
     37#include "FrameLoader.h"
     38#include "FrameView.h"
    3639#include "GenericBinding.h"
    3740#include "Page.h"
     41#include "PlatformScreen.h"
     42#include "ScriptController.h"
    3843#include "SecurityOrigin.h"
     44#include "WindowFeatures.h"
    3945
    4046namespace WebCore {
     
    5359                               const WindowFeatures& windowFeatures,
    5460                               BindingValue dialogArgs);
     61
     62    static WebCore::DOMWindow* open(State<Binding>*,
     63                                    WebCore::DOMWindow* parent,
     64                                    const String& url,
     65                                    const String& frameName,
     66                                    const WindowFeatures& rawFeatures);
     67
     68    // FIXME: There should be a place for generic binding utilities.
     69    static KURL completeURL(State<Binding>*, const String& relativeURL);
     70
     71private:
     72    // Horizontal and vertical offset, from the parent content area,
     73    // around newly opened popups that don't specify a location.
     74    static const int popupTilePixels = 10;
    5575};
    5676
     
    104124    if (!protocolIsJavaScript(url) || BindingSecurity<Binding>::canAccessFrame(state, newFrame, true)) {
    105125        KURL completedUrl =
    106             url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(url);
    107         bool userGesture = processingUserGesture();
     126            url.isEmpty() ? KURL(ParsedURLString, "") : completeURL(state, url);
     127        bool userGesture = state->processingUserGesture();
    108128
    109129        if (created)
     
    116136}
    117137
     138template<class Binding>
     139WebCore::DOMWindow* BindingDOMWindow<Binding>::open(State<Binding>* state,
     140                                                    WebCore::DOMWindow* parent,
     141                                                    const String& urlString,
     142                                                    const String& frameName,
     143                                                    const WindowFeatures& rawFeatures)
     144{
     145    Frame* frame = parent->frame();
     146
     147    if (!BindingSecurity<Binding>::canAccessFrame(state, frame, true))
     148        return 0;
     149
     150    Frame* firstFrame = state->getFirstFrame();
     151    if (!firstFrame)
     152        return 0;
     153
     154    Frame* activeFrame = state->getActiveFrame();
     155    // We may not have a calling context if we are invoked by a plugin
     156    // via NPAPI.
     157    if (!activeFrame)
     158        activeFrame = firstFrame;
     159
     160    Page* page = frame->page();
     161    if (!page)
     162        return 0;
     163
     164    // Because FrameTree::find() returns true for empty strings, we must check
     165    // for empty framenames. Otherwise, illegitimate window.open() calls with
     166    // no name will pass right through the popup blocker.
     167    if (!BindingSecurity<Binding>::allowPopUp(state)
     168        && (frameName.isEmpty() || !frame->tree()->find(frameName))) {
     169        return 0;
     170    }
     171
     172    // Get the target frame for the special cases of _top and _parent.
     173    // In those cases, we can schedule a location change right now and
     174    // return early.
     175    bool topOrParent = false;
     176    if (frameName == "_top") {
     177        frame = frame->tree()->top();
     178        topOrParent = true;
     179    } else if (frameName == "_parent") {
     180        if (Frame* parent = frame->tree()->parent())
     181            frame = parent;
     182        topOrParent = true;
     183    }
     184    if (topOrParent) {
     185        if (!BindingSecurity<Binding>::shouldAllowNavigation(state, frame))
     186            return 0;
     187
     188        String completedUrl;
     189        if (!urlString.isEmpty())
     190            completedUrl = completeURL(state, urlString);
     191
     192        if (!completedUrl.isEmpty()
     193            && (!protocolIsJavaScript(completedUrl)
     194                || BindingSecurity<Binding>::canAccessFrame(state, frame, true))) {
     195            bool userGesture = state->processingUserGesture();
     196
     197            // For whatever reason, Firefox uses the first frame to determine
     198            // the outgoingReferrer.  We replicate that behavior here.
     199            String referrer = firstFrame->loader()->outgoingReferrer();
     200
     201            frame->redirectScheduler()->scheduleLocationChange(completedUrl, referrer, false, false, userGesture);
     202        }
     203        return frame->domWindow();
     204    }
     205
     206    // In the case of a named frame or a new window, we'll use the
     207    // createWindow() helper.
     208
     209    // Work with a copy of the parsed values so we can restore the
     210    // values we may not want to overwrite after we do the multiple
     211    // monitor fixes.
     212    WindowFeatures windowFeatures(rawFeatures);
     213    FloatRect screenRect = screenAvailableRect(page->mainFrame()->view());
     214
     215    // Set default size and location near parent window if none were specified.
     216    // These may be further modified by adjustWindowRect, below.
     217    if (!windowFeatures.xSet) {
     218        windowFeatures.x = parent->screenX() - screenRect.x() + popupTilePixels;
     219        windowFeatures.xSet = true;
     220    }
     221    if (!windowFeatures.ySet) {
     222        windowFeatures.y = parent->screenY() - screenRect.y() + popupTilePixels;
     223        windowFeatures.ySet = true;
     224    }
     225    if (!windowFeatures.widthSet) {
     226        windowFeatures.width = parent->innerWidth();
     227        windowFeatures.widthSet = true;
     228    }
     229    if (!windowFeatures.heightSet) {
     230        windowFeatures.height = parent->innerHeight();
     231        windowFeatures.heightSet = true;
     232    }
     233
     234    FloatRect windowRect(windowFeatures.x, windowFeatures.y, windowFeatures.width, windowFeatures.height);
     235
     236    // The new window's location is relative to its current screen, so shift
     237    // it in case it's on a secondary monitor. See http://b/viewIssue?id=967905.
     238    windowRect.move(screenRect.x(), screenRect.y());
     239    WebCore::DOMWindow::adjustWindowRect(screenRect, windowRect, windowRect);
     240
     241    windowFeatures.x = windowRect.x();
     242    windowFeatures.y = windowRect.y();
     243    windowFeatures.height = windowRect.height();
     244    windowFeatures.width = windowRect.width();
     245
     246    // If either of the origin coordinates or dimensions weren't set
     247    // in the original string, make sure they aren't set now.
     248    if (!rawFeatures.xSet) {
     249        windowFeatures.x = 0;
     250        windowFeatures.xSet = false;
     251    }
     252    if (!rawFeatures.ySet) {
     253        windowFeatures.y = 0;
     254        windowFeatures.ySet = false;
     255    }
     256    if (!rawFeatures.widthSet) {
     257      windowFeatures.width = 0;
     258      windowFeatures.widthSet = false;
     259    }
     260    if (!rawFeatures.heightSet) {
     261      windowFeatures.height = 0;
     262      windowFeatures.heightSet = false;
     263    }
     264
     265    frame = createWindow(state, activeFrame, firstFrame, frame, urlString, frameName, windowFeatures, Binding::emptyScriptValue());
     266
     267    if (!frame)
     268        return 0;
     269
     270    return frame->domWindow();
     271}
     272
     273template <class Binding>
     274KURL BindingDOMWindow<Binding>::completeURL(State<Binding>* state,
     275                                            const String& relativeURL)
     276{
     277    // For historical reasons, we need to complete the URL using the
     278    // dynamic frame.
     279    Frame* frame = state->getFirstFrame();
     280    if (!frame)
     281        return KURL();
     282    return frame->loader()->completeURL(relativeURL);
     283}
     284
    118285} // namespace WebCore
    119286
  • trunk/WebCore/bindings/generic/BindingSecurity.h

    r61094 r64991  
    3535#include "CSSHelper.h"
    3636#include "Element.h"
     37#include "Frame.h"
    3738#include "GenericBinding.h"
    3839#include "HTMLFrameElementBase.h"
    3940#include "HTMLNames.h"
     41#include "Settings.h"
    4042
    4143namespace WebCore {
    4244
    4345class DOMWindow;
    44 class Frame;
    4546class Node;
    4647
     
    5657    static bool checkNodeSecurity(State<Binding>*, Node* target);
    5758
     59    static bool allowPopUp(State<Binding>*);
    5860    static bool allowSettingFrameSrcToJavascriptUrl(State<Binding>*, HTMLFrameElementBase*, String value);
    5961    static bool allowSettingSrcToJavascriptURL(State<Binding>*, Element*, String name, String value);
     62
     63    static bool shouldAllowNavigation(State<Binding>*, Frame*);
    6064
    6165private:
     
    111115
    112116template <class Binding>
     117bool BindingSecurity<Binding>::allowPopUp(State<Binding>* state)
     118{
     119    if (state->processingUserGesture())
     120        return true;
     121
     122    Frame* frame = state->getFirstFrame();
     123    ASSERT(frame);
     124    Settings* settings = frame->settings();
     125    return settings && settings->javaScriptCanOpenWindowsAutomatically();
     126}
     127
     128template <class Binding>
    113129bool BindingSecurity<Binding>::allowSettingFrameSrcToJavascriptUrl(State<Binding>* state, HTMLFrameElementBase* frame, String value)
    114130{
     
    129145}
    130146
     147template <class Binding>
     148bool BindingSecurity<Binding>::shouldAllowNavigation(State<Binding>* state, Frame* frame)
     149{
     150    Frame* activeFrame = state->getActiveFrame();
     151    return activeFrame && activeFrame->loader()->shouldAllowNavigation(frame);
     152}
     153
    131154}
    132155
  • trunk/WebCore/bindings/v8/V8Binding.h

    r64840 r64991  
    11/*
    22* Copyright (C) 2009 Google Inc. All rights reserved.
    3 * 
     3*
    44* Redistribution and use in source and binary forms, with or without
    55* modification, are permitted provided that the following conditions are
    66* met:
    7 * 
     7*
    88*     * Redistributions of source code must retain the above copyright
    99* notice, this list of conditions and the following disclaimer.
     
    1515* contributors may be used to endorse or promote products derived from
    1616* this software without specific prior written permission.
    17 * 
     17*
    1818* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    4141
    4242namespace WebCore {
    43    
     43
    4444    class EventListener;
    4545    class EventTarget;
     
    5151        typedef v8::Handle<v8::Value> Value;
    5252        typedef V8BindingDOMWindow DOMWindow;
     53
     54        static Value emptyScriptValue() { return v8::Local<v8::Value>(); }
    5355    };
    5456    typedef BindingSecurity<V8Binding> V8BindingSecurity;
     
    153155        return v8ValueToWebCoreString(object);
    154156    }
    155    
     157
    156158    String toWebCoreString(const v8::Arguments&, int index);
    157159
     
    172174
    173175    String toWebCoreStringWithNullOrUndefinedCheck(v8::Handle<v8::Value> value);
    174  
     176
    175177    v8::Handle<v8::String> v8UndetectableString(const String& str);
    176178
     
    184186
    185187    v8::Handle<v8::Value> v8DateOrNull(double value);
    186    
     188
    187189    v8::Persistent<v8::FunctionTemplate> createRawTemplate();
    188190
    189191    struct BatchedAttribute;
    190192    struct BatchedCallback;
    191    
     193
    192194    v8::Local<v8::Signature> configureTemplate(v8::Persistent<v8::FunctionTemplate>,
    193195                                               const char* interfaceName,
    194196                                               v8::Persistent<v8::FunctionTemplate> parentClass,
    195197                                               int fieldCount,
    196                                                const BatchedAttribute*, 
     198                                               const BatchedAttribute*,
    197199                                               size_t attributeCount,
    198200                                               const BatchedCallback*,
    199201                                               size_t callbackCount);
    200    
     202
    201203    v8::Handle<v8::Value> getElementStringAttr(const v8::AccessorInfo&,
    202204                                               const QualifiedName&);
     
    205207                              v8::Local<v8::Value>);
    206208
    207    
     209
    208210    v8::Persistent<v8::String> getToStringName();
    209211    v8::Persistent<v8::FunctionTemplate> getToStringTemplate();
    210    
     212
    211213    // V8Parameter is an adapter class that converts V8 values to Strings
    212214    // or AtomicStrings as appropriate, using multiple typecast operators.
     
    225227        v8::Local<v8::Value> m_v8Object;
    226228    };
    227    
     229
    228230    template<> inline V8Parameter<DefaultMode>::operator String() { return toWebCoreString(m_v8Object); }
    229231    template<> inline V8Parameter<WithNullCheck>::operator String() { return toWebCoreStringWithNullCheck(m_v8Object); }
  • trunk/WebCore/bindings/v8/V8Utilities.cpp

    r62868 r64991  
    3939#include "ScriptState.h"
    4040#include "V8Binding.h"
     41#include "V8BindingDOMWindow.h" // FIXME: remove when completeURL moves
     42#include "V8BindingState.h"
    4143#include "V8Proxy.h"
    4244#include "WorkerContext.h"
     
    9395        createHiddenDependency(object, newValue, cacheIndex);
    9496}
    95    
    9697
    9798bool processingUserGesture()
    9899{
    99     Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
    100     return frame && frame->script()->processingUserGesture();
     100    return V8BindingState::Only()->processingUserGesture();
    101101}
    102102
    103103Frame* callingOrEnteredFrame()
    104104{
    105     Frame* frame = V8Proxy::retrieveFrameForCallingContext();
    106     if (!frame) {
    107         // Unfortunately, when processing script from a plug-in, we might not
    108         // have a calling context.  In those cases, we fall back to the
    109         // entered context for security checks.
    110         // FIXME: We need a better API for retrieving frames that abstracts
    111         //        away this concern.
    112         frame = V8Proxy::retrieveFrameForEnteredContext();
    113     }
    114     return frame;
     105    return V8BindingState::Only()->getActiveFrame();
    115106}
    116107
    117108bool shouldAllowNavigation(Frame* frame)
    118109{
    119     Frame* callingOrEntered = callingOrEnteredFrame();
    120     return callingOrEntered && callingOrEntered->loader()->shouldAllowNavigation(frame);
     110    return V8BindingSecurity::shouldAllowNavigation(V8BindingState::Only(), frame);
    121111}
    122112
    123113KURL completeURL(const String& relativeURL)
    124114{
    125     // For histoical reasons, we need to complete the URL using the dynamic frame.
    126     Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
    127     if (!frame)
    128         return KURL();
    129     return frame->loader()->completeURL(relativeURL);
     115    return V8BindingDOMWindow::completeURL(V8BindingState::Only(), relativeURL);
    130116}
    131117
  • trunk/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp

    r61339 r64991  
    3535#include "ArrayBuffer.h"
    3636
     37#include "ExceptionCode.h"
    3738#include "V8Binding.h"
    3839#include "V8ArrayBuffer.h"
  • trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r64840 r64991  
    8383#include "WindowFeatures.h"
    8484
    85 // Horizontal and vertical offset, from the parent content area, around newly
    86 // opened popups that don't specify a location.
    87 static const int popupTilePixels = 10;
    88 
    8985namespace WebCore {
    9086
     
    448444        return false;
    449445    return frame->page()->chrome()->canRunModalNow();
    450 }
    451 
    452 static bool allowPopUp()
    453 {
    454     Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
    455 
    456     ASSERT(frame);
    457     if (frame->script()->processingUserGesture())
    458         return true;
    459     Settings* settings = frame->settings();
    460     return settings && settings->javaScriptCanOpenWindowsAutomatically();
    461446}
    462447
     
    514499        return v8::Undefined();
    515500
    516     if (!canShowModalDialogNow(frame) || !allowPopUp())
     501    if (!canShowModalDialogNow(frame) || !V8BindingSecurity::allowPopUp(V8BindingState::Only()))
    517502        return v8::Undefined();
    518503
     
    585570    INC_STATS("DOM.DOMWindow.open()");
    586571
     572    DOMWindow* parent = V8DOMWindow::toNative(args.Holder());
    587573    String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]);
    588574    AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1]));
    589 
    590     DOMWindow* parent = V8DOMWindow::toNative(args.Holder());
    591     Frame* frame = parent->frame();
    592 
    593     if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), frame, true))
    594         return v8::Undefined();
    595 
    596     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
    597     if (!enteredFrame)
    598         return v8::Undefined();
    599 
    600     Frame* callingFrame = V8Proxy::retrieveFrameForCallingContext();
    601     // We may not have a calling context if we are invoked by a plugin via NPAPI.
    602     if (!callingFrame)
    603         callingFrame = enteredFrame;
    604 
    605     Page* page = frame->page();
    606     if (!page)
    607         return v8::Undefined();
    608 
    609     // Because FrameTree::find() returns true for empty strings, we must check
    610     // for empty framenames. Otherwise, illegitimate window.open() calls with
    611     // no name will pass right through the popup blocker.
    612     if (!allowPopUp() &&
    613         (frameName.isEmpty() || !frame->tree()->find(frameName))) {
    614         return v8::Undefined();
    615     }
    616 
    617     // Get the target frame for the special cases of _top and _parent.  In those
    618     // cases, we can schedule a location change right now and return early.
    619     bool topOrParent = false;
    620     if (frameName == "_top") {
    621         frame = frame->tree()->top();
    622         topOrParent = true;
    623     } else if (frameName == "_parent") {
    624         if (Frame* parent = frame->tree()->parent())
    625             frame = parent;
    626         topOrParent = true;
    627     }
    628     if (topOrParent) {
    629         if (!shouldAllowNavigation(frame))
    630             return v8::Undefined();
    631 
    632         String completedUrl;
    633         if (!urlString.isEmpty())
    634             completedUrl = completeURL(urlString);
    635 
    636         if (!completedUrl.isEmpty() &&
    637             (!protocolIsJavaScript(completedUrl) || ScriptController::isSafeScript(frame))) {
    638             bool userGesture = processingUserGesture();
    639 
    640             // For whatever reason, Firefox uses the entered frame to determine
    641             // the outgoingReferrer.  We replicate that behavior here.
    642             String referrer = enteredFrame->loader()->outgoingReferrer();
    643 
    644             frame->redirectScheduler()->scheduleLocationChange(completedUrl, referrer, false, false, userGesture);
    645         }
    646         return toV8(frame->domWindow());
    647     }
    648 
    649     // In the case of a named frame or a new window, we'll use the
    650     // createWindow() helper.
    651 
    652     // Parse the values, and then work with a copy of the parsed values
    653     // so we can restore the values we may not want to overwrite after
    654     // we do the multiple monitor fixes.
    655575    WindowFeatures rawFeatures(toWebCoreStringWithNullOrUndefinedCheck(args[2]));
    656     WindowFeatures windowFeatures(rawFeatures);
    657     FloatRect screenRect = screenAvailableRect(page->mainFrame()->view());
    658 
    659     // Set default size and location near parent window if none were specified.
    660     // These may be further modified by adjustWindowRect, below.
    661     if (!windowFeatures.xSet) {
    662         windowFeatures.x = parent->screenX() - screenRect.x() + popupTilePixels;
    663         windowFeatures.xSet = true;
    664     }
    665     if (!windowFeatures.ySet) {
    666         windowFeatures.y = parent->screenY() - screenRect.y() + popupTilePixels;
    667         windowFeatures.ySet = true;
    668     }
    669     if (!windowFeatures.widthSet) {
    670         windowFeatures.width = parent->innerWidth();
    671         windowFeatures.widthSet = true;
    672     }
    673     if (!windowFeatures.heightSet) {
    674         windowFeatures.height = parent->innerHeight();
    675         windowFeatures.heightSet = true;
    676     }
    677 
    678     FloatRect windowRect(windowFeatures.x, windowFeatures.y, windowFeatures.width, windowFeatures.height);
    679 
    680     // The new window's location is relative to its current screen, so shift
    681     // it in case it's on a secondary monitor. See http://b/viewIssue?id=967905.
    682     windowRect.move(screenRect.x(), screenRect.y());
    683     WebCore::DOMWindow::adjustWindowRect(screenRect, windowRect, windowRect);
    684 
    685     windowFeatures.x = windowRect.x();
    686     windowFeatures.y = windowRect.y();
    687     windowFeatures.height = windowRect.height();
    688     windowFeatures.width = windowRect.width();
    689 
    690     // If either of the origin coordinates or dimensions weren't set in the original
    691     // string, make sure they aren't set now.
    692     if (!rawFeatures.xSet) {
    693         windowFeatures.x = 0;
    694         windowFeatures.xSet = false;
    695     }
    696     if (!rawFeatures.ySet) {
    697         windowFeatures.y = 0;
    698         windowFeatures.ySet = false;
    699     }
    700     if (!rawFeatures.widthSet) {
    701       windowFeatures.width = 0;
    702       windowFeatures.widthSet = false;
    703     }
    704     if (!rawFeatures.heightSet) {
    705       windowFeatures.height = 0;
    706       windowFeatures.heightSet = false;
    707     }
    708 
    709     frame = V8BindingDOMWindow::createWindow(V8BindingState::Only(), callingFrame, enteredFrame, frame, urlString, frameName, windowFeatures, v8::Local<v8::Value>());
    710 
    711     if (!frame)
    712         return v8::Undefined();
    713 
    714     return toV8(frame->domWindow());
     576    DOMWindow* child = V8BindingDOMWindow::open(V8BindingState::Only(), parent, urlString, frameName, rawFeatures);
     577
     578    if (!child)
     579        return v8::Undefined();
     580
     581    return toV8(child);
    715582}
    716583
  • trunk/WebCore/bindings/v8/specialization/V8BindingState.cpp

    r52810 r64991  
    11/*
    22 * Copyright (C) 2009 Google Inc. All rights reserved.
    3  * 
     3 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  * 
     7 *
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    3232#include "V8BindingState.h"
    3333
     34#include "Frame.h"
     35#include "ScriptController.h"
    3436#include "V8Proxy.h"
    3537#include <wtf/StdLibExtras.h>
     
    5456}
    5557
     58Frame* State<V8Binding>::getActiveFrame()
     59{
     60    Frame* frame = V8Proxy::retrieveFrameForCallingContext();
     61    if (!frame) {
     62        // Unfortunately, when processing script from a plug-in, we might not
     63        // have a calling context.  In those cases, we fall back to the
     64        // entered context for security checks.
     65        // FIXME: We need a better API for retrieving frames that abstracts
     66        //        away this concern.
     67        frame = V8Proxy::retrieveFrameForEnteredContext();
     68    }
     69    return frame;
     70}
     71
     72Frame* State<V8Binding>::getFirstFrame()
     73{
     74    return V8Proxy::retrieveFrameForEnteredContext();
     75}
     76
    5677void State<V8Binding>::immediatelyReportUnsafeAccessTo(Frame* target)
    5778{
     
    5980}
    6081
     82bool State<V8Binding>::processingUserGesture()
     83{
     84    Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
     85    return frame && frame->script()->processingUserGesture();
     86}
     87
    6188} // namespace WebCore
  • trunk/WebCore/bindings/v8/specialization/V8BindingState.h

    r52810 r64991  
    11/*
    22 * Copyright (C) 2009 Google Inc. All rights reserved.
    3  * 
     3 *
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are
    66 * met:
    7  * 
     7 *
    88 *     * Redistributions of source code must retain the above copyright
    99 * notice, this list of conditions and the following disclaimer.
     
    1515 * contributors may be used to endorse or promote products derived from
    1616 * this software without specific prior written permission.
    17  * 
     17 *
    1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    3737namespace WebCore {
    3838
     39class Frame;
     40
    3941// Singleton implementation of State<V8Binding>.  Uses V8's global data
    4042// structures to return information about relevant execution state.
     
    4547    static State* Only();
    4648
     49    // Reports an error message (without delay) if the security check fails.
     50    static void immediatelyReportUnsafeAccessTo(Frame*);
     51
    4752    // The DOMWindow corresponding to the 'calling context' of execution.
    4853    DOMWindow* getActiveWindow();
    4954
    50     // Reports an error message (without delay) if the security check fails.
    51     static void immediatelyReportUnsafeAccessTo(Frame*);
     55    // The frame corresponding to the 'calling context' of execution.
     56    Frame* getActiveFrame();
     57
     58    // The first frame in which execution entered user script.
     59    Frame* getFirstFrame();
     60
     61    bool processingUserGesture();
    5262
    5363private:
Note: See TracChangeset for help on using the changeset viewer.