diff options
author | bors-servo <release+servo@mozilla.com> | 2013-07-30 13:57:26 -0700 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2013-07-30 13:57:26 -0700 |
commit | 7911ae56954cc0ff03f77ff901233a411a30f1e7 (patch) | |
tree | 74051c69466d57a603ae028a9e2dfbcd9fcab611 /src/components/script/dom/bindings/codegen | |
parent | 0c105b5307bb69e8d43a1c6263b09c1b8e52c355 (diff) | |
parent | a2bdab7989bf39fa5db4cdedc21884ca6018036f (diff) | |
download | servo-7911ae56954cc0ff03f77ff901233a411a30f1e7.tar.gz servo-7911ae56954cc0ff03f77ff901233a411a30f1e7.zip |
auto merge of #645 : jdm/servo/window, r=jdm
This one also looks larger than necessary because GetParentObject needed to be changed to return an Option.
Diffstat (limited to 'src/components/script/dom/bindings/codegen')
3 files changed, 82 insertions, 23 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf index 6ab8feb11d8..b07e27c75a3 100644 --- a/src/components/script/dom/bindings/codegen/Bindings.conf +++ b/src/components/script/dom/bindings/codegen/Bindings.conf @@ -401,6 +401,9 @@ DOMInterfaces = { 'implicitJSContext': [ 'constructor' ] }], +'Window': { +}, + 'WindowProxy': { }, @@ -567,5 +570,4 @@ addExternalIface('WebGLShaderPrecisionFormat', headerFile='WebGLContext.h') addExternalIface('WebGLTexture', nativeType='mozilla::WebGLTexture', headerFile='WebGLContext.h') -addExternalIface('Window') addExternalIface('XULElement') diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 919673ac830..1c177e2e8ea 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1158,8 +1158,8 @@ for (uint32_t i = 0; i < length; ++i) { "rooting issues") templateBody = "${declName} = ${val};" templateBody = handleDefaultNull(templateBody, - "${declName} = JS::NullValue()") - return (templateBody, CGGeneric("JS::Value"), None, isOptional, None) + "${declName} = JSVAL_NULL") + return (templateBody, CGGeneric("JSVal"), None, isOptional, "JSVAL_NULL") if type.isObject(): assert not isEnforceRange and not isClamp @@ -1263,7 +1263,7 @@ for (uint32_t i = 0; i < length; ++i) { " %s = %s;\n" "}" % (dataLoc, defaultStr))).define() - return (template, declType, None, isOptional, None) + return (template, declType, None, isOptional, "0 as %s" % typeName) def instantiateJSToNativeConversionTemplate(templateTuple, replacements, argcAndIndex=None): @@ -1308,11 +1308,7 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements, originalDeclName = replacements["declName"] if declType is not None: if dealWithOptional: - replacements["declName"] = ( - "const_cast< %s & >(%s.Value())" % - (declType.define(), originalDeclName)) - mutableDeclType = CGWrapper(declType, pre="Optional< ", post=" >") - declType = CGWrapper(mutableDeclType, pre="const ") + mutableDeclType = CGWrapper(declType, pre="Option< ", post=" >") newDecl = [CGGeneric("let mut "), CGGeneric(originalDeclName), CGGeneric(": "), @@ -1327,19 +1323,8 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements, ) if argcAndIndex is not None: - if dealWithOptional: - declConstruct = CGIndenter( - CGGeneric("const_cast< %s &>(%s).Construct();" % - (mutableDeclType.define(), originalDeclName))) - if holderType is not None: - holderConstruct = CGIndenter( - CGGeneric("const_cast< %s &>(%s).Construct();" % - (mutableHolderType.define(), originalHolderName))) - else: - holderConstruct = None - else: - declConstruct = None - holderConstruct = None + declConstruct = None + holderConstruct = None conversion = CGList( [CGGeneric( @@ -2155,7 +2140,7 @@ class CGImports(CGWrapper): # TODO imports to cover descriptors, etc. def _useString(imports): - return '#[allow(non_uppercase_statics,unused_imports,unused_variable,unused_unsafe,unused_mut)];' + ''.join(['use %s;\n' % i for i in imports]) + '\n' + return '#[allow(non_uppercase_statics,unused_imports,unused_variable,unused_unsafe,unused_mut,dead_assignment)];\n' + ''.join(['use %s;\n' % i for i in imports]) + '\n' CGWrapper.__init__(self, child, declarePre=_useString(sorted(declareImports))) @@ -4373,6 +4358,7 @@ class CGBindingRoot(CGThing): 'dom::mouseevent::*', #XXXjdm 'dom::uievent::*', #XXXjdm 'dom::windowproxy::*', #XXXjdm + 'dom::window::Window', #XXXjdm 'dom::bindings::codegen::*', #XXXjdm 'script_task::{JSPageInfo, page_from_context}', 'dom::bindings::utils::EnumEntry', diff --git a/src/components/script/dom/bindings/codegen/Window.webidl b/src/components/script/dom/bindings/codegen/Window.webidl new file mode 100644 index 00000000000..6240365be94 --- /dev/null +++ b/src/components/script/dom/bindings/codegen/Window.webidl @@ -0,0 +1,71 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is: + * http://www.w3.org/html/wg/drafts/html/master/browsers.html#the-window-object + */ + +[NamedPropertiesObject] +/*sealed*/ interface Window /*: EventTarget*/ { + // the current browsing context + /*[Unforgeable] readonly attribute WindowProxy window; + [Replaceable] readonly attribute WindowProxy self;*/ + [Unforgeable] readonly attribute Document document; + attribute DOMString name; + /*[PutForwards=href, Unforgeable] readonly attribute Location location; + readonly attribute History history; + [Replaceable] readonly attribute BarProp locationbar; + [Replaceable] readonly attribute BarProp menubar; + [Replaceable] readonly attribute BarProp personalbar; + [Replaceable] readonly attribute BarProp scrollbars; + [Replaceable] readonly attribute BarProp statusbar; + [Replaceable] readonly attribute BarProp toolbar;*/ + attribute DOMString status; + void close(); + readonly attribute boolean closed; + void stop(); + void focus(); + void blur(); + + // other browsing contexts + /*[Replaceable] readonly attribute WindowProxy frames; + [Replaceable] readonly attribute unsigned long length; + [Unforgeable] readonly attribute WindowProxy top; + attribute WindowProxy? opener; + readonly attribute WindowProxy parent;*/ + readonly attribute Element? frameElement; + /*WindowProxy open(optional DOMString url = "about:blank", optional DOMString target = "_blank", optional DOMString features = "", optional boolean replace = false); + getter WindowProxy (unsigned long index);*/ + getter object (DOMString name); + + // the user agent + /*readonly attribute Navigator navigator; + readonly attribute External external; + readonly attribute ApplicationCache applicationCache;*/ + + // user prompts + void alert(optional DOMString message = ""); + boolean confirm(optional DOMString message = ""); + DOMString? prompt(optional DOMString message = "", optional DOMString default = ""); + void print(); + any showModalDialog(DOMString url, optional any argument); + + +}; +/*Window implements GlobalEventHandlers; + Window implements WindowEventHandlers;*/ + +[NoInterfaceObject] +interface WindowTimers { + //long setTimeout(Function handler, optional long timeout, any... arguments); + //XXXjdm No support for Function or variadic arguments yet + long setTimeout(any handler, optional long timeout/*, any... arguments*/); + /*long setTimeout(DOMString handler, optional long timeout, any... arguments); + void clearTimeout(long handle); + long setInterval(Function handler, optional long timeout, any... arguments); + long setInterval(DOMString handler, optional long timeout, any... arguments); + void clearInterval(long handle);*/ +}; +Window implements WindowTimers; |