Changeset 66770 in webkit
- Timestamp:
- Sep 3, 2010 2:11:48 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 16 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r66768 r66770 1 2010-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 1 53 2010-09-03 Dimitri Glazkov <dglazkov@chromium.org> 2 54 -
trunk/WebCore/GNUmakefile.am
r66736 r66770 10 10 -I$(srcdir)/WebCore/bindings/generic \ 11 11 -I$(srcdir)/WebCore/bindings/js \ 12 -I$(srcdir)/WebCore/bindings/js/specialization \ 12 13 -I$(srcdir)/WebCore/bindings/gobject \ 13 14 -I$(srcdir)/WebCore/bridge \ … … 624 625 WebCore/bindings/generic/ActiveDOMCallback.cpp \ 625 626 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 \ 626 633 WebCore/bindings/generic/RuntimeEnabledFeatures.cpp \ 627 634 WebCore/bindings/generic/RuntimeEnabledFeatures.h \ … … 797 804 WebCore/bindings/js/StringSourceProvider.h \ 798 805 WebCore/bindings/js/WebCoreJSClientData.h \ 806 WebCore/bindings/js/specialization/JSBindingState.cpp \ 807 WebCore/bindings/js/specialization/JSBindingState.h \ 799 808 WebCore/bindings/ScriptControllerBase.cpp \ 800 809 WebCore/bindings/ScriptControllerBase.h \ -
trunk/WebCore/WebCore.gypi
r66746 r66770 513 513 'bindings/generic/ActiveDOMCallback.h', 514 514 'bindings/generic/BindingDOMWindow.h', 515 'bindings/generic/BindingFrame.h', 516 'bindings/generic/BindingLocation.h', 515 517 'bindings/generic/BindingSecurity.h', 516 518 'bindings/generic/BindingSecurityBase.cpp', … … 532 534 'bindings/js/JSAudioConstructor.cpp', 533 535 'bindings/js/JSAudioConstructor.h', 536 'bindings/js/JSBinding.h', 534 537 'bindings/js/JSCanvasRenderingContextCustom.cpp', 535 538 'bindings/js/JSCanvasRenderingContext2DCustom.cpp', … … 711 714 'bindings/js/WorkerScriptController.cpp', 712 715 'bindings/js/WorkerScriptController.h', 716 'bindings/js/specialization/JSBindingState.cpp', 717 'bindings/js/specialization/JSBindingState.h', 713 718 'bindings/ScriptControllerBase.cpp', 714 719 'bindings/ScriptControllerBase.h', -
trunk/WebCore/WebCore.pro
r66597 r66770 185 185 $$PWD/bindings/generic \ 186 186 $$PWD/bindings/js \ 187 $$PWD/bindings/js/specialization \ 187 188 $$PWD/bridge \ 188 189 $$PWD/bridge/c \ … … 393 394 bindings/js/ScheduledAction.cpp \ 394 395 bindings/js/SerializedScriptValue.cpp \ 396 bindings/js/specialization/JSBindingState.cpp \ 395 397 bindings/ScriptControllerBase.cpp \ 396 398 bridge/IdentifierRep.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r66739 r66770 41968 41968 > 41969 41969 </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> 41970 41994 </Filter> 41971 41995 <Filter … … 42325 42349 </File> 42326 42350 <File 42351 RelativePath="..\bindings\js\JSBinding.h" 42352 > 42353 </File> 42354 <File 42327 42355 RelativePath="..\bindings\js\JSBindingsAllInOne.cpp" 42328 42356 > … … 49618 49646 <File 49619 49647 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" 49620 49704 > 49621 49705 </File> -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r66586 r66770 2838 2838 A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; }; 2839 2839 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 */; }; 2840 2849 A718760E0B2A120100A16ECE /* DragActions.h in Headers */ = {isa = PBXBuildFile; fileRef = A718760D0B2A120100A16ECE /* DragActions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2841 2850 A71878900B2D04AC00A16ECE /* DragControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */; }; … … 8708 8717 A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCocoa.h; path = cocoa/KeyEventCocoa.h; sourceTree = "<group>"; }; 8709 8718 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>"; }; 8710 8728 A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = "<group>"; }; 8711 8729 A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragControllerMac.mm; sourceTree = "<group>"; }; … … 14453 14471 sourceTree = "<group>"; 14454 14472 }; 14473 A622A8EF122C444500A785B3 /* specialization */ = { 14474 isa = PBXGroup; 14475 children = ( 14476 A622A8F0122C444500A785B3 /* JSBindingState.cpp */, 14477 A622A8F1122C444500A785B3 /* JSBindingState.h */, 14478 ); 14479 path = specialization; 14480 sourceTree = "<group>"; 14481 }; 14455 14482 A75E8B7F0E1DE2B0007F2481 /* filters */ = { 14456 14483 isa = PBXGroup; … … 16070 16097 B5D31DF811CF610B009F22B4 /* ActiveDOMCallback.cpp */, 16071 16098 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 */, 16072 16105 ); 16073 16106 name = generic; … … 16109 16142 BCCE58B41061E925008FB35A /* Constructors */, 16110 16143 BC4EDEF70C08F414007EDD49 /* Custom */, 16144 A622A8EF122C444500A785B3 /* specialization */, 16111 16145 14DFB33F0A7DF7630018F769 /* Derived Sources */, 16112 16146 BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */, … … 16122 16156 1C81BA030E97348300266E07 /* JavaScriptCallFrame.cpp */, 16123 16157 1C81BA040E97348300266E07 /* JavaScriptCallFrame.h */, 16158 A622A8ED122C442A00A785B3 /* JSBinding.h */, 16124 16159 BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */, 16125 16160 BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */, … … 20433 20468 898785F1122E1E87003AABDA /* JSFileException.h in Headers */, 20434 20469 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 */, 20435 20477 ); 20436 20478 runOnlyForDeploymentPostprocessing = 0; … … 22896 22938 898785F0122E1E87003AABDA /* JSFileException.cpp in Sources */, 22897 22939 898785F4122E1EAC003AABDA /* JSFileReaderSync.cpp in Sources */, 22940 A622A8F2122C444500A785B3 /* JSBindingState.cpp in Sources */, 22941 A622A8FC122C44A600A785B3 /* BindingSecurityBase.cpp in Sources */, 22898 22942 ); 22899 22943 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/generic/BindingDOMWindow.h
r65164 r66770 66 66 const WindowFeatures& rawFeatures); 67 67 68 // FIXME: There should be a place for generic binding utilities.69 static KURL completeURL(State<Binding>*, const String& relativeURL);70 71 68 private: 72 69 // Horizontal and vertical offset, from the parent content area, … … 269 266 } 270 267 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 the276 // dynamic frame.277 Frame* frame = state->getFirstFrame();278 if (!frame)279 return KURL();280 return frame->loader()->completeURL(relativeURL);281 }282 283 268 } // namespace WebCore 284 269 -
trunk/WebCore/bindings/generic/BindingFrame.h
r66769 r66770 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.3 * 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 29 29 */ 30 30 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" 33 36 34 37 namespace WebCore { 35 38 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. 39 template <class Binding> 40 class BindingFrame { 41 public: 42 static void navigateIfAllowed(State<Binding>*, Frame*, const KURL&, bool lockHistory, bool lockBackForwardList); 48 43 }; 49 44 45 template <class Binding> 46 void 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()); 50 53 } 51 54 52 #endif // GenericBinding_h 55 } // namespace WebCore 56 57 #endif // BindingFrame_h -
trunk/WebCore/bindings/generic/BindingLocation.h
r66769 r66770 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.3 * 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 29 29 */ 30 30 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" 33 37 34 38 namespace WebCore { 35 39 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 template <class Binding> 41 class BindingLocation { 42 public: 43 static void replace(State<Binding>*, Location*, const String& url); 48 44 }; 49 45 46 template <class Binding> 47 void 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); 50 61 } 51 62 52 #endif // GenericBinding_h 63 } // namespace WebCore 64 65 #endif // BindingLocation_h -
trunk/WebCore/bindings/generic/GenericBinding.h
r52810 r66770 32 32 #define GenericBinding_h 33 33 34 #include "Frame.h" 35 #include "FrameLoader.h" 36 34 37 namespace WebCore { 35 38 … … 48 51 }; 49 52 53 template <class Binding> 54 KURL 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 50 64 } 51 65 -
trunk/WebCore/bindings/js/JSBinding.h
r66769 r66770 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.3 * 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 29 29 */ 30 30 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" 33 37 34 38 namespace WebCore { 35 39 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. 41 class JSBinding { 42 public: 43 typedef BindingFrame<JSBinding> Frame; 44 typedef BindingLocation<JSBinding> Location; 48 45 }; 49 46 50 } 47 typedef BindingSecurity<JSBinding> JSBindingSecurity; 51 48 52 #endif // GenericBinding_h 49 } // namespace WebCore 50 51 #endif // JSBinding_h -
trunk/WebCore/bindings/js/JSBindingsAllInOne.cpp
r65005 r66770 31 31 #include "JSAttrCustom.cpp" 32 32 #include "JSAudioConstructor.cpp" 33 #include "JSBindingState.cpp" 33 34 #include "JSCDATASectionCustom.cpp" 34 35 #include "JSCSSRuleCustom.cpp" -
trunk/WebCore/bindings/js/JSDOMBinding.cpp
r65104 r66770 39 39 #include "HTMLNames.h" 40 40 #include "HTMLScriptElement.h" 41 #include "JSBinding.h" 42 #include "JSBindingState.h" 41 43 #include "JSDOMCoreException.h" 42 44 #include "JSDOMWindowCustom.h" … … 44 46 #include "JSEventException.h" 45 47 #include "JSExceptionBase.h" 48 #include "JSMainThreadExecState.h" 46 49 #include "JSNode.h" 47 50 #include "JSRangeException.h" … … 640 643 bool shouldAllowNavigation(ExecState* exec, Frame* frame) 641 644 { 642 Frame* lexicalFrame = toLexicalFrame(exec);643 return lexicalFrame && lexicalFrame->loader()->shouldAllowNavigation(frame);645 JSBindingState state(exec); 646 return JSBindingSecurity::shouldAllowNavigation(&state, frame); 644 647 } 645 648 … … 672 675 Frame* toLexicalFrame(ExecState* exec) 673 676 { 674 return asJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame();677 return JSBindingState(exec).getActiveFrame(); 675 678 } 676 679 677 680 Frame* toDynamicFrame(ExecState* exec) 678 681 { 679 return asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame();682 return JSBindingState(exec).getFirstFrame(); 680 683 } 681 684 682 685 bool processingUserGesture() 683 686 { 684 return ScriptController::processingUserGesture();687 return JSBindingState(JSMainThreadExecState::currentState()).processingUserGesture(); 685 688 } 686 689 687 690 KURL completeURL(ExecState* exec, const String& relativeURL) 688 691 { 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); 694 694 } 695 695 -
trunk/WebCore/bindings/js/JSLocationCustom.cpp
r65177 r66770 28 28 #include "Frame.h" 29 29 #include "FrameLoader.h" 30 #include "JSBinding.h" 31 #include "JSBindingState.h" 30 32 #include "JSDOMBinding.h" 31 33 #include "JSDOMWindowCustom.h" … … 187 189 static void navigateIfAllowed(ExecState* exec, Frame* frame, const KURL& url, bool lockHistory, bool lockBackForwardList) 188 190 { 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); 195 193 } 196 194 … … 304 302 JSValue JSLocation::replace(ExecState* exec) 305 303 { 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))); 318 306 return jsUndefined(); 319 307 } -
trunk/WebCore/bindings/js/specialization/JSBindingState.cpp
r66769 r66770 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.3 * 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 29 29 */ 30 30 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" 33 38 34 39 namespace WebCore { 35 40 36 // Used to instantiate binding templates for any methods shared among all 37 // language bindings. 38 class GenericBinding {}; 41 class Frame; 39 42 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 43 Frame* State<JSBinding>::getActiveFrame() 44 { 45 return asJSDOMWindow(m_exec->lexicalGlobalObject())->impl()->frame(); 50 46 } 51 47 52 #endif // GenericBinding_h 48 Frame* State<JSBinding>::getFirstFrame() 49 { 50 return asJSDOMWindow(m_exec->dynamicGlobalObject())->impl()->frame(); 51 } 52 53 bool State<JSBinding>::processingUserGesture() 54 { 55 return ScriptController::processingUserGesture(); 56 } 57 58 bool 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 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.3 * 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 5 * modification, are permitted provided that the following conditions are 6 6 * met: 7 * 7 * 8 8 * * Redistributions of source code must retain the above copyright 9 9 * notice, this list of conditions and the following disclaimer. … … 15 15 * contributors may be used to endorse or promote products derived from 16 16 * this software without specific prior written permission. 17 * 17 * 18 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT … … 29 29 */ 30 30 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 37 namespace JSC { 38 39 class ExecState; 40 41 } // namespace JSC 33 42 34 43 namespace WebCore { 35 44 36 // Used to instantiate binding templates for any methods shared among all 37 // language bindings. 38 class GenericBinding {}; 45 class Frame; 39 46 40 // Class to represent execution state for each language binding. 41 template <class T> 42 class State {}; 47 template <> 48 class State<JSBinding> : public State<GenericBinding> { 49 public: 50 explicit State(JSC::ExecState* exec) 51 : m_exec(exec) 52 { 53 } 43 54 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 67 private: 68 JSC::ExecState* m_exec; 48 69 }; 49 70 50 } 71 typedef State<JSBinding> JSBindingState; 51 72 52 #endif // GenericBinding_h 73 } // namespace WebCore 74 75 #endif // JSBindingState_h -
trunk/WebCore/bindings/v8/V8Binding.h
r66521 r66770 32 32 #define V8Binding_h 33 33 34 #include "BindingFrame.h" 35 #include "BindingLocation.h" 34 36 #include "BindingSecurity.h" 35 37 #include "MathExtras.h" … … 51 53 typedef v8::Handle<v8::Value> Value; 52 54 typedef V8BindingDOMWindow DOMWindow; 55 typedef BindingFrame<V8Binding> Frame; 56 typedef BindingLocation<V8Binding> Location; 53 57 54 58 static Value emptyScriptValue() { return v8::Local<v8::Value>(); } 55 59 }; 56 60 typedef BindingSecurity<V8Binding> V8BindingSecurity; 57 61 58 62 enum ExternalMode { 59 63 Externalize, 60 64 DoNotExternalize 61 65 }; 62 66 63 67 template <typename StringType> 64 68 StringType v8StringToWebCoreString(v8::Handle<v8::String> v8String, ExternalMode external); -
trunk/WebCore/bindings/v8/V8Utilities.cpp
r64991 r66770 39 39 #include "ScriptState.h" 40 40 #include "V8Binding.h" 41 #include "V8BindingDOMWindow.h" // FIXME: remove when completeURL moves42 41 #include "V8BindingState.h" 43 42 #include "V8Proxy.h" … … 113 112 KURL completeURL(const String& relativeURL) 114 113 { 115 return V8BindingDOMWindow::completeURL(V8BindingState::Only(), relativeURL);114 return completeURL(V8BindingState::Only(), relativeURL); 116 115 } 117 116 118 117 void navigateIfAllowed(Frame* frame, const KURL& url, bool lockHistory, bool lockBackForwardList) 119 118 { 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); 125 120 } 126 121 -
trunk/WebCore/bindings/v8/custom/V8LocationCustom.cpp
r57004 r66770 293 293 v8::Handle<v8::Object> holder = args.Holder(); 294 294 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])); 308 296 return v8::Undefined(); 309 297 } … … 379 367 380 368 } // namespace WebCore 381 -
trunk/WebCore/bindings/v8/specialization/V8BindingState.cpp
r65082 r66770 85 85 } 86 86 87 bool State<V8Binding>::allowsAccessFromFrame(Frame* frame) 88 { 89 return ScriptController::isSafeScript(frame); 90 } 91 87 92 } // namespace WebCore -
trunk/WebCore/bindings/v8/specialization/V8BindingState.h
r64991 r66770 61 61 bool processingUserGesture(); 62 62 63 // FIXME: This should be shared in BindingSecurity 64 bool allowsAccessFromFrame(Frame*); 65 63 66 private: 64 67 explicit State() {}
Note: See TracChangeset
for help on using the changeset viewer.