aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/codegen/Bindings.conf6
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py18
-rw-r--r--components/script/dom/bindings/codegen/Configuration.py10
-rw-r--r--components/script/dom/htmliframeelement.rs24
-rw-r--r--components/script/dom/webidls/BrowserElement.webidl8
-rw-r--r--components/script/dom/webidls/HTMLIFrameElement.webidl5
-rw-r--r--components/script/dom/webidls/Window.webidl18
-rw-r--r--components/script/dom/window.rs25
8 files changed, 68 insertions, 46 deletions
diff --git a/components/script/dom/bindings/codegen/Bindings.conf b/components/script/dom/bindings/codegen/Bindings.conf
index 314151f8c58..44d835589c4 100644
--- a/components/script/dom/bindings/codegen/Bindings.conf
+++ b/components/script/dom/bindings/codegen/Bindings.conf
@@ -23,6 +23,12 @@ DOMInterfaces = {
'URL': {
'weakReferenceable': True,
+},
+
+'WindowProxy' : {
+ 'nativeType': 'BrowsingContext',
+ 'path': 'dom::browsingcontext::BrowsingContext',
+ 'register': False,
}
}
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index c356a7d066c..057246f05aa 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -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):
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py
index 3ee7fb37e77..7aad0f75f75 100644
--- a/components/script/dom/bindings/codegen/Configuration.py
+++ b/components/script/dom/bindings/codegen/Configuration.py
@@ -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)
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 1c0e0c9cf1a..44122f07fe4 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -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();
diff --git a/components/script/dom/webidls/BrowserElement.webidl b/components/script/dom/webidls/BrowserElement.webidl
index ae3b8e310e3..9351cc9377a 100644
--- a/components/script/dom/webidls/BrowserElement.webidl
+++ b/components/script/dom/webidls/BrowserElement.webidl
@@ -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,
diff --git a/components/script/dom/webidls/HTMLIFrameElement.webidl b/components/script/dom/webidls/HTMLIFrameElement.webidl
index 65ccbe84048..bf547c8930a 100644
--- a/components/script/dom/webidls/HTMLIFrameElement.webidl
+++ b/components/script/dom/webidls/HTMLIFrameElement.webidl
@@ -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;
};
diff --git a/components/script/dom/webidls/Window.webidl b/components/script/dom/webidls/Window.webidl
index b263d53bb7b..fcac82ea0c5 100644
--- a/components/script/dom/webidls/Window.webidl
+++ b/components/script/dom/webidls/Window.webidl
@@ -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 {
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index c8d327897d2..4bfbb1993d1 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -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/