2010-12-30 Darin Adler <darin@apple.com>
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Dec 2010 19:27:28 +0000 (19:27 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Dec 2010 19:27:28 +0000 (19:27 +0000)
commit7fa6b382a06c736c0103e43947a6d7ec0a116319
tree477be0439610496266f128dcf6cedfd3fcdb3670
parenta25484c3d114dbf4abda8820878426204aac1e51
2010-12-30  Darin Adler  <darin@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
13 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSBinding.h
WebCore/bindings/js/JSDOMBinding.cpp
WebCore/bindings/js/JSDOMBinding.h
WebCore/bindings/js/JSDOMWindowCustom.cpp
WebCore/bindings/js/JSLocationCustom.cpp
WebCore/bindings/js/specialization/JSBindingState.cpp
WebCore/bindings/js/specialization/JSBindingState.h
WebCore/page/DOMWindow.cpp
WebCore/page/DOMWindow.h
WebCore/page/Location.cpp
WebCore/page/Location.h