Changeset 66770 in webkit


Ignore:
Timestamp:
Sep 3, 2010 2:11:48 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

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

Reviewed by Adam Barth.

Moves location.replace bindings logic into bindings/generic and
instantiates it for JSC and V8.

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

Covered by existing location.replace tests.

  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/generic/BindingDOMWindow.h: (WebCore::::createWindow): (WebCore::::open):
  • bindings/generic/BindingFrame.h: Added. (WebCore::::navigateIfAllowed):
  • bindings/generic/BindingLocation.h: Added. (WebCore::::replace):
  • bindings/generic/GenericBinding.h: (WebCore::completeURL):
  • bindings/js/JSBinding.h: Added.
  • bindings/js/JSBindingsAllInOne.cpp:
  • bindings/js/JSDOMBinding.cpp: (WebCore::shouldAllowNavigation): (WebCore::toLexicalFrame): (WebCore::toDynamicFrame): (WebCore::processingUserGesture): (WebCore::completeURL):
  • bindings/js/JSLocationCustom.cpp: (WebCore::navigateIfAllowed): (WebCore::JSLocation::replace):
  • bindings/js/specialization/JSBindingState.cpp: Added. (WebCore::::getActiveFrame): (WebCore::::getFirstFrame): (WebCore::::processingUserGesture): (WebCore::::allowsAccessFromFrame):
  • bindings/js/specialization/JSBindingState.h: Added.
  • bindings/v8/V8Binding.h:
  • bindings/v8/V8Utilities.cpp: (WebCore::completeURL): (WebCore::navigateIfAllowed):
  • bindings/v8/custom/V8LocationCustom.cpp: (WebCore::V8Location::replaceCallback):
  • bindings/v8/specialization/V8BindingState.cpp: (WebCore::::allowsAccessFromFrame):
  • bindings/v8/specialization/V8BindingState.h:
Location:
trunk/WebCore
Files:
1 added
16 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66768 r66770  
     12010-09-03  Dominic Cooney  <dominicc@google.com>
     2
     3        Reviewed by Adam Barth.
     4
     5        Moves location.replace bindings logic into bindings/generic and
     6        instantiates it for JSC and V8.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=44891
     9
     10        Covered by existing location.replace tests.
     11
     12        * GNUmakefile.am:
     13        * WebCore.gypi:
     14        * WebCore.pro:
     15        * WebCore.vcproj/WebCore.vcproj:
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * bindings/generic/BindingDOMWindow.h:
     18        (WebCore::::createWindow):
     19        (WebCore::::open):
     20        * bindings/generic/BindingFrame.h: Added.
     21        (WebCore::::navigateIfAllowed):
     22        * bindings/generic/BindingLocation.h: Added.
     23        (WebCore::::replace):
     24        * bindings/generic/GenericBinding.h:
     25        (WebCore::completeURL):
     26        * bindings/js/JSBinding.h: Added.
     27        * bindings/js/JSBindingsAllInOne.cpp:
     28        * bindings/js/JSDOMBinding.cpp:
     29        (WebCore::shouldAllowNavigation):
     30        (WebCore::toLexicalFrame):
     31        (WebCore::toDynamicFrame):
     32        (WebCore::processingUserGesture):
     33        (WebCore::completeURL):
     34        * bindings/js/JSLocationCustom.cpp:
     35        (WebCore::navigateIfAllowed):
     36        (WebCore::JSLocation::replace):
     37        * bindings/js/specialization/JSBindingState.cpp: Added.
     38        (WebCore::::getActiveFrame):
     39        (WebCore::::getFirstFrame):
     40        (WebCore::::processingUserGesture):
     41        (WebCore::::allowsAccessFromFrame):
     42        * bindings/js/specialization/JSBindingState.h: Added.
     43        * bindings/v8/V8Binding.h:
     44        * bindings/v8/V8Utilities.cpp:
     45        (WebCore::completeURL):
     46        (WebCore::navigateIfAllowed):
     47        * bindings/v8/custom/V8LocationCustom.cpp:
     48        (WebCore::V8Location::replaceCallback):
     49        * bindings/v8/specialization/V8BindingState.cpp:
     50        (WebCore::::allowsAccessFromFrame):
     51        * bindings/v8/specialization/V8BindingState.h:
     52
    1532010-09-03  Dimitri Glazkov  <dglazkov@chromium.org>
    254
  • trunk/WebCore/GNUmakefile.am

    r66736 r66770  
    1010        -I$(srcdir)/WebCore/bindings/generic \
    1111        -I$(srcdir)/WebCore/bindings/js \
     12        -I$(srcdir)/WebCore/bindings/js/specialization \
    1213        -I$(srcdir)/WebCore/bindings/gobject \
    1314        -I$(srcdir)/WebCore/bridge \
     
    624625        WebCore/bindings/generic/ActiveDOMCallback.cpp \
    625626        WebCore/bindings/generic/ActiveDOMCallback.h \
     627        WebCore/bindings/generic/BindingFrame.h \
     628        WebCore/bindings/generic/BindingLocation.h \
     629        WebCore/bindings/generic/BindingSecurity.h \
     630        WebCore/bindings/generic/BindingSecurityBase.cpp \
     631        WebCore/bindings/generic/BindingSecurityBase.h \
     632        WebCore/bindings/generic/GenericBinding.h \
    626633        WebCore/bindings/generic/RuntimeEnabledFeatures.cpp \
    627634        WebCore/bindings/generic/RuntimeEnabledFeatures.h \
     
    797804        WebCore/bindings/js/StringSourceProvider.h \
    798805        WebCore/bindings/js/WebCoreJSClientData.h \
     806        WebCore/bindings/js/specialization/JSBindingState.cpp \
     807        WebCore/bindings/js/specialization/JSBindingState.h \
    799808        WebCore/bindings/ScriptControllerBase.cpp \
    800809        WebCore/bindings/ScriptControllerBase.h \
  • trunk/WebCore/WebCore.gypi

    r66746 r66770  
    513513            'bindings/generic/ActiveDOMCallback.h',
    514514            'bindings/generic/BindingDOMWindow.h',
     515            'bindings/generic/BindingFrame.h',
     516            'bindings/generic/BindingLocation.h',
    515517            'bindings/generic/BindingSecurity.h',
    516518            'bindings/generic/BindingSecurityBase.cpp',
     
    532534            'bindings/js/JSAudioConstructor.cpp',
    533535            'bindings/js/JSAudioConstructor.h',
     536            'bindings/js/JSBinding.h',
    534537            'bindings/js/JSCanvasRenderingContextCustom.cpp',
    535538            'bindings/js/JSCanvasRenderingContext2DCustom.cpp',
     
    711714            'bindings/js/WorkerScriptController.cpp',
    712715            'bindings/js/WorkerScriptController.h',
     716            'bindings/js/specialization/JSBindingState.cpp',
     717            'bindings/js/specialization/JSBindingState.h',
    713718            'bindings/ScriptControllerBase.cpp',
    714719            'bindings/ScriptControllerBase.h',
  • trunk/WebCore/WebCore.pro

    r66597 r66770  
    185185    $$PWD/bindings/generic \
    186186    $$PWD/bindings/js \
     187    $$PWD/bindings/js/specialization \
    187188    $$PWD/bridge \
    188189    $$PWD/bridge/c \
     
    393394    bindings/js/ScheduledAction.cpp \
    394395    bindings/js/SerializedScriptValue.cpp \
     396    bindings/js/specialization/JSBindingState.cpp \
    395397    bindings/ScriptControllerBase.cpp \
    396398    bridge/IdentifierRep.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r66739 r66770  
    4196841968                                        >
    4196941969                                </File>
     41970                                <File
     41971                                        RelativePath="..\bindings\generic\BindingFrame.h"
     41972                                        >
     41973                                </File>
     41974                                <File
     41975                                        RelativePath="..\bindings\generic\BindingLocation.h"
     41976                                        >
     41977                                </File>
     41978                                <File
     41979                                        RelativePath="..\bindings\generic\BindingSecurity.h"
     41980                                        >
     41981                                </File>
     41982                                <File
     41983                                        RelativePath="..\bindings\generic\BindingSecurityBase.cpp"
     41984                                        >
     41985                                </File>
     41986                                <File
     41987                                        RelativePath="..\bindings\generic\BindingSecurityBase.h"
     41988                                        >
     41989                                </File>
     41990                                <File
     41991                                        RelativePath="..\bindings\generic\GenericBinding.h"
     41992                                        >
     41993                                </File>
    4197041994                        </Filter>
    4197141995                        <Filter
     
    4232542349                                </File>
    4232642350                                <File
     42351                                        RelativePath="..\bindings\js\JSBinding.h"
     42352                                        >
     42353                                </File>
     42354                                <File
    4232742355                                        RelativePath="..\bindings\js\JSBindingsAllInOne.cpp"
    4232842356                                        >
     
    4961849646                                <File
    4961949647                                        RelativePath="..\bindings\js\WorkerScriptController.h"
     49648                                        >
     49649                                </File>
     49650                                <File
     49651                                        RelativePath="..\bindings\js\specialization\JSBindingState.cpp"
     49652                                        >
     49653                                        <FileConfiguration
     49654                                                Name="Debug|Win32"
     49655                                                ExcludedFromBuild="true"
     49656                                                >
     49657                                                <Tool
     49658                                                        Name="VCCLCompilerTool"
     49659                                                />
     49660                                        </FileConfiguration>
     49661                                        <FileConfiguration
     49662                                                Name="Release|Win32"
     49663                                                ExcludedFromBuild="true"
     49664                                                >
     49665                                                <Tool
     49666                                                        Name="VCCLCompilerTool"
     49667                                                />
     49668                                        </FileConfiguration>
     49669                                        <FileConfiguration
     49670                                                Name="Debug_Internal|Win32"
     49671                                                ExcludedFromBuild="true"
     49672                                                >
     49673                                                <Tool
     49674                                                        Name="VCCLCompilerTool"
     49675                                                />
     49676                                        </FileConfiguration>
     49677                                        <FileConfiguration
     49678                                                Name="Debug_Cairo|Win32"
     49679                                                ExcludedFromBuild="true"
     49680                                                >
     49681                                                <Tool
     49682                                                        Name="VCCLCompilerTool"
     49683                                                />
     49684                                        </FileConfiguration>
     49685                                        <FileConfiguration
     49686                                                Name="Release_Cairo|Win32"
     49687                                                ExcludedFromBuild="true"
     49688                                                >
     49689                                                <Tool
     49690                                                        Name="VCCLCompilerTool"
     49691                                                />
     49692                                        </FileConfiguration>
     49693                                        <FileConfiguration
     49694                                                Name="Debug_All|Win32"
     49695                                                ExcludedFromBuild="true"
     49696                                                >
     49697                                                <Tool
     49698                                                        Name="VCCLCompilerTool"
     49699                                                />
     49700                                        </FileConfiguration>
     49701                                </File>
     49702                                <File
     49703                                        RelativePath="..\bindings\js\specialization\JSBindingState.h"
    4962049704                                        >
    4962149705                                </File>
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r66586 r66770  
    28382838                A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; };
    28392839                A5AFB350115151A700B045CB /* StepRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AFB34E115151A700B045CB /* StepRange.h */; };
     2840                A622A8EE122C442A00A785B3 /* JSBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8ED122C442A00A785B3 /* JSBinding.h */; };
     2841                A622A8F2122C444500A785B3 /* JSBindingState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A622A8F0122C444500A785B3 /* JSBindingState.cpp */; };
     2842                A622A8F3122C444500A785B3 /* JSBindingState.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F1122C444500A785B3 /* JSBindingState.h */; };
     2843                A622A8FA122C44A600A785B3 /* BindingLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F4122C44A600A785B3 /* BindingLocation.h */; };
     2844                A622A8FB122C44A600A785B3 /* BindingSecurity.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F5122C44A600A785B3 /* BindingSecurity.h */; };
     2845                A622A8FC122C44A600A785B3 /* BindingSecurityBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A622A8F6122C44A600A785B3 /* BindingSecurityBase.cpp */; };
     2846                A622A8FD122C44A600A785B3 /* BindingSecurityBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F7122C44A600A785B3 /* BindingSecurityBase.h */; };
     2847                A622A8FE122C44A600A785B3 /* BindingUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F8122C44A600A785B3 /* BindingUtilities.h */; };
     2848                A622A8FF122C44A600A785B3 /* GenericBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F9122C44A600A785B3 /* GenericBinding.h */; };
    28402849                A718760E0B2A120100A16ECE /* DragActions.h in Headers */ = {isa = PBXBuildFile; fileRef = A718760D0B2A120100A16ECE /* DragActions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    28412850                A71878900B2D04AC00A16ECE /* DragControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */; };
     
    87088717                A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCocoa.h; path = cocoa/KeyEventCocoa.h; sourceTree = "<group>"; };
    87098718                A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyEventCocoa.mm; path = cocoa/KeyEventCocoa.mm; sourceTree = "<group>"; };
     8719                A622A8ED122C442A00A785B3 /* JSBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBinding.h; sourceTree = "<group>"; };
     8720                A622A8F0122C444500A785B3 /* JSBindingState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBindingState.cpp; sourceTree = "<group>"; };
     8721                A622A8F1122C444500A785B3 /* JSBindingState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBindingState.h; sourceTree = "<group>"; };
     8722                A622A8F4122C44A600A785B3 /* BindingLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindingLocation.h; path = generic/BindingLocation.h; sourceTree = "<group>"; };
     8723                A622A8F5122C44A600A785B3 /* BindingSecurity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindingSecurity.h; path = generic/BindingSecurity.h; sourceTree = "<group>"; };
     8724                A622A8F6122C44A600A785B3 /* BindingSecurityBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BindingSecurityBase.cpp; path = generic/BindingSecurityBase.cpp; sourceTree = "<group>"; };
     8725                A622A8F7122C44A600A785B3 /* BindingSecurityBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindingSecurityBase.h; path = generic/BindingSecurityBase.h; sourceTree = "<group>"; };
     8726                A622A8F8122C44A600A785B3 /* BindingUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindingUtilities.h; path = generic/BindingUtilities.h; sourceTree = "<group>"; };
     8727                A622A8F9122C44A600A785B3 /* GenericBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GenericBinding.h; path = generic/GenericBinding.h; sourceTree = "<group>"; };
    87108728                A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = "<group>"; };
    87118729                A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragControllerMac.mm; sourceTree = "<group>"; };
     
    1445314471                        sourceTree = "<group>";
    1445414472                };
     14473                A622A8EF122C444500A785B3 /* specialization */ = {
     14474                        isa = PBXGroup;
     14475                        children = (
     14476                                A622A8F0122C444500A785B3 /* JSBindingState.cpp */,
     14477                                A622A8F1122C444500A785B3 /* JSBindingState.h */,
     14478                        );
     14479                        path = specialization;
     14480                        sourceTree = "<group>";
     14481                };
    1445514482                A75E8B7F0E1DE2B0007F2481 /* filters */ = {
    1445614483                        isa = PBXGroup;
     
    1607016097                                B5D31DF811CF610B009F22B4 /* ActiveDOMCallback.cpp */,
    1607116098                                B5D31DF911CF610B009F22B4 /* ActiveDOMCallback.h */,
     16099                                A622A8F4122C44A600A785B3 /* BindingLocation.h */,
     16100                                A622A8F5122C44A600A785B3 /* BindingSecurity.h */,
     16101                                A622A8F6122C44A600A785B3 /* BindingSecurityBase.cpp */,
     16102                                A622A8F7122C44A600A785B3 /* BindingSecurityBase.h */,
     16103                                A622A8F8122C44A600A785B3 /* BindingUtilities.h */,
     16104                                A622A8F9122C44A600A785B3 /* GenericBinding.h */,
    1607216105                        );
    1607316106                        name = generic;
     
    1610916142                                BCCE58B41061E925008FB35A /* Constructors */,
    1611016143                                BC4EDEF70C08F414007EDD49 /* Custom */,
     16144                                A622A8EF122C444500A785B3 /* specialization */,
    1611116145                                14DFB33F0A7DF7630018F769 /* Derived Sources */,
    1611216146                                BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */,
     
    1612216156                                1C81BA030E97348300266E07 /* JavaScriptCallFrame.cpp */,
    1612316157                                1C81BA040E97348300266E07 /* JavaScriptCallFrame.h */,
     16158                                A622A8ED122C442A00A785B3 /* JSBinding.h */,
    1612416159                                BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */,
    1612516160                                BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */,
     
    2043320468                                898785F1122E1E87003AABDA /* JSFileException.h in Headers */,
    2043420469                                898785F5122E1EAC003AABDA /* JSFileReaderSync.h in Headers */,
     20470                                A622A8EE122C442A00A785B3 /* JSBinding.h in Headers */,
     20471                                A622A8F3122C444500A785B3 /* JSBindingState.h in Headers */,
     20472                                A622A8FA122C44A600A785B3 /* BindingLocation.h in Headers */,
     20473                                A622A8FB122C44A600A785B3 /* BindingSecurity.h in Headers */,
     20474                                A622A8FD122C44A600A785B3 /* BindingSecurityBase.h in Headers */,
     20475                                A622A8FE122C44A600A785B3 /* BindingUtilities.h in Headers */,
     20476                                A622A8FF122C44A600A785B3 /* GenericBinding.h in Headers */,
    2043520477                        );
    2043620478                        runOnlyForDeploymentPostprocessing = 0;
     
    2289622938                                898785F0122E1E87003AABDA /* JSFileException.cpp in Sources */,
    2289722939                                898785F4122E1EAC003AABDA /* JSFileReaderSync.cpp in Sources */,
     22940                                A622A8F2122C444500A785B3 /* JSBindingState.cpp in Sources */,
     22941                                A622A8FC122C44A600A785B3 /* BindingSecurityBase.cpp in Sources */,
    2289822942                        );
    2289922943                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/generic/BindingDOMWindow.h

    r65164 r66770  
    6666                                    const WindowFeatures& rawFeatures);
    6767
    68     // FIXME: There should be a place for generic binding utilities.
    69     static KURL completeURL(State<Binding>*, const String& relativeURL);
    70 
    7168private:
    7269    // Horizontal and vertical offset, from the parent content area,
     
    269266}
    270267
    271 template <class Binding>
    272 KURL BindingDOMWindow<Binding>::completeURL(State<Binding>* state,
    273                                             const String& relativeURL)
    274 {
    275     // For historical reasons, we need to complete the URL using the
    276     // dynamic frame.
    277     Frame* frame = state->getFirstFrame();
    278     if (!frame)
    279         return KURL();
    280     return frame->loader()->completeURL(relativeURL);
    281 }
    282 
    283268} // namespace WebCore
    284269
  • trunk/WebCore/bindings/generic/BindingFrame.h

    r66769 r66770  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
    3  * 
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
     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
     
    2929 */
    3030
    31 #ifndef GenericBinding_h
    32 #define GenericBinding_h
     31#ifndef BindingFrame_h
     32#define BindingFrame_h
     33
     34#include "Frame.h"
     35#include "GenericBinding.h"
    3336
    3437namespace WebCore {
    3538
    36 // Used to instantiate binding templates for any methods shared among all
    37 // language bindings.
    38 class GenericBinding {};
    39 
    40 // Class to represent execution state for each language binding.
    41 template <class T>
    42 class State {};
    43 
    44 // Common notion of execution state for language bindings.
    45 template <>
    46 class State<GenericBinding> {
    47     // Any methods shared across bindings can go here.
     39template <class Binding>
     40class BindingFrame {
     41public:
     42    static void navigateIfAllowed(State<Binding>*, Frame*, const KURL&, bool lockHistory, bool lockBackForwardList);
    4843};
    4944
     45template <class Binding>
     46void BindingFrame<Binding>::navigateIfAllowed(State<Binding>* state, Frame* frame, const KURL& url, bool lockHistory, bool lockBackForwardList)
     47{
     48    Frame* activeFrame = state->getActiveFrame();
     49    if (!activeFrame)
     50        return;
     51    if (!protocolIsJavaScript(url) || state->allowsAccessFromFrame(frame))
     52        frame->redirectScheduler()->scheduleLocationChange(url.string(), activeFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, state->processingUserGesture());
    5053}
    5154
    52 #endif // GenericBinding_h
     55} // namespace WebCore
     56
     57#endif // BindingFrame_h
  • trunk/WebCore/bindings/generic/BindingLocation.h

    r66769 r66770  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
    3  * 
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
     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
     
    2929 */
    3030
    31 #ifndef GenericBinding_h
    32 #define GenericBinding_h
     31#ifndef BindingLocation_h
     32#define BindingLocation_h
     33
     34#include "BindingSecurity.h"
     35#include "GenericBinding.h"
     36#include "Location.h"
    3337
    3438namespace WebCore {
    3539
    36 // Used to instantiate binding templates for any methods shared among all
    37 // language bindings.
    38 class GenericBinding {};
    39 
    40 // Class to represent execution state for each language binding.
    41 template <class T>
    42 class State {};
    43 
    44 // Common notion of execution state for language bindings.
    45 template <>
    46 class State<GenericBinding> {
    47     // Any methods shared across bindings can go here.
     40template <class Binding>
     41class BindingLocation {
     42public:
     43    static void replace(State<Binding>*, Location*, const String& url);
    4844};
    4945
     46template <class Binding>
     47void BindingLocation<Binding>::replace(State<Binding>* state, Location* location, const String& url)
     48{
     49    Frame* frame = location->frame();
     50    if (!frame)
     51        return;
     52
     53    KURL fullURL = completeURL(state, url);
     54    if (fullURL.isNull())
     55        return;
     56
     57    if (!BindingSecurity<Binding>::shouldAllowNavigation(state, frame))
     58        return;
     59
     60    Binding::Frame::navigateIfAllowed(state, frame, fullURL, true, true);
    5061}
    5162
    52 #endif // GenericBinding_h
     63} // namespace WebCore
     64
     65#endif // BindingLocation_h
  • trunk/WebCore/bindings/generic/GenericBinding.h

    r52810 r66770  
    3232#define GenericBinding_h
    3333
     34#include "Frame.h"
     35#include "FrameLoader.h"
     36
    3437namespace WebCore {
    3538
     
    4851};
    4952
     53template <class Binding>
     54KURL completeURL(State<Binding>* state, const String& relativeURL)
     55{
     56    // For historical reasons, we need to complete the URL using the
     57    // dynamic frame.
     58    Frame* frame = state->getFirstFrame();
     59    if (!frame)
     60        return KURL();
     61    return frame->loader()->completeURL(relativeURL);
     62}
     63
    5064}
    5165
  • trunk/WebCore/bindings/js/JSBinding.h

    r66769 r66770  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
    3  * 
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
     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
     
    2929 */
    3030
    31 #ifndef GenericBinding_h
    32 #define GenericBinding_h
     31#ifndef JSBinding_h
     32#define JSBinding_h
     33
     34#include "BindingFrame.h"
     35#include "BindingLocation.h"
     36#include "BindingSecurity.h"
    3337
    3438namespace WebCore {
    3539
    36 // Used to instantiate binding templates for any methods shared among all
    37 // language bindings.
    38 class GenericBinding {};
    39 
    40 // Class to represent execution state for each language binding.
    41 template <class T>
    42 class State {};
    43 
    44 // Common notion of execution state for language bindings.
    45 template <>
    46 class State<GenericBinding> {
    47     // Any methods shared across bindings can go here.
     40// Instantiate binding template classes for JSC.
     41class JSBinding {
     42public:
     43    typedef BindingFrame<JSBinding> Frame;
     44    typedef BindingLocation<JSBinding> Location;
    4845};
    4946
    50 }
     47typedef BindingSecurity<JSBinding> JSBindingSecurity;
    5148
    52 #endif // GenericBinding_h
     49} // namespace WebCore
     50
     51#endif // JSBinding_h
  • trunk/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r65005 r66770  
    3131#include "JSAttrCustom.cpp"
    3232#include "JSAudioConstructor.cpp"
     33#include "JSBindingState.cpp"
    3334#include "JSCDATASectionCustom.cpp"
    3435#include "JSCSSRuleCustom.cpp"
  • trunk/WebCore/bindings/js/JSDOMBinding.cpp

    r65104 r66770  
    3939#include "HTMLNames.h"
    4040#include "HTMLScriptElement.h"
     41#include "JSBinding.h"
     42#include "JSBindingState.h"
    4143#include "JSDOMCoreException.h"
    4244#include "JSDOMWindowCustom.h"
     
    4446#include "JSEventException.h"
    4547#include "JSExceptionBase.h"
     48#include "JSMainThreadExecState.h"
    4649#include "JSNode.h"
    4750#include "JSRangeException.h"
     
    640643bool shouldAllowNavigation(ExecState* exec, Frame* frame)
    641644{
    642     Frame* lexicalFrame = toLexicalFrame(exec);
    643     return lexicalFrame && lexicalFrame->loader()->shouldAllowNavigation(frame);
     645    JSBindingState state(exec);
     646    return JSBindingSecurity::shouldAllowNavigation(&state, frame);
    644647}
    645648
     
    672675Frame* toLexicalFrame(ExecState* exec)
    673676{
    674     return asJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame();
     677    return JSBindingState(exec).getActiveFrame();
    675678}
    676679
    677680Frame* toDynamicFrame(ExecState* exec)
    678681{
    679     return asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame();
     682    return JSBindingState(exec).getFirstFrame();
    680683}
    681684
    682685bool processingUserGesture()
    683686{
    684     return ScriptController::processingUserGesture();
     687    return JSBindingState(JSMainThreadExecState::currentState()).processingUserGesture();
    685688}
    686689
    687690KURL completeURL(ExecState* exec, const String& relativeURL)
    688691{
    689     // For historical reasons, we need to complete the URL using the dynamic frame.
    690     Frame* frame = toDynamicFrame(exec);
    691     if (!frame)
    692         return KURL();
    693     return frame->loader()->completeURL(relativeURL);
     692    JSBindingState state(exec);
     693    return completeURL(&state, relativeURL);
    694694}
    695695
  • trunk/WebCore/bindings/js/JSLocationCustom.cpp

    r65177 r66770  
    2828#include "Frame.h"
    2929#include "FrameLoader.h"
     30#include "JSBinding.h"
     31#include "JSBindingState.h"
    3032#include "JSDOMBinding.h"
    3133#include "JSDOMWindowCustom.h"
     
    187189static void navigateIfAllowed(ExecState* exec, Frame* frame, const KURL& url, bool lockHistory, bool lockBackForwardList)
    188190{
    189     Frame* lexicalFrame = toLexicalFrame(exec);
    190     if (!lexicalFrame)
    191         return;
    192 
    193     if (!protocolIsJavaScript(url) || allowsAccessFromFrame(exec, frame))
    194         frame->redirectScheduler()->scheduleLocationChange(url.string(), lexicalFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture());
     191    JSBindingState state(exec);
     192    JSBinding::Frame::navigateIfAllowed(&state, frame, url, lockHistory, lockBackForwardList);
    195193}
    196194
     
    304302JSValue JSLocation::replace(ExecState* exec)
    305303{
    306     Frame* frame = impl()->frame();
    307     if (!frame)
    308         return jsUndefined();
    309 
    310     KURL url = completeURL(exec, ustringToString(exec->argument(0).toString(exec)));
    311     if (url.isNull())
    312         return jsUndefined();
    313 
    314     if (!shouldAllowNavigation(exec, frame))
    315         return jsUndefined();
    316 
    317     navigateIfAllowed(exec, frame, url, true, true);
     304    JSBindingState state(exec);
     305    JSBinding::Location::replace(&state, impl(), ustringToString(exec->argument(0).toString(exec)));
    318306    return jsUndefined();
    319307}
  • trunk/WebCore/bindings/js/specialization/JSBindingState.cpp

    r66769 r66770  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
    3  * 
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
     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
     
    2929 */
    3030
    31 #ifndef GenericBinding_h
    32 #define GenericBinding_h
     31#include "config.h"
     32#include "JSBindingState.h"
     33
     34#include "DOMWindow.h"
     35#include "JSDOMWindow.h"
     36#include "JSDOMWindowCustom.h"
     37#include "ScriptController.h"
    3338
    3439namespace WebCore {
    3540
    36 // Used to instantiate binding templates for any methods shared among all
    37 // language bindings.
    38 class GenericBinding {};
     41class Frame;
    3942
    40 // Class to represent execution state for each language binding.
    41 template <class T>
    42 class State {};
    43 
    44 // Common notion of execution state for language bindings.
    45 template <>
    46 class State<GenericBinding> {
    47     // Any methods shared across bindings can go here.
    48 };
    49 
     43Frame* State<JSBinding>::getActiveFrame()
     44{
     45    return asJSDOMWindow(m_exec->lexicalGlobalObject())->impl()->frame();
    5046}
    5147
    52 #endif // GenericBinding_h
     48Frame* State<JSBinding>::getFirstFrame()
     49{
     50    return asJSDOMWindow(m_exec->dynamicGlobalObject())->impl()->frame();
     51}
     52
     53bool State<JSBinding>::processingUserGesture()
     54{
     55    return ScriptController::processingUserGesture();
     56}
     57
     58bool State<JSBinding>::allowsAccessFromFrame(Frame* frame)
     59{
     60    return WebCore::allowsAccessFromFrame(m_exec, frame);
     61}
     62
     63} // namespace WebCore
  • trunk/WebCore/bindings/js/specialization/JSBindingState.h

    r66769 r66770  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
    3  * 
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
     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
     
    2929 */
    3030
    31 #ifndef GenericBinding_h
    32 #define GenericBinding_h
     31#ifndef JSBindingState_h
     32#define JSBindingState_h
     33
     34#include "GenericBinding.h"
     35#include "JSBinding.h"
     36
     37namespace JSC {
     38
     39class ExecState;
     40
     41} // namespace JSC
    3342
    3443namespace WebCore {
    3544
    36 // Used to instantiate binding templates for any methods shared among all
    37 // language bindings.
    38 class GenericBinding {};
     45class Frame;
    3946
    40 // Class to represent execution state for each language binding.
    41 template <class T>
    42 class State {};
     47template <>
     48class State<JSBinding> : public State<GenericBinding> {
     49public:
     50    explicit State(JSC::ExecState* exec)
     51        : m_exec(exec)
     52    {
     53    }
    4354
    44 // Common notion of execution state for language bindings.
    45 template <>
    46 class State<GenericBinding> {
    47     // Any methods shared across bindings can go here.
     55    virtual ~State()
     56    {
     57    }
     58
     59    Frame* getActiveFrame();
     60    Frame* getFirstFrame();
     61
     62    bool processingUserGesture();
     63
     64    // FIXME: This should be shared in BindingSecurity
     65    bool allowsAccessFromFrame(Frame*);
     66
     67private:
     68    JSC::ExecState* m_exec;
    4869};
    4970
    50 }
     71typedef State<JSBinding> JSBindingState;
    5172
    52 #endif // GenericBinding_h
     73} // namespace WebCore
     74
     75#endif // JSBindingState_h
  • trunk/WebCore/bindings/v8/V8Binding.h

    r66521 r66770  
    3232#define V8Binding_h
    3333
     34#include "BindingFrame.h"
     35#include "BindingLocation.h"
    3436#include "BindingSecurity.h"
    3537#include "MathExtras.h"
     
    5153        typedef v8::Handle<v8::Value> Value;
    5254        typedef V8BindingDOMWindow DOMWindow;
     55        typedef BindingFrame<V8Binding> Frame;
     56        typedef BindingLocation<V8Binding> Location;
    5357
    5458        static Value emptyScriptValue() { return v8::Local<v8::Value>(); }
    5559    };
    5660    typedef BindingSecurity<V8Binding> V8BindingSecurity;
    57    
     61
    5862    enum ExternalMode {
    5963        Externalize,
    6064        DoNotExternalize
    6165    };
    62    
     66
    6367    template <typename StringType>
    6468    StringType v8StringToWebCoreString(v8::Handle<v8::String> v8String, ExternalMode external);
  • trunk/WebCore/bindings/v8/V8Utilities.cpp

    r64991 r66770  
    3939#include "ScriptState.h"
    4040#include "V8Binding.h"
    41 #include "V8BindingDOMWindow.h" // FIXME: remove when completeURL moves
    4241#include "V8BindingState.h"
    4342#include "V8Proxy.h"
     
    113112KURL completeURL(const String& relativeURL)
    114113{
    115     return V8BindingDOMWindow::completeURL(V8BindingState::Only(), relativeURL);
     114    return completeURL(V8BindingState::Only(), relativeURL);
    116115}
    117116
    118117void navigateIfAllowed(Frame* frame, const KURL& url, bool lockHistory, bool lockBackForwardList)
    119118{
    120     Frame* callingOrEntered = callingOrEnteredFrame();
    121     if (!callingOrEntered)
    122         return;
    123     if (!protocolIsJavaScript(url) || ScriptController::isSafeScript(frame))
    124         frame->redirectScheduler()->scheduleLocationChange(url.string(), callingOrEntered->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture());
     119    return V8Binding::Frame::navigateIfAllowed(V8BindingState::Only(), frame, url, lockHistory, lockBackForwardList);
    125120}
    126121
  • trunk/WebCore/bindings/v8/custom/V8LocationCustom.cpp

    r57004 r66770  
    293293    v8::Handle<v8::Object> holder = args.Holder();
    294294    Location* imp = V8Location::toNative(holder);
    295 
    296     Frame* frame = imp->frame();
    297     if (!frame)
    298         return v8::Undefined();
    299 
    300     KURL url = completeURL(toWebCoreString(args[0]));
    301     if (url.isNull())
    302         return v8::Undefined();
    303 
    304     if (!shouldAllowNavigation(frame))
    305         return v8::Undefined();
    306 
    307     navigateIfAllowed(frame, url, true, true);
     295    V8Binding::Location::replace(V8BindingState::Only(), imp, toWebCoreString(args[0]));
    308296    return v8::Undefined();
    309297}
     
    379367
    380368}  // namespace WebCore
    381 
  • trunk/WebCore/bindings/v8/specialization/V8BindingState.cpp

    r65082 r66770  
    8585}
    8686
     87bool State<V8Binding>::allowsAccessFromFrame(Frame* frame)
     88{
     89    return ScriptController::isSafeScript(frame);
     90}
     91
    8792} // namespace WebCore
  • trunk/WebCore/bindings/v8/specialization/V8BindingState.h

    r64991 r66770  
    6161    bool processingUserGesture();
    6262
     63    // FIXME: This should be shared in BindingSecurity
     64    bool allowsAccessFromFrame(Frame*);
     65
    6366private:
    6467    explicit State() {}
Note: See TracChangeset for help on using the changeset viewer.