mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Auto merge of #11214 - farodin91:windowproxy, r=jdm
Support WindowProxy return values in bindings Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy --faster` does not report any errors - [x] These changes fix #10965 (github issue number if applicable). Either: - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11214) <!-- Reviewable:end -->
This commit is contained in:
commit
08a55e2951
11 changed files with 69 additions and 61 deletions
|
@ -23,6 +23,12 @@ DOMInterfaces = {
|
|||
|
||||
'URL': {
|
||||
'weakReferenceable': True,
|
||||
},
|
||||
|
||||
'WindowProxy' : {
|
||||
'nativeType': 'BrowsingContext',
|
||||
'path': 'dom::browsingcontext::BrowsingContext',
|
||||
'register': False,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1695,7 +1695,7 @@ class CGImports(CGWrapper):
|
|||
"""
|
||||
Generates the appropriate import/use statements.
|
||||
"""
|
||||
def __init__(self, child, descriptors, callbacks, imports, ignored_warnings=None):
|
||||
def __init__(self, child, descriptors, callbacks, imports, config, ignored_warnings=None):
|
||||
"""
|
||||
Adds a set of imports.
|
||||
"""
|
||||
|
@ -1756,7 +1756,11 @@ class CGImports(CGWrapper):
|
|||
for c in callbacks:
|
||||
types += relatedTypesForSignatures(c)
|
||||
|
||||
imports += ['dom::types::%s' % getIdentifier(t).name for t in types if isImportable(t)]
|
||||
descriptorProvider = config.getDescriptorProvider()
|
||||
for t in types:
|
||||
if isImportable(t):
|
||||
descriptor = descriptorProvider.getDescriptor(getIdentifier(t).name)
|
||||
imports += ['%s' % descriptor.path]
|
||||
|
||||
statements = []
|
||||
if len(ignored_warnings) > 0:
|
||||
|
@ -2090,7 +2094,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
|
|||
# Sort unionStructs by key, retrieve value
|
||||
unionStructs = (i[1] for i in sorted(unionStructs.items(), key=operator.itemgetter(0)))
|
||||
|
||||
return CGImports(CGList(unionStructs, "\n\n"), [], [], imports, ignored_warnings=[])
|
||||
return CGImports(CGList(unionStructs, "\n\n"), [], [], imports, config, ignored_warnings=[])
|
||||
|
||||
|
||||
class Argument():
|
||||
|
@ -5460,7 +5464,8 @@ class CGBindingRoot(CGThing):
|
|||
# (hence hasInterfaceObject=False).
|
||||
descriptors.extend(config.getDescriptors(webIDLFile=webIDLFile,
|
||||
hasInterfaceObject=False,
|
||||
isCallback=False))
|
||||
isCallback=False,
|
||||
register=True))
|
||||
|
||||
dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
|
||||
|
||||
|
@ -5588,6 +5593,7 @@ class CGBindingRoot(CGThing):
|
|||
'dom::bindings::str::{ByteString, DOMString, USVString}',
|
||||
'dom::bindings::trace::RootedVec',
|
||||
'dom::bindings::weakref::{DOM_WEAK_SLOT, WeakBox, WeakReferenceable}',
|
||||
'dom::browsingcontext::BrowsingContext',
|
||||
'mem::heap_size_of_raw_self_and_children',
|
||||
'libc',
|
||||
'util::prefs',
|
||||
|
@ -5602,7 +5608,7 @@ class CGBindingRoot(CGThing):
|
|||
'std::rc::Rc',
|
||||
'std::default::Default',
|
||||
'std::ffi::CString',
|
||||
])
|
||||
], config)
|
||||
|
||||
# Add the auto-generated comment.
|
||||
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
||||
|
@ -6278,7 +6284,7 @@ class GlobalGenRoots():
|
|||
'dom::bindings::codegen',
|
||||
'dom::bindings::codegen::PrototypeList::Proxies',
|
||||
'libc',
|
||||
], ignored_warnings=[])
|
||||
], config, ignored_warnings=[])
|
||||
|
||||
@staticmethod
|
||||
def InterfaceTypes(config):
|
||||
|
|
|
@ -173,6 +173,7 @@ class Descriptor(DescriptorProvider):
|
|||
|
||||
# Read the desc, and fill in the relevant defaults.
|
||||
ifaceName = self.interface.identifier.name
|
||||
typeName = desc.get('nativeType', ifaceName)
|
||||
|
||||
# Callback types do not use JS smart pointers, so we should not use the
|
||||
# built-in rooting mechanisms for them.
|
||||
|
@ -184,12 +185,13 @@ class Descriptor(DescriptorProvider):
|
|||
self.nativeType = ty
|
||||
else:
|
||||
self.needsRooting = True
|
||||
self.returnType = "Root<%s>" % ifaceName
|
||||
self.argumentType = "&%s" % ifaceName
|
||||
self.nativeType = "*const %s" % ifaceName
|
||||
self.returnType = "Root<%s>" % typeName
|
||||
self.argumentType = "&%s" % typeName
|
||||
self.nativeType = "*const %s" % typeName
|
||||
|
||||
self.concreteType = ifaceName
|
||||
self.concreteType = typeName
|
||||
self.register = desc.get('register', True)
|
||||
self.path = desc.get('path', 'dom::types::%s' % typeName)
|
||||
self.outerObjectHook = desc.get('outerObjectHook', 'None')
|
||||
self.proxy = False
|
||||
self.weakReferenceable = desc.get('weakReferenceable', False)
|
||||
|
|
|
@ -22,6 +22,7 @@ use dom::bindings::inheritance::Castable;
|
|||
use dom::bindings::js::{Root, LayoutJS};
|
||||
use dom::bindings::reflector::Reflectable;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::browsingcontext::BrowsingContext;
|
||||
use dom::customevent::CustomEvent;
|
||||
use dom::document::Document;
|
||||
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||
|
@ -256,6 +257,15 @@ impl HTMLIFrameElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_content_window(&self) -> Option<Root<Window>> {
|
||||
self.subpage_id.get().and_then(|subpage_id| {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let browsing_context = window.browsing_context();
|
||||
browsing_context.find_child_by_subpage(subpage_id)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub trait HTMLIFrameElementLayoutMethods {
|
||||
|
@ -422,18 +432,16 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow
|
||||
fn GetContentWindow(&self) -> Option<Root<Window>> {
|
||||
self.subpage_id.get().and_then(|subpage_id| {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let browsing_context = window.browsing_context();
|
||||
browsing_context.find_child_by_subpage(subpage_id)
|
||||
})
|
||||
fn GetContentWindow(&self) -> Option<Root<BrowsingContext>> {
|
||||
match self.get_content_window() {
|
||||
Some(ref window) => Some(window.browsing_context()),
|
||||
None => None
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
|
||||
fn GetContentDocument(&self) -> Option<Root<Document>> {
|
||||
self.GetContentWindow().and_then(|window| {
|
||||
self.get_content_window().and_then(|window| {
|
||||
// FIXME(#10964): this should use the Document's origin and the
|
||||
// origin of the incumbent settings object.
|
||||
let self_url = self.get_url();
|
||||
|
|
|
@ -159,16 +159,16 @@ interface BrowserElementPrivileged {
|
|||
// unsigned long count,
|
||||
// unsigned long modifiers);
|
||||
|
||||
[Func="Window::global_is_mozbrowser", Throws]
|
||||
[Func="::dom::window::Window::global_is_mozbrowser", Throws]
|
||||
void goBack();
|
||||
|
||||
[Func="Window::global_is_mozbrowser", Throws]
|
||||
[Func="::dom::window::Window::global_is_mozbrowser", Throws]
|
||||
void goForward();
|
||||
|
||||
[Func="Window::global_is_mozbrowser", Throws]
|
||||
[Func="::dom::window::Window::global_is_mozbrowser", Throws]
|
||||
void reload(optional boolean hardReload = false);
|
||||
|
||||
[Func="Window::global_is_mozbrowser", Throws]
|
||||
[Func="::dom::window::Window::global_is_mozbrowser", Throws]
|
||||
void stop();
|
||||
|
||||
//[Throws,
|
||||
|
|
|
@ -13,8 +13,7 @@ interface HTMLIFrameElement : HTMLElement {
|
|||
attribute DOMString width;
|
||||
attribute DOMString height;
|
||||
readonly attribute Document? contentDocument;
|
||||
//readonly attribute WindowProxy? contentWindow;
|
||||
readonly attribute Window? contentWindow;
|
||||
readonly attribute WindowProxy? contentWindow;
|
||||
|
||||
// also has obsolete members
|
||||
};
|
||||
|
@ -31,7 +30,7 @@ partial interface HTMLIFrameElement {
|
|||
};
|
||||
|
||||
partial interface HTMLIFrameElement {
|
||||
[Func="Window::global_is_mozbrowser"]
|
||||
[Func="::dom::window::Window::global_is_mozbrowser"]
|
||||
attribute boolean mozbrowser;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
[PrimaryGlobal]
|
||||
/*sealed*/ interface Window : EventTarget {
|
||||
// the current browsing context
|
||||
//[Unforgeable] readonly attribute WindowProxy window;
|
||||
//[Replaceable] readonly attribute WindowProxy self;
|
||||
readonly attribute Window window;
|
||||
[BinaryName="Self_"] readonly attribute Window self;
|
||||
[Unforgeable] readonly attribute WindowProxy window;
|
||||
[BinaryName="Self_", Replaceable] readonly attribute WindowProxy self;
|
||||
[Unforgeable] readonly attribute Document document;
|
||||
// attribute DOMString name;
|
||||
[/*PutForwards=href, */Unforgeable] readonly attribute Location location;
|
||||
|
@ -28,14 +26,11 @@
|
|||
//void blur();
|
||||
|
||||
// other browsing contexts
|
||||
//[Replaceable] readonly attribute WindowProxy frames;
|
||||
readonly attribute Window frames;
|
||||
[Replaceable] readonly attribute WindowProxy frames;
|
||||
//[Replaceable] readonly attribute unsigned long length;
|
||||
//[Unforgeable] readonly attribute WindowProxy top;
|
||||
readonly attribute Window top;
|
||||
[Unforgeable] readonly attribute WindowProxy top;
|
||||
// attribute any opener;
|
||||
//readonly attribute WindowProxy parent;
|
||||
readonly attribute Window parent;
|
||||
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);
|
||||
|
@ -65,6 +60,9 @@
|
|||
Window implements GlobalEventHandlers;
|
||||
Window implements WindowEventHandlers;
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface WindowProxy {};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#timers
|
||||
[NoInterfaceObject/*, Exposed=Window,Worker*/]
|
||||
interface WindowTimers {
|
||||
|
|
|
@ -558,32 +558,35 @@ impl WindowMethods for Window {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-window
|
||||
fn Window(&self) -> Root<Window> {
|
||||
Root::from_ref(self)
|
||||
fn Window(&self) -> Root<BrowsingContext> {
|
||||
self.browsing_context()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-self
|
||||
fn Self_(&self) -> Root<Window> {
|
||||
self.Window()
|
||||
fn Self_(&self) -> Root<BrowsingContext> {
|
||||
self.browsing_context()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-frames
|
||||
fn Frames(&self) -> Root<Window> {
|
||||
self.Window()
|
||||
fn Frames(&self) -> Root<BrowsingContext> {
|
||||
self.browsing_context()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-parent
|
||||
fn Parent(&self) -> Root<Window> {
|
||||
self.parent().unwrap_or(self.Window())
|
||||
fn Parent(&self) -> Root<BrowsingContext> {
|
||||
match self.parent() {
|
||||
Some(window) => window.browsing_context(),
|
||||
None => self.Window()
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-top
|
||||
fn Top(&self) -> Root<Window> {
|
||||
let mut window = self.Window();
|
||||
fn Top(&self) -> Root<BrowsingContext> {
|
||||
let mut window = Root::from_ref(self);
|
||||
while let Some(parent) = window.parent() {
|
||||
window = parent;
|
||||
}
|
||||
window
|
||||
window.browsing_context()
|
||||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/
|
||||
|
|
|
@ -6,7 +6,6 @@ use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclar
|
|||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
|
@ -105,7 +104,7 @@ pub fn handle_get_frame_id(context: &BrowsingContext,
|
|||
match find_node_by_unique_id(context, pipeline, x) {
|
||||
Some(ref node) => {
|
||||
match node.downcast::<HTMLIFrameElement>() {
|
||||
Some(ref elem) => Ok(elem.GetContentWindow()),
|
||||
Some(ref elem) => Ok(elem.get_content_window()),
|
||||
None => Err(())
|
||||
}
|
||||
},
|
||||
|
|
|
@ -297,15 +297,9 @@
|
|||
[Window attribute: onwaiting]
|
||||
expected: FAIL
|
||||
|
||||
[Window unforgeable attribute: window]
|
||||
expected: FAIL
|
||||
|
||||
[Window unforgeable attribute: location]
|
||||
expected: FAIL
|
||||
|
||||
[Window unforgeable attribute: top]
|
||||
expected: FAIL
|
||||
|
||||
[Window replaceable attribute: self]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -5304,9 +5304,6 @@
|
|||
[Window interface: attribute localStorage]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must have own property "window"]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must inherit property "self" with the proper type (1)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -5358,9 +5355,6 @@
|
|||
[Window interface: window must inherit property "length" with the proper type (19)]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must have own property "top"]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must inherit property "opener" with the proper type (21)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -9581,4 +9575,3 @@
|
|||
|
||||
[HTMLInputElement interface: createInput("button") must inherit property "useMap" with the proper type (57)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue