[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

darin at apple.com darin at apple.com
Fri Jan 21 14:48:19 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 7fa6b382a06c736c0103e43947a6d7ec0a116319
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 30 19:27:28 2010 +0000

    2010-12-30  Darin Adler  <darin at apple.com>
    
            Reviewed by Adam Barth.
    
            Move security logic out of the JavaScript binding for location into the DOM class
            https://bugs.webkit.org/show_bug.cgi?id=51714
    
            * WebCore.xcodeproj/project.pbxproj: Removed JSBindingState.cpp, JSBindingState.h,
            and JSBinding.h. Later, we'll remove them from other project files and delete
            the source files.
    
            * bindings/js/JSBinding.h: Emptied out, marked for later deletion.
    
            * bindings/js/JSDOMBinding.cpp: Removed unused overload of the jsOwnedStringOrNull
            function, unused shouldAllowNavigation function, unused allowSettingSrcToJavascriptURL
            function, unused toLexicalFrame function, unused completeURL function, unused
            getCachedDOMStructure and cacheDOMStructure overloads, and unused
            getCachedDOMConstructor and cacheDOMConstruction functions.
            (WebCore::activeDOMWindow): Added.
            (WebCore::firstDOMWindow): Added.
            (WebCore::toDynamicFrame): Changed to use firstDOMWindow instead of calling through
            JSBindingState, since the latter is an unneeded abstraction.
            (WebCore::processingUserGesture): Changed to call ScriptController's function
            rather than calling through JSBindingState, which is an unneeded abstraction
    
            * bindings/js/JSDOMBinding.h: Removed the functions mentioned above. Added
            activeDOMWindow and firstDOMWindow. Also added a FIXME for the extremely poorly
            named allowsAccessFromFrame functions, which answer the question of whether
            script is allowed access *to* a frame.
    
            * bindings/js/JSDOMWindowCustom.cpp: Removed many unneeded includes.
            (WebCore::JSDOMWindow::setLocation): Streamlined by using the new
            activeDOMWindow and firstDOMWindow functions.
            (WebCore::JSDOMWindow::open): Ditto.
            (WebCore::JSDOMWindow::showModalDialog): Ditto.
            (WebCore::JSDOMWindow::postMessage): Ditto.
    
            * bindings/js/JSLocationCustom.cpp:
            (WebCore::JSLocation::setHref): Changed to pass the active and first windows through
            to the Location::setHref function, with it doing the rest of the work. This moves
            work out of the DOM binding that belongs in the DOM itself. Eventually such functions
            could even be automatically generated by the bindings script.
            (WebCore::JSLocation::setProtocol): Ditto.
            (WebCore::JSLocation::setHost): Ditto.
            (WebCore::JSLocation::setHostname): Ditto.
            (WebCore::JSLocation::setPort): Ditto.
            (WebCore::JSLocation::setPathname): Ditto.
            (WebCore::JSLocation::setSearch): Ditto.
            (WebCore::JSLocation::setHash): Ditto.
            (WebCore::JSLocation::replace): Ditto.
            (WebCore::JSLocation::reload): Ditto.
            (WebCore::JSLocation::assign): Ditto.
    
            * bindings/js/specialization/JSBindingState.cpp: Emptied out, marked for later deletion.
            * bindings/js/specialization/JSBindingState.h: Emptied out, marked for later deletion.
    
            * page/DOMWindow.cpp:
            (WebCore::DOMWindow::setLocation): Added a SetLocationLocking argument that allows us
            to use this function for Location::replace, which is the same as setLocation except that
            it locks both history and the back/forward list.
            * page/DOMWindow.h: Ditto.
    
            * page/Location.cpp:
            (WebCore::Location::setHref): Added. Uses DOMWindow::setLocation so that the security
            logic there does not have to be repeated or even refactored.
            (WebCore::Location::setProtocol): Ditto.
            (WebCore::Location::setHost): Ditto.
            (WebCore::Location::setHostname): Ditto.
            (WebCore::Location::setPort): Ditto.
            (WebCore::Location::setPathname): Ditto.
            (WebCore::Location::setSearch): Ditto.
            (WebCore::Location::setHash): Ditto.
            (WebCore::Location::assign): Ditto.
            (WebCore::Location::replace): Ditto.
            (WebCore::Location::reload): Added. Security logic was refactored from the code in
            JSLocationCustom.cpp. Added a FIXME about the fact that this security logic seems
            possibly unneeded.
    
            * page/Location.h: Fixed indentation on the whole file. Added the new functions above.
            (WebCore::Location::create):
            (WebCore::Location::frame):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74800 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 77d4c6b..f4d244b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,85 @@
+2010-12-30  Darin Adler  <darin at apple.com>
+
+        Reviewed by Adam Barth.
+
+        Move security logic out of the JavaScript binding for location into the DOM class
+        https://bugs.webkit.org/show_bug.cgi?id=51714
+
+        * WebCore.xcodeproj/project.pbxproj: Removed JSBindingState.cpp, JSBindingState.h,
+        and JSBinding.h. Later, we'll remove them from other project files and delete
+        the source files.
+
+        * bindings/js/JSBinding.h: Emptied out, marked for later deletion.
+
+        * bindings/js/JSDOMBinding.cpp: Removed unused overload of the jsOwnedStringOrNull
+        function, unused shouldAllowNavigation function, unused allowSettingSrcToJavascriptURL
+        function, unused toLexicalFrame function, unused completeURL function, unused
+        getCachedDOMStructure and cacheDOMStructure overloads, and unused
+        getCachedDOMConstructor and cacheDOMConstruction functions.
+        (WebCore::activeDOMWindow): Added.
+        (WebCore::firstDOMWindow): Added.
+        (WebCore::toDynamicFrame): Changed to use firstDOMWindow instead of calling through
+        JSBindingState, since the latter is an unneeded abstraction.
+        (WebCore::processingUserGesture): Changed to call ScriptController's function
+        rather than calling through JSBindingState, which is an unneeded abstraction
+
+        * bindings/js/JSDOMBinding.h: Removed the functions mentioned above. Added
+        activeDOMWindow and firstDOMWindow. Also added a FIXME for the extremely poorly
+        named allowsAccessFromFrame functions, which answer the question of whether
+        script is allowed access *to* a frame.
+
+        * bindings/js/JSDOMWindowCustom.cpp: Removed many unneeded includes.
+        (WebCore::JSDOMWindow::setLocation): Streamlined by using the new
+        activeDOMWindow and firstDOMWindow functions.
+        (WebCore::JSDOMWindow::open): Ditto.
+        (WebCore::JSDOMWindow::showModalDialog): Ditto.
+        (WebCore::JSDOMWindow::postMessage): Ditto.
+
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::JSLocation::setHref): Changed to pass the active and first windows through
+        to the Location::setHref function, with it doing the rest of the work. This moves
+        work out of the DOM binding that belongs in the DOM itself. Eventually such functions
+        could even be automatically generated by the bindings script.
+        (WebCore::JSLocation::setProtocol): Ditto.
+        (WebCore::JSLocation::setHost): Ditto.
+        (WebCore::JSLocation::setHostname): Ditto.
+        (WebCore::JSLocation::setPort): Ditto.
+        (WebCore::JSLocation::setPathname): Ditto.
+        (WebCore::JSLocation::setSearch): Ditto.
+        (WebCore::JSLocation::setHash): Ditto.
+        (WebCore::JSLocation::replace): Ditto.
+        (WebCore::JSLocation::reload): Ditto.
+        (WebCore::JSLocation::assign): Ditto.
+
+        * bindings/js/specialization/JSBindingState.cpp: Emptied out, marked for later deletion.
+        * bindings/js/specialization/JSBindingState.h: Emptied out, marked for later deletion.
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::setLocation): Added a SetLocationLocking argument that allows us
+        to use this function for Location::replace, which is the same as setLocation except that
+        it locks both history and the back/forward list.
+        * page/DOMWindow.h: Ditto.
+
+        * page/Location.cpp:
+        (WebCore::Location::setHref): Added. Uses DOMWindow::setLocation so that the security
+        logic there does not have to be repeated or even refactored.
+        (WebCore::Location::setProtocol): Ditto.
+        (WebCore::Location::setHost): Ditto.
+        (WebCore::Location::setHostname): Ditto.
+        (WebCore::Location::setPort): Ditto.
+        (WebCore::Location::setPathname): Ditto.
+        (WebCore::Location::setSearch): Ditto.
+        (WebCore::Location::setHash): Ditto.
+        (WebCore::Location::assign): Ditto.
+        (WebCore::Location::replace): Ditto.
+        (WebCore::Location::reload): Added. Security logic was refactored from the code in
+        JSLocationCustom.cpp. Added a FIXME about the fact that this security logic seems
+        possibly unneeded.
+
+        * page/Location.h: Fixed indentation on the whole file. Added the new functions above.
+        (WebCore::Location::create):
+        (WebCore::Location::frame):
+
 2010-12-30  Alexander Pavlov  <apavlov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index aa2ed82..1f8afcb 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -3090,9 +3090,6 @@
 		A59E3C1F11580F510072928E /* KeyEventIPhone.mm in Sources */ = {isa = PBXBuildFile; fileRef = A59E3C1D11580F510072928E /* KeyEventIPhone.mm */; };
 		A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; };
 		A5AFB350115151A700B045CB /* StepRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AFB34E115151A700B045CB /* StepRange.h */; };
-		A622A8EE122C442A00A785B3 /* JSBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8ED122C442A00A785B3 /* JSBinding.h */; };
-		A622A8F2122C444500A785B3 /* JSBindingState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A622A8F0122C444500A785B3 /* JSBindingState.cpp */; };
-		A622A8F3122C444500A785B3 /* JSBindingState.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F1122C444500A785B3 /* JSBindingState.h */; };
 		A622A8FA122C44A600A785B3 /* BindingLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F4122C44A600A785B3 /* BindingLocation.h */; };
 		A622A8FB122C44A600A785B3 /* BindingSecurity.h in Headers */ = {isa = PBXBuildFile; fileRef = A622A8F5122C44A600A785B3 /* BindingSecurity.h */; };
 		A622A8FC122C44A600A785B3 /* BindingSecurityBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A622A8F6122C44A600A785B3 /* BindingSecurityBase.cpp */; };
@@ -9422,9 +9419,6 @@
 		A5AFB34E115151A700B045CB /* StepRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StepRange.h; sourceTree = "<group>"; };
 		A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCocoa.h; path = cocoa/KeyEventCocoa.h; sourceTree = "<group>"; };
 		A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyEventCocoa.mm; path = cocoa/KeyEventCocoa.mm; sourceTree = "<group>"; };
-		A622A8ED122C442A00A785B3 /* JSBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBinding.h; sourceTree = "<group>"; };
-		A622A8F0122C444500A785B3 /* JSBindingState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBindingState.cpp; sourceTree = "<group>"; };
-		A622A8F1122C444500A785B3 /* JSBindingState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBindingState.h; sourceTree = "<group>"; };
 		A622A8F4122C44A600A785B3 /* BindingLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindingLocation.h; path = generic/BindingLocation.h; sourceTree = "<group>"; };
 		A622A8F5122C44A600A785B3 /* BindingSecurity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindingSecurity.h; path = generic/BindingSecurity.h; sourceTree = "<group>"; };
 		A622A8F6122C44A600A785B3 /* BindingSecurityBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BindingSecurityBase.cpp; path = generic/BindingSecurityBase.cpp; sourceTree = "<group>"; };
@@ -15737,15 +15731,6 @@
 			name = cocoa;
 			sourceTree = "<group>";
 		};
-		A622A8EF122C444500A785B3 /* specialization */ = {
-			isa = PBXGroup;
-			children = (
-				A622A8F0122C444500A785B3 /* JSBindingState.cpp */,
-				A622A8F1122C444500A785B3 /* JSBindingState.h */,
-			);
-			path = specialization;
-			sourceTree = "<group>";
-		};
 		A75E8B7F0E1DE2B0007F2481 /* filters */ = {
 			isa = PBXGroup;
 			children = (
@@ -17453,7 +17438,6 @@
 				BCCE58B41061E925008FB35A /* Constructors */,
 				BC4EDEF70C08F414007EDD49 /* Custom */,
 				14DFB33F0A7DF7630018F769 /* Derived Sources */,
-				A622A8EF122C444500A785B3 /* specialization */,
 				BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */,
 				93F8B3060A300FEA00F61AB8 /* CodeGeneratorJS.pm */,
 				BC53DA61114314BD000D817E /* DOMObjectHashTableMap.cpp */,
@@ -17466,7 +17450,6 @@
 				C585A66111D4FAC5004C3E4B /* IDBBindingUtilities.h */,
 				1C81BA030E97348300266E07 /* JavaScriptCallFrame.cpp */,
 				1C81BA040E97348300266E07 /* JavaScriptCallFrame.h */,
-				A622A8ED122C442A00A785B3 /* JSBinding.h */,
 				BC53DAC411432FD9000D817E /* JSDebugWrapperSet.cpp */,
 				BC53DAC111432EEE000D817E /* JSDebugWrapperSet.h */,
 				93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */,
@@ -20779,8 +20762,6 @@
 				BC124F000C26447A009E2349 /* JSBarInfo.h in Headers */,
 				BC946348107A936600857193 /* JSBeforeLoadEvent.h in Headers */,
 				51721FD311D27EF200638B42 /* JSBeforeProcessEvent.h in Headers */,
-				A622A8EE122C442A00A785B3 /* JSBinding.h in Headers */,
-				A622A8F3122C444500A785B3 /* JSBindingState.h in Headers */,
 				2E2D99CE10E2BBDA00496337 /* JSBlob.h in Headers */,
 				89CD029411C85B870070B791 /* JSBlobBuilder.h in Headers */,
 				1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */,
@@ -23500,7 +23481,6 @@
 				BC124EFF0C26447A009E2349 /* JSBarInfo.cpp in Sources */,
 				BC946346107A934B00857193 /* JSBeforeLoadEvent.cpp in Sources */,
 				51721FD211D27EF200638B42 /* JSBeforeProcessEvent.cpp in Sources */,
-				A622A8F2122C444500A785B3 /* JSBindingState.cpp in Sources */,
 				2E2D99CD10E2BBDA00496337 /* JSBlob.cpp in Sources */,
 				89CD029311C85B870070B791 /* JSBlobBuilder.cpp in Sources */,
 				1449E287107D4DB400B5793F /* JSCallbackData.cpp in Sources */,
diff --git a/WebCore/bindings/js/JSBinding.h b/WebCore/bindings/js/JSBinding.h
index b42c9be..40ae380 100644
--- a/WebCore/bindings/js/JSBinding.h
+++ b/WebCore/bindings/js/JSBinding.h
@@ -1,51 +1,2 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JSBinding_h
-#define JSBinding_h
-
-#include "BindingFrame.h"
-#include "BindingLocation.h"
-#include "BindingSecurity.h"
-
-namespace WebCore {
-
-// Instantiate binding template classes for JSC.
-class JSBinding {
-public:
-    typedef BindingFrame<JSBinding> Frame;
-    typedef BindingLocation<JSBinding> Location;
-};
-
-typedef BindingSecurity<JSBinding> JSBindingSecurity;
-
-} // namespace WebCore
-
-#endif // JSBinding_h
+// Once references to this file are removed from build files, this file should be deleted.
+#error
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp
index ed579d3..72c7cd6 100644
--- a/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/WebCore/bindings/js/JSDOMBinding.cpp
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2001 Harri Porten (porten at kde.org)
- *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  *  Copyright (C) 2007 Samuel Weinig <sam at webkit.org>
  *
  *  This library is free software; you can redistribute it and/or
@@ -39,8 +39,6 @@
 #include "HTMLNames.h"
 #include "HTMLScriptElement.h"
 #include "HTMLStyleElement.h"
-#include "JSBinding.h"
-#include "JSBindingState.h"
 #include "JSDOMCoreException.h"
 #include "JSDOMWindowCustom.h"
 #include "JSDebugWrapperSet.h"
@@ -490,13 +488,6 @@ JSValue jsOwnedStringOrNull(ExecState* exec, const String& s)
     return jsOwnedString(exec, stringToUString(s));
 }
 
-JSValue jsOwnedStringOrNull(ExecState* exec, const UString& s)
-{
-    if (s.isNull())
-        return jsNull();
-    return jsOwnedString(exec, s);
-}
-
 JSValue jsStringOrUndefined(ExecState* exec, const String& s)
 {
     if (s.isNull())
@@ -666,6 +657,16 @@ void setDOMException(ExecState* exec, ExceptionCode ec)
     throwError(exec, errorObject);
 }
 
+DOMWindow* activeDOMWindow(ExecState* exec)
+{
+    return asJSDOMWindow(exec->lexicalGlobalObject())->impl();
+}
+
+DOMWindow* firstDOMWindow(ExecState* exec)
+{
+    return asJSDOMWindow(exec->dynamicGlobalObject())->impl();
+}
+
 bool checkNodeSecurity(ExecState* exec, Node* node)
 {
     return node && allowsAccessFromFrame(exec, node->document()->frame());
@@ -687,22 +688,6 @@ bool allowsAccessFromFrame(ExecState* exec, Frame* frame, String& message)
     return window && window->allowsAccessFrom(exec, message);
 }
 
-bool shouldAllowNavigation(ExecState* exec, Frame* frame)
-{
-    JSBindingState state(exec);
-    return JSBindingSecurity::shouldAllowNavigation(&state, frame);
-}
-
-bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* element, const String& name, const String& value)
-{
-    if ((element->hasTagName(iframeTag) || element->hasTagName(frameTag)) && equalIgnoringCase(name, "src") && protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value))) {
-          Document* contentDocument = static_cast<HTMLFrameElementBase*>(element)->contentDocument();
-          if (contentDocument && !checkNodeSecurity(exec, contentDocument))
-              return false;
-      }
-      return true;
-}
-
 void printErrorMessageForFrame(Frame* frame, const String& message)
 {
     if (!frame)
@@ -710,25 +695,16 @@ void printErrorMessageForFrame(Frame* frame, const String& message)
     frame->domWindow()->printErrorMessage(message);
 }
 
-Frame* toLexicalFrame(ExecState* exec)
-{
-    return JSBindingState(exec).activeFrame();
-}
-
+// FIXME: We should remove or at least deprecate this function. Callers can use firstDOMWindow directly.
 Frame* toDynamicFrame(ExecState* exec)
 {
-    return JSBindingState(exec).firstFrame();
+    return firstDOMWindow(exec)->frame();
 }
 
+// FIXME: We should remove this function. Callers can use ScriptController directly.
 bool processingUserGesture()
 {
-    return JSBindingState(JSMainThreadExecState::currentState()).processingUserGesture();
-}
-
-KURL completeURL(ExecState* exec, const String& relativeURL)
-{
-    JSBindingState state(exec);
-    return completeURL(&state, relativeURL);
+    return ScriptController::processingUserGesture();
 }
 
 JSValue objectToStringFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
@@ -749,29 +725,6 @@ Structure* cacheDOMStructure(JSDOMGlobalObject* globalObject, NonNullPassRefPtr<
     return structures.set(classInfo, structure).first->second.get();
 }
 
-Structure* getCachedDOMStructure(ExecState* exec, const ClassInfo* classInfo)
-{
-    return getCachedDOMStructure(static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), classInfo);
-}
-
-Structure* cacheDOMStructure(ExecState* exec, NonNullPassRefPtr<Structure> structure, const ClassInfo* classInfo)
-{
-    return cacheDOMStructure(static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), structure, classInfo);
-}
-
-JSObject* getCachedDOMConstructor(ExecState* exec, const ClassInfo* classInfo)
-{
-    JSDOMConstructorMap& constructors = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->constructors();
-    return constructors.get(classInfo);
-}
-
-void cacheDOMConstructor(ExecState* exec, const ClassInfo* classInfo, JSObject* constructor)
-{
-    JSDOMConstructorMap& constructors = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->constructors();
-    ASSERT(!constructors.contains(classInfo));
-    constructors.set(classInfo, constructor);
-}
-
 JSC::JSObject* toJSSequence(ExecState* exec, JSValue value, unsigned& length)
 {
     JSObject* object = value.getObject();
diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h
index 54e9cf6..52a1a71 100644
--- a/WebCore/bindings/js/JSDOMBinding.h
+++ b/WebCore/bindings/js/JSDOMBinding.h
@@ -132,11 +132,6 @@ namespace WebCore {
 
     JSC::Structure* getCachedDOMStructure(JSDOMGlobalObject*, const JSC::ClassInfo*);
     JSC::Structure* cacheDOMStructure(JSDOMGlobalObject*, NonNullPassRefPtr<JSC::Structure>, const JSC::ClassInfo*);
-    JSC::Structure* getCachedDOMStructure(JSC::ExecState*, const JSC::ClassInfo*);
-    JSC::Structure* cacheDOMStructure(JSC::ExecState*, NonNullPassRefPtr<JSC::Structure>, const JSC::ClassInfo*);
-
-    JSC::JSObject* getCachedDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*);
-    void cacheDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*, JSC::JSObject* constructor);
 
     inline JSDOMGlobalObject* deprecatedGlobalObjectForPrototype(JSC::ExecState* exec)
     {
@@ -225,10 +220,9 @@ namespace WebCore {
     JSC::JSValue jsStringOrFalse(JSC::ExecState*, const String&); // boolean false if the string is null
     JSC::JSValue jsStringOrFalse(JSC::ExecState*, const KURL&); // boolean false if the URL is null
 
-    // See JavaScriptCore for explanation: Should be used for any UString that is already owned by another
+    // See JavaScriptCore for explanation: Should be used for any string that is already owned by another
     // object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
     JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const String&); 
-    JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const JSC::UString&); 
 
     String identifierToString(const JSC::Identifier&);
     String ustringToString(const JSC::UString&);
@@ -284,18 +278,17 @@ namespace WebCore {
     // Helpers for Window, History, and Location classes to implement cross-domain policy.
     // Besides the cross-domain check, they need non-caching versions of staticFunctionGetter for
     // because we do not want current property values involved at all.
+    // FIXME: These functions should be named frameAllowsAccessFrom, because the access is *to* the frame.
     bool allowsAccessFromFrame(JSC::ExecState*, Frame*);
     bool allowsAccessFromFrame(JSC::ExecState*, Frame*, String& message);
-    bool shouldAllowNavigation(JSC::ExecState*, Frame*);
-    bool allowSettingSrcToJavascriptURL(JSC::ExecState*, Element*, const String&, const String&);
+    DOMWindow* activeDOMWindow(JSC::ExecState*);
+    DOMWindow* firstDOMWindow(JSC::ExecState*);
 
     void printErrorMessageForFrame(Frame*, const String& message);
     JSC::JSValue objectToStringFunctionGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier& propertyName);
 
-    Frame* toLexicalFrame(JSC::ExecState*);
     Frame* toDynamicFrame(JSC::ExecState*);
     bool processingUserGesture();
-    KURL completeURL(JSC::ExecState*, const String& relativeURL);
     
     inline JSC::JSValue jsString(JSC::ExecState* exec, const String& s)
     {
diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 6434877..76a6763 100644
--- a/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -20,21 +20,11 @@
 #include "config.h"
 #include "JSDOMWindowCustom.h"
 
-#include "Chrome.h"
-#include "DOMWindow.h"
-#include "Document.h"
-#include "ExceptionCode.h"
-#include "FloatRect.h"
 #include "Frame.h"
-#include "FrameLoadRequest.h"
-#include "FrameLoader.h"
-#include "FrameTree.h"
-#include "FrameView.h"
 #include "HTMLCollection.h"
 #include "HTMLDocument.h"
 #include "History.h"
 #include "JSAudioConstructor.h"
-#include "JSDOMWindowShell.h"
 #include "JSEvent.h"
 #include "JSEventListener.h"
 #include "JSEventSource.h"
@@ -43,7 +33,6 @@
 #include "JSImageConstructor.h"
 #include "JSLocation.h"
 #include "JSMessageChannel.h"
-#include "JSMessagePort.h"
 #include "JSMessagePortCustom.h"
 #include "JSOptionConstructor.h"
 #include "JSWebKitCSSMatrix.h"
@@ -53,22 +42,10 @@
 #include "JSXSLTProcessor.h"
 #include "Location.h"
 #include "MediaPlayer.h"
-#include "MessagePort.h"
-#include "NotificationCenter.h"
-#include "Page.h"
-#include "PlatformScreen.h"
-#include "RegisteredEventListener.h"
 #include "ScheduledAction.h"
-#include "ScriptController.h"
-#include "SerializedScriptValue.h"
 #include "Settings.h"
 #include "SharedWorkerRepository.h"
-#include "WindowFeatures.h"
-#include <runtime/Error.h>
 #include <runtime/JSFunction.h>
-#include <runtime/JSObject.h>
-#include <runtime/PrototypeFunction.h>
-#include <wtf/text/AtomicString.h>
 
 #if ENABLE(3D_CANVAS) || ENABLE(BLOB)
 #include "JSArrayBuffer.h"
@@ -490,13 +467,10 @@ JSValue JSDOMWindow::location(ExecState* exec) const
 
 void JSDOMWindow::setLocation(ExecState* exec, JSValue value)
 {
-    DOMWindow* activeWindow = asJSDOMWindow(exec->lexicalGlobalObject())->impl();
-    DOMWindow* firstWindow = asJSDOMWindow(exec->dynamicGlobalObject())->impl();
-
 #if ENABLE(DASHBOARD_SUPPORT)
     // To avoid breaking old widgets, make "var location =" in a top-level frame create
     // a property named "location" instead of performing a navigation (<rdar://problem/5688039>).
-    if (Frame* activeFrame = activeWindow->frame()) {
+    if (Frame* activeFrame = activeDOMWindow(exec)->frame()) {
         if (Settings* settings = activeFrame->settings()) {
             if (settings->usesDashboardBackwardCompatibilityMode() && !activeFrame->tree()->parent()) {
                 if (allowsAccessFrom(exec))
@@ -511,7 +485,7 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue value)
     if (exec->hadException())
         return;
 
-    impl()->setLocation(ustringToString(locationString), activeWindow, firstWindow);
+    impl()->setLocation(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 JSValue JSDOMWindow::crypto(ExecState*) const
@@ -669,9 +643,6 @@ JSValue JSDOMWindow::webSocket(ExecState* exec) const
 
 JSValue JSDOMWindow::open(ExecState* exec)
 {
-    DOMWindow* activeWindow = asJSDOMWindow(exec->lexicalGlobalObject())->impl();
-    DOMWindow* firstWindow = asJSDOMWindow(exec->dynamicGlobalObject())->impl();
-
     String urlString = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));
     if (exec->hadException())
         return jsUndefined();
@@ -682,7 +653,7 @@ JSValue JSDOMWindow::open(ExecState* exec)
     if (exec->hadException())
         return jsUndefined();
 
-    RefPtr<DOMWindow> openedWindow = impl()->open(urlString, frameName, windowFeaturesString, activeWindow, firstWindow);
+    RefPtr<DOMWindow> openedWindow = impl()->open(urlString, frameName, windowFeaturesString, activeDOMWindow(exec), firstDOMWindow(exec));
     if (!openedWindow)
         return jsUndefined();
     return toJS(exec, openedWindow.get());
@@ -731,9 +702,6 @@ static void setUpDialog(DOMWindow* dialog, void* handler)
 
 JSValue JSDOMWindow::showModalDialog(ExecState* exec)
 {
-    DOMWindow* activeWindow = asJSDOMWindow(exec->lexicalGlobalObject())->impl();
-    DOMWindow* firstWindow = asJSDOMWindow(exec->dynamicGlobalObject())->impl();
-
     String urlString = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));
     if (exec->hadException())
         return jsUndefined();
@@ -743,15 +711,13 @@ JSValue JSDOMWindow::showModalDialog(ExecState* exec)
 
     DialogHandler handler(exec);
 
-    impl()->showModalDialog(urlString, dialogFeaturesString, activeWindow, firstWindow, setUpDialog, &handler);
+    impl()->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(exec), firstDOMWindow(exec), setUpDialog, &handler);
 
     return handler.returnValue();
 }
 
 JSValue JSDOMWindow::postMessage(ExecState* exec)
 {
-    DOMWindow* activeWindow = asJSDOMWindow(exec->lexicalGlobalObject())->impl();
-
     PassRefPtr<SerializedScriptValue> message = SerializedScriptValue::create(exec, exec->argument(0));
 
     if (exec->hadException())
@@ -768,7 +734,7 @@ JSValue JSDOMWindow::postMessage(ExecState* exec)
         return jsUndefined();
 
     ExceptionCode ec = 0;
-    impl()->postMessage(message, &messagePorts, targetOrigin, activeWindow, ec);
+    impl()->postMessage(message, &messagePorts, targetOrigin, activeDOMWindow(exec), ec);
     setDOMException(exec, ec);
 
     return jsUndefined();
diff --git a/WebCore/bindings/js/JSLocationCustom.cpp b/WebCore/bindings/js/JSLocationCustom.cpp
index b00249f..3102e06 100644
--- a/WebCore/bindings/js/JSLocationCustom.cpp
+++ b/WebCore/bindings/js/JSLocationCustom.cpp
@@ -1,7 +1,7 @@
 /*
  *  Copyright (C) 2000 Harri Porten (porten at kde.org)
  *  Copyright (C) 2006 Jon Shier (jshier at iastate.edu)
- *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reseved.
+ *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reseved.
  *  Copyright (C) 2006 Alexey Proskuryakov (ap at webkit.org)
  *
  *  This library is free software; you can redistribute it and/or
@@ -23,19 +23,8 @@
 #include "config.h"
 #include "JSLocationCustom.h"
 
-#include "DOMWindow.h"
-#include "ExceptionCode.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "JSBinding.h"
-#include "JSBindingState.h"
-#include "JSDOMBinding.h"
-#include "JSDOMWindowCustom.h"
-#include "KURL.h"
 #include "Location.h"
-#include "ScriptController.h"
 #include <runtime/JSFunction.h>
-#include <runtime/PrototypeFunction.h>
 
 using namespace JSC;
 
@@ -186,152 +175,93 @@ void JSLocation::defineGetter(ExecState* exec, const Identifier& propertyName, J
     Base::defineGetter(exec, propertyName, getterFunction, attributes);
 }
 
-static void navigateIfAllowed(ExecState* exec, Frame* frame, const KURL& url, bool lockHistory, bool lockBackForwardList)
-{
-    JSBindingState state(exec);
-    JSBinding::Frame::navigateIfAllowed(&state, frame, url, lockHistory, lockBackForwardList);
-}
-
 void JSLocation::setHref(ExecState* exec, JSValue value)
 {
-    Frame* frame = impl()->frame();
-    ASSERT(frame);
-
-    KURL url = completeURL(exec, ustringToString(value.toString(exec)));
-    if (url.isNull())
+    UString href = value.toString(exec);
+    if (exec->hadException())
         return;
-
-    if (!shouldAllowNavigation(exec, frame))
-        return;
-
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    impl()->setHref(ustringToString(href), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 void JSLocation::setProtocol(ExecState* exec, JSValue value)
 {
-    Frame* frame = impl()->frame();
-    ASSERT(frame);
-
-    KURL url = frame->loader()->url();
-    if (!url.setProtocol(ustringToString(value.toString(exec)))) {
-        setDOMException(exec, SYNTAX_ERR);
+    UString protocol = value.toString(exec);
+    if (exec->hadException())
         return;
-    }
-
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    ExceptionCode ec = 0;
+    impl()->setProtocol(ustringToString(protocol), activeDOMWindow(exec), firstDOMWindow(exec), ec);
+    setDOMException(exec, ec);
 }
 
 void JSLocation::setHost(ExecState* exec, JSValue value)
 {
-    Frame* frame = impl()->frame();
-    ASSERT(frame);
-
-    KURL url = frame->loader()->url();
-    url.setHostAndPort(ustringToString(value.toString(exec)));
-
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    UString host = value.toString(exec);
+    if (exec->hadException())
+        return;
+    impl()->setHost(ustringToString(host), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 void JSLocation::setHostname(ExecState* exec, JSValue value)
 {
-    Frame* frame = impl()->frame();
-    ASSERT(frame);
-
-    KURL url = frame->loader()->url();
-    url.setHost(ustringToString(value.toString(exec)));
-
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    UString hostname = value.toString(exec);
+    if (exec->hadException())
+        return;
+    impl()->setHostname(ustringToString(hostname), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 void JSLocation::setPort(ExecState* exec, JSValue value)
 {
-    Frame* frame = impl()->frame();
-    ASSERT(frame);
-
-    KURL url = frame->loader()->url();
-    // FIXME: Could make this a little less ugly if String provided a toUnsignedShort function.
-    const UString& portString = value.toString(exec);
-    int port = charactersToInt(portString.characters(), portString.length());
-    if (port < 0 || port > 0xFFFF)
-        url.removePort();
-    else
-        url.setPort(port);
-
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    UString port = value.toString(exec);
+    if (exec->hadException())
+        return;
+    impl()->setPort(ustringToString(port), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 void JSLocation::setPathname(ExecState* exec, JSValue value)
 {
-    Frame* frame = impl()->frame();
-    ASSERT(frame);
-
-    KURL url = frame->loader()->url();
-    url.setPath(ustringToString(value.toString(exec)));
-
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    UString pathname = value.toString(exec);
+    if (exec->hadException())
+        return;
+    impl()->setPathname(ustringToString(pathname), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 void JSLocation::setSearch(ExecState* exec, JSValue value)
 {
-    Frame* frame = impl()->frame();
-    ASSERT(frame);
-
-    KURL url = frame->loader()->url();
-    url.setQuery(ustringToString(value.toString(exec)));
-
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    UString pathname = value.toString(exec);
+    if (exec->hadException())
+        return;
+    impl()->setSearch(ustringToString(pathname), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 void JSLocation::setHash(ExecState* exec, JSValue value)
 {
-    Frame* frame = impl()->frame();
-    ASSERT(frame);
-
-    KURL url = frame->loader()->url();
-    String oldFragmentIdentifier = url.fragmentIdentifier();
-    String str = ustringToString(value.toString(exec));
-    if (str.startsWith("#"))
-        str = str.substring(1);
-    if (equalIgnoringNullity(oldFragmentIdentifier, str))
+    UString hash = value.toString(exec);
+    if (exec->hadException())
         return;
-    url.setFragmentIdentifier(str);
-
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    impl()->setHash(ustringToString(hash), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 JSValue JSLocation::replace(ExecState* exec)
 {
-    JSBindingState state(exec);
-    JSBinding::Location::replace(&state, impl(), ustringToString(exec->argument(0).toString(exec)));
+    UString urlString = exec->argument(0).toString(exec);
+    if (exec->hadException())
+        return jsUndefined();
+    impl()->replace(ustringToString(urlString), activeDOMWindow(exec), firstDOMWindow(exec));
     return jsUndefined();
 }
 
 JSValue JSLocation::reload(ExecState* exec)
 {
-    Frame* frame = impl()->frame();
-    if (!frame || !allowsAccessFromFrame(exec, frame))
-        return jsUndefined();
-
-    if (!protocolIsJavaScript(frame->loader()->url()))
-        frame->navigationScheduler()->scheduleRefresh();
+    impl()->reload(activeDOMWindow(exec));
     return jsUndefined();
 }
 
 JSValue JSLocation::assign(ExecState* exec)
 {
-    Frame* frame = impl()->frame();
-    if (!frame)
+    UString urlString = exec->argument(0).toString(exec);
+    if (exec->hadException())
         return jsUndefined();
-
-    KURL url = completeURL(exec, ustringToString(exec->argument(0).toString(exec)));
-    if (url.isNull())
-        return jsUndefined();
-
-    if (!shouldAllowNavigation(exec, frame))
-        return jsUndefined();
-
-    // We want a new history item if this JS was called via a user gesture
-    navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
+    impl()->assign(ustringToString(urlString), activeDOMWindow(exec), firstDOMWindow(exec));
     return jsUndefined();
 }
 
diff --git a/WebCore/bindings/js/specialization/JSBindingState.cpp b/WebCore/bindings/js/specialization/JSBindingState.cpp
index 1aa6c7e..1c0922e 100644
--- a/WebCore/bindings/js/specialization/JSBindingState.cpp
+++ b/WebCore/bindings/js/specialization/JSBindingState.cpp
@@ -1,63 +1 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSBindingState.h"
-
-#include "DOMWindow.h"
-#include "JSDOMWindow.h"
-#include "JSDOMWindowCustom.h"
-#include "ScriptController.h"
-
-namespace WebCore {
-
-class Frame;
-
-Frame* State<JSBinding>::activeFrame()
-{
-    return asJSDOMWindow(m_exec->lexicalGlobalObject())->impl()->frame();
-}
-
-Frame* State<JSBinding>::firstFrame()
-{
-    return asJSDOMWindow(m_exec->dynamicGlobalObject())->impl()->frame();
-}
-
-bool State<JSBinding>::processingUserGesture()
-{
-    return ScriptController::processingUserGesture();
-}
-
-bool State<JSBinding>::allowsAccessFromFrame(Frame* frame)
-{
-    return WebCore::allowsAccessFromFrame(m_exec, frame);
-}
-
-} // namespace WebCore
+// Once references to this file are removed from build files, this file should be deleted.
diff --git a/WebCore/bindings/js/specialization/JSBindingState.h b/WebCore/bindings/js/specialization/JSBindingState.h
index 9f5afe7..40ae380 100644
--- a/WebCore/bindings/js/specialization/JSBindingState.h
+++ b/WebCore/bindings/js/specialization/JSBindingState.h
@@ -1,75 +1,2 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JSBindingState_h
-#define JSBindingState_h
-
-#include "GenericBinding.h"
-#include "JSBinding.h"
-
-namespace JSC {
-
-class ExecState;
-
-} // namespace JSC
-
-namespace WebCore {
-
-class Frame;
-
-template <>
-class State<JSBinding> : public State<GenericBinding> {
-public:
-    explicit State(JSC::ExecState* exec)
-        : m_exec(exec)
-    {
-    }
-
-    virtual ~State()
-    {
-    }
-
-    Frame* activeFrame();
-    Frame* firstFrame();
-
-    bool processingUserGesture();
-
-    // FIXME: This should be shared in BindingSecurity
-    bool allowsAccessFromFrame(Frame*);
-
-private:
-    JSC::ExecState* m_exec;
-};
-
-typedef State<JSBinding> JSBindingState;
-
-} // namespace WebCore
-
-#endif // JSBindingState_h
+// Once references to this file are removed from build files, this file should be deleted.
+#error
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index e62960f..d3652e4 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -1608,7 +1608,7 @@ void DOMWindow::revokeObjectURL(const String& blobURLString)
 }
 #endif
 
-void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow)
+void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow, SetLocationLocking locking)
 {
     Frame* activeFrame = activeWindow->frame();
     if (!activeFrame)
@@ -1631,7 +1631,8 @@ void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DO
     // We want a new history item if we are processing a user gesture.
     m_frame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
         completedURL, activeFrame->loader()->outgoingReferrer(),
-        !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
+        locking != LockHistoryBasedOnGestureState || !activeFrame->script()->anyPageIsProcessingUserGesture(),
+        locking != LockHistoryBasedOnGestureState);
 }
 
 void DOMWindow::printErrorMessage(const String& message)
diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h
index 0bffc15..e5dc019 100644
--- a/WebCore/page/DOMWindow.h
+++ b/WebCore/page/DOMWindow.h
@@ -68,6 +68,8 @@ namespace WebCore {
 
     typedef int ExceptionCode;
 
+    enum SetLocationLocking { LockHistoryBasedOnGestureState, LockHistoryAndBackForwardList };
+
     class DOMWindow : public RefCounted<DOMWindow>, public EventTarget {
     public:
         static PassRefPtr<DOMWindow> create(Frame* frame) { return adoptRef(new DOMWindow(frame)); }
@@ -118,7 +120,8 @@ namespace WebCore {
         Navigator* clientInformation() const { return navigator(); }
 
         Location* location() const;
-        void setLocation(const String& location, DOMWindow* activeWindow, DOMWindow* firstWindow);
+        void setLocation(const String& location, DOMWindow* activeWindow, DOMWindow* firstWindow,
+            SetLocationLocking = LockHistoryBasedOnGestureState);
 
         DOMSelection* getSelection();
 
diff --git a/WebCore/page/Location.cpp b/WebCore/page/Location.cpp
index 78809e3..b37a084 100644
--- a/WebCore/page/Location.cpp
+++ b/WebCore/page/Location.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,10 +29,11 @@
 #include "config.h"
 #include "Location.h"
 
+#include "DOMWindow.h"
+#include "ExceptionCode.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "KURL.h"
-#include "PlatformString.h"
 
 namespace WebCore {
 
@@ -52,7 +53,7 @@ inline const KURL& Location::url() const
 
     const KURL& url = m_frame->loader()->url();
     if (!url.isValid())
-        return blankURL();  // Use "about:blank" while the page is still loading (before we have a frame).
+        return blankURL(); // Use "about:blank" while the page is still loading (before we have a frame).
 
     return url;
 }
@@ -124,9 +125,7 @@ String Location::origin() const
 {
     if (!m_frame)
         return String();
-
-    RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url());
-    return origin->toString();
+    return SecurityOrigin::create(url())->toString();
 }
 
 String Location::hash() const
@@ -134,7 +133,7 @@ String Location::hash() const
     if (!m_frame)
         return String();
 
-    const String& fragmentIdentifier = this->url().fragmentIdentifier();
+    const String& fragmentIdentifier = url().fragmentIdentifier();
     return fragmentIdentifier.isEmpty() ? "" : "#" + fragmentIdentifier;
 }
 
@@ -157,4 +156,118 @@ String Location::toString() const
     return url.hasPath() ? url.prettyURL() : url.prettyURL() + "/";
 }
 
+void Location::setHref(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow);
+}
+
+void Location::setProtocol(const String& protocol, DOMWindow* activeWindow, DOMWindow* firstWindow, ExceptionCode& ec)
+{
+    if (!m_frame)
+        return;
+    KURL url = m_frame->loader()->url();
+    if (!url.setProtocol(protocol)) {
+        ec = SYNTAX_ERR;
+        return;
+    }
+    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+}
+
+void Location::setHost(const String& host, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    KURL url = m_frame->loader()->url();
+    url.setHostAndPort(host);
+    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+}
+
+void Location::setHostname(const String& hostname, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    KURL url = m_frame->loader()->url();
+    url.setHost(hostname);
+    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+}
+
+void Location::setPort(const String& portString, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    KURL url = m_frame->loader()->url();
+    int port = portString.toInt();
+    if (port < 0 || port > 0xFFFF)
+        url.removePort();
+    else
+        url.setPort(port);
+    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+}
+
+void Location::setPathname(const String& pathname, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    KURL url = m_frame->loader()->url();
+    url.setPath(pathname);
+    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+}
+
+void Location::setSearch(const String& search, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    KURL url = m_frame->loader()->url();
+    url.setQuery(search);
+    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+}
+
+void Location::setHash(const String& hash, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    KURL url = m_frame->loader()->url();
+    String oldFragmentIdentifier = url.fragmentIdentifier();
+    String newFragmentIdentifier = hash;
+    if (hash[0] == '#')
+        newFragmentIdentifier = hash.substring(1);
+    if (equalIgnoringNullity(oldFragmentIdentifier, newFragmentIdentifier))
+        return;
+    url.setFragmentIdentifier(newFragmentIdentifier);
+    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+}
+
+void Location::assign(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow);
+}
+
+void Location::replace(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    if (!m_frame)
+        return;
+    m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow, LockHistoryAndBackForwardList);
+}
+
+void Location::reload(DOMWindow* activeWindow)
+{
+    if (!m_frame)
+        return;
+    // FIXME: It's not clear this cross-origin security check is valuable.
+    // We allow one page to change the location of another. Why block attempts to reload?
+    // Other location operations simply block use of JavaScript URLs cross origin.
+    DOMWindow* targetWindow = m_frame->domWindow();
+    if (!activeWindow->securityOrigin()->canAccess(targetWindow->securityOrigin())) {
+        targetWindow->printErrorMessage(targetWindow->crossDomainAccessErrorMessage(activeWindow));
+        return;
+    }
+    if (protocolIsJavaScript(m_frame->loader()->url()))
+        return;
+    m_frame->navigationScheduler()->scheduleRefresh();
+}
+
 } // namespace WebCore
diff --git a/WebCore/page/Location.h b/WebCore/page/Location.h
index c62f5aa..1b68cee 100644
--- a/WebCore/page/Location.h
+++ b/WebCore/page/Location.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -35,39 +35,53 @@
 
 namespace WebCore {
 
-    class Frame;
-    class KURL;
+class DOMWindow;
+class Frame;
+class KURL;
 
-    class Location : public RefCounted<Location> {
-    public:
-        static PassRefPtr<Location> create(Frame* frame) { return adoptRef(new Location(frame)); }
+typedef int ExceptionCode;
 
-        Frame* frame() const { return m_frame; }
-        void disconnectFrame();
+class Location : public RefCounted<Location> {
+public:
+    static PassRefPtr<Location> create(Frame* frame) { return adoptRef(new Location(frame)); }
 
-        String href() const;
+    Frame* frame() const { return m_frame; }
+    void disconnectFrame();
 
-        // URI decomposition attributes
-        String protocol() const;
-        String host() const;
-        String hostname() const;
-        String port() const;
-        String pathname() const;
-        String search() const;
-        String hash() const;
-        String origin() const;
+    void setHref(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow);
+    String href() const;
 
-        String toString() const;
+    void assign(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow);
+    void replace(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow);
+    void reload(DOMWindow* activeWindow);
 
-        String getParameter(const String&) const;
+    void setProtocol(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow, ExceptionCode&);
+    String protocol() const;
+    void setHost(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow); 
+    String host() const;
+    void setHostname(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow); 
+    String hostname() const;
+    void setPort(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow); 
+    String port() const;
+    void setPathname(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow); 
+    String pathname() const;
+    void setSearch(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow); 
+    String search() const;
+    void setHash(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow); 
+    String hash() const;
+    String origin() const;
 
-    private:
-        Location(Frame*);
+    String toString() const;
 
-        const KURL& url() const;
+    String getParameter(const String&) const;
 
-        Frame* m_frame;
-    };
+private:
+    Location(Frame*);
+
+    const KURL& url() const;
+
+    Frame* m_frame;
+};
 
 } // namespace WebCore
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list