From f4315cf2f7fe2806a9642b26ce4365b087a4b47b Mon Sep 17 00:00:00 2001 From: weinig Date: Tue, 17 Jul 2007 05:06:26 +0000 Subject: [PATCH] Reviewed by Adam and Maciej. Move the frameElement attribute from kjs_window to DOMWindow and auto-generate the bindings for it. * bindings/js/kjs_window.cpp: (KJS::Window::getValueProperty): * bindings/js/kjs_window.h: (KJS::Window::): * bindings/scripts/CodeGeneratorJS.pm: * page/DOMWindow.cpp: (WebCore::DOMWindow::frameElement): (WebCore::DOMWindow::devicePixelRatio): * page/DOMWindow.h: * page/DOMWindow.idl: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@24351 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 18 ++++++++++++++++++ WebCore/bindings/js/kjs_window.cpp | 9 --------- WebCore/bindings/js/kjs_window.h | 1 - WebCore/bindings/scripts/CodeGeneratorJS.pm | 3 +++ WebCore/page/DOMWindow.cpp | 16 +++++++++++++++- WebCore/page/DOMWindow.h | 2 ++ WebCore/page/DOMWindow.idl | 2 ++ 7 files changed, 40 insertions(+), 11 deletions(-) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 7e61f64f51e..38a581a029a 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2007-07-16 Sam Weinig + + Reviewed by Adam and Maciej. + + Move the frameElement attribute from kjs_window to DOMWindow and + auto-generate the bindings for it. + + * bindings/js/kjs_window.cpp: + (KJS::Window::getValueProperty): + * bindings/js/kjs_window.h: + (KJS::Window::): + * bindings/scripts/CodeGeneratorJS.pm: + * page/DOMWindow.cpp: + (WebCore::DOMWindow::frameElement): + (WebCore::DOMWindow::devicePixelRatio): + * page/DOMWindow.h: + * page/DOMWindow.idl: + 2007-07-16 Sam Weinig Reviewed by Adam. diff --git a/WebCore/bindings/js/kjs_window.cpp b/WebCore/bindings/js/kjs_window.cpp index bdb1943b529..725f5868bcf 100644 --- a/WebCore/bindings/js/kjs_window.cpp +++ b/WebCore/bindings/js/kjs_window.cpp @@ -179,7 +179,6 @@ const ClassInfo Window::info = { "Window", 0, &WindowTable, 0 }; self Window::Self DontDelete|ReadOnly window Window::Window_ DontDelete|ReadOnly top Window::Top DontDelete|ReadOnly - frameElement Window::FrameElement DontDelete|ReadOnly # -- Event Listeners -- onabort Window::Onabort DontDelete onblur Window::Onblur DontDelete @@ -578,14 +577,6 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const case XSLTProcessor_: return jsUndefined(); #endif - case FrameElement: - if (!isSafeScript(exec)) - return jsUndefined(); - if (Document* doc = impl()->frame()->document()) - if (Element* fe = doc->ownerElement()) - if (checkNodeSecurity(exec, fe)) - return toJS(exec, fe); - return jsUndefined(); } if (!isSafeScript(exec)) diff --git a/WebCore/bindings/js/kjs_window.h b/WebCore/bindings/js/kjs_window.h index ef6226c08a0..696202b94a2 100644 --- a/WebCore/bindings/js/kjs_window.h +++ b/WebCore/bindings/js/kjs_window.h @@ -153,7 +153,6 @@ namespace KJS { Crypto, Frames, Event_, Location_, Navigator_, ClientInformation, Opener, Parent, Self, Window_, Top, - FrameElement, // Event Listeners Onabort, Onblur, Onchange, Onclick, diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 6d91d1a76d7..ce0e99c98b9 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -891,6 +891,9 @@ sub GenerateImplementation if ($attribute->signature->extendedAttributes->{"Custom"}) { push(@implContent, " return $name(exec);\n"); + } elsif ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) { + $implIncludes{"kjs_dom.h"} = 1; + push(@implContent, " return checkNodeSecurity(exec, imp->$name()) ? " . NativeToJSValue($attribute->signature, $implClassNameForValueConversion, "imp->$name()") . " : jsUndefined();\n"); } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) { $implIncludes{"Document.h"} = 1; $implIncludes{"kjs_dom.h"} = 1; diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp index 5bb862b521c..1c083adf3a8 100644 --- a/WebCore/page/DOMWindow.cpp +++ b/WebCore/page/DOMWindow.cpp @@ -146,6 +146,20 @@ DOMSelection* DOMWindow::getSelection() return m_selection.get(); } +Element* DOMWindow::frameElement() const +{ + if (!m_frame) + return 0; + + Document* doc = m_frame->document(); + ASSERT(doc); + if (!doc) + return 0; + + // FIXME: could this use m_frame->ownerElement() instead of going through the Document. + return doc->ownerElement(); +} + void DOMWindow::focus() { if (!m_frame) @@ -467,7 +481,7 @@ double DOMWindow::devicePixelRatio() const Page* page = m_frame->page(); if (!page) - return 0; + return 0.0; return page->chrome()->scaleFactor(); } diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h index fb369ec9964..0c54a645da3 100644 --- a/WebCore/page/DOMWindow.h +++ b/WebCore/page/DOMWindow.h @@ -63,6 +63,8 @@ namespace WebCore { DOMSelection* getSelection(); + Element* frameElement() const; + void focus(); void blur(); void close(); diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl index eb2380e6f77..2ec38f3de77 100644 --- a/WebCore/page/DOMWindow.idl +++ b/WebCore/page/DOMWindow.idl @@ -38,6 +38,8 @@ module window { DOMSelection getSelection(); + readonly attribute [CheckNodeSecurity] Element frameElement; + [DoNotCheckDomainSecurity] void focus(); [DoNotCheckDomainSecurity] void blur(); [DoNotCheckDomainSecurity] void close(); -- GitLab