From c10df37830d733667d0e5dbf174eae88fdb0dbff Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 26 Sep 2017 03:20:05 -0500 Subject: [PATCH] servo: Merge #18635 - Rename JS to Dom, Root to DomRoot, and other things (from servo:RENAME-ALL-THE-THINGS); r=emilio Source-Repo: https://github.com/servo/servo Source-Revision: 1282e0d8080ae15307ac8d35941754f9d60f0d76 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 7b291b334b5797291cac309f71232069534f53d2 --- servo/components/layout/wrapper.rs | 2 +- servo/components/layout_thread/dom_wrapper.rs | 34 +- servo/components/script/body.rs | 6 +- servo/components/script/devtools.rs | 4 +- .../script/docs/JS-Servos-only-GC.md | 54 +-- servo/components/script/document_loader.rs | 6 +- servo/components/script/dom/attr.rs | 20 +- .../script/dom/beforeunloadevent.rs | 12 +- .../script/dom/bindings/callback.rs | 10 +- servo/components/script/dom/bindings/cell.rs | 18 +- .../dom/bindings/codegen/CodegenRust.py | 36 +- .../dom/bindings/codegen/Configuration.py | 2 +- .../script/dom/bindings/conversions.rs | 24 +- .../script/dom/bindings/interface.rs | 10 +- .../script/dom/bindings/iterable.rs | 8 +- servo/components/script/dom/bindings/mod.rs | 2 +- .../script/dom/bindings/refcounted.rs | 6 +- .../script/dom/bindings/reflector.rs | 8 +- .../script/dom/bindings/{js.rs => root.rs} | 252 +++++------ .../script/dom/bindings/settings_stack.rs | 20 +- .../script/dom/bindings/structuredclone.rs | 4 +- servo/components/script/dom/bindings/trace.rs | 30 +- .../components/script/dom/bindings/weakref.rs | 12 +- servo/components/script/dom/blob.rs | 30 +- servo/components/script/dom/bluetooth.rs | 20 +- .../script/dom/bluetoothadvertisingevent.rs | 14 +- .../dom/bluetoothcharacteristicproperties.rs | 4 +- .../components/script/dom/bluetoothdevice.rs | 50 +-- .../script/dom/bluetoothpermissionresult.rs | 26 +- .../dom/bluetoothremotegattcharacteristic.rs | 26 +- .../dom/bluetoothremotegattdescriptor.rs | 18 +- .../script/dom/bluetoothremotegattserver.rs | 12 +- .../script/dom/bluetoothremotegattservice.rs | 12 +- servo/components/script/dom/canvasgradient.rs | 10 +- servo/components/script/dom/canvaspattern.rs | 4 +- .../script/dom/canvasrenderingcontext2d.rs | 60 +-- servo/components/script/dom/characterdata.rs | 26 +- servo/components/script/dom/client.rs | 8 +- servo/components/script/dom/closeevent.rs | 8 +- servo/components/script/dom/comment.rs | 6 +- .../components/script/dom/compositionevent.rs | 6 +- servo/components/script/dom/create.rs | 22 +- servo/components/script/dom/crypto.rs | 10 +- .../components/script/dom/cssfontfacerule.rs | 4 +- .../components/script/dom/cssgroupingrule.rs | 10 +- servo/components/script/dom/cssimportrule.rs | 4 +- .../components/script/dom/csskeyframerule.rs | 10 +- .../components/script/dom/csskeyframesrule.rs | 16 +- servo/components/script/dom/cssmediarule.rs | 12 +- .../components/script/dom/cssnamespacerule.rs | 4 +- servo/components/script/dom/cssrule.rs | 28 +- servo/components/script/dom/cssrulelist.rs | 32 +- .../script/dom/cssstyledeclaration.rs | 12 +- servo/components/script/dom/cssstylerule.rs | 10 +- servo/components/script/dom/cssstylesheet.rs | 16 +- servo/components/script/dom/cssstylevalue.rs | 4 +- .../components/script/dom/csssupportsrule.rs | 4 +- .../components/script/dom/cssviewportrule.rs | 4 +- .../script/dom/customelementregistry.rs | 44 +- servo/components/script/dom/customevent.rs | 8 +- .../script/dom/dedicatedworkerglobalscope.rs | 14 +- .../script/dom/dissimilaroriginlocation.rs | 8 +- .../script/dom/dissimilaroriginwindow.rs | 34 +- servo/components/script/dom/document.rs | 391 +++++++++--------- .../components/script/dom/documentfragment.rs | 22 +- servo/components/script/dom/documenttype.rs | 4 +- servo/components/script/dom/domexception.rs | 4 +- .../script/dom/domimplementation.rs | 20 +- servo/components/script/dom/dommatrix.rs | 56 +-- .../script/dom/dommatrixreadonly.rs | 42 +- servo/components/script/dom/domparser.rs | 12 +- servo/components/script/dom/dompoint.rs | 8 +- .../components/script/dom/dompointreadonly.rs | 6 +- servo/components/script/dom/domquad.rs | 44 +- servo/components/script/dom/domrect.rs | 6 +- .../components/script/dom/domrectreadonly.rs | 6 +- servo/components/script/dom/domstringmap.rs | 8 +- servo/components/script/dom/domtokenlist.rs | 10 +- servo/components/script/dom/element.rs | 179 ++++---- servo/components/script/dom/errorevent.rs | 18 +- servo/components/script/dom/event.rs | 32 +- servo/components/script/dom/eventsource.rs | 16 +- servo/components/script/dom/eventtarget.rs | 20 +- .../components/script/dom/extendableevent.rs | 6 +- .../script/dom/extendablemessageevent.rs | 6 +- servo/components/script/dom/file.rs | 8 +- servo/components/script/dom/filelist.rs | 18 +- servo/components/script/dom/filereader.rs | 24 +- servo/components/script/dom/filereadersync.rs | 6 +- servo/components/script/dom/focusevent.rs | 12 +- .../components/script/dom/forcetouchevent.rs | 4 +- servo/components/script/dom/formdata.rs | 24 +- servo/components/script/dom/gamepad.rs | 20 +- servo/components/script/dom/gamepadbutton.rs | 4 +- .../script/dom/gamepadbuttonlist.rs | 14 +- servo/components/script/dom/gamepadevent.rs | 16 +- servo/components/script/dom/gamepadlist.rs | 20 +- servo/components/script/dom/globalscope.rs | 36 +- .../components/script/dom/hashchangeevent.rs | 8 +- servo/components/script/dom/headers.rs | 16 +- servo/components/script/dom/history.rs | 8 +- .../script/dom/htmlanchorelement.rs | 14 +- .../script/dom/htmlappletelement.rs | 4 +- .../components/script/dom/htmlareaelement.rs | 8 +- .../components/script/dom/htmlaudioelement.rs | 4 +- .../components/script/dom/htmlbaseelement.rs | 4 +- .../components/script/dom/htmlbodyelement.rs | 6 +- servo/components/script/dom/htmlbrelement.rs | 4 +- .../script/dom/htmlbuttonelement.rs | 16 +- .../script/dom/htmlcanvaselement.rs | 28 +- servo/components/script/dom/htmlcollection.rs | 54 +-- .../components/script/dom/htmldataelement.rs | 4 +- .../script/dom/htmldatalistelement.rs | 6 +- .../script/dom/htmldetailselement.rs | 4 +- .../script/dom/htmldialogelement.rs | 10 +- .../script/dom/htmldirectoryelement.rs | 4 +- servo/components/script/dom/htmldivelement.rs | 4 +- .../components/script/dom/htmldlistelement.rs | 4 +- servo/components/script/dom/htmlelement.rs | 28 +- .../components/script/dom/htmlembedelement.rs | 4 +- .../script/dom/htmlfieldsetelement.rs | 14 +- .../components/script/dom/htmlfontelement.rs | 6 +- .../script/dom/htmlformcontrolscollection.rs | 10 +- .../components/script/dom/htmlformelement.rs | 52 +-- .../components/script/dom/htmlframeelement.rs | 4 +- .../script/dom/htmlframesetelement.rs | 4 +- .../components/script/dom/htmlheadelement.rs | 6 +- .../script/dom/htmlheadingelement.rs | 4 +- servo/components/script/dom/htmlhrelement.rs | 6 +- .../components/script/dom/htmlhtmlelement.rs | 4 +- .../script/dom/htmliframeelement.rs | 22 +- .../components/script/dom/htmlimageelement.rs | 30 +- .../components/script/dom/htmlinputelement.rs | 54 +-- .../components/script/dom/htmllabelelement.rs | 18 +- .../script/dom/htmllegendelement.rs | 10 +- servo/components/script/dom/htmllielement.rs | 4 +- .../components/script/dom/htmllinkelement.rs | 24 +- servo/components/script/dom/htmlmapelement.rs | 8 +- .../components/script/dom/htmlmediaelement.rs | 34 +- .../components/script/dom/htmlmetaelement.rs | 16 +- .../components/script/dom/htmlmeterelement.rs | 6 +- servo/components/script/dom/htmlmodelement.rs | 4 +- .../script/dom/htmlobjectelement.rs | 18 +- .../components/script/dom/htmlolistelement.rs | 4 +- .../script/dom/htmloptgroupelement.rs | 6 +- .../script/dom/htmloptionelement.rs | 10 +- .../script/dom/htmloptionscollection.rs | 12 +- .../script/dom/htmloutputelement.rs | 14 +- .../script/dom/htmlparagraphelement.rs | 4 +- .../components/script/dom/htmlparamelement.rs | 4 +- servo/components/script/dom/htmlpreelement.rs | 4 +- .../script/dom/htmlprogresselement.rs | 6 +- .../components/script/dom/htmlquoteelement.rs | 4 +- .../script/dom/htmlscriptelement.rs | 9 +- .../script/dom/htmlselectelement.rs | 40 +- .../script/dom/htmlsourceelement.rs | 4 +- .../components/script/dom/htmlspanelement.rs | 4 +- .../components/script/dom/htmlstyleelement.rs | 20 +- .../script/dom/htmltablecaptionelement.rs | 4 +- .../script/dom/htmltablecellelement.rs | 4 +- .../script/dom/htmltablecolelement.rs | 4 +- .../script/dom/htmltabledatacellelement.rs | 4 +- .../components/script/dom/htmltableelement.rs | 48 +-- .../script/dom/htmltableheadercellelement.rs | 4 +- .../script/dom/htmltablerowelement.rs | 14 +- .../script/dom/htmltablesectionelement.rs | 10 +- .../script/dom/htmltemplateelement.rs | 12 +- .../script/dom/htmltextareaelement.rs | 24 +- .../components/script/dom/htmltimeelement.rs | 4 +- .../components/script/dom/htmltitleelement.rs | 4 +- .../components/script/dom/htmltrackelement.rs | 4 +- .../components/script/dom/htmlulistelement.rs | 4 +- .../script/dom/htmlunknownelement.rs | 4 +- .../components/script/dom/htmlvideoelement.rs | 4 +- servo/components/script/dom/imagedata.rs | 10 +- servo/components/script/dom/inputevent.rs | 6 +- servo/components/script/dom/keyboardevent.rs | 18 +- servo/components/script/dom/location.rs | 8 +- servo/components/script/dom/macros.rs | 4 +- servo/components/script/dom/mediaerror.rs | 4 +- servo/components/script/dom/medialist.rs | 8 +- servo/components/script/dom/mediaquerylist.rs | 16 +- .../script/dom/mediaquerylistevent.rs | 8 +- servo/components/script/dom/messageevent.rs | 10 +- servo/components/script/dom/mimetype.rs | 4 +- servo/components/script/dom/mimetypearray.rs | 12 +- servo/components/script/dom/mod.rs | 18 +- servo/components/script/dom/mouseevent.rs | 12 +- .../components/script/dom/mutationobserver.rs | 24 +- servo/components/script/dom/mutationrecord.rs | 42 +- servo/components/script/dom/namednodemap.rs | 28 +- servo/components/script/dom/navigator.rs | 32 +- servo/components/script/dom/node.rs | 266 ++++++------ servo/components/script/dom/nodeiterator.rs | 24 +- servo/components/script/dom/nodelist.rs | 40 +- .../script/dom/pagetransitionevent.rs | 8 +- .../script/dom/paintrenderingcontext2d.rs | 10 +- servo/components/script/dom/paintsize.rs | 4 +- .../script/dom/paintworkletglobalscope.rs | 29 +- servo/components/script/dom/performance.rs | 44 +- .../components/script/dom/performanceentry.rs | 4 +- .../script/dom/performanceobserver.rs | 16 +- .../dom/performanceobserverentrylist.rs | 16 +- .../script/dom/performancepainttiming.rs | 4 +- .../script/dom/performancetiming.rs | 8 +- servo/components/script/dom/permissions.rs | 6 +- .../components/script/dom/permissionstatus.rs | 4 +- servo/components/script/dom/plugin.rs | 10 +- servo/components/script/dom/pluginarray.rs | 12 +- servo/components/script/dom/popstateevent.rs | 8 +- .../script/dom/processinginstruction.rs | 4 +- servo/components/script/dom/progressevent.rs | 8 +- .../script/dom/promisenativehandler.rs | 4 +- servo/components/script/dom/radionodelist.rs | 12 +- servo/components/script/dom/range.rs | 56 +-- servo/components/script/dom/request.rs | 36 +- servo/components/script/dom/response.rs | 50 +-- servo/components/script/dom/screen.rs | 4 +- servo/components/script/dom/serviceworker.rs | 10 +- .../script/dom/serviceworkercontainer.rs | 12 +- .../script/dom/serviceworkerglobalscope.rs | 6 +- .../script/dom/serviceworkerregistration.rs | 32 +- .../script/dom/servoparser/async_html.rs | 40 +- .../components/script/dom/servoparser/html.rs | 32 +- .../components/script/dom/servoparser/mod.rs | 114 ++--- .../components/script/dom/servoparser/xml.rs | 14 +- servo/components/script/dom/storage.rs | 4 +- servo/components/script/dom/storageevent.rs | 14 +- .../script/dom/stylepropertymapreadonly.rs | 15 +- servo/components/script/dom/stylesheet.rs | 4 +- servo/components/script/dom/stylesheetlist.rs | 14 +- servo/components/script/dom/svgsvgelement.rs | 6 +- servo/components/script/dom/testbinding.rs | 40 +- .../script/dom/testbindingiterable.rs | 12 +- .../script/dom/testbindingpairiterable.rs | 12 +- servo/components/script/dom/testrunner.rs | 4 +- servo/components/script/dom/testworklet.rs | 11 +- .../script/dom/testworkletglobalscope.rs | 8 +- servo/components/script/dom/text.rs | 9 +- servo/components/script/dom/textdecoder.rs | 8 +- servo/components/script/dom/textencoder.rs | 6 +- servo/components/script/dom/touch.rs | 10 +- servo/components/script/dom/touchevent.rs | 24 +- servo/components/script/dom/touchlist.rs | 14 +- .../components/script/dom/transitionevent.rs | 6 +- servo/components/script/dom/treewalker.rs | 67 ++- servo/components/script/dom/uievent.rs | 12 +- servo/components/script/dom/url.rs | 16 +- .../components/script/dom/urlsearchparams.rs | 12 +- servo/components/script/dom/validitystate.rs | 8 +- servo/components/script/dom/vr.rs | 38 +- servo/components/script/dom/vrdisplay.rs | 66 +-- .../script/dom/vrdisplaycapabilities.rs | 10 +- servo/components/script/dom/vrdisplayevent.rs | 16 +- .../components/script/dom/vreyeparameters.rs | 18 +- servo/components/script/dom/vrfieldofview.rs | 10 +- servo/components/script/dom/vrframedata.rs | 14 +- servo/components/script/dom/vrpose.rs | 4 +- .../script/dom/vrstageparameters.rs | 10 +- .../ext/oesstandardderivatives.rs | 4 +- .../webgl_extensions/ext/oestexturefloat.rs | 4 +- .../ext/oestexturefloatlinear.rs | 4 +- .../ext/oestexturehalffloat.rs | 4 +- .../ext/oestexturehalffloatlinear.rs | 4 +- .../ext/oesvertexarrayobject.rs | 14 +- .../ext/webglvertexarrayobjectoes.rs | 25 +- .../script/dom/webgl_extensions/extension.rs | 4 +- .../script/dom/webgl_extensions/extensions.rs | 14 +- .../script/dom/webgl_extensions/wrapper.rs | 10 +- .../dom/webgl_validations/tex_image_2d.rs | 6 +- .../components/script/dom/webglactiveinfo.rs | 4 +- servo/components/script/dom/webglbuffer.rs | 12 +- .../script/dom/webglcontextevent.rs | 8 +- .../components/script/dom/webglframebuffer.rs | 36 +- servo/components/script/dom/webglprogram.rs | 14 +- .../script/dom/webglrenderbuffer.rs | 6 +- .../script/dom/webglrenderingcontext.rs | 80 ++-- servo/components/script/dom/webglshader.rs | 16 +- .../script/dom/webglshaderprecisionformat.rs | 4 +- servo/components/script/dom/webgltexture.rs | 12 +- .../script/dom/webgluniformlocation.rs | 4 +- servo/components/script/dom/websocket.rs | 16 +- servo/components/script/dom/window.rs | 120 +++--- servo/components/script/dom/windowproxy.rs | 20 +- servo/components/script/dom/worker.rs | 6 +- .../script/dom/workerglobalscope.rs | 20 +- servo/components/script/dom/workerlocation.rs | 4 +- .../components/script/dom/workernavigator.rs | 8 +- servo/components/script/dom/worklet.rs | 18 +- .../script/dom/workletglobalscope.rs | 10 +- servo/components/script/dom/xmldocument.rs | 6 +- servo/components/script/dom/xmlhttprequest.rs | 86 ++-- .../script/dom/xmlhttprequestupload.rs | 4 +- servo/components/script/fetch.rs | 4 +- servo/components/script/lib.rs | 2 +- servo/components/script/microtask.rs | 8 +- servo/components/script/script_runtime.rs | 2 +- servo/components/script/script_thread.rs | 116 +++--- servo/components/script/serviceworkerjob.rs | 12 +- servo/components/script/test.rs | 4 +- servo/components/script/timers.rs | 10 +- servo/components/script/webdriver_handlers.rs | 4 +- .../script_layout_interface/wrapper_traits.rs | 2 +- .../script_plugins/unrooted_must_root.rs | 4 +- servo/python/tidy/servo_tidy/tidy.py | 10 +- .../tidy/servo_tidy_tests/ban-domrefcell.rs | 8 +- servo/python/tidy/servo_tidy_tests/ban.rs | 2 +- .../python/tidy/servo_tidy_tests/test_tidy.py | 4 +- 308 files changed, 2886 insertions(+), 2895 deletions(-) rename servo/components/script/dom/bindings/{js.rs => root.rs} (73%) diff --git a/servo/components/layout/wrapper.rs b/servo/components/layout/wrapper.rs index 6abe08748b45..27c9475a8b2a 100644 --- a/servo/components/layout/wrapper.rs +++ b/servo/components/layout/wrapper.rs @@ -12,7 +12,7 @@ //! //! 1. Layout is not allowed to mutate the DOM. //! -//! 2. Layout is not allowed to see anything with `LayoutJS` in the name, because it could hang +//! 2. Layout is not allowed to see anything with `LayoutDom` in the name, because it could hang //! onto these objects and cause use-after-free. //! //! When implementing wrapper functions, be careful that you do not touch the borrow flags, or you diff --git a/servo/components/layout_thread/dom_wrapper.rs b/servo/components/layout_thread/dom_wrapper.rs index f5ad43ba3bad..525e1afb5f08 100644 --- a/servo/components/layout_thread/dom_wrapper.rs +++ b/servo/components/layout_thread/dom_wrapper.rs @@ -12,7 +12,7 @@ //! //! 1. Layout is not allowed to mutate the DOM. //! -//! 2. Layout is not allowed to see anything with `LayoutJS` in the name, because it could hang +//! 2. Layout is not allowed to see anything with `LayoutDom` in the name, because it could hang //! onto these objects and cause use-after-free. //! //! When implementing wrapper functions, be careful that you do not touch the borrow flags, or you @@ -44,7 +44,7 @@ use script::layout_exports::{Document, Element, Node, Text}; use script::layout_exports::{HANDLED_SNAPSHOT, HAS_SNAPSHOT}; use script::layout_exports::{LayoutCharacterDataHelpers, LayoutDocumentHelpers}; use script::layout_exports::{LayoutElementHelpers, LayoutNodeHelpers, RawLayoutElementHelpers}; -use script::layout_exports::LayoutJS; +use script::layout_exports::LayoutDom; use script::layout_exports::PendingRestyle; use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress}; use script_layout_interface::{OpaqueStyleAndLayoutData, StyleData}; @@ -87,7 +87,7 @@ pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) { #[derive(Clone, Copy)] pub struct ServoLayoutNode<'a> { /// The wrapped node. - node: LayoutJS, + node: LayoutDom, /// Being chained to a PhantomData prevents `LayoutNode`s from escaping. chain: PhantomData<&'a ()>, @@ -115,7 +115,7 @@ impl<'a> PartialEq for ServoLayoutNode<'a> { } impl<'ln> ServoLayoutNode<'ln> { - fn from_layout_js(n: LayoutJS) -> ServoLayoutNode<'ln> { + fn from_layout_js(n: LayoutDom) -> ServoLayoutNode<'ln> { ServoLayoutNode { node: n, chain: PhantomData, @@ -123,11 +123,11 @@ impl<'ln> ServoLayoutNode<'ln> { } pub unsafe fn new(address: &TrustedNodeAddress) -> ServoLayoutNode { - ServoLayoutNode::from_layout_js(LayoutJS::from_trusted_node_address(*address)) + ServoLayoutNode::from_layout_js(LayoutDom::from_trusted_node_address(*address)) } /// Creates a new layout node with the same lifetime as this layout node. - pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS) -> ServoLayoutNode<'ln> { + pub unsafe fn new_with_this_lifetime(&self, node: &LayoutDom) -> ServoLayoutNode<'ln> { ServoLayoutNode { node: *node, chain: self.chain, @@ -301,9 +301,9 @@ impl<'le> GetLayoutData for ServoThreadSafeLayoutElement<'le> { } impl<'ln> ServoLayoutNode<'ln> { - /// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to + /// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to /// call and as such is marked `unsafe`. - pub unsafe fn get_jsmanaged(&self) -> &LayoutJS { + pub unsafe fn get_jsmanaged(&self) -> &LayoutDom { &self.node } } @@ -311,7 +311,7 @@ impl<'ln> ServoLayoutNode<'ln> { // A wrapper around documents that ensures ayout can only ever access safe properties. #[derive(Clone, Copy)] pub struct ServoLayoutDocument<'ld> { - document: LayoutJS, + document: LayoutDom, chain: PhantomData<&'ld ()>, } @@ -341,7 +341,7 @@ impl<'ld> ServoLayoutDocument<'ld> { unsafe { self.document.style_shared_lock() } } - pub fn from_layout_js(doc: LayoutJS) -> ServoLayoutDocument<'ld> { + pub fn from_layout_js(doc: LayoutDom) -> ServoLayoutDocument<'ld> { ServoLayoutDocument { document: doc, chain: PhantomData, @@ -352,7 +352,7 @@ impl<'ld> ServoLayoutDocument<'ld> { /// A wrapper around elements that ensures layout can only ever access safe properties. #[derive(Clone, Copy)] pub struct ServoLayoutElement<'le> { - element: LayoutJS, + element: LayoutDom, chain: PhantomData<&'le ()>, } @@ -560,7 +560,7 @@ impl<'le> Hash for ServoLayoutElement<'le> { impl<'le> Eq for ServoLayoutElement<'le> {} impl<'le> ServoLayoutElement<'le> { - fn from_layout_js(el: LayoutJS) -> ServoLayoutElement<'le> { + fn from_layout_js(el: LayoutDom) -> ServoLayoutElement<'le> { ServoLayoutElement { element: el, chain: PhantomData, @@ -611,7 +611,7 @@ impl<'le> ServoLayoutElement<'le> { } } -fn as_element<'le>(node: LayoutJS) -> Option> { +fn as_element<'le>(node: LayoutDom) -> Option> { node.downcast().map(ServoLayoutElement::from_layout_js) } @@ -828,7 +828,7 @@ impl<'ln> DangerousThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { impl<'ln> ServoThreadSafeLayoutNode<'ln> { /// Creates a new layout node with the same lifetime as this layout node. - pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS) -> ServoThreadSafeLayoutNode<'ln> { + pub unsafe fn new_with_this_lifetime(&self, node: &LayoutDom) -> ServoThreadSafeLayoutNode<'ln> { ServoThreadSafeLayoutNode { node: self.node.new_with_this_lifetime(node), pseudo: PseudoElementType::Normal, @@ -843,9 +843,9 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> { } } - /// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to + /// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to /// call and as such is marked `unsafe`. - unsafe fn get_jsmanaged(&self) -> &LayoutJS { + unsafe fn get_jsmanaged(&self) -> &LayoutDom { self.node.get_jsmanaged() } } @@ -915,7 +915,7 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { fn is_ignorable_whitespace(&self, context: &SharedStyleContext) -> bool { unsafe { - let text: LayoutJS = match self.get_jsmanaged().downcast() { + let text: LayoutDom = match self.get_jsmanaged().downcast() { Some(text) => text, None => return false }; diff --git a/servo/components/script/body.rs b/servo/components/script/body.rs index 83fe5b119322..bdeff81e1639 100644 --- a/servo/components/script/body.rs +++ b/servo/components/script/body.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::Root; use dom::bindings::reflector::DomObject; +use dom::bindings::root::DomRoot; use dom::bindings::str::USVString; use dom::blob::{Blob, BlobImpl}; use dom::formdata::FormData; @@ -33,8 +33,8 @@ pub enum BodyType { pub enum FetchedData { Text(String), Json(JSValue), - BlobData(Root), - FormData(Root), + BlobData(DomRoot), + FormData(DomRoot), } // https://fetch.spec.whatwg.org/#concept-body-consume-body diff --git a/servo/components/script/devtools.rs b/servo/components/script/devtools.rs index 7172f2bdf9d9..9bcd2376167e 100644 --- a/servo/components/script/devtools.rs +++ b/servo/components/script/devtools.rs @@ -13,8 +13,8 @@ use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, jsstring_to_str}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::DomObject; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::AnimationFrameCallback; use dom::element::Element; @@ -90,7 +90,7 @@ pub fn handle_get_document_element(documents: &Documents, fn find_node_by_unique_id(documents: &Documents, pipeline: PipelineId, node_id: &str) - -> Option> { + -> Option> { documents.find_document(pipeline).and_then(|document| document.upcast::().traverse_preorder().find(|candidate| candidate.unique_id() == node_id) ) diff --git a/servo/components/script/docs/JS-Servos-only-GC.md b/servo/components/script/docs/JS-Servos-only-GC.md index e5549a61063d..f2502691afdc 100644 --- a/servo/components/script/docs/JS-Servos-only-GC.md +++ b/servo/components/script/docs/JS-Servos-only-GC.md @@ -143,7 +143,7 @@ use dom_struct::dom_struct; #[dom_struct] pub struct Document { node: Node, - window: JS, + window: Dom, is_html_document: bool, ... } @@ -164,11 +164,11 @@ relationship. The `Document` just has a pointer to a `Window`, one of many pointers to that object, which can live in native DOM data structures or in JavaScript objects. These are precisely the pointers we need to tell the garbage collector about. We do this with a -[custom type for traced pointers: `JS`][js] (for example, the `JS` -above). The implementation of `trace` for `JS` is not auto-generated; this +[custom type for traced pointers: `Dom`][dom] (for example, the `Dom` +above). The implementation of `trace` for `Dom` is not auto-generated; this is where we actually call the SpiderMonkey trace hooks: -[js]: http://doc.servo.org/script/dom/bindings/js/struct.JS.html +[dom]: http://doc.servo.org/script/dom/bindings/root/struct.Dom.html ```rust pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) { @@ -183,7 +183,7 @@ pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Ref } } -impl JSTraceable for JS { +impl JSTraceable for Dom { unsafe fn trace(&self, trc: *mut JSTracer) { trace_reflector(trc, "", unsafe { (**self.ptr).reflector() }); } @@ -222,22 +222,22 @@ objects. [gc-root]: https://en.wikipedia.org/wiki/Tracing_garbage_collection#Reachability_of_an_object Another common situation is creating a stack-local root manually. For this -purpose, we have a [`Root`][root] struct. When the `Root` is destroyed, +purpose, we have a [`DomRoot`][root] struct. When the `DomRoot` is destroyed, typically at the end of the function (or block) where it was created, its destructor will un-root the DOM object. This is an example of the [RAII idiom][raii], which Rust inherits from C++. -`Root` structs are primarily returned from [`T::new` functions][new] when +`DomRoot` structs are primarily returned from [`T::new` functions][new] when creating a new DOM object. In some cases, we need to use a DOM object longer than the reference we -received allows us to; the [`Root::from_ref` associated function][from-ref] -allows creating a new `Root` struct in that case. +received allows us to; the [`DomRoot::from_ref` associated function][from-ref] +allows creating a new `DomRoot` struct in that case. -[root]: http://doc.servo.org/script/dom/bindings/js/struct.Root.html +[root]: http://doc.servo.org/script/dom/bindings/root/struct.DomRoot.html [raii]: https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization [new]: http://doc.servo.org/script/dom/index.html#construction -[from-ref]: http://doc.servo.org/script/dom/bindings/js/struct.Root.html#method.from_ref +[from-ref]: http://doc.servo.org/script/dom/bindings/root/struct.DomRoot.html#method.from_ref -We can then obtain a reference from the `Root` through Rust's built-in +We can then obtain a reference from the `DomRoot` through Rust's built-in [`Deref` trait][deref], which exposes a method `deref` with the following signature: @@ -249,19 +249,19 @@ pub fn deref<'a>(&'a self) -> &'a T { What this syntax means is: - **`<'a>`**: 'for any lifetime `'a`', -- **`(&'a self)`**: 'take a reference to a `Root` which is valid over lifetime `'a`', +- **`(&'a self)`**: 'take a reference to a `DomRoot` which is valid over lifetime `'a`', - **`-> &'a T`**: 'return a reference whose lifetime is limited to `'a`'. This allows us to call methods and access fields of the underlying type `T` -through a `Root`. +through a `DomRoot`. [deref]: https://doc.rust-lang.org/std/ops/trait.Deref.html -A third way to obtain a reference is from the `JS` struct we encountered -earlier. Whenever we have a reference to a `JS`, we know that the DOM struct +A third way to obtain a reference is from the `Dom` struct we encountered +earlier. Whenever we have a reference to a `Dom`, we know that the DOM struct that contains it is already rooted, and thus that the garbage collector is -aware of the `JS`, and will keep the DOM object it points to alive. -This allows us to implement the `Deref` trait on `JS` as well. +aware of the `Dom`, and will keep the DOM object it points to alive. +This allows us to implement the `Deref` trait on `Dom` as well. The correctness of these APIs is heavily dependent on the fact that the reference cannot outlive the smart pointer it was retrieved from, and the fact @@ -282,10 +282,10 @@ use-after-free and other dangerous bugs. [lifetimes]: https://doc.rust-lang.org/book/lifetimes.html [ti]: https://en.wikipedia.org/wiki/Type_inference -You can check out the [`js` module's documentation][js-docs] for more details +You can check out the [`root` module's documentation][root-docs] for more details that didn't make it into this document. -[js-docs]: http://doc.servo.org/script/dom/bindings/js/index.html +[root-docs]: http://doc.servo.org/script/dom/bindings/root/index.html Custom static analysis ====================== @@ -294,14 +294,14 @@ To recapitulate, the safety of our system depends on two major parts: - The auto-generated `trace` methods ensure that SpiderMonkey's garbage collector can see all of the references between DOM objects. -- The implementation of `Root` guarantees that we can't use a DOM object +- The implementation of `DomRoot` guarantees that we can't use a DOM object from Rust without telling SpiderMonkey about our temporary reference. But there's a hole in this scheme. We could copy an unrooted pointer — a -`JS` — to a local variable on the stack, and then at some later point, root +`Dom` — to a local variable on the stack, and then at some later point, root it and use the DOM object. In the meantime, SpiderMonkey's garbage collector -won't know about that `JS` on the stack, so it might free the DOM object. -To really be safe, we need to make sure that `JS` *only* appears in places +won't know about that `Dom` on the stack, so it might free the DOM object. +To really be safe, we need to make sure that `Dom` *only* appears in places where it will be traced, such as DOM structs, and never in local variables, function arguments, and so forth. @@ -315,10 +315,10 @@ Developing the Servo Web Browser Engine using Rust][lints]. [lints]: http://arxiv.org/pdf/1505.07383v1.pdf We have already [implemented a plugin][js-lint] which effectively forbids -`JS` from appearing on the [stack][stack]. Because lint plugins are part of +`Dom` from appearing on the [stack][stack]. Because lint plugins are part of the usual [warnings infrastructure][warnings], we can use the `allow` attribute -in places where it's okay to use `JS`, like DOM struct definitions and the -implementation of `JS` itself. +in places where it's okay to use `Dom`, like DOM struct definitions and the +implementation of `Dom` itself. [js-lint]: http://doc.servo.org/plugins/lints/unrooted_must_root/struct.UnrootedPass.html [stack]: https://en.wikipedia.org/wiki/Stack-based_memory_allocation diff --git a/servo/components/script/document_loader.rs b/servo/components/script/document_loader.rs index 1073403da7eb..c541882f6219 100644 --- a/servo/components/script/document_loader.rs +++ b/servo/components/script/document_loader.rs @@ -5,7 +5,7 @@ //! Tracking of pending loads in a document. //! https://html.spec.whatwg.org/multipage/#the-end -use dom::bindings::js::JS; +use dom::bindings::root::Dom; use dom::document::Document; use ipc_channel::ipc::IpcSender; use net_traits::{CoreResourceMsg, FetchResponseMsg, ResourceThreads, IpcSend}; @@ -43,7 +43,7 @@ impl LoadType { #[must_root] pub struct LoadBlocker { /// The document whose load event is blocked by this object existing. - doc: JS, + doc: Dom, /// The load that is blocking the document's load event. load: Option, } @@ -53,7 +53,7 @@ impl LoadBlocker { pub fn new(doc: &Document, load: LoadType) -> LoadBlocker { doc.loader_mut().add_blocking_load(load.clone()); LoadBlocker { - doc: JS::from_ref(doc), + doc: Dom::from_ref(doc), load: Some(load), } } diff --git a/servo/components/script/dom/attr.rs b/servo/components/script/dom/attr.rs index 3ce627b46775..10e0ee6bb5c7 100644 --- a/servo/components/script/dom/attr.rs +++ b/servo/components/script/dom/attr.rs @@ -3,11 +3,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use devtools_traits::AttrInfo; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::customelementregistry::CallbackReaction; use dom::element::{AttributeMutation, Element}; @@ -29,10 +29,10 @@ use style::attr::{AttrIdentifier, AttrValue}; pub struct Attr { reflector_: Reflector, identifier: AttrIdentifier, - value: DOMRefCell, + value: DomRefCell, /// the element that owns this attribute. - owner: MutNullableJS, + owner: MutNullableDom, } impl Attr { @@ -51,8 +51,8 @@ impl Attr { namespace: namespace, prefix: prefix, }, - value: DOMRefCell::new(value), - owner: MutNullableJS::new(owner), + value: DomRefCell::new(value), + owner: MutNullableDom::new(owner), } } @@ -63,7 +63,7 @@ impl Attr { namespace: Namespace, prefix: Option, owner: Option<&Element>) - -> Root { + -> DomRoot { reflect_dom_object(box Attr::new_inherited(local_name, value, name, @@ -161,7 +161,7 @@ impl AttrMethods for Attr { } // https://dom.spec.whatwg.org/#dom-attr-ownerelement - fn GetOwnerElement(&self) -> Option> { + fn GetOwnerElement(&self) -> Option> { self.owner() } @@ -232,7 +232,7 @@ impl Attr { self.owner.set(owner); } - pub fn owner(&self) -> Option> { + pub fn owner(&self) -> Option> { self.owner.get() } @@ -256,7 +256,7 @@ pub trait AttrHelpersForLayout { } #[allow(unsafe_code)] -impl AttrHelpersForLayout for LayoutJS { +impl AttrHelpersForLayout for LayoutDom { #[inline] unsafe fn value_forever(&self) -> &'static AttrValue { // This transmute is used to cheat the lifetime restriction. diff --git a/servo/components/script/dom/beforeunloadevent.rs b/servo/components/script/dom/beforeunloadevent.rs index f0b152e0fdda..ad1f3ee2a21a 100644 --- a/servo/components/script/dom/beforeunloadevent.rs +++ b/servo/components/script/dom/beforeunloadevent.rs @@ -4,13 +4,13 @@ #![allow(dead_code)] -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding; use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::window::Window; @@ -21,18 +21,18 @@ use servo_atoms::Atom; #[dom_struct] pub struct BeforeUnloadEvent { event: Event, - return_value: DOMRefCell, + return_value: DomRefCell, } impl BeforeUnloadEvent { fn new_inherited() -> BeforeUnloadEvent { BeforeUnloadEvent { event: Event::new_inherited(), - return_value: DOMRefCell::new(DOMString::new()), + return_value: DomRefCell::new(DOMString::new()), } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { reflect_dom_object(box BeforeUnloadEvent::new_inherited(), window, BeforeUnloadEventBinding::Wrap) @@ -41,7 +41,7 @@ impl BeforeUnloadEvent { pub fn new(window: &Window, type_: Atom, bubbles: EventBubbles, - cancelable: EventCancelable) -> Root { + cancelable: EventCancelable) -> DomRoot { let ev = BeforeUnloadEvent::new_uninitialized(window); { let event = ev.upcast::(); diff --git a/servo/components/script/dom/bindings/callback.rs b/servo/components/script/dom/bindings/callback.rs index 4dfb6584989d..7a73ce602154 100644 --- a/servo/components/script/dom/bindings/callback.rs +++ b/servo/components/script/dom/bindings/callback.rs @@ -5,8 +5,8 @@ //! Base classes to work with IDL callbacks. use dom::bindings::error::{Error, Fallible, report_pending_exception}; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript}; use dom::bindings::utils::AsCCharPtrPtr; use dom::globalscope::GlobalScope; @@ -53,7 +53,7 @@ pub struct CallbackObject { /// /// ["callback context"]: https://heycam.github.io/webidl/#dfn-callback-context /// [sometimes]: https://github.com/whatwg/html/issues/2248 - incumbent: Option> + incumbent: Option> } impl Default for CallbackObject { @@ -69,7 +69,7 @@ impl CallbackObject { CallbackObject { callback: Heap::default(), permanent_js_root: Heap::default(), - incumbent: GlobalScope::incumbent().map(|i| JS::from_ref(&*i)), + incumbent: GlobalScope::incumbent().map(|i| Dom::from_ref(&*i)), } } @@ -120,7 +120,7 @@ pub trait CallbackContainer { /// /// ["callback context"]: https://heycam.github.io/webidl/#dfn-callback-context fn incumbent(&self) -> Option<&GlobalScope> { - self.callback_holder().incumbent.as_ref().map(JS::deref) + self.callback_holder().incumbent.as_ref().map(Dom::deref) } } @@ -223,7 +223,7 @@ pub fn wrap_call_this_object(cx: *mut JSContext, pub struct CallSetup { /// The global for reporting exceptions. This is the global object of the /// (possibly wrapped) callback object. - exception_global: Root, + exception_global: DomRoot, /// The `JSContext` used for the call. cx: *mut JSContext, /// The compartment we were in before the call. diff --git a/servo/components/script/dom/bindings/cell.rs b/servo/components/script/dom/bindings/cell.rs index 8e82de943818..2ae54fce97a1 100644 --- a/servo/components/script/dom/bindings/cell.rs +++ b/servo/components/script/dom/bindings/cell.rs @@ -12,14 +12,14 @@ use style::thread_state; /// This extends the API of `core::cell::RefCell` to allow unsafe access in /// certain situations, with dynamic checking in debug builds. #[derive(Clone, Debug, Default, HeapSizeOf, PartialEq)] -pub struct DOMRefCell { +pub struct DomRefCell { value: RefCell, } -// Functionality specific to Servo's `DOMRefCell` type +// Functionality specific to Servo's `DomRefCell` type // =================================================== -impl DOMRefCell { +impl DomRefCell { /// Return a reference to the contents. /// /// For use in the layout thread only. @@ -59,10 +59,10 @@ impl DOMRefCell { // Functionality duplicated with `core::cell::RefCell` // =================================================== -impl DOMRefCell { - /// Create a new `DOMRefCell` containing `value`. - pub fn new(value: T) -> DOMRefCell { - DOMRefCell { +impl DomRefCell { + /// Create a new `DomRefCell` containing `value`. + pub fn new(value: T) -> DomRefCell { + DomRefCell { value: RefCell::new(value), } } @@ -79,7 +79,7 @@ impl DOMRefCell { /// /// Panics if the value is currently mutably borrowed. pub fn borrow(&self) -> Ref { - self.try_borrow().expect("DOMRefCell already mutably borrowed") + self.try_borrow().expect("DomRefCell already mutably borrowed") } /// Mutably borrows the wrapped value. @@ -93,7 +93,7 @@ impl DOMRefCell { /// /// Panics if the value is currently borrowed. pub fn borrow_mut(&self) -> RefMut { - self.try_borrow_mut().expect("DOMRefCell already borrowed") + self.try_borrow_mut().expect("DomRefCell already borrowed") } /// Attempts to immutably borrow the wrapped value. diff --git a/servo/components/script/dom/bindings/codegen/CodegenRust.py b/servo/components/script/dom/bindings/codegen/CodegenRust.py index 68ab0a33c186..8880707f7d5f 100644 --- a/servo/components/script/dom/bindings/codegen/CodegenRust.py +++ b/servo/components/script/dom/bindings/codegen/CodegenRust.py @@ -1272,7 +1272,7 @@ class CGArgumentConverter(CGThing): arg = "arg%d" % index if argument.type.isGeckoInterface(): init = "rooted_vec!(let mut %s)" % arg - innerConverter.append(CGGeneric("%s.push(JS::from_ref(&*slot));" % arg)) + innerConverter.append(CGGeneric("%s.push(Dom::from_ref(&*slot));" % arg)) else: init = "let mut %s = vec![]" % arg innerConverter.append(CGGeneric("%s.push(slot);" % arg)) @@ -2253,8 +2253,8 @@ def UnionTypes(descriptors, dictionaries, callbacks, typedefs, config): 'dom::bindings::conversions::StringificationBehavior', 'dom::bindings::conversions::root_from_handlevalue', 'dom::bindings::error::throw_not_in_union', - 'dom::bindings::js::Root', 'dom::bindings::mozmap::MozMap', + 'dom::bindings::root::DomRoot', 'dom::bindings::str::ByteString', 'dom::bindings::str::DOMString', 'dom::bindings::str::USVString', @@ -2558,7 +2558,7 @@ class CGWrapMethod(CGAbstractMethod): args = [Argument('*mut JSContext', 'cx'), Argument('&GlobalScope', 'scope'), Argument("Box<%s>" % descriptor.concreteType, 'object')] - retval = 'Root<%s>' % descriptor.concreteType + retval = 'DomRoot<%s>' % descriptor.concreteType CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True, unsafe=True) @@ -2580,7 +2580,7 @@ assert!(!proto.is_null()); %(copyUnforgeable)s (*raw).init_reflector(obj.get()); -Root::from_ref(&*raw)""" % {'copyUnforgeable': unforgeable, 'createObject': create}) +DomRoot::from_ref(&*raw)""" % {'copyUnforgeable': unforgeable, 'createObject': create}) class CGWrapGlobalMethod(CGAbstractMethod): @@ -2592,7 +2592,7 @@ class CGWrapGlobalMethod(CGAbstractMethod): assert descriptor.isGlobal() args = [Argument('*mut JSContext', 'cx'), Argument("Box<%s>" % descriptor.concreteType, 'object')] - retval = 'Root<%s>' % descriptor.concreteType + retval = 'DomRoot<%s>' % descriptor.concreteType CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True, unsafe=True) self.properties = properties @@ -2638,7 +2638,7 @@ assert!(immutable); %(unforgeable)s -Root::from_ref(&*raw)\ +DomRoot::from_ref(&*raw)\ """ % values) @@ -3421,7 +3421,9 @@ class CGAbstractStaticBindingMethod(CGAbstractMethod): def definition_body(self): preamble = "let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n" if len(self.exposureSet) == 1: - preamble += "let global = Root::downcast::(global).unwrap();\n" % list(self.exposureSet)[0] + preamble += """ +let global = DomRoot::downcast::(global).unwrap(); +""" % list(self.exposureSet)[0] return CGList([CGGeneric(preamble), self.generate_code()]) def generate_code(self): @@ -5352,7 +5354,9 @@ class CGClassConstructHook(CGAbstractExternMethod): def definition_body(self): preamble = """let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n""" if len(self.exposureSet) == 1: - preamble += "let global = Root::downcast::(global).unwrap();\n" % list(self.exposureSet)[0] + preamble += """\ +let global = DomRoot::downcast::(global).unwrap(); +""" % list(self.exposureSet)[0] preamble += """let args = CallArgs::from_vp(vp, argc);\n""" preamble = CGGeneric(preamble) if self.constructor.isHTMLConstructor(): @@ -5408,7 +5412,7 @@ if !JS_WrapObject(cx, prototype.handle_mut()) { return false; } -let result: Result, Error> = html_constructor(&global, &args); +let result: Result, Error> = html_constructor(&global, &args); let result = match result { Ok(result) => result, Err(e) => { @@ -5708,14 +5712,14 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries 'dom::bindings::interface::push_new_element_queue', 'dom::bindings::iterable::Iterable', 'dom::bindings::iterable::IteratorType', - 'dom::bindings::js::JS', - 'dom::bindings::js::OptionalHeapSetter', - 'dom::bindings::js::Root', - 'dom::bindings::js::RootedReference', 'dom::bindings::namespace::NamespaceObjectClass', 'dom::bindings::namespace::create_namespace_object', 'dom::bindings::reflector::MutDomObject', 'dom::bindings::reflector::DomObject', + 'dom::bindings::root::Dom', + 'dom::bindings::root::DomRoot', + 'dom::bindings::root::OptionalHeapSetter', + 'dom::bindings::root::RootedReference', 'dom::bindings::utils::AsVoidPtr', 'dom::bindings::utils::DOMClass', 'dom::bindings::utils::DOMJSClass', @@ -6281,7 +6285,7 @@ class CGRegisterProxyHandlers(CGThing): class CGBindingRoot(CGThing): """ - Root codegen class for binding generation. Instantiate the class, and call + DomRoot codegen class for binding generation. Instantiate the class, and call declare or define to generate header or cpp code (respectively). """ def __init__(self, config, prefix, webIDLFile): @@ -6961,7 +6965,7 @@ class CallbackGetter(CallbackMember): needThisHandling=False) def getRvalDecl(self): - return "JS::Rooted rval(cx, JS::UndefinedValue());\n" + return "Dom::Rooted rval(cx, JS::UndefinedValue());\n" def getCall(self): replacements = { @@ -7195,7 +7199,7 @@ class GlobalGenRoots(): imports = [CGGeneric("use dom::types::*;\n"), CGGeneric("use dom::bindings::conversions::{DerivedFrom, get_dom_class};\n"), CGGeneric("use dom::bindings::inheritance::Castable;\n"), - CGGeneric("use dom::bindings::js::{JS, LayoutJS, Root};\n"), + CGGeneric("use dom::bindings::root::{Dom, DomRoot, LayoutDom};\n"), CGGeneric("use dom::bindings::trace::JSTraceable;\n"), CGGeneric("use dom::bindings::reflector::DomObject;\n"), CGGeneric("use js::jsapi::JSTracer;\n\n"), diff --git a/servo/components/script/dom/bindings/codegen/Configuration.py b/servo/components/script/dom/bindings/codegen/Configuration.py index df6c0a36c76a..56141e52b09c 100644 --- a/servo/components/script/dom/bindings/codegen/Configuration.py +++ b/servo/components/script/dom/bindings/codegen/Configuration.py @@ -212,7 +212,7 @@ class Descriptor(DescriptorProvider): self.argumentType = "???" self.nativeType = ty else: - self.returnType = "Root<%s>" % typeName + self.returnType = "DomRoot<%s>" % typeName self.argumentType = "&%s" % typeName self.nativeType = "*const %s" % typeName if self.interface.isIteratorInterface(): diff --git a/servo/components/script/dom/bindings/conversions.rs b/servo/components/script/dom/bindings/conversions.rs index 69751f2c263b..075f681308e2 100644 --- a/servo/components/script/dom/bindings/conversions.rs +++ b/servo/components/script/dom/bindings/conversions.rs @@ -24,7 +24,7 @@ //! | USVString | `USVString` | //! | ByteString | `ByteString` | //! | object | `*mut JSObject` | -//! | interface types | `&T` | `Root` | +//! | interface types | `&T` | `DomRoot` | //! | dictionary types | `&T` | *unsupported* | //! | enumeration types | `T` | //! | callback function types | `Rc` | @@ -34,9 +34,9 @@ use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::{DomObject, Reflector}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{ByteString, DOMString, USVString}; use dom::bindings::trace::{JSTraceable, RootedTraceableBox}; use dom::bindings::utils::DOMClass; @@ -102,13 +102,13 @@ impl> FromJSValConvertible for Finite } } -impl FromJSValConvertible for Root { +impl FromJSValConvertible for DomRoot { type Config = (); unsafe fn from_jsval(_cx: *mut JSContext, value: HandleValue, _config: Self::Config) - -> Result>, ()> { + -> Result>, ()> { Ok(match root_from_handlevalue(value) { Ok(result) => ConversionResult::Success(result), Err(()) => ConversionResult::Failure("value is not an object".into()), @@ -405,16 +405,16 @@ pub fn native_from_object(obj: *mut JSObject) -> Result<*const T, ()> } } -/// Get a `Root` for the given DOM object, unwrapping any wrapper +/// Get a `DomRoot` for the given DOM object, unwrapping any wrapper /// around it first, and checking if the object is of the correct type. /// /// Returns Err(()) if `obj` is an opaque security wrapper or if the object is /// not a reflector for a DOM object of the given type (as defined by the /// proto_id and proto_depth). -pub fn root_from_object(obj: *mut JSObject) -> Result, ()> +pub fn root_from_object(obj: *mut JSObject) -> Result, ()> where T: DomObject + IDLInterface { - native_from_object(obj).map(|ptr| unsafe { Root::from_ref(&*ptr) }) + native_from_object(obj).map(|ptr| unsafe { DomRoot::from_ref(&*ptr) }) } /// Get a `*const T` for a DOM object accessible from a `HandleValue`. @@ -428,9 +428,9 @@ pub fn native_from_handlevalue(v: HandleValue) -> Result<*const T, ()> native_from_object(v.get().to_object()) } -/// Get a `Root` for a DOM object accessible from a `HandleValue`. +/// Get a `DomRoot` for a DOM object accessible from a `HandleValue`. /// Caller is responsible for throwing a JS exception if needed in case of error. -pub fn root_from_handlevalue(v: HandleValue) -> Result, ()> +pub fn root_from_handlevalue(v: HandleValue) -> Result, ()> where T: DomObject + IDLInterface { if !v.get().is_object() { @@ -439,14 +439,14 @@ pub fn root_from_handlevalue(v: HandleValue) -> Result, ()> root_from_object(v.get().to_object()) } -/// Get a `Root` for a DOM object accessible from a `HandleObject`. -pub fn root_from_handleobject(obj: HandleObject) -> Result, ()> +/// Get a `DomRoot` for a DOM object accessible from a `HandleObject`. +pub fn root_from_handleobject(obj: HandleObject) -> Result, ()> where T: DomObject + IDLInterface { root_from_object(obj.get()) } -impl ToJSValConvertible for Root { +impl ToJSValConvertible for DomRoot { unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { self.reflector().to_jsval(cx, rval); } diff --git a/servo/components/script/dom/bindings/interface.rs b/servo/components/script/dom/bindings/interface.rs index c242bd7f0650..5604d33aa290 100644 --- a/servo/components/script/dom/bindings/interface.rs +++ b/servo/components/script/dom/bindings/interface.rs @@ -77,7 +77,7 @@ use dom::bindings::constant::{ConstantSpec, define_constants}; use dom::bindings::conversions::{DOM_OBJECT_SLOT, DerivedFrom, get_dom_class}; use dom::bindings::error::{Error, Fallible}; use dom::bindings::guard::Guard; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::utils::{DOM_PROTOTYPE_SLOT, ProtoOrIfaceArray, get_proto_or_iface_array}; use dom::create::create_native_html_element; use dom::customelementregistry::ConstructionStackEntry; @@ -236,7 +236,7 @@ pub unsafe fn create_global_object( } // https://html.spec.whatwg.org/multipage/#htmlconstructor -pub unsafe fn html_constructor(window: &Window, call_args: &CallArgs) -> Fallible> +pub unsafe fn html_constructor(window: &Window, call_args: &CallArgs) -> Fallible> where T: DerivedFrom { let document = window.Document(); @@ -289,7 +289,7 @@ pub unsafe fn html_constructor(window: &Window, call_args: &CallArgs) -> Fall // Step 8.1 let name = QualName::new(None, ns!(html), definition.local_name.clone()); let element = if definition.is_autonomous() { - Root::upcast(HTMLElement::new(name.local, None, &*document)) + DomRoot::upcast(HTMLElement::new(name.local, None, &*document)) } else { create_native_html_element(name, None, &*document, ElementCreator::ScriptCreated) }; @@ -303,7 +303,7 @@ pub unsafe fn html_constructor(window: &Window, call_args: &CallArgs) -> Fall element.set_custom_element_definition(definition.clone()); // Step 8.5 - Root::downcast(element).ok_or(Error::InvalidState) + DomRoot::downcast(element).ok_or(Error::InvalidState) }, // Step 9 Some(ConstructionStackEntry::Element(element)) => { @@ -315,7 +315,7 @@ pub unsafe fn html_constructor(window: &Window, call_args: &CallArgs) -> Fall construction_stack.push(ConstructionStackEntry::AlreadyConstructedMarker); // Step 13 - Root::downcast(element).ok_or(Error::InvalidState) + DomRoot::downcast(element).ok_or(Error::InvalidState) }, // Step 10 Some(ConstructionStackEntry::AlreadyConstructedMarker) => Err(Error::InvalidState), diff --git a/servo/components/script/dom/bindings/iterable.rs b/servo/components/script/dom/bindings/iterable.rs index 7926ff54173a..fbb9894210ea 100644 --- a/servo/components/script/dom/bindings/iterable.rs +++ b/servo/components/script/dom/bindings/iterable.rs @@ -10,8 +10,8 @@ use core::nonzero::NonZero; use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndValueResult; use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -51,7 +51,7 @@ pub trait Iterable { #[dom_struct] pub struct IterableIterator { reflector: Reflector, - iterable: JS, + iterable: Dom, type_: IteratorType, index: Cell, } @@ -61,11 +61,11 @@ impl IterableIterator { pub fn new(iterable: &T, type_: IteratorType, wrap: unsafe fn(*mut JSContext, &GlobalScope, Box>) - -> Root) -> Root { + -> DomRoot) -> DomRoot { let iterator = box IterableIterator { reflector: Reflector::new(), type_: type_, - iterable: JS::from_ref(iterable), + iterable: Dom::from_ref(iterable), index: Cell::new(0), }; reflect_dom_object(iterator, &*iterable.global(), wrap) diff --git a/servo/components/script/dom/bindings/mod.rs b/servo/components/script/dom/bindings/mod.rs index 5d0cd864dad7..f251f0bd364c 100644 --- a/servo/components/script/dom/bindings/mod.rs +++ b/servo/components/script/dom/bindings/mod.rs @@ -142,13 +142,13 @@ pub mod guard; pub mod inheritance; pub mod interface; pub mod iterable; -pub mod js; pub mod mozmap; pub mod namespace; pub mod num; pub mod proxyhandler; pub mod refcounted; pub mod reflector; +pub mod root; pub mod settings_stack; pub mod str; pub mod structuredclone; diff --git a/servo/components/script/dom/bindings/refcounted.rs b/servo/components/script/dom/bindings/refcounted.rs index 0a00148d6617..02f6784fb2f8 100644 --- a/servo/components/script/dom/bindings/refcounted.rs +++ b/servo/components/script/dom/bindings/refcounted.rs @@ -25,8 +25,8 @@ use core::nonzero::NonZero; use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::error::Error; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector}; +use dom::bindings::root::DomRoot; use dom::bindings::trace::trace_reflector; use dom::promise::Promise; use js::jsapi::JSTracer; @@ -178,14 +178,14 @@ impl Trusted { /// Obtain a usable DOM pointer from a pinned `Trusted` value. Fails if used on /// a different thread than the original value from which this `Trusted` was /// obtained. - pub fn root(&self) -> Root { + pub fn root(&self) -> DomRoot { assert!(LIVE_REFERENCES.with(|ref r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); self.owner_thread == (&*live_references) as *const _ as *const libc::c_void })); unsafe { - Root::new(NonZero::new_unchecked(self.refcount.0 as *const T)) + DomRoot::new(NonZero::new_unchecked(self.refcount.0 as *const T)) } } } diff --git a/servo/components/script/dom/bindings/reflector.rs b/servo/components/script/dom/bindings/reflector.rs index 896cf74a34f9..de6c8ab7c815 100644 --- a/servo/components/script/dom/bindings/reflector.rs +++ b/servo/components/script/dom/bindings/reflector.rs @@ -5,7 +5,7 @@ //! The `Reflector` struct. use dom::bindings::conversions::DerivedFrom; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use js::jsapi::{HandleObject, JSContext, JSObject, Heap}; use std::default::Default; @@ -15,8 +15,8 @@ use std::default::Default; pub fn reflect_dom_object( obj: Box, global: &U, - wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box) -> Root) - -> Root + wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box) -> DomRoot) + -> DomRoot where T: DomObject, U: DerivedFrom { let global_scope = global.upcast(); @@ -77,7 +77,7 @@ pub trait DomObject { fn reflector(&self) -> &Reflector; /// Returns the global scope of the realm that the DomObject was created in. - fn global(&self) -> Root where Self: Sized { + fn global(&self) -> DomRoot where Self: Sized { GlobalScope::from_reflector(self) } } diff --git a/servo/components/script/dom/bindings/js.rs b/servo/components/script/dom/bindings/root.rs similarity index 73% rename from servo/components/script/dom/bindings/js.rs rename to servo/components/script/dom/bindings/root.rs index 07dc4d747784..1a81965fef97 100644 --- a/servo/components/script/dom/bindings/js.rs +++ b/servo/components/script/dom/bindings/root.rs @@ -11,16 +11,16 @@ //! //! Here is a brief overview of the important types: //! -//! - `Root`: a stack-based reference to a rooted DOM object. -//! - `JS`: a reference to a DOM object that can automatically be traced by +//! - `DomRoot`: a stack-based reference to a rooted DOM object. +//! - `Dom`: a reference to a DOM object that can automatically be traced by //! the GC when encountered as a field of a Rust structure. //! -//! `JS` does not allow access to their inner value without explicitly -//! creating a stack-based root via the `root` method. This returns a `Root`, +//! `Dom` does not allow access to their inner value without explicitly +//! creating a stack-based root via the `root` method. This returns a `DomRoot`, //! which causes the JS-owned value to be uncollectable for the duration of the //! `Root` object's lifetime. A reference to the object can then be obtained //! from the `Root` object. These references are not allowed to outlive their -//! originating `Root`. +//! originating `DomRoot`. //! use core::nonzero::NonZero; @@ -50,63 +50,63 @@ use style::thread_state; /// A traced reference to a DOM object /// /// This type is critical to making garbage collection work with the DOM, -/// but it is very dangerous; if garbage collection happens with a `JS` -/// on the stack, the `JS` can point to freed memory. +/// but it is very dangerous; if garbage collection happens with a `Dom` +/// on the stack, the `Dom` can point to freed memory. /// /// This should only be used as a field in other DOM objects. #[must_root] -pub struct JS { +pub struct Dom { ptr: NonZero<*const T>, } -// JS is similar to Rc, in that it's not always clear how to avoid double-counting. +// Dom is similar to Rc, in that it's not always clear how to avoid double-counting. // For now, we choose not to follow any such pointers. -impl HeapSizeOf for JS { +impl HeapSizeOf for Dom { fn heap_size_of_children(&self) -> usize { 0 } } -impl JS { - /// Returns `LayoutJS` containing the same pointer. - pub unsafe fn to_layout(&self) -> LayoutJS { +impl Dom { + /// Returns `LayoutDom` containing the same pointer. + pub unsafe fn to_layout(&self) -> LayoutDom { debug_assert!(thread_state::get().is_layout()); - LayoutJS { + LayoutDom { ptr: self.ptr.clone(), } } } -impl JS { - /// Create a JS from a &T +impl Dom { + /// Create a Dom from a &T #[allow(unrooted_must_root)] - pub fn from_ref(obj: &T) -> JS { + pub fn from_ref(obj: &T) -> Dom { debug_assert!(thread_state::get().is_script()); - JS { + Dom { ptr: unsafe { NonZero::new_unchecked(&*obj) }, } } } -impl<'root, T: DomObject + 'root> RootedReference<'root> for JS { +impl<'root, T: DomObject + 'root> RootedReference<'root> for Dom { type Ref = &'root T; fn r(&'root self) -> &'root T { &self } } -impl Deref for JS { +impl Deref for Dom { type Target = T; fn deref(&self) -> &T { debug_assert!(thread_state::get().is_script()); - // We can only have &JS from a rooted thing, so it's safe to deref + // We can only have &Dom from a rooted thing, so it's safe to deref // it to &T. unsafe { &*self.ptr.get() } } } -unsafe impl JSTraceable for JS { +unsafe impl JSTraceable for Dom { unsafe fn trace(&self, trc: *mut JSTracer) { #[cfg(debug_assertions)] let trace_str = format!("for {} on heap", type_name::()); @@ -124,32 +124,32 @@ unsafe impl JSTraceable for JS { /// An unrooted reference to a DOM object for use in layout. `Layout*Helpers` /// traits must be implemented on this. #[allow_unrooted_interior] -pub struct LayoutJS { +pub struct LayoutDom { ptr: NonZero<*const T>, } -impl LayoutJS { +impl LayoutDom { /// Cast a DOM object root upwards to one of the interfaces it derives from. - pub fn upcast(&self) -> LayoutJS + pub fn upcast(&self) -> LayoutDom where U: Castable, T: DerivedFrom { debug_assert!(thread_state::get().is_layout()); let ptr: *const T = self.ptr.get(); - LayoutJS { + LayoutDom { ptr: unsafe { NonZero::new_unchecked(ptr as *const U) }, } } /// Cast a DOM object downwards to one of the interfaces it might implement. - pub fn downcast(&self) -> Option> + pub fn downcast(&self) -> Option> where U: DerivedFrom { debug_assert!(thread_state::get().is_layout()); unsafe { if (*self.unsafe_get()).is::() { let ptr: *const T = self.ptr.get(); - Some(LayoutJS { + Some(LayoutDom { ptr: NonZero::new_unchecked(ptr as *const U), }) } else { @@ -159,7 +159,7 @@ impl LayoutJS { } } -impl LayoutJS { +impl LayoutDom { /// Get the reflector. pub unsafe fn get_jsobject(&self) -> *mut JSObject { debug_assert!(thread_state::get().is_layout()); @@ -167,114 +167,114 @@ impl LayoutJS { } } -impl Copy for LayoutJS {} +impl Copy for LayoutDom {} -impl PartialEq for JS { - fn eq(&self, other: &JS) -> bool { +impl PartialEq for Dom { + fn eq(&self, other: &Dom) -> bool { self.ptr == other.ptr } } -impl Eq for JS {} +impl Eq for Dom {} -impl PartialEq for LayoutJS { - fn eq(&self, other: &LayoutJS) -> bool { +impl PartialEq for LayoutDom { + fn eq(&self, other: &LayoutDom) -> bool { self.ptr == other.ptr } } -impl Eq for LayoutJS {} +impl Eq for LayoutDom {} -impl Hash for JS { +impl Hash for Dom { fn hash(&self, state: &mut H) { self.ptr.hash(state) } } -impl Hash for LayoutJS { +impl Hash for LayoutDom { fn hash(&self, state: &mut H) { self.ptr.hash(state) } } -impl Clone for JS { +impl Clone for Dom { #[inline] #[allow(unrooted_must_root)] - fn clone(&self) -> JS { + fn clone(&self) -> Dom { debug_assert!(thread_state::get().is_script()); - JS { + Dom { ptr: self.ptr.clone(), } } } -impl Clone for LayoutJS { +impl Clone for LayoutDom { #[inline] - fn clone(&self) -> LayoutJS { + fn clone(&self) -> LayoutDom { debug_assert!(thread_state::get().is_layout()); - LayoutJS { + LayoutDom { ptr: self.ptr.clone(), } } } -impl LayoutJS { +impl LayoutDom { /// Create a new JS-owned value wrapped from an address known to be a /// `Node` pointer. - pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutJS { + pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutDom { debug_assert!(thread_state::get().is_layout()); let TrustedNodeAddress(addr) = inner; - LayoutJS { + LayoutDom { ptr: NonZero::new_unchecked(addr as *const Node), } } } /// A holder that provides interior mutability for GC-managed values such as -/// `JS`. Essentially a `Cell>`, but safer. +/// `Dom`. Essentially a `Cell>`, but safer. /// /// This should only be used as a field in other DOM objects; see warning -/// on `JS`. +/// on `Dom`. #[must_root] #[derive(JSTraceable)] -pub struct MutJS { - val: UnsafeCell>, +pub struct MutDom { + val: UnsafeCell>, } -impl MutJS { - /// Create a new `MutJS`. - pub fn new(initial: &T) -> MutJS { +impl MutDom { + /// Create a new `MutDom`. + pub fn new(initial: &T) -> MutDom { debug_assert!(thread_state::get().is_script()); - MutJS { - val: UnsafeCell::new(JS::from_ref(initial)), + MutDom { + val: UnsafeCell::new(Dom::from_ref(initial)), } } - /// Set this `MutJS` to the given value. + /// Set this `MutDom` to the given value. pub fn set(&self, val: &T) { debug_assert!(thread_state::get().is_script()); unsafe { - *self.val.get() = JS::from_ref(val); + *self.val.get() = Dom::from_ref(val); } } - /// Get the value in this `MutJS`. - pub fn get(&self) -> Root { + /// Get the value in this `MutDom`. + pub fn get(&self) -> DomRoot { debug_assert!(thread_state::get().is_script()); unsafe { - Root::from_ref(&*ptr::read(self.val.get())) + DomRoot::from_ref(&*ptr::read(self.val.get())) } } } -impl HeapSizeOf for MutJS { +impl HeapSizeOf for MutDom { fn heap_size_of_children(&self) -> usize { - // See comment on HeapSizeOf for JS. + // See comment on HeapSizeOf for Dom. 0 } } -impl PartialEq for MutJS { +impl PartialEq for MutDom { fn eq(&self, other: &Self) -> bool { unsafe { *self.val.get() == *other.val.get() @@ -282,7 +282,7 @@ impl PartialEq for MutJS { } } -impl PartialEq for MutJS { +impl PartialEq for MutDom { fn eq(&self, other: &T) -> bool { unsafe { **self.val.get() == *other @@ -291,30 +291,30 @@ impl PartialEq for MutJS { } /// A holder that provides interior mutability for GC-managed values such as -/// `JS`, with nullability represented by an enclosing Option wrapper. -/// Essentially a `Cell>>`, but safer. +/// `Dom`, with nullability represented by an enclosing Option wrapper. +/// Essentially a `Cell>>`, but safer. /// /// This should only be used as a field in other DOM objects; see warning -/// on `JS`. +/// on `Dom`. #[must_root] #[derive(JSTraceable)] -pub struct MutNullableJS { - ptr: UnsafeCell>>, +pub struct MutNullableDom { + ptr: UnsafeCell>>, } -impl MutNullableJS { - /// Create a new `MutNullableJS`. - pub fn new(initial: Option<&T>) -> MutNullableJS { +impl MutNullableDom { + /// Create a new `MutNullableDom`. + pub fn new(initial: Option<&T>) -> MutNullableDom { debug_assert!(thread_state::get().is_script()); - MutNullableJS { - ptr: UnsafeCell::new(initial.map(JS::from_ref)), + MutNullableDom { + ptr: UnsafeCell::new(initial.map(Dom::from_ref)), } } /// Retrieve a copy of the current inner value. If it is `None`, it is /// initialized with the result of `cb` first. - pub fn or_init(&self, cb: F) -> Root - where F: FnOnce() -> Root + pub fn or_init(&self, cb: F) -> DomRoot + where F: FnOnce() -> DomRoot { debug_assert!(thread_state::get().is_script()); match self.get() { @@ -327,40 +327,40 @@ impl MutNullableJS { } } - /// Retrieve a copy of the inner optional `JS` as `LayoutJS`. + /// Retrieve a copy of the inner optional `Dom` as `LayoutDom`. /// For use by layout, which can't use safe types like Temporary. #[allow(unrooted_must_root)] - pub unsafe fn get_inner_as_layout(&self) -> Option> { + pub unsafe fn get_inner_as_layout(&self) -> Option> { debug_assert!(thread_state::get().is_layout()); ptr::read(self.ptr.get()).map(|js| js.to_layout()) } /// Get a rooted value out of this object #[allow(unrooted_must_root)] - pub fn get(&self) -> Option> { + pub fn get(&self) -> Option> { debug_assert!(thread_state::get().is_script()); unsafe { - ptr::read(self.ptr.get()).map(|o| Root::from_ref(&*o)) + ptr::read(self.ptr.get()).map(|o| DomRoot::from_ref(&*o)) } } - /// Set this `MutNullableJS` to the given value. + /// Set this `MutNullableDom` to the given value. pub fn set(&self, val: Option<&T>) { debug_assert!(thread_state::get().is_script()); unsafe { - *self.ptr.get() = val.map(|p| JS::from_ref(p)); + *self.ptr.get() = val.map(|p| Dom::from_ref(p)); } } /// Gets the current value out of this object and sets it to `None`. - pub fn take(&self) -> Option> { + pub fn take(&self) -> Option> { let value = self.get(); self.set(None); value } } -impl PartialEq for MutNullableJS { +impl PartialEq for MutNullableDom { fn eq(&self, other: &Self) -> bool { unsafe { *self.ptr.get() == *other.ptr.get() @@ -368,73 +368,73 @@ impl PartialEq for MutNullableJS { } } -impl<'a, T: DomObject> PartialEq> for MutNullableJS { +impl<'a, T: DomObject> PartialEq> for MutNullableDom { fn eq(&self, other: &Option<&T>) -> bool { unsafe { - *self.ptr.get() == other.map(JS::from_ref) + *self.ptr.get() == other.map(Dom::from_ref) } } } -impl Default for MutNullableJS { +impl Default for MutNullableDom { #[allow(unrooted_must_root)] - fn default() -> MutNullableJS { + fn default() -> MutNullableDom { debug_assert!(thread_state::get().is_script()); - MutNullableJS { + MutNullableDom { ptr: UnsafeCell::new(None), } } } -impl HeapSizeOf for MutNullableJS { +impl HeapSizeOf for MutNullableDom { fn heap_size_of_children(&self) -> usize { - // See comment on HeapSizeOf for JS. + // See comment on HeapSizeOf for Dom. 0 } } /// A holder that allows to lazily initialize the value only once -/// `JS`, using OnceCell -/// Essentially a `OnceCell>`. +/// `Dom`, using OnceCell +/// Essentially a `OnceCell>`. /// /// This should only be used as a field in other DOM objects; see warning -/// on `JS`. +/// on `Dom`. #[must_root] -pub struct OnceCellJS { - ptr: OnceCell>, +pub struct DomOnceCell { + ptr: OnceCell>, } -impl OnceCellJS { +impl DomOnceCell { /// Retrieve a copy of the current inner value. If it is `None`, it is /// initialized with the result of `cb` first. #[allow(unrooted_must_root)] pub fn init_once(&self, cb: F) -> &T - where F: FnOnce() -> Root + where F: FnOnce() -> DomRoot { debug_assert!(thread_state::get().is_script()); - &self.ptr.init_once(|| JS::from_ref(&cb())) + &self.ptr.init_once(|| Dom::from_ref(&cb())) } } -impl Default for OnceCellJS { +impl Default for DomOnceCell { #[allow(unrooted_must_root)] - fn default() -> OnceCellJS { + fn default() -> DomOnceCell { debug_assert!(thread_state::get().is_script()); - OnceCellJS { + DomOnceCell { ptr: OnceCell::new(), } } } -impl HeapSizeOf for OnceCellJS { +impl HeapSizeOf for DomOnceCell { fn heap_size_of_children(&self) -> usize { - // See comment on HeapSizeOf for JS. + // See comment on HeapSizeOf for Dom. 0 } } #[allow(unrooted_must_root)] -unsafe impl JSTraceable for OnceCellJS { +unsafe impl JSTraceable for DomOnceCell { unsafe fn trace(&self, trc: *mut JSTracer) { if let Some(ptr) = self.ptr.as_ref() { ptr.trace(trc); @@ -442,7 +442,7 @@ unsafe impl JSTraceable for OnceCellJS { } } -impl LayoutJS { +impl LayoutDom { /// Returns an unsafe pointer to the interior of this JS object. This is /// the only method that be safely accessed from layout. (The fact that /// this is unsafe is what necessitates the layout wrappers.) @@ -468,7 +468,7 @@ pub trait RootedReference<'root> { fn r(&'root self) -> Self::Ref; } -impl<'root, T: JSTraceable + DomObject + 'root> RootedReference<'root> for [JS] { +impl<'root, T: JSTraceable + DomObject + 'root> RootedReference<'root> for [Dom] { type Ref = &'root [&'root T]; fn r(&'root self) -> &'root [&'root T] { unsafe { mem::transmute(self) } @@ -559,16 +559,16 @@ pub unsafe fn trace_roots(tracer: *mut JSTracer) { /// for the same JS value. `Root`s cannot outlive the associated /// `RootCollection` object. #[allow_unrooted_interior] -pub struct Root { +pub struct DomRoot { /// Reference to rooted value that must not outlive this container ptr: NonZero<*const T>, /// List that ensures correct dynamic root ordering root_list: *const RootCollection, } -impl Root { +impl DomRoot { /// Cast a DOM object root upwards to one of the interfaces it derives from. - pub fn upcast(root: Root) -> Root + pub fn upcast(root: DomRoot) -> DomRoot where U: Castable, T: DerivedFrom { @@ -576,7 +576,7 @@ impl Root { } /// Cast a DOM object root downwards to one of the interfaces it might implement. - pub fn downcast(root: Root) -> Option> + pub fn downcast(root: DomRoot) -> Option> where U: DerivedFrom { if root.is::() { @@ -587,16 +587,16 @@ impl Root { } } -impl Root { +impl DomRoot { /// Create a new stack-bounded root for the provided JS-owned value. /// It cannot outlive its associated `RootCollection`, and it gives /// out references which cannot outlive this new `Root`. - pub fn new(unrooted: NonZero<*const T>) -> Root { + pub fn new(unrooted: NonZero<*const T>) -> DomRoot { debug_assert!(thread_state::get().is_script()); STACK_ROOTS.with(|ref collection| { let RootCollectionPtr(collection) = collection.get().unwrap(); unsafe { (*collection).root(&*(*unrooted.get()).reflector()) } - Root { + DomRoot { ptr: unrooted, root_list: collection, } @@ -604,19 +604,19 @@ impl Root { } /// Generate a new root from a reference - pub fn from_ref(unrooted: &T) -> Root { - Root::new(unsafe { NonZero::new_unchecked(unrooted) }) + pub fn from_ref(unrooted: &T) -> DomRoot { + DomRoot::new(unsafe { NonZero::new_unchecked(unrooted) }) } } -impl<'root, T: DomObject + 'root> RootedReference<'root> for Root { +impl<'root, T: DomObject + 'root> RootedReference<'root> for DomRoot { type Ref = &'root T; fn r(&'root self) -> &'root T { self } } -impl Deref for Root { +impl Deref for DomRoot { type Target = T; fn deref(&self) -> &T { debug_assert!(thread_state::get().is_script()); @@ -624,25 +624,25 @@ impl Deref for Root { } } -impl HeapSizeOf for Root { +impl HeapSizeOf for DomRoot { fn heap_size_of_children(&self) -> usize { (**self).heap_size_of_children() } } -impl PartialEq for Root { +impl PartialEq for DomRoot { fn eq(&self, other: &Self) -> bool { self.ptr == other.ptr } } -impl Clone for Root { - fn clone(&self) -> Root { - Root::from_ref(&*self) +impl Clone for DomRoot { + fn clone(&self) -> DomRoot { + DomRoot::from_ref(&*self) } } -impl Drop for Root { +impl Drop for DomRoot { fn drop(&mut self) { unsafe { (*self.root_list).unroot(self.reflector()); @@ -650,7 +650,7 @@ impl Drop for Root { } } -unsafe impl JSTraceable for Root { +unsafe impl JSTraceable for DomRoot { unsafe fn trace(&self, _: *mut JSTracer) { // Already traced. } diff --git a/servo/components/script/dom/bindings/settings_stack.rs b/servo/components/script/dom/bindings/settings_stack.rs index bf67bae5f3f8..fb708d1b2356 100644 --- a/servo/components/script/dom/bindings/settings_stack.rs +++ b/servo/components/script/dom/bindings/settings_stack.rs @@ -2,7 +2,7 @@ * 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/. */ -use dom::bindings::js::{JS, Root}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use js::jsapi::GetScriptedCallerGlobal; @@ -24,7 +24,7 @@ enum StackEntryKind { #[allow(unrooted_must_root)] #[derive(JSTraceable)] struct StackEntry { - global: JS, + global: Dom, kind: StackEntryKind, } @@ -37,7 +37,7 @@ pub unsafe fn trace(tracer: *mut JSTracer) { /// RAII struct that pushes and pops entries from the script settings stack. pub struct AutoEntryScript { - global: Root, + global: DomRoot, } impl AutoEntryScript { @@ -47,11 +47,11 @@ impl AutoEntryScript { trace!("Prepare to run script with {:p}", global); let mut stack = stack.borrow_mut(); stack.push(StackEntry { - global: JS::from_ref(global), + global: Dom::from_ref(global), kind: StackEntryKind::Entry, }); AutoEntryScript { - global: Root::from_ref(global), + global: DomRoot::from_ref(global), } }) } @@ -80,13 +80,13 @@ impl Drop for AutoEntryScript { /// Returns the ["entry"] global object. /// /// ["entry"]: https://html.spec.whatwg.org/multipage/#entry -pub fn entry_global() -> Root { +pub fn entry_global() -> DomRoot { STACK.with(|stack| { stack.borrow() .iter() .rev() .find(|entry| entry.kind == StackEntryKind::Entry) - .map(|entry| Root::from_ref(&*entry.global)) + .map(|entry| DomRoot::from_ref(&*entry.global)) }).unwrap() } @@ -109,7 +109,7 @@ impl AutoIncumbentScript { // Step 1. let mut stack = stack.borrow_mut(); stack.push(StackEntry { - global: JS::from_ref(global), + global: Dom::from_ref(global), kind: StackEntryKind::Incumbent, }); AutoIncumbentScript { @@ -145,7 +145,7 @@ impl Drop for AutoIncumbentScript { /// Returns the ["incumbent"] global object. /// /// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent -pub fn incumbent_global() -> Option> { +pub fn incumbent_global() -> Option> { // https://html.spec.whatwg.org/multipage/#incumbent-settings-object // Step 1, 3: See what the JS engine has to say. If we've got a scripted @@ -165,6 +165,6 @@ pub fn incumbent_global() -> Option> { STACK.with(|stack| { stack.borrow() .last() - .map(|entry| Root::from_ref(&*entry.global)) + .map(|entry| DomRoot::from_ref(&*entry.global)) }) } diff --git a/servo/components/script/dom/bindings/structuredclone.rs b/servo/components/script/dom/bindings/structuredclone.rs index 5644784e10c3..bdc5348782f4 100644 --- a/servo/components/script/dom/bindings/structuredclone.rs +++ b/servo/components/script/dom/bindings/structuredclone.rs @@ -7,8 +7,8 @@ use dom::bindings::conversions::root_from_handleobject; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::Root; use dom::bindings::reflector::DomObject; +use dom::bindings::root::DomRoot; use dom::blob::{Blob, BlobImpl}; use dom::globalscope::GlobalScope; use js::jsapi::{Handle, HandleObject, HandleValue, MutableHandleValue, JSAutoCompartment, JSContext}; @@ -110,7 +110,7 @@ unsafe fn read_blob(cx: *mut JSContext, return blob.reflector().get_jsobject().get() } -unsafe fn write_blob(blob: Root, +unsafe fn write_blob(blob: DomRoot, w: *mut JSStructuredCloneWriter) -> Result<(), ()> { let structured_writer = StructuredCloneWriter { w: w }; diff --git a/servo/components/script/dom/bindings/trace.rs b/servo/components/script/dom/bindings/trace.rs index cdb2fd425ace..c367df5ee560 100644 --- a/servo/components/script/dom/bindings/trace.rs +++ b/servo/components/script/dom/bindings/trace.rs @@ -18,9 +18,9 @@ //! achieved via `unsafe_no_jsmanaged_fields!` or similar. //! 3. For all fields, `Foo::trace()` //! calls `trace()` on the field. -//! For example, for fields of type `JS`, `JS::trace()` calls +//! For example, for fields of type `Dom`, `Dom::trace()` calls //! `trace_reflector()`. -//! 4. `trace_reflector()` calls `JS::TraceEdge()` with a +//! 4. `trace_reflector()` calls `Dom::TraceEdge()` with a //! pointer to the `JSObject` for the reflector. This notifies the GC, which //! will add the object to the graph, and will trace that object as well. //! 5. When the GC finishes tracing, it [`finalizes`](../index.html#destruction) @@ -38,11 +38,11 @@ use canvas_traits::webgl::{WebGLReceiver, WebGLSender, WebGLShaderId, WebGLTextu use cssparser::RGBA; use devtools_traits::{CSSError, TimelineMarkerType, WorkerId}; use dom::abstractworker::SharedRt; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::error::Error; -use dom::bindings::js::{JS, Root}; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::{DomObject, Reflector}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::{DOMString, USVString}; use dom::bindings::utils::WindowProxyHandler; use dom::document::PendingRestyle; @@ -202,7 +202,7 @@ unsafe impl JSTraceable for UnsafeCell { } } -unsafe impl JSTraceable for DOMRefCell { +unsafe impl JSTraceable for DomRefCell { unsafe fn trace(&self, trc: *mut JSTracer) { (*self).borrow_for_gc_trace().trace(trc) } @@ -710,7 +710,7 @@ impl RootedTraceableSet { /// Roots any JSTraceable thing /// -/// If you have a valid DomObject, use Root. +/// If you have a valid DomObject, use DomRoot. /// If you have GC things like *mut JSObject or JSVal, use rooted!. /// If you have an arbitrary number of DomObjects to root, use rooted_vec!. /// If you know what you're doing, use this. @@ -720,7 +720,7 @@ pub struct RootedTraceable<'a, T: 'static + JSTraceable> { } impl<'a, T: JSTraceable + 'static> RootedTraceable<'a, T> { - /// Root a JSTraceable thing for the life of this RootedTraceable + /// DomRoot a JSTraceable thing for the life of this RootedTraceable pub fn new(traceable: &'a T) -> RootedTraceable<'a, T> { unsafe { RootedTraceableSet::add(traceable); @@ -741,7 +741,7 @@ impl<'a, T: JSTraceable + 'static> Drop for RootedTraceable<'a, T> { /// Roots any JSTraceable thing /// -/// If you have a valid DomObject, use Root. +/// If you have a valid DomObject, use DomRoot. /// If you have GC things like *mut JSObject or JSVal, use rooted!. /// If you have an arbitrary number of DomObjects to root, use rooted_vec!. /// If you know what you're doing, use this. @@ -757,7 +757,7 @@ unsafe impl JSTraceable for RootedTraceableBox { } impl RootedTraceableBox { - /// Root a JSTraceable thing for the life of this RootedTraceable + /// DomRoot a JSTraceable thing for the life of this RootedTraceable pub fn new(traceable: T) -> RootedTraceableBox { let traceable = Box::into_raw(box traceable); unsafe { @@ -804,7 +804,7 @@ impl Drop for RootedTraceableBox { /// A vector of items to be rooted with `RootedVec`. /// Guaranteed to be empty when not rooted. /// Usage: `rooted_vec!(let mut v);` or if you have an -/// iterator of `Root`s, `rooted_vec!(let v <- iterator);`. +/// iterator of `DomRoot`s, `rooted_vec!(let v <- iterator);`. #[allow(unrooted_must_root)] #[derive(JSTraceable)] #[allow_unrooted_interior] @@ -840,16 +840,16 @@ impl<'a, T: 'static + JSTraceable> RootedVec<'a, T> { } } -impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, JS> { - /// Create a vector of items of type JS that is rooted for +impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, Dom> { + /// Create a vector of items of type Dom that is rooted for /// the lifetime of this struct - pub fn from_iter(root: &'a mut RootableVec>, iter: I) -> Self - where I: Iterator> + pub fn from_iter(root: &'a mut RootableVec>, iter: I) -> Self + where I: Iterator> { unsafe { RootedTraceableSet::add(root); } - root.v.extend(iter.map(|item| JS::from_ref(&*item))); + root.v.extend(iter.map(|item| Dom::from_ref(&*item))); RootedVec { root: root, } diff --git a/servo/components/script/dom/bindings/weakref.rs b/servo/components/script/dom/bindings/weakref.rs index 7291405e5f65..6ece47cea3bf 100644 --- a/servo/components/script/dom/bindings/weakref.rs +++ b/servo/components/script/dom/bindings/weakref.rs @@ -12,8 +12,8 @@ //! `WeakBox` itself is dropped too. use core::nonzero::NonZero; -use dom::bindings::js::Root; use dom::bindings::reflector::DomObject; +use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; use heapsize::HeapSizeOf; use js::jsapi::{JSTracer, JS_GetReservedSlot, JS_SetReservedSlot}; @@ -84,9 +84,9 @@ impl WeakRef { value.downgrade() } - /// Root a weak reference. Returns `None` if the object was already collected. - pub fn root(&self) -> Option> { - unsafe { &*self.ptr.get() }.value.get().map(Root::new) + /// DomRoot a weak reference. Returns `None` if the object was already collected. + pub fn root(&self) -> Option> { + unsafe { &*self.ptr.get() }.value.get().map(DomRoot::new) } /// Return whether the weakly-referenced object is still alive. @@ -179,9 +179,9 @@ impl MutableWeakRef { } } - /// Root a mutable weak reference. Returns `None` if the object + /// DomRoot a mutable weak reference. Returns `None` if the object /// was already collected. - pub fn root(&self) -> Option> { + pub fn root(&self) -> Option> { unsafe { &*self.cell.get() }.as_ref().and_then(WeakRef::root) } } diff --git a/servo/components/script/dom/blob.rs b/servo/components/script/dom/blob.rs index 191ea6f84f7d..66dcc5b475cc 100644 --- a/servo/components/script/dom/blob.rs +++ b/servo/components/script/dom/blob.rs @@ -2,13 +2,13 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BlobBinding; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::UnionTypes::BlobOrString; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -27,7 +27,7 @@ use uuid::Uuid; pub struct FileBlob { id: Uuid, name: Option, - cache: DOMRefCell>>, + cache: DomRefCell>>, size: u64, } @@ -44,7 +44,7 @@ pub enum BlobImpl { /// relative positions of current slicing range, /// IMPORTANT: The depth of tree is only two, i.e. the parent Blob must be /// either File-based or Memory-based - Sliced(JS, RelativePos), + Sliced(Dom, RelativePos), } impl BlobImpl { @@ -59,7 +59,7 @@ impl BlobImpl { BlobImpl::File(FileBlob { id: file_id, name: Some(name), - cache: DOMRefCell::new(None), + cache: DomRefCell::new(None), size: size, }) } @@ -70,7 +70,7 @@ impl BlobImpl { pub struct Blob { reflector_: Reflector, #[ignore_heap_size_of = "No clear owner"] - blob_impl: DOMRefCell, + blob_impl: DomRefCell, /// content-type string type_string: String, } @@ -79,7 +79,7 @@ impl Blob { #[allow(unrooted_must_root)] pub fn new( global: &GlobalScope, blob_impl: BlobImpl, typeString: String) - -> Root { + -> DomRoot { let boxed_blob = box Blob::new_inherited(blob_impl, typeString); reflect_dom_object(boxed_blob, global, BlobBinding::Wrap) } @@ -88,7 +88,7 @@ impl Blob { pub fn new_inherited(blob_impl: BlobImpl, type_string: String) -> Blob { Blob { reflector_: Reflector::new(), - blob_impl: DOMRefCell::new(blob_impl), + blob_impl: DomRefCell::new(blob_impl), // NOTE: Guarding the format correctness here, // https://w3c.github.io/FileAPI/#dfn-type type_string: normalize_type_string(&type_string), @@ -97,15 +97,15 @@ impl Blob { #[allow(unrooted_must_root)] fn new_sliced(parent: &Blob, rel_pos: RelativePos, - relative_content_type: DOMString) -> Root { + relative_content_type: DOMString) -> DomRoot { let blob_impl = match *parent.blob_impl.borrow() { BlobImpl::File(_) => { // Create new parent node - BlobImpl::Sliced(JS::from_ref(parent), rel_pos) + BlobImpl::Sliced(Dom::from_ref(parent), rel_pos) } BlobImpl::Memory(_) => { // Create new parent node - BlobImpl::Sliced(JS::from_ref(parent), rel_pos) + BlobImpl::Sliced(Dom::from_ref(parent), rel_pos) } BlobImpl::Sliced(ref grandparent, ref old_rel_pos) => { // Adjust the slicing position, using same parent @@ -120,7 +120,7 @@ impl Blob { pub fn Constructor(global: &GlobalScope, blobParts: Option>, blobPropertyBag: &BlobBinding::BlobPropertyBag) - -> Fallible> { + -> Fallible> { // TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView let bytes: Vec = match blobParts { None => Vec::new(), @@ -237,7 +237,7 @@ impl Blob { *self.blob_impl.borrow_mut() = BlobImpl::File(FileBlob { id: id.clone(), name: None, - cache: DOMRefCell::new(Some(bytes.to_vec())), + cache: DomRefCell::new(Some(bytes.to_vec())), size: bytes.len() as u64, }); id @@ -262,7 +262,7 @@ impl Blob { *self.blob_impl.borrow_mut() = BlobImpl::File(FileBlob { id: new_id.clone(), name: None, - cache: DOMRefCell::new(None), + cache: DomRefCell::new(None), size: rel_pos.to_abs_range(parent_len as usize).len() as u64, }); @@ -369,7 +369,7 @@ impl BlobMethods for Blob { start: Option, end: Option, content_type: Option) - -> Root { + -> DomRoot { let rel_pos = RelativePos::from_opts(start, end); Blob::new_sliced(self, rel_pos, content_type.unwrap_or(DOMString::from(""))) } diff --git a/servo/components/script/dom/bluetooth.rs b/servo/components/script/dom/bluetooth.rs index 12d363731ca8..ac3b9b7ea53b 100644 --- a/servo/components/script/dom/bluetooth.rs +++ b/servo/components/script/dom/bluetooth.rs @@ -8,7 +8,7 @@ use bluetooth_traits::blocklist::{Blocklist, uuid_is_blocklisted}; use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence}; use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence}; use core::clone::Clone; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothDataFilterInit, BluetoothLEScanFilterInit}; use dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions}; use dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::BluetoothPermissionDescriptor; @@ -18,9 +18,9 @@ use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionName, use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong; use dom::bindings::error::Error::{self, Network, Security, Type}; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, Root}; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::bluetoothdevice::BluetoothDevice; use dom::bluetoothpermissionresult::BluetoothPermissionResult; @@ -65,13 +65,13 @@ pub struct AllowedBluetoothDevice { #[derive(HeapSizeOf, JSTraceable)] pub struct BluetoothExtraPermissionData { - allowed_devices: DOMRefCell>, + allowed_devices: DomRefCell>, } impl BluetoothExtraPermissionData { pub fn new() -> BluetoothExtraPermissionData { BluetoothExtraPermissionData { - allowed_devices: DOMRefCell::new(Vec::new()), + allowed_devices: DomRefCell::new(Vec::new()), } } @@ -120,18 +120,18 @@ where #[dom_struct] pub struct Bluetooth { eventtarget: EventTarget, - device_instance_map: DOMRefCell>>, + device_instance_map: DomRefCell>>, } impl Bluetooth { pub fn new_inherited() -> Bluetooth { Bluetooth { eventtarget: EventTarget::new_inherited(), - device_instance_map: DOMRefCell::new(HashMap::new()), + device_instance_map: DomRefCell::new(HashMap::new()), } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box Bluetooth::new_inherited(), global, BluetoothBinding::Wrap) @@ -141,7 +141,7 @@ impl Bluetooth { self.global().as_window().bluetooth_thread() } - pub fn get_device_map(&self) -> &DOMRefCell>> { + pub fn get_device_map(&self) -> &DomRefCell>> { &self.device_instance_map } @@ -520,7 +520,7 @@ impl AsyncBluetoothListener for Bluetooth { DOMString::from(device.id.clone()), device.name.map(DOMString::from), &self); - device_instance_map.insert(device.id.clone(), JS::from_ref(&bt_device)); + device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device)); self.global().as_window().bluetooth_extra_permission_data().add_new_allowed_device( AllowedBluetoothDevice { @@ -631,7 +631,7 @@ impl PermissionAlgorithm for Bluetooth { // TODO: Implement this correctly, not just using device ids here. // https://webbluetoothcg.github.io/web-bluetooth/#get-the-bluetoothdevice-representing if let Some(device) = device_map.get(&device_id) { - matching_devices.push(JS::from_ref(&**device)); + matching_devices.push(Dom::from_ref(&**device)); } } diff --git a/servo/components/script/dom/bluetoothadvertisingevent.rs b/servo/components/script/dom/bluetoothadvertisingevent.rs index 604a1c820259..9477c998587c 100644 --- a/servo/components/script/dom/bluetoothadvertisingevent.rs +++ b/servo/components/script/dom/bluetoothadvertisingevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::BluetoothAdvertisingEventBinding::Bluetoot use dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot, RootedReference}; use dom::bindings::str::DOMString; use dom::bluetoothdevice::BluetoothDevice; use dom::event::{Event, EventBubbles, EventCancelable}; @@ -21,7 +21,7 @@ use servo_atoms::Atom; #[dom_struct] pub struct BluetoothAdvertisingEvent { event: Event, - device: JS, + device: Dom, name: Option, appearance: Option, tx_power: Option, @@ -37,7 +37,7 @@ impl BluetoothAdvertisingEvent { -> BluetoothAdvertisingEvent { BluetoothAdvertisingEvent { event: Event::new_inherited(), - device: JS::from_ref(device), + device: Dom::from_ref(device), name: name, appearance: appearance, tx_power: tx_power, @@ -54,7 +54,7 @@ impl BluetoothAdvertisingEvent { appearance: Option, txPower: Option, rssi: Option) - -> Root { + -> DomRoot { let ev = reflect_dom_object(box BluetoothAdvertisingEvent::new_inherited(device, name, appearance, @@ -73,7 +73,7 @@ impl BluetoothAdvertisingEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &BluetoothAdvertisingEventInit) - -> Fallible> { + -> Fallible> { let global = window.upcast::(); let device = init.device.r(); let name = init.name.clone(); @@ -96,8 +96,8 @@ impl BluetoothAdvertisingEvent { impl BluetoothAdvertisingEventMethods for BluetoothAdvertisingEvent { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingevent-device - fn Device(&self) -> Root { - Root::from_ref(&*self.device) + fn Device(&self) -> DomRoot { + DomRoot::from_ref(&*self.device) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingevent-name diff --git a/servo/components/script/dom/bluetoothcharacteristicproperties.rs b/servo/components/script/dom/bluetoothcharacteristicproperties.rs index a477c130a2de..048e52765c8f 100644 --- a/servo/components/script/dom/bluetoothcharacteristicproperties.rs +++ b/servo/components/script/dom/bluetoothcharacteristicproperties.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding; use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding:: BluetoothCharacteristicPropertiesMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -60,7 +60,7 @@ impl BluetoothCharacteristicProperties { authenticatedSignedWrites: bool, reliableWrite: bool, writableAuxiliaries: bool) - -> Root { + -> DomRoot { reflect_dom_object(box BluetoothCharacteristicProperties::new_inherited(broadcast, read, writeWithoutResponse, diff --git a/servo/components/script/dom/bluetoothdevice.rs b/servo/components/script/dom/bluetoothdevice.rs index 2e8e07503da0..6c6dc5c9d6e1 100644 --- a/servo/components/script/dom/bluetoothdevice.rs +++ b/servo/components/script/dom/bluetoothdevice.rs @@ -4,15 +4,15 @@ use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg}; use bluetooth_traits::{BluetoothRequest, BluetoothResponse, BluetoothServiceMsg}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BluetoothDeviceBinding; use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::error::Error; use dom::bindings::error::ErrorResult; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::bluetooth::{AsyncBluetoothListener, Bluetooth, response_async}; use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties; @@ -35,11 +35,11 @@ pub struct BluetoothDevice { eventtarget: EventTarget, id: DOMString, name: Option, - gatt: MutNullableJS, - context: JS, - attribute_instance_map: (DOMRefCell>>, - DOMRefCell>>, - DOMRefCell>>), + gatt: MutNullableDom, + context: Dom, + attribute_instance_map: (DomRefCell>>, + DomRefCell>>, + DomRefCell>>), watching_advertisements: Cell, } @@ -53,10 +53,10 @@ impl BluetoothDevice { id: id, name: name, gatt: Default::default(), - context: JS::from_ref(context), - attribute_instance_map: (DOMRefCell::new(HashMap::new()), - DOMRefCell::new(HashMap::new()), - DOMRefCell::new(HashMap::new())), + context: Dom::from_ref(context), + attribute_instance_map: (DomRefCell::new(HashMap::new()), + DomRefCell::new(HashMap::new()), + DomRefCell::new(HashMap::new())), watching_advertisements: Cell::new(false), } } @@ -65,7 +65,7 @@ impl BluetoothDevice { id: DOMString, name: Option, context: &Bluetooth) - -> Root { + -> DomRoot { reflect_dom_object(box BluetoothDevice::new_inherited(id, name, context), @@ -73,42 +73,42 @@ impl BluetoothDevice { BluetoothDeviceBinding::Wrap) } - pub fn get_gatt(&self) -> Root { + pub fn get_gatt(&self) -> DomRoot { self.gatt.or_init(|| { BluetoothRemoteGATTServer::new(&self.global(), self) }) } - fn get_context(&self) -> Root { - Root::from_ref(&self.context) + fn get_context(&self) -> DomRoot { + DomRoot::from_ref(&self.context) } pub fn get_or_create_service(&self, service: &BluetoothServiceMsg, server: &BluetoothRemoteGATTServer) - -> Root { + -> DomRoot { let (ref service_map_ref, _, _) = self.attribute_instance_map; let mut service_map = service_map_ref.borrow_mut(); if let Some(existing_service) = service_map.get(&service.instance_id) { - return Root::from_ref(&existing_service); + return DomRoot::from_ref(&existing_service); } let bt_service = BluetoothRemoteGATTService::new(&server.global(), &server.Device(), DOMString::from(service.uuid.clone()), service.is_primary, service.instance_id.clone()); - service_map.insert(service.instance_id.clone(), JS::from_ref(&bt_service)); + service_map.insert(service.instance_id.clone(), Dom::from_ref(&bt_service)); return bt_service; } pub fn get_or_create_characteristic(&self, characteristic: &BluetoothCharacteristicMsg, service: &BluetoothRemoteGATTService) - -> Root { + -> DomRoot { let (_, ref characteristic_map_ref, _) = self.attribute_instance_map; let mut characteristic_map = characteristic_map_ref.borrow_mut(); if let Some(existing_characteristic) = characteristic_map.get(&characteristic.instance_id) { - return Root::from_ref(&existing_characteristic); + return DomRoot::from_ref(&existing_characteristic); } let properties = BluetoothCharacteristicProperties::new(&service.global(), @@ -126,7 +126,7 @@ impl BluetoothDevice { DOMString::from(characteristic.uuid.clone()), &properties, characteristic.instance_id.clone()); - characteristic_map.insert(characteristic.instance_id.clone(), JS::from_ref(&bt_characteristic)); + characteristic_map.insert(characteristic.instance_id.clone(), Dom::from_ref(&bt_characteristic)); return bt_characteristic; } @@ -140,17 +140,17 @@ impl BluetoothDevice { pub fn get_or_create_descriptor(&self, descriptor: &BluetoothDescriptorMsg, characteristic: &BluetoothRemoteGATTCharacteristic) - -> Root { + -> DomRoot { let (_, _, ref descriptor_map_ref) = self.attribute_instance_map; let mut descriptor_map = descriptor_map_ref.borrow_mut(); if let Some(existing_descriptor) = descriptor_map.get(&descriptor.instance_id) { - return Root::from_ref(&existing_descriptor); + return DomRoot::from_ref(&existing_descriptor); } let bt_descriptor = BluetoothRemoteGATTDescriptor::new(&characteristic.global(), characteristic, DOMString::from(descriptor.uuid.clone()), descriptor.instance_id.clone()); - descriptor_map.insert(descriptor.instance_id.clone(), JS::from_ref(&bt_descriptor)); + descriptor_map.insert(descriptor.instance_id.clone(), Dom::from_ref(&bt_descriptor)); return bt_descriptor; } @@ -225,7 +225,7 @@ impl BluetoothDeviceMethods for BluetoothDevice { } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt - fn GetGatt(&self) -> Option> { + fn GetGatt(&self) -> Option> { // Step 1. if self.global().as_window().bluetooth_extra_permission_data() .allowed_devices_contains_id(self.id.clone()) && !self.is_represented_device_null() { diff --git a/servo/components/script/dom/bluetoothpermissionresult.rs b/servo/components/script/dom/bluetoothpermissionresult.rs index cc766b854772..ea1097c1f293 100644 --- a/servo/components/script/dom/bluetoothpermissionresult.rs +++ b/servo/components/script/dom/bluetoothpermissionresult.rs @@ -3,15 +3,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use bluetooth_traits::{BluetoothRequest, BluetoothResponse}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::{self, BluetoothPermissionResultMethods}; use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding::NavigatorMethods; use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionName, PermissionState}; use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusBinding::PermissionStatusMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use dom::bindings::error::Error; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::bluetooth::{AsyncBluetoothListener, Bluetooth, AllowedBluetoothDevice}; use dom::bluetoothdevice::BluetoothDevice; @@ -26,7 +26,7 @@ use std::rc::Rc; #[dom_struct] pub struct BluetoothPermissionResult { status: PermissionStatus, - devices: DOMRefCell>>, + devices: DomRefCell>>, } impl BluetoothPermissionResult { @@ -34,19 +34,19 @@ impl BluetoothPermissionResult { fn new_inherited(status: &PermissionStatus) -> BluetoothPermissionResult { let result = BluetoothPermissionResult { status: PermissionStatus::new_inherited(status.get_query()), - devices: DOMRefCell::new(Vec::new()), + devices: DomRefCell::new(Vec::new()), }; result.status.set_state(status.State()); result } - pub fn new(global: &GlobalScope, status: &PermissionStatus) -> Root { + pub fn new(global: &GlobalScope, status: &PermissionStatus) -> DomRoot { reflect_dom_object(box BluetoothPermissionResult::new_inherited(status), global, BluetoothPermissionResultBinding::Wrap) } - pub fn get_bluetooth(&self) -> Root { + pub fn get_bluetooth(&self) -> DomRoot { self.global().as_window().Navigator().Bluetooth() } @@ -67,16 +67,16 @@ impl BluetoothPermissionResult { } #[allow(unrooted_must_root)] - pub fn set_devices(&self, devices: Vec>) { + pub fn set_devices(&self, devices: Vec>) { *self.devices.borrow_mut() = devices; } } impl BluetoothPermissionResultMethods for BluetoothPermissionResult { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothpermissionresult-devices - fn Devices(&self) -> Vec> { - let device_vec: Vec> = - self.devices.borrow().iter().map(|d| Root::from_ref(&**d)).collect(); + fn Devices(&self) -> Vec> { + let device_vec: Vec> = + self.devices.borrow().iter().map(|d| DomRoot::from_ref(&**d)).collect(); device_vec } } @@ -93,7 +93,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult { if let Some(ref existing_device) = device_instance_map.get(&device.id) { // https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission // Step 3. - self.set_devices(vec!(JS::from_ref(&*existing_device))); + self.set_devices(vec!(Dom::from_ref(&*existing_device))); // https://w3c.github.io/permissions/#dom-permissions-request // Step 8. @@ -103,7 +103,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult { DOMString::from(device.id.clone()), device.name.map(DOMString::from), &bluetooth); - device_instance_map.insert(device.id.clone(), JS::from_ref(&bt_device)); + device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device)); self.global().as_window().bluetooth_extra_permission_data().add_new_allowed_device( AllowedBluetoothDevice { deviceId: DOMString::from(device.id), @@ -112,7 +112,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult { ); // https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission // Step 3. - self.set_devices(vec!(JS::from_ref(&bt_device))); + self.set_devices(vec!(Dom::from_ref(&bt_device))); // https://w3c.github.io/permissions/#dom-permissions-request // Step 8. diff --git a/servo/components/script/dom/bluetoothremotegattcharacteristic.rs b/servo/components/script/dom/bluetoothremotegattcharacteristic.rs index f54776d37a92..d322d0494b4f 100644 --- a/servo/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/servo/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -4,7 +4,7 @@ use bluetooth_traits::{BluetoothRequest, BluetoothResponse, GATTType}; use bluetooth_traits::blocklist::{Blocklist, uuid_is_blocklisted}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding:: BluetoothCharacteristicPropertiesMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding; @@ -14,8 +14,8 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::{ByteString, DOMString}; use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async}; use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties; @@ -36,10 +36,10 @@ pub const MAXIMUM_ATTRIBUTE_LENGTH: usize = 512; #[dom_struct] pub struct BluetoothRemoteGATTCharacteristic { eventtarget: EventTarget, - service: JS, + service: Dom, uuid: DOMString, - properties: JS, - value: DOMRefCell>, + properties: Dom, + value: DomRefCell>, instance_id: String, } @@ -51,10 +51,10 @@ impl BluetoothRemoteGATTCharacteristic { -> BluetoothRemoteGATTCharacteristic { BluetoothRemoteGATTCharacteristic { eventtarget: EventTarget::new_inherited(), - service: JS::from_ref(service), + service: Dom::from_ref(service), uuid: uuid, - properties: JS::from_ref(properties), - value: DOMRefCell::new(None), + properties: Dom::from_ref(properties), + value: DomRefCell::new(None), instance_id: instance_id, } } @@ -64,7 +64,7 @@ impl BluetoothRemoteGATTCharacteristic { uuid: DOMString, properties: &BluetoothCharacteristicProperties, instanceID: String) - -> Root { + -> DomRoot { reflect_dom_object(box BluetoothRemoteGATTCharacteristic::new_inherited(service, uuid, properties, @@ -84,13 +84,13 @@ impl BluetoothRemoteGATTCharacteristic { impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteristic { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-properties - fn Properties(&self) -> Root { - Root::from_ref(&self.properties) + fn Properties(&self) -> DomRoot { + DomRoot::from_ref(&self.properties) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-service - fn Service(&self) -> Root { - Root::from_ref(&self.service) + fn Service(&self) -> DomRoot { + DomRoot::from_ref(&self.service) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-uuid diff --git a/servo/components/script/dom/bluetoothremotegattdescriptor.rs b/servo/components/script/dom/bluetoothremotegattdescriptor.rs index d05194af1d20..03ae0aa5651e 100644 --- a/servo/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/servo/components/script/dom/bluetoothremotegattdescriptor.rs @@ -4,7 +4,7 @@ use bluetooth_traits::{BluetoothRequest, BluetoothResponse}; use bluetooth_traits::blocklist::{Blocklist, uuid_is_blocklisted}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding:: BluetoothRemoteGATTCharacteristicMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding; @@ -12,8 +12,8 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::Blue use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; use dom::bindings::error::Error::{self, InvalidModification, Network, Security}; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::{ByteString, DOMString}; use dom::bluetooth::{AsyncBluetoothListener, response_async}; use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH}; @@ -27,9 +27,9 @@ use std::rc::Rc; #[dom_struct] pub struct BluetoothRemoteGATTDescriptor { reflector_: Reflector, - characteristic: JS, + characteristic: Dom, uuid: DOMString, - value: DOMRefCell>, + value: DomRefCell>, instance_id: String, } @@ -40,9 +40,9 @@ impl BluetoothRemoteGATTDescriptor { -> BluetoothRemoteGATTDescriptor { BluetoothRemoteGATTDescriptor { reflector_: Reflector::new(), - characteristic: JS::from_ref(characteristic), + characteristic: Dom::from_ref(characteristic), uuid: uuid, - value: DOMRefCell::new(None), + value: DomRefCell::new(None), instance_id: instance_id, } } @@ -51,7 +51,7 @@ impl BluetoothRemoteGATTDescriptor { characteristic: &BluetoothRemoteGATTCharacteristic, uuid: DOMString, instanceID: String) - -> Root{ + -> DomRoot{ reflect_dom_object(box BluetoothRemoteGATTDescriptor::new_inherited(characteristic, uuid, instanceID), @@ -70,8 +70,8 @@ impl BluetoothRemoteGATTDescriptor { impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-characteristic - fn Characteristic(&self) -> Root { - Root::from_ref(&self.characteristic) + fn Characteristic(&self) -> DomRoot { + DomRoot::from_ref(&self.characteristic) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-uuid diff --git a/servo/components/script/dom/bluetoothremotegattserver.rs b/servo/components/script/dom/bluetoothremotegattserver.rs index 65e66edecd3f..dbc477456c6b 100644 --- a/servo/components/script/dom/bluetoothremotegattserver.rs +++ b/servo/components/script/dom/bluetoothremotegattserver.rs @@ -8,8 +8,8 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::error::Error; use dom::bindings::error::ErrorResult; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children, response_async}; use dom::bluetoothdevice::BluetoothDevice; use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID}; @@ -24,7 +24,7 @@ use std::rc::Rc; #[dom_struct] pub struct BluetoothRemoteGATTServer { reflector_: Reflector, - device: JS, + device: Dom, connected: Cell, } @@ -32,12 +32,12 @@ impl BluetoothRemoteGATTServer { pub fn new_inherited(device: &BluetoothDevice) -> BluetoothRemoteGATTServer { BluetoothRemoteGATTServer { reflector_: Reflector::new(), - device: JS::from_ref(device), + device: Dom::from_ref(device), connected: Cell::new(false), } } - pub fn new(global: &GlobalScope, device: &BluetoothDevice) -> Root { + pub fn new(global: &GlobalScope, device: &BluetoothDevice) -> DomRoot { reflect_dom_object(box BluetoothRemoteGATTServer::new_inherited(device), global, BluetoothRemoteGATTServerBinding::Wrap) @@ -54,8 +54,8 @@ impl BluetoothRemoteGATTServer { impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-device - fn Device(&self) -> Root { - Root::from_ref(&self.device) + fn Device(&self) -> DomRoot { + DomRoot::from_ref(&self.device) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connected diff --git a/servo/components/script/dom/bluetoothremotegattservice.rs b/servo/components/script/dom/bluetoothremotegattservice.rs index 6140d83c9f52..acb81f1f9a1d 100644 --- a/servo/components/script/dom/bluetoothremotegattservice.rs +++ b/servo/components/script/dom/bluetoothremotegattservice.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; use dom::bindings::error::Error; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::bluetooth::{AsyncBluetoothListener, get_gatt_children}; use dom::bluetoothdevice::BluetoothDevice; @@ -23,7 +23,7 @@ use std::rc::Rc; #[dom_struct] pub struct BluetoothRemoteGATTService { eventtarget: EventTarget, - device: JS, + device: Dom, uuid: DOMString, is_primary: bool, instance_id: String, @@ -37,7 +37,7 @@ impl BluetoothRemoteGATTService { -> BluetoothRemoteGATTService { BluetoothRemoteGATTService { eventtarget: EventTarget::new_inherited(), - device: JS::from_ref(device), + device: Dom::from_ref(device), uuid: uuid, is_primary: is_primary, instance_id: instance_id, @@ -49,7 +49,7 @@ impl BluetoothRemoteGATTService { uuid: DOMString, isPrimary: bool, instanceID: String) - -> Root { + -> DomRoot { reflect_dom_object(box BluetoothRemoteGATTService::new_inherited(device, uuid, isPrimary, @@ -65,8 +65,8 @@ impl BluetoothRemoteGATTService { impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-device - fn Device(&self) -> Root { - Root::from_ref(&self.device) + fn Device(&self) -> DomRoot { + DomRoot::from_ref(&self.device) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-isprimary diff --git a/servo/components/script/dom/canvasgradient.rs b/servo/components/script/dom/canvasgradient.rs index e571e3afabfc..21bd0c3a0d1c 100644 --- a/servo/components/script/dom/canvasgradient.rs +++ b/servo/components/script/dom/canvasgradient.rs @@ -5,13 +5,13 @@ use canvas_traits::canvas::{CanvasGradientStop, FillOrStrokeStyle, LinearGradientStyle, RadialGradientStyle}; use cssparser::{Parser, ParserInput, RGBA}; use cssparser::Color as CSSColor; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CanvasGradientBinding; use dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMethods; use dom::bindings::error::{Error, ErrorResult}; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -21,7 +21,7 @@ use dom_struct::dom_struct; pub struct CanvasGradient { reflector_: Reflector, style: CanvasGradientStyle, - stops: DOMRefCell>, + stops: DomRefCell>, } #[derive(Clone, HeapSizeOf, JSTraceable)] @@ -35,11 +35,11 @@ impl CanvasGradient { CanvasGradient { reflector_: Reflector::new(), style: style, - stops: DOMRefCell::new(Vec::new()), + stops: DomRefCell::new(Vec::new()), } } - pub fn new(global: &GlobalScope, style: CanvasGradientStyle) -> Root { + pub fn new(global: &GlobalScope, style: CanvasGradientStyle) -> DomRoot { reflect_dom_object(box CanvasGradient::new_inherited(style), global, CanvasGradientBinding::Wrap) diff --git a/servo/components/script/dom/canvaspattern.rs b/servo/components/script/dom/canvaspattern.rs index 46bcbedcef0d..5c1a7edaf75e 100644 --- a/servo/components/script/dom/canvaspattern.rs +++ b/servo/components/script/dom/canvaspattern.rs @@ -4,8 +4,8 @@ use canvas_traits::canvas::{FillOrStrokeStyle, RepetitionStyle, SurfaceStyle}; use dom::bindings::codegen::Bindings::CanvasPatternBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::canvasgradient::ToFillOrStrokeStyle; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -49,7 +49,7 @@ impl CanvasPattern { surface_size: Size2D, repeat: RepetitionStyle, origin_clean: bool) - -> Root { + -> DomRoot { reflect_dom_object(box CanvasPattern::new_inherited(surface_data, surface_size, repeat, origin_clean), global, diff --git a/servo/components/script/dom/canvasrenderingcontext2d.rs b/servo/components/script/dom/canvasrenderingcontext2d.rs index e6007c8b6eec..de56cb28debb 100644 --- a/servo/components/script/dom/canvasrenderingcontext2d.rs +++ b/servo/components/script/dom/canvasrenderingcontext2d.rs @@ -8,7 +8,7 @@ use canvas_traits::canvas::{LineCapStyle, LineJoinStyle, LinearGradientStyle}; use canvas_traits::canvas::{RadialGradientStyle, RepetitionStyle, byte_swap_and_premultiply}; use cssparser::{Parser, ParserInput, RGBA}; use cssparser::Color as CSSColor; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding; use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasFillRule; @@ -21,9 +21,9 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, Root}; use dom::bindings::num::Finite; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, LayoutDom}; use dom::bindings::str::DOMString; use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle}; use dom::canvaspattern::CanvasPattern; @@ -55,8 +55,8 @@ use unpremultiplytable::UNPREMULTIPLY_TABLE; #[allow(dead_code)] enum CanvasFillOrStrokeStyle { Color(RGBA), - Gradient(JS), - Pattern(JS), + Gradient(Dom), + Pattern(Dom), } // https://html.spec.whatwg.org/multipage/#canvasrenderingcontext2d @@ -67,16 +67,16 @@ pub struct CanvasRenderingContext2D { ipc_renderer: IpcSender, /// For rendering contexts created by an HTML canvas element, this is Some, /// for ones created by a paint worklet, this is None. - canvas: Option>, + canvas: Option>, #[ignore_heap_size_of = "Arc"] image_cache: Arc, /// Any missing image URLs. - missing_image_urls: DOMRefCell>, + missing_image_urls: DomRefCell>, /// The base URL for resolving CSS image URL values. /// Needed because of https://github.com/servo/servo/issues/17625 base_url: ServoUrl, - state: DOMRefCell, - saved_states: DOMRefCell>, + state: DomRefCell, + saved_states: DomRefCell>, origin_clean: Cell, } @@ -138,12 +138,12 @@ impl CanvasRenderingContext2D { CanvasRenderingContext2D { reflector_: Reflector::new(), ipc_renderer: ipc_renderer, - canvas: canvas.map(JS::from_ref), + canvas: canvas.map(Dom::from_ref), image_cache: image_cache, - missing_image_urls: DOMRefCell::new(Vec::new()), + missing_image_urls: DomRefCell::new(Vec::new()), base_url: base_url, - state: DOMRefCell::new(CanvasContextState::new()), - saved_states: DOMRefCell::new(Vec::new()), + state: DomRefCell::new(CanvasContextState::new()), + saved_states: DomRefCell::new(Vec::new()), origin_clean: Cell::new(true), } } @@ -151,7 +151,7 @@ impl CanvasRenderingContext2D { pub fn new(global: &GlobalScope, canvas: &HTMLCanvasElement, size: Size2D) - -> Root { + -> DomRoot { let window = window_from_node(canvas); let image_cache = window.image_cache(); let base_url = window.get_url(); @@ -585,7 +585,7 @@ pub trait LayoutCanvasRenderingContext2DHelpers { unsafe fn get_ipc_renderer(&self) -> IpcSender; } -impl LayoutCanvasRenderingContext2DHelpers for LayoutJS { +impl LayoutCanvasRenderingContext2DHelpers for LayoutDom { #[allow(unsafe_code)] unsafe fn get_ipc_renderer(&self) -> IpcSender { (*self.unsafe_get()).ipc_renderer.clone() @@ -603,10 +603,10 @@ impl LayoutCanvasRenderingContext2DHelpers for LayoutJS Root { + fn Canvas(&self) -> DomRoot { // This method is not called from a paint worklet rendering context, // so it's OK to panic if self.canvas is None. - Root::from_ref(self.canvas.as_ref().expect("No canvas.")) + DomRoot::from_ref(self.canvas.as_ref().expect("No canvas.")) } // https://html.spec.whatwg.org/multipage/#dom-context-2d-save @@ -997,10 +997,10 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { StringOrCanvasGradientOrCanvasPattern::String(DOMString::from(result)) }, CanvasFillOrStrokeStyle::Gradient(ref gradient) => { - StringOrCanvasGradientOrCanvasPattern::CanvasGradient(Root::from_ref(&*gradient)) + StringOrCanvasGradientOrCanvasPattern::CanvasGradient(DomRoot::from_ref(&*gradient)) }, CanvasFillOrStrokeStyle::Pattern(ref pattern) => { - StringOrCanvasGradientOrCanvasPattern::CanvasPattern(Root::from_ref(&*pattern)) + StringOrCanvasGradientOrCanvasPattern::CanvasPattern(DomRoot::from_ref(&*pattern)) } } } @@ -1019,14 +1019,14 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { }, StringOrCanvasGradientOrCanvasPattern::CanvasGradient(gradient) => { self.state.borrow_mut().stroke_style = - CanvasFillOrStrokeStyle::Gradient(JS::from_ref(&*gradient)); + CanvasFillOrStrokeStyle::Gradient(Dom::from_ref(&*gradient)); let msg = CanvasMsg::Canvas2d( Canvas2dMsg::SetStrokeStyle(gradient.to_fill_or_stroke_style())); self.ipc_renderer.send(msg).unwrap(); }, StringOrCanvasGradientOrCanvasPattern::CanvasPattern(pattern) => { self.state.borrow_mut().stroke_style = - CanvasFillOrStrokeStyle::Pattern(JS::from_ref(&*pattern)); + CanvasFillOrStrokeStyle::Pattern(Dom::from_ref(&*pattern)); let msg = CanvasMsg::Canvas2d( Canvas2dMsg::SetStrokeStyle(pattern.to_fill_or_stroke_style())); self.ipc_renderer.send(msg).unwrap(); @@ -1046,10 +1046,10 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { StringOrCanvasGradientOrCanvasPattern::String(DOMString::from(result)) }, CanvasFillOrStrokeStyle::Gradient(ref gradient) => { - StringOrCanvasGradientOrCanvasPattern::CanvasGradient(Root::from_ref(&*gradient)) + StringOrCanvasGradientOrCanvasPattern::CanvasGradient(DomRoot::from_ref(&*gradient)) }, CanvasFillOrStrokeStyle::Pattern(ref pattern) => { - StringOrCanvasGradientOrCanvasPattern::CanvasPattern(Root::from_ref(&*pattern)) + StringOrCanvasGradientOrCanvasPattern::CanvasPattern(DomRoot::from_ref(&*pattern)) } } } @@ -1068,14 +1068,14 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { } StringOrCanvasGradientOrCanvasPattern::CanvasGradient(gradient) => { self.state.borrow_mut().fill_style = - CanvasFillOrStrokeStyle::Gradient(JS::from_ref(&*gradient)); + CanvasFillOrStrokeStyle::Gradient(Dom::from_ref(&*gradient)); let msg = CanvasMsg::Canvas2d( Canvas2dMsg::SetFillStyle(gradient.to_fill_or_stroke_style())); self.ipc_renderer.send(msg).unwrap(); } StringOrCanvasGradientOrCanvasPattern::CanvasPattern(pattern) => { self.state.borrow_mut().fill_style = - CanvasFillOrStrokeStyle::Pattern(JS::from_ref(&*pattern)); + CanvasFillOrStrokeStyle::Pattern(Dom::from_ref(&*pattern)); let msg = CanvasMsg::Canvas2d( Canvas2dMsg::SetFillStyle(pattern.to_fill_or_stroke_style())); self.ipc_renderer.send(msg).unwrap(); @@ -1087,7 +1087,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata - fn CreateImageData(&self, sw: Finite, sh: Finite) -> Fallible> { + fn CreateImageData(&self, sw: Finite, sh: Finite) -> Fallible> { if *sw == 0.0 || *sh == 0.0 { return Err(Error::IndexSize); } @@ -1098,7 +1098,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata - fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible> { + fn CreateImageData_(&self, imagedata: &ImageData) -> Fallible> { ImageData::new(&self.global(), imagedata.Width(), imagedata.Height(), @@ -1111,7 +1111,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { sy: Finite, sw: Finite, sh: Finite) - -> Fallible> { + -> Fallible> { if !self.origin_is_clean() { return Err(Error::Security) } @@ -1198,7 +1198,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { y0: Finite, x1: Finite, y1: Finite) - -> Root { + -> DomRoot { CanvasGradient::new(&self.global(), CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0, *y0, @@ -1215,7 +1215,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { x1: Finite, y1: Finite, r1: Finite) - -> Fallible> { + -> Fallible> { if *r0 < 0. || *r1 < 0. { return Err(Error::IndexSize); } @@ -1234,7 +1234,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D { fn CreatePattern(&self, image: CanvasImageSource, mut repetition: DOMString) - -> Fallible> { + -> Fallible> { let (image_data, image_size) = match image { CanvasImageSource::HTMLImageElement(ref image) => { // https://html.spec.whatwg.org/multipage/#img-error diff --git a/servo/components/script/dom/characterdata.rs b/servo/components/script/dom/characterdata.rs index 747589ada5dd..65c84f1e2c0b 100644 --- a/servo/components/script/dom/characterdata.rs +++ b/servo/components/script/dom/characterdata.rs @@ -4,7 +4,7 @@ //! DOM bindings for `CharacterData`. -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::ProcessingInstructionBinding::ProcessingInstructionMethods; @@ -12,7 +12,7 @@ use dom::bindings::codegen::InheritTypes::{CharacterDataTypeId, NodeTypeId}; use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, Root}; +use dom::bindings::root::{DomRoot, LayoutDom}; use dom::bindings::str::DOMString; use dom::comment::Comment; use dom::document::Document; @@ -29,28 +29,28 @@ use std::cell::Ref; #[dom_struct] pub struct CharacterData { node: Node, - data: DOMRefCell, + data: DomRefCell, } impl CharacterData { pub fn new_inherited(data: DOMString, document: &Document) -> CharacterData { CharacterData { node: Node::new_inherited(document), - data: DOMRefCell::new(data), + data: DomRefCell::new(data), } } - pub fn clone_with_data(&self, data: DOMString, document: &Document) -> Root { + pub fn clone_with_data(&self, data: DOMString, document: &Document) -> DomRoot { match self.upcast::().type_id() { NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => { - Root::upcast(Comment::new(data, &document)) + DomRoot::upcast(Comment::new(data, &document)) } NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => { let pi = self.downcast::().unwrap(); - Root::upcast(ProcessingInstruction::new(pi.Target(), data, &document)) + DomRoot::upcast(ProcessingInstruction::new(pi.Target(), data, &document)) }, NodeTypeId::CharacterData(CharacterDataTypeId::Text) => { - Root::upcast(Text::new(data, &document)) + DomRoot::upcast(Text::new(data, &document)) }, _ => unreachable!(), } @@ -237,13 +237,13 @@ impl CharacterDataMethods for CharacterData { } // https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling - fn GetPreviousElementSibling(&self) -> Option> { - self.upcast::().preceding_siblings().filter_map(Root::downcast).next() + fn GetPreviousElementSibling(&self) -> Option> { + self.upcast::().preceding_siblings().filter_map(DomRoot::downcast).next() } // https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling - fn GetNextElementSibling(&self) -> Option> { - self.upcast::().following_siblings().filter_map(Root::downcast).next() + fn GetNextElementSibling(&self) -> Option> { + self.upcast::().following_siblings().filter_map(DomRoot::downcast).next() } } @@ -253,7 +253,7 @@ pub trait LayoutCharacterDataHelpers { } #[allow(unsafe_code)] -impl LayoutCharacterDataHelpers for LayoutJS { +impl LayoutCharacterDataHelpers for LayoutDom { #[inline] unsafe fn data_for_layout(&self) -> &str { &(*self.unsafe_get()).data.borrow_for_layout() diff --git a/servo/components/script/dom/client.rs b/servo/components/script/dom/client.rs index 7910ffc8dfa2..e4bb8f137a1d 100644 --- a/servo/components/script/dom/client.rs +++ b/servo/components/script/dom/client.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap}; use dom::bindings::codegen::Bindings::ClientBinding::FrameType; -use dom::bindings::js::{Root, MutNullableJS}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::{DOMString, USVString}; use dom::serviceworker::ServiceWorker; use dom::window::Window; @@ -17,7 +17,7 @@ use uuid::Uuid; #[dom_struct] pub struct Client { reflector_: Reflector, - active_worker: MutNullableJS, + active_worker: MutNullableDom, url: ServoUrl, frame_type: FrameType, #[ignore_heap_size_of = "Defined in uuid"] @@ -35,7 +35,7 @@ impl Client { } } - pub fn new(window: &Window) -> Root { + pub fn new(window: &Window) -> DomRoot { reflect_dom_object(box Client::new_inherited(window.get_url()), window, Wrap) @@ -45,7 +45,7 @@ impl Client { self.url.clone() } - pub fn get_controller(&self) -> Option> { + pub fn get_controller(&self) -> Option> { self.active_worker.get() } diff --git a/servo/components/script/dom/closeevent.rs b/servo/components/script/dom/closeevent.rs index f052c0eff44d..ef25e97c945f 100644 --- a/servo/components/script/dom/closeevent.rs +++ b/servo/components/script/dom/closeevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::CloseEventBinding::CloseEventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::globalscope::GlobalScope; @@ -33,7 +33,7 @@ impl CloseEvent { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root { + pub fn new_uninitialized(global: &GlobalScope) -> DomRoot { reflect_dom_object(box CloseEvent::new_inherited(false, 0, DOMString::new()), global, CloseEventBinding::Wrap) @@ -46,7 +46,7 @@ impl CloseEvent { wasClean: bool, code: u16, reason: DOMString) - -> Root { + -> DomRoot { let event = box CloseEvent::new_inherited(wasClean, code, reason); let ev = reflect_dom_object(event, global, CloseEventBinding::Wrap); { @@ -61,7 +61,7 @@ impl CloseEvent { pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &CloseEventBinding::CloseEventInit) - -> Fallible> { + -> Fallible> { let bubbles = EventBubbles::from(init.parent.bubbles); let cancelable = EventCancelable::from(init.parent.cancelable); Ok(CloseEvent::new(global, diff --git a/servo/components/script/dom/comment.rs b/servo/components/script/dom/comment.rs index ad5121326988..a42ba542eb5f 100644 --- a/servo/components/script/dom/comment.rs +++ b/servo/components/script/dom/comment.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::CommentBinding; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::characterdata::CharacterData; use dom::document::Document; @@ -26,13 +26,13 @@ impl Comment { } } - pub fn new(text: DOMString, document: &Document) -> Root { + pub fn new(text: DOMString, document: &Document) -> DomRoot { Node::reflect_node(box Comment::new_inherited(text, document), document, CommentBinding::Wrap) } - pub fn Constructor(window: &Window, data: DOMString) -> Fallible> { + pub fn Constructor(window: &Window, data: DOMString) -> Fallible> { let document = window.Document(); Ok(Comment::new(data, &document)) } diff --git a/servo/components/script/dom/compositionevent.rs b/servo/components/script/dom/compositionevent.rs index c1f84386adec..f28f9229742c 100644 --- a/servo/components/script/dom/compositionevent.rs +++ b/servo/components/script/dom/compositionevent.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::CompositionEventBinding::{self, CompositionEventMethods}; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::{Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, RootedReference}; use dom::bindings::str::DOMString; use dom::uievent::UIEvent; use dom::window::Window; @@ -25,7 +25,7 @@ impl CompositionEvent { cancelable: bool, view: Option<&Window>, detail: i32, - data: DOMString) -> Root { + data: DOMString) -> DomRoot { let ev = reflect_dom_object(box CompositionEvent { uievent: UIEvent::new_inherited(), data: data, @@ -39,7 +39,7 @@ impl CompositionEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &CompositionEventBinding::CompositionEventInit) - -> Fallible> { + -> Fallible> { let event = CompositionEvent::new(window, type_, init.parent.parent.bubbles, diff --git a/servo/components/script/dom/create.rs b/servo/components/script/dom/create.rs index 922757593f35..39e91a215e52 100644 --- a/servo/components/script/dom/create.rs +++ b/servo/components/script/dom/create.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::error::{report_pending_exception, throw_dom_exception}; -use dom::bindings::js::Root; use dom::bindings::reflector::DomObject; +use dom::bindings::root::DomRoot; use dom::customelementregistry::{is_valid_custom_element_name, upgrade_element}; use dom::document::Document; use dom::element::{CustomElementCreationMode, CustomElementState, Element, ElementCreator}; @@ -87,17 +87,17 @@ use servo_config::prefs::PREFS; fn create_svg_element(name: QualName, prefix: Option, document: &Document) - -> Root { + -> DomRoot { assert!(name.ns == ns!(svg)); macro_rules! make( ($ctor:ident) => ({ let obj = $ctor::new(name.local, prefix, document); - Root::upcast(obj) + DomRoot::upcast(obj) }); ($ctor:ident, $($arg:expr),+) => ({ let obj = $ctor::new(name.local, prefix, document, $($arg),+); - Root::upcast(obj) + DomRoot::upcast(obj) }) ); @@ -119,7 +119,7 @@ fn create_html_element(name: QualName, document: &Document, creator: ElementCreator, mode: CustomElementCreationMode) - -> Root { + -> DomRoot { assert!(name.ns == ns!(html)); // Step 4 @@ -129,7 +129,7 @@ fn create_html_element(name: QualName, if definition.is_autonomous() { match mode { CustomElementCreationMode::Asynchronous => { - let result = Root::upcast::( + let result = DomRoot::upcast::( HTMLElement::new(name.local.clone(), prefix.clone(), document)); result.set_custom_element_state(CustomElementState::Undefined); ScriptThread::enqueue_upgrade_reaction(&*result, definition); @@ -155,7 +155,7 @@ fn create_html_element(name: QualName, } // Step 6.1.2 - let element = Root::upcast::( + let element = DomRoot::upcast::( HTMLUnknownElement::new(local_name, prefix, document)); element.set_custom_element_state(CustomElementState::Failed); element @@ -195,17 +195,17 @@ pub fn create_native_html_element(name: QualName, prefix: Option, document: &Document, creator: ElementCreator) - -> Root { + -> DomRoot { assert!(name.ns == ns!(html)); macro_rules! make( ($ctor:ident) => ({ let obj = $ctor::new(name.local, prefix, document); - Root::upcast(obj) + DomRoot::upcast(obj) }); ($ctor:ident, $($arg:expr),+) => ({ let obj = $ctor::new(name.local, prefix, document, $($arg),+); - Root::upcast(obj) + DomRoot::upcast(obj) }) ); @@ -364,7 +364,7 @@ pub fn create_element(name: QualName, document: &Document, creator: ElementCreator, mode: CustomElementCreationMode) - -> Root { + -> DomRoot { let prefix = name.prefix.clone(); match name.ns { ns!(html) => create_html_element(name, prefix, is, document, creator, mode), diff --git a/servo/components/script/dom/crypto.rs b/servo/components/script/dom/crypto.rs index 986e1b0ab09d..e6c6354557f8 100644 --- a/servo/components/script/dom/crypto.rs +++ b/servo/components/script/dom/crypto.rs @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CryptoBinding; use dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use js::jsapi::{JSContext, JSObject}; @@ -22,18 +22,18 @@ unsafe_no_jsmanaged_fields!(ServoRng); pub struct Crypto { reflector_: Reflector, #[ignore_heap_size_of = "Defined in rand"] - rng: DOMRefCell, + rng: DomRefCell, } impl Crypto { fn new_inherited() -> Crypto { Crypto { reflector_: Reflector::new(), - rng: DOMRefCell::new(ServoRng::new()), + rng: DomRefCell::new(ServoRng::new()), } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box Crypto::new_inherited(), global, CryptoBinding::Wrap) } } diff --git a/servo/components/script/dom/cssfontfacerule.rs b/servo/components/script/dom/cssfontfacerule.rs index 366a28c84d12..f24c20037005 100644 --- a/servo/components/script/dom/cssfontfacerule.rs +++ b/servo/components/script/dom/cssfontfacerule.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSFontFaceRuleBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstylesheet::CSSStyleSheet; @@ -32,7 +32,7 @@ impl CSSFontFaceRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - fontfacerule: Arc>) -> Root { + fontfacerule: Arc>) -> DomRoot { reflect_dom_object(box CSSFontFaceRule::new_inherited(parent_stylesheet, fontfacerule), window, CSSFontFaceRuleBinding::Wrap) diff --git a/servo/components/script/dom/cssgroupingrule.rs b/servo/components/script/dom/cssgroupingrule.rs index 580c6f05b0da..dec666c825e0 100644 --- a/servo/components/script/dom/cssgroupingrule.rs +++ b/servo/components/script/dom/cssgroupingrule.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::CSSGroupingRuleBinding::CSSGroupingRuleMethods; use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::cssrule::CSSRule; use dom::cssrulelist::{CSSRuleList, RulesSource}; @@ -21,7 +21,7 @@ pub struct CSSGroupingRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] rules: Arc>, - rulelist: MutNullableJS, + rulelist: MutNullableDom, } impl CSSGroupingRule { @@ -30,11 +30,11 @@ impl CSSGroupingRule { CSSGroupingRule { cssrule: CSSRule::new_inherited(parent_stylesheet), rules: rules, - rulelist: MutNullableJS::new(None), + rulelist: MutNullableDom::new(None), } } - fn rulelist(&self) -> Root { + fn rulelist(&self) -> DomRoot { let parent_stylesheet = self.upcast::().parent_stylesheet(); self.rulelist.or_init(|| CSSRuleList::new(self.global().as_window(), parent_stylesheet, @@ -52,7 +52,7 @@ impl CSSGroupingRule { impl CSSGroupingRuleMethods for CSSGroupingRule { // https://drafts.csswg.org/cssom/#dom-cssgroupingrule-cssrules - fn CssRules(&self) -> Root { + fn CssRules(&self) -> DomRoot { // XXXManishearth check origin clean flag self.rulelist() } diff --git a/servo/components/script/dom/cssimportrule.rs b/servo/components/script/dom/cssimportrule.rs index 1467019cb840..78233b998e62 100644 --- a/servo/components/script/dom/cssimportrule.rs +++ b/servo/components/script/dom/cssimportrule.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSImportRuleBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstylesheet::CSSStyleSheet; @@ -34,7 +34,7 @@ impl CSSImportRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - import_rule: Arc>) -> Root { + import_rule: Arc>) -> DomRoot { reflect_dom_object(box Self::new_inherited(parent_stylesheet, import_rule), window, CSSImportRuleBinding::Wrap) diff --git a/servo/components/script/dom/csskeyframerule.rs b/servo/components/script/dom/csskeyframerule.rs index e46152700cee..e1883d33af35 100644 --- a/servo/components/script/dom/csskeyframerule.rs +++ b/servo/components/script/dom/csskeyframerule.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::{self, CSSKeyframeRuleMethods}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner}; @@ -21,7 +21,7 @@ pub struct CSSKeyframeRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] keyframerule: Arc>, - style_decl: MutNullableJS, + style_decl: MutNullableDom, } impl CSSKeyframeRule { @@ -36,7 +36,7 @@ impl CSSKeyframeRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - keyframerule: Arc>) -> Root { + keyframerule: Arc>) -> DomRoot { reflect_dom_object(box CSSKeyframeRule::new_inherited(parent_stylesheet, keyframerule), window, CSSKeyframeRuleBinding::Wrap) @@ -45,13 +45,13 @@ impl CSSKeyframeRule { impl CSSKeyframeRuleMethods for CSSKeyframeRule { // https://drafts.csswg.org/css-animations/#dom-csskeyframerule-style - fn Style(&self) -> Root { + fn Style(&self) -> DomRoot { self.style_decl.or_init(|| { let guard = self.cssrule.shared_lock().read(); CSSStyleDeclaration::new( self.global().as_window(), CSSStyleOwner::CSSRule( - JS::from_ref(self.upcast()), + Dom::from_ref(self.upcast()), self.keyframerule.read_with(&guard).block.clone(), ), None, diff --git a/servo/components/script/dom/csskeyframesrule.rs b/servo/components/script/dom/csskeyframesrule.rs index 0a5e0e35a7d1..407a3f78ff1e 100644 --- a/servo/components/script/dom/csskeyframesrule.rs +++ b/servo/components/script/dom/csskeyframesrule.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding; use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods; use dom::bindings::error::ErrorResult; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::csskeyframerule::CSSKeyframeRule; use dom::cssrule::{CSSRule, SpecificCSSRule}; @@ -26,7 +26,7 @@ pub struct CSSKeyframesRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] keyframesrule: Arc>, - rulelist: MutNullableJS, + rulelist: MutNullableDom, } impl CSSKeyframesRule { @@ -35,19 +35,19 @@ impl CSSKeyframesRule { CSSKeyframesRule { cssrule: CSSRule::new_inherited(parent_stylesheet), keyframesrule: keyframesrule, - rulelist: MutNullableJS::new(None), + rulelist: MutNullableDom::new(None), } } #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - keyframesrule: Arc>) -> Root { + keyframesrule: Arc>) -> DomRoot { reflect_dom_object(box CSSKeyframesRule::new_inherited(parent_stylesheet, keyframesrule), window, CSSKeyframesRuleBinding::Wrap) } - fn rulelist(&self) -> Root { + fn rulelist(&self) -> DomRoot { self.rulelist.or_init(|| { let parent_stylesheet = &self.upcast::().parent_stylesheet(); CSSRuleList::new(self.global().as_window(), @@ -76,7 +76,7 @@ impl CSSKeyframesRule { impl CSSKeyframesRuleMethods for CSSKeyframesRule { // https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-cssrules - fn CssRules(&self) -> Root { + fn CssRules(&self) -> DomRoot { self.rulelist() } @@ -104,10 +104,10 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule { } // https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-findrule - fn FindRule(&self, selector: DOMString) -> Option> { + fn FindRule(&self, selector: DOMString) -> Option> { self.find_rule(&selector).and_then(|idx| { self.rulelist().item(idx as u32) - }).and_then(Root::downcast) + }).and_then(DomRoot::downcast) } // https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-name diff --git a/servo/components/script/dom/cssmediarule.rs b/servo/components/script/dom/cssmediarule.rs index dd921d9f787b..3bf34bc6cf56 100644 --- a/servo/components/script/dom/cssmediarule.rs +++ b/servo/components/script/dom/cssmediarule.rs @@ -6,8 +6,8 @@ use cssparser::{Parser, ParserInput}; use dom::bindings::codegen::Bindings::CSSMediaRuleBinding; use dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::cssconditionrule::CSSConditionRule; use dom::cssrule::SpecificCSSRule; @@ -27,7 +27,7 @@ pub struct CSSMediaRule { cssconditionrule: CSSConditionRule, #[ignore_heap_size_of = "Arc"] mediarule: Arc>, - medialist: MutNullableJS, + medialist: MutNullableDom, } impl CSSMediaRule { @@ -38,19 +38,19 @@ impl CSSMediaRule { CSSMediaRule { cssconditionrule: CSSConditionRule::new_inherited(parent_stylesheet, list), mediarule: mediarule, - medialist: MutNullableJS::new(None), + medialist: MutNullableDom::new(None), } } #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - mediarule: Arc>) -> Root { + mediarule: Arc>) -> DomRoot { reflect_dom_object(box CSSMediaRule::new_inherited(parent_stylesheet, mediarule), window, CSSMediaRuleBinding::Wrap) } - fn medialist(&self) -> Root { + fn medialist(&self) -> DomRoot { self.medialist.or_init(|| { let guard = self.cssconditionrule.shared_lock().read(); MediaList::new(self.global().as_window(), @@ -108,7 +108,7 @@ impl SpecificCSSRule for CSSMediaRule { impl CSSMediaRuleMethods for CSSMediaRule { // https://drafts.csswg.org/cssom/#dom-cssgroupingrule-media - fn Media(&self) -> Root { + fn Media(&self) -> DomRoot { self.medialist() } } diff --git a/servo/components/script/dom/cssnamespacerule.rs b/servo/components/script/dom/cssnamespacerule.rs index e7cecb2ebe78..0d5768d646f7 100644 --- a/servo/components/script/dom/cssnamespacerule.rs +++ b/servo/components/script/dom/cssnamespacerule.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding; use dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstylesheet::CSSStyleSheet; @@ -33,7 +33,7 @@ impl CSSNamespaceRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - namespacerule: Arc>) -> Root { + namespacerule: Arc>) -> DomRoot { reflect_dom_object(box CSSNamespaceRule::new_inherited(parent_stylesheet, namespacerule), window, CSSNamespaceRuleBinding::Wrap) diff --git a/servo/components/script/dom/cssrule.rs b/servo/components/script/dom/cssrule.rs index 40bd087899b8..da867be8df05 100644 --- a/servo/components/script/dom/cssrule.rs +++ b/servo/components/script/dom/cssrule.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::Reflector; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::cssfontfacerule::CSSFontFaceRule; use dom::cssimportrule::CSSImportRule; @@ -27,7 +27,7 @@ use style::stylesheets::CssRule as StyleCssRule; #[dom_struct] pub struct CSSRule { reflector_: Reflector, - parent_stylesheet: JS, + parent_stylesheet: Dom, /// Whether the parentStyleSheet attribute should return null. /// We keep parent_stylesheet in that case because insertRule needs it @@ -40,7 +40,7 @@ impl CSSRule { pub fn new_inherited(parent_stylesheet: &CSSStyleSheet) -> CSSRule { CSSRule { reflector_: Reflector::new(), - parent_stylesheet: JS::from_ref(parent_stylesheet), + parent_stylesheet: Dom::from_ref(parent_stylesheet), parent_stylesheet_removed: Cell::new(false), } } @@ -72,19 +72,19 @@ impl CSSRule { // Given a StyleCssRule, create a new instance of a derived class of // CSSRule based on which rule it is pub fn new_specific(window: &Window, parent_stylesheet: &CSSStyleSheet, - rule: StyleCssRule) -> Root { + rule: StyleCssRule) -> DomRoot { // be sure to update the match in as_specific when this is updated match rule { - StyleCssRule::Import(s) => Root::upcast(CSSImportRule::new(window, parent_stylesheet, s)), - StyleCssRule::Style(s) => Root::upcast(CSSStyleRule::new(window, parent_stylesheet, s)), - StyleCssRule::FontFace(s) => Root::upcast(CSSFontFaceRule::new(window, parent_stylesheet, s)), + StyleCssRule::Import(s) => DomRoot::upcast(CSSImportRule::new(window, parent_stylesheet, s)), + StyleCssRule::Style(s) => DomRoot::upcast(CSSStyleRule::new(window, parent_stylesheet, s)), + StyleCssRule::FontFace(s) => DomRoot::upcast(CSSFontFaceRule::new(window, parent_stylesheet, s)), StyleCssRule::FontFeatureValues(_) => unimplemented!(), StyleCssRule::CounterStyle(_) => unimplemented!(), - StyleCssRule::Keyframes(s) => Root::upcast(CSSKeyframesRule::new(window, parent_stylesheet, s)), - StyleCssRule::Media(s) => Root::upcast(CSSMediaRule::new(window, parent_stylesheet, s)), - StyleCssRule::Namespace(s) => Root::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s)), - StyleCssRule::Viewport(s) => Root::upcast(CSSViewportRule::new(window, parent_stylesheet, s)), - StyleCssRule::Supports(s) => Root::upcast(CSSSupportsRule::new(window, parent_stylesheet, s)), + StyleCssRule::Keyframes(s) => DomRoot::upcast(CSSKeyframesRule::new(window, parent_stylesheet, s)), + StyleCssRule::Media(s) => DomRoot::upcast(CSSMediaRule::new(window, parent_stylesheet, s)), + StyleCssRule::Namespace(s) => DomRoot::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s)), + StyleCssRule::Viewport(s) => DomRoot::upcast(CSSViewportRule::new(window, parent_stylesheet, s)), + StyleCssRule::Supports(s) => DomRoot::upcast(CSSSupportsRule::new(window, parent_stylesheet, s)), StyleCssRule::Page(_) => unreachable!(), StyleCssRule::Document(_) => unimplemented!(), // TODO } @@ -121,11 +121,11 @@ impl CSSRuleMethods for CSSRule { } // https://drafts.csswg.org/cssom/#dom-cssrule-parentstylesheet - fn GetParentStyleSheet(&self) -> Option> { + fn GetParentStyleSheet(&self) -> Option> { if self.parent_stylesheet_removed.get() { None } else { - Some(Root::from_ref(&*self.parent_stylesheet)) + Some(DomRoot::from_ref(&*self.parent_stylesheet)) } } diff --git a/servo/components/script/dom/cssrulelist.rs b/servo/components/script/dom/cssrulelist.rs index 63420f266081..c33005d0a575 100644 --- a/servo/components/script/dom/cssrulelist.rs +++ b/servo/components/script/dom/cssrulelist.rs @@ -2,12 +2,12 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CSSRuleListBinding; use dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::csskeyframerule::CSSKeyframeRule; use dom::cssrule::CSSRule; use dom::cssstylesheet::CSSStyleSheet; @@ -36,10 +36,10 @@ impl From for Error { #[dom_struct] pub struct CSSRuleList { reflector_: Reflector, - parent_stylesheet: JS, + parent_stylesheet: Dom, #[ignore_heap_size_of = "Arc"] rules: RulesSource, - dom_rules: DOMRefCell>> + dom_rules: DomRefCell>> } pub enum RulesSource { @@ -53,24 +53,24 @@ impl CSSRuleList { let guard = parent_stylesheet.shared_lock().read(); let dom_rules = match rules { RulesSource::Rules(ref rules) => { - rules.read_with(&guard).0.iter().map(|_| MutNullableJS::new(None)).collect() + rules.read_with(&guard).0.iter().map(|_| MutNullableDom::new(None)).collect() } RulesSource::Keyframes(ref rules) => { - rules.read_with(&guard).keyframes.iter().map(|_| MutNullableJS::new(None)).collect() + rules.read_with(&guard).keyframes.iter().map(|_| MutNullableDom::new(None)).collect() } }; CSSRuleList { reflector_: Reflector::new(), - parent_stylesheet: JS::from_ref(parent_stylesheet), + parent_stylesheet: Dom::from_ref(parent_stylesheet), rules: rules, - dom_rules: DOMRefCell::new(dom_rules), + dom_rules: DomRefCell::new(dom_rules), } } #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - rules: RulesSource) -> Root { + rules: RulesSource) -> DomRoot { reflect_dom_object(box CSSRuleList::new_inherited(parent_stylesheet, rules), window, CSSRuleListBinding::Wrap) @@ -102,7 +102,7 @@ impl CSSRuleList { let parent_stylesheet = &*self.parent_stylesheet; let dom_rule = CSSRule::new_specific(&window, parent_stylesheet, new_rule); - self.dom_rules.borrow_mut().insert(index, MutNullableJS::new(Some(&*dom_rule))); + self.dom_rules.borrow_mut().insert(index, MutNullableDom::new(Some(&*dom_rule))); Ok((idx)) } @@ -133,11 +133,11 @@ impl CSSRuleList { // Remove parent stylesheets from all children pub fn deparent_all(&self) { for rule in self.dom_rules.borrow().iter() { - rule.get().map(|r| Root::upcast(r).deparent()); + rule.get().map(|r| DomRoot::upcast(r).deparent()); } } - pub fn item(&self, idx: u32) -> Option> { + pub fn item(&self, idx: u32) -> Option> { self.dom_rules.borrow().get(idx as usize).map(|rule| { rule.or_init(|| { let parent_stylesheet = &self.parent_stylesheet; @@ -149,7 +149,7 @@ impl CSSRuleList { rules.read_with(&guard).0[idx as usize].clone()) } RulesSource::Keyframes(ref rules) => { - Root::upcast(CSSKeyframeRule::new(self.global().as_window(), + DomRoot::upcast(CSSKeyframeRule::new(self.global().as_window(), parent_stylesheet, rules.read_with(&guard) .keyframes[idx as usize] @@ -170,13 +170,13 @@ impl CSSRuleList { if let RulesSource::Rules(..) = self.rules { panic!("Can only call append_lazy_rule with keyframes-backed CSSRules"); } - self.dom_rules.borrow_mut().push(MutNullableJS::new(None)); + self.dom_rules.borrow_mut().push(MutNullableDom::new(None)); } } impl CSSRuleListMethods for CSSRuleList { // https://drafts.csswg.org/cssom/#ref-for-dom-cssrulelist-item-1 - fn Item(&self, idx: u32) -> Option> { + fn Item(&self, idx: u32) -> Option> { self.item(idx) } @@ -186,7 +186,7 @@ impl CSSRuleListMethods for CSSRuleList { } // check-tidy: no specs after this line - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } } diff --git a/servo/components/script/dom/cssstyledeclaration.rs b/servo/components/script/dom/cssstyledeclaration.rs index 5aea41c1b36c..f2cb3b4e5ce2 100644 --- a/servo/components/script/dom/cssstyledeclaration.rs +++ b/servo/components/script/dom/cssstyledeclaration.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::{self, CSSStyl use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::cssrule::CSSRule; use dom::element::Element; @@ -36,8 +36,8 @@ pub struct CSSStyleDeclaration { #[derive(HeapSizeOf, JSTraceable)] #[must_root] pub enum CSSStyleOwner { - Element(JS), - CSSRule(JS, + Element(Dom), + CSSRule(Dom, #[ignore_heap_size_of = "Arc"] Arc>), } @@ -137,10 +137,10 @@ impl CSSStyleOwner { } } - fn window(&self) -> Root { + fn window(&self) -> DomRoot { match *self { CSSStyleOwner::Element(ref el) => window_from_node(&**el), - CSSStyleOwner::CSSRule(ref rule, _) => Root::from_ref(rule.global().as_window()), + CSSStyleOwner::CSSRule(ref rule, _) => DomRoot::from_ref(rule.global().as_window()), } } @@ -192,7 +192,7 @@ impl CSSStyleDeclaration { owner: CSSStyleOwner, pseudo: Option, modification_access: CSSModificationAccess) - -> Root { + -> DomRoot { reflect_dom_object(box CSSStyleDeclaration::new_inherited(owner, pseudo, modification_access), diff --git a/servo/components/script/dom/cssstylerule.rs b/servo/components/script/dom/cssstylerule.rs index 42e56a5e8fcf..e67245f835fc 100644 --- a/servo/components/script/dom/cssstylerule.rs +++ b/servo/components/script/dom/cssstylerule.rs @@ -7,8 +7,8 @@ use cssparser::ToCss; use dom::bindings::codegen::Bindings::CSSStyleRuleBinding::{self, CSSStyleRuleMethods}; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner}; @@ -27,7 +27,7 @@ pub struct CSSStyleRule { cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] stylerule: Arc>, - style_decl: MutNullableJS, + style_decl: MutNullableDom, } impl CSSStyleRule { @@ -42,7 +42,7 @@ impl CSSStyleRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - stylerule: Arc>) -> Root { + stylerule: Arc>) -> DomRoot { reflect_dom_object(box CSSStyleRule::new_inherited(parent_stylesheet, stylerule), window, CSSStyleRuleBinding::Wrap) @@ -63,13 +63,13 @@ impl SpecificCSSRule for CSSStyleRule { impl CSSStyleRuleMethods for CSSStyleRule { // https://drafts.csswg.org/cssom/#dom-cssstylerule-style - fn Style(&self) -> Root { + fn Style(&self) -> DomRoot { self.style_decl.or_init(|| { let guard = self.cssrule.shared_lock().read(); CSSStyleDeclaration::new( self.global().as_window(), CSSStyleOwner::CSSRule( - JS::from_ref(self.upcast()), + Dom::from_ref(self.upcast()), self.stylerule.read_with(&guard).block.clone() ), None, diff --git a/servo/components/script/dom/cssstylesheet.rs b/servo/components/script/dom/cssstylesheet.rs index 7a1634aa7340..bf8f34977b16 100644 --- a/servo/components/script/dom/cssstylesheet.rs +++ b/servo/components/script/dom/cssstylesheet.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::CSSStyleSheetBinding; use dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{reflect_dom_object, DomObject}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::cssrulelist::{CSSRuleList, RulesSource}; use dom::element::Element; @@ -22,8 +22,8 @@ use style::stylesheets::Stylesheet as StyleStyleSheet; #[dom_struct] pub struct CSSStyleSheet { stylesheet: StyleSheet, - owner: JS, - rulelist: MutNullableJS, + owner: Dom, + rulelist: MutNullableDom, #[ignore_heap_size_of = "Arc"] style_stylesheet: Arc, origin_clean: Cell, @@ -37,8 +37,8 @@ impl CSSStyleSheet { stylesheet: Arc) -> CSSStyleSheet { CSSStyleSheet { stylesheet: StyleSheet::new_inherited(type_, href, title), - owner: JS::from_ref(owner), - rulelist: MutNullableJS::new(None), + owner: Dom::from_ref(owner), + rulelist: MutNullableDom::new(None), style_stylesheet: stylesheet, origin_clean: Cell::new(true), } @@ -50,13 +50,13 @@ impl CSSStyleSheet { type_: DOMString, href: Option, title: Option, - stylesheet: Arc) -> Root { + stylesheet: Arc) -> DomRoot { reflect_dom_object(box CSSStyleSheet::new_inherited(owner, type_, href, title, stylesheet), window, CSSStyleSheetBinding::Wrap) } - fn rulelist(&self) -> Root { + fn rulelist(&self) -> DomRoot { self.rulelist.or_init(|| { let rules = self.style_stylesheet.contents.rules.clone(); CSSRuleList::new( @@ -92,7 +92,7 @@ impl CSSStyleSheet { impl CSSStyleSheetMethods for CSSStyleSheet { // https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssrules - fn GetCssRules(&self) -> Fallible> { + fn GetCssRules(&self) -> Fallible> { if !self.origin_clean.get() { return Err(Error::Security); } diff --git a/servo/components/script/dom/cssstylevalue.rs b/servo/components/script/dom/cssstylevalue.rs index adc70ed79722..a498ff7b59de 100644 --- a/servo/components/script/dom/cssstylevalue.rs +++ b/servo/components/script/dom/cssstylevalue.rs @@ -6,9 +6,9 @@ use cssparser::Parser; use cssparser::ParserInput; use dom::bindings::codegen::Bindings::CSSStyleValueBinding::CSSStyleValueMethods; use dom::bindings::codegen::Bindings::CSSStyleValueBinding::Wrap; -use dom::bindings::js::Root; use dom::bindings::reflector::Reflector; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -28,7 +28,7 @@ impl CSSStyleValue { } } - pub fn new(global: &GlobalScope, value: String) -> Root { + pub fn new(global: &GlobalScope, value: String) -> DomRoot { reflect_dom_object(box CSSStyleValue::new_inherited(value), global, Wrap) } } diff --git a/servo/components/script/dom/csssupportsrule.rs b/servo/components/script/dom/csssupportsrule.rs index 5971eb6a009f..fe42ebba7172 100644 --- a/servo/components/script/dom/csssupportsrule.rs +++ b/servo/components/script/dom/csssupportsrule.rs @@ -5,8 +5,8 @@ use cssparser::{Parser, ParserInput}; use dom::bindings::codegen::Bindings::CSSSupportsRuleBinding; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::cssconditionrule::CSSConditionRule; use dom::cssrule::SpecificCSSRule; @@ -40,7 +40,7 @@ impl CSSSupportsRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - supportsrule: Arc>) -> Root { + supportsrule: Arc>) -> DomRoot { reflect_dom_object(box CSSSupportsRule::new_inherited(parent_stylesheet, supportsrule), window, CSSSupportsRuleBinding::Wrap) diff --git a/servo/components/script/dom/cssviewportrule.rs b/servo/components/script/dom/cssviewportrule.rs index c9acead9bd2d..afe845a7882b 100644 --- a/servo/components/script/dom/cssviewportrule.rs +++ b/servo/components/script/dom/cssviewportrule.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSViewportRuleBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstylesheet::CSSStyleSheet; @@ -31,7 +31,7 @@ impl CSSViewportRule { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, - viewportrule: Arc>) -> Root { + viewportrule: Arc>) -> DomRoot { reflect_dom_object(box CSSViewportRule::new_inherited(parent_stylesheet, viewportrule), window, CSSViewportRuleBinding::Wrap) diff --git a/servo/components/script/dom/customelementregistry.rs b/servo/components/script/dom/customelementregistry.rs index b4ad9365f4f6..912a4038a81d 100644 --- a/servo/components/script/dom/customelementregistry.rs +++ b/servo/components/script/dom/customelementregistry.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::callback::{CallbackContainer, ExceptionHandling}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CustomElementRegistryBinding; use dom::bindings::codegen::Bindings::CustomElementRegistryBinding::CustomElementRegistryMethods; use dom::bindings::codegen::Bindings::CustomElementRegistryBinding::ElementDefinitionOptions; @@ -13,8 +13,8 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethod use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, StringificationBehavior}; use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception, throw_dom_exception}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::domexception::{DOMErrorName, DOMException}; @@ -45,29 +45,29 @@ use std::rc::Rc; pub struct CustomElementRegistry { reflector_: Reflector, - window: JS, + window: Dom, #[ignore_heap_size_of = "Rc"] - when_defined: DOMRefCell>>, + when_defined: DomRefCell>>, element_definition_is_running: Cell, #[ignore_heap_size_of = "Rc"] - definitions: DOMRefCell>>, + definitions: DomRefCell>>, } impl CustomElementRegistry { fn new_inherited(window: &Window) -> CustomElementRegistry { CustomElementRegistry { reflector_: Reflector::new(), - window: JS::from_ref(window), - when_defined: DOMRefCell::new(HashMap::new()), + window: Dom::from_ref(window), + when_defined: DomRefCell::new(HashMap::new()), element_definition_is_running: Cell::new(false), - definitions: DOMRefCell::new(HashMap::new()), + definitions: DomRefCell::new(HashMap::new()), } } - pub fn new(window: &Window) -> Root { + pub fn new(window: &Window) -> DomRoot { reflect_dom_object(box CustomElementRegistry::new_inherited(window), window, CustomElementRegistryBinding::Wrap) @@ -304,7 +304,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry { let document = self.window.Document(); // Steps 14-15 - for candidate in document.upcast::().traverse_preorder().filter_map(Root::downcast::) { + for candidate in document.upcast::().traverse_preorder().filter_map(DomRoot::downcast::) { let is = candidate.get_is(); if *candidate.local_name() == local_name && *candidate.namespace() == ns!(html) && @@ -386,7 +386,7 @@ pub struct LifecycleCallbacks { #[derive(Clone, HeapSizeOf, JSTraceable)] pub enum ConstructionStackEntry { - Element(Root), + Element(DomRoot), AlreadyConstructedMarker, } @@ -404,7 +404,7 @@ pub struct CustomElementDefinition { pub callbacks: LifecycleCallbacks, - pub construction_stack: DOMRefCell>, + pub construction_stack: DomRefCell>, } impl CustomElementDefinition { @@ -431,7 +431,7 @@ impl CustomElementDefinition { /// https://dom.spec.whatwg.org/#concept-create-element Step 6.1 #[allow(unsafe_code)] - pub fn create_element(&self, document: &Document, prefix: Option) -> Fallible> { + pub fn create_element(&self, document: &Document, prefix: Option) -> Fallible> { let window = document.window(); let cx = window.get_cx(); // Step 2 @@ -447,7 +447,7 @@ impl CustomElementDefinition { } rooted!(in(cx) let element_val = ObjectValue(element.get())); - let element: Root = match unsafe { Root::from_jsval(cx, element_val.handle(), ()) } { + let element: DomRoot = match unsafe { DomRoot::from_jsval(cx, element_val.handle(), ()) } { Ok(ConversionResult::Success(element)) => element, Ok(ConversionResult::Failure(..)) => return Err(Error::Type("Constructor did not return a DOM node".to_owned())), @@ -504,7 +504,7 @@ pub fn upgrade_element(definition: Rc, element: &Elemen } // Step 5 - definition.construction_stack.borrow_mut().push(ConstructionStackEntry::Element(Root::from_ref(element))); + definition.construction_stack.borrow_mut().push(ConstructionStackEntry::Element(DomRoot::from_ref(element))); // Step 7 let result = run_upgrade_constructor(&definition.constructor, element); @@ -612,7 +612,7 @@ impl CustomElementReaction { pub enum CallbackReaction { Connected, Disconnected, - Adopted(Root, Root), + Adopted(DomRoot, DomRoot), AttributeChanged(LocalName, Option, Option, Namespace), } @@ -627,7 +627,7 @@ enum BackupElementQueueFlag { #[derive(HeapSizeOf, JSTraceable)] #[must_root] pub struct CustomElementReactionStack { - stack: DOMRefCell>, + stack: DomRefCell>, backup_queue: ElementQueue, processing_backup_element_queue: Cell, } @@ -635,7 +635,7 @@ pub struct CustomElementReactionStack { impl CustomElementReactionStack { pub fn new() -> CustomElementReactionStack { CustomElementReactionStack { - stack: DOMRefCell::new(Vec::new()), + stack: DomRefCell::new(Vec::new()), backup_queue: ElementQueue::new(), processing_backup_element_queue: Cell::new(BackupElementQueueFlag::NotProcessing), } @@ -776,7 +776,7 @@ impl CustomElementReactionStack { #[derive(HeapSizeOf, JSTraceable)] #[must_root] struct ElementQueue { - queue: DOMRefCell>>, + queue: DomRefCell>>, } impl ElementQueue { @@ -795,12 +795,12 @@ impl ElementQueue { self.queue.borrow_mut().clear(); } - fn next_element(&self) -> Option> { - self.queue.borrow_mut().pop_front().as_ref().map(JS::deref).map(Root::from_ref) + fn next_element(&self) -> Option> { + self.queue.borrow_mut().pop_front().as_ref().map(Dom::deref).map(DomRoot::from_ref) } fn append_element(&self, element: &Element) { - self.queue.borrow_mut().push_back(JS::from_ref(element)); + self.queue.borrow_mut().push_back(Dom::from_ref(element)); } } diff --git a/servo/components/script/dom/customevent.rs b/servo/components/script/dom/customevent.rs index 7b522cde3ed0..0c2d0a26a3a8 100644 --- a/servo/components/script/dom/customevent.rs +++ b/servo/components/script/dom/customevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::CustomEventBinding::CustomEventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::bindings::trace::RootedTraceableBox; use dom::event::Event; @@ -34,7 +34,7 @@ impl CustomEvent { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root { + pub fn new_uninitialized(global: &GlobalScope) -> DomRoot { reflect_dom_object(box CustomEvent::new_inherited(), global, CustomEventBinding::Wrap) @@ -44,7 +44,7 @@ impl CustomEvent { bubbles: bool, cancelable: bool, detail: HandleValue) - -> Root { + -> DomRoot { let ev = CustomEvent::new_uninitialized(global); ev.init_custom_event(type_, bubbles, cancelable, detail); ev @@ -54,7 +54,7 @@ impl CustomEvent { pub fn Constructor(global: &GlobalScope, type_: DOMString, init: RootedTraceableBox) - -> Fallible> { + -> Fallible> { Ok(CustomEvent::new(global, Atom::from(type_), init.parent.bubbles, diff --git a/servo/components/script/dom/dedicatedworkerglobalscope.rs b/servo/components/script/dom/dedicatedworkerglobalscope.rs index 46093a7bb7f6..118f2d328874 100644 --- a/servo/components/script/dom/dedicatedworkerglobalscope.rs +++ b/servo/components/script/dom/dedicatedworkerglobalscope.rs @@ -6,13 +6,13 @@ use devtools; use devtools_traits::DevtoolScriptControlMsg; use dom::abstractworker::{SharedRt, SimpleWorkerErrorHandler, WorkerScriptMsg}; use dom::abstractworkerglobalscope::{SendableWorkerScriptChan, WorkerThreadWorkerChan}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding; use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods; use dom::bindings::error::{ErrorInfo, ErrorResult}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{Root, RootCollection}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{DomRoot, RootCollection}; use dom::bindings::str::DOMString; use dom::bindings::structuredclone::StructuredCloneData; use dom::errorevent::ErrorEvent; @@ -86,8 +86,8 @@ pub struct DedicatedWorkerGlobalScope { own_sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>, #[ignore_heap_size_of = "Defined in std"] timer_event_port: Receiver<(TrustedWorkerAddress, TimerEvent)>, - #[ignore_heap_size_of = "Trusted has unclear ownership like JS"] - worker: DOMRefCell>, + #[ignore_heap_size_of = "Trusted has unclear ownership like Dom"] + worker: DomRefCell>, #[ignore_heap_size_of = "Can't measure trait objects"] /// Sender to the parent thread. parent_sender: Box, @@ -116,7 +116,7 @@ impl DedicatedWorkerGlobalScope { own_sender: own_sender, timer_event_port: timer_event_port, parent_sender: parent_sender, - worker: DOMRefCell::new(None), + worker: DomRefCell::new(None), } } @@ -131,7 +131,7 @@ impl DedicatedWorkerGlobalScope { timer_event_chan: IpcSender, timer_event_port: Receiver<(TrustedWorkerAddress, TimerEvent)>, closing: Arc) - -> Root { + -> DomRoot { let cx = runtime.cx(); let scope = box DedicatedWorkerGlobalScope::new_inherited(init, worker_url, @@ -387,7 +387,7 @@ impl DedicatedWorkerGlobalScope { #[allow(unsafe_code)] unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool { let worker = - Root::downcast::(GlobalScope::from_context(cx)) + DomRoot::downcast::(GlobalScope::from_context(cx)) .expect("global is not a worker scope"); assert!(worker.is::()); diff --git a/servo/components/script/dom/dissimilaroriginlocation.rs b/servo/components/script/dom/dissimilaroriginlocation.rs index 7ea2e3efc3cd..b75bff7620dd 100644 --- a/servo/components/script/dom/dissimilaroriginlocation.rs +++ b/servo/components/script/dom/dissimilaroriginlocation.rs @@ -5,9 +5,9 @@ use dom::bindings::codegen::Bindings::DissimilarOriginLocationBinding; use dom::bindings::codegen::Bindings::DissimilarOriginLocationBinding::DissimilarOriginLocationMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::Reflector; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::bindings::str::USVString; use dom::dissimilaroriginwindow::DissimilarOriginWindow; @@ -27,7 +27,7 @@ pub struct DissimilarOriginLocation { reflector: Reflector, /// The window associated with this location. - window: JS, + window: Dom, } impl DissimilarOriginLocation { @@ -35,11 +35,11 @@ impl DissimilarOriginLocation { fn new_inherited(window: &DissimilarOriginWindow) -> DissimilarOriginLocation { DissimilarOriginLocation { reflector: Reflector::new(), - window: JS::from_ref(window), + window: Dom::from_ref(window), } } - pub fn new(window: &DissimilarOriginWindow) -> Root { + pub fn new(window: &DissimilarOriginWindow) -> DomRoot { reflect_dom_object(box DissimilarOriginLocation::new_inherited(window), window, DissimilarOriginLocationBinding::Wrap) diff --git a/servo/components/script/dom/dissimilaroriginwindow.rs b/servo/components/script/dom/dissimilaroriginwindow.rs index 6b0745a72e53..786169f2921a 100644 --- a/servo/components/script/dom/dissimilaroriginwindow.rs +++ b/servo/components/script/dom/dissimilaroriginwindow.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding; use dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding::DissimilarOriginWindowMethods; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::bindings::structuredclone::StructuredCloneData; use dom::dissimilaroriginlocation::DissimilarOriginLocation; @@ -37,10 +37,10 @@ pub struct DissimilarOriginWindow { globalscope: GlobalScope, /// The window proxy for this window. - window_proxy: JS, + window_proxy: Dom, /// The location of this window, initialized lazily. - location: MutNullableJS, + location: MutNullableDom, } impl DissimilarOriginWindow { @@ -48,7 +48,7 @@ impl DissimilarOriginWindow { pub fn new( global_to_clone_from: &GlobalScope, window_proxy: &WindowProxy, - ) -> Root { + ) -> DomRoot { let cx = global_to_clone_from.get_cx(); // Any timer events fired on this window are ignored. let (timer_event_chan, _) = ipc::channel().unwrap(); @@ -67,7 +67,7 @@ impl DissimilarOriginWindow { // here, but this whole DOM interface is a hack anyway. global_to_clone_from.microtask_queue().clone(), ), - window_proxy: JS::from_ref(window_proxy), + window_proxy: Dom::from_ref(window_proxy), location: Default::default(), }; unsafe { DissimilarOriginWindowBinding::Wrap(cx, win) } @@ -80,42 +80,42 @@ impl DissimilarOriginWindow { impl DissimilarOriginWindowMethods for DissimilarOriginWindow { // https://html.spec.whatwg.org/multipage/#dom-window - fn Window(&self) -> Root { - Root::from_ref(&*self.window_proxy) + fn Window(&self) -> DomRoot { + DomRoot::from_ref(&*self.window_proxy) } // https://html.spec.whatwg.org/multipage/#dom-self - fn Self_(&self) -> Root { - Root::from_ref(&*self.window_proxy) + fn Self_(&self) -> DomRoot { + DomRoot::from_ref(&*self.window_proxy) } // https://html.spec.whatwg.org/multipage/#dom-frames - fn Frames(&self) -> Root { - Root::from_ref(&*self.window_proxy) + fn Frames(&self) -> DomRoot { + DomRoot::from_ref(&*self.window_proxy) } // https://html.spec.whatwg.org/multipage/#dom-parent - fn GetParent(&self) -> Option> { + fn GetParent(&self) -> Option> { // Steps 1-3. if self.window_proxy.is_browsing_context_discarded() { return None; } // Step 4. if let Some(parent) = self.window_proxy.parent() { - return Some(Root::from_ref(parent)); + return Some(DomRoot::from_ref(parent)); } // Step 5. - Some(Root::from_ref(&*self.window_proxy)) + Some(DomRoot::from_ref(&*self.window_proxy)) } // https://html.spec.whatwg.org/multipage/#dom-top - fn GetTop(&self) -> Option> { + fn GetTop(&self) -> Option> { // Steps 1-3. if self.window_proxy.is_browsing_context_discarded() { return None; } // Steps 4-5. - Some(Root::from_ref(self.window_proxy.top())) + Some(DomRoot::from_ref(self.window_proxy.top())) } // https://html.spec.whatwg.org/multipage/#dom-length @@ -184,7 +184,7 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow { } // https://html.spec.whatwg.org/multipage/#dom-location - fn Location(&self) -> Root { + fn Location(&self) -> DomRoot { self.location.or_init(|| DissimilarOriginLocation::new(self)) } } diff --git a/servo/components/script/dom/document.rs b/servo/components/script/dom/document.rs index bccfe5a76b33..c29314d04c11 100644 --- a/servo/components/script/dom/document.rs +++ b/servo/components/script/dom/document.rs @@ -10,7 +10,7 @@ use dom::activation::{ActivationSource, synthetic_click_activation}; use dom::attr::Attr; use dom::beforeunloadevent::BeforeUnloadEvent; use dom::bindings::callback::ExceptionHandling; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use dom::bindings::codegen::Bindings::DocumentBinding; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState, ElementCreationOptions}; @@ -24,11 +24,10 @@ use dom::bindings::codegen::Bindings::WindowBinding::{FrameRequestCallback, Scro use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; -use dom::bindings::js::{JS, LayoutJS, MutNullableJS, Root}; -use dom::bindings::js::RootedReference; use dom::bindings::num::Finite; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference}; use dom::bindings::str::{DOMString, USVString}; use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type}; use dom::bindings::xmlname::XMLName::InvalidXMLName; @@ -197,7 +196,7 @@ impl PendingRestyle { struct StyleSheetInDocument { #[ignore_heap_size_of = "Arc"] sheet: Arc, - owner: JS, + owner: Dom, } impl PartialEq for StyleSheetInDocument { @@ -224,46 +223,46 @@ impl ::style::stylesheets::StylesheetInDocument for StyleSheetInDocument { #[dom_struct] pub struct Document { node: Node, - window: JS, - implementation: MutNullableJS, + window: Dom, + implementation: MutNullableDom, content_type: DOMString, last_modified: Option, encoding: Cell, has_browsing_context: bool, is_html_document: bool, activity: Cell, - url: DOMRefCell, + url: DomRefCell, #[ignore_heap_size_of = "defined in selectors"] quirks_mode: Cell, /// Caches for the getElement methods - id_map: DOMRefCell>>>, - tag_map: DOMRefCell>>, - tagns_map: DOMRefCell>>, - classes_map: DOMRefCell, JS>>, - images: MutNullableJS, - embeds: MutNullableJS, - links: MutNullableJS, - forms: MutNullableJS, - scripts: MutNullableJS, - anchors: MutNullableJS, - applets: MutNullableJS, + id_map: DomRefCell>>>, + tag_map: DomRefCell>>, + tagns_map: DomRefCell>>, + classes_map: DomRefCell, Dom>>, + images: MutNullableDom, + embeds: MutNullableDom, + links: MutNullableDom, + forms: MutNullableDom, + scripts: MutNullableDom, + anchors: MutNullableDom, + applets: MutNullableDom, /// Lock use for style attributes and author-origin stylesheet objects in this document. /// Can be acquired once for accessing many objects. style_shared_lock: StyleSharedRwLock, /// List of stylesheets associated with nodes in this document. |None| if the list needs to be refreshed. - stylesheets: DOMRefCell>, - stylesheet_list: MutNullableJS, + stylesheets: DomRefCell>, + stylesheet_list: MutNullableDom, ready_state: Cell, /// Whether the DOMContentLoaded event has already been dispatched. domcontentloaded_dispatched: Cell, /// The element that has most recently requested focus for itself. - possibly_focused: MutNullableJS, + possibly_focused: MutNullableDom, /// The element that currently has the document focus context. - focused: MutNullableJS, + focused: MutNullableDom, /// The script element that is currently executing. - current_script: MutNullableJS, + current_script: MutNullableDom, /// https://html.spec.whatwg.org/multipage/#pending-parsing-blocking-script - pending_parsing_blocking_script: DOMRefCell>, + pending_parsing_blocking_script: DomRefCell>, /// Number of stylesheets that block executing the next parser-inserted script script_blocking_stylesheets_count: Cell, /// https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing @@ -271,7 +270,7 @@ pub struct Document { /// https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-in-order-as-soon-as-possible asap_in_order_scripts_list: PendingInOrderScriptVec, /// https://html.spec.whatwg.org/multipage/#set-of-scripts-that-will-execute-as-soon-as-possible - asap_scripts_set: DOMRefCell>>, + asap_scripts_set: DomRefCell>>, /// https://html.spec.whatwg.org/multipage/#concept-n-noscript /// True if scripting is enabled for all scripts in this document scripting_enabled: bool, @@ -280,31 +279,31 @@ pub struct Document { animation_frame_ident: Cell, /// https://html.spec.whatwg.org/multipage/#list-of-animation-frame-callbacks /// List of animation frame callbacks - animation_frame_list: DOMRefCell)>>, + animation_frame_list: DomRefCell)>>, /// Whether we're in the process of running animation callbacks. /// /// Tracking this is not necessary for correctness. Instead, it is an optimization to avoid /// sending needless `ChangeRunningAnimationsState` messages to the compositor. running_animation_callbacks: Cell, /// Tracks all outstanding loads related to this document. - loader: DOMRefCell, + loader: DomRefCell, /// The current active HTML parser, to allow resuming after interruptions. - current_parser: MutNullableJS, + current_parser: MutNullableDom, /// When we should kick off a reflow. This happens during parsing. reflow_timeout: Cell>, /// The cached first `base` element with an `href` attribute. - base_element: MutNullableJS, + base_element: MutNullableDom, /// This field is set to the document itself for inert documents. /// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document - appropriate_template_contents_owner_document: MutNullableJS, + appropriate_template_contents_owner_document: MutNullableDom, /// Information on elements needing restyle to ship over to the layout thread when the /// time comes. - pending_restyles: DOMRefCell, PendingRestyle>>, + pending_restyles: DomRefCell, PendingRestyle>>, /// This flag will be true if layout suppressed a reflow attempt that was /// needed in order for the page to be painted. needs_paint: Cell, /// http://w3c.github.io/touch-events/#dfn-active-touch-point - active_touch_points: DOMRefCell>>, + active_touch_points: DomRefCell>>, /// Navigation Timing properties: /// https://w3c.github.io/navigation-timing/#sec-PerformanceNavigationTiming dom_loading: Cell, @@ -324,10 +323,10 @@ pub struct Document { /// https://html.spec.whatwg.org/multipage/#dom-document-referrer referrer: Option, /// https://html.spec.whatwg.org/multipage/#target-element - target_element: MutNullableJS, + target_element: MutNullableDom, /// https://w3c.github.io/uievents/#event-type-dblclick #[ignore_heap_size_of = "Defined in std"] - last_click_info: DOMRefCell)>>, + last_click_info: DomRefCell)>>, /// https://html.spec.whatwg.org/multipage/#ignore-destructive-writes-counter ignore_destructive_writes_counter: Cell, /// The number of spurious `requestAnimationFrame()` requests we've received. @@ -342,13 +341,13 @@ pub struct Document { /// See also: https://github.com/servo/servo/issues/10110 dom_count: Cell, /// Entry node for fullscreen. - fullscreen_element: MutNullableJS, + fullscreen_element: MutNullableDom, /// Map from ID to set of form control elements that have that ID as /// their 'form' content attribute. Used to reset form controls /// whenever any element with the same ID as the form attribute /// is inserted or removed from the document. /// See https://html.spec.whatwg.org/multipage/#form-owner - form_id_listener_map: DOMRefCell>>>, + form_id_listener_map: DomRefCell>>>, } #[derive(HeapSizeOf, JSTraceable)] @@ -424,7 +423,7 @@ impl Document { /// https://html.spec.whatwg.org/multipage/#concept-document-bc #[inline] - pub fn browsing_context(&self) -> Option> { + pub fn browsing_context(&self) -> Option> { if self.has_browsing_context { self.window.undiscarded_window_proxy() } else { @@ -524,7 +523,7 @@ impl Document { } /// Returns the first `base` element in the DOM that has an `href` attribute. - pub fn base_element(&self) -> Option> { + pub fn base_element(&self) -> Option> { self.base_element.get() } @@ -533,7 +532,7 @@ impl Document { pub fn refresh_base_element(&self) { let base = self.upcast::() .traverse_preorder() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .find(|element| element.upcast::().has_attribute(&local_name!("href"))); self.base_element.set(base.r()); } @@ -660,13 +659,13 @@ impl Document { let mut map = self.form_id_listener_map.borrow_mut(); let listener = listener.to_element(); let set = map.entry(Atom::from(id)).or_insert(HashSet::new()); - set.insert(JS::from_ref(listener)); + set.insert(Dom::from_ref(listener)); } pub fn unregister_form_id_listener(&self, id: DOMString, listener: &T) { let mut map = self.form_id_listener_map.borrow_mut(); if let Occupied(mut entry) = map.entry(Atom::from(id)) { - entry.get_mut().remove(&JS::from_ref(listener.to_element())); + entry.get_mut().remove(&Dom::from_ref(listener.to_element())); if entry.get().is_empty() { entry.remove(); } @@ -675,7 +674,7 @@ impl Document { /// Attempt to find a named element in this page's document. /// https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document - pub fn find_fragment_node(&self, fragid: &str) -> Option> { + pub fn find_fragment_node(&self, fragid: &str) -> Option> { // Step 1 is not handled here; the fragid is already obtained by the calling function // Step 2: Simply use None to indicate the top of the document. // Step 3 & 4 @@ -731,7 +730,7 @@ impl Document { } } - fn get_anchor_by_name(&self, name: &str) -> Option> { + fn get_anchor_by_name(&self, name: &str) -> Option> { let check_anchor = |node: &HTMLAnchorElement| { let elem = node.upcast::(); elem.get_attribute(&ns!(), &local_name!("name")) @@ -739,9 +738,9 @@ impl Document { }; let doc_node = self.upcast::(); doc_node.traverse_preorder() - .filter_map(Root::downcast) + .filter_map(DomRoot::downcast) .find(|node| check_anchor(&node)) - .map(Root::upcast) + .map(DomRoot::upcast) } // https://html.spec.whatwg.org/multipage/#current-document-readiness @@ -772,7 +771,7 @@ impl Document { /// Return the element that currently has focus. // https://w3c.github.io/uievents/#events-focusevent-doc-focus - pub fn get_focused_element(&self) -> Option> { + pub fn get_focused_element(&self) -> Option> { self.focused.get() } @@ -864,10 +863,10 @@ impl Document { }; let el = match node.downcast::() { - Some(el) => Root::from_ref(el), + Some(el) => DomRoot::from_ref(el), None => { let parent = node.GetParentNode(); - match parent.and_then(Root::downcast::) { + match parent.and_then(DomRoot::downcast::) { Some(parent) => parent, None => return, } @@ -1019,10 +1018,10 @@ impl Document { }; let el = match node.downcast::() { - Some(el) => Root::from_ref(el), + Some(el) => DomRoot::from_ref(el), None => { let parent = node.GetParentNode(); - match parent.and_then(Root::downcast::) { + match parent.and_then(DomRoot::downcast::) { Some(parent) => parent, None => return } @@ -1113,7 +1112,7 @@ impl Document { pub fn handle_mouse_move_event(&self, js_runtime: *mut JSRuntime, client_point: Option>, - prev_mouse_over_target: &MutNullableJS) { + prev_mouse_over_target: &MutNullableDom) { let client_point = match client_point { None => { // If there's no point, there's no target under the mouse @@ -1127,7 +1126,7 @@ impl Document { let maybe_new_target = self.window.hit_test_query(client_point, true).and_then(|address| { let node = unsafe { node::from_untrusted_node_address(js_runtime, address) }; node.inclusive_ancestors() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .next() }); @@ -1170,7 +1169,7 @@ impl Document { if !old_target_is_ancestor_of_new_target { for element in old_target.upcast::() .inclusive_ancestors() - .filter_map(Root::downcast::) { + .filter_map(DomRoot::downcast::) { element.set_hover_state(false); element.set_active_state(false); } @@ -1186,7 +1185,7 @@ impl Document { if let Some(ref new_target) = maybe_new_target { for element in new_target.upcast::() .inclusive_ancestors() - .filter_map(Root::downcast::) { + .filter_map(DomRoot::downcast::) { if element.hover_state() { break; } @@ -1230,10 +1229,10 @@ impl Document { None => return TouchEventResult::Processed(false), }; let el = match node.downcast::() { - Some(el) => Root::from_ref(el), + Some(el) => DomRoot::from_ref(el), None => { let parent = node.GetParentNode(); - match parent.and_then(Root::downcast::) { + match parent.and_then(DomRoot::downcast::) { Some(parent) => parent, None => return TouchEventResult::Processed(false), } @@ -1254,7 +1253,7 @@ impl Document { return TouchEventResult::Forwarded; } - let target = Root::upcast::(el); + let target = DomRoot::upcast::(el); let window = &*self.window; let client_x = Finite::wrap(point.x as f64); @@ -1275,13 +1274,13 @@ impl Document { match event_type { TouchEventType::Down => { // Add a new touch point - self.active_touch_points.borrow_mut().push(JS::from_ref(&*touch)); + self.active_touch_points.borrow_mut().push(Dom::from_ref(&*touch)); } TouchEventType::Move => { // Replace an existing touch point let mut active_touch_points = self.active_touch_points.borrow_mut(); match active_touch_points.iter_mut().find(|t| t.Identifier() == identifier) { - Some(t) => *t = JS::from_ref(&*touch), + Some(t) => *t = Dom::from_ref(&*touch), None => warn!("Got a touchmove event for a non-active touch point"), } } @@ -1456,21 +1455,21 @@ impl Document { // https://dom.spec.whatwg.org/#converting-nodes-into-a-node pub fn node_from_nodes_and_strings(&self, mut nodes: Vec) - -> Fallible> { + -> Fallible> { if nodes.len() == 1 { Ok(match nodes.pop().unwrap() { NodeOrString::Node(node) => node, - NodeOrString::String(string) => Root::upcast(self.CreateTextNode(string)), + NodeOrString::String(string) => DomRoot::upcast(self.CreateTextNode(string)), }) } else { - let fragment = Root::upcast::(self.CreateDocumentFragment()); + let fragment = DomRoot::upcast::(self.CreateDocumentFragment()); for node in nodes { match node { NodeOrString::Node(node) => { fragment.AppendChild(&node)?; }, NodeOrString::String(string) => { - let node = Root::upcast::(self.CreateTextNode(string)); + let node = DomRoot::upcast::(self.CreateTextNode(string)); // No try!() here because appending a text node // should not fail. fragment.AppendChild(&node).unwrap(); @@ -1482,7 +1481,7 @@ impl Document { } pub fn get_body_attribute(&self, local_name: &LocalName) -> DOMString { - match self.GetBody().and_then(Root::downcast::) { + match self.GetBody().and_then(DomRoot::downcast::) { Some(ref body) => { body.upcast::().get_string_attribute(local_name) }, @@ -1491,7 +1490,7 @@ impl Document { } pub fn set_body_attribute(&self, local_name: &LocalName, value: DOMString) { - if let Some(ref body) = self.GetBody().and_then(Root::downcast::) { + if let Some(ref body) = self.GetBody().and_then(DomRoot::downcast::) { let body = body.upcast::(); let value = body.parse_attribute(&ns!(), &local_name, value); body.set_attribute(local_name, value); @@ -1821,7 +1820,7 @@ impl Document { // https://html.spec.whatwg.org/multipage/#set-of-scripts-that-will-execute-as-soon-as-possible pub fn add_asap_script(&self, script: &HTMLScriptElement) { - self.asap_scripts_set.borrow_mut().push(JS::from_ref(script)); + self.asap_scripts_set.borrow_mut().push(Dom::from_ref(script)); } /// https://html.spec.whatwg.org/multipage/#the-end step 5. @@ -1949,19 +1948,19 @@ impl Document { self.current_parser.set(script); } - pub fn get_current_parser(&self) -> Option> { + pub fn get_current_parser(&self) -> Option> { self.current_parser.get() } /// Iterate over all iframes in the document. - pub fn iter_iframes(&self) -> impl Iterator> { + pub fn iter_iframes(&self) -> impl Iterator> { self.upcast::() .traverse_preorder() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) } /// Find an iframe element in the document. - pub fn find_iframe(&self, browsing_context_id: BrowsingContextId) -> Option> { + pub fn find_iframe(&self, browsing_context_id: BrowsingContextId) -> Option> { self.iter_iframes() .find(|node| node.browsing_context_id() == Some(browsing_context_id)) } @@ -1969,7 +1968,7 @@ impl Document { /// Find a mozbrowser iframe element in the document. pub fn find_mozbrowser_iframe(&self, top_level_browsing_context_id: TopLevelBrowsingContextId) - -> Option> + -> Option> { match self.find_iframe(BrowsingContextId::from(top_level_browsing_context_id)) { None => None, @@ -2083,7 +2082,7 @@ pub enum DocumentSource { #[allow(unsafe_code)] pub trait LayoutDocumentHelpers { unsafe fn is_html_document_for_layout(&self) -> bool; - unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutJS, PendingRestyle)>; + unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom, PendingRestyle)>; unsafe fn needs_paint_from_layout(&self); unsafe fn will_paint(&self); unsafe fn quirks_mode(&self) -> QuirksMode; @@ -2091,7 +2090,7 @@ pub trait LayoutDocumentHelpers { } #[allow(unsafe_code)] -impl LayoutDocumentHelpers for LayoutJS { +impl LayoutDocumentHelpers for LayoutDom { #[inline] unsafe fn is_html_document_for_layout(&self) -> bool { (*self.unsafe_get()).is_html_document @@ -2099,7 +2098,7 @@ impl LayoutDocumentHelpers for LayoutJS { #[inline] #[allow(unrooted_must_root)] - unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutJS, PendingRestyle)> { + unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom, PendingRestyle)> { let mut elements = (*self.unsafe_get()).pending_restyles.borrow_mut_for_layout(); // Elements were in a document when they were adding to this list, but that // may no longer be true when the next layout occurs. @@ -2218,7 +2217,7 @@ impl Document { Document { node: Node::new_document_node(), - window: JS::from_ref(window), + window: Dom::from_ref(window), has_browsing_context: has_browsing_context == HasBrowsingContext::Yes, implementation: Default::default(), content_type: match content_type { @@ -2231,17 +2230,17 @@ impl Document { }), }, last_modified: last_modified, - url: DOMRefCell::new(url), + url: DomRefCell::new(url), // https://dom.spec.whatwg.org/#concept-document-quirks quirks_mode: Cell::new(QuirksMode::NoQuirks), // https://dom.spec.whatwg.org/#concept-document-encoding encoding: Cell::new(UTF_8), is_html_document: is_html_document == IsHTMLDocument::HTMLDocument, activity: Cell::new(activity), - id_map: DOMRefCell::new(HashMap::new()), - tag_map: DOMRefCell::new(HashMap::new()), - tagns_map: DOMRefCell::new(HashMap::new()), - classes_map: DOMRefCell::new(HashMap::new()), + id_map: DomRefCell::new(HashMap::new()), + tag_map: DomRefCell::new(HashMap::new()), + tagns_map: DomRefCell::new(HashMap::new()), + classes_map: DomRefCell::new(HashMap::new()), images: Default::default(), embeds: Default::default(), links: Default::default(), @@ -2264,8 +2263,8 @@ impl Document { PER_PROCESS_AUTHOR_SHARED_LOCK.clone() //StyleSharedRwLock::new() }, - stylesheets: DOMRefCell::new(StylesheetSet::new()), - stylesheet_list: MutNullableJS::new(None), + stylesheets: DomRefCell::new(StylesheetSet::new()), + stylesheet_list: MutNullableDom::new(None), ready_state: Cell::new(ready_state), domcontentloaded_dispatched: Cell::new(domcontentloaded_dispatched), possibly_focused: Default::default(), @@ -2278,16 +2277,16 @@ impl Document { asap_scripts_set: Default::default(), scripting_enabled: has_browsing_context == HasBrowsingContext::Yes, animation_frame_ident: Cell::new(0), - animation_frame_list: DOMRefCell::new(vec![]), + animation_frame_list: DomRefCell::new(vec![]), running_animation_callbacks: Cell::new(false), - loader: DOMRefCell::new(doc_loader), + loader: DomRefCell::new(doc_loader), current_parser: Default::default(), reflow_timeout: Cell::new(None), base_element: Default::default(), appropriate_template_contents_owner_document: Default::default(), - pending_restyles: DOMRefCell::new(HashMap::new()), + pending_restyles: DomRefCell::new(HashMap::new()), needs_paint: Cell::new(false), - active_touch_points: DOMRefCell::new(Vec::new()), + active_touch_points: DomRefCell::new(Vec::new()), dom_loading: Cell::new(Default::default()), dom_interactive: Cell::new(Default::default()), dom_content_loaded_event_start: Cell::new(Default::default()), @@ -2300,18 +2299,18 @@ impl Document { origin: origin, referrer: referrer, referrer_policy: Cell::new(referrer_policy), - target_element: MutNullableJS::new(None), - last_click_info: DOMRefCell::new(None), + target_element: MutNullableDom::new(None), + last_click_info: DomRefCell::new(None), ignore_destructive_writes_counter: Default::default(), spurious_animation_frames: Cell::new(0), dom_count: Cell::new(1), - fullscreen_element: MutNullableJS::new(None), + fullscreen_element: MutNullableDom::new(None), form_id_listener_map: Default::default(), } } // https://dom.spec.whatwg.org/#dom-document-document - pub fn Constructor(window: &Window) -> Fallible> { + pub fn Constructor(window: &Window) -> Fallible> { let doc = window.Document(); let docloader = DocumentLoader::new(&*doc.loader()); Ok(Document::new(window, @@ -2340,7 +2339,7 @@ impl Document { doc_loader: DocumentLoader, referrer: Option, referrer_policy: Option) - -> Root { + -> DomRoot { let document = reflect_dom_object(box Document::new_inherited(window, has_browsing_context, url, @@ -2362,7 +2361,7 @@ impl Document { document } - fn create_node_list bool>(&self, callback: F) -> Root { + fn create_node_list bool>(&self, callback: F) -> DomRoot { let doc = self.GetDocumentElement(); let maybe_node = doc.r().map(Castable::upcast::); let iter = maybe_node.iter() @@ -2371,8 +2370,8 @@ impl Document { NodeList::new_simple_list(&self.window, iter) } - fn get_html_element(&self) -> Option> { - self.GetDocumentElement().and_then(Root::downcast) + fn get_html_element(&self) -> Option> { + self.GetDocumentElement().and_then(DomRoot::downcast) } /// Return a reference to the per-document shared lock used in stylesheets. @@ -2427,7 +2426,7 @@ impl Document { None, StyleSheetInDocument { sheet: s.clone(), - owner: JS::from_ref(owner), + owner: Dom::from_ref(owner), }, &guard, ); @@ -2462,7 +2461,7 @@ impl Document { let sheet = StyleSheetInDocument { sheet, - owner: JS::from_ref(owner), + owner: Dom::from_ref(owner), }; let lock = self.style_shared_lock(); @@ -2483,7 +2482,7 @@ impl Document { self.stylesheets.borrow().len() } - pub fn stylesheet_at(&self, index: usize) -> Option> { + pub fn stylesheet_at(&self, index: usize) -> Option> { let stylesheets = self.stylesheets.borrow(); stylesheets.get(Origin::Author, index).and_then(|s| { @@ -2492,7 +2491,7 @@ impl Document { } /// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document - pub fn appropriate_template_contents_owner_document(&self) -> Root { + pub fn appropriate_template_contents_owner_document(&self) -> DomRoot { self.appropriate_template_contents_owner_document.or_init(|| { let doctype = if self.is_html_document { IsHTMLDocument::HTMLDocument @@ -2517,13 +2516,13 @@ impl Document { }) } - pub fn get_element_by_id(&self, id: &Atom) -> Option> { - self.id_map.borrow().get(&id).map(|ref elements| Root::from_ref(&*(*elements)[0])) + pub fn get_element_by_id(&self, id: &Atom) -> Option> { + self.id_map.borrow().get(&id).map(|ref elements| DomRoot::from_ref(&*(*elements)[0])) } pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut { let map = self.pending_restyles.borrow_mut(); - RefMut::map(map, |m| m.entry(JS::from_ref(el)).or_insert_with(PendingRestyle::new)) + RefMut::map(map, |m| m.entry(Dom::from_ref(el)).or_insert_with(PendingRestyle::new)) } pub fn element_state_will_change(&self, el: &Element) { @@ -2748,12 +2747,12 @@ impl Element { impl DocumentMethods for Document { // https://drafts.csswg.org/cssom/#dom-document-stylesheets - fn StyleSheets(&self) -> Root { - self.stylesheet_list.or_init(|| StyleSheetList::new(&self.window, JS::from_ref(&self))) + fn StyleSheets(&self) -> DomRoot { + self.stylesheet_list.or_init(|| StyleSheetList::new(&self.window, Dom::from_ref(&self))) } // https://dom.spec.whatwg.org/#dom-document-implementation - fn Implementation(&self) -> Root { + fn Implementation(&self) -> DomRoot { self.implementation.or_init(|| DOMImplementation::new(self)) } @@ -2763,13 +2762,13 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-activeelement - fn GetActiveElement(&self) -> Option> { + fn GetActiveElement(&self) -> Option> { // TODO: Step 2. match self.get_focused_element() { Some(element) => Some(element), // Step 3. and 4. None => match self.GetBody() { // Step 5. - Some(body) => Some(Root::upcast(body)), + Some(body) => Some(DomRoot::upcast(body)), None => self.GetDocumentElement(), }, } @@ -2900,24 +2899,24 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-document-doctype - fn GetDoctype(&self) -> Option> { - self.upcast::().children().filter_map(Root::downcast).next() + fn GetDoctype(&self) -> Option> { + self.upcast::().children().filter_map(DomRoot::downcast).next() } // https://dom.spec.whatwg.org/#dom-document-documentelement - fn GetDocumentElement(&self) -> Option> { + fn GetDocumentElement(&self) -> Option> { self.upcast::().child_elements().next() } // https://dom.spec.whatwg.org/#dom-document-getelementsbytagname - fn GetElementsByTagName(&self, qualified_name: DOMString) -> Root { + fn GetElementsByTagName(&self, qualified_name: DOMString) -> DomRoot { let qualified_name = LocalName::from(&*qualified_name); match self.tag_map.borrow_mut().entry(qualified_name.clone()) { - Occupied(entry) => Root::from_ref(entry.get()), + Occupied(entry) => DomRoot::from_ref(entry.get()), Vacant(entry) => { let result = HTMLCollection::by_qualified_name( &self.window, self.upcast(), qualified_name); - entry.insert(JS::from_ref(&*result)); + entry.insert(Dom::from_ref(&*result)); result } } @@ -2927,39 +2926,39 @@ impl DocumentMethods for Document { fn GetElementsByTagNameNS(&self, maybe_ns: Option, tag_name: DOMString) - -> Root { + -> DomRoot { let ns = namespace_from_domstring(maybe_ns); let local = LocalName::from(tag_name); let qname = QualName::new(None, ns, local); match self.tagns_map.borrow_mut().entry(qname.clone()) { - Occupied(entry) => Root::from_ref(entry.get()), + Occupied(entry) => DomRoot::from_ref(entry.get()), Vacant(entry) => { let result = HTMLCollection::by_qual_tag_name(&self.window, self.upcast(), qname); - entry.insert(JS::from_ref(&*result)); + entry.insert(Dom::from_ref(&*result)); result } } } // https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname - fn GetElementsByClassName(&self, classes: DOMString) -> Root { + fn GetElementsByClassName(&self, classes: DOMString) -> DomRoot { let class_atoms: Vec = split_html_space_chars(&classes) .map(Atom::from) .collect(); match self.classes_map.borrow_mut().entry(class_atoms.clone()) { - Occupied(entry) => Root::from_ref(entry.get()), + Occupied(entry) => DomRoot::from_ref(entry.get()), Vacant(entry) => { let result = HTMLCollection::by_atomic_class_name(&self.window, self.upcast(), class_atoms); - entry.insert(JS::from_ref(&*result)); + entry.insert(Dom::from_ref(&*result)); result } } } // https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid - fn GetElementById(&self, id: DOMString) -> Option> { + fn GetElementById(&self, id: DOMString) -> Option> { self.get_element_by_id(&Atom::from(id)) } @@ -2967,7 +2966,7 @@ impl DocumentMethods for Document { fn CreateElement(&self, mut local_name: DOMString, options: &ElementCreationOptions) - -> Fallible> { + -> Fallible> { if xml_name_type(&local_name) == InvalidXMLName { debug!("Not a valid element name"); return Err(Error::InvalidCharacter); @@ -2992,7 +2991,7 @@ impl DocumentMethods for Document { namespace: Option, qualified_name: DOMString, options: &ElementCreationOptions) - -> Fallible> { + -> Fallible> { let (namespace, prefix, local_name) = validate_and_extract(namespace, &qualified_name)?; let name = QualName::new(prefix, namespace, local_name); @@ -3001,7 +3000,7 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-document-createattribute - fn CreateAttribute(&self, mut local_name: DOMString) -> Fallible> { + fn CreateAttribute(&self, mut local_name: DOMString) -> Fallible> { if xml_name_type(&local_name) == InvalidXMLName { debug!("Not a valid element name"); return Err(Error::InvalidCharacter); @@ -3019,7 +3018,7 @@ impl DocumentMethods for Document { fn CreateAttributeNS(&self, namespace: Option, qualified_name: DOMString) - -> Fallible> { + -> Fallible> { let (namespace, prefix, local_name) = validate_and_extract(namespace, &qualified_name)?; let value = AttrValue::String("".to_owned()); @@ -3034,17 +3033,17 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-document-createdocumentfragment - fn CreateDocumentFragment(&self) -> Root { + fn CreateDocumentFragment(&self) -> DomRoot { DocumentFragment::new(self) } // https://dom.spec.whatwg.org/#dom-document-createtextnode - fn CreateTextNode(&self, data: DOMString) -> Root { + fn CreateTextNode(&self, data: DOMString) -> DomRoot { Text::new(data, self) } // https://dom.spec.whatwg.org/#dom-document-createcomment - fn CreateComment(&self, data: DOMString) -> Root { + fn CreateComment(&self, data: DOMString) -> DomRoot { Comment::new(data, self) } @@ -3052,7 +3051,7 @@ impl DocumentMethods for Document { fn CreateProcessingInstruction(&self, target: DOMString, data: DOMString) - -> Fallible> { + -> Fallible> { // Step 1. if xml_name_type(&target) == InvalidXMLName { return Err(Error::InvalidCharacter); @@ -3068,7 +3067,7 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-document-importnode - fn ImportNode(&self, node: &Node, deep: bool) -> Fallible> { + fn ImportNode(&self, node: &Node, deep: bool) -> Fallible> { // Step 1. if node.is::() { return Err(Error::NotSupported); @@ -3085,7 +3084,7 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-document-adoptnode - fn AdoptNode(&self, node: &Node) -> Fallible> { + fn AdoptNode(&self, node: &Node) -> Fallible> { // Step 1. if node.is::() { return Err(Error::NotSupported); @@ -3095,44 +3094,44 @@ impl DocumentMethods for Document { Node::adopt(node, self); // Step 3. - Ok(Root::from_ref(node)) + Ok(DomRoot::from_ref(node)) } // https://dom.spec.whatwg.org/#dom-document-createevent - fn CreateEvent(&self, mut interface: DOMString) -> Fallible> { + fn CreateEvent(&self, mut interface: DOMString) -> Fallible> { interface.make_ascii_lowercase(); match &*interface { "beforeunloadevent" => - Ok(Root::upcast(BeforeUnloadEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(BeforeUnloadEvent::new_uninitialized(&self.window))), "closeevent" => - Ok(Root::upcast(CloseEvent::new_uninitialized(self.window.upcast()))), + Ok(DomRoot::upcast(CloseEvent::new_uninitialized(self.window.upcast()))), "customevent" => - Ok(Root::upcast(CustomEvent::new_uninitialized(self.window.upcast()))), + Ok(DomRoot::upcast(CustomEvent::new_uninitialized(self.window.upcast()))), "errorevent" => - Ok(Root::upcast(ErrorEvent::new_uninitialized(self.window.upcast()))), + Ok(DomRoot::upcast(ErrorEvent::new_uninitialized(self.window.upcast()))), "events" | "event" | "htmlevents" | "svgevents" => Ok(Event::new_uninitialized(&self.window.upcast())), "focusevent" => - Ok(Root::upcast(FocusEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(FocusEvent::new_uninitialized(&self.window))), "hashchangeevent" => - Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(HashChangeEvent::new_uninitialized(&self.window))), "keyboardevent" => - Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(KeyboardEvent::new_uninitialized(&self.window))), "messageevent" => - Ok(Root::upcast(MessageEvent::new_uninitialized(self.window.upcast()))), + Ok(DomRoot::upcast(MessageEvent::new_uninitialized(self.window.upcast()))), "mouseevent" | "mouseevents" => - Ok(Root::upcast(MouseEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(MouseEvent::new_uninitialized(&self.window))), "pagetransitionevent" => - Ok(Root::upcast(PageTransitionEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(PageTransitionEvent::new_uninitialized(&self.window))), "popstateevent" => - Ok(Root::upcast(PopStateEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(PopStateEvent::new_uninitialized(&self.window))), "progressevent" => - Ok(Root::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))), + Ok(DomRoot::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))), "storageevent" => { - Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, "".into()))) + Ok(DomRoot::upcast(StorageEvent::new_uninitialized(&self.window, "".into()))) }, "touchevent" => - Ok(Root::upcast( + Ok(DomRoot::upcast( TouchEvent::new_uninitialized(&self.window, &TouchList::new(&self.window, &[]), &TouchList::new(&self.window, &[]), @@ -3140,9 +3139,9 @@ impl DocumentMethods for Document { ) )), "uievent" | "uievents" => - Ok(Root::upcast(UIEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(UIEvent::new_uninitialized(&self.window))), "webglcontextevent" => - Ok(Root::upcast(WebGLContextEvent::new_uninitialized(&self.window))), + Ok(DomRoot::upcast(WebGLContextEvent::new_uninitialized(&self.window))), _ => Err(Error::NotSupported), } @@ -3157,7 +3156,7 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-document-createrange - fn CreateRange(&self) -> Root { + fn CreateRange(&self) -> DomRoot { Range::new_with_doc(self) } @@ -3166,7 +3165,7 @@ impl DocumentMethods for Document { root: &Node, what_to_show: u32, filter: Option>) - -> Root { + -> DomRoot { NodeIterator::new(self, root, what_to_show, filter) } @@ -3179,7 +3178,7 @@ impl DocumentMethods for Document { page_y: Finite, screen_x: Finite, screen_y: Finite) - -> Root { + -> DomRoot { let client_x = Finite::wrap(*page_x - window.PageXOffset() as f64); let client_y = Finite::wrap(*page_y - window.PageYOffset() as f64); Touch::new(window, @@ -3194,7 +3193,7 @@ impl DocumentMethods for Document { } // https://w3c.github.io/touch-events/#idl-def-document-createtouchlist(touch...) - fn CreateTouchList(&self, touches: &[&Touch]) -> Root { + fn CreateTouchList(&self, touches: &[&Touch]) -> DomRoot { TouchList::new(&self.window, &touches) } @@ -3203,7 +3202,7 @@ impl DocumentMethods for Document { root: &Node, what_to_show: u32, filter: Option>) - -> Root { + -> DomRoot { TreeWalker::new(self, root, what_to_show, filter) } @@ -3217,7 +3216,7 @@ impl DocumentMethods for Document { .find(|node| { node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title") }) - .map(Root::upcast::) + .map(DomRoot::upcast::) } else { // Step 2. root.upcast::() @@ -3248,7 +3247,7 @@ impl DocumentMethods for Document { node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title") }); match elem { - Some(elem) => Root::upcast::(elem), + Some(elem) => DomRoot::upcast::(elem), None => { let name = QualName::new(None, ns!(svg), local_name!("title")); let elem = Element::create(name, @@ -3293,18 +3292,18 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-head - fn GetHead(&self) -> Option> { + fn GetHead(&self) -> Option> { self.get_html_element() - .and_then(|root| root.upcast::().children().filter_map(Root::downcast).next()) + .and_then(|root| root.upcast::().children().filter_map(DomRoot::downcast).next()) } // https://html.spec.whatwg.org/multipage/#dom-document-currentscript - fn GetCurrentScript(&self) -> Option> { + fn GetCurrentScript(&self) -> Option> { self.current_script.get() } // https://html.spec.whatwg.org/multipage/#dom-document-body - fn GetBody(&self) -> Option> { + fn GetBody(&self) -> Option> { self.get_html_element().and_then(|root| { let node = root.upcast::(); node.children().find(|child| { @@ -3313,7 +3312,7 @@ impl DocumentMethods for Document { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFrameSetElement)) => true, _ => false } - }).map(|node| Root::downcast(node).unwrap()) + }).map(|node| DomRoot::downcast(node).unwrap()) }) } @@ -3358,7 +3357,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname - fn GetElementsByName(&self, name: DOMString) -> Root { + fn GetElementsByName(&self, name: DOMString) -> DomRoot { self.create_node_list(|node| { let element = match node.downcast::() { Some(element) => element, @@ -3373,7 +3372,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-images - fn Images(&self) -> Root { + fn Images(&self) -> DomRoot { self.images.or_init(|| { let filter = box ImagesFilter; HTMLCollection::create(&self.window, self.upcast(), filter) @@ -3381,7 +3380,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-embeds - fn Embeds(&self) -> Root { + fn Embeds(&self) -> DomRoot { self.embeds.or_init(|| { let filter = box EmbedsFilter; HTMLCollection::create(&self.window, self.upcast(), filter) @@ -3389,12 +3388,12 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-plugins - fn Plugins(&self) -> Root { + fn Plugins(&self) -> DomRoot { self.Embeds() } // https://html.spec.whatwg.org/multipage/#dom-document-links - fn Links(&self) -> Root { + fn Links(&self) -> DomRoot { self.links.or_init(|| { let filter = box LinksFilter; HTMLCollection::create(&self.window, self.upcast(), filter) @@ -3402,7 +3401,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-forms - fn Forms(&self) -> Root { + fn Forms(&self) -> DomRoot { self.forms.or_init(|| { let filter = box FormsFilter; HTMLCollection::create(&self.window, self.upcast(), filter) @@ -3410,7 +3409,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-scripts - fn Scripts(&self) -> Root { + fn Scripts(&self) -> DomRoot { self.scripts.or_init(|| { let filter = box ScriptsFilter; HTMLCollection::create(&self.window, self.upcast(), filter) @@ -3418,7 +3417,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-anchors - fn Anchors(&self) -> Root { + fn Anchors(&self) -> DomRoot { self.anchors.or_init(|| { let filter = box AnchorsFilter; HTMLCollection::create(&self.window, self.upcast(), filter) @@ -3426,7 +3425,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-applets - fn Applets(&self) -> Root { + fn Applets(&self) -> DomRoot { // FIXME: This should be return OBJECT elements containing applets. self.applets.or_init(|| { let filter = box AppletsFilter; @@ -3435,7 +3434,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-location - fn GetLocation(&self) -> Option> { + fn GetLocation(&self) -> Option> { if self.is_fully_active() { Some(self.window.Location()) } else { @@ -3444,18 +3443,18 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-parentnode-children - fn Children(&self) -> Root { + fn Children(&self) -> DomRoot { HTMLCollection::children(&self.window, self.upcast()) } // https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild - fn GetFirstElementChild(&self) -> Option> { + fn GetFirstElementChild(&self) -> Option> { self.upcast::().child_elements().next() } // https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild - fn GetLastElementChild(&self) -> Option> { - self.upcast::().rev_children().filter_map(Root::downcast).next() + fn GetLastElementChild(&self) -> Option> { + self.upcast::().rev_children().filter_map(DomRoot::downcast).next() } // https://dom.spec.whatwg.org/#dom-parentnode-childelementcount @@ -3474,13 +3473,13 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-parentnode-queryselector - fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { + fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { let root = self.upcast::(); root.query_selector(selectors) } // https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall - fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { + fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { let root = self.upcast::(); root.query_selector_all(selectors) } @@ -3491,9 +3490,9 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-defaultview - fn GetDefaultView(&self) -> Option> { + fn GetDefaultView(&self) -> Option> { if self.has_browsing_context { - Some(Root::from_ref(&*self.window)) + Some(DomRoot::from_ref(&*self.window)) } else { None } @@ -3674,7 +3673,7 @@ impl DocumentMethods for Document { #[allow(unsafe_code)] // https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint - fn ElementFromPoint(&self, x: Finite, y: Finite) -> Option> { + fn ElementFromPoint(&self, x: Finite, y: Finite) -> Option> { let x = *x as f32; let y = *y as f32; let point = &Point2D::new(x, y); @@ -3701,7 +3700,7 @@ impl DocumentMethods for Document { parent_node.downcast::().unwrap() }); - Some(Root::from_ref(element_ref)) + Some(DomRoot::from_ref(element_ref)) }, None => self.GetDocumentElement() } @@ -3709,7 +3708,7 @@ impl DocumentMethods for Document { #[allow(unsafe_code)] // https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint - fn ElementsFromPoint(&self, x: Finite, y: Finite) -> Vec> { + fn ElementsFromPoint(&self, x: Finite, y: Finite) -> Vec> { let x = *x as f32; let y = *y as f32; let point = &Point2D::new(x, y); @@ -3728,12 +3727,12 @@ impl DocumentMethods for Document { let js_runtime = unsafe { JS_GetRuntime(window.get_cx()) }; // Step 1 and Step 3 - let mut elements: Vec> = self.nodes_from_point(point).iter() + let mut elements: Vec> = self.nodes_from_point(point).iter() .flat_map(|&untrusted_node_address| { let node = unsafe { node::from_untrusted_node_address(js_runtime, untrusted_node_address) }; - Root::downcast::(node) + DomRoot::downcast::(node) }).collect(); // Step 4 @@ -3748,7 +3747,7 @@ impl DocumentMethods for Document { } // https://html.spec.whatwg.org/multipage/#dom-document-open - fn Open(&self, type_: DOMString, replace: DOMString) -> Fallible> { + fn Open(&self, type_: DOMString, replace: DOMString) -> Fallible> { if !self.is_html_document() { // Step 1. return Err(Error::InvalidState); @@ -3759,7 +3758,7 @@ impl DocumentMethods for Document { if !self.is_active() { // Step 3. - return Ok(Root::from_ref(self)); + return Ok(DomRoot::from_ref(self)); } let entry_responsible_document = GlobalScope::entry().as_window().Document(); @@ -3774,7 +3773,7 @@ impl DocumentMethods for Document { if self.get_current_parser().map_or(false, |parser| parser.script_nesting_level() > 0) { // Step 5. - return Ok(Root::from_ref(self)); + return Ok(DomRoot::from_ref(self)); } // Step 6. @@ -3890,7 +3889,7 @@ impl DocumentMethods for Document { // Step 34 is handled when creating the parser in step 25. // Step 35. - Ok(Root::from_ref(self)) + Ok(DomRoot::from_ref(self)) } // https://html.spec.whatwg.org/multipage/#dom-document-write @@ -3908,7 +3907,7 @@ impl DocumentMethods for Document { } let parser = match self.get_current_parser() { - Some(ref parser) if parser.can_write() => Root::from_ref(&**parser), + Some(ref parser) if parser.can_write() => DomRoot::from_ref(&**parser), _ => { // Either there is no parser, which means the parsing ended; // or script nesting level is 0, which means the method was @@ -3951,7 +3950,7 @@ impl DocumentMethods for Document { // TODO: handle throw-on-dynamic-markup-insertion counter. let parser = match self.get_current_parser() { - Some(ref parser) if parser.is_script_created() => Root::from_ref(&**parser), + Some(ref parser) if parser.is_script_created() => DomRoot::from_ref(&**parser), _ => { // Step 3. return Ok(()); @@ -3984,7 +3983,7 @@ impl DocumentMethods for Document { } // https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement - fn GetFullscreenElement(&self) -> Option> { + fn GetFullscreenElement(&self) -> Option> { // TODO ShadowRoot self.fullscreen_element.get() } @@ -4082,7 +4081,7 @@ impl AnimationFrameCallback { #[derive(Default, HeapSizeOf, JSTraceable)] #[must_root] struct PendingInOrderScriptVec { - scripts: DOMRefCell>, + scripts: DomRefCell>, } impl PendingInOrderScriptVec { @@ -4100,7 +4099,7 @@ impl PendingInOrderScriptVec { entry.loaded(result); } - fn take_next_ready_to_be_executed(&self) -> Option<(Root, ScriptResult)> { + fn take_next_ready_to_be_executed(&self) -> Option<(DomRoot, ScriptResult)> { let mut scripts = self.scripts.borrow_mut(); let pair = scripts.front_mut().and_then(PendingScript::take_result); if pair.is_none() { @@ -4118,17 +4117,17 @@ impl PendingInOrderScriptVec { #[derive(HeapSizeOf, JSTraceable)] #[must_root] struct PendingScript { - element: JS, + element: Dom, load: Option, } impl PendingScript { fn new(element: &HTMLScriptElement) -> Self { - Self { element: JS::from_ref(element), load: None } + Self { element: Dom::from_ref(element), load: None } } fn new_with_load(element: &HTMLScriptElement, load: Option) -> Self { - Self { element: JS::from_ref(element), load } + Self { element: Dom::from_ref(element), load } } fn loaded(&mut self, result: ScriptResult) { @@ -4136,7 +4135,7 @@ impl PendingScript { self.load = Some(result); } - fn take_result(&mut self) -> Option<(Root, ScriptResult)> { - self.load.take().map(|result| (Root::from_ref(&*self.element), result)) + fn take_result(&mut self) -> Option<(DomRoot, ScriptResult)> { + self.load.take().map(|result| (DomRoot::from_ref(&*self.element), result)) } } diff --git a/servo/components/script/dom/documentfragment.rs b/servo/components/script/dom/documentfragment.rs index 6f2a123dd06c..320d33416915 100644 --- a/servo/components/script/dom/documentfragment.rs +++ b/servo/components/script/dom/documentfragment.rs @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::Element; @@ -33,13 +33,13 @@ impl DocumentFragment { } } - pub fn new(document: &Document) -> Root { + pub fn new(document: &Document) -> DomRoot { Node::reflect_node(box DocumentFragment::new_inherited(document), document, DocumentFragmentBinding::Wrap) } - pub fn Constructor(window: &Window) -> Fallible> { + pub fn Constructor(window: &Window) -> Fallible> { let document = window.Document(); Ok(DocumentFragment::new(&document)) @@ -48,16 +48,16 @@ impl DocumentFragment { impl DocumentFragmentMethods for DocumentFragment { // https://dom.spec.whatwg.org/#dom-parentnode-children - fn Children(&self) -> Root { + fn Children(&self) -> DomRoot { let window = window_from_node(self); HTMLCollection::children(&window, self.upcast()) } // https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid - fn GetElementById(&self, id: DOMString) -> Option> { + fn GetElementById(&self, id: DOMString) -> Option> { let node = self.upcast::(); let id = Atom::from(id); - node.traverse_preorder().filter_map(Root::downcast::).find(|descendant| { + node.traverse_preorder().filter_map(DomRoot::downcast::).find(|descendant| { match descendant.get_attribute(&ns!(), &local_name!("id")) { None => false, Some(attr) => *attr.value().as_atom() == id, @@ -66,13 +66,13 @@ impl DocumentFragmentMethods for DocumentFragment { } // https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild - fn GetFirstElementChild(&self) -> Option> { + fn GetFirstElementChild(&self) -> Option> { self.upcast::().child_elements().next() } // https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild - fn GetLastElementChild(&self) -> Option> { - self.upcast::().rev_children().filter_map(Root::downcast::).next() + fn GetLastElementChild(&self) -> Option> { + self.upcast::().rev_children().filter_map(DomRoot::downcast::).next() } // https://dom.spec.whatwg.org/#dom-parentnode-childelementcount @@ -91,12 +91,12 @@ impl DocumentFragmentMethods for DocumentFragment { } // https://dom.spec.whatwg.org/#dom-parentnode-queryselector - fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { + fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { self.upcast::().query_selector(selectors) } // https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall - fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { + fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { self.upcast::().query_selector_all(selectors) } } diff --git a/servo/components/script/dom/documenttype.rs b/servo/components/script/dom/documenttype.rs index 2b03ce2e07bf..5fd83343570c 100644 --- a/servo/components/script/dom/documenttype.rs +++ b/servo/components/script/dom/documenttype.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods; use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::ErrorResult; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::node::Node; @@ -41,7 +41,7 @@ impl DocumentType { public_id: Option, system_id: Option, document: &Document) - -> Root { + -> DomRoot { Node::reflect_node(box DocumentType::new_inherited(name, public_id, system_id, document), document, DocumentTypeBinding::Wrap) diff --git a/servo/components/script/dom/domexception.rs b/servo/components/script/dom/domexception.rs index 63be8dc83e80..c9fc953950af 100644 --- a/servo/components/script/dom/domexception.rs +++ b/servo/components/script/dom/domexception.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::DOMExceptionBinding; use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionConstants; use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -51,7 +51,7 @@ impl DOMException { } } - pub fn new(global: &GlobalScope, code: DOMErrorName) -> Root { + pub fn new(global: &GlobalScope, code: DOMErrorName) -> DomRoot { reflect_dom_object(box DOMException::new_inherited(code), global, DOMExceptionBinding::Wrap) diff --git a/servo/components/script/dom/domimplementation.rs b/servo/components/script/dom/domimplementation.rs index 5b56242e14bc..93ba4b287ff2 100644 --- a/servo/components/script/dom/domimplementation.rs +++ b/servo/components/script/dom/domimplementation.rs @@ -9,8 +9,8 @@ use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, Element use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::bindings::xmlname::{namespace_from_domstring, validate_qualified_name}; use dom::document::{Document, HasBrowsingContext, IsHTMLDocument}; @@ -30,18 +30,18 @@ use script_traits::DocumentActivity; #[dom_struct] pub struct DOMImplementation { reflector_: Reflector, - document: JS, + document: Dom, } impl DOMImplementation { fn new_inherited(document: &Document) -> DOMImplementation { DOMImplementation { reflector_: Reflector::new(), - document: JS::from_ref(document), + document: Dom::from_ref(document), } } - pub fn new(document: &Document) -> Root { + pub fn new(document: &Document) -> DomRoot { let window = document.window(); reflect_dom_object(box DOMImplementation::new_inherited(document), window, @@ -56,7 +56,7 @@ impl DOMImplementationMethods for DOMImplementation { qualified_name: DOMString, pubid: DOMString, sysid: DOMString) - -> Fallible> { + -> Fallible> { validate_qualified_name(&qualified_name)?; Ok(DocumentType::new(qualified_name, Some(pubid), Some(sysid), &self.document)) } @@ -66,7 +66,7 @@ impl DOMImplementationMethods for DOMImplementation { maybe_namespace: Option, qname: DOMString, maybe_doctype: Option<&DocumentType>) - -> Fallible> { + -> Fallible> { let win = self.document.window(); let loader = DocumentLoader::new(&self.document.loader()); let namespace = namespace_from_domstring(maybe_namespace.to_owned()); @@ -121,7 +121,7 @@ impl DOMImplementationMethods for DOMImplementation { } // https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument - fn CreateHTMLDocument(&self, title: Option) -> Root { + fn CreateHTMLDocument(&self, title: Option) -> DomRoot { let win = self.document.window(); let loader = DocumentLoader::new(&self.document.loader()); @@ -149,14 +149,14 @@ impl DOMImplementationMethods for DOMImplementation { { // Step 4. let doc_node = doc.upcast::(); - let doc_html = Root::upcast::(HTMLHtmlElement::new(local_name!("html"), + let doc_html = DomRoot::upcast::(HTMLHtmlElement::new(local_name!("html"), None, &doc)); doc_node.AppendChild(&doc_html).expect("Appending failed"); { // Step 5. - let doc_head = Root::upcast::(HTMLHeadElement::new(local_name!("head"), + let doc_head = DomRoot::upcast::(HTMLHeadElement::new(local_name!("head"), None, &doc)); doc_html.AppendChild(&doc_head).unwrap(); @@ -165,7 +165,7 @@ impl DOMImplementationMethods for DOMImplementation { if let Some(title_str) = title { // Step 6.1. let doc_title = - Root::upcast::(HTMLTitleElement::new(local_name!("title"), + DomRoot::upcast::(HTMLTitleElement::new(local_name!("title"), None, &doc)); doc_head.AppendChild(&doc_title).unwrap(); diff --git a/servo/components/script/dom/dommatrix.rs b/servo/components/script/dom/dommatrix.rs index 3b262650bac8..9bf315299f47 100644 --- a/servo/components/script/dom/dommatrix.rs +++ b/servo/components/script/dom/dommatrix.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::DOMMatrixBinding::{Wrap, DOMMatrixMethods, use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::dommatrixreadonly::{dommatrixinit_to_matrix, DOMMatrixReadOnly, entries_to_matrix}; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -21,7 +21,7 @@ pub struct DOMMatrix { impl DOMMatrix { #[allow(unrooted_must_root)] - pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D) -> Root { + pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D) -> DomRoot { let dommatrix = Self::new_inherited(is2D, matrix); reflect_dom_object(box dommatrix, global, Wrap) } @@ -33,12 +33,12 @@ impl DOMMatrix { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Self::Constructor_(global, vec![1.0, 0.0, 0.0, 1.0, 0.0, 0.0]) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-dommatrix-numbersequence - pub fn Constructor_(global: &GlobalScope, entries: Vec) -> Fallible> { + pub fn Constructor_(global: &GlobalScope, entries: Vec) -> Fallible> { entries_to_matrix(&entries[..]) .map(|(is2D, matrix)| { Self::new(global, is2D, matrix) @@ -46,14 +46,14 @@ impl DOMMatrix { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix - pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible> { + pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible> { dommatrixinit_to_matrix(&other) .map(|(is2D, matrix)| { Self::new(global, is2D, matrix) }) } - pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> Root { + pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> DomRoot { Self::new(global, ro.is_2d(), ro.matrix().clone()) } } @@ -280,91 +280,91 @@ impl DOMMatrixMethods for DOMMatrix { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself - fn MultiplySelf(&self, other:&DOMMatrixInit) -> Fallible> { + fn MultiplySelf(&self, other:&DOMMatrixInit) -> Fallible> { // Steps 1-3. self.upcast::().multiply_self(other) // Step 4. - .and(Ok(Root::from_ref(&self))) + .and(Ok(DomRoot::from_ref(&self))) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself - fn PreMultiplySelf(&self, other:&DOMMatrixInit) -> Fallible> { + fn PreMultiplySelf(&self, other:&DOMMatrixInit) -> Fallible> { // Steps 1-3. self.upcast::().pre_multiply_self(other) // Step 4. - .and(Ok(Root::from_ref(&self))) + .and(Ok(DomRoot::from_ref(&self))) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself - fn TranslateSelf(&self, tx: f64, ty: f64, tz: f64) -> Root { + fn TranslateSelf(&self, tx: f64, ty: f64, tz: f64) -> DomRoot { // Steps 1-2. self.upcast::().translate_self(tx, ty, tz); // Step 3. - Root::from_ref(&self) + DomRoot::from_ref(&self) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself fn ScaleSelf(&self, scaleX: f64, scaleY: Option, scaleZ: f64, - originX: f64, originY: f64, originZ: f64) -> Root { + originX: f64, originY: f64, originZ: f64) -> DomRoot { // Steps 1-6. self.upcast::().scale_self(scaleX, scaleY, scaleZ, originX, originY, originZ); // Step 7. - Root::from_ref(&self) + DomRoot::from_ref(&self) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scale3dself - fn Scale3dSelf(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root { + fn Scale3dSelf(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> DomRoot { // Steps 1-4. self.upcast::().scale_3d_self(scale, originX, originY, originZ); // Step 5. - Root::from_ref(&self) + DomRoot::from_ref(&self) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateself - fn RotateSelf(&self, rotX: f64, rotY: Option, rotZ: Option) -> Root { + fn RotateSelf(&self, rotX: f64, rotY: Option, rotZ: Option) -> DomRoot { // Steps 1-7. self.upcast::().rotate_self(rotX, rotY, rotZ); // Step 8. - Root::from_ref(&self) + DomRoot::from_ref(&self) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotatefromvectorself - fn RotateFromVectorSelf(&self, x: f64, y: f64) -> Root { + fn RotateFromVectorSelf(&self, x: f64, y: f64) -> DomRoot { // Step 1. self.upcast::().rotate_from_vector_self(x, y); // Step 2. - Root::from_ref(&self) + DomRoot::from_ref(&self) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateaxisangleself - fn RotateAxisAngleSelf(&self, x: f64, y: f64, z: f64, angle: f64) -> Root { + fn RotateAxisAngleSelf(&self, x: f64, y: f64, z: f64, angle: f64) -> DomRoot { // Steps 1-2. self.upcast::().rotate_axis_angle_self(x, y, z, angle); // Step 3. - Root::from_ref(&self) + DomRoot::from_ref(&self) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself - fn SkewXSelf(&self, sx: f64) -> Root { + fn SkewXSelf(&self, sx: f64) -> DomRoot { // Step 1. self.upcast::().skew_x_self(sx); // Step 2. - Root::from_ref(&self) + DomRoot::from_ref(&self) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself - fn SkewYSelf(&self, sy: f64) -> Root { + fn SkewYSelf(&self, sy: f64) -> DomRoot { // Step 1. self.upcast::().skew_y_self(sy); // Step 2. - Root::from_ref(&self) + DomRoot::from_ref(&self) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself - fn InvertSelf(&self) -> Root { + fn InvertSelf(&self) -> DomRoot { // Steps 1-2. self.upcast::().invert_self(); // Step 3. - Root::from_ref(&self) + DomRoot::from_ref(&self) } } diff --git a/servo/components/script/dom/dommatrixreadonly.rs b/servo/components/script/dom/dommatrixreadonly.rs index b31ce329ce2a..82aa96ba7b7b 100644 --- a/servo/components/script/dom/dommatrixreadonly.rs +++ b/servo/components/script/dom/dommatrixreadonly.rs @@ -2,14 +2,14 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods}; use dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::{DOMMatrixReadOnlyMethods, Wrap}; use dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; use dom::bindings::error; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; use dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; +use dom::bindings::root::DomRoot; use dom::dommatrix::DOMMatrix; use dom::dompoint::DOMPoint; use dom::globalscope::GlobalScope; @@ -21,13 +21,13 @@ use std::f64; #[dom_struct] pub struct DOMMatrixReadOnly { reflector_: Reflector, - matrix: DOMRefCell>, + matrix: DomRefCell>, is2D: Cell, } impl DOMMatrixReadOnly { #[allow(unrooted_must_root)] - pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D) -> Root { + pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D) -> DomRoot { let dommatrix = Self::new_inherited(is2D, matrix); reflect_dom_object(box dommatrix, global, Wrap) } @@ -35,18 +35,18 @@ impl DOMMatrixReadOnly { pub fn new_inherited(is2D: bool, matrix: Transform3D) -> Self { DOMMatrixReadOnly { reflector_: Reflector::new(), - matrix: DOMRefCell::new(matrix), + matrix: DomRefCell::new(matrix), is2D: Cell::new(is2D), } } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Ok(Self::new(global, true, Transform3D::identity())) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence - pub fn Constructor_(global: &GlobalScope, entries: Vec) -> Fallible> { + pub fn Constructor_(global: &GlobalScope, entries: Vec) -> Fallible> { entries_to_matrix(&entries[..]) .map(|(is2D, matrix)| { Self::new(global, is2D, matrix) @@ -54,7 +54,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix - pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible> { + pub fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible> { dommatrixinit_to_matrix(&other) .map(|(is2D, matrix)| { Self::new(global, is2D, matrix) @@ -463,55 +463,55 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate - fn Translate(&self, tx: f64, ty: f64, tz: f64) -> Root { + fn Translate(&self, tx: f64, ty: f64, tz: f64) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self).TranslateSelf(tx, ty, tz) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale fn Scale(&self, scaleX: f64, scaleY: Option, scaleZ: f64, - originX: f64, originY: f64, originZ: f64) -> Root { + originX: f64, originY: f64, originZ: f64) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self) .ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d - fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> Root { + fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self) .Scale3dSelf(scale, originX, originY, originZ) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate - fn Rotate(&self, rotX: f64, rotY: Option, rotZ: Option) -> Root { + fn Rotate(&self, rotX: f64, rotY: Option, rotZ: Option) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self).RotateSelf(rotX, rotY, rotZ) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector - fn RotateFromVector(&self, x: f64, y: f64) -> Root { + fn RotateFromVector(&self, x: f64, y: f64) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self).RotateFromVectorSelf(x, y) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle - fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> Root { + fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self).RotateAxisAngleSelf(x, y, z, angle) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx - fn SkewX(&self, sx: f64) -> Root { + fn SkewX(&self, sx: f64) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self).SkewXSelf(sx) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy - fn SkewY(&self, sy: f64) -> Root { + fn SkewY(&self, sy: f64) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self).SkewYSelf(sy) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply - fn Multiply(&self, other: &DOMMatrixInit) -> Fallible> { + fn Multiply(&self, other: &DOMMatrixInit) -> Fallible> { DOMMatrix::from_readonly(&self.global(), self).MultiplySelf(&other) } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx - fn FlipX(&self) -> Root { + fn FlipX(&self) -> DomRoot { let is2D = self.is2D.get(); let flip = Transform3D::row_major(-1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, @@ -522,7 +522,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy - fn FlipY(&self) -> Root { + fn FlipY(&self) -> DomRoot { let is2D = self.is2D.get(); let flip = Transform3D::row_major(1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, @@ -533,12 +533,12 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse - fn Inverse(&self) -> Root { + fn Inverse(&self) -> DomRoot { DOMMatrix::from_readonly(&self.global(), self).InvertSelf() } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint - fn TransformPoint(&self, point: &DOMPointInit) -> Root { + fn TransformPoint(&self, point: &DOMPointInit) -> DomRoot { // Euclid always normalizes the homogeneous coordinate which is usually the right // thing but may (?) not be compliant with the CSS matrix spec (or at least is // probably not the behavior web authors will expect even if it is mathematically diff --git a/servo/components/script/dom/domparser.rs b/servo/components/script/dom/domparser.rs index 4af6ebf8c60b..957b93f59b28 100644 --- a/servo/components/script/dom/domparser.rs +++ b/servo/components/script/dom/domparser.rs @@ -12,8 +12,8 @@ use dom::bindings::codegen::Bindings::DOMParserBinding::SupportedType::Text_xml; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentReadyState; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::document::{Document, HasBrowsingContext, IsHTMLDocument}; use dom::document::DocumentSource; @@ -25,24 +25,24 @@ use script_traits::DocumentActivity; #[dom_struct] pub struct DOMParser { reflector_: Reflector, - window: JS, // XXXjdm Document instead? + window: Dom, // XXXjdm Document instead? } impl DOMParser { fn new_inherited(window: &Window) -> DOMParser { DOMParser { reflector_: Reflector::new(), - window: JS::from_ref(window), + window: Dom::from_ref(window), } } - pub fn new(window: &Window) -> Root { + pub fn new(window: &Window) -> DomRoot { reflect_dom_object(box DOMParser::new_inherited(window), window, DOMParserBinding::Wrap) } - pub fn Constructor(window: &Window) -> Fallible> { + pub fn Constructor(window: &Window) -> Fallible> { Ok(DOMParser::new(window)) } } @@ -52,7 +52,7 @@ impl DOMParserMethods for DOMParser { fn ParseFromString(&self, s: DOMString, ty: DOMParserBinding::SupportedType) - -> Fallible> { + -> Fallible> { let url = self.window.get_url(); let content_type = DOMString::from(ty.as_str()); let doc = self.window.Document(); diff --git a/servo/components/script/dom/dompoint.rs b/servo/components/script/dom/dompoint.rs index 0a2ed9cec5dd..8f27603a4568 100644 --- a/servo/components/script/dom/dompoint.rs +++ b/servo/components/script/dom/dompoint.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods, Wrap}; use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods}; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -24,7 +24,7 @@ impl DOMPoint { } } - pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> Root { + pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot { reflect_dom_object(box DOMPoint::new_inherited(x, y, z, w), global, Wrap) } @@ -33,11 +33,11 @@ impl DOMPoint { y: f64, z: f64, w: f64) - -> Fallible> { + -> Fallible> { Ok(DOMPoint::new(global, x, y, z, w)) } - pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> Root { + pub fn new_from_init(global: &GlobalScope, p: &DOMPointInit) -> DomRoot { DOMPoint::new(global, p.x, p.y, p.z, p.w) } } diff --git a/servo/components/script/dom/dompointreadonly.rs b/servo/components/script/dom/dompointreadonly.rs index 7180207c9308..13ec9ee8c0f2 100644 --- a/servo/components/script/dom/dompointreadonly.rs +++ b/servo/components/script/dom/dompointreadonly.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap}; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use std::cell::Cell; @@ -31,7 +31,7 @@ impl DOMPointReadOnly { } } - pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> Root { + pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot { reflect_dom_object(box DOMPointReadOnly::new_inherited(x, y, z, w), global, Wrap) @@ -42,7 +42,7 @@ impl DOMPointReadOnly { y: f64, z: f64, w: f64) - -> Fallible> { + -> Fallible> { Ok(DOMPointReadOnly::new(global, x, y, z, w)) } } diff --git a/servo/components/script/dom/domquad.rs b/servo/components/script/dom/domquad.rs index 8c665731f847..54c07b8275c7 100644 --- a/servo/components/script/dom/domquad.rs +++ b/servo/components/script/dom/domquad.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMe use dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods, Wrap}; use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectInit; use dom::bindings::error::Fallible; -use dom::bindings::js::{Root, JS}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::dompoint::DOMPoint; use dom::domrect::DOMRect; use dom::globalscope::GlobalScope; @@ -17,10 +17,10 @@ use dom_struct::dom_struct; #[dom_struct] pub struct DOMQuad { reflector_: Reflector, - p1: JS, - p2: JS, - p3: JS, - p4: JS, + p1: Dom, + p2: Dom, + p3: Dom, + p4: Dom, } impl DOMQuad { @@ -31,10 +31,10 @@ impl DOMQuad { -> DOMQuad { DOMQuad { reflector_: Reflector::new(), - p1: JS::from_ref(p1), - p2: JS::from_ref(p2), - p3: JS::from_ref(p3), - p4: JS::from_ref(p4), + p1: Dom::from_ref(p1), + p2: Dom::from_ref(p2), + p3: Dom::from_ref(p3), + p4: Dom::from_ref(p4), } } @@ -42,7 +42,7 @@ impl DOMQuad { p1: &DOMPoint, p2: &DOMPoint, p3: &DOMPoint, - p4: &DOMPoint) -> Root { + p4: &DOMPoint) -> DomRoot { reflect_dom_object(box DOMQuad::new_inherited(p1, p2, p3, p4), global, Wrap) @@ -53,7 +53,7 @@ impl DOMQuad { p2: &DOMPointInit, p3: &DOMPointInit, p4: &DOMPointInit) - -> Fallible> { + -> Fallible> { Ok(DOMQuad::new(global, &*DOMPoint::new_from_init(global, p1), &*DOMPoint::new_from_init(global, p2), @@ -62,7 +62,7 @@ impl DOMQuad { } // https://drafts.fxtf.org/geometry/#dom-domquad-fromrect - pub fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> Root { + pub fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> DomRoot { DOMQuad::new(global, &*DOMPoint::new(global, other.x, other.y, 0f64, 1f64), &*DOMPoint::new(global, other.x + other.width, other.y, 0f64, 1f64), @@ -71,7 +71,7 @@ impl DOMQuad { } // https://drafts.fxtf.org/geometry/#dom-domquad-fromquad - pub fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> Root { + pub fn FromQuad(global: &GlobalScope, other: &DOMQuadInit) -> DomRoot { DOMQuad::new(global, &DOMPoint::new_from_init(global, &other.p1), &DOMPoint::new_from_init(global, &other.p2), @@ -82,27 +82,27 @@ impl DOMQuad { impl DOMQuadMethods for DOMQuad { // https://drafts.fxtf.org/geometry/#dom-domquad-p1 - fn P1(&self) -> Root { - Root::from_ref(&self.p1) + fn P1(&self) -> DomRoot { + DomRoot::from_ref(&self.p1) } // https://drafts.fxtf.org/geometry/#dom-domquad-p2 - fn P2(&self) -> Root { - Root::from_ref(&self.p2) + fn P2(&self) -> DomRoot { + DomRoot::from_ref(&self.p2) } // https://drafts.fxtf.org/geometry/#dom-domquad-p3 - fn P3(&self) -> Root { - Root::from_ref(&self.p3) + fn P3(&self) -> DomRoot { + DomRoot::from_ref(&self.p3) } // https://drafts.fxtf.org/geometry/#dom-domquad-p4 - fn P4(&self) -> Root { - Root::from_ref(&self.p4) + fn P4(&self) -> DomRoot { + DomRoot::from_ref(&self.p4) } // https://drafts.fxtf.org/geometry/#dom-domquad-getbounds - fn GetBounds(&self) -> Root { + fn GetBounds(&self) -> DomRoot { let left = self.p1.X().min(self.p2.X()).min(self.p3.X()).min(self.p4.X()); let top = self.p1.Y().min(self.p2.Y()).min(self.p3.Y()).min(self.p4.Y()); let right = self.p1.X().max(self.p2.X()).max(self.p3.X()).max(self.p4.X()); diff --git a/servo/components/script/dom/domrect.rs b/servo/components/script/dom/domrect.rs index 3201e6c49efa..4933619d172b 100644 --- a/servo/components/script/dom/domrect.rs +++ b/servo/components/script/dom/domrect.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::DOMRectBinding; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::domrectreadonly::DOMRectReadOnly; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -24,7 +24,7 @@ impl DOMRect { } } - pub fn new(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> Root { + pub fn new(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> DomRoot { reflect_dom_object(box DOMRect::new_inherited(x, y, width, height), global, DOMRectBinding::Wrap) @@ -35,7 +35,7 @@ impl DOMRect { y: f64, width: f64, height: f64) - -> Fallible> { + -> Fallible> { Ok(DOMRect::new(global, x, y, width, height)) } } diff --git a/servo/components/script/dom/domrectreadonly.rs b/servo/components/script/dom/domrectreadonly.rs index f5e08a4fcb78..fe590b0e7491 100644 --- a/servo/components/script/dom/domrectreadonly.rs +++ b/servo/components/script/dom/domrectreadonly.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{DOMRectReadOnlyMethods, Wrap}; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use std::cell::Cell; @@ -35,7 +35,7 @@ impl DOMRectReadOnly { y: f64, width: f64, height: f64) - -> Root { + -> DomRoot { reflect_dom_object(box DOMRectReadOnly::new_inherited(x, y, width, height), global, Wrap) @@ -46,7 +46,7 @@ impl DOMRectReadOnly { y: f64, width: f64, height: f64) - -> Fallible> { + -> Fallible> { Ok(DOMRectReadOnly::new(global, x, y, width, height)) } diff --git a/servo/components/script/dom/domstringmap.rs b/servo/components/script/dom/domstringmap.rs index d529ca25cf8b..c349a9d52591 100644 --- a/servo/components/script/dom/domstringmap.rs +++ b/servo/components/script/dom/domstringmap.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::DOMStringMapBinding; use dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods; use dom::bindings::error::ErrorResult; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::htmlelement::HTMLElement; use dom::node::window_from_node; @@ -15,18 +15,18 @@ use dom_struct::dom_struct; #[dom_struct] pub struct DOMStringMap { reflector_: Reflector, - element: JS, + element: Dom, } impl DOMStringMap { fn new_inherited(element: &HTMLElement) -> DOMStringMap { DOMStringMap { reflector_: Reflector::new(), - element: JS::from_ref(element), + element: Dom::from_ref(element), } } - pub fn new(element: &HTMLElement) -> Root { + pub fn new(element: &HTMLElement) -> DomRoot { let window = window_from_node(element); reflect_dom_object(box DOMStringMap::new_inherited(element), &*window, diff --git a/servo/components/script/dom/domtokenlist.rs b/servo/components/script/dom/domtokenlist.rs index c3834ceeddd5..22f0a45654bd 100644 --- a/servo/components/script/dom/domtokenlist.rs +++ b/servo/components/script/dom/domtokenlist.rs @@ -6,8 +6,8 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::DOMTokenListBinding; use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::element::Element; use dom::node::window_from_node; @@ -19,7 +19,7 @@ use style::str::HTML_SPACE_CHARACTERS; #[dom_struct] pub struct DOMTokenList { reflector_: Reflector, - element: JS, + element: Dom, local_name: LocalName, } @@ -27,19 +27,19 @@ impl DOMTokenList { pub fn new_inherited(element: &Element, local_name: LocalName) -> DOMTokenList { DOMTokenList { reflector_: Reflector::new(), - element: JS::from_ref(element), + element: Dom::from_ref(element), local_name: local_name, } } - pub fn new(element: &Element, local_name: &LocalName) -> Root { + pub fn new(element: &Element, local_name: &LocalName) -> DomRoot { let window = window_from_node(element); reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()), &*window, DOMTokenListBinding::Wrap) } - fn attribute(&self) -> Option> { + fn attribute(&self) -> Option> { self.element.get_attribute(&ns!(), &self.local_name) } diff --git a/servo/components/script/dom/element.rs b/servo/components/script/dom/element.rs index 0fe36814b335..509425100062 100644 --- a/servo/components/script/dom/element.rs +++ b/servo/components/script/dom/element.rs @@ -7,7 +7,7 @@ use devtools_traits::AttrInfo; use dom::activation::Activatable; use dom::attr::{Attr, AttrHelpersForLayout}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::ElementBinding; @@ -22,10 +22,9 @@ use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::conversions::DerivedFrom; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; -use dom::bindings::js::{JS, LayoutJS, MutNullableJS}; -use dom::bindings::js::{Root, RootedReference}; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type}; use dom::bindings::xmlname::XMLName::InvalidXMLName; @@ -131,14 +130,14 @@ pub struct Element { local_name: LocalName, tag_name: TagName, namespace: Namespace, - prefix: DOMRefCell>, - attrs: DOMRefCell>>, - id_attribute: DOMRefCell>, - is: DOMRefCell>, + prefix: DomRefCell>, + attrs: DomRefCell>>, + id_attribute: DomRefCell>, + is: DomRefCell>, #[ignore_heap_size_of = "Arc"] - style_attribute: DOMRefCell>>>, - attr_list: MutNullableJS, - class_list: MutNullableJS, + style_attribute: DomRefCell>>>, + attr_list: MutNullableDom, + class_list: MutNullableDom, state: Cell, /// These flags are set by the style system to indicate the that certain /// operations may require restyling this element or its descendants. The @@ -147,10 +146,10 @@ pub struct Element { #[ignore_heap_size_of = "bitflags defined in rust-selectors"] selector_flags: Cell, /// https://html.spec.whatwg.org/multipage/#custom-element-reaction-queue - custom_element_reaction_queue: DOMRefCell>, + custom_element_reaction_queue: DomRefCell>, /// https://dom.spec.whatwg.org/#concept-element-custom-element-definition #[ignore_heap_size_of = "Rc"] - custom_element_definition: DOMRefCell>>, + custom_element_definition: DomRefCell>>, /// https://dom.spec.whatwg.org/#concept-element-custom-element-state custom_element_state: Cell, } @@ -165,7 +164,7 @@ impl fmt::Debug for Element { } } -impl fmt::Debug for Root { +impl fmt::Debug for DomRoot { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } @@ -236,7 +235,7 @@ impl Element { document: &Document, creator: ElementCreator, mode: CustomElementCreationMode) - -> Root { + -> DomRoot { create_element(name, is, document, creator, mode) } @@ -256,11 +255,11 @@ impl Element { local_name: local_name, tag_name: TagName::new(), namespace: namespace, - prefix: DOMRefCell::new(prefix), - attrs: DOMRefCell::new(vec![]), - id_attribute: DOMRefCell::new(None), - is: DOMRefCell::new(None), - style_attribute: DOMRefCell::new(None), + prefix: DomRefCell::new(prefix), + attrs: DomRefCell::new(vec![]), + id_attribute: DomRefCell::new(None), + is: DomRefCell::new(None), + style_attribute: DomRefCell::new(None), attr_list: Default::default(), class_list: Default::default(), state: Cell::new(state), @@ -274,7 +273,7 @@ impl Element { pub fn new(local_name: LocalName, namespace: Namespace, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node( box Element::new_inherited(local_name, namespace, prefix, document), document, @@ -385,7 +384,7 @@ pub trait RawLayoutElementHelpers { #[inline] #[allow(unsafe_code)] pub unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name: &LocalName) - -> Option> { + -> Option> { // cast to point to T in RefCell directly let attrs = elem.attrs.borrow_for_layout(); attrs.iter().find(|attr| { @@ -454,7 +453,7 @@ pub trait LayoutElementHelpers { fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool; } -impl LayoutElementHelpers for LayoutJS { +impl LayoutElementHelpers for LayoutDom { #[allow(unsafe_code)] #[inline] unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool { @@ -913,7 +912,7 @@ impl Element { *self.prefix.borrow_mut() = prefix; } - pub fn attrs(&self) -> Ref<[JS]> { + pub fn attrs(&self) -> Ref<[Dom]> { Ref::map(self.attrs.borrow(), |attrs| &**attrs) } @@ -924,7 +923,7 @@ impl Element { let inclusive_ancestor_elements = self.upcast::() .inclusive_ancestors() - .filter_map(Root::downcast::); + .filter_map(DomRoot::downcast::); // Steps 3-4. for element in inclusive_ancestor_elements { @@ -959,7 +958,7 @@ impl Element { ns!() } - pub fn style_attribute(&self) -> &DOMRefCell>>> { + pub fn style_attribute(&self) -> &DomRefCell>>> { &self.style_attribute } @@ -1003,7 +1002,7 @@ impl Element { } } - pub fn root_element(&self) -> Root { + pub fn root_element(&self) -> DomRoot { if self.node.is_in_doc() { self.upcast::() .owner_doc() @@ -1012,7 +1011,7 @@ impl Element { } else { self.upcast::() .inclusive_ancestors() - .filter_map(Root::downcast) + .filter_map(DomRoot::downcast) .last() .expect("We know inclusive_ancestors will return `self` which is an element") } @@ -1119,24 +1118,24 @@ impl Element { assert!(attr.GetOwnerElement().r() == Some(self)); self.will_mutate_attr(attr); - self.attrs.borrow_mut().push(JS::from_ref(attr)); + self.attrs.borrow_mut().push(Dom::from_ref(attr)); if attr.namespace() == &ns!() { vtable_for(self.upcast()).attribute_mutated(attr, AttributeMutation::Set(None)); } } - pub fn get_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option> { + pub fn get_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option> { self.attrs .borrow() .iter() .find(|attr| attr.local_name() == local_name && attr.namespace() == namespace) - .map(|js| Root::from_ref(&**js)) + .map(|js| DomRoot::from_ref(&**js)) } // https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name - pub fn get_attribute_by_name(&self, name: DOMString) -> Option> { + pub fn get_attribute_by_name(&self, name: DOMString) -> Option> { let name = &self.parsed_name(name); - self.attrs.borrow().iter().find(|a| a.name() == name).map(|js| Root::from_ref(&**js)) + self.attrs.borrow().iter().find(|a| a.name() == name).map(|js| DomRoot::from_ref(&**js)) } pub fn set_attribute_from_parser(&self, @@ -1208,7 +1207,7 @@ impl Element { .borrow() .iter() .find(|attr| find(&attr)) - .map(|js| Root::from_ref(&**js)); + .map(|js| DomRoot::from_ref(&**js)); if let Some(attr) = attr { attr.set_value(value, self); } else { @@ -1228,21 +1227,21 @@ impl Element { } } - pub fn remove_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option> { + pub fn remove_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option> { self.remove_first_matching_attribute(|attr| { attr.namespace() == namespace && attr.local_name() == local_name }) } - pub fn remove_attribute_by_name(&self, name: &LocalName) -> Option> { + pub fn remove_attribute_by_name(&self, name: &LocalName) -> Option> { self.remove_first_matching_attribute(|attr| attr.name() == name) } - fn remove_first_matching_attribute(&self, find: F) -> Option> + fn remove_first_matching_attribute(&self, find: F) -> Option> where F: Fn(&Attr) -> bool { let idx = self.attrs.borrow().iter().position(|attr| find(&attr)); idx.map(|idx| { - let attr = Root::from_ref(&*(*self.attrs.borrow())[idx]); + let attr = DomRoot::from_ref(&*(*self.attrs.borrow())[idx]); self.will_mutate_attr(&attr); let name = attr.local_name().clone(); @@ -1397,7 +1396,7 @@ impl Element { // https://dom.spec.whatwg.org/#insert-adjacent pub fn insert_adjacent(&self, where_: AdjacentPosition, node: &Node) - -> Fallible>> { + -> Fallible>> { let self_node = self.upcast::(); match where_ { AdjacentPosition::BeforeBegin => { @@ -1469,7 +1468,7 @@ impl Element { } // https://w3c.github.io/DOM-Parsing/#parsing - pub fn parse_fragment(&self, markup: DOMString) -> Fallible> { + pub fn parse_fragment(&self, markup: DOMString) -> Fallible> { // Steps 1-2. let context_document = document_from_node(self); // TODO(#11995): XML case. @@ -1484,13 +1483,13 @@ impl Element { Ok(fragment) } - pub fn fragment_parsing_context(owner_doc: &Document, element: Option<&Self>) -> Root { + pub fn fragment_parsing_context(owner_doc: &Document, element: Option<&Self>) -> DomRoot { match element { Some(elem) if elem.local_name() != &local_name!("html") || !elem.html_element_in_html_document() => { - Root::from_ref(elem) + DomRoot::from_ref(elem) }, _ => { - Root::upcast(HTMLBodyElement::new(local_name!("body"), None, owner_doc)) + DomRoot::upcast(HTMLBodyElement::new(local_name!("body"), None, owner_doc)) } } } @@ -1569,12 +1568,12 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-element-classlist - fn ClassList(&self) -> Root { + fn ClassList(&self) -> DomRoot { self.class_list.or_init(|| DOMTokenList::new(self, &local_name!("class"))) } // https://dom.spec.whatwg.org/#dom-element-attributes - fn Attributes(&self) -> Root { + fn Attributes(&self) -> DomRoot { self.attr_list.or_init(|| NamedNodeMap::new(&window_from_node(self), self)) } @@ -1604,7 +1603,7 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-element-getattributenode - fn GetAttributeNode(&self, name: DOMString) -> Option> { + fn GetAttributeNode(&self, name: DOMString) -> Option> { self.get_attribute_by_name(name) } @@ -1612,7 +1611,7 @@ impl ElementMethods for Element { fn GetAttributeNodeNS(&self, namespace: Option, local_name: DOMString) - -> Option> { + -> Option> { let namespace = &namespace_from_domstring(namespace); self.get_attribute(namespace, &LocalName::from(local_name)) } @@ -1651,7 +1650,7 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-element-setattributenode - fn SetAttributeNode(&self, attr: &Attr) -> Fallible>> { + fn SetAttributeNode(&self, attr: &Attr) -> Fallible>> { // Step 1. if let Some(owner) = attr.GetOwnerElement() { if &*owner != self { @@ -1674,11 +1673,11 @@ impl ElementMethods for Element { }); if let Some(position) = position { - let old_attr = Root::from_ref(&*self.attrs.borrow()[position]); + let old_attr = DomRoot::from_ref(&*self.attrs.borrow()[position]); // Step 3. if &*old_attr == attr { - return Ok(Some(Root::from_ref(attr))); + return Ok(Some(DomRoot::from_ref(attr))); } // Step 4. @@ -1693,7 +1692,7 @@ impl ElementMethods for Element { } self.will_mutate_attr(attr); attr.set_owner(Some(self)); - self.attrs.borrow_mut()[position] = JS::from_ref(attr); + self.attrs.borrow_mut()[position] = Dom::from_ref(attr); old_attr.set_owner(None); if attr.namespace() == &ns!() { vtable.attribute_mutated( @@ -1713,7 +1712,7 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-element-setattributenodens - fn SetAttributeNodeNS(&self, attr: &Attr) -> Fallible>> { + fn SetAttributeNodeNS(&self, attr: &Attr) -> Fallible>> { self.SetAttributeNode(attr) } @@ -1731,7 +1730,7 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-element-removeattributenode - fn RemoveAttributeNode(&self, attr: &Attr) -> Fallible> { + fn RemoveAttributeNode(&self, attr: &Attr) -> Fallible> { self.remove_first_matching_attribute(|a| a == attr) .ok_or(Error::NotFound) } @@ -1747,7 +1746,7 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-element-getelementsbytagname - fn GetElementsByTagName(&self, localname: DOMString) -> Root { + fn GetElementsByTagName(&self, localname: DOMString) -> DomRoot { let window = window_from_node(self); HTMLCollection::by_qualified_name(&window, self.upcast(), LocalName::from(&*localname)) } @@ -1756,19 +1755,19 @@ impl ElementMethods for Element { fn GetElementsByTagNameNS(&self, maybe_ns: Option, localname: DOMString) - -> Root { + -> DomRoot { let window = window_from_node(self); HTMLCollection::by_tag_name_ns(&window, self.upcast(), localname, maybe_ns) } // https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname - fn GetElementsByClassName(&self, classes: DOMString) -> Root { + fn GetElementsByClassName(&self, classes: DOMString) -> DomRoot { let window = window_from_node(self); HTMLCollection::by_class_name(&window, self.upcast(), classes) } // https://drafts.csswg.org/cssom-view/#dom-element-getclientrects - fn GetClientRects(&self) -> Vec> { + fn GetClientRects(&self) -> Vec> { let win = window_from_node(self); let raw_rects = self.upcast::().content_boxes(); raw_rects.iter().map(|rect| { @@ -1781,7 +1780,7 @@ impl ElementMethods for Element { } // https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect - fn GetBoundingClientRect(&self) -> Root { + fn GetBoundingClientRect(&self) -> DomRoot { let win = window_from_node(self); let rect = self.upcast::().bounding_content_box_or_zero(); DOMRect::new(win.upcast(), @@ -2060,9 +2059,9 @@ impl ElementMethods for Element { // Step 2. // https://github.com/w3c/DOM-Parsing/issues/1 let target = if let Some(template) = self.downcast::() { - Root::upcast(template.Content()) + DomRoot::upcast(template.Content()) } else { - Root::from_ref(self.upcast()) + DomRoot::from_ref(self.upcast()) }; Node::replace_all(Some(frag.upcast()), &target); Ok(()) @@ -2097,7 +2096,7 @@ impl ElementMethods for Element { &context_document, ElementCreator::ScriptCreated, CustomElementCreationMode::Synchronous); - Root::upcast(body_elem) + DomRoot::upcast(body_elem) }, _ => context_node.GetParentElement().unwrap() }; @@ -2110,29 +2109,29 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling - fn GetPreviousElementSibling(&self) -> Option> { - self.upcast::().preceding_siblings().filter_map(Root::downcast).next() + fn GetPreviousElementSibling(&self) -> Option> { + self.upcast::().preceding_siblings().filter_map(DomRoot::downcast).next() } // https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling - fn GetNextElementSibling(&self) -> Option> { - self.upcast::().following_siblings().filter_map(Root::downcast).next() + fn GetNextElementSibling(&self) -> Option> { + self.upcast::().following_siblings().filter_map(DomRoot::downcast).next() } // https://dom.spec.whatwg.org/#dom-parentnode-children - fn Children(&self) -> Root { + fn Children(&self) -> DomRoot { let window = window_from_node(self); HTMLCollection::children(&window, self.upcast()) } // https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild - fn GetFirstElementChild(&self) -> Option> { + fn GetFirstElementChild(&self) -> Option> { self.upcast::().child_elements().next() } // https://dom.spec.whatwg.org/#dom-parentnode-lastelementchild - fn GetLastElementChild(&self) -> Option> { - self.upcast::().rev_children().filter_map(Root::downcast::).next() + fn GetLastElementChild(&self) -> Option> { + self.upcast::().rev_children().filter_map(DomRoot::downcast::).next() } // https://dom.spec.whatwg.org/#dom-parentnode-childelementcount @@ -2151,13 +2150,13 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-parentnode-queryselector - fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { + fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { let root = self.upcast::(); root.query_selector(selectors) } // https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall - fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { + fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { let root = self.upcast::(); root.query_selector_all(selectors) } @@ -2191,7 +2190,7 @@ impl ElementMethods for Element { // FIXME(bholley): Consider an nth-index cache here. let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None, quirks_mode); - Ok(matches_selector_list(&selectors, &Root::from_ref(self), &mut ctx)) + Ok(matches_selector_list(&selectors, &DomRoot::from_ref(self), &mut ctx)) } } } @@ -2202,13 +2201,13 @@ impl ElementMethods for Element { } // https://dom.spec.whatwg.org/#dom-element-closest - fn Closest(&self, selectors: DOMString) -> Fallible>> { + fn Closest(&self, selectors: DOMString) -> Fallible>> { match SelectorParser::parse_author_origin_no_namespace(&selectors) { Err(_) => Err(Error::Syntax), Ok(selectors) => { let root = self.upcast::(); for element in root.inclusive_ancestors() { - if let Some(element) = Root::downcast::(element) { + if let Some(element) = DomRoot::downcast::(element) { let quirks_mode = document_from_node(self).quirks_mode(); // FIXME(bholley): Consider an nth-index cache here. let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None, @@ -2225,10 +2224,10 @@ impl ElementMethods for Element { // https://dom.spec.whatwg.org/#dom-element-insertadjacentelement fn InsertAdjacentElement(&self, where_: DOMString, element: &Element) - -> Fallible>> { + -> Fallible>> { let where_ = AdjacentPosition::try_from(&*where_)?; let inserted_node = self.insert_adjacent(where_, element.upcast())?; - Ok(inserted_node.map(|node| Root::downcast(node).unwrap())) + Ok(inserted_node.map(|node| DomRoot::downcast(node).unwrap())) } // https://dom.spec.whatwg.org/#dom-element-insertadjacenttext @@ -2259,7 +2258,7 @@ impl ElementMethods for Element { } } AdjacentPosition::AfterBegin | AdjacentPosition::BeforeEnd => { - Root::from_ref(self.upcast::()) + DomRoot::from_ref(self.upcast::()) } }; @@ -2497,14 +2496,14 @@ impl VirtualMethods for Element { } } -impl<'a> ::selectors::Element for Root { +impl<'a> ::selectors::Element for DomRoot { type Impl = SelectorImpl; fn opaque(&self) -> ::selectors::OpaqueElement { ::selectors::OpaqueElement::new(self.reflector().get_jsobject().get()) } - fn parent_element(&self) -> Option> { + fn parent_element(&self) -> Option> { self.upcast::().GetParentElement() } @@ -2517,20 +2516,20 @@ impl<'a> ::selectors::Element for Root { } - fn first_child_element(&self) -> Option> { + fn first_child_element(&self) -> Option> { self.node.child_elements().next() } - fn last_child_element(&self) -> Option> { - self.node.rev_children().filter_map(Root::downcast).next() + fn last_child_element(&self) -> Option> { + self.node.rev_children().filter_map(DomRoot::downcast).next() } - fn prev_sibling_element(&self) -> Option> { - self.node.preceding_siblings().filter_map(Root::downcast).next() + fn prev_sibling_element(&self) -> Option> { + self.node.preceding_siblings().filter_map(DomRoot::downcast).next() } - fn next_sibling_element(&self) -> Option> { - self.node.following_siblings().filter_map(Root::downcast).next() + fn next_sibling_element(&self) -> Option> { + self.node.following_siblings().filter_map(DomRoot::downcast).next() } fn attr_matches(&self, @@ -2740,15 +2739,15 @@ impl Element { } // https://html.spec.whatwg.org/multipage/#nearest-activatable-element - pub fn nearest_activable_element(&self) -> Option> { + pub fn nearest_activable_element(&self) -> Option> { match self.as_maybe_activatable() { - Some(el) => Some(Root::from_ref(el.as_element())), + Some(el) => Some(DomRoot::from_ref(el.as_element())), None => { let node = self.upcast::(); for node in node.ancestors() { if let Some(node) = node.downcast::() { if node.as_maybe_activatable().is_some() { - return Some(Root::from_ref(node)); + return Some(DomRoot::from_ref(node)); } } } @@ -3007,12 +3006,12 @@ impl<'a> AttributeMutation<'a> { /// owner changes. #[derive(HeapSizeOf, JSTraceable)] struct TagName { - ptr: DOMRefCell>, + ptr: DomRefCell>, } impl TagName { fn new() -> TagName { - TagName { ptr: DOMRefCell::new(None) } + TagName { ptr: DomRefCell::new(None) } } /// Retrieve a copy of the current inner value. If it is `None`, it is diff --git a/servo/components/script/dom/errorevent.rs b/servo/components/script/dom/errorevent.rs index 170a979d9969..cf9439484556 100644 --- a/servo/components/script/dom/errorevent.rs +++ b/servo/components/script/dom/errorevent.rs @@ -2,14 +2,14 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::ErrorEventBinding; use dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::bindings::trace::RootedTraceableBox; use dom::event::{Event, EventBubbles, EventCancelable}; @@ -23,8 +23,8 @@ use std::cell::Cell; #[dom_struct] pub struct ErrorEvent { event: Event, - message: DOMRefCell, - filename: DOMRefCell, + message: DomRefCell, + filename: DomRefCell, lineno: Cell, colno: Cell, #[ignore_heap_size_of = "Defined in rust-mozjs"] @@ -35,15 +35,15 @@ impl ErrorEvent { fn new_inherited() -> ErrorEvent { ErrorEvent { event: Event::new_inherited(), - message: DOMRefCell::new(DOMString::new()), - filename: DOMRefCell::new(DOMString::new()), + message: DomRefCell::new(DOMString::new()), + filename: DomRefCell::new(DOMString::new()), lineno: Cell::new(0), colno: Cell::new(0), error: Heap::default() } } - pub fn new_uninitialized(global: &GlobalScope) -> Root { + pub fn new_uninitialized(global: &GlobalScope) -> DomRoot { reflect_dom_object(box ErrorEvent::new_inherited(), global, ErrorEventBinding::Wrap) @@ -57,7 +57,7 @@ impl ErrorEvent { filename: DOMString, lineno: u32, colno: u32, - error: HandleValue) -> Root { + error: HandleValue) -> DomRoot { let ev = ErrorEvent::new_uninitialized(global); { let event = ev.upcast::(); @@ -75,7 +75,7 @@ impl ErrorEvent { pub fn Constructor(global: &GlobalScope, type_: DOMString, init: RootedTraceableBox) - -> Fallible>{ + -> Fallible>{ let msg = match init.message.as_ref() { Some(message) => message.clone(), None => DOMString::new(), diff --git a/servo/components/script/dom/event.rs b/servo/components/script/dom/event.rs index cead9f74df9b..e693dd1c5ebd 100644 --- a/servo/components/script/dom/event.rs +++ b/servo/components/script/dom/event.rs @@ -4,14 +4,14 @@ use devtools_traits::{TimelineMarker, TimelineMarkerType}; use dom::bindings::callback::ExceptionHandling; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::EventBinding; use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods}; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::eventtarget::{CompiledEventListener, EventTarget, ListenerPhase}; @@ -29,9 +29,9 @@ use time; #[dom_struct] pub struct Event { reflector_: Reflector, - current_target: MutNullableJS, - target: MutNullableJS, - type_: DOMRefCell, + current_target: MutNullableDom, + target: MutNullableDom, + type_: DomRefCell, phase: Cell, canceled: Cell, stop_propagation: Cell, @@ -50,7 +50,7 @@ impl Event { reflector_: Reflector::new(), current_target: Default::default(), target: Default::default(), - type_: DOMRefCell::new(atom!("")), + type_: DomRefCell::new(atom!("")), phase: Cell::new(EventPhase::None), canceled: Cell::new(EventDefault::Allowed), stop_propagation: Cell::new(false), @@ -64,7 +64,7 @@ impl Event { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root { + pub fn new_uninitialized(global: &GlobalScope) -> DomRoot { reflect_dom_object(box Event::new_inherited(), global, EventBinding::Wrap) @@ -73,7 +73,7 @@ impl Event { pub fn new(global: &GlobalScope, type_: Atom, bubbles: EventBubbles, - cancelable: EventCancelable) -> Root { + cancelable: EventCancelable) -> DomRoot { let event = Event::new_uninitialized(global); event.init_event(type_, bool::from(bubbles), bool::from(cancelable)); event @@ -81,7 +81,7 @@ impl Event { pub fn Constructor(global: &GlobalScope, type_: DOMString, - init: &EventBinding::EventInit) -> Fallible> { + init: &EventBinding::EventInit) -> Fallible> { let bubbles = EventBubbles::from(init.bubbles); let cancelable = EventCancelable::from(init.cancelable); Ok(Event::new(global, Atom::from(type_), bubbles, cancelable)) @@ -137,13 +137,13 @@ impl Event { // Step 4. if let Some(target_node) = target.downcast::() { for ancestor in target_node.ancestors() { - event_path.push(JS::from_ref(ancestor.upcast::())); + event_path.push(Dom::from_ref(ancestor.upcast::())); } let top_most_ancestor_or_target = - Root::from_ref(event_path.r().last().cloned().unwrap_or(target)); - if let Some(document) = Root::downcast::(top_most_ancestor_or_target) { + DomRoot::from_ref(event_path.r().last().cloned().unwrap_or(target)); + if let Some(document) = DomRoot::downcast::(top_most_ancestor_or_target) { if self.type_() != atom!("load") && document.browsing_context().is_some() { - event_path.push(JS::from_ref(document.window().upcast())); + event_path.push(Dom::from_ref(document.window().upcast())); } } } @@ -233,12 +233,12 @@ impl EventMethods for Event { } // https://dom.spec.whatwg.org/#dom-event-target - fn GetTarget(&self) -> Option> { + fn GetTarget(&self) -> Option> { self.target.get() } // https://dom.spec.whatwg.org/#dom-event-currenttarget - fn GetCurrentTarget(&self) -> Option> { + fn GetCurrentTarget(&self) -> Option> { self.current_target.get() } @@ -416,7 +416,7 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve assert!(!event.stop_propagation.get()); assert!(!event.stop_immediate.get()); - let window = match Root::downcast::(target.global()) { + let window = match DomRoot::downcast::(target.global()) { Some(window) => { if window.need_emit_timeline_marker(TimelineMarkerType::DOMEvent) { Some(window) diff --git a/servo/components/script/dom/eventsource.rs b/servo/components/script/dom/eventsource.rs index 07f5c3b45008..962138968d07 100644 --- a/servo/components/script/dom/eventsource.rs +++ b/servo/components/script/dom/eventsource.rs @@ -2,13 +2,13 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::EventSourceBinding::{EventSourceInit, EventSourceMethods, Wrap}; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::Event; use dom::eventtarget::EventTarget; @@ -56,8 +56,8 @@ enum ReadyState { pub struct EventSource { eventtarget: EventTarget, url: ServoUrl, - request: DOMRefCell>, - last_event_id: DOMRefCell, + request: DomRefCell>, + last_event_id: DomRefCell, reconnection_time: Cell, generation_id: Cell, @@ -402,8 +402,8 @@ impl EventSource { EventSource { eventtarget: EventTarget::new_inherited(), url: url, - request: DOMRefCell::new(None), - last_event_id: DOMRefCell::new(DOMString::from("")), + request: DomRefCell::new(None), + last_event_id: DomRefCell::new(DOMString::from("")), reconnection_time: Cell::new(DEFAULT_RECONNECTION_TIME), generation_id: Cell::new(GenerationId(0)), @@ -412,7 +412,7 @@ impl EventSource { } } - fn new(global: &GlobalScope, url: ServoUrl, with_credentials: bool) -> Root { + fn new(global: &GlobalScope, url: ServoUrl, with_credentials: bool) -> DomRoot { reflect_dom_object(box EventSource::new_inherited(url, with_credentials), global, Wrap) @@ -424,7 +424,7 @@ impl EventSource { pub fn Constructor(global: &GlobalScope, url: DOMString, - event_source_init: &EventSourceInit) -> Fallible> { + event_source_init: &EventSourceInit) -> Fallible> { // TODO: Step 2 relevant settings object // Step 3 let base_url = global.api_base_url(); diff --git a/servo/components/script/dom/eventtarget.rs b/servo/components/script/dom/eventtarget.rs index eaab9f79d9b8..a33f7703e1a5 100644 --- a/servo/components/script/dom/eventtarget.rs +++ b/servo/components/script/dom/eventtarget.rs @@ -4,7 +4,7 @@ use dom::beforeunloadevent::BeforeUnloadEvent; use dom::bindings::callback::{CallbackContainer, ExceptionHandling, CallbackFunction}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods; use dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; @@ -17,8 +17,8 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::UnionTypes::EventOrString; use dom::bindings::error::{Error, Fallible, report_pending_exception}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::element::Element; use dom::errorevent::ErrorEvent; @@ -174,7 +174,7 @@ impl CompiledEventListener { return; } - let _ = handler.Call_(object, EventOrString::Event(Root::from_ref(event)), + let _ = handler.Call_(object, EventOrString::Event(DomRoot::from_ref(event)), None, None, None, None, exception_handle); } @@ -276,14 +276,14 @@ impl EventListeners { #[dom_struct] pub struct EventTarget { reflector_: Reflector, - handlers: DOMRefCell>>, + handlers: DomRefCell>>, } impl EventTarget { pub fn new_inherited() -> EventTarget { EventTarget { reflector_: Reflector::new(), - handlers: DOMRefCell::new(Default::default()), + handlers: DomRefCell::new(Default::default()), } } @@ -506,28 +506,28 @@ impl EventTarget { } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_event(&self, name: Atom) -> Root { + pub fn fire_event(&self, name: Atom) -> DomRoot { self.fire_event_with_params(name, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable) } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_bubbling_event(&self, name: Atom) -> Root { + pub fn fire_bubbling_event(&self, name: Atom) -> DomRoot { self.fire_event_with_params(name, EventBubbles::Bubbles, EventCancelable::NotCancelable) } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_cancelable_event(&self, name: Atom) -> Root { + pub fn fire_cancelable_event(&self, name: Atom) -> DomRoot { self.fire_event_with_params(name, EventBubbles::DoesNotBubble, EventCancelable::Cancelable) } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_bubbling_cancelable_event(&self, name: Atom) -> Root { + pub fn fire_bubbling_cancelable_event(&self, name: Atom) -> DomRoot { self.fire_event_with_params(name, EventBubbles::Bubbles, EventCancelable::Cancelable) @@ -538,7 +538,7 @@ impl EventTarget { name: Atom, bubbles: EventBubbles, cancelable: EventCancelable) - -> Root { + -> DomRoot { let event = Event::new(&self.global(), name, bubbles, cancelable); event.fire(self); event diff --git a/servo/components/script/dom/extendableevent.rs b/servo/components/script/dom/extendableevent.rs index 553ed7a1fe40..4af769b2d697 100644 --- a/servo/components/script/dom/extendableevent.rs +++ b/servo/components/script/dom/extendableevent.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::EventBinding::{self, EventMethods}; use dom::bindings::codegen::Bindings::ExtendableEventBinding; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::Event; use dom::serviceworkerglobalscope::ServiceWorkerGlobalScope; @@ -33,7 +33,7 @@ impl ExtendableEvent { type_: Atom, bubbles: bool, cancelable: bool) - -> Root { + -> DomRoot { let ev = reflect_dom_object(box ExtendableEvent::new_inherited(), worker, ExtendableEventBinding::Wrap); { let event = ev.upcast::(); @@ -44,7 +44,7 @@ impl ExtendableEvent { pub fn Constructor(worker: &ServiceWorkerGlobalScope, type_: DOMString, - init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible> { + init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible> { Ok(ExtendableEvent::new(worker, Atom::from(type_), init.parent.bubbles, diff --git a/servo/components/script/dom/extendablemessageevent.rs b/servo/components/script/dom/extendablemessageevent.rs index 6c72655ec4c1..eacc3fb4e8cd 100644 --- a/servo/components/script/dom/extendablemessageevent.rs +++ b/servo/components/script/dom/extendablemessageevent.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding; use dom::bindings::codegen::Bindings::ExtendableMessageEventBinding::ExtendableMessageEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::bindings::trace::RootedTraceableBox; use dom::event::Event; @@ -32,7 +32,7 @@ impl ExtendableMessageEvent { pub fn new(global: &GlobalScope, type_: Atom, bubbles: bool, cancelable: bool, data: HandleValue, origin: DOMString, lastEventId: DOMString) - -> Root { + -> DomRoot { let ev = box ExtendableMessageEvent { event: ExtendableEvent::new_inherited(), data: Heap::default(), @@ -52,7 +52,7 @@ impl ExtendableMessageEvent { pub fn Constructor(worker: &ServiceWorkerGlobalScope, type_: DOMString, init: RootedTraceableBox) - -> Fallible> { + -> Fallible> { let global = worker.upcast::(); let ev = ExtendableMessageEvent::new(global, Atom::from(type_), diff --git a/servo/components/script/dom/file.rs b/servo/components/script/dom/file.rs index 6cf144d10e00..1bfd12a26547 100644 --- a/servo/components/script/dom/file.rs +++ b/servo/components/script/dom/file.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::FileBinding::FileMethods; use dom::bindings::codegen::UnionTypes::BlobOrString; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::blob::{Blob, BlobImpl, blob_parts_to_bytes}; use dom::globalscope::GlobalScope; @@ -44,14 +44,14 @@ impl File { #[allow(unrooted_must_root)] pub fn new(global: &GlobalScope, blob_impl: BlobImpl, - name: DOMString, modified: Option, typeString: &str) -> Root { + name: DOMString, modified: Option, typeString: &str) -> DomRoot { reflect_dom_object(box File::new_inherited(blob_impl, name, modified, typeString), global, FileBinding::Wrap) } // Construct from selected file message from file manager thread - pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root { + pub fn new_from_selected(window: &Window, selected: SelectedFile) -> DomRoot { let name = DOMString::from(selected.filename.to_str().expect("File name encoding error")); File::new(window.upcast(), BlobImpl::new_from_file(selected.id, selected.filename, selected.size), @@ -63,7 +63,7 @@ impl File { fileBits: Vec, filename: DOMString, filePropertyBag: &FileBinding::FilePropertyBag) - -> Fallible> { + -> Fallible> { let bytes: Vec = match blob_parts_to_bytes(fileBits) { Ok(bytes) => bytes, Err(_) => return Err(Error::InvalidCharacter), diff --git a/servo/components/script/dom/filelist.rs b/servo/components/script/dom/filelist.rs index 3a5acc41235e..559f36cbd7c9 100644 --- a/servo/components/script/dom/filelist.rs +++ b/servo/components/script/dom/filelist.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::FileListBinding; use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::file::File; use dom::window::Window; use dom_struct::dom_struct; @@ -15,12 +15,12 @@ use std::slice::Iter; #[dom_struct] pub struct FileList { reflector_: Reflector, - list: Vec> + list: Vec> } impl FileList { #[allow(unrooted_must_root)] - fn new_inherited(files: Vec>) -> FileList { + fn new_inherited(files: Vec>) -> FileList { FileList { reflector_: Reflector::new(), list: files @@ -28,13 +28,13 @@ impl FileList { } #[allow(unrooted_must_root)] - pub fn new(window: &Window, files: Vec>) -> Root { - reflect_dom_object(box FileList::new_inherited(files.iter().map(|r| JS::from_ref(&**r)).collect()), + pub fn new(window: &Window, files: Vec>) -> DomRoot { + reflect_dom_object(box FileList::new_inherited(files.iter().map(|r| Dom::from_ref(&**r)).collect()), window, FileListBinding::Wrap) } - pub fn iter_files(&self) -> Iter> { + pub fn iter_files(&self) -> Iter> { self.list.iter() } } @@ -46,16 +46,16 @@ impl FileListMethods for FileList { } // https://w3c.github.io/FileAPI/#dfn-item - fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { if (index as usize) < self.list.len() { - Some(Root::from_ref(&*(self.list[index as usize]))) + Some(DomRoot::from_ref(&*(self.list[index as usize]))) } else { None } } // check-tidy: no specs after this line - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } } diff --git a/servo/components/script/dom/filereader.rs b/servo/components/script/dom/filereader.rs index 355cd85bcd47..5bd964d41880 100644 --- a/servo/components/script/dom/filereader.rs +++ b/servo/components/script/dom/filereader.rs @@ -3,15 +3,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use base64; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::Bindings::FileReaderBinding::{self, FileReaderConstants, FileReaderMethods}; use dom::bindings::codegen::UnionTypes::StringOrObject; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::bindings::trace::RootedTraceableBox; use dom::blob::Blob; @@ -87,8 +87,8 @@ pub enum FileReaderResult { pub struct FileReader { eventtarget: EventTarget, ready_state: Cell, - error: MutNullableJS, - result: DOMRefCell>, + error: MutNullableDom, + result: DomRefCell>, generation_id: Cell, } @@ -97,18 +97,18 @@ impl FileReader { FileReader { eventtarget: EventTarget::new_inherited(), ready_state: Cell::new(FileReaderReadyState::Empty), - error: MutNullableJS::new(None), - result: DOMRefCell::new(None), + error: MutNullableDom::new(None), + result: DomRefCell::new(None), generation_id: Cell::new(GenerationId(0)), } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box FileReader::new_inherited(), global, FileReaderBinding::Wrap) } - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Ok(FileReader::new(global)) } @@ -216,7 +216,7 @@ impl FileReader { } // https://w3c.github.io/FileAPI/#dfn-readAsText - fn perform_readastext(result: &DOMRefCell>, data: ReadMetaData, blob_bytes: &[u8]) { + fn perform_readastext(result: &DomRefCell>, data: ReadMetaData, blob_bytes: &[u8]) { let blob_label = &data.label; let blob_type = &data.blobtype; @@ -246,7 +246,7 @@ impl FileReader { } //https://w3c.github.io/FileAPI/#dfn-readAsDataURL - fn perform_readasdataurl(result: &DOMRefCell>, data: ReadMetaData, bytes: &[u8]) { + fn perform_readasdataurl(result: &DomRefCell>, data: ReadMetaData, bytes: &[u8]) { let base64 = base64::encode(bytes); let output = if data.blobtype.is_empty() { @@ -260,7 +260,7 @@ impl FileReader { // https://w3c.github.io/FileAPI/#dfn-readAsArrayBuffer #[allow(unsafe_code)] - fn perform_readasarraybuffer(result: &DOMRefCell>, + fn perform_readasarraybuffer(result: &DomRefCell>, cx: *mut JSContext, _: ReadMetaData, bytes: &[u8]) { unsafe { rooted!(in(cx) let mut array_buffer = ptr::null_mut()); @@ -328,7 +328,7 @@ impl FileReaderMethods for FileReader { } // https://w3c.github.io/FileAPI/#dfn-error - fn GetError(&self) -> Option> { + fn GetError(&self) -> Option> { self.error.get() } diff --git a/servo/components/script/dom/filereadersync.rs b/servo/components/script/dom/filereadersync.rs index 744625474cdd..a4e75f4bca54 100644 --- a/servo/components/script/dom/filereadersync.rs +++ b/servo/components/script/dom/filereadersync.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::FileReaderSyncBinding; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::eventtarget::EventTarget; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -22,12 +22,12 @@ impl FileReaderSync { } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box FileReaderSync::new_inherited(), global, FileReaderSyncBinding::Wrap) } - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Ok(FileReaderSync::new(global)) } } diff --git a/servo/components/script/dom/focusevent.rs b/servo/components/script/dom/focusevent.rs index eae3920dae01..de689683b6b2 100644 --- a/servo/components/script/dom/focusevent.rs +++ b/servo/components/script/dom/focusevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::FocusEventBinding::FocusEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::event::{EventBubbles, EventCancelable}; use dom::eventtarget::EventTarget; @@ -20,7 +20,7 @@ use std::default::Default; #[dom_struct] pub struct FocusEvent { uievent: UIEvent, - related_target: MutNullableJS, + related_target: MutNullableDom, } impl FocusEvent { @@ -31,7 +31,7 @@ impl FocusEvent { } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { reflect_dom_object(box FocusEvent::new_inherited(), window, FocusEventBinding::Wrap) @@ -43,7 +43,7 @@ impl FocusEvent { cancelable: EventCancelable, view: Option<&Window>, detail: i32, - related_target: Option<&EventTarget>) -> Root { + related_target: Option<&EventTarget>) -> DomRoot { let ev = FocusEvent::new_uninitialized(window); ev.upcast::().InitUIEvent(type_, bool::from(can_bubble), @@ -55,7 +55,7 @@ impl FocusEvent { pub fn Constructor(window: &Window, type_: DOMString, - init: &FocusEventBinding::FocusEventInit) -> Fallible> { + init: &FocusEventBinding::FocusEventInit) -> Fallible> { let bubbles = EventBubbles::from(init.parent.parent.bubbles); let cancelable = EventCancelable::from(init.parent.parent.cancelable); let event = FocusEvent::new(window, @@ -71,7 +71,7 @@ impl FocusEvent { impl FocusEventMethods for FocusEvent { // https://w3c.github.io/uievents/#widl-FocusEvent-relatedTarget - fn GetRelatedTarget(&self) -> Option> { + fn GetRelatedTarget(&self) -> Option> { self.related_target.get() } diff --git a/servo/components/script/dom/forcetouchevent.rs b/servo/components/script/dom/forcetouchevent.rs index cf5c622d8e8a..b1159a578473 100644 --- a/servo/components/script/dom/forcetouchevent.rs +++ b/servo/components/script/dom/forcetouchevent.rs @@ -6,9 +6,9 @@ use dom::bindings::codegen::Bindings::ForceTouchEventBinding; use dom::bindings::codegen::Bindings::ForceTouchEventBinding::ForceTouchEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::uievent::UIEvent; use dom::window::Window; @@ -30,7 +30,7 @@ impl ForceTouchEvent { pub fn new(window: &Window, type_: DOMString, - force: f32) -> Root { + force: f32) -> DomRoot { let event = box ForceTouchEvent::new_inherited(force); let ev = reflect_dom_object(event, window, ForceTouchEventBinding::Wrap); ev.upcast::().InitUIEvent(type_, true, true, Some(window), 0); diff --git a/servo/components/script/dom/formdata.rs b/servo/components/script/dom/formdata.rs index 2d8657e35648..f97b425883a2 100644 --- a/servo/components/script/dom/formdata.rs +++ b/servo/components/script/dom/formdata.rs @@ -2,15 +2,15 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods; use dom::bindings::codegen::Bindings::FormDataBinding::FormDataWrap; use dom::bindings::codegen::UnionTypes::FileOrUSVString; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; use dom::bindings::iterable::Iterable; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{DOMString, USVString}; use dom::blob::{Blob, BlobImpl}; use dom::file::File; @@ -25,7 +25,7 @@ use std::iter; #[dom_struct] pub struct FormData { reflector_: Reflector, - data: DOMRefCell>>, + data: DomRefCell>>, } impl FormData { @@ -43,16 +43,16 @@ impl FormData { FormData { reflector_: Reflector::new(), - data: DOMRefCell::new(hashmap), + data: DomRefCell::new(hashmap), } } - pub fn new(form: Option<&HTMLFormElement>, global: &GlobalScope) -> Root { + pub fn new(form: Option<&HTMLFormElement>, global: &GlobalScope) -> DomRoot { reflect_dom_object(box FormData::new_inherited(form), global, FormDataWrap) } - pub fn Constructor(global: &GlobalScope, form: Option<&HTMLFormElement>) -> Fallible> { + pub fn Constructor(global: &GlobalScope, form: Option<&HTMLFormElement>) -> Fallible> { // TODO: Construct form data set for form if it is supplied Ok(FormData::new(form, global)) } @@ -80,7 +80,7 @@ impl FormDataMethods for FormData { let datum = FormDatum { ty: DOMString::from("file"), name: DOMString::from(name.0.clone()), - value: FormDatumValue::File(Root::from_ref(&*self.create_an_entry(blob, filename))), + value: FormDatumValue::File(DomRoot::from_ref(&*self.create_an_entry(blob, filename))), }; let mut data = self.data.borrow_mut(); @@ -102,7 +102,7 @@ impl FormDataMethods for FormData { .get(&LocalName::from(name.0)) .map(|entry| match entry[0].value { FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())), - FormDatumValue::File(ref b) => FileOrUSVString::File(Root::from_ref(&*b)), + FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(&*b)), }) } @@ -113,7 +113,7 @@ impl FormDataMethods for FormData { .map_or(vec![], |data| data.iter().map(|item| match item.value { FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())), - FormDatumValue::File(ref b) => FileOrUSVString::File(Root::from_ref(&*b)), + FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(&*b)), }).collect() ) } @@ -138,7 +138,7 @@ impl FormDataMethods for FormData { self.data.borrow_mut().insert(LocalName::from(name.0.clone()), vec![FormDatum { ty: DOMString::from("file"), name: DOMString::from(name.0), - value: FormDatumValue::File(Root::from_ref(&*self.create_an_entry(blob, filename))), + value: FormDatumValue::File(DomRoot::from_ref(&*self.create_an_entry(blob, filename))), }]); } @@ -148,7 +148,7 @@ impl FormDataMethods for FormData { impl FormData { // https://xhr.spec.whatwg.org/#create-an-entry // Steps 3-4. - fn create_an_entry(&self, blob: &Blob, opt_filename: Option) -> Root { + fn create_an_entry(&self, blob: &Blob, opt_filename: Option) -> DomRoot { let name = match opt_filename { Some(filename) => DOMString::from(filename.0), None if blob.downcast::().is_none() => DOMString::from("blob"), @@ -185,7 +185,7 @@ impl Iterable for FormData { .value; match *value { FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())), - FormDatumValue::File(ref b) => FileOrUSVString::File(Root::from_ref(&*b)), + FormDatumValue::File(ref b) => FileOrUSVString::File(DomRoot::from_ref(&*b)), } } diff --git a/servo/components/script/dom/gamepad.rs b/servo/components/script/dom/gamepad.rs index bee219bbbcdc..39e76818906e 100644 --- a/servo/components/script/dom/gamepad.rs +++ b/servo/components/script/dom/gamepad.rs @@ -6,9 +6,9 @@ use core::nonzero::NonZero; use dom::bindings::codegen::Bindings::GamepadBinding; use dom::bindings::codegen::Bindings::GamepadBinding::GamepadMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::num::Finite; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::event::Event; use dom::eventtarget::EventTarget; @@ -33,8 +33,8 @@ pub struct Gamepad { timestamp: Cell, mapping_type: String, axes: Heap<*mut JSObject>, - buttons: JS, - pose: Option>, + buttons: Dom, + pose: Option>, #[ignore_heap_size_of = "Defined in rust-webvr"] hand: WebVRGamepadHand, display_id: u32 @@ -60,8 +60,8 @@ impl Gamepad { timestamp: Cell::new(timestamp), mapping_type: mapping_type, axes: Heap::default(), - buttons: JS::from_ref(buttons), - pose: pose.map(JS::from_ref), + buttons: Dom::from_ref(buttons), + pose: pose.map(Dom::from_ref), hand: hand, display_id: display_id } @@ -71,7 +71,7 @@ impl Gamepad { pub fn new_from_vr(global: &GlobalScope, index: i32, data: &WebVRGamepadData, - state: &WebVRGamepadState) -> Root { + state: &WebVRGamepadState) -> DomRoot { let buttons = GamepadButtonList::new_from_vr(&global, &state.buttons); let pose = VRPose::new(&global, &state.pose); @@ -132,8 +132,8 @@ impl GamepadMethods for Gamepad { } // https://w3c.github.io/gamepad/#dom-gamepad-buttons - fn Buttons(&self) -> Root { - Root::from_ref(&*self.buttons) + fn Buttons(&self) -> DomRoot { + DomRoot::from_ref(&*self.buttons) } // https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum @@ -147,8 +147,8 @@ impl GamepadMethods for Gamepad { } // https://w3c.github.io/gamepad/extensions.html#dom-gamepad-pose - fn GetPose(&self) -> Option> { - self.pose.as_ref().map(|p| Root::from_ref(&**p)) + fn GetPose(&self) -> Option> { + self.pose.as_ref().map(|p| DomRoot::from_ref(&**p)) } // https://w3c.github.io/webvr/spec/1.1/#gamepad-getvrdisplays-attribute diff --git a/servo/components/script/dom/gamepadbutton.rs b/servo/components/script/dom/gamepadbutton.rs index ff0c7271e5b8..1fc93941f9cc 100644 --- a/servo/components/script/dom/gamepadbutton.rs +++ b/servo/components/script/dom/gamepadbutton.rs @@ -4,9 +4,9 @@ use dom::bindings::codegen::Bindings::GamepadButtonBinding; use dom::bindings::codegen::Bindings::GamepadButtonBinding::GamepadButtonMethods; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use std::cell::Cell; @@ -29,7 +29,7 @@ impl GamepadButton { } } - pub fn new(global: &GlobalScope, pressed: bool, touched: bool) -> Root { + pub fn new(global: &GlobalScope, pressed: bool, touched: bool) -> DomRoot { reflect_dom_object(box GamepadButton::new_inherited(pressed, touched), global, GamepadButtonBinding::Wrap) diff --git a/servo/components/script/dom/gamepadbuttonlist.rs b/servo/components/script/dom/gamepadbuttonlist.rs index 5ac25504009b..809760baca29 100644 --- a/servo/components/script/dom/gamepadbuttonlist.rs +++ b/servo/components/script/dom/gamepadbuttonlist.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::GamepadButtonListBinding; use dom::bindings::codegen::Bindings::GamepadButtonListBinding::GamepadButtonListMethods; -use dom::bindings::js::{JS, Root, RootedReference}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, RootedReference}; use dom::gamepadbutton::GamepadButton; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -15,7 +15,7 @@ use webvr_traits::WebVRGamepadButton; #[dom_struct] pub struct GamepadButtonList { reflector_: Reflector, - list: Vec> + list: Vec> } impl GamepadButtonList { @@ -23,11 +23,11 @@ impl GamepadButtonList { fn new_inherited(list: &[&GamepadButton]) -> GamepadButtonList { GamepadButtonList { reflector_: Reflector::new(), - list: list.iter().map(|button| JS::from_ref(*button)).collect(), + list: list.iter().map(|button| Dom::from_ref(*button)).collect(), } } - pub fn new_from_vr(global: &GlobalScope, buttons: &[WebVRGamepadButton]) -> Root { + pub fn new_from_vr(global: &GlobalScope, buttons: &[WebVRGamepadButton]) -> DomRoot { rooted_vec!(let list <- buttons.iter() .map(|btn| GamepadButton::new(&global, btn.pressed, btn.touched))); @@ -52,12 +52,12 @@ impl GamepadButtonListMethods for GamepadButtonList { } // https://w3c.github.io/gamepad/#dom-gamepad-buttons - fn Item(&self, index: u32) -> Option> { - self.list.get(index as usize).map(|button| Root::from_ref(&**button)) + fn Item(&self, index: u32) -> Option> { + self.list.get(index as usize).map(|button| DomRoot::from_ref(&**button)) } // https://w3c.github.io/gamepad/#dom-gamepad-buttons - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } } diff --git a/servo/components/script/dom/gamepadevent.rs b/servo/components/script/dom/gamepadevent.rs index f6690981a57b..644713be2256 100644 --- a/servo/components/script/dom/gamepadevent.rs +++ b/servo/components/script/dom/gamepadevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::GamepadEventBinding; use dom::bindings::codegen::Bindings::GamepadEventBinding::GamepadEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::event::Event; use dom::gamepad::Gamepad; @@ -20,7 +20,7 @@ use servo_atoms::Atom; #[dom_struct] pub struct GamepadEvent { event: Event, - gamepad: JS, + gamepad: Dom, } pub enum GamepadEventType { @@ -32,7 +32,7 @@ impl GamepadEvent { fn new_inherited(gamepad: &Gamepad) -> GamepadEvent { GamepadEvent { event: Event::new_inherited(), - gamepad: JS::from_ref(gamepad), + gamepad: Dom::from_ref(gamepad), } } @@ -41,7 +41,7 @@ impl GamepadEvent { bubbles: bool, cancelable: bool, gamepad: &Gamepad) - -> Root { + -> DomRoot { let ev = reflect_dom_object(box GamepadEvent::new_inherited(&gamepad), global, GamepadEventBinding::Wrap); @@ -53,7 +53,7 @@ impl GamepadEvent { } pub fn new_with_type(global: &GlobalScope, event_type: GamepadEventType, gamepad: &Gamepad) - -> Root { + -> DomRoot { let name = match event_type { GamepadEventType::Connected => "gamepadconnected", GamepadEventType::Disconnected => "gamepaddisconnected" @@ -70,7 +70,7 @@ impl GamepadEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &GamepadEventBinding::GamepadEventInit) - -> Fallible> { + -> Fallible> { Ok(GamepadEvent::new(&window.global(), Atom::from(type_), init.parent.bubbles, @@ -81,8 +81,8 @@ impl GamepadEvent { impl GamepadEventMethods for GamepadEvent { // https://w3c.github.io/gamepad/#gamepadevent-interface - fn Gamepad(&self) -> Root { - Root::from_ref(&*self.gamepad) + fn Gamepad(&self) -> DomRoot { + DomRoot::from_ref(&*self.gamepad) } // https://dom.spec.whatwg.org/#dom-event-istrusted diff --git a/servo/components/script/dom/gamepadlist.rs b/servo/components/script/dom/gamepadlist.rs index dd5bdd757d9c..bcbb71314565 100644 --- a/servo/components/script/dom/gamepadlist.rs +++ b/servo/components/script/dom/gamepadlist.rs @@ -2,11 +2,11 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::GamepadListBinding; use dom::bindings::codegen::Bindings::GamepadListBinding::GamepadListMethods; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::gamepad::Gamepad; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -15,27 +15,27 @@ use dom_struct::dom_struct; #[dom_struct] pub struct GamepadList { reflector_: Reflector, - list: DOMRefCell>> + list: DomRefCell>> } impl GamepadList { fn new_inherited(list: &[&Gamepad]) -> GamepadList { GamepadList { reflector_: Reflector::new(), - list: DOMRefCell::new(list.iter().map(|g| JS::from_ref(&**g)).collect()) + list: DomRefCell::new(list.iter().map(|g| Dom::from_ref(&**g)).collect()) } } - pub fn new(global: &GlobalScope, list: &[&Gamepad]) -> Root { + pub fn new(global: &GlobalScope, list: &[&Gamepad]) -> DomRoot { reflect_dom_object(box GamepadList::new_inherited(list), global, GamepadListBinding::Wrap) } - pub fn add_if_not_exists(&self, gamepads: &[Root]) { + pub fn add_if_not_exists(&self, gamepads: &[DomRoot]) { for gamepad in gamepads { if !self.list.borrow().iter().any(|g| g.gamepad_id() == gamepad.gamepad_id()) { - self.list.borrow_mut().push(JS::from_ref(&*gamepad)); + self.list.borrow_mut().push(Dom::from_ref(&*gamepad)); // Ensure that the gamepad has the correct index gamepad.update_index(self.list.borrow().len() as i32 - 1); } @@ -50,12 +50,12 @@ impl GamepadListMethods for GamepadList { } // https://w3c.github.io/gamepad/#dom-navigator-getgamepads - fn Item(&self, index: u32) -> Option> { - self.list.borrow().get(index as usize).map(|gamepad| Root::from_ref(&**gamepad)) + fn Item(&self, index: u32) -> Option> { + self.list.borrow().get(index as usize).map(|gamepad| DomRoot::from_ref(&**gamepad)) } // https://w3c.github.io/gamepad/#dom-navigator-getgamepads - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } } diff --git a/servo/components/script/dom/globalscope.rs b/servo/components/script/dom/globalscope.rs index e298cb184c8b..386231ac6e35 100644 --- a/servo/components/script/dom/globalscope.rs +++ b/servo/components/script/dom/globalscope.rs @@ -3,14 +3,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods; use dom::bindings::conversions::root_from_object; use dom::bindings::error::{ErrorInfo, report_pending_exception}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::settings_stack::{AutoEntryScript, entry_global, incumbent_global}; use dom::bindings::str::DOMString; use dom::crypto::Crypto; @@ -58,7 +58,7 @@ use timers::{OneshotTimers, TimerCallback}; #[dom_struct] pub struct GlobalScope { eventtarget: EventTarget, - crypto: MutNullableJS, + crypto: MutNullableDom, next_worker_id: Cell, /// Pipeline id associated with this global. @@ -69,7 +69,7 @@ pub struct GlobalScope { devtools_wants_updates: Cell, /// Timers used by the Console API. - console_timers: DOMRefCell>, + console_timers: DomRefCell>, /// For providing instructions to an optional devtools server. #[ignore_heap_size_of = "channels are hard"] @@ -131,7 +131,7 @@ impl GlobalScope { next_worker_id: Cell::new(WorkerId(0)), pipeline_id, devtools_wants_updates: Default::default(), - console_timers: DOMRefCell::new(Default::default()), + console_timers: DomRefCell::new(Default::default()), devtools_chan, mem_profiler_chan, time_profiler_chan, @@ -148,13 +148,13 @@ impl GlobalScope { /// Returns the global scope of the realm that the given DOM object's reflector /// was created in. #[allow(unsafe_code)] - pub fn from_reflector(reflector: &T) -> Root { + pub fn from_reflector(reflector: &T) -> DomRoot { unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) } } /// Returns the global scope of the realm that the given JS object was created in. #[allow(unsafe_code)] - pub unsafe fn from_object(obj: *mut JSObject) -> Root { + pub unsafe fn from_object(obj: *mut JSObject) -> DomRoot { assert!(!obj.is_null()); let global = GetGlobalForObjectCrossCompartment(obj); global_scope_from_global(global) @@ -162,7 +162,7 @@ impl GlobalScope { /// Returns the global scope for the given JSContext #[allow(unsafe_code)] - pub unsafe fn from_context(cx: *mut JSContext) -> Root { + pub unsafe fn from_context(cx: *mut JSContext) -> DomRoot { let global = CurrentGlobalOrNull(cx); global_scope_from_global(global) } @@ -170,7 +170,7 @@ impl GlobalScope { /// Returns the global object of the realm that the given JS object /// was created in, after unwrapping any wrappers. #[allow(unsafe_code)] - pub unsafe fn from_object_maybe_wrapped(mut obj: *mut JSObject) -> Root { + pub unsafe fn from_object_maybe_wrapped(mut obj: *mut JSObject) -> DomRoot { if IsWrapper(obj) { obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0); assert!(!obj.is_null()); @@ -190,7 +190,7 @@ impl GlobalScope { } } - pub fn crypto(&self) -> Root { + pub fn crypto(&self) -> DomRoot { self.crypto.or_init(|| Crypto::new(self)) } @@ -409,7 +409,7 @@ impl GlobalScope { let _aes = AutoEntryScript::new(self); let options = CompileOptionsWrapper::new(cx, filename.as_ptr(), line_number); - debug!("evaluating JS string"); + debug!("evaluating Dom string"); let result = unsafe { Evaluate2(cx, options.ptr, code.as_ptr(), code.len() as libc::size_t, @@ -417,7 +417,7 @@ impl GlobalScope { }; if !result { - debug!("error evaluating JS string"); + debug!("error evaluating Dom string"); unsafe { report_pending_exception(cx, true) }; } @@ -496,7 +496,7 @@ impl GlobalScope { /// Perform a microtask checkpoint. pub fn perform_a_microtask_checkpoint(&self) { - self.microtask_queue.checkpoint(|_| Some(Root::from_ref(self))); + self.microtask_queue.checkpoint(|_| Some(DomRoot::from_ref(self))); } /// Enqueue a microtask for subsequent execution. @@ -550,7 +550,7 @@ impl GlobalScope { /// /// ["current"]: https://html.spec.whatwg.org/multipage/#current #[allow(unsafe_code)] - pub fn current() -> Option> { + pub fn current() -> Option> { unsafe { let cx = Runtime::get(); assert!(!cx.is_null()); @@ -566,18 +566,18 @@ impl GlobalScope { /// Returns the ["entry"] global object. /// /// ["entry"]: https://html.spec.whatwg.org/multipage/#entry - pub fn entry() -> Root { + pub fn entry() -> DomRoot { entry_global() } /// Returns the ["incumbent"] global object. /// /// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent - pub fn incumbent() -> Option> { + pub fn incumbent() -> Option> { incumbent_global() } - pub fn performance(&self) -> Root { + pub fn performance(&self) -> DomRoot { if let Some(window) = self.downcast::() { return window.Performance(); } @@ -607,7 +607,7 @@ fn timestamp_in_ms(time: Timespec) -> u64 { /// Returns the Rust global scope from a JS global object. #[allow(unsafe_code)] -unsafe fn global_scope_from_global(global: *mut JSObject) -> Root { +unsafe fn global_scope_from_global(global: *mut JSObject) -> DomRoot { assert!(!global.is_null()); let clasp = get_object_class(global); assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0); diff --git a/servo/components/script/dom/hashchangeevent.rs b/servo/components/script/dom/hashchangeevent.rs index 4505d79f4401..16dad9f60784 100644 --- a/servo/components/script/dom/hashchangeevent.rs +++ b/servo/components/script/dom/hashchangeevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::HashChangeEventBinding; use dom::bindings::codegen::Bindings::HashChangeEventBinding::HashChangeEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::{DOMString, USVString}; use dom::event::Event; use dom::window::Window; @@ -32,7 +32,7 @@ impl HashChangeEvent { } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()), window, HashChangeEventBinding::Wrap) @@ -44,7 +44,7 @@ impl HashChangeEvent { cancelable: bool, old_url: String, new_url: String) - -> Root { + -> DomRoot { let ev = reflect_dom_object(box HashChangeEvent::new_inherited(old_url, new_url), window, HashChangeEventBinding::Wrap); @@ -58,7 +58,7 @@ impl HashChangeEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &HashChangeEventBinding::HashChangeEventInit) - -> Fallible> { + -> Fallible> { Ok(HashChangeEvent::new(window, Atom::from(type_), init.parent.bubbles, diff --git a/servo/components/script/dom/headers.rs b/servo/components/script/dom/headers.rs index ce97cb860d2e..2baa604b058c 100644 --- a/servo/components/script/dom/headers.rs +++ b/servo/components/script/dom/headers.rs @@ -2,12 +2,12 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods, HeadersWrap}; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::iterable::Iterable; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{ByteString, is_token}; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -22,7 +22,7 @@ pub struct Headers { reflector_: Reflector, guard: Cell, #[ignore_heap_size_of = "Defined in hyper"] - header_list: DOMRefCell + header_list: DomRefCell } // https://fetch.spec.whatwg.org/#concept-headers-guard @@ -40,17 +40,17 @@ impl Headers { Headers { reflector_: Reflector::new(), guard: Cell::new(Guard::None), - header_list: DOMRefCell::new(HyperHeaders::new()), + header_list: DomRefCell::new(HyperHeaders::new()), } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box Headers::new_inherited(), global, HeadersWrap) } // https://fetch.spec.whatwg.org/#dom-headers pub fn Constructor(global: &GlobalScope, init: Option) - -> Fallible> { + -> Fallible> { let dom_headers_new = Headers::new(global); dom_headers_new.fill(init)?; Ok(dom_headers_new) @@ -206,13 +206,13 @@ impl Headers { } } - pub fn for_request(global: &GlobalScope) -> Root { + pub fn for_request(global: &GlobalScope) -> DomRoot { let headers_for_request = Headers::new(global); headers_for_request.guard.set(Guard::Request); headers_for_request } - pub fn for_response(global: &GlobalScope) -> Root { + pub fn for_response(global: &GlobalScope) -> DomRoot { let headers_for_response = Headers::new(global); headers_for_response.guard.set(Guard::Response); headers_for_response diff --git a/servo/components/script/dom/history.rs b/servo/components/script/dom/history.rs index 9344f3f4b80b..9e97a3d5e955 100644 --- a/servo/components/script/dom/history.rs +++ b/servo/components/script/dom/history.rs @@ -8,8 +8,8 @@ use dom::bindings::codegen::Bindings::LocationBinding::LocationBinding::Location use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::globalscope::GlobalScope; use dom::window::Window; use dom_struct::dom_struct; @@ -21,18 +21,18 @@ use script_traits::ScriptMsg; #[dom_struct] pub struct History { reflector_: Reflector, - window: JS, + window: Dom, } impl History { pub fn new_inherited(window: &Window) -> History { History { reflector_: Reflector::new(), - window: JS::from_ref(&window), + window: Dom::from_ref(&window), } } - pub fn new(window: &Window) -> Root { + pub fn new(window: &Window) -> DomRoot { reflect_dom_object(box History::new_inherited(window), window, HistoryBinding::Wrap) diff --git a/servo/components/script/dom/htmlanchorelement.rs b/servo/components/script/dom/htmlanchorelement.rs index aefa776531c0..5909480eb95d 100644 --- a/servo/components/script/dom/htmlanchorelement.rs +++ b/servo/components/script/dom/htmlanchorelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::activation::Activatable; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods; use dom::bindings::codegen::Bindings::HTMLAnchorElementBinding; @@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::HTMLAnchorElementBinding::HTMLAnchorElemen use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::{DOMString, USVString}; use dom::document::Document; use dom::domtokenlist::DOMTokenList; @@ -37,8 +37,8 @@ use style::attr::AttrValue; #[dom_struct] pub struct HTMLAnchorElement { htmlelement: HTMLElement, - rel_list: MutNullableJS, - url: DOMRefCell>, + rel_list: MutNullableDom, + url: DomRefCell>, } impl HTMLAnchorElement { @@ -49,14 +49,14 @@ impl HTMLAnchorElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), rel_list: Default::default(), - url: DOMRefCell::new(None), + url: DomRefCell::new(None), } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLAnchorElement::new_inherited(local_name, prefix, document), document, HTMLAnchorElementBinding::Wrap) @@ -122,7 +122,7 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement { } // https://html.spec.whatwg.org/multipage/#dom-a-rellist - fn RelList(&self) -> Root { + fn RelList(&self) -> DomRoot { self.rel_list.or_init(|| DOMTokenList::new(self.upcast(), &local_name!("rel"))) } diff --git a/servo/components/script/dom/htmlappletelement.rs b/servo/components/script/dom/htmlappletelement.rs index c8d07f488040..a28475442837 100644 --- a/servo/components/script/dom/htmlappletelement.rs +++ b/servo/components/script/dom/htmlappletelement.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::HTMLAppletElementBinding; use dom::bindings::codegen::Bindings::HTMLAppletElementBinding::HTMLAppletElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::htmlelement::HTMLElement; @@ -33,7 +33,7 @@ impl HTMLAppletElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLAppletElement::new_inherited(local_name, prefix, document), document, HTMLAppletElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlareaelement.rs b/servo/components/script/dom/htmlareaelement.rs index 4e227491d01d..859c1081e97e 100644 --- a/servo/components/script/dom/htmlareaelement.rs +++ b/servo/components/script/dom/htmlareaelement.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods; use dom::bindings::codegen::Bindings::HTMLAreaElementBinding; use dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::domtokenlist::DOMTokenList; @@ -217,7 +217,7 @@ impl Area { #[dom_struct] pub struct HTMLAreaElement { htmlelement: HTMLElement, - rel_list: MutNullableJS, + rel_list: MutNullableDom, } impl HTMLAreaElement { @@ -231,7 +231,7 @@ impl HTMLAreaElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLAreaElement::new_inherited(local_name, prefix, document), document, HTMLAreaElementBinding::Wrap) @@ -273,7 +273,7 @@ impl VirtualMethods for HTMLAreaElement { impl HTMLAreaElementMethods for HTMLAreaElement { // https://html.spec.whatwg.org/multipage/#dom-area-rellist - fn RelList(&self) -> Root { + fn RelList(&self) -> DomRoot { self.rel_list.or_init(|| { DOMTokenList::new(self.upcast(), &local_name!("rel")) }) diff --git a/servo/components/script/dom/htmlaudioelement.rs b/servo/components/script/dom/htmlaudioelement.rs index 6d98e94209b5..456baaa23168 100644 --- a/servo/components/script/dom/htmlaudioelement.rs +++ b/servo/components/script/dom/htmlaudioelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLAudioElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlmediaelement::HTMLMediaElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLAudioElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLAudioElement::new_inherited(local_name, prefix, document), document, HTMLAudioElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlbaseelement.rs b/servo/components/script/dom/htmlbaseelement.rs index 0b42265617d2..ada9539833a6 100644 --- a/servo/components/script/dom/htmlbaseelement.rs +++ b/servo/components/script/dom/htmlbaseelement.rs @@ -6,7 +6,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLBaseElementBinding; use dom::bindings::codegen::Bindings::HTMLBaseElementBinding::HTMLBaseElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element}; @@ -33,7 +33,7 @@ impl HTMLBaseElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLBaseElement::new_inherited(local_name, prefix, document), document, HTMLBaseElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlbodyelement.rs b/servo/components/script/dom/htmlbodyelement.rs index 7c9c53ade45b..4ade5560700b 100644 --- a/servo/components/script/dom/htmlbodyelement.rs +++ b/servo/components/script/dom/htmlbodyelement.rs @@ -7,7 +7,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{self, HTMLBodyElementMethods}; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, Root}; +use dom::bindings::root::{LayoutDom, DomRoot}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; @@ -42,7 +42,7 @@ impl HTMLBodyElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, document: &Document) - -> Root { + -> DomRoot { Node::reflect_node(box HTMLBodyElement::new_inherited(local_name, prefix, document), document, HTMLBodyElementBinding::Wrap) @@ -88,7 +88,7 @@ pub trait HTMLBodyElementLayoutHelpers { fn get_background(&self) -> Option; } -impl HTMLBodyElementLayoutHelpers for LayoutJS { +impl HTMLBodyElementLayoutHelpers for LayoutDom { #[allow(unsafe_code)] fn get_background_color(&self) -> Option { unsafe { diff --git a/servo/components/script/dom/htmlbrelement.rs b/servo/components/script/dom/htmlbrelement.rs index dba06c52a0f1..fa782cf35645 100644 --- a/servo/components/script/dom/htmlbrelement.rs +++ b/servo/components/script/dom/htmlbrelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLBRElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -25,7 +25,7 @@ impl HTMLBRElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLBRElement::new_inherited(local_name, prefix, document), document, HTMLBRElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlbuttonelement.rs b/servo/components/script/dom/htmlbuttonelement.rs index 84a1294d1c2e..aea8bf5c5857 100755 --- a/servo/components/script/dom/htmlbuttonelement.rs +++ b/servo/components/script/dom/htmlbuttonelement.rs @@ -7,7 +7,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLButtonElementBinding; use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element}; @@ -42,7 +42,7 @@ enum ButtonType { pub struct HTMLButtonElement { htmlelement: HTMLElement, button_type: Cell, - form_owner: MutNullableJS, + form_owner: MutNullableDom, } impl HTMLButtonElement { @@ -61,7 +61,7 @@ impl HTMLButtonElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLButtonElement::new_inherited(local_name, prefix, document), document, HTMLButtonElementBinding::Wrap) @@ -70,7 +70,7 @@ impl HTMLButtonElement { impl HTMLButtonElementMethods for HTMLButtonElement { // https://html.spec.whatwg.org/multipage/#dom-cva-validity - fn Validity(&self) -> Root { + fn Validity(&self) -> DomRoot { let window = window_from_node(self); ValidityState::new(&window, self.upcast()) } @@ -82,7 +82,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement { make_bool_setter!(SetDisabled, "disabled"); // https://html.spec.whatwg.org/multipage/#dom-fae-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { self.form_owner() } @@ -138,7 +138,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement { make_setter!(SetValue, "value"); // https://html.spec.whatwg.org/multipage/#dom-lfe-labels - fn Labels(&self) -> Root { + fn Labels(&self) -> DomRoot { self.upcast::().labels() } } @@ -244,7 +244,7 @@ impl VirtualMethods for HTMLButtonElement { } impl FormControl for HTMLButtonElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } @@ -319,7 +319,7 @@ impl Activatable for HTMLButtonElement { return; } node.query_selector_iter(DOMString::from("button[type=submit]")).unwrap() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .find(|r| r.form_owner() == owner) .map(|s| synthetic_click_activation(s.as_element(), ctrl_key, diff --git a/servo/components/script/dom/htmlcanvaselement.rs b/servo/components/script/dom/htmlcanvaselement.rs index 4491c22487a2..c624d5d9fdaa 100644 --- a/servo/components/script/dom/htmlcanvaselement.rs +++ b/servo/components/script/dom/htmlcanvaselement.rs @@ -5,7 +5,7 @@ use base64; use canvas_traits::canvas::{CanvasMsg, FromScriptMsg}; use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasRenderingContext2DMethods; use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding; use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::HTMLCanvasElementMethods; @@ -14,8 +14,8 @@ use dom::bindings::codegen::UnionTypes::CanvasRenderingContext2DOrWebGLRendering use dom::bindings::conversions::ConversionResult; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, Root}; use dom::bindings::num::Finite; +use dom::bindings::root::{Dom, DomRoot, LayoutDom}; use dom::bindings::str::DOMString; use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers}; use dom::document::Document; @@ -44,14 +44,14 @@ const DEFAULT_HEIGHT: u32 = 150; #[must_root] #[derive(Clone, HeapSizeOf, JSTraceable)] pub enum CanvasContext { - Context2d(JS), - WebGL(JS), + Context2d(Dom), + WebGL(Dom), } #[dom_struct] pub struct HTMLCanvasElement { htmlelement: HTMLElement, - context: DOMRefCell>, + context: DomRefCell>, } impl HTMLCanvasElement { @@ -60,14 +60,14 @@ impl HTMLCanvasElement { document: &Document) -> HTMLCanvasElement { HTMLCanvasElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), - context: DOMRefCell::new(None), + context: DomRefCell::new(None), } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLCanvasElement::new_inherited(local_name, prefix, document), document, HTMLCanvasElementBinding::Wrap) @@ -101,7 +101,7 @@ pub trait LayoutHTMLCanvasElementHelpers { fn get_height(&self) -> LengthOrPercentageOrAuto; } -impl LayoutHTMLCanvasElementHelpers for LayoutJS { +impl LayoutHTMLCanvasElementHelpers for LayoutDom { #[allow(unsafe_code)] fn data(&self) -> HTMLCanvasData { unsafe { @@ -151,16 +151,16 @@ impl LayoutHTMLCanvasElementHelpers for LayoutJS { impl HTMLCanvasElement { - pub fn get_or_init_2d_context(&self) -> Option> { + pub fn get_or_init_2d_context(&self) -> Option> { if self.context.borrow().is_none() { let window = window_from_node(self); let size = self.get_size(); let context = CanvasRenderingContext2D::new(window.upcast::(), self, size); - *self.context.borrow_mut() = Some(CanvasContext::Context2d(JS::from_ref(&*context))); + *self.context.borrow_mut() = Some(CanvasContext::Context2d(Dom::from_ref(&*context))); } match *self.context.borrow().as_ref().unwrap() { - CanvasContext::Context2d(ref context) => Some(Root::from_ref(&*context)), + CanvasContext::Context2d(ref context) => Some(DomRoot::from_ref(&*context)), _ => None, } } @@ -168,7 +168,7 @@ impl HTMLCanvasElement { #[allow(unsafe_code)] pub fn get_or_init_webgl_context(&self, cx: *mut JSContext, - attrs: Option) -> Option> { + attrs: Option) -> Option> { if self.context.borrow().is_none() { let window = window_from_node(self); let size = self.get_size(); @@ -192,11 +192,11 @@ impl HTMLCanvasElement { let maybe_ctx = WebGLRenderingContext::new(&window, self, size, attrs); - *self.context.borrow_mut() = maybe_ctx.map( |ctx| CanvasContext::WebGL(JS::from_ref(&*ctx))); + *self.context.borrow_mut() = maybe_ctx.map( |ctx| CanvasContext::WebGL(Dom::from_ref(&*ctx))); } if let Some(CanvasContext::WebGL(ref context)) = *self.context.borrow() { - Some(Root::from_ref(&*context)) + Some(DomRoot::from_ref(&*context)) } else { None } diff --git a/servo/components/script/dom/htmlcollection.rs b/servo/components/script/dom/htmlcollection.rs index aa8fe9cf3830..cefa1407413d 100644 --- a/servo/components/script/dom/htmlcollection.rs +++ b/servo/components/script/dom/htmlcollection.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::HTMLCollectionBinding; use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root, MutNullableJS}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; use dom::bindings::xmlname::namespace_from_domstring; @@ -53,14 +53,14 @@ impl OptionU32 { #[dom_struct] pub struct HTMLCollection { reflector_: Reflector, - root: JS, + root: Dom, #[ignore_heap_size_of = "Contains a trait object; can't measure due to #6870"] filter: Box, // We cache the version of the root node and all its decendents, // the length of the collection, and a cursor into the collection. // FIXME: make the cached cursor element a weak pointer cached_version: Cell, - cached_cursor_element: MutNullableJS, + cached_cursor_element: MutNullableDom, cached_cursor_index: Cell, cached_length: Cell, } @@ -70,24 +70,24 @@ impl HTMLCollection { pub fn new_inherited(root: &Node, filter: Box) -> HTMLCollection { HTMLCollection { reflector_: Reflector::new(), - root: JS::from_ref(root), + root: Dom::from_ref(root), filter: filter, // Default values for the cache cached_version: Cell::new(root.inclusive_descendants_version()), - cached_cursor_element: MutNullableJS::new(None), + cached_cursor_element: MutNullableDom::new(None), cached_cursor_index: Cell::new(OptionU32::none()), cached_length: Cell::new(OptionU32::none()), } } #[allow(unrooted_must_root)] - pub fn new(window: &Window, root: &Node, filter: Box) -> Root { + pub fn new(window: &Window, root: &Node, filter: Box) -> DomRoot { reflect_dom_object(box HTMLCollection::new_inherited(root, filter), window, HTMLCollectionBinding::Wrap) } pub fn create(window: &Window, root: &Node, - filter: Box) -> Root { + filter: Box) -> DomRoot { HTMLCollection::new(window, root, filter) } @@ -104,7 +104,7 @@ impl HTMLCollection { } } - fn set_cached_cursor(&self, index: u32, element: Option>) -> Option> { + fn set_cached_cursor(&self, index: u32, element: Option>) -> Option> { if let Some(element) = element { self.cached_cursor_index.set(OptionU32::some(index)); self.cached_cursor_element.set(Some(&element)); @@ -116,7 +116,7 @@ impl HTMLCollection { // https://dom.spec.whatwg.org/#concept-getelementsbytagname pub fn by_qualified_name(window: &Window, root: &Node, qualified_name: LocalName) - -> Root { + -> DomRoot { // case 1 if qualified_name == local_name!("*") { #[derive(HeapSizeOf, JSTraceable)] @@ -161,14 +161,14 @@ impl HTMLCollection { } pub fn by_tag_name_ns(window: &Window, root: &Node, tag: DOMString, - maybe_ns: Option) -> Root { + maybe_ns: Option) -> DomRoot { let local = LocalName::from(tag); let ns = namespace_from_domstring(maybe_ns); let qname = QualName::new(None, ns, local); HTMLCollection::by_qual_tag_name(window, root, qname) } - pub fn by_qual_tag_name(window: &Window, root: &Node, qname: QualName) -> Root { + pub fn by_qual_tag_name(window: &Window, root: &Node, qname: QualName) -> DomRoot { #[derive(HeapSizeOf, JSTraceable)] struct TagNameNSFilter { qname: QualName @@ -186,13 +186,13 @@ impl HTMLCollection { } pub fn by_class_name(window: &Window, root: &Node, classes: DOMString) - -> Root { + -> DomRoot { let class_atoms = split_html_space_chars(&classes).map(Atom::from).collect(); HTMLCollection::by_atomic_class_name(window, root, class_atoms) } pub fn by_atomic_class_name(window: &Window, root: &Node, classes: Vec) - -> Root { + -> DomRoot { #[derive(HeapSizeOf, JSTraceable)] struct ClassNameFilter { classes: Vec @@ -211,7 +211,7 @@ impl HTMLCollection { HTMLCollection::create(window, root, box filter) } - pub fn children(window: &Window, root: &Node) -> Root { + pub fn children(window: &Window, root: &Node) -> DomRoot { #[derive(HeapSizeOf, JSTraceable)] struct ElementChildFilter; impl CollectionFilter for ElementChildFilter { @@ -222,27 +222,27 @@ impl HTMLCollection { HTMLCollection::create(window, root, box ElementChildFilter) } - pub fn elements_iter_after<'a>(&'a self, after: &'a Node) -> impl Iterator> + 'a { + pub fn elements_iter_after<'a>(&'a self, after: &'a Node) -> impl Iterator> + 'a { // Iterate forwards from a node. after.following_nodes(&self.root) - .filter_map(Root::downcast) + .filter_map(DomRoot::downcast) .filter(move |element| self.filter.filter(&element, &self.root)) } - pub fn elements_iter<'a>(&'a self) -> impl Iterator> + 'a { + pub fn elements_iter<'a>(&'a self) -> impl Iterator> + 'a { // Iterate forwards from the root. self.elements_iter_after(&*self.root) } - pub fn elements_iter_before<'a>(&'a self, before: &'a Node) -> impl Iterator> + 'a { + pub fn elements_iter_before<'a>(&'a self, before: &'a Node) -> impl Iterator> + 'a { // Iterate backwards from a node. before.preceding_nodes(&self.root) - .filter_map(Root::downcast) + .filter_map(DomRoot::downcast) .filter(move |element| self.filter.filter(&element, &self.root)) } - pub fn root_node(&self) -> Root { - Root::from_ref(&self.root) + pub fn root_node(&self) -> DomRoot { + DomRoot::from_ref(&self.root) } } @@ -263,7 +263,7 @@ impl HTMLCollectionMethods for HTMLCollection { } // https://dom.spec.whatwg.org/#dom-htmlcollection-item - fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { self.validate_cache(); if let Some(element) = self.cached_cursor_element.get() { @@ -276,14 +276,14 @@ impl HTMLCollectionMethods for HTMLCollection { // The cursor is before the element we're looking for // Iterate forwards, starting at the cursor. let offset = index - (cached_index + 1); - let node: Root = Root::upcast(element); + let node: DomRoot = DomRoot::upcast(element); let mut iter = self.elements_iter_after(&node); self.set_cached_cursor(index, iter.nth(offset as usize)) } else { // The cursor is after the element we're looking for // Iterate backwards, starting at the cursor. let offset = cached_index - (index + 1); - let node: Root = Root::upcast(element); + let node: DomRoot = DomRoot::upcast(element); let mut iter = self.elements_iter_before(&node); self.set_cached_cursor(index, iter.nth(offset as usize)) } @@ -300,7 +300,7 @@ impl HTMLCollectionMethods for HTMLCollection { } // https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem - fn NamedItem(&self, key: DOMString) -> Option> { + fn NamedItem(&self, key: DOMString) -> Option> { // Step 1. if key.is_empty() { return None; @@ -314,12 +314,12 @@ impl HTMLCollectionMethods for HTMLCollection { } // https://dom.spec.whatwg.org/#dom-htmlcollection-item - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } // check-tidy: no specs after this line - fn NamedGetter(&self, name: DOMString) -> Option> { + fn NamedGetter(&self, name: DOMString) -> Option> { self.NamedItem(name) } diff --git a/servo/components/script/dom/htmldataelement.rs b/servo/components/script/dom/htmldataelement.rs index baf9c565b4d0..556fec894e28 100644 --- a/servo/components/script/dom/htmldataelement.rs +++ b/servo/components/script/dom/htmldataelement.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::HTMLDataElementBinding; use dom::bindings::codegen::Bindings::HTMLDataElementBinding::HTMLDataElementMethods; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::htmlelement::HTMLElement; @@ -29,7 +29,7 @@ impl HTMLDataElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLDataElement::new_inherited(local_name, prefix, document), document, HTMLDataElementBinding::Wrap) diff --git a/servo/components/script/dom/htmldatalistelement.rs b/servo/components/script/dom/htmldatalistelement.rs index c7ee6c60ff86..1e71ca7502b3 100644 --- a/servo/components/script/dom/htmldatalistelement.rs +++ b/servo/components/script/dom/htmldatalistelement.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataListElementBinding::HTMLDataListElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::element::Element; use dom::htmlcollection::{CollectionFilter, HTMLCollection}; @@ -33,7 +33,7 @@ impl HTMLDataListElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLDataListElement::new_inherited(local_name, prefix, document), document, HTMLDataListElementBinding::Wrap) @@ -42,7 +42,7 @@ impl HTMLDataListElement { impl HTMLDataListElementMethods for HTMLDataListElement { // https://html.spec.whatwg.org/multipage/#dom-datalist-options - fn Options(&self) -> Root { + fn Options(&self) -> DomRoot { #[derive(HeapSizeOf, JSTraceable)] struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOptionsFilter { diff --git a/servo/components/script/dom/htmldetailselement.rs b/servo/components/script/dom/htmldetailselement.rs index 72952da8310c..75780f83d86b 100644 --- a/servo/components/script/dom/htmldetailselement.rs +++ b/servo/components/script/dom/htmldetailselement.rs @@ -6,8 +6,8 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding; use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding::HTMLDetailsElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::element::AttributeMutation; use dom::eventtarget::EventTarget; @@ -39,7 +39,7 @@ impl HTMLDetailsElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLDetailsElement::new_inherited(local_name, prefix, document), document, HTMLDetailsElementBinding::Wrap) diff --git a/servo/components/script/dom/htmldialogelement.rs b/servo/components/script/dom/htmldialogelement.rs index 15bbdbfe99e2..39e195e08145 100644 --- a/servo/components/script/dom/htmldialogelement.rs +++ b/servo/components/script/dom/htmldialogelement.rs @@ -2,11 +2,11 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::HTMLDialogElementBinding; use dom::bindings::codegen::Bindings::HTMLDialogElementBinding::HTMLDialogElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::Element; @@ -19,7 +19,7 @@ use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLDialogElement { htmlelement: HTMLElement, - return_value: DOMRefCell, + return_value: DomRefCell, } impl HTMLDialogElement { @@ -29,14 +29,14 @@ impl HTMLDialogElement { HTMLDialogElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), - return_value: DOMRefCell::new(DOMString::new()), + return_value: DomRefCell::new(DOMString::new()), } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLDialogElement::new_inherited(local_name, prefix, document), document, HTMLDialogElementBinding::Wrap) diff --git a/servo/components/script/dom/htmldirectoryelement.rs b/servo/components/script/dom/htmldirectoryelement.rs index 67d1b567c52b..2ec56cb6415d 100644 --- a/servo/components/script/dom/htmldirectoryelement.rs +++ b/servo/components/script/dom/htmldirectoryelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLDirectoryElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLDirectoryElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLDirectoryElement::new_inherited(local_name, prefix, document), document, HTMLDirectoryElementBinding::Wrap) diff --git a/servo/components/script/dom/htmldivelement.rs b/servo/components/script/dom/htmldivelement.rs index 6e20b3796f5d..001ca7c5ca5e 100644 --- a/servo/components/script/dom/htmldivelement.rs +++ b/servo/components/script/dom/htmldivelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLDivElementBinding::{self, HTMLDivElementMethods}; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::htmlelement::HTMLElement; @@ -28,7 +28,7 @@ impl HTMLDivElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLDivElement::new_inherited(local_name, prefix, document), document, HTMLDivElementBinding::Wrap) diff --git a/servo/components/script/dom/htmldlistelement.rs b/servo/components/script/dom/htmldlistelement.rs index 796f104c240e..6622571c5c89 100644 --- a/servo/components/script/dom/htmldlistelement.rs +++ b/servo/components/script/dom/htmldlistelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLDListElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -26,7 +26,7 @@ impl HTMLDListElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLDListElement::new_inherited(local_name, prefix, document), document, HTMLDListElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlelement.rs b/servo/components/script/dom/htmlelement.rs index 1e87982aa540..9f671e2d10ce 100644 --- a/servo/components/script/dom/htmlelement.rs +++ b/servo/components/script/dom/htmlelement.rs @@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::inheritance::{ElementTypeId, HTMLElementTypeId, NodeTypeId}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner}; use dom::document::{Document, FocusType}; @@ -39,8 +39,8 @@ use style::element_state::*; #[dom_struct] pub struct HTMLElement { element: Element, - style_decl: MutNullableJS, - dataset: MutNullableJS, + style_decl: MutNullableDom, + dataset: MutNullableDom, } impl HTMLElement { @@ -61,7 +61,7 @@ impl HTMLElement { } #[allow(unrooted_must_root)] - pub fn new(local_name: LocalName, prefix: Option, document: &Document) -> Root { + pub fn new(local_name: LocalName, prefix: Option, document: &Document) -> DomRoot { Node::reflect_node(box HTMLElement::new_inherited(local_name, prefix, document), document, HTMLElementBinding::Wrap) @@ -111,11 +111,11 @@ impl HTMLElement { impl HTMLElementMethods for HTMLElement { // https://html.spec.whatwg.org/multipage/#the-style-attribute - fn Style(&self) -> Root { + fn Style(&self) -> DomRoot { self.style_decl.or_init(|| { let global = window_from_node(self); CSSStyleDeclaration::new(&global, - CSSStyleOwner::Element(JS::from_ref(self.upcast())), + CSSStyleOwner::Element(Dom::from_ref(self.upcast())), None, CSSModificationAccess::ReadWrite) }) @@ -143,7 +143,7 @@ impl HTMLElementMethods for HTMLElement { document_and_element_event_handlers!(); // https://html.spec.whatwg.org/multipage/#dom-dataset - fn Dataset(&self) -> Root { + fn Dataset(&self) -> DomRoot { self.dataset.or_init(|| DOMStringMap::new(self)) } @@ -313,7 +313,7 @@ impl HTMLElementMethods for HTMLElement { } // https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent - fn GetOffsetParent(&self) -> Option> { + fn GetOffsetParent(&self) -> Option> { if self.is::() || self.is::() { return None; } @@ -503,7 +503,7 @@ impl HTMLElement { } // https://html.spec.whatwg.org/multipage/#dom-lfe-labels - pub fn labels(&self) -> Root { + pub fn labels(&self) -> DomRoot { debug_assert!(self.is_labelable_element()); let element = self.upcast::(); @@ -514,14 +514,14 @@ impl HTMLElement { let ancestors = self.upcast::() .ancestors() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) // If we reach a labelable element, we have a guarantee no ancestors above it // will be a label for this HTMLElement .take_while(|elem| !elem.is_labelable_element()) - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .filter(|elem| !elem.upcast::().has_attribute(&local_name!("for"))) .filter(|elem| elem.first_labelable_descendant().r() == Some(self)) - .map(Root::upcast::); + .map(DomRoot::upcast::); let id = element.Id(); let id = match &id as &str { @@ -533,10 +533,10 @@ impl HTMLElement { let root_element = element.root_element(); let root_node = root_element.upcast::(); let children = root_node.traverse_preorder() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .filter(|elem| elem.is::()) .filter(|elem| elem.get_string_attribute(&local_name!("for")) == id) - .map(Root::upcast::); + .map(DomRoot::upcast::); NodeList::new_simple_list(&window, children.chain(ancestors)) } diff --git a/servo/components/script/dom/htmlembedelement.rs b/servo/components/script/dom/htmlembedelement.rs index 0b3c80b9beaa..daa011fcf6d9 100644 --- a/servo/components/script/dom/htmlembedelement.rs +++ b/servo/components/script/dom/htmlembedelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLEmbedElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -25,7 +25,7 @@ impl HTMLEmbedElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLEmbedElement::new_inherited(local_name, prefix, document), document, HTMLEmbedElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlfieldsetelement.rs b/servo/components/script/dom/htmlfieldsetelement.rs index e121a38032f4..89e1d2db481e 100644 --- a/servo/components/script/dom/htmlfieldsetelement.rs +++ b/servo/components/script/dom/htmlfieldsetelement.rs @@ -6,7 +6,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding; use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::document::Document; use dom::element::{AttributeMutation, Element}; use dom::htmlcollection::{CollectionFilter, HTMLCollection}; @@ -24,7 +24,7 @@ use style::element_state::*; #[dom_struct] pub struct HTMLFieldSetElement { htmlelement: HTMLElement, - form_owner: MutNullableJS, + form_owner: MutNullableDom, } impl HTMLFieldSetElement { @@ -42,7 +42,7 @@ impl HTMLFieldSetElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLFieldSetElement::new_inherited(local_name, prefix, document), document, HTMLFieldSetElementBinding::Wrap) @@ -51,7 +51,7 @@ impl HTMLFieldSetElement { impl HTMLFieldSetElementMethods for HTMLFieldSetElement { // https://html.spec.whatwg.org/multipage/#dom-fieldset-elements - fn Elements(&self) -> Root { + fn Elements(&self) -> DomRoot { #[derive(HeapSizeOf, JSTraceable)] struct ElementsFilter; impl CollectionFilter for ElementsFilter { @@ -66,7 +66,7 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement { } // https://html.spec.whatwg.org/multipage/#dom-cva-validity - fn Validity(&self) -> Root { + fn Validity(&self) -> DomRoot { let window = window_from_node(self); ValidityState::new(&window, self.upcast()) } @@ -78,7 +78,7 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement { make_bool_setter!(SetDisabled, "disabled"); // https://html.spec.whatwg.org/multipage/#dom-fae-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { self.form_owner() } } @@ -159,7 +159,7 @@ impl VirtualMethods for HTMLFieldSetElement { } impl FormControl for HTMLFieldSetElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } diff --git a/servo/components/script/dom/htmlfontelement.rs b/servo/components/script/dom/htmlfontelement.rs index b804d3273261..c5eee1971598 100644 --- a/servo/components/script/dom/htmlfontelement.rs +++ b/servo/components/script/dom/htmlfontelement.rs @@ -7,7 +7,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLFontElementBinding; use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, Root}; +use dom::bindings::root::{DomRoot, LayoutDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{Element, RawLayoutElementHelpers}; @@ -36,7 +36,7 @@ impl HTMLFontElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLFontElement::new_inherited(local_name, prefix, document), document, HTMLFontElementBinding::Wrap) @@ -96,7 +96,7 @@ pub trait HTMLFontElementLayoutHelpers { fn get_size(&self) -> Option; } -impl HTMLFontElementLayoutHelpers for LayoutJS { +impl HTMLFontElementLayoutHelpers for LayoutDom { #[allow(unsafe_code)] fn get_color(&self) -> Option { unsafe { diff --git a/servo/components/script/dom/htmlformcontrolscollection.rs b/servo/components/script/dom/htmlformcontrolscollection.rs index a90e2dd48eea..8b786d2cb357 100644 --- a/servo/components/script/dom/htmlformcontrolscollection.rs +++ b/servo/components/script/dom/htmlformcontrolscollection.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMetho use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding; use dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods; use dom::bindings::codegen::UnionTypes::RadioNodeListOrElement; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::element::Element; use dom::htmlcollection::{CollectionFilter, HTMLCollection}; @@ -30,7 +30,7 @@ impl HTMLFormControlsCollection { } pub fn new(window: &Window, root: &Node, filter: Box) - -> Root + -> DomRoot { reflect_dom_object(box HTMLFormControlsCollection::new_inherited(root, filter), window, @@ -64,8 +64,8 @@ impl HTMLFormControlsCollectionMethods for HTMLFormControlsCollection { Some(RadioNodeListOrElement::Element(elem)) } else { // Step 4-5 - let once = iter::once(Root::upcast::(elem)); - let list = once.chain(peekable.map(Root::upcast)); + let once = iter::once(DomRoot::upcast::(elem)); + let list = once.chain(peekable.map(DomRoot::upcast)); let global = self.global(); let window = global.as_window(); Some(RadioNodeListOrElement::RadioNodeList(RadioNodeList::new_simple_list(window, list))) @@ -90,7 +90,7 @@ impl HTMLFormControlsCollectionMethods for HTMLFormControlsCollection { // https://github.com/servo/servo/issues/5875 // // https://dom.spec.whatwg.org/#dom-htmlcollection-item - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.collection.IndexedGetter(index) } } diff --git a/servo/components/script/dom/htmlformelement.rs b/servo/components/script/dom/htmlformelement.rs index 9b63d1fca667..a61b7bf3e518 100755 --- a/servo/components/script/dom/htmlformelement.rs +++ b/servo/components/script/dom/htmlformelement.rs @@ -2,7 +2,7 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; @@ -13,9 +13,9 @@ use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMet use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; -use dom::bindings::js::{JS, OnceCellJS, Root, RootedReference}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{Dom, DomOnceCell, DomRoot, RootedReference}; use dom::bindings::str::DOMString; use dom::blob::Blob; use dom::document::Document; @@ -64,9 +64,9 @@ pub struct GenerationId(u32); pub struct HTMLFormElement { htmlelement: HTMLElement, marked_for_reset: Cell, - elements: OnceCellJS, + elements: DomOnceCell, generation_id: Cell, - controls: DOMRefCell>>, + controls: DomRefCell>>, } impl HTMLFormElement { @@ -78,14 +78,14 @@ impl HTMLFormElement { marked_for_reset: Cell::new(false), elements: Default::default(), generation_id: Cell::new(GenerationId(0)), - controls: DOMRefCell::new(Vec::new()), + controls: DomRefCell::new(Vec::new()), } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLFormElement::new_inherited(local_name, prefix, document), document, HTMLFormElementBinding::Wrap) @@ -165,10 +165,10 @@ impl HTMLFormElementMethods for HTMLFormElement { } // https://html.spec.whatwg.org/multipage/#dom-form-elements - fn Elements(&self) -> Root { + fn Elements(&self) -> DomRoot { #[derive(HeapSizeOf, JSTraceable)] struct ElementsFilter { - form: Root + form: DomRoot } impl CollectionFilter for ElementsFilter { fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool { @@ -216,8 +216,8 @@ impl HTMLFormElementMethods for HTMLFormElement { } } } - Root::from_ref(self.elements.init_once(|| { - let filter = box ElementsFilter { form: Root::from_ref(self) }; + DomRoot::from_ref(self.elements.init_once(|| { + let filter = box ElementsFilter { form: DomRoot::from_ref(self) }; let window = window_from_node(self); HTMLFormControlsCollection::new(&window, self.upcast(), filter) })) @@ -229,7 +229,7 @@ impl HTMLFormElementMethods for HTMLFormElement { } // https://html.spec.whatwg.org/multipage/#dom-form-item - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { let elements = self.Elements(); elements.IndexedGetter(index) } @@ -520,7 +520,7 @@ impl HTMLFormElement { // Step 3.1: The field element has a datalist element ancestor. if child.ancestors() - .any(|a| Root::downcast::(a).is_some()) { + .any(|a| DomRoot::downcast::(a).is_some()) { continue; } if let NodeTypeId::Element(ElementTypeId::HTMLElement(element)) = child.type_id() { @@ -677,7 +677,7 @@ impl HTMLFormElement { #[derive(Clone, HeapSizeOf, JSTraceable)] pub enum FormDatumValue { #[allow(dead_code)] - File(Root), + File(DomRoot), String(DOMString) } @@ -718,13 +718,13 @@ pub enum FormMethod { #[derive(HeapSizeOf)] #[allow(dead_code)] pub enum FormSubmittableElement { - ButtonElement(Root), - InputElement(Root), + ButtonElement(DomRoot), + InputElement(DomRoot), // TODO: HTMLKeygenElement unimplemented // KeygenElement(&'a HTMLKeygenElement), - ObjectElement(Root), - SelectElement(Root), - TextAreaElement(Root), + ObjectElement(DomRoot), + SelectElement(DomRoot), + TextAreaElement(DomRoot), } impl FormSubmittableElement { @@ -740,19 +740,19 @@ impl FormSubmittableElement { fn from_element(element: &Element) -> FormSubmittableElement { if let Some(input) = element.downcast::() { - FormSubmittableElement::InputElement(Root::from_ref(&input)) + FormSubmittableElement::InputElement(DomRoot::from_ref(&input)) } else if let Some(input) = element.downcast::() { - FormSubmittableElement::ButtonElement(Root::from_ref(&input)) + FormSubmittableElement::ButtonElement(DomRoot::from_ref(&input)) } else if let Some(input) = element.downcast::() { - FormSubmittableElement::ObjectElement(Root::from_ref(&input)) + FormSubmittableElement::ObjectElement(DomRoot::from_ref(&input)) } else if let Some(input) = element.downcast::() { - FormSubmittableElement::SelectElement(Root::from_ref(&input)) + FormSubmittableElement::SelectElement(DomRoot::from_ref(&input)) } else if let Some(input) = element.downcast::() { - FormSubmittableElement::TextAreaElement(Root::from_ref(&input)) + FormSubmittableElement::TextAreaElement(DomRoot::from_ref(&input)) } else { unreachable!() } @@ -862,7 +862,7 @@ impl<'a> FormSubmitter<'a> { } pub trait FormControl: DomObject { - fn form_owner(&self) -> Option>; + fn form_owner(&self) -> Option>; fn set_form_owner(&self, form: Option<&HTMLFormElement>); @@ -891,7 +891,7 @@ pub trait FormControl: DomObject { let old_owner = self.form_owner(); let has_form_id = elem.has_attribute(&local_name!("form")); let nearest_form_ancestor = node.ancestors() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .next(); // Step 1 @@ -905,7 +905,7 @@ pub trait FormControl: DomObject { // Step 3 let doc = document_from_node(node); let form_id = elem.get_string_attribute(&local_name!("form")); - doc.GetElementById(form_id).and_then(Root::downcast::) + doc.GetElementById(form_id).and_then(DomRoot::downcast::) } else { // Step 4 nearest_form_ancestor diff --git a/servo/components/script/dom/htmlframeelement.rs b/servo/components/script/dom/htmlframeelement.rs index 68cd8f8a4059..147e05a836eb 100644 --- a/servo/components/script/dom/htmlframeelement.rs +++ b/servo/components/script/dom/htmlframeelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLFrameElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -25,7 +25,7 @@ impl HTMLFrameElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLFrameElement::new_inherited(local_name, prefix, document), document, HTMLFrameElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlframesetelement.rs b/servo/components/script/dom/htmlframesetelement.rs index 56195bd57adb..99b58deea3d3 100644 --- a/servo/components/script/dom/htmlframesetelement.rs +++ b/servo/components/script/dom/htmlframesetelement.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding; use dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding::HTMLFrameSetElementMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::{Node, document_from_node}; @@ -30,7 +30,7 @@ impl HTMLFrameSetElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLFrameSetElement::new_inherited(local_name, prefix, document), document, HTMLFrameSetElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlheadelement.rs b/servo/components/script/dom/htmlheadelement.rs index 5c14f110c8f7..1aaf0a799b59 100644 --- a/servo/components/script/dom/htmlheadelement.rs +++ b/servo/components/script/dom/htmlheadelement.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::HTMLHeadElementBinding; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{Root, RootedReference}; +use dom::bindings::root::{DomRoot, RootedReference}; use dom::document::{Document, determine_policy_for_token}; use dom::element::Element; use dom::htmlelement::HTMLElement; @@ -33,7 +33,7 @@ impl HTMLHeadElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLHeadElement::new_inherited(local_name, prefix, document), document, HTMLHeadElementBinding::Wrap) @@ -49,7 +49,7 @@ impl HTMLHeadElement { let node = self.upcast::(); let candidates = node.traverse_preorder() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .filter(|elem| elem.is::()) .filter(|elem| elem.get_string_attribute(&local_name!("name")) == "referrer") .filter(|elem| elem.get_attribute(&ns!(), &local_name!("content")).is_some()); diff --git a/servo/components/script/dom/htmlheadingelement.rs b/servo/components/script/dom/htmlheadingelement.rs index e9cba94c2df5..44223863dd48 100644 --- a/servo/components/script/dom/htmlheadingelement.rs +++ b/servo/components/script/dom/htmlheadingelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLHeadingElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -42,7 +42,7 @@ impl HTMLHeadingElement { pub fn new(local_name: LocalName, prefix: Option, document: &Document, - level: HeadingLevel) -> Root { + level: HeadingLevel) -> DomRoot { Node::reflect_node(box HTMLHeadingElement::new_inherited(local_name, prefix, document, level), document, HTMLHeadingElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlhrelement.rs b/servo/components/script/dom/htmlhrelement.rs index 85b160bb8482..e4769ed72024 100644 --- a/servo/components/script/dom/htmlhrelement.rs +++ b/servo/components/script/dom/htmlhrelement.rs @@ -5,7 +5,7 @@ use cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLHRElementBinding::{self, HTMLHRElementMethods}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, Root}; +use dom::bindings::root::{DomRoot, LayoutDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{Element, RawLayoutElementHelpers}; @@ -31,7 +31,7 @@ impl HTMLHRElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLHRElement::new_inherited(local_name, prefix, document), document, HTMLHRElementBinding::Wrap) @@ -63,7 +63,7 @@ pub trait HTMLHRLayoutHelpers { fn get_width(&self) -> LengthOrPercentageOrAuto; } -impl HTMLHRLayoutHelpers for LayoutJS { +impl HTMLHRLayoutHelpers for LayoutDom { #[allow(unsafe_code)] fn get_color(&self) -> Option { unsafe { diff --git a/servo/components/script/dom/htmlhtmlelement.rs b/servo/components/script/dom/htmlhtmlelement.rs index 47aa909035da..b112e304c09c 100644 --- a/servo/components/script/dom/htmlhtmlelement.rs +++ b/servo/components/script/dom/htmlhtmlelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLHtmlElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -25,7 +25,7 @@ impl HTMLHtmlElement { #[allow(unrooted_must_root)] pub fn new(localName: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLHtmlElement::new_inherited(localName, prefix, document), document, HTMLHtmlElementBinding::Wrap) diff --git a/servo/components/script/dom/htmliframeelement.rs b/servo/components/script/dom/htmliframeelement.rs index 7f0b82fa2391..8cc7ca9977bc 100644 --- a/servo/components/script/dom/htmliframeelement.rs +++ b/servo/components/script/dom/htmliframeelement.rs @@ -4,7 +4,7 @@ use document_loader::{LoadBlocker, LoadType}; use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementErrorEventDetail; use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementIconChangeEventDetail; use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementLocationChangeEventDetail; @@ -19,9 +19,9 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethod use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{LayoutDom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::customevent::CustomEvent; use dom::document::Document; @@ -88,9 +88,9 @@ pub struct HTMLIFrameElement { browsing_context_id: Cell>, pipeline_id: Cell>, pending_pipeline_id: Cell>, - sandbox: MutNullableJS, + sandbox: MutNullableDom, sandbox_allowance: Cell>, - load_blocker: DOMRefCell>, + load_blocker: DomRefCell>, visibility: Cell, } @@ -329,7 +329,7 @@ impl HTMLIFrameElement { pending_pipeline_id: Cell::new(None), sandbox: Default::default(), sandbox_allowance: Cell::new(None), - load_blocker: DOMRefCell::new(None), + load_blocker: DomRefCell::new(None), visibility: Cell::new(true), } } @@ -337,7 +337,7 @@ impl HTMLIFrameElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLIFrameElement::new_inherited(local_name, prefix, document), document, HTMLIFrameElementBinding::Wrap) @@ -419,7 +419,7 @@ pub trait HTMLIFrameElementLayoutMethods { fn get_height(&self) -> LengthOrPercentageOrAuto; } -impl HTMLIFrameElementLayoutMethods for LayoutJS { +impl HTMLIFrameElementLayoutMethods for LayoutDom { #[inline] #[allow(unsafe_code)] fn pipeline_id(&self) -> Option { @@ -461,7 +461,7 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS { } #[allow(unsafe_code)] -pub fn build_mozbrowser_custom_event(window: &Window, event: MozBrowserEvent) -> Root { +pub fn build_mozbrowser_custom_event(window: &Window, event: MozBrowserEvent) -> DomRoot { // TODO(gw): Support mozbrowser event types that have detail which is not a string. // See https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API // for a list of mozbrowser events. @@ -583,19 +583,19 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { } // https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox - fn Sandbox(&self) -> Root { + fn Sandbox(&self) -> DomRoot { self.sandbox.or_init(|| DOMTokenList::new(self.upcast::(), &local_name!("sandbox"))) } // https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow - fn GetContentWindow(&self) -> Option> { + fn GetContentWindow(&self) -> Option> { self.browsing_context_id.get() .and_then(|browsing_context_id| ScriptThread::find_window_proxy(browsing_context_id)) } // https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument // https://html.spec.whatwg.org/multipage/#concept-bcc-content-document - fn GetContentDocument(&self) -> Option> { + fn GetContentDocument(&self) -> Option> { // Step 1. let pipeline_id = match self.pipeline_id.get() { None => return None, diff --git a/servo/components/script/dom/htmlimageelement.rs b/servo/components/script/dom/htmlimageelement.rs index 49db07a3242c..7c2255d6696a 100644 --- a/servo/components/script/dom/htmlimageelement.rs +++ b/servo/components/script/dom/htmlimageelement.rs @@ -6,7 +6,7 @@ use app_units::{Au, AU_PER_PX}; use document_loader::{LoadType, LoadBlocker}; use dom::activation::Activatable; use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectBinding::DOMRectMethods; use dom::bindings::codegen::Bindings::ElementBinding::ElementBinding::ElementMethods; use dom::bindings::codegen::Bindings::HTMLImageElementBinding; @@ -15,9 +15,9 @@ use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; @@ -87,9 +87,9 @@ struct ImageRequest { pub struct HTMLImageElement { htmlelement: HTMLElement, image_request: Cell, - current_request: DOMRefCell, - pending_request: DOMRefCell, - form_owner: MutNullableJS, + current_request: DomRefCell, + pending_request: DomRefCell, + form_owner: MutNullableDom, generation: Cell, } @@ -569,7 +569,7 @@ impl HTMLImageElement { // step 6, await a stable state. self.generation.set(self.generation.get() + 1); let task = ImageElementMicrotask::StableStateUpdateImageDataTask { - elem: Root::from_ref(self), + elem: DomRoot::from_ref(self), generation: self.generation.get(), }; ScriptThread::await_stable_state(Microtask::ImageElement(task)); @@ -579,7 +579,7 @@ impl HTMLImageElement { HTMLImageElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), image_request: Cell::new(ImageRequestPhase::Current), - current_request: DOMRefCell::new(ImageRequest { + current_request: DomRefCell::new(ImageRequest { state: State::Unavailable, parsed_url: None, source_url: None, @@ -588,7 +588,7 @@ impl HTMLImageElement { blocker: None, final_url: None, }), - pending_request: DOMRefCell::new(ImageRequest { + pending_request: DomRefCell::new(ImageRequest { state: State::Unavailable, parsed_url: None, source_url: None, @@ -605,7 +605,7 @@ impl HTMLImageElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLImageElement::new_inherited(local_name, prefix, document), document, HTMLImageElementBinding::Wrap) @@ -613,7 +613,7 @@ impl HTMLImageElement { pub fn Image(window: &Window, width: Option, - height: Option) -> Fallible> { + height: Option) -> Fallible> { let document = window.Document(); let image = HTMLImageElement::new(local_name!("img"), None, &document); if let Some(w) = width { @@ -625,7 +625,7 @@ impl HTMLImageElement { Ok(image) } - pub fn areas(&self) -> Option>> { + pub fn areas(&self) -> Option>> { let elem = self.upcast::(); let usemap_attr = match elem.get_attribute(&ns!(), &local_name!("usemap")) { Some(attr) => attr, @@ -646,7 +646,7 @@ impl HTMLImageElement { let useMapElements = document_from_node(self).upcast::() .traverse_preorder() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .find(|n| n.upcast::().get_string_attribute(&LocalName::from("name")) == last); useMapElements.map(|mapElem| mapElem.get_area_elements()) @@ -664,7 +664,7 @@ impl HTMLImageElement { #[derive(HeapSizeOf, JSTraceable)] pub enum ImageElementMicrotask { StableStateUpdateImageDataTask { - elem: Root, + elem: DomRoot, generation: u32, } } @@ -694,7 +694,7 @@ pub trait LayoutHTMLImageElementHelpers { fn get_height(&self) -> LengthOrPercentageOrAuto; } -impl LayoutHTMLImageElementHelpers for LayoutJS { +impl LayoutHTMLImageElementHelpers for LayoutDom { #[allow(unsafe_code)] unsafe fn image(&self) -> Option> { (*self.unsafe_get()).current_request.borrow_for_layout().image.clone() @@ -937,7 +937,7 @@ impl VirtualMethods for HTMLImageElement { } impl FormControl for HTMLImageElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } diff --git a/servo/components/script/dom/htmlinputelement.rs b/servo/components/script/dom/htmlinputelement.rs index 26597f5a1003..ce76eb8ced5d 100755 --- a/servo/components/script/dom/htmlinputelement.rs +++ b/servo/components/script/dom/htmlinputelement.rs @@ -5,7 +5,7 @@ use caseless::compatibility_caseless_match_str; use dom::activation::{Activatable, ActivationSource, synthetic_click_activation}; use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods; use dom::bindings::codegen::Bindings::HTMLInputElementBinding; @@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, MutNullableJS, Root, RootedReference}; +use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, LayoutElementHelpers, RawLayoutElementHelpers}; @@ -88,19 +88,19 @@ pub struct HTMLInputElement { htmlelement: HTMLElement, input_type: Cell, checked_changed: Cell, - placeholder: DOMRefCell, + placeholder: DomRefCell, value_changed: Cell, size: Cell, maxlength: Cell, minlength: Cell, #[ignore_heap_size_of = "#7193"] - textinput: DOMRefCell>, - activation_state: DOMRefCell, + textinput: DomRefCell>, + activation_state: DomRefCell, // https://html.spec.whatwg.org/multipage/#concept-input-value-dirty-flag value_dirty: Cell, - filelist: MutNullableJS, - form_owner: MutNullableJS, + filelist: MutNullableDom, + form_owner: MutNullableDom, } #[derive(JSTraceable)] @@ -110,7 +110,7 @@ struct InputActivationState { indeterminate: bool, checked: bool, checked_changed: bool, - checked_radio: Option>, + checked_radio: Option>, // In case mutability changed was_mutable: bool, // In case the type changed @@ -142,21 +142,21 @@ impl HTMLInputElement { HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE, local_name, prefix, document), input_type: Cell::new(InputType::InputText), - placeholder: DOMRefCell::new(DOMString::new()), + placeholder: DomRefCell::new(DOMString::new()), checked_changed: Cell::new(false), value_changed: Cell::new(false), maxlength: Cell::new(DEFAULT_MAX_LENGTH), minlength: Cell::new(DEFAULT_MIN_LENGTH), size: Cell::new(DEFAULT_INPUT_SIZE), - textinput: DOMRefCell::new(TextInput::new(Single, + textinput: DomRefCell::new(TextInput::new(Single, DOMString::new(), chan, None, None, SelectionDirection::None)), - activation_state: DOMRefCell::new(InputActivationState::new()), + activation_state: DomRefCell::new(InputActivationState::new()), value_dirty: Cell::new(false), - filelist: MutNullableJS::new(None), + filelist: MutNullableDom::new(None), form_owner: Default::default(), } } @@ -164,7 +164,7 @@ impl HTMLInputElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLInputElement::new_inherited(local_name, prefix, document), document, HTMLInputElementBinding::Wrap) @@ -206,15 +206,15 @@ pub trait LayoutHTMLInputElementHelpers { } #[allow(unsafe_code)] -unsafe fn get_raw_textinput_value(input: LayoutJS) -> DOMString { +unsafe fn get_raw_textinput_value(input: LayoutDom) -> DOMString { (*input.unsafe_get()).textinput.borrow_for_layout().get_content() } -impl LayoutHTMLInputElementHelpers for LayoutJS { +impl LayoutHTMLInputElementHelpers for LayoutDom { #[allow(unsafe_code)] unsafe fn value_for_layout(self) -> String { #[allow(unsafe_code)] - unsafe fn get_raw_attr_value(input: LayoutJS, default: &str) -> String { + unsafe fn get_raw_attr_value(input: LayoutDom, default: &str) -> String { let elem = input.upcast::(); let value = (*elem.unsafe_get()) .get_attr_val_for_layout(&ns!(), &local_name!("value")) @@ -318,12 +318,12 @@ impl HTMLInputElementMethods for HTMLInputElement { make_bool_setter!(SetDisabled, "disabled"); // https://html.spec.whatwg.org/multipage/#dom-fae-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { self.form_owner() } // https://html.spec.whatwg.org/multipage/#dom-input-files - fn GetFiles(&self) -> Option> { + fn GetFiles(&self) -> Option> { match self.filelist.get() { Some(ref fl) => Some(fl.clone()), None => None, @@ -549,7 +549,7 @@ impl HTMLInputElementMethods for HTMLInputElement { } // https://html.spec.whatwg.org/multipage/#dom-lfe-labels - fn Labels(&self) -> Root { + fn Labels(&self) -> DomRoot { if self.type_() == atom!("hidden") { let window = window_from_node(self); NodeList::empty(&window) @@ -638,7 +638,7 @@ fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&Atom>) fn do_broadcast(doc_node: &Node, broadcaster: &HTMLInputElement, owner: Option<&HTMLFormElement>, group: Option<&Atom>) { let iter = doc_node.query_selector_iter(DOMString::from("input[type=radio]")).unwrap() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .filter(|r| in_same_group(&r, owner, group) && broadcaster != &**r); for ref r in iter { if r.Checked() { @@ -705,7 +705,7 @@ impl HTMLInputElement { datums.push(FormDatum { ty: type_.clone(), name: name.clone(), - value: FormDatumValue::File(Root::from_ref(&f)), + value: FormDatumValue::File(DomRoot::from_ref(&f)), }); } } @@ -805,7 +805,7 @@ impl HTMLInputElement { let origin = get_blob_origin(&window.get_url()); let resource_threads = window.upcast::().resource_threads(); - let mut files: Vec> = vec![]; + let mut files: Vec> = vec![]; let mut error = None; let filter = filter_from_accept(&self.Accept()); @@ -1169,7 +1169,7 @@ impl VirtualMethods for HTMLInputElement { } impl FormControl for HTMLInputElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } @@ -1246,12 +1246,12 @@ impl Activatable for HTMLInputElement { // Safe since we only manipulate the DOM tree after finding an element let checked_member = doc_node.query_selector_iter(DOMString::from("input[type=radio]")) .unwrap() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .find(|r| { in_same_group(&*r, owner.r(), group.as_ref()) && r.Checked() }); - cache.checked_radio = checked_member.r().map(JS::from_ref); + cache.checked_radio = checked_member.r().map(Dom::from_ref); cache.checked_changed = self.checked_changed.get(); self.SetChecked(true); } @@ -1361,7 +1361,7 @@ impl Activatable for HTMLInputElement { } let submit_button; submit_button = node.query_selector_iter(DOMString::from("input[type=submit]")).unwrap() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .find(|r| r.form_owner() == owner); match submit_button { Some(ref button) => { @@ -1376,7 +1376,7 @@ impl Activatable for HTMLInputElement { } None => { let inputs = node.query_selector_iter(DOMString::from("input")).unwrap() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .filter(|input| { input.form_owner() == owner && match input.type_() { atom!("text") | atom!("search") | atom!("url") | atom!("tel") | diff --git a/servo/components/script/dom/htmllabelelement.rs b/servo/components/script/dom/htmllabelelement.rs index cd5044fe4ed0..09397059eabc 100644 --- a/servo/components/script/dom/htmllabelelement.rs +++ b/servo/components/script/dom/htmllabelelement.rs @@ -7,7 +7,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLLabelElementBinding; use dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element}; @@ -39,7 +39,7 @@ impl HTMLLabelElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLLabelElement::new_inherited(local_name, prefix, document), document, HTMLLabelElementBinding::Wrap) @@ -88,7 +88,7 @@ impl Activatable for HTMLLabelElement { impl HTMLLabelElementMethods for HTMLLabelElement { // https://html.spec.whatwg.org/multipage/#dom-fae-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { self.form_owner() } @@ -99,7 +99,7 @@ impl HTMLLabelElementMethods for HTMLLabelElement { make_atomic_setter!(SetHtmlFor, "for"); // https://html.spec.whatwg.org/multipage/#dom-label-control - fn GetControl(&self) -> Option> { + fn GetControl(&self) -> Option> { if !self.upcast::().is_in_doc() { return None; } @@ -111,7 +111,7 @@ impl HTMLLabelElementMethods for HTMLLabelElement { let for_value = for_attr.value(); document_from_node(self).get_element_by_id(for_value.as_atom()) - .and_then(Root::downcast::) + .and_then(DomRoot::downcast::) .into_iter() .filter(|e| e.is_labelable_element()) .next() @@ -142,18 +142,18 @@ impl VirtualMethods for HTMLLabelElement { } impl HTMLLabelElement { - pub fn first_labelable_descendant(&self) -> Option> { + pub fn first_labelable_descendant(&self) -> Option> { self.upcast::() .traverse_preorder() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .filter(|elem| elem.is_labelable_element()) .next() } } impl FormControl for HTMLLabelElement { - fn form_owner(&self) -> Option> { - self.GetControl().map(Root::upcast::).and_then(|elem| { + fn form_owner(&self) -> Option> { + self.GetControl().map(DomRoot::upcast::).and_then(|elem| { elem.as_maybe_form_control().and_then(|control| control.form_owner()) }) } diff --git a/servo/components/script/dom/htmllegendelement.rs b/servo/components/script/dom/htmllegendelement.rs index d527df711ef2..c54b25f61182 100644 --- a/servo/components/script/dom/htmllegendelement.rs +++ b/servo/components/script/dom/htmllegendelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::HTMLLegendElementBinding; use dom::bindings::codegen::Bindings::HTMLLegendElementBinding::HTMLLegendElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::document::Document; use dom::element::Element; use dom::htmlelement::HTMLElement; @@ -20,7 +20,7 @@ use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLLegendElement { htmlelement: HTMLElement, - form_owner: MutNullableJS, + form_owner: MutNullableDom, } impl HTMLLegendElement { @@ -38,7 +38,7 @@ impl HTMLLegendElement { pub fn new(local_name: LocalName, prefix: Option, document: &Document) - -> Root { + -> DomRoot { Node::reflect_node(box HTMLLegendElement::new_inherited(local_name, prefix, document), document, HTMLLegendElementBinding::Wrap) @@ -74,7 +74,7 @@ impl VirtualMethods for HTMLLegendElement { impl HTMLLegendElementMethods for HTMLLegendElement { // https://html.spec.whatwg.org/multipage/#dom-legend-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { let parent = match self.upcast::().GetParentElement() { Some(parent) => parent, None => return None, @@ -87,7 +87,7 @@ impl HTMLLegendElementMethods for HTMLLegendElement { } impl FormControl for HTMLLegendElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } diff --git a/servo/components/script/dom/htmllielement.rs b/servo/components/script/dom/htmllielement.rs index 9d949764a61e..da98a3d1be29 100644 --- a/servo/components/script/dom/htmllielement.rs +++ b/servo/components/script/dom/htmllielement.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::HTMLLIElementBinding; use dom::bindings::codegen::Bindings::HTMLLIElementBinding::HTMLLIElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::htmlelement::HTMLElement; @@ -30,7 +30,7 @@ impl HTMLLIElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLLIElement::new_inherited(local_name, prefix, document), document, HTMLLIElementBinding::Wrap) diff --git a/servo/components/script/dom/htmllinkelement.rs b/servo/components/script/dom/htmllinkelement.rs index f1a8242b3453..320b425331b2 100644 --- a/servo/components/script/dom/htmllinkelement.rs +++ b/servo/components/script/dom/htmllinkelement.rs @@ -4,12 +4,12 @@ use cssparser::{Parser as CssParser, ParserInput}; use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListBinding::DOMTokenListMethods; use dom::bindings::codegen::Bindings::HTMLLinkElementBinding; use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root, RootedReference}; +use dom::bindings::root::{DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::cssstylesheet::CSSStyleSheet; use dom::document::Document; @@ -50,10 +50,10 @@ impl RequestGenerationId { #[dom_struct] pub struct HTMLLinkElement { htmlelement: HTMLElement, - rel_list: MutNullableJS, + rel_list: MutNullableDom, #[ignore_heap_size_of = "Arc"] - stylesheet: DOMRefCell>>, - cssom_stylesheet: MutNullableJS, + stylesheet: DomRefCell>>, + cssom_stylesheet: MutNullableDom, /// https://html.spec.whatwg.org/multipage/#a-style-sheet-that-is-blocking-scripts parser_inserted: Cell, @@ -73,8 +73,8 @@ impl HTMLLinkElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), rel_list: Default::default(), parser_inserted: Cell::new(creator.is_parser_created()), - stylesheet: DOMRefCell::new(None), - cssom_stylesheet: MutNullableJS::new(None), + stylesheet: DomRefCell::new(None), + cssom_stylesheet: MutNullableDom::new(None), pending_loads: Cell::new(0), any_failed_load: Cell::new(false), request_generation_id: Cell::new(RequestGenerationId(0)), @@ -85,7 +85,7 @@ impl HTMLLinkElement { pub fn new(local_name: LocalName, prefix: Option, document: &Document, - creator: ElementCreator) -> Root { + creator: ElementCreator) -> DomRoot { Node::reflect_node(box HTMLLinkElement::new_inherited(local_name, prefix, document, creator), document, HTMLLinkElementBinding::Wrap) @@ -111,7 +111,7 @@ impl HTMLLinkElement { self.stylesheet.borrow().clone() } - pub fn get_cssom_stylesheet(&self) -> Option> { + pub fn get_cssom_stylesheet(&self) -> Option> { self.get_stylesheet().map(|sheet| { self.cssom_stylesheet.or_init(|| { CSSStyleSheet::new(&window_from_node(self), @@ -408,7 +408,7 @@ impl HTMLLinkElementMethods for HTMLLinkElement { make_setter!(SetType, "type"); // https://html.spec.whatwg.org/multipage/#dom-link-rellist - fn RelList(&self) -> Root { + fn RelList(&self) -> DomRoot { self.rel_list.or_init(|| DOMTokenList::new(self.upcast(), &local_name!("rel"))) } @@ -441,7 +441,7 @@ impl HTMLLinkElementMethods for HTMLLinkElement { } // https://drafts.csswg.org/cssom/#dom-linkstyle-sheet - fn GetSheet(&self) -> Option> { - self.get_cssom_stylesheet().map(Root::upcast) + fn GetSheet(&self) -> Option> { + self.get_cssom_stylesheet().map(DomRoot::upcast) } } diff --git a/servo/components/script/dom/htmlmapelement.rs b/servo/components/script/dom/htmlmapelement.rs index e3ec4dc42ebd..82afa2c121fe 100644 --- a/servo/components/script/dom/htmlmapelement.rs +++ b/servo/components/script/dom/htmlmapelement.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::HTMLMapElementBinding; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlareaelement::HTMLAreaElement; use dom::htmlelement::HTMLElement; @@ -29,15 +29,15 @@ impl HTMLMapElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLMapElement::new_inherited(local_name, prefix, document), document, HTMLMapElementBinding::Wrap) } - pub fn get_area_elements(&self) -> Vec> { + pub fn get_area_elements(&self) -> Vec> { self.upcast::() .traverse_preorder() - .filter_map(Root::downcast::).collect() + .filter_map(DomRoot::downcast::).collect() } } diff --git a/servo/components/script/dom/htmlmediaelement.rs b/servo/components/script/dom/htmlmediaelement.rs index 90efb26e1f31..7d976a9d899a 100644 --- a/servo/components/script/dom/htmlmediaelement.rs +++ b/servo/components/script/dom/htmlmediaelement.rs @@ -5,7 +5,7 @@ use audio_video_metadata; use document_loader::{LoadBlocker, LoadType}; use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::CanPlayTypeResult; use dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementConstants; @@ -16,9 +16,9 @@ use dom::bindings::codegen::InheritTypes::{ElementTypeId, HTMLElementTypeId}; use dom::bindings::codegen::InheritTypes::{HTMLMediaElementTypeId, NodeTypeId}; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{Element, AttributeMutation}; @@ -58,7 +58,7 @@ pub struct HTMLMediaElement { /// https://html.spec.whatwg.org/multipage/#dom-media-readystate ready_state: Cell, /// https://html.spec.whatwg.org/multipage/#dom-media-currentsrc - current_src: DOMRefCell, + current_src: DomRefCell, /// Incremented whenever tasks associated with this element are cancelled. generation_id: Cell, /// https://html.spec.whatwg.org/multipage/#fire-loadeddata @@ -66,22 +66,22 @@ pub struct HTMLMediaElement { /// Reset to false every time the load algorithm is invoked. fired_loadeddata_event: Cell, /// https://html.spec.whatwg.org/multipage/#dom-media-error - error: MutNullableJS, + error: MutNullableDom, /// https://html.spec.whatwg.org/multipage/#dom-media-paused paused: Cell, /// https://html.spec.whatwg.org/multipage/#attr-media-autoplay autoplaying: Cell, /// https://html.spec.whatwg.org/multipage/#delaying-the-load-event-flag - delaying_the_load_event_flag: DOMRefCell>, + delaying_the_load_event_flag: DomRefCell>, /// https://html.spec.whatwg.org/multipage/#list-of-pending-play-promises #[ignore_heap_size_of = "promises are hard"] - pending_play_promises: DOMRefCell>>, + pending_play_promises: DomRefCell>>, /// Play promises which are soon to be fulfilled by a queued task. #[ignore_heap_size_of = "promises are hard"] - in_flight_play_promises_queue: DOMRefCell]>, ErrorResult)>>, + in_flight_play_promises_queue: DomRefCell]>, ErrorResult)>>, /// The details of the video currently related to this media element. // FIXME(nox): Why isn't this in HTMLVideoElement? - video: DOMRefCell>, + video: DomRefCell>, } /// https://html.spec.whatwg.org/multipage/#dom-media-networkstate @@ -126,7 +126,7 @@ impl HTMLMediaElement { htmlelement: HTMLElement::new_inherited(tag_name, prefix, document), network_state: Cell::new(NetworkState::Empty), ready_state: Cell::new(ReadyState::HaveNothing), - current_src: DOMRefCell::new("".to_owned()), + current_src: DomRefCell::new("".to_owned()), generation_id: Cell::new(0), fired_loadeddata_event: Cell::new(false), error: Default::default(), @@ -136,7 +136,7 @@ impl HTMLMediaElement { delaying_the_load_event_flag: Default::default(), pending_play_promises: Default::default(), in_flight_play_promises_queue: Default::default(), - video: DOMRefCell::new(None), + video: DomRefCell::new(None), } } @@ -444,7 +444,7 @@ impl HTMLMediaElement { // right here. let doc = document_from_node(self); let task = MediaElementMicrotask::ResourceSelectionTask { - elem: Root::from_ref(self), + elem: DomRoot::from_ref(self), base_url: doc.base_url() }; @@ -466,7 +466,7 @@ impl HTMLMediaElement { #[allow(dead_code)] Object, Attribute(String), - Children(Root), + Children(DomRoot), } fn mode(media: &HTMLMediaElement) -> Option { if let Some(attr) = media.upcast::().get_attribute(&ns!(), &local_name!("src")) { @@ -474,7 +474,7 @@ impl HTMLMediaElement { } let source_child_element = media.upcast::() .children() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .next(); if let Some(element) = source_child_element { return Some(Mode::Children(element)); @@ -880,7 +880,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement { } // https://html.spec.whatwg.org/multipage/#dom-media-error - fn GetError(&self) -> Option> { + fn GetError(&self) -> Option> { self.error.get() } @@ -933,7 +933,7 @@ impl VirtualMethods for HTMLMediaElement { if context.tree_in_doc { let task = MediaElementMicrotask::PauseIfNotInDocumentTask { - elem: Root::from_ref(self) + elem: DomRoot::from_ref(self) }; ScriptThread::await_stable_state(Microtask::MediaElement(task)); } @@ -943,11 +943,11 @@ impl VirtualMethods for HTMLMediaElement { #[derive(HeapSizeOf, JSTraceable)] pub enum MediaElementMicrotask { ResourceSelectionTask { - elem: Root, + elem: DomRoot, base_url: ServoUrl }, PauseIfNotInDocumentTask { - elem: Root, + elem: DomRoot, } } diff --git a/servo/components/script/dom/htmlmetaelement.rs b/servo/components/script/dom/htmlmetaelement.rs index 462c4aafec17..36a2f7016430 100644 --- a/servo/components/script/dom/htmlmetaelement.rs +++ b/servo/components/script/dom/htmlmetaelement.rs @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::HTMLMetaElementBinding; use dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root, RootedReference}; +use dom::bindings::root::{DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::cssstylesheet::CSSStyleSheet; use dom::document::Document; @@ -33,8 +33,8 @@ use style::stylesheets::{Stylesheet, StylesheetContents, CssRule, CssRules, Orig pub struct HTMLMetaElement { htmlelement: HTMLElement, #[ignore_heap_size_of = "Arc"] - stylesheet: DOMRefCell>>, - cssom_stylesheet: MutNullableJS, + stylesheet: DomRefCell>>, + cssom_stylesheet: MutNullableDom, } impl HTMLMetaElement { @@ -43,15 +43,15 @@ impl HTMLMetaElement { document: &Document) -> HTMLMetaElement { HTMLMetaElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), - stylesheet: DOMRefCell::new(None), - cssom_stylesheet: MutNullableJS::new(None), + stylesheet: DomRefCell::new(None), + cssom_stylesheet: MutNullableDom::new(None), } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLMetaElement::new_inherited(local_name, prefix, document), document, HTMLMetaElementBinding::Wrap) @@ -61,7 +61,7 @@ impl HTMLMetaElement { self.stylesheet.borrow().clone() } - pub fn get_cssom_stylesheet(&self) -> Option> { + pub fn get_cssom_stylesheet(&self) -> Option> { self.get_stylesheet().map(|sheet| { self.cssom_stylesheet.or_init(|| { CSSStyleSheet::new(&window_from_node(self), diff --git a/servo/components/script/dom/htmlmeterelement.rs b/servo/components/script/dom/htmlmeterelement.rs index ccf1e9a07bb1..2fd7a554fce3 100644 --- a/servo/components/script/dom/htmlmeterelement.rs +++ b/servo/components/script/dom/htmlmeterelement.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::HTMLMeterElementBinding::{self, HTMLMeterElementMethods}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -29,7 +29,7 @@ impl HTMLMeterElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLMeterElement::new_inherited(local_name, prefix, document), document, HTMLMeterElementBinding::Wrap) @@ -38,7 +38,7 @@ impl HTMLMeterElement { impl HTMLMeterElementMethods for HTMLMeterElement { // https://html.spec.whatwg.org/multipage/#dom-lfe-labels - fn Labels(&self) -> Root { + fn Labels(&self) -> DomRoot { self.upcast::().labels() } } diff --git a/servo/components/script/dom/htmlmodelement.rs b/servo/components/script/dom/htmlmodelement.rs index fc3ac0752428..4266b954a81e 100644 --- a/servo/components/script/dom/htmlmodelement.rs +++ b/servo/components/script/dom/htmlmodelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLModElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLModElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLModElement::new_inherited(local_name, prefix, document), document, HTMLModElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlobjectelement.rs b/servo/components/script/dom/htmlobjectelement.rs index 4c7d54c2f1fe..0cde28ec1a6f 100755 --- a/servo/components/script/dom/htmlobjectelement.rs +++ b/servo/components/script/dom/htmlobjectelement.rs @@ -3,11 +3,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::HTMLObjectElementBinding; use dom::bindings::codegen::Bindings::HTMLObjectElementBinding::HTMLObjectElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element}; @@ -27,8 +27,8 @@ use std::default::Default; pub struct HTMLObjectElement { htmlelement: HTMLElement, #[ignore_heap_size_of = "Arc"] - image: DOMRefCell>>, - form_owner: MutNullableJS, + image: DomRefCell>>, + form_owner: MutNullableDom, } impl HTMLObjectElement { @@ -38,7 +38,7 @@ impl HTMLObjectElement { HTMLObjectElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), - image: DOMRefCell::new(None), + image: DomRefCell::new(None), form_owner: Default::default(), } } @@ -46,7 +46,7 @@ impl HTMLObjectElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLObjectElement::new_inherited(local_name, prefix, document), document, HTMLObjectElementBinding::Wrap) @@ -76,7 +76,7 @@ impl<'a> ProcessDataURL for &'a HTMLObjectElement { impl HTMLObjectElementMethods for HTMLObjectElement { // https://html.spec.whatwg.org/multipage/#dom-cva-validity - fn Validity(&self) -> Root { + fn Validity(&self) -> DomRoot { let window = window_from_node(self); ValidityState::new(&window, self.upcast()) } @@ -88,7 +88,7 @@ impl HTMLObjectElementMethods for HTMLObjectElement { make_setter!(SetType, "type"); // https://html.spec.whatwg.org/multipage/#dom-fae-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { self.form_owner() } } @@ -126,7 +126,7 @@ impl VirtualMethods for HTMLObjectElement { } impl FormControl for HTMLObjectElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } diff --git a/servo/components/script/dom/htmlolistelement.rs b/servo/components/script/dom/htmlolistelement.rs index 42351aea0ffc..58c159f1e686 100644 --- a/servo/components/script/dom/htmlolistelement.rs +++ b/servo/components/script/dom/htmlolistelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLOListElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -27,7 +27,7 @@ impl HTMLOListElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLOListElement::new_inherited(local_name, prefix, document), document, HTMLOListElementBinding::Wrap) diff --git a/servo/components/script/dom/htmloptgroupelement.rs b/servo/components/script/dom/htmloptgroupelement.rs index d7a50906a76a..b22bb0a79b57 100644 --- a/servo/components/script/dom/htmloptgroupelement.rs +++ b/servo/components/script/dom/htmloptgroupelement.rs @@ -6,7 +6,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding; use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding::HTMLOptGroupElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::element::{AttributeMutation, Element}; use dom::htmlelement::HTMLElement; @@ -36,7 +36,7 @@ impl HTMLOptGroupElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLOptGroupElement::new_inherited(local_name, prefix, document), document, HTMLOptGroupElementBinding::Wrap) @@ -73,7 +73,7 @@ impl VirtualMethods for HTMLOptGroupElement { el.set_enabled_state(!disabled_state); let options = el.upcast::().children().filter(|child| { child.is::() - }).map(|child| Root::from_ref(child.downcast::().unwrap())); + }).map(|child| DomRoot::from_ref(child.downcast::().unwrap())); if disabled_state { for option in options { let el = option.upcast::(); diff --git a/servo/components/script/dom/htmloptionelement.rs b/servo/components/script/dom/htmloptionelement.rs index 251bbc62a840..9e916912b871 100644 --- a/servo/components/script/dom/htmloptionelement.rs +++ b/servo/components/script/dom/htmloptionelement.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElemen use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementBinding::HTMLSelectElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::characterdata::CharacterData; use dom::document::Document; @@ -55,7 +55,7 @@ impl HTMLOptionElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLOptionElement::new_inherited(local_name, prefix, document), document, HTMLOptionElementBinding::Wrap) @@ -71,7 +71,7 @@ impl HTMLOptionElement { fn pick_if_selected_and_reset(&self) { if let Some(select) = self.upcast::().ancestors() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .next() { if self.Selected() { select.pick_option(self); @@ -119,7 +119,7 @@ impl HTMLOptionElementMethods for HTMLOptionElement { } // https://html.spec.whatwg.org/multipage/#dom-option-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { let parent = self.upcast::().GetParentNode().and_then(|p| if p.is::() { p.upcast::().GetParentNode() @@ -234,7 +234,7 @@ impl VirtualMethods for HTMLOptionElement { self.super_type().unwrap().unbind_from_tree(context); if let Some(select) = context.parent.inclusive_ancestors() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .next() { select.ask_for_reset(); } diff --git a/servo/components/script/dom/htmloptionscollection.rs b/servo/components/script/dom/htmloptionscollection.rs index f3b839a8a2a7..84d4901aa8b6 100644 --- a/servo/components/script/dom/htmloptionscollection.rs +++ b/servo/components/script/dom/htmloptionscollection.rs @@ -11,8 +11,8 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; use dom::bindings::codegen::UnionTypes::{HTMLOptionElementOrHTMLOptGroupElement, HTMLElementOrLong}; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, RootedReference}; use dom::bindings::str::DOMString; use dom::element::Element; use dom::htmlcollection::{CollectionFilter, HTMLCollection}; @@ -35,7 +35,7 @@ impl HTMLOptionsCollection { } pub fn new(window: &Window, select: &HTMLSelectElement, filter: Box) - -> Root + -> DomRoot { reflect_dom_object(box HTMLOptionsCollection::new_inherited(select, filter), window, @@ -61,7 +61,7 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection { // https://github.com/servo/servo/issues/5875 // // https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem - fn NamedGetter(&self, name: DOMString) -> Option> { + fn NamedGetter(&self, name: DOMString) -> Option> { self.upcast().NamedItem(name) } @@ -75,7 +75,7 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection { // https://github.com/servo/servo/issues/5875 // // https://dom.spec.whatwg.org/#dom-htmlcollection-item - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.upcast().IndexedGetter(index) } @@ -161,9 +161,9 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection { // Step 4 let reference_node = before.and_then(|before| { match before { - HTMLElementOrLong::HTMLElement(element) => Some(Root::upcast::(element)), + HTMLElementOrLong::HTMLElement(element) => Some(DomRoot::upcast::(element)), HTMLElementOrLong::Long(index) => { - self.upcast().IndexedGetter(index as u32).map(Root::upcast::) + self.upcast().IndexedGetter(index as u32).map(DomRoot::upcast::) } } }); diff --git a/servo/components/script/dom/htmloutputelement.rs b/servo/components/script/dom/htmloutputelement.rs index f0b9377e4478..d3d7d5991cff 100644 --- a/servo/components/script/dom/htmloutputelement.rs +++ b/servo/components/script/dom/htmloutputelement.rs @@ -6,7 +6,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLOutputElementBinding; use dom::bindings::codegen::Bindings::HTMLOutputElementBinding::HTMLOutputElementMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::document::Document; use dom::element::{AttributeMutation, Element}; use dom::htmlelement::HTMLElement; @@ -21,7 +21,7 @@ use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLOutputElement { htmlelement: HTMLElement, - form_owner: MutNullableJS, + form_owner: MutNullableDom, } impl HTMLOutputElement { @@ -38,7 +38,7 @@ impl HTMLOutputElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLOutputElement::new_inherited(local_name, prefix, document), document, HTMLOutputElementBinding::Wrap) @@ -47,18 +47,18 @@ impl HTMLOutputElement { impl HTMLOutputElementMethods for HTMLOutputElement { // https://html.spec.whatwg.org/multipage/#dom-cva-validity - fn Validity(&self) -> Root { + fn Validity(&self) -> DomRoot { let window = window_from_node(self); ValidityState::new(&window, self.upcast()) } // https://html.spec.whatwg.org/multipage/#dom-fae-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { self.form_owner() } // https://html.spec.whatwg.org/multipage/#dom-lfe-labels - fn Labels(&self) -> Root { + fn Labels(&self) -> DomRoot { self.upcast::().labels() } } @@ -80,7 +80,7 @@ impl VirtualMethods for HTMLOutputElement { } impl FormControl for HTMLOutputElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } diff --git a/servo/components/script/dom/htmlparagraphelement.rs b/servo/components/script/dom/htmlparagraphelement.rs index f0b0e176152b..f17b7653b6ff 100644 --- a/servo/components/script/dom/htmlparagraphelement.rs +++ b/servo/components/script/dom/htmlparagraphelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLParagraphElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLParagraphElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLParagraphElement::new_inherited(local_name, prefix, document), document, HTMLParagraphElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlparamelement.rs b/servo/components/script/dom/htmlparamelement.rs index 46dd705ef3bd..a1544b8157c3 100644 --- a/servo/components/script/dom/htmlparamelement.rs +++ b/servo/components/script/dom/htmlparamelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLParamElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLParamElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLParamElement::new_inherited(local_name, prefix, document), document, HTMLParamElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlpreelement.rs b/servo/components/script/dom/htmlpreelement.rs index 76862160847a..7befed936cc8 100644 --- a/servo/components/script/dom/htmlpreelement.rs +++ b/servo/components/script/dom/htmlpreelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLPreElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLPreElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLPreElement::new_inherited(local_name, prefix, document), document, HTMLPreElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlprogresselement.rs b/servo/components/script/dom/htmlprogresselement.rs index 2ad3371da940..c8fb1937fe16 100644 --- a/servo/components/script/dom/htmlprogresselement.rs +++ b/servo/components/script/dom/htmlprogresselement.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::HTMLProgressElementBinding::{self, HTMLProgressElementMethods}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -30,7 +30,7 @@ impl HTMLProgressElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLProgressElement::new_inherited(local_name, prefix, document), document, HTMLProgressElementBinding::Wrap) @@ -39,7 +39,7 @@ impl HTMLProgressElement { impl HTMLProgressElementMethods for HTMLProgressElement { // https://html.spec.whatwg.org/multipage/#dom-lfe-labels - fn Labels(&self) -> Root { + fn Labels(&self) -> DomRoot { self.upcast::().labels() } } diff --git a/servo/components/script/dom/htmlquoteelement.rs b/servo/components/script/dom/htmlquoteelement.rs index 7ccb59b5e848..9db0dbc87f32 100644 --- a/servo/components/script/dom/htmlquoteelement.rs +++ b/servo/components/script/dom/htmlquoteelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLQuoteElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLQuoteElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLQuoteElement::new_inherited(local_name, prefix, document), document, HTMLQuoteElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlscriptelement.rs b/servo/components/script/dom/htmlscriptelement.rs index a9a7869e33e3..7cdebdbcba4b 100644 --- a/servo/components/script/dom/htmlscriptelement.rs +++ b/servo/components/script/dom/htmlscriptelement.rs @@ -9,10 +9,9 @@ use dom::bindings::codegen::Bindings::HTMLScriptElementBinding; use dom::bindings::codegen::Bindings::HTMLScriptElementBinding::HTMLScriptElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; -use dom::bindings::js::RootedReference; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{Dom, DomRoot, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, ElementCreator}; @@ -62,7 +61,7 @@ pub struct HTMLScriptElement { non_blocking: Cell, /// Document of the parser that created this element - parser_document: JS, + parser_document: Dom, /// Track line line_number line_number: u64, @@ -77,14 +76,14 @@ impl HTMLScriptElement { already_started: Cell::new(false), parser_inserted: Cell::new(creator.is_parser_created()), non_blocking: Cell::new(!creator.is_parser_created()), - parser_document: JS::from_ref(document), + parser_document: Dom::from_ref(document), line_number: creator.return_line_number(), } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, document: &Document, - creator: ElementCreator) -> Root { + creator: ElementCreator) -> DomRoot { Node::reflect_node(box HTMLScriptElement::new_inherited(local_name, prefix, document, creator), document, HTMLScriptElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlselectelement.rs b/servo/components/script/dom/htmlselectelement.rs index 9db953162970..d9eba4dea723 100755 --- a/servo/components/script/dom/htmlselectelement.rs +++ b/servo/components/script/dom/htmlselectelement.rs @@ -14,7 +14,7 @@ use dom::bindings::codegen::UnionTypes::HTMLElementOrLong; use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement; //use dom::bindings::error::ErrorResult; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element}; @@ -61,8 +61,8 @@ impl CollectionFilter for OptionsFilter { #[dom_struct] pub struct HTMLSelectElement { htmlelement: HTMLElement, - options: MutNullableJS, - form_owner: MutNullableJS, + options: MutNullableDom, + form_owner: MutNullableDom, } static DEFAULT_SELECT_SIZE: u32 = 0; @@ -83,22 +83,22 @@ impl HTMLSelectElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLSelectElement::new_inherited(local_name, prefix, document), document, HTMLSelectElementBinding::Wrap) } // https://html.spec.whatwg.org/multipage/#concept-select-option-list - fn list_of_options(&self) -> impl Iterator> { + fn list_of_options(&self) -> impl Iterator> { self.upcast::() .children() .flat_map(|node| { if node.is::() { - let node = Root::downcast::(node).unwrap(); + let node = DomRoot::downcast::(node).unwrap(); Choice3::First(iter::once(node)) } else if node.is::() { - Choice3::Second(node.children().filter_map(Root::downcast)) + Choice3::Second(node.children().filter_map(DomRoot::downcast)) } else { Choice3::Third(iter::empty()) } @@ -120,17 +120,17 @@ impl HTMLSelectElement { return; } - let mut first_enabled: Option> = None; - let mut last_selected: Option> = None; + let mut first_enabled: Option> = None; + let mut last_selected: Option> = None; for opt in self.list_of_options() { if opt.Selected() { opt.set_selectedness(false); - last_selected = Some(Root::from_ref(&opt)); + last_selected = Some(DomRoot::from_ref(&opt)); } let element = opt.upcast::(); if first_enabled.is_none() && !element.disabled_state() { - first_enabled = Some(Root::from_ref(&opt)); + first_enabled = Some(DomRoot::from_ref(&opt)); } } @@ -189,7 +189,7 @@ impl HTMLSelectElement { impl HTMLSelectElementMethods for HTMLSelectElement { // https://html.spec.whatwg.org/multipage/#dom-cva-validity - fn Validity(&self) -> Root { + fn Validity(&self) -> DomRoot { let window = window_from_node(self); ValidityState::new(&window, self.upcast()) } @@ -206,7 +206,7 @@ impl HTMLSelectElementMethods for HTMLSelectElement { make_bool_setter!(SetDisabled, "disabled"); // https://html.spec.whatwg.org/multipage/#dom-fae-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { self.form_owner() } @@ -238,12 +238,12 @@ impl HTMLSelectElementMethods for HTMLSelectElement { } // https://html.spec.whatwg.org/multipage/#dom-lfe-labels - fn Labels(&self) -> Root { + fn Labels(&self) -> DomRoot { self.upcast::().labels() } // https://html.spec.whatwg.org/multipage/#dom-select-options - fn Options(&self) -> Root { + fn Options(&self) -> DomRoot { self.options.or_init(|| { let window = window_from_node(self); HTMLOptionsCollection::new( @@ -262,18 +262,18 @@ impl HTMLSelectElementMethods for HTMLSelectElement { } // https://html.spec.whatwg.org/multipage/#dom-select-item - fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { self.Options().upcast().Item(index) } // https://html.spec.whatwg.org/multipage/#dom-select-item - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Options().IndexedGetter(index) } // https://html.spec.whatwg.org/multipage/#dom-select-nameditem - fn NamedItem(&self, name: DOMString) -> Option> { - self.Options().NamedGetter(name).map_or(None, |e| Root::downcast::(e)) + fn NamedItem(&self, name: DOMString) -> Option> { + self.Options().NamedGetter(name).map_or(None, |e| DomRoot::downcast::(e)) } // https://html.spec.whatwg.org/multipage/#dom-select-remove @@ -398,7 +398,7 @@ impl VirtualMethods for HTMLSelectElement { } impl FormControl for HTMLSelectElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } diff --git a/servo/components/script/dom/htmlsourceelement.rs b/servo/components/script/dom/htmlsourceelement.rs index 865b21d6acb1..c7a60c159c86 100644 --- a/servo/components/script/dom/htmlsourceelement.rs +++ b/servo/components/script/dom/htmlsourceelement.rs @@ -5,7 +5,7 @@ use dom::bindings::codegen::Bindings::HTMLSourceElementBinding; use dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::htmlmediaelement::HTMLMediaElement; @@ -32,7 +32,7 @@ impl HTMLSourceElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLSourceElement::new_inherited(local_name, prefix, document), document, HTMLSourceElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlspanelement.rs b/servo/components/script/dom/htmlspanelement.rs index 657b4aca17b7..f0a16e47d612 100644 --- a/servo/components/script/dom/htmlspanelement.rs +++ b/servo/components/script/dom/htmlspanelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLSpanElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -25,7 +25,7 @@ impl HTMLSpanElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLSpanElement::new_inherited(local_name, prefix, document), document, HTMLSpanElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlstyleelement.rs b/servo/components/script/dom/htmlstyleelement.rs index 65c7d11c12f2..952c143ad688 100644 --- a/servo/components/script/dom/htmlstyleelement.rs +++ b/servo/components/script/dom/htmlstyleelement.rs @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::{Parser as CssParser, ParserInput}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::HTMLStyleElementBinding; use dom::bindings::codegen::Bindings::HTMLStyleElementBinding::HTMLStyleElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::cssstylesheet::CSSStyleSheet; use dom::document::Document; use dom::element::{Element, ElementCreator}; @@ -32,8 +32,8 @@ use stylesheet_loader::{StylesheetLoader, StylesheetOwner}; pub struct HTMLStyleElement { htmlelement: HTMLElement, #[ignore_heap_size_of = "Arc"] - stylesheet: DOMRefCell>>, - cssom_stylesheet: MutNullableJS, + stylesheet: DomRefCell>>, + cssom_stylesheet: MutNullableDom, /// https://html.spec.whatwg.org/multipage/#a-style-sheet-that-is-blocking-scripts parser_inserted: Cell, in_stack_of_open_elements: Cell, @@ -49,8 +49,8 @@ impl HTMLStyleElement { creator: ElementCreator) -> HTMLStyleElement { HTMLStyleElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), - stylesheet: DOMRefCell::new(None), - cssom_stylesheet: MutNullableJS::new(None), + stylesheet: DomRefCell::new(None), + cssom_stylesheet: MutNullableDom::new(None), parser_inserted: Cell::new(creator.is_parser_created()), in_stack_of_open_elements: Cell::new(creator.is_parser_created()), pending_loads: Cell::new(0), @@ -63,7 +63,7 @@ impl HTMLStyleElement { pub fn new(local_name: LocalName, prefix: Option, document: &Document, - creator: ElementCreator) -> Root { + creator: ElementCreator) -> DomRoot { Node::reflect_node(box HTMLStyleElement::new_inherited(local_name, prefix, document, creator), document, HTMLStyleElementBinding::Wrap) @@ -128,7 +128,7 @@ impl HTMLStyleElement { self.stylesheet.borrow().clone() } - pub fn get_cssom_stylesheet(&self) -> Option> { + pub fn get_cssom_stylesheet(&self) -> Option> { self.get_stylesheet().map(|sheet| { self.cssom_stylesheet.or_init(|| { CSSStyleSheet::new(&window_from_node(self), @@ -236,7 +236,7 @@ impl StylesheetOwner for HTMLStyleElement { impl HTMLStyleElementMethods for HTMLStyleElement { // https://drafts.csswg.org/cssom/#dom-linkstyle-sheet - fn GetSheet(&self) -> Option> { - self.get_cssom_stylesheet().map(Root::upcast) + fn GetSheet(&self) -> Option> { + self.get_cssom_stylesheet().map(DomRoot::upcast) } } diff --git a/servo/components/script/dom/htmltablecaptionelement.rs b/servo/components/script/dom/htmltablecaptionelement.rs index b21a00bc1906..2ceecc50609e 100644 --- a/servo/components/script/dom/htmltablecaptionelement.rs +++ b/servo/components/script/dom/htmltablecaptionelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLTableCaptionElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLTableCaptionElement::new_inherited(local_name, prefix, document), document, HTMLTableCaptionElementBinding::Wrap) diff --git a/servo/components/script/dom/htmltablecellelement.rs b/servo/components/script/dom/htmltablecellelement.rs index de0bab2ce9a9..3be05003a4a4 100644 --- a/servo/components/script/dom/htmltablecellelement.rs +++ b/servo/components/script/dom/htmltablecellelement.rs @@ -6,7 +6,7 @@ use cssparser::RGBA; use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::LayoutJS; +use dom::bindings::root::LayoutDom; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{Element, RawLayoutElementHelpers}; @@ -88,7 +88,7 @@ pub trait HTMLTableCellElementLayoutHelpers { } #[allow(unsafe_code)] -impl HTMLTableCellElementLayoutHelpers for LayoutJS { +impl HTMLTableCellElementLayoutHelpers for LayoutDom { fn get_background_color(&self) -> Option { unsafe { (&*self.upcast::().unsafe_get()) diff --git a/servo/components/script/dom/htmltablecolelement.rs b/servo/components/script/dom/htmltablecolelement.rs index 875e6e696bd9..ffbef21ed897 100644 --- a/servo/components/script/dom/htmltablecolelement.rs +++ b/servo/components/script/dom/htmltablecolelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTableColElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLTableColElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLTableColElement::new_inherited(local_name, prefix, document), document, HTMLTableColElementBinding::Wrap) diff --git a/servo/components/script/dom/htmltabledatacellelement.rs b/servo/components/script/dom/htmltabledatacellelement.rs index 1c70ffbd8fb4..7ebd64f20dc0 100644 --- a/servo/components/script/dom/htmltabledatacellelement.rs +++ b/servo/components/script/dom/htmltabledatacellelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTableDataCellElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmltablecellelement::HTMLTableCellElement; use dom::node::Node; @@ -27,7 +27,7 @@ impl HTMLTableDataCellElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, document: &Document) - -> Root { + -> DomRoot { Node::reflect_node(box HTMLTableDataCellElement::new_inherited(local_name, prefix, document), diff --git a/servo/components/script/dom/htmltableelement.rs b/servo/components/script/dom/htmltableelement.rs index c4a6232a5998..2f8e3e3857b2 100644 --- a/servo/components/script/dom/htmltableelement.rs +++ b/servo/components/script/dom/htmltableelement.rs @@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementM use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, MutNullableJS, Root, RootedReference}; +use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; @@ -32,13 +32,13 @@ pub struct HTMLTableElement { htmlelement: HTMLElement, border: Cell>, cellspacing: Cell>, - tbodies: MutNullableJS, + tbodies: MutNullableDom, } #[allow(unrooted_must_root)] #[derive(HeapSizeOf, JSTraceable)] struct TableRowFilter { - sections: Vec>, + sections: Vec>, } impl CollectionFilter for TableRowFilter { @@ -62,7 +62,7 @@ impl HTMLTableElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, document: &Document) - -> Root { + -> DomRoot { Node::reflect_node(box HTMLTableElement::new_inherited(local_name, prefix, document), document, HTMLTableElementBinding::Wrap) @@ -74,11 +74,11 @@ impl HTMLTableElement { // https://html.spec.whatwg.org/multipage/#dom-table-thead // https://html.spec.whatwg.org/multipage/#dom-table-tfoot - fn get_first_section_of_type(&self, atom: &LocalName) -> Option> { + fn get_first_section_of_type(&self, atom: &LocalName) -> Option> { self.upcast::() .child_elements() .find(|n| n.is::() && n.local_name() == atom) - .and_then(|n| n.downcast().map(Root::from_ref)) + .and_then(|n| n.downcast().map(DomRoot::from_ref)) } // https://html.spec.whatwg.org/multipage/#dom-table-thead @@ -88,7 +88,7 @@ impl HTMLTableElement { section: Option<&HTMLTableSectionElement>, reference_predicate: P) -> ErrorResult - where P: FnMut(&Root) -> bool { + where P: FnMut(&DomRoot) -> bool { if let Some(e) = section { if e.upcast::().local_name() != atom { return Err(Error::HierarchyRequest) @@ -111,7 +111,7 @@ impl HTMLTableElement { // https://html.spec.whatwg.org/multipage/#dom-table-createthead // https://html.spec.whatwg.org/multipage/#dom-table-createtfoot - fn create_section_of_type(&self, atom: &LocalName) -> Root { + fn create_section_of_type(&self, atom: &LocalName) -> DomRoot { if let Some(section) = self.get_first_section_of_type(atom) { return section } @@ -141,7 +141,7 @@ impl HTMLTableElement { sections: self.upcast::() .children() .filter_map(|ref node| - node.downcast::().map(|_| JS::from_ref(&**node))) + node.downcast::().map(|_| Dom::from_ref(&**node))) .collect() } } @@ -149,14 +149,14 @@ impl HTMLTableElement { impl HTMLTableElementMethods for HTMLTableElement { // https://html.spec.whatwg.org/multipage/#dom-table-rows - fn Rows(&self) -> Root { + fn Rows(&self) -> DomRoot { let filter = self.get_rows(); HTMLCollection::new(&window_from_node(self), self.upcast(), box filter) } // https://html.spec.whatwg.org/multipage/#dom-table-caption - fn GetCaption(&self) -> Option> { - self.upcast::().children().filter_map(Root::downcast).next() + fn GetCaption(&self) -> Option> { + self.upcast::().children().filter_map(DomRoot::downcast).next() } // https://html.spec.whatwg.org/multipage/#dom-table-caption @@ -173,7 +173,7 @@ impl HTMLTableElementMethods for HTMLTableElement { } // https://html.spec.whatwg.org/multipage/#dom-table-createcaption - fn CreateCaption(&self) -> Root { + fn CreateCaption(&self) -> DomRoot { match self.GetCaption() { Some(caption) => caption, None => { @@ -195,7 +195,7 @@ impl HTMLTableElementMethods for HTMLTableElement { // https://html.spec.whatwg.org/multipage/#dom-table-thead - fn GetTHead(&self) -> Option> { + fn GetTHead(&self) -> Option> { self.get_first_section_of_type(&local_name!("thead")) } @@ -207,7 +207,7 @@ impl HTMLTableElementMethods for HTMLTableElement { } // https://html.spec.whatwg.org/multipage/#dom-table-createthead - fn CreateTHead(&self) -> Root { + fn CreateTHead(&self) -> DomRoot { self.create_section_of_type(&local_name!("thead")) } @@ -217,7 +217,7 @@ impl HTMLTableElementMethods for HTMLTableElement { } // https://html.spec.whatwg.org/multipage/#dom-table-tfoot - fn GetTFoot(&self) -> Option> { + fn GetTFoot(&self) -> Option> { self.get_first_section_of_type(&local_name!("tfoot")) } @@ -241,7 +241,7 @@ impl HTMLTableElementMethods for HTMLTableElement { } // https://html.spec.whatwg.org/multipage/#dom-table-createtfoot - fn CreateTFoot(&self) -> Root { + fn CreateTFoot(&self) -> DomRoot { self.create_section_of_type(&local_name!("tfoot")) } @@ -251,7 +251,7 @@ impl HTMLTableElementMethods for HTMLTableElement { } // https://html.spec.whatwg.org/multipage/#dom-table-tbodies - fn TBodies(&self) -> Root { + fn TBodies(&self) -> DomRoot { #[derive(JSTraceable)] struct TBodiesFilter; impl CollectionFilter for TBodiesFilter { @@ -271,14 +271,14 @@ impl HTMLTableElementMethods for HTMLTableElement { // https://html.spec.whatwg.org/multipage/#dom-table-createtbody - fn CreateTBody(&self) -> Root { + fn CreateTBody(&self) -> DomRoot { let tbody = HTMLTableSectionElement::new(local_name!("tbody"), None, &document_from_node(self)); let node = self.upcast::(); let last_tbody = node.rev_children() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .find(|n| n.is::() && n.local_name() == &local_name!("tbody")); let reference_element = last_tbody.and_then(|t| t.upcast::().GetNextSibling()); @@ -289,7 +289,7 @@ impl HTMLTableElementMethods for HTMLTableElement { } // https://html.spec.whatwg.org/multipage/#dom-table-insertrow - fn InsertRow(&self, index: i32) -> Fallible> { + fn InsertRow(&self, index: i32) -> Fallible> { let rows = self.Rows(); let number_of_row_elements = rows.Length(); @@ -305,7 +305,7 @@ impl HTMLTableElementMethods for HTMLTableElement { if number_of_row_elements == 0 { // append new row to last or new tbody in table if let Some(last_tbody) = node.rev_children() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .find(|n| n.is::() && n.local_name() == &local_name!("tbody")) { last_tbody.upcast::().AppendChild(new_row.upcast::()) .expect("InsertRow failed to append first row."); @@ -355,7 +355,7 @@ impl HTMLTableElementMethods for HTMLTableElement { return Err(Error::IndexSize); } // Step 3. - Root::upcast::(rows.Item(index as u32).unwrap()).remove_self(); + DomRoot::upcast::(rows.Item(index as u32).unwrap()).remove_self(); Ok(()) } @@ -379,7 +379,7 @@ pub trait HTMLTableElementLayoutHelpers { fn get_width(&self) -> LengthOrPercentageOrAuto; } -impl HTMLTableElementLayoutHelpers for LayoutJS { +impl HTMLTableElementLayoutHelpers for LayoutDom { #[allow(unsafe_code)] fn get_background_color(&self) -> Option { unsafe { diff --git a/servo/components/script/dom/htmltableheadercellelement.rs b/servo/components/script/dom/htmltableheadercellelement.rs index 7655db7ee775..6b03b4211171 100644 --- a/servo/components/script/dom/htmltableheadercellelement.rs +++ b/servo/components/script/dom/htmltableheadercellelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTableHeaderCellElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmltablecellelement::HTMLTableCellElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLTableHeaderCellElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLTableHeaderCellElement::new_inherited(local_name, prefix, document), document, HTMLTableHeaderCellElementBinding::Wrap) diff --git a/servo/components/script/dom/htmltablerowelement.rs b/servo/components/script/dom/htmltablerowelement.rs index d18ef77f8d85..bdc6708ee4f2 100644 --- a/servo/components/script/dom/htmltablerowelement.rs +++ b/servo/components/script/dom/htmltablerowelement.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableS use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, MutNullableJS, Root, RootedReference}; +use dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{Element, RawLayoutElementHelpers}; @@ -37,7 +37,7 @@ impl CollectionFilter for CellsFilter { #[dom_struct] pub struct HTMLTableRowElement { htmlelement: HTMLElement, - cells: MutNullableJS, + cells: MutNullableDom, } impl HTMLTableRowElement { @@ -51,7 +51,7 @@ impl HTMLTableRowElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, document: &Document) - -> Root { + -> DomRoot { Node::reflect_node(box HTMLTableRowElement::new_inherited(local_name, prefix, document), document, HTMLTableRowElementBinding::Wrap) @@ -59,7 +59,7 @@ impl HTMLTableRowElement { /// Determine the index for this `HTMLTableRowElement` within the given /// `HTMLCollection`. Returns `-1` if not found within collection. - fn row_index(&self, collection: Root) -> i32 { + fn row_index(&self, collection: DomRoot) -> i32 { collection.elements_iter() .position(|elem| (&elem as &Element) == self.upcast()) .map_or(-1, |i| i as i32) @@ -74,7 +74,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement { make_legacy_color_setter!(SetBgColor, "bgcolor"); // https://html.spec.whatwg.org/multipage/#dom-tr-cells - fn Cells(&self) -> Root { + fn Cells(&self) -> DomRoot { self.cells.or_init(|| { let window = window_from_node(self); let filter = box CellsFilter; @@ -83,7 +83,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement { } // https://html.spec.whatwg.org/multipage/#dom-tr-insertcell - fn InsertCell(&self, index: i32) -> Fallible> { + fn InsertCell(&self, index: i32) -> Fallible> { let node = self.upcast::(); node.insert_cell_or_row( index, @@ -142,7 +142,7 @@ pub trait HTMLTableRowElementLayoutHelpers { } #[allow(unsafe_code)] -impl HTMLTableRowElementLayoutHelpers for LayoutJS { +impl HTMLTableRowElementLayoutHelpers for LayoutDom { fn get_background_color(&self) -> Option { unsafe { (&*self.upcast::().unsafe_get()) diff --git a/servo/components/script/dom/htmltablesectionelement.rs b/servo/components/script/dom/htmltablesectionelement.rs index 66703305bc73..1b4d1c72020d 100644 --- a/servo/components/script/dom/htmltablesectionelement.rs +++ b/servo/components/script/dom/htmltablesectionelement.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{self, HTM use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, Root, RootedReference}; +use dom::bindings::root::{DomRoot, LayoutDom, RootedReference}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{Element, RawLayoutElementHelpers}; @@ -35,7 +35,7 @@ impl HTMLTableSectionElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, document: &Document) - -> Root { + -> DomRoot { Node::reflect_node(box HTMLTableSectionElement::new_inherited(local_name, prefix, document), document, HTMLTableSectionElementBinding::Wrap) @@ -53,12 +53,12 @@ impl CollectionFilter for RowsFilter { impl HTMLTableSectionElementMethods for HTMLTableSectionElement { // https://html.spec.whatwg.org/multipage/#dom-tbody-rows - fn Rows(&self) -> Root { + fn Rows(&self) -> DomRoot { HTMLCollection::create(&window_from_node(self), self.upcast(), box RowsFilter) } // https://html.spec.whatwg.org/multipage/#dom-tbody-insertrow - fn InsertRow(&self, index: i32) -> Fallible> { + fn InsertRow(&self, index: i32) -> Fallible> { let node = self.upcast::(); node.insert_cell_or_row( index, @@ -81,7 +81,7 @@ pub trait HTMLTableSectionElementLayoutHelpers { } #[allow(unsafe_code)] -impl HTMLTableSectionElementLayoutHelpers for LayoutJS { +impl HTMLTableSectionElementLayoutHelpers for LayoutDom { fn get_background_color(&self) -> Option { unsafe { (&*self.upcast::().unsafe_get()) diff --git a/servo/components/script/dom/htmltemplateelement.rs b/servo/components/script/dom/htmltemplateelement.rs index 9b058607aff8..dde9d380c728 100644 --- a/servo/components/script/dom/htmltemplateelement.rs +++ b/servo/components/script/dom/htmltemplateelement.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding; use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::document::Document; use dom::documentfragment::DocumentFragment; use dom::htmlelement::HTMLElement; @@ -21,7 +21,7 @@ pub struct HTMLTemplateElement { htmlelement: HTMLElement, /// https://html.spec.whatwg.org/multipage/#template-contents - contents: MutNullableJS, + contents: MutNullableDom, } impl HTMLTemplateElement { @@ -31,14 +31,14 @@ impl HTMLTemplateElement { HTMLTemplateElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document), - contents: MutNullableJS::new(None), + contents: MutNullableDom::new(None), } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLTemplateElement::new_inherited(local_name, prefix, document), document, HTMLTemplateElementBinding::Wrap) @@ -47,7 +47,7 @@ impl HTMLTemplateElement { impl HTMLTemplateElementMethods for HTMLTemplateElement { /// https://html.spec.whatwg.org/multipage/#dom-template-content - fn Content(&self) -> Root { + fn Content(&self) -> DomRoot { self.contents.or_init(|| { let doc = document_from_node(self); doc.appropriate_template_contents_owner_document().CreateDocumentFragment() @@ -79,7 +79,7 @@ impl VirtualMethods for HTMLTemplateElement { } let copy = copy.downcast::().unwrap(); // Steps 2-3. - let copy_contents = Root::upcast::(copy.Content()); + let copy_contents = DomRoot::upcast::(copy.Content()); let copy_contents_doc = copy_contents.owner_doc(); for child in self.Content().upcast::().children() { let copy_child = Node::clone( diff --git a/servo/components/script/dom/htmltextareaelement.rs b/servo/components/script/dom/htmltextareaelement.rs index fc48564d0300..c599113f6b39 100755 --- a/servo/components/script/dom/htmltextareaelement.rs +++ b/servo/components/script/dom/htmltextareaelement.rs @@ -3,13 +3,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::attr::Attr; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding; use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, MutNullableJS, Root}; +use dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element}; @@ -39,11 +39,11 @@ use textinput::{KeyReaction, Lines, SelectionDirection, TextInput}; pub struct HTMLTextAreaElement { htmlelement: HTMLElement, #[ignore_heap_size_of = "#7193"] - textinput: DOMRefCell>, - placeholder: DOMRefCell, + textinput: DomRefCell>, + placeholder: DomRefCell, // https://html.spec.whatwg.org/multipage/#concept-textarea-dirty value_changed: Cell, - form_owner: MutNullableJS, + form_owner: MutNullableDom, } pub trait LayoutHTMLTextAreaElementHelpers { @@ -57,7 +57,7 @@ pub trait LayoutHTMLTextAreaElementHelpers { fn get_rows(self) -> u32; } -impl LayoutHTMLTextAreaElementHelpers for LayoutJS { +impl LayoutHTMLTextAreaElementHelpers for LayoutDom { #[allow(unrooted_must_root)] #[allow(unsafe_code)] unsafe fn get_value_for_layout(self) -> String { @@ -113,8 +113,8 @@ impl HTMLTextAreaElement { htmlelement: HTMLElement::new_inherited_with_state(IN_ENABLED_STATE | IN_READ_WRITE_STATE, local_name, prefix, document), - placeholder: DOMRefCell::new(DOMString::new()), - textinput: DOMRefCell::new(TextInput::new( + placeholder: DomRefCell::new(DOMString::new()), + textinput: DomRefCell::new(TextInput::new( Lines::Multiple, DOMString::new(), chan, None, None, SelectionDirection::None)), value_changed: Cell::new(false), form_owner: Default::default(), @@ -124,7 +124,7 @@ impl HTMLTextAreaElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLTextAreaElement::new_inherited(local_name, prefix, document), document, HTMLTextAreaElementBinding::Wrap) @@ -156,7 +156,7 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement { make_bool_setter!(SetDisabled, "disabled"); // https://html.spec.whatwg.org/multipage/#dom-fae-form - fn GetForm(&self) -> Option> { + fn GetForm(&self) -> Option> { self.form_owner() } @@ -232,7 +232,7 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement { } // https://html.spec.whatwg.org/multipage/#dom-lfe-labels - fn Labels(&self) -> Root { + fn Labels(&self) -> DomRoot { self.upcast::().labels() } @@ -441,7 +441,7 @@ impl VirtualMethods for HTMLTextAreaElement { } impl FormControl for HTMLTextAreaElement { - fn form_owner(&self) -> Option> { + fn form_owner(&self) -> Option> { self.form_owner.get() } diff --git a/servo/components/script/dom/htmltimeelement.rs b/servo/components/script/dom/htmltimeelement.rs index 7fc3245ed419..0653d32ad5fe 100644 --- a/servo/components/script/dom/htmltimeelement.rs +++ b/servo/components/script/dom/htmltimeelement.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::HTMLTimeElementBinding; use dom::bindings::codegen::Bindings::HTMLTimeElementBinding::HTMLTimeElementMethods; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::htmlelement::HTMLElement; @@ -27,7 +27,7 @@ impl HTMLTimeElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLTimeElement::new_inherited(local_name, prefix, document), document, HTMLTimeElementBinding::Wrap) diff --git a/servo/components/script/dom/htmltitleelement.rs b/servo/components/script/dom/htmltitleelement.rs index 751f3c0ef2e8..0c1aeac47b60 100644 --- a/servo/components/script/dom/htmltitleelement.rs +++ b/servo/components/script/dom/htmltitleelement.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::HTMLTitleElementBinding; use dom::bindings::codegen::Bindings::HTMLTitleElementBinding::HTMLTitleElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::Document; use dom::htmlelement::HTMLElement; @@ -30,7 +30,7 @@ impl HTMLTitleElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLTitleElement::new_inherited(local_name, prefix, document), document, HTMLTitleElementBinding::Wrap) diff --git a/servo/components/script/dom/htmltrackelement.rs b/servo/components/script/dom/htmltrackelement.rs index eb9a5ecf80d5..94015862c58b 100644 --- a/servo/components/script/dom/htmltrackelement.rs +++ b/servo/components/script/dom/htmltrackelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTrackElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -25,7 +25,7 @@ impl HTMLTrackElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLTrackElement::new_inherited(local_name, prefix, document), document, HTMLTrackElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlulistelement.rs b/servo/components/script/dom/htmlulistelement.rs index b40f4a1f8dbb..d6b1b7ea41e1 100644 --- a/servo/components/script/dom/htmlulistelement.rs +++ b/servo/components/script/dom/htmlulistelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLUListElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -25,7 +25,7 @@ impl HTMLUListElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLUListElement::new_inherited(local_name, prefix, document), document, HTMLUListElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlunknownelement.rs b/servo/components/script/dom/htmlunknownelement.rs index cb3db5be2928..1622b88cb777 100644 --- a/servo/components/script/dom/htmlunknownelement.rs +++ b/servo/components/script/dom/htmlunknownelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLUnknownElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; @@ -28,7 +28,7 @@ impl HTMLUnknownElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLUnknownElement::new_inherited(local_name, prefix, document), document, HTMLUnknownElementBinding::Wrap) diff --git a/servo/components/script/dom/htmlvideoelement.rs b/servo/components/script/dom/htmlvideoelement.rs index 00befe9a109a..998f46c279bc 100644 --- a/servo/components/script/dom/htmlvideoelement.rs +++ b/servo/components/script/dom/htmlvideoelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLVideoElementBinding; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::document::Document; use dom::htmlmediaelement::HTMLMediaElement; use dom::node::Node; @@ -26,7 +26,7 @@ impl HTMLVideoElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box HTMLVideoElement::new_inherited(local_name, prefix, document), document, HTMLVideoElementBinding::Wrap) diff --git a/servo/components/script/dom/imagedata.rs b/servo/components/script/dom/imagedata.rs index 30e0e3d6dae5..98be416ff457 100644 --- a/servo/components/script/dom/imagedata.rs +++ b/servo/components/script/dom/imagedata.rs @@ -6,8 +6,8 @@ use core::nonzero::NonZero; use dom::bindings::codegen::Bindings::ImageDataBinding; use dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods; use dom::bindings::error::{Fallible, Error}; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use euclid::Size2D; @@ -32,7 +32,7 @@ impl ImageData { width: u32, height: u32, mut data: Option>) - -> Fallible> { + -> Fallible> { let len = width * height * 4; unsafe { let cx = global.get_cx(); @@ -54,7 +54,7 @@ impl ImageData { width: u32, mut opt_height: Option, opt_jsobject: Option<*mut JSObject>) - -> Fallible> { + -> Fallible> { assert!(opt_jsobject.is_some() || opt_height.is_some()); if width == 0 { @@ -113,7 +113,7 @@ impl ImageData { // https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-3 #[allow(unsafe_code)] - pub fn Constructor(global: &GlobalScope, width: u32, height: u32) -> Fallible> { + pub fn Constructor(global: &GlobalScope, width: u32, height: u32) -> Fallible> { unsafe { Self::new_with_jsobject(global, width, Some(height), None) } } @@ -125,7 +125,7 @@ impl ImageData { jsobject: *mut JSObject, width: u32, opt_height: Option) - -> Fallible> { + -> Fallible> { Self::new_with_jsobject(global, width, opt_height, Some(jsobject)) } diff --git a/servo/components/script/dom/inputevent.rs b/servo/components/script/dom/inputevent.rs index c080ea0c9173..641eb21a5d30 100644 --- a/servo/components/script/dom/inputevent.rs +++ b/servo/components/script/dom/inputevent.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::InputEventBinding::{self, InputEventMethods}; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::{Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, RootedReference}; use dom::bindings::str::DOMString; use dom::uievent::UIEvent; use dom::window::Window; @@ -27,7 +27,7 @@ impl InputEvent { view: Option<&Window>, detail: i32, data: Option, - is_composing: bool) -> Root { + is_composing: bool) -> DomRoot { let ev = reflect_dom_object(box InputEvent { uievent: UIEvent::new_inherited(), data: data, @@ -42,7 +42,7 @@ impl InputEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &InputEventBinding::InputEventInit) - -> Fallible> { + -> Fallible> { let event = InputEvent::new(window, type_, init.parent.parent.bubbles, diff --git a/servo/components/script/dom/keyboardevent.rs b/servo/components/script/dom/keyboardevent.rs index 33b044085a23..69d71ae665af 100644 --- a/servo/components/script/dom/keyboardevent.rs +++ b/servo/components/script/dom/keyboardevent.rs @@ -2,14 +2,14 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::KeyboardEventBinding; use dom::bindings::codegen::Bindings::KeyboardEventBinding::{KeyboardEventConstants, KeyboardEventMethods}; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, RootedReference}; use dom::bindings::str::DOMString; use dom::event::Event; use dom::uievent::UIEvent; @@ -26,8 +26,8 @@ unsafe_no_jsmanaged_fields!(Key); pub struct KeyboardEvent { uievent: UIEvent, key: Cell>, - key_string: DOMRefCell, - code: DOMRefCell, + key_string: DomRefCell, + code: DomRefCell, location: Cell, ctrl: Cell, alt: Cell, @@ -45,8 +45,8 @@ impl KeyboardEvent { KeyboardEvent { uievent: UIEvent::new_inherited(), key: Cell::new(None), - key_string: DOMRefCell::new(DOMString::new()), - code: DOMRefCell::new(DOMString::new()), + key_string: DomRefCell::new(DOMString::new()), + code: DomRefCell::new(DOMString::new()), location: Cell::new(0), ctrl: Cell::new(false), alt: Cell::new(false), @@ -60,7 +60,7 @@ impl KeyboardEvent { } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { reflect_dom_object(box KeyboardEvent::new_inherited(), window, KeyboardEventBinding::Wrap) @@ -84,7 +84,7 @@ impl KeyboardEvent { shift_key: bool, meta_key: bool, char_code: Option, - key_code: u32) -> Root { + key_code: u32) -> DomRoot { let ev = KeyboardEvent::new_uninitialized(window); ev.InitKeyboardEvent(type_, can_bubble, cancelable, view, key_string, location, DOMString::new(), repeat, DOMString::new()); @@ -103,7 +103,7 @@ impl KeyboardEvent { pub fn Constructor(window: &Window, type_: DOMString, - init: &KeyboardEventBinding::KeyboardEventInit) -> Fallible> { + init: &KeyboardEventBinding::KeyboardEventInit) -> Fallible> { let event = KeyboardEvent::new(window, type_, init.parent.parent.parent.bubbles, diff --git a/servo/components/script/dom/location.rs b/servo/components/script/dom/location.rs index c725e6cee54e..868b9df22660 100644 --- a/servo/components/script/dom/location.rs +++ b/servo/components/script/dom/location.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::LocationBinding; use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::{DOMString, USVString}; use dom::globalscope::GlobalScope; use dom::urlhelper::UrlHelper; @@ -18,18 +18,18 @@ use servo_url::{MutableOrigin, ServoUrl}; #[dom_struct] pub struct Location { reflector_: Reflector, - window: JS, + window: Dom, } impl Location { fn new_inherited(window: &Window) -> Location { Location { reflector_: Reflector::new(), - window: JS::from_ref(window) + window: Dom::from_ref(window) } } - pub fn new(window: &Window) -> Root { + pub fn new(window: &Window) -> DomRoot { reflect_dom_object(box Location::new_inherited(window), window, LocationBinding::Wrap) diff --git a/servo/components/script/dom/macros.rs b/servo/components/script/dom/macros.rs index 075caf04c5fc..9029a2b694a9 100644 --- a/servo/components/script/dom/macros.rs +++ b/servo/components/script/dom/macros.rs @@ -600,8 +600,8 @@ macro_rules! rooted_vec { macro_rules! impl_performance_entry_struct( ($binding:ident, $struct:ident, $type:expr) => ( use dom::bindings::codegen::Bindings::$binding; - use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; + use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom::performanceentry::PerformanceEntry; @@ -627,7 +627,7 @@ macro_rules! impl_performance_entry_struct( pub fn new(global: &GlobalScope, name: DOMString, start_time: f64, - duration: f64) -> Root<$struct> { + duration: f64) -> DomRoot<$struct> { let entry = $struct::new_inherited(name, start_time, duration); reflect_dom_object(box entry, global, $binding::Wrap) } diff --git a/servo/components/script/dom/mediaerror.rs b/servo/components/script/dom/mediaerror.rs index ff158333473e..5787085e9fc7 100644 --- a/servo/components/script/dom/mediaerror.rs +++ b/servo/components/script/dom/mediaerror.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::MediaErrorBinding::{self, MediaErrorMethods}; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::window::Window; use dom_struct::dom_struct; @@ -22,7 +22,7 @@ impl MediaError { } } - pub fn new(window: &Window, code: u16) -> Root { + pub fn new(window: &Window, code: u16) -> DomRoot { reflect_dom_object(box MediaError::new_inherited(code), window, MediaErrorBinding::Wrap) diff --git a/servo/components/script/dom/medialist.rs b/servo/components/script/dom/medialist.rs index f737ecc9d2ed..8b67de260719 100644 --- a/servo/components/script/dom/medialist.rs +++ b/servo/components/script/dom/medialist.rs @@ -6,8 +6,8 @@ use cssparser::{Parser, ParserInput}; use dom::bindings::codegen::Bindings::MediaListBinding; use dom::bindings::codegen::Bindings::MediaListBinding::MediaListMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; @@ -23,7 +23,7 @@ use style_traits::{PARSING_MODE_DEFAULT, ToCss}; #[dom_struct] pub struct MediaList { reflector_: Reflector, - parent_stylesheet: JS, + parent_stylesheet: Dom, #[ignore_heap_size_of = "Arc"] media_queries: Arc>, } @@ -33,7 +33,7 @@ impl MediaList { pub fn new_inherited(parent_stylesheet: &CSSStyleSheet, media_queries: Arc>) -> MediaList { MediaList { - parent_stylesheet: JS::from_ref(parent_stylesheet), + parent_stylesheet: Dom::from_ref(parent_stylesheet), reflector_: Reflector::new(), media_queries: media_queries, } @@ -42,7 +42,7 @@ impl MediaList { #[allow(unrooted_must_root)] pub fn new(window: &Window, parent_stylesheet: &CSSStyleSheet, media_queries: Arc>) - -> Root { + -> DomRoot { reflect_dom_object(box MediaList::new_inherited(parent_stylesheet, media_queries), window, MediaListBinding::Wrap) diff --git a/servo/components/script/dom/mediaquerylist.rs b/servo/components/script/dom/mediaquerylist.rs index d80354645de4..33eb2dc92d53 100644 --- a/servo/components/script/dom/mediaquerylist.rs +++ b/servo/components/script/dom/mediaquerylist.rs @@ -2,14 +2,14 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods; use dom::bindings::codegen::Bindings::MediaQueryListBinding::{self, MediaQueryListMethods}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::DomObject; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; use dom::bindings::weakref::{WeakRef, WeakRefVec}; @@ -32,7 +32,7 @@ pub enum MediaQueryListMatchState { #[dom_struct] pub struct MediaQueryList { eventtarget: EventTarget, - document: JS, + document: Dom, media_query_list: MediaList, last_match_state: Cell> } @@ -41,13 +41,13 @@ impl MediaQueryList { fn new_inherited(document: &Document, media_query_list: MediaList) -> MediaQueryList { MediaQueryList { eventtarget: EventTarget::new_inherited(), - document: JS::from_ref(document), + document: Dom::from_ref(document), media_query_list: media_query_list, last_match_state: Cell::new(None), } } - pub fn new(document: &Document, media_query_list: MediaList) -> Root { + pub fn new(document: &Document, media_query_list: MediaList) -> DomRoot { reflect_dom_object(box MediaQueryList::new_inherited(document, media_query_list), document.window(), MediaQueryListBinding::Wrap) @@ -113,13 +113,13 @@ impl MediaQueryListMethods for MediaQueryList { #[derive(HeapSizeOf)] pub struct WeakMediaQueryListVec { - cell: DOMRefCell>, + cell: DomRefCell>, } impl WeakMediaQueryListVec { /// Create a new vector of weak references to MediaQueryList pub fn new() -> Self { - WeakMediaQueryListVec { cell: DOMRefCell::new(WeakRefVec::new()) } + WeakMediaQueryListVec { cell: DomRefCell::new(WeakRefVec::new()) } } pub fn push(&self, mql: &MediaQueryList) { @@ -134,7 +134,7 @@ impl WeakMediaQueryListVec { let mql = mql.root().unwrap(); if let MediaQueryListMatchState::Changed(_) = mql.evaluate_changes() { // Recording list of changed Media Queries - mql_list.push(JS::from_ref(&*mql)); + mql_list.push(Dom::from_ref(&*mql)); } }); // Sending change events for all changed Media Queries diff --git a/servo/components/script/dom/mediaquerylistevent.rs b/servo/components/script/dom/mediaquerylistevent.rs index 18be8b1d1b54..8eb1c8a3520b 100644 --- a/servo/components/script/dom/mediaquerylistevent.rs +++ b/servo/components/script/dom/mediaquerylistevent.rs @@ -8,8 +8,8 @@ use dom::bindings::codegen::Bindings::MediaQueryListEventBinding::MediaQueryList use dom::bindings::codegen::Bindings::MediaQueryListEventBinding::MediaQueryListEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::Event; use dom::globalscope::GlobalScope; @@ -29,7 +29,7 @@ pub struct MediaQueryListEvent { impl MediaQueryListEvent { pub fn new_initialized(global: &GlobalScope, media: DOMString, - matches: bool) -> Root { + matches: bool) -> DomRoot { let ev = box MediaQueryListEvent { event: Event::new_inherited(), media: media, @@ -40,7 +40,7 @@ impl MediaQueryListEvent { pub fn new(global: &GlobalScope, type_: Atom, bubbles: bool, cancelable: bool, - media: DOMString, matches: bool) -> Root { + media: DOMString, matches: bool) -> DomRoot { let ev = MediaQueryListEvent::new_initialized(global, media, matches); { let event = ev.upcast::(); @@ -51,7 +51,7 @@ impl MediaQueryListEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &MediaQueryListEventInit) - -> Fallible> { + -> Fallible> { let global = window.upcast::(); Ok(MediaQueryListEvent::new(global, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/servo/components/script/dom/messageevent.rs b/servo/components/script/dom/messageevent.rs index 4b49840b9c4e..cab9e245f8a1 100644 --- a/servo/components/script/dom/messageevent.rs +++ b/servo/components/script/dom/messageevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::MessageEventBinding; use dom::bindings::codegen::Bindings::MessageEventBinding::MessageEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::bindings::trace::RootedTraceableBox; use dom::event::Event; @@ -28,7 +28,7 @@ pub struct MessageEvent { } impl MessageEvent { - pub fn new_uninitialized(global: &GlobalScope) -> Root { + pub fn new_uninitialized(global: &GlobalScope) -> DomRoot { MessageEvent::new_initialized(global, HandleValue::undefined(), DOMString::new(), @@ -38,7 +38,7 @@ impl MessageEvent { pub fn new_initialized(global: &GlobalScope, data: HandleValue, origin: DOMString, - lastEventId: DOMString) -> Root { + lastEventId: DOMString) -> DomRoot { let ev = box MessageEvent { event: Event::new_inherited(), data: Heap::default(), @@ -54,7 +54,7 @@ impl MessageEvent { pub fn new(global: &GlobalScope, type_: Atom, bubbles: bool, cancelable: bool, data: HandleValue, origin: DOMString, lastEventId: DOMString) - -> Root { + -> DomRoot { let ev = MessageEvent::new_initialized(global, data, origin, lastEventId); { let event = ev.upcast::(); @@ -66,7 +66,7 @@ impl MessageEvent { pub fn Constructor(global: &GlobalScope, type_: DOMString, init: RootedTraceableBox) - -> Fallible> { + -> Fallible> { let ev = MessageEvent::new(global, Atom::from(type_), init.parent.bubbles, diff --git a/servo/components/script/dom/mimetype.rs b/servo/components/script/dom/mimetype.rs index daa499084082..ecef40321e55 100644 --- a/servo/components/script/dom/mimetype.rs +++ b/servo/components/script/dom/mimetype.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::MimeTypeBinding::MimeTypeMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::Reflector; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::plugin::Plugin; use dom_struct::dom_struct; @@ -31,7 +31,7 @@ impl MimeTypeMethods for MimeType { } // https://html.spec.whatwg.org/multipage/#dom-mimetype-enabledplugin - fn EnabledPlugin(&self) -> Root { + fn EnabledPlugin(&self) -> DomRoot { unreachable!() } } diff --git a/servo/components/script/dom/mimetypearray.rs b/servo/components/script/dom/mimetypearray.rs index 4bc33e9b2373..7a195e3fe7f6 100644 --- a/servo/components/script/dom/mimetypearray.rs +++ b/servo/components/script/dom/mimetypearray.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::MimeTypeArrayBinding; use dom::bindings::codegen::Bindings::MimeTypeArrayBinding::MimeTypeArrayMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom::mimetype::MimeType; @@ -23,7 +23,7 @@ impl MimeTypeArray { } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box MimeTypeArray::new_inherited(), global, MimeTypeArrayBinding::Wrap) @@ -37,22 +37,22 @@ impl MimeTypeArrayMethods for MimeTypeArray { } // https://html.spec.whatwg.org/multipage/#dom-mimetypearray-item - fn Item(&self, _index: u32) -> Option> { + fn Item(&self, _index: u32) -> Option> { None } // https://html.spec.whatwg.org/multipage/#dom-mimetypearray-nameditem - fn NamedItem(&self, _name: DOMString) -> Option> { + fn NamedItem(&self, _name: DOMString) -> Option> { None } // https://html.spec.whatwg.org/multipage/#dom-mimetypearray-item - fn IndexedGetter(&self, _index: u32) -> Option> { + fn IndexedGetter(&self, _index: u32) -> Option> { None } // check-tidy: no specs after this line - fn NamedGetter(&self, _name: DOMString) -> Option> { + fn NamedGetter(&self, _name: DOMString) -> Option> { None } diff --git a/servo/components/script/dom/mod.rs b/servo/components/script/dom/mod.rs index a088b1ae96a4..6866efd17d02 100644 --- a/servo/components/script/dom/mod.rs +++ b/servo/components/script/dom/mod.rs @@ -30,10 +30,10 @@ //! For more information, see: //! //! * rooting pointers on the stack: -//! the [`Root`](bindings/js/struct.Root.html) smart pointer; -//! * tracing pointers in member fields: the [`JS`](bindings/js/struct.JS.html), -//! [`MutNullableJS`](bindings/js/struct.MutNullableJS.html) and -//! [`MutJS`](bindings/js/struct.MutJS.html) smart pointers and +//! the [`Root`](bindings/root/struct.Root.html) smart pointer; +//! * tracing pointers in member fields: the [`Dom`](bindings/root/struct.Dom.html), +//! [`MutNullableDom`](bindings/root/struct.MutNullableDom.html) and +//! [`MutDom`](bindings/root/struct.MutDom.html) smart pointers and //! [the tracing implementation](bindings/trace/index.html); //! * rooting pointers from across thread boundaries or in channels: the //! [`Trusted`](bindings/refcounted/struct.Trusted.html) smart pointer; @@ -44,7 +44,7 @@ //! Rust does not support struct inheritance, as would be used for the //! object-oriented DOM APIs. To work around this issue, Servo stores an //! instance of the superclass in the first field of its subclasses. (Note that -//! it is stored by value, rather than in a smart pointer such as `JS`.) +//! it is stored by value, rather than in a smart pointer such as `Dom`.) //! //! This implies that a pointer to an object can safely be cast to a pointer //! to all its classes. @@ -94,7 +94,7 @@ //! DOM objects of type `T` in Servo have two constructors: //! //! * a `T::new_inherited` static method that returns a plain `T`, and -//! * a `T::new` static method that returns `Root`. +//! * a `T::new` static method that returns `DomRoot`. //! //! (The result of either method can be wrapped in `Result`, if that is //! appropriate for the type in question.) @@ -123,7 +123,7 @@ //! //! Reflectors are JavaScript objects, and as such can be freely aliased. As //! Rust does not allow mutable aliasing, mutable borrows of DOM objects are -//! not allowed. In particular, any mutable fields use `Cell` or `DOMRefCell` +//! not allowed. In particular, any mutable fields use `Cell` or `DomRefCell` //! to manage their mutability. //! //! `Reflector` and `DomObject` @@ -195,11 +195,11 @@ //! ================================= //! //! Layout code can access the DOM through the -//! [`LayoutJS`](bindings/js/struct.LayoutJS.html) smart pointer. This does not +//! [`LayoutDom`](bindings/root/struct.LayoutDom.html) smart pointer. This does not //! keep the DOM object alive; we ensure that no DOM code (Garbage Collection //! in particular) runs while the layout thread is accessing the DOM. //! -//! Methods accessible to layout are implemented on `LayoutJS` using +//! Methods accessible to layout are implemented on `LayoutDom` using //! `LayoutFooHelpers` traits. #[macro_use] diff --git a/servo/components/script/dom/mouseevent.rs b/servo/components/script/dom/mouseevent.rs index f19c37df868b..2fa79f433868 100644 --- a/servo/components/script/dom/mouseevent.rs +++ b/servo/components/script/dom/mouseevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::eventtarget::EventTarget; @@ -31,7 +31,7 @@ pub struct MouseEvent { alt_key: Cell, meta_key: Cell, button: Cell, - related_target: MutNullableJS, + related_target: MutNullableDom, } impl MouseEvent { @@ -51,7 +51,7 @@ impl MouseEvent { } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { reflect_dom_object(box MouseEvent::new_inherited(), window, MouseEventBinding::Wrap) @@ -72,7 +72,7 @@ impl MouseEvent { shift_key: bool, meta_key: bool, button: i16, - related_target: Option<&EventTarget>) -> Root { + related_target: Option<&EventTarget>) -> DomRoot { let ev = MouseEvent::new_uninitialized(window); ev.InitMouseEvent(type_, bool::from(can_bubble), bool::from(cancelable), view, detail, @@ -84,7 +84,7 @@ impl MouseEvent { pub fn Constructor(window: &Window, type_: DOMString, - init: &MouseEventBinding::MouseEventInit) -> Fallible> { + init: &MouseEventBinding::MouseEventInit) -> Fallible> { let bubbles = EventBubbles::from(init.parent.parent.parent.bubbles); let cancelable = EventCancelable::from(init.parent.parent.parent.cancelable); let event = MouseEvent::new(window, @@ -148,7 +148,7 @@ impl MouseEventMethods for MouseEvent { } // https://w3c.github.io/uievents/#widl-MouseEvent-relatedTarget - fn GetRelatedTarget(&self) -> Option> { + fn GetRelatedTarget(&self) -> Option> { self.related_target.get() } diff --git a/servo/components/script/dom/mutationobserver.rs b/servo/components/script/dom/mutationobserver.rs index 84d34af0149c..72996a782899 100644 --- a/servo/components/script/dom/mutationobserver.rs +++ b/servo/components/script/dom/mutationobserver.rs @@ -3,14 +3,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::callback::ExceptionHandling; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::MutationObserverBinding; use dom::bindings::codegen::Bindings::MutationObserverBinding::MutationCallback; use dom::bindings::codegen::Bindings::MutationObserverBinding::MutationObserverBinding::MutationObserverMethods; use dom::bindings::codegen::Bindings::MutationObserverBinding::MutationObserverInit; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::mutationrecord::MutationRecord; use dom::node::Node; @@ -26,7 +26,7 @@ pub struct MutationObserver { reflector_: Reflector, #[ignore_heap_size_of = "can't measure Rc values"] callback: Rc, - record_queue: DOMRefCell>>, + record_queue: DomRefCell>>, } pub enum Mutation<'a> { @@ -37,7 +37,7 @@ pub enum Mutation<'a> { #[derive(HeapSizeOf, JSTraceable)] pub struct RegisteredObserver { - observer: Root, + observer: DomRoot, options: ObserverOptions, } @@ -53,7 +53,7 @@ pub struct ObserverOptions { } impl MutationObserver { - fn new(global: &Window, callback: Rc) -> Root { + fn new(global: &Window, callback: Rc) -> DomRoot { let boxed_observer = box MutationObserver::new_inherited(callback); reflect_dom_object(boxed_observer, global, MutationObserverBinding::Wrap) } @@ -62,11 +62,11 @@ impl MutationObserver { MutationObserver { reflector_: Reflector::new(), callback: callback, - record_queue: DOMRefCell::new(vec![]), + record_queue: DomRefCell::new(vec![]), } } - pub fn Constructor(global: &Window, callback: Rc) -> Fallible> { + pub fn Constructor(global: &Window, callback: Rc) -> Fallible> { let observer = MutationObserver::new(global, callback); ScriptThread::add_mutation_observer(&*observer); Ok(observer) @@ -93,7 +93,7 @@ impl MutationObserver { // TODO: steps 3-4 (slots) // Step 5 for mo in ¬ify_list { - let queue: Vec> = mo.record_queue.borrow().clone(); + let queue: Vec> = mo.record_queue.borrow().clone(); mo.record_queue.borrow_mut().clear(); // TODO: Step 5.3 Remove all transient registered observers whose observer is mo. if !queue.is_empty() { @@ -106,7 +106,7 @@ impl MutationObserver { /// https://dom.spec.whatwg.org/#queueing-a-mutation-record pub fn queue_a_mutation_record(target: &Node, attr_type: Mutation) { // Step 1 - let mut interestedObservers: Vec<(Root, Option)> = vec![]; + let mut interestedObservers: Vec<(DomRoot, Option)> = vec![]; // Step 2 & 3 for node in target.inclusive_ancestors() { for registered in &*node.registered_mutation_observers() { @@ -141,7 +141,7 @@ impl MutationObserver { if let Some(idx) = idx { interestedObservers[idx].1 = paired_string; } else { - interestedObservers.push((Root::from_ref(&*registered.observer), + interestedObservers.push((DomRoot::from_ref(&*registered.observer), paired_string)); } }, @@ -149,7 +149,7 @@ impl MutationObserver { if !registered.options.child_list { continue; } - interestedObservers.push((Root::from_ref(&*registered.observer), None)); + interestedObservers.push((DomRoot::from_ref(&*registered.observer), None)); } } } @@ -246,7 +246,7 @@ impl MutationObserverMethods for MutationObserver { // Step 8 if add_new_observer { target.registered_mutation_observers().push(RegisteredObserver { - observer: Root::from_ref(self), + observer: DomRoot::from_ref(self), options: ObserverOptions { attributes, attribute_old_value, diff --git a/servo/components/script/dom/mutationrecord.rs b/servo/components/script/dom/mutationrecord.rs index 00d96e258c4c..a3b381821477 100644 --- a/servo/components/script/dom/mutationrecord.rs +++ b/servo/components/script/dom/mutationrecord.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::MutationRecordBinding::MutationRecordBinding; use dom::bindings::codegen::Bindings::MutationRecordBinding::MutationRecordBinding::MutationRecordMethods; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::node::{Node, window_from_node}; use dom::nodelist::NodeList; @@ -16,14 +16,14 @@ use html5ever::{LocalName, Namespace}; pub struct MutationRecord { reflector_: Reflector, record_type: DOMString, - target: JS, + target: Dom, attribute_name: Option, attribute_namespace: Option, old_value: Option, - added_nodes: MutNullableJS, - removed_nodes: MutNullableJS, - next_sibling: Option>, - prev_sibling: Option>, + added_nodes: MutNullableDom, + removed_nodes: MutNullableDom, + next_sibling: Option>, + prev_sibling: Option>, } impl MutationRecord { @@ -31,7 +31,7 @@ impl MutationRecord { pub fn attribute_mutated(target: &Node, attribute_name: &LocalName, attribute_namespace: Option<&Namespace>, - old_value: Option) -> Root { + old_value: Option) -> DomRoot { let record = box MutationRecord::new_inherited("attributes", target, Some(DOMString::from(&**attribute_name)), @@ -45,7 +45,7 @@ impl MutationRecord { added_nodes: Option<&[&Node]>, removed_nodes: Option<&[&Node]>, next_sibling: Option<&Node>, - prev_sibling: Option<&Node>) -> Root { + prev_sibling: Option<&Node>) -> DomRoot { let window = window_from_node(target); let added_nodes = added_nodes.map(|list| NodeList::new_simple_list_slice(&window, list)); let removed_nodes = removed_nodes.map(|list| NodeList::new_simple_list_slice(&window, list)); @@ -73,14 +73,14 @@ impl MutationRecord { MutationRecord { reflector_: Reflector::new(), record_type: DOMString::from(record_type), - target: JS::from_ref(target), + target: Dom::from_ref(target), attribute_name: attribute_name, attribute_namespace: attribute_namespace, old_value: old_value, - added_nodes: MutNullableJS::new(added_nodes), - removed_nodes: MutNullableJS::new(removed_nodes), - next_sibling: next_sibling.map(JS::from_ref), - prev_sibling: prev_sibling.map(JS::from_ref), + added_nodes: MutNullableDom::new(added_nodes), + removed_nodes: MutNullableDom::new(removed_nodes), + next_sibling: next_sibling.map(Dom::from_ref), + prev_sibling: prev_sibling.map(Dom::from_ref), } } } @@ -92,8 +92,8 @@ impl MutationRecordMethods for MutationRecord { } // https://dom.spec.whatwg.org/#dom-mutationrecord-target - fn Target(&self) -> Root { - Root::from_ref(&*self.target) + fn Target(&self) -> DomRoot { + DomRoot::from_ref(&*self.target) } // https://dom.spec.whatwg.org/#dom-mutationrecord-attributename @@ -112,7 +112,7 @@ impl MutationRecordMethods for MutationRecord { } // https://dom.spec.whatwg.org/#dom-mutationrecord-addednodes - fn AddedNodes(&self) -> Root { + fn AddedNodes(&self) -> DomRoot { self.added_nodes.or_init(|| { let window = window_from_node(&*self.target); NodeList::empty(&window) @@ -120,7 +120,7 @@ impl MutationRecordMethods for MutationRecord { } // https://dom.spec.whatwg.org/#dom-mutationrecord-removednodes - fn RemovedNodes(&self) -> Root { + fn RemovedNodes(&self) -> DomRoot { self.removed_nodes.or_init(|| { let window = window_from_node(&*self.target); NodeList::empty(&window) @@ -128,13 +128,13 @@ impl MutationRecordMethods for MutationRecord { } // https://dom.spec.whatwg.org/#dom-mutationrecord-previoussibling - fn GetPreviousSibling(&self) -> Option> { - self.prev_sibling.as_ref().map(|node| Root::from_ref(&**node)) + fn GetPreviousSibling(&self) -> Option> { + self.prev_sibling.as_ref().map(|node| DomRoot::from_ref(&**node)) } // https://dom.spec.whatwg.org/#dom-mutationrecord-previoussibling - fn GetNextSibling(&self) -> Option> { - self.next_sibling.as_ref().map(|node| Root::from_ref(&**node)) + fn GetNextSibling(&self) -> Option> { + self.next_sibling.as_ref().map(|node| DomRoot::from_ref(&**node)) } } diff --git a/servo/components/script/dom/namednodemap.rs b/servo/components/script/dom/namednodemap.rs index 9d92bf11c2d2..023665371cfd 100644 --- a/servo/components/script/dom/namednodemap.rs +++ b/servo/components/script/dom/namednodemap.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::codegen::Bindings::NamedNodeMapBinding; use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::bindings::xmlname::namespace_from_domstring; use dom::element::Element; @@ -20,18 +20,18 @@ use std::ascii::AsciiExt; #[dom_struct] pub struct NamedNodeMap { reflector_: Reflector, - owner: JS, + owner: Dom, } impl NamedNodeMap { fn new_inherited(elem: &Element) -> NamedNodeMap { NamedNodeMap { reflector_: Reflector::new(), - owner: JS::from_ref(elem), + owner: Dom::from_ref(elem), } } - pub fn new(window: &Window, elem: &Element) -> Root { + pub fn new(window: &Window, elem: &Element) -> DomRoot { reflect_dom_object(box NamedNodeMap::new_inherited(elem), window, NamedNodeMapBinding::Wrap) } @@ -44,53 +44,53 @@ impl NamedNodeMapMethods for NamedNodeMap { } // https://dom.spec.whatwg.org/#dom-namednodemap-item - fn Item(&self, index: u32) -> Option> { - self.owner.attrs().get(index as usize).map(|js| Root::from_ref(&**js)) + fn Item(&self, index: u32) -> Option> { + self.owner.attrs().get(index as usize).map(|js| DomRoot::from_ref(&**js)) } // https://dom.spec.whatwg.org/#dom-namednodemap-getnameditem - fn GetNamedItem(&self, name: DOMString) -> Option> { + fn GetNamedItem(&self, name: DOMString) -> Option> { self.owner.get_attribute_by_name(name) } // https://dom.spec.whatwg.org/#dom-namednodemap-getnameditemns fn GetNamedItemNS(&self, namespace: Option, local_name: DOMString) - -> Option> { + -> Option> { let ns = namespace_from_domstring(namespace); self.owner.get_attribute(&ns, &LocalName::from(local_name)) } // https://dom.spec.whatwg.org/#dom-namednodemap-setnameditem - fn SetNamedItem(&self, attr: &Attr) -> Fallible>> { + fn SetNamedItem(&self, attr: &Attr) -> Fallible>> { self.owner.SetAttributeNode(attr) } // https://dom.spec.whatwg.org/#dom-namednodemap-setnameditemns - fn SetNamedItemNS(&self, attr: &Attr) -> Fallible>> { + fn SetNamedItemNS(&self, attr: &Attr) -> Fallible>> { self.SetNamedItem(attr) } // https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem - fn RemoveNamedItem(&self, name: DOMString) -> Fallible> { + fn RemoveNamedItem(&self, name: DOMString) -> Fallible> { let name = self.owner.parsed_name(name); self.owner.remove_attribute_by_name(&name).ok_or(Error::NotFound) } // https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns fn RemoveNamedItemNS(&self, namespace: Option, local_name: DOMString) - -> Fallible> { + -> Fallible> { let ns = namespace_from_domstring(namespace); self.owner.remove_attribute(&ns, &LocalName::from(local_name)) .ok_or(Error::NotFound) } // https://dom.spec.whatwg.org/#dom-namednodemap-item - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } // check-tidy: no specs after this line - fn NamedGetter(&self, name: DOMString) -> Option> { + fn NamedGetter(&self, name: DOMString) -> Option> { self.GetNamedItem(name) } diff --git a/servo/components/script/dom/navigator.rs b/servo/components/script/dom/navigator.rs index 4d0b38f78b37..5d3e41dc4212 100644 --- a/servo/components/script/dom/navigator.rs +++ b/servo/components/script/dom/navigator.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::NavigatorBinding; use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods; use dom::bindings::codegen::Bindings::VRBinding::VRBinding::VRMethods; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{Reflector, DomObject, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::bluetooth::Bluetooth; use dom::gamepadlist::GamepadList; @@ -24,13 +24,13 @@ use std::rc::Rc; #[dom_struct] pub struct Navigator { reflector_: Reflector, - bluetooth: MutNullableJS, - plugins: MutNullableJS, - mime_types: MutNullableJS, - service_worker: MutNullableJS, - vr: MutNullableJS, - gamepads: MutNullableJS, - permissions: MutNullableJS, + bluetooth: MutNullableDom, + plugins: MutNullableDom, + mime_types: MutNullableDom, + service_worker: MutNullableDom, + vr: MutNullableDom, + gamepads: MutNullableDom, + permissions: MutNullableDom, } impl Navigator { @@ -47,7 +47,7 @@ impl Navigator { } } - pub fn new(window: &Window) -> Root { + pub fn new(window: &Window) -> DomRoot { reflect_dom_object(box Navigator::new_inherited(), window, NavigatorBinding::Wrap) @@ -91,7 +91,7 @@ impl NavigatorMethods for Navigator { } // https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth - fn Bluetooth(&self) -> Root { + fn Bluetooth(&self) -> DomRoot { self.bluetooth.or_init(|| Bluetooth::new(&self.global())) } @@ -101,12 +101,12 @@ impl NavigatorMethods for Navigator { } // https://html.spec.whatwg.org/multipage/#dom-navigator-plugins - fn Plugins(&self) -> Root { + fn Plugins(&self) -> DomRoot { self.plugins.or_init(|| PluginArray::new(&self.global())) } // https://html.spec.whatwg.org/multipage/#dom-navigator-mimetypes - fn MimeTypes(&self) -> Root { + fn MimeTypes(&self) -> DomRoot { self.mime_types.or_init(|| MimeTypeArray::new(&self.global())) } @@ -116,7 +116,7 @@ impl NavigatorMethods for Navigator { } // https://w3c.github.io/ServiceWorker/#navigator-service-worker-attribute - fn ServiceWorker(&self) -> Root { + fn ServiceWorker(&self) -> DomRoot { self.service_worker.or_init(|| { ServiceWorkerContainer::new(&self.global()) }) @@ -128,7 +128,7 @@ impl NavigatorMethods for Navigator { } // https://www.w3.org/TR/gamepad/#navigator-interface-extension - fn GetGamepads(&self) -> Root { + fn GetGamepads(&self) -> DomRoot { let root = self.gamepads.or_init(|| { GamepadList::new(&self.global(), &[]) }); @@ -139,7 +139,7 @@ impl NavigatorMethods for Navigator { root } // https://w3c.github.io/permissions/#navigator-and-workernavigator-extension - fn Permissions(&self) -> Root { + fn Permissions(&self) -> DomRoot { self.permissions.or_init(|| Permissions::new(&self.global())) } @@ -151,7 +151,7 @@ impl NavigatorMethods for Navigator { } impl Navigator { - pub fn Vr(&self) -> Root { + pub fn Vr(&self) -> DomRoot { self.vr.or_init(|| VR::new(&self.global())) } } diff --git a/servo/components/script/dom/node.rs b/servo/components/script/dom/node.rs index 77e499a6f5ab..a620d09433d5 100644 --- a/servo/components/script/dom/node.rs +++ b/servo/components/script/dom/node.rs @@ -7,7 +7,7 @@ use app_units::Au; use devtools_traits::NodeInfo; use document_loader::DocumentLoader; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; @@ -22,10 +22,8 @@ use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId}; use dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId}; use dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId}; -use dom::bindings::js::{JS, LayoutJS, MutNullableJS}; -use dom::bindings::js::Root; -use dom::bindings::js::RootedReference; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference}; use dom::bindings::str::{DOMString, USVString}; use dom::bindings::xmlname::namespace_from_domstring; use dom::characterdata::{CharacterData, LayoutCharacterDataHelpers}; @@ -100,25 +98,25 @@ pub struct Node { eventtarget: EventTarget, /// The parent of this node. - parent_node: MutNullableJS, + parent_node: MutNullableDom, /// The first child of this node. - first_child: MutNullableJS, + first_child: MutNullableDom, /// The last child of this node. - last_child: MutNullableJS, + last_child: MutNullableDom, /// The next sibling of this node. - next_sibling: MutNullableJS, + next_sibling: MutNullableDom, /// The previous sibling of this node. - prev_sibling: MutNullableJS, + prev_sibling: MutNullableDom, /// The document that this node belongs to. - owner_doc: MutNullableJS, + owner_doc: MutNullableDom, /// The live list of children return by .childNodes. - child_list: MutNullableJS, + child_list: MutNullableDom, /// The live count of children of this node. children_count: Cell, @@ -142,7 +140,7 @@ pub struct Node { style_and_layout_data: Cell>, /// Registered observers for this node. - mutation_observers: DOMRefCell>, + mutation_observers: DomRefCell>, unique_id: UniqueId, } @@ -329,10 +327,10 @@ impl Node { UntrustedNodeAddress(self.reflector().get_jsobject().get() as *const c_void) } - pub fn as_custom_element(&self) -> Option> { + pub fn as_custom_element(&self) -> Option> { self.downcast::() .and_then(|element| if element.get_custom_element_definition().is_some() { - Some(Root::from_ref(element)) + Some(DomRoot::from_ref(element)) } else { None }) @@ -355,9 +353,9 @@ impl<'a> QuerySelectorIterator { } impl<'a> Iterator for QuerySelectorIterator { - type Item = Root; + type Item = DomRoot; - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option> { let selectors = &self.selectors; self.iterator.by_ref().filter_map(|node| { @@ -367,9 +365,9 @@ impl<'a> Iterator for QuerySelectorIterator { // FIXME(bholley): Consider an nth-index cache here. let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None, node.owner_doc().quirks_mode()); - if let Some(element) = Root::downcast(node) { + if let Some(element) = DomRoot::downcast(node) { if matches_selector_list(selectors, &element, &mut ctx) { - return Some(Root::upcast(element)); + return Some(DomRoot::upcast(element)); } } None @@ -499,7 +497,7 @@ impl Node { // its descendants version, and the document's version. Normally, this will just be // the document's version, but we do have to deal with the case where the node has moved // document, so may have a higher version count than its owning document. - let doc: Root = Root::upcast(self.owner_doc()); + let doc: DomRoot = DomRoot::upcast(self.owner_doc()); let version = cmp::max(self.inclusive_descendants_version(), doc.inclusive_descendants_version()) + 1; for ancestor in self.inclusive_ancestors() { ancestor.inclusive_descendants_version.set(version); @@ -532,16 +530,16 @@ impl Node { TreeIterator::new(self) } - pub fn inclusively_following_siblings(&self) -> impl Iterator> { + pub fn inclusively_following_siblings(&self) -> impl Iterator> { SimpleNodeIterator { - current: Some(Root::from_ref(self)), + current: Some(DomRoot::from_ref(self)), next_node: |n| n.GetNextSibling(), } } - pub fn inclusively_preceding_siblings(&self) -> impl Iterator> { + pub fn inclusively_preceding_siblings(&self) -> impl Iterator> { SimpleNodeIterator { - current: Some(Root::from_ref(self)), + current: Some(DomRoot::from_ref(self)), next_node: |n| n.GetPreviousSibling(), } } @@ -554,14 +552,14 @@ impl Node { parent.ancestors().any(|ancestor| &*ancestor == self) } - pub fn following_siblings(&self) -> impl Iterator> { + pub fn following_siblings(&self) -> impl Iterator> { SimpleNodeIterator { current: self.GetNextSibling(), next_node: |n| n.GetNextSibling(), } } - pub fn preceding_siblings(&self) -> impl Iterator> { + pub fn preceding_siblings(&self) -> impl Iterator> { SimpleNodeIterator { current: self.GetPreviousSibling(), next_node: |n| n.GetPreviousSibling(), @@ -570,19 +568,19 @@ impl Node { pub fn following_nodes(&self, root: &Node) -> FollowingNodeIterator { FollowingNodeIterator { - current: Some(Root::from_ref(self)), - root: Root::from_ref(root), + current: Some(DomRoot::from_ref(self)), + root: DomRoot::from_ref(root), } } pub fn preceding_nodes(&self, root: &Node) -> PrecedingNodeIterator { PrecedingNodeIterator { - current: Some(Root::from_ref(self)), - root: Root::from_ref(root), + current: Some(DomRoot::from_ref(self)), + root: DomRoot::from_ref(root), } } - pub fn descending_last_children(&self) -> impl Iterator> { + pub fn descending_last_children(&self) -> impl Iterator> { SimpleNodeIterator { current: self.GetLastChild(), next_node: |n| n.GetLastChild(), @@ -749,7 +747,7 @@ impl Node { } // https://dom.spec.whatwg.org/#dom-parentnode-queryselector - pub fn query_selector(&self, selectors: DOMString) -> Fallible>> { + pub fn query_selector(&self, selectors: DOMString) -> Fallible>> { // Step 1. match SelectorParser::parse_author_origin_no_namespace(&selectors) { // Step 2. @@ -759,7 +757,7 @@ impl Node { // FIXME(bholley): Consider an nth-index cache here. let mut ctx = MatchingContext::new(MatchingMode::Normal, None, None, self.owner_doc().quirks_mode()); - Ok(self.traverse_preorder().filter_map(Root::downcast).find(|element| { + Ok(self.traverse_preorder().filter_map(DomRoot::downcast).find(|element| { matches_selector_list(&selectors, element, &mut ctx) })) } @@ -788,27 +786,27 @@ impl Node { // https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall #[allow(unsafe_code)] - pub fn query_selector_all(&self, selectors: DOMString) -> Fallible> { + pub fn query_selector_all(&self, selectors: DOMString) -> Fallible> { let window = window_from_node(self); let iter = self.query_selector_iter(selectors)?; Ok(NodeList::new_simple_list(&window, iter)) } - pub fn ancestors(&self) -> impl Iterator> { + pub fn ancestors(&self) -> impl Iterator> { SimpleNodeIterator { current: self.GetParentNode(), next_node: |n| n.GetParentNode(), } } - pub fn inclusive_ancestors(&self) -> impl Iterator> { + pub fn inclusive_ancestors(&self) -> impl Iterator> { SimpleNodeIterator { - current: Some(Root::from_ref(self)), + current: Some(DomRoot::from_ref(self)), next_node: |n| n.GetParentNode(), } } - pub fn owner_doc(&self) -> Root { + pub fn owner_doc(&self) -> DomRoot { self.owner_doc.get().unwrap() } @@ -824,22 +822,22 @@ impl Node { self.is_in_doc() && self.owner_doc().browsing_context().is_some() } - pub fn children(&self) -> impl Iterator> { + pub fn children(&self) -> impl Iterator> { SimpleNodeIterator { current: self.GetFirstChild(), next_node: |n| n.GetNextSibling(), } } - pub fn rev_children(&self) -> impl Iterator> { + pub fn rev_children(&self) -> impl Iterator> { SimpleNodeIterator { current: self.GetLastChild(), next_node: |n| n.GetPreviousSibling(), } } - pub fn child_elements(&self) -> impl Iterator> { - self.children().filter_map(Root::downcast as fn(_) -> _).peekable() + pub fn child_elements(&self) -> impl Iterator> { + self.children().filter_map(DomRoot::downcast as fn(_) -> _).peekable() } pub fn remove_self(&self) { @@ -880,9 +878,9 @@ impl Node { } /// Used by `HTMLTableSectionElement::InsertRow` and `HTMLTableRowElement::InsertCell` - pub fn insert_cell_or_row(&self, index: i32, get_items: F, new_child: G) -> Fallible> - where F: Fn() -> Root, - G: Fn() -> Root, + pub fn insert_cell_or_row(&self, index: i32, get_items: F, new_child: G) -> Fallible> + where F: Fn() -> DomRoot, + G: Fn() -> DomRoot, I: DerivedFrom + DerivedFrom + DomObject, { if index < -1 { @@ -899,7 +897,7 @@ impl Node { } else { let items = get_items(); let node = match items.elements_iter() - .map(Root::upcast::) + .map(DomRoot::upcast::) .map(Some) .chain(iter::once(None)) .nth(index as usize) { @@ -910,12 +908,12 @@ impl Node { } } - Ok(Root::upcast::(tr)) + Ok(DomRoot::upcast::(tr)) } /// Used by `HTMLTableSectionElement::DeleteRow` and `HTMLTableRowElement::DeleteCell` pub fn delete_cell_or_row(&self, index: i32, get_items: F, is_delete_type: G) -> ErrorResult - where F: Fn() -> Root, + where F: Fn() -> DomRoot, G: Fn(&Element) -> bool { let element = match index { @@ -923,7 +921,7 @@ impl Node { -1 => { let last_child = self.upcast::().GetLastChild(); match last_child.and_then(|node| node.inclusively_preceding_siblings() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .filter(|elem| is_delete_type(elem)) .next()) { Some(element) => element, @@ -952,7 +950,7 @@ impl Node { } } - pub fn get_cssom_stylesheet(&self) -> Option> { + pub fn get_cssom_stylesheet(&self) -> Option> { if let Some(node) = self.downcast::() { node.get_cssom_stylesheet() } else if let Some(node) = self.downcast::() { @@ -967,8 +965,8 @@ impl Node { /// Iterate through `nodes` until we find a `Node` that is not in `not_in` -fn first_node_not_in(mut nodes: I, not_in: &[NodeOrString]) -> Option> - where I: Iterator> +fn first_node_not_in(mut nodes: I, not_in: &[NodeOrString]) -> Option> + where I: Iterator> { nodes.find(|node| { not_in.iter().all(|n| { @@ -984,30 +982,30 @@ fn first_node_not_in(mut nodes: I, not_in: &[NodeOrString]) -> Option Root { + -> DomRoot { // https://github.com/servo/servo/issues/6383 let candidate: uintptr_t = mem::transmute(candidate.0); // let object: *mut JSObject = jsfriendapi::bindgen::JS_GetAddressableObject(runtime, // candidate); let object: *mut JSObject = mem::transmute(candidate); if object.is_null() { - panic!("Attempted to create a `JS` from an invalid pointer!") + panic!("Attempted to create a `Dom` from an invalid pointer!") } let boxed_node = conversions::private_from_object(object) as *const Node; - Root::from_ref(&*boxed_node) + DomRoot::from_ref(&*boxed_node) } #[allow(unsafe_code)] pub trait LayoutNodeHelpers { unsafe fn type_id_for_layout(&self) -> NodeTypeId; - unsafe fn parent_node_ref(&self) -> Option>; - unsafe fn first_child_ref(&self) -> Option>; - unsafe fn last_child_ref(&self) -> Option>; - unsafe fn prev_sibling_ref(&self) -> Option>; - unsafe fn next_sibling_ref(&self) -> Option>; + unsafe fn parent_node_ref(&self) -> Option>; + unsafe fn first_child_ref(&self) -> Option>; + unsafe fn last_child_ref(&self) -> Option>; + unsafe fn prev_sibling_ref(&self) -> Option>; + unsafe fn next_sibling_ref(&self) -> Option>; - unsafe fn owner_doc_for_layout(&self) -> LayoutJS; + unsafe fn owner_doc_for_layout(&self) -> LayoutDom; unsafe fn is_element_for_layout(&self) -> bool; unsafe fn get_flag(&self, flag: NodeFlags) -> bool; @@ -1029,7 +1027,7 @@ pub trait LayoutNodeHelpers { fn opaque(&self) -> OpaqueNode; } -impl LayoutNodeHelpers for LayoutJS { +impl LayoutNodeHelpers for LayoutDom { #[inline] #[allow(unsafe_code)] unsafe fn type_id_for_layout(&self) -> NodeTypeId { @@ -1044,37 +1042,37 @@ impl LayoutNodeHelpers for LayoutJS { #[inline] #[allow(unsafe_code)] - unsafe fn parent_node_ref(&self) -> Option> { + unsafe fn parent_node_ref(&self) -> Option> { (*self.unsafe_get()).parent_node.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn first_child_ref(&self) -> Option> { + unsafe fn first_child_ref(&self) -> Option> { (*self.unsafe_get()).first_child.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn last_child_ref(&self) -> Option> { + unsafe fn last_child_ref(&self) -> Option> { (*self.unsafe_get()).last_child.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn prev_sibling_ref(&self) -> Option> { + unsafe fn prev_sibling_ref(&self) -> Option> { (*self.unsafe_get()).prev_sibling.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn next_sibling_ref(&self) -> Option> { + unsafe fn next_sibling_ref(&self) -> Option> { (*self.unsafe_get()).next_sibling.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn owner_doc_for_layout(&self) -> LayoutJS { + unsafe fn owner_doc_for_layout(&self) -> LayoutDom { (*self.unsafe_get()).owner_doc.get_inner_as_layout().unwrap() } @@ -1201,13 +1199,13 @@ impl LayoutNodeHelpers for LayoutJS { // pub struct FollowingNodeIterator { - current: Option>, - root: Root, + current: Option>, + root: DomRoot, } impl FollowingNodeIterator { /// Skips iterating the children of the current node - pub fn next_skipping_children(&mut self) -> Option> { + pub fn next_skipping_children(&mut self) -> Option> { let current = match self.current.take() { None => return None, Some(current) => current, @@ -1216,7 +1214,7 @@ impl FollowingNodeIterator { self.next_skipping_children_impl(current) } - fn next_skipping_children_impl(&mut self, current: Root) -> Option> { + fn next_skipping_children_impl(&mut self, current: DomRoot) -> Option> { if self.root == current { self.current = None; return None; @@ -1242,10 +1240,10 @@ impl FollowingNodeIterator { } impl Iterator for FollowingNodeIterator { - type Item = Root; + type Item = DomRoot; // https://dom.spec.whatwg.org/#concept-tree-following - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option> { let current = match self.current.take() { None => return None, Some(current) => current, @@ -1261,15 +1259,15 @@ impl Iterator for FollowingNodeIterator { } pub struct PrecedingNodeIterator { - current: Option>, - root: Root, + current: Option>, + root: DomRoot, } impl Iterator for PrecedingNodeIterator { - type Item = Root; + type Item = DomRoot; // https://dom.spec.whatwg.org/#concept-tree-preceding - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option> { let current = match self.current.take() { None => return None, Some(current) => current, @@ -1293,16 +1291,16 @@ impl Iterator for PrecedingNodeIterator { } struct SimpleNodeIterator - where I: Fn(&Node) -> Option> + where I: Fn(&Node) -> Option> { - current: Option>, + current: Option>, next_node: I, } impl Iterator for SimpleNodeIterator - where I: Fn(&Node) -> Option> + where I: Fn(&Node) -> Option> { - type Item = Root; + type Item = DomRoot; fn next(&mut self) -> Option { let current = self.current.take(); @@ -1312,19 +1310,19 @@ impl Iterator for SimpleNodeIterator } pub struct TreeIterator { - current: Option>, + current: Option>, depth: usize, } impl TreeIterator { fn new(root: &Node) -> TreeIterator { TreeIterator { - current: Some(Root::from_ref(root)), + current: Some(DomRoot::from_ref(root)), depth: 0, } } - pub fn next_skipping_children(&mut self) -> Option> { + pub fn next_skipping_children(&mut self) -> Option> { let current = match self.current.take() { None => return None, Some(current) => current, @@ -1333,7 +1331,7 @@ impl TreeIterator { self.next_skipping_children_impl(current) } - fn next_skipping_children_impl(&mut self, current: Root) -> Option> { + fn next_skipping_children_impl(&mut self, current: DomRoot) -> Option> { for ancestor in current.inclusive_ancestors() { if self.depth == 0 { break; @@ -1351,10 +1349,10 @@ impl TreeIterator { } impl Iterator for TreeIterator { - type Item = Root; + type Item = DomRoot; // https://dom.spec.whatwg.org/#concept-tree-order - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option> { let current = match self.current.take() { None => return None, Some(current) => current, @@ -1382,8 +1380,8 @@ impl Node { pub fn reflect_node( node: Box, document: &Document, - wrap_fn: unsafe extern "Rust" fn(*mut JSContext, &GlobalScope, Box) -> Root) - -> Root + wrap_fn: unsafe extern "Rust" fn(*mut JSContext, &GlobalScope, Box) -> DomRoot) + -> DomRoot where N: DerivedFrom + DomObject { let window = document.window(); @@ -1409,7 +1407,7 @@ impl Node { last_child: Default::default(), next_sibling: Default::default(), prev_sibling: Default::default(), - owner_doc: MutNullableJS::new(doc), + owner_doc: MutNullableDom::new(doc), child_list: Default::default(), children_count: Cell::new(0u32), flags: Cell::new(flags), @@ -1439,7 +1437,7 @@ impl Node { for descendant in node.traverse_preorder().filter_map(|d| d.as_custom_element()) { // Step 3.2. ScriptThread::enqueue_callback_reaction(&*descendant, - CallbackReaction::Adopted(old_doc.clone(), Root::from_ref(document)), None); + CallbackReaction::Adopted(old_doc.clone(), DomRoot::from_ref(document)), None); } for descendant in node.traverse_preorder() { // Step 3.3. @@ -1564,7 +1562,7 @@ impl Node { // https://dom.spec.whatwg.org/#concept-node-pre-insert pub fn pre_insert(node: &Node, parent: &Node, child: Option<&Node>) - -> Fallible> { + -> Fallible> { // Step 1. Node::ensure_pre_insertion_validity(node, parent, child)?; @@ -1586,7 +1584,7 @@ impl Node { Node::insert(node, parent, reference_child, SuppressObserver::Unsuppressed); // Step 6. - Ok(Root::from_ref(node)) + Ok(DomRoot::from_ref(node)) } // https://dom.spec.whatwg.org/#concept-node-insert @@ -1614,7 +1612,7 @@ impl Node { rooted_vec!(let mut new_nodes); let new_nodes = if let NodeTypeId::DocumentFragment = node.type_id() { // Step 3. - new_nodes.extend(node.children().map(|kid| JS::from_ref(&*kid))); + new_nodes.extend(node.children().map(|kid| Dom::from_ref(&*kid))); // Step 4. for kid in new_nodes.r() { Node::remove(*kid, node, SuppressObserver::Suppressed); @@ -1650,7 +1648,7 @@ impl Node { // Step 7.1. parent.add_child(*kid, child); // Step 7.7. - for descendant in kid.traverse_preorder().filter_map(Root::downcast::) { + for descendant in kid.traverse_preorder().filter_map(DomRoot::downcast::) { // Step 7.7.2. if descendant.is_connected() { if descendant.get_custom_element_definition().is_some() { @@ -1689,7 +1687,7 @@ impl Node { rooted_vec!(let mut added_nodes); let added_nodes = if let Some(node) = node.as_ref() { if let NodeTypeId::DocumentFragment = node.type_id() { - added_nodes.extend(node.children().map(|child| JS::from_ref(&*child))); + added_nodes.extend(node.children().map(|child| Dom::from_ref(&*child))); added_nodes.r() } else { ref_slice(node) @@ -1721,7 +1719,7 @@ impl Node { } // https://dom.spec.whatwg.org/#concept-node-pre-remove - fn pre_remove(child: &Node, parent: &Node) -> Fallible> { + fn pre_remove(child: &Node, parent: &Node) -> Fallible> { // Step 1. match child.GetParentNode() { Some(ref node) if &**node != parent => return Err(Error::NotFound), @@ -1733,7 +1731,7 @@ impl Node { Node::remove(child, parent, SuppressObserver::Unsuppressed); // Step 3. - Ok(Root::from_ref(child)) + Ok(DomRoot::from_ref(child)) } // https://dom.spec.whatwg.org/#concept-node-remove @@ -1782,27 +1780,27 @@ impl Node { // https://dom.spec.whatwg.org/#concept-node-clone pub fn clone(node: &Node, maybe_doc: Option<&Document>, - clone_children: CloneChildrenFlag) -> Root { + clone_children: CloneChildrenFlag) -> DomRoot { // Step 1. let document = match maybe_doc { - Some(doc) => Root::from_ref(doc), + Some(doc) => DomRoot::from_ref(doc), None => node.owner_doc() }; // Step 2. // XXXabinader: clone() for each node as trait? - let copy: Root = match node.type_id() { + let copy: DomRoot = match node.type_id() { NodeTypeId::DocumentType => { let doctype = node.downcast::().unwrap(); let doctype = DocumentType::new(doctype.name().clone(), Some(doctype.public_id().clone()), Some(doctype.system_id().clone()), &document); - Root::upcast::(doctype) + DomRoot::upcast::(doctype) }, NodeTypeId::DocumentFragment => { let doc_fragment = DocumentFragment::new(&document); - Root::upcast::(doc_fragment) + DomRoot::upcast::(doc_fragment) }, NodeTypeId::CharacterData(_) => { let cdata = node.downcast::().unwrap(); @@ -1825,7 +1823,7 @@ impl Node { None, DocumentActivity::Inactive, DocumentSource::NotFromParser, loader, None, None); - Root::upcast::(document) + DomRoot::upcast::(document) }, NodeTypeId::Element(..) => { let element = node.downcast::().unwrap(); @@ -1839,14 +1837,14 @@ impl Node { &document, ElementCreator::ScriptCreated, CustomElementCreationMode::Asynchronous); - Root::upcast::(element) + DomRoot::upcast::(element) }, }; // Step 3. let document = match copy.downcast::() { - Some(doc) => Root::from_ref(doc), - None => Root::from_ref(&*document), + Some(doc) => DomRoot::from_ref(doc), + None => DomRoot::from_ref(&*document), }; assert!(copy.owner_doc() == document); @@ -1894,7 +1892,7 @@ impl Node { Node::collect_text_contents(self.children()) } - pub fn collect_text_contents>>(iterator: T) -> DOMString { + pub fn collect_text_contents>>(iterator: T) -> DOMString { let mut content = String::new(); for node in iterator { if let Some(ref text) = node.downcast::() { @@ -1978,7 +1976,7 @@ impl NodeMethods for Node { } // https://dom.spec.whatwg.org/#dom-node-ownerdocument - fn GetOwnerDocument(&self) -> Option> { + fn GetOwnerDocument(&self) -> Option> { match self.type_id() { NodeTypeId::CharacterData(..) | NodeTypeId::Element(..) | @@ -1989,18 +1987,18 @@ impl NodeMethods for Node { } // https://dom.spec.whatwg.org/#dom-node-getrootnode - fn GetRootNode(&self) -> Root { + fn GetRootNode(&self) -> DomRoot { self.inclusive_ancestors().last().unwrap() } // https://dom.spec.whatwg.org/#dom-node-parentnode - fn GetParentNode(&self) -> Option> { + fn GetParentNode(&self) -> Option> { self.parent_node.get() } // https://dom.spec.whatwg.org/#dom-node-parentelement - fn GetParentElement(&self) -> Option> { - self.GetParentNode().and_then(Root::downcast) + fn GetParentElement(&self) -> Option> { + self.GetParentNode().and_then(DomRoot::downcast) } // https://dom.spec.whatwg.org/#dom-node-haschildnodes @@ -2009,7 +2007,7 @@ impl NodeMethods for Node { } // https://dom.spec.whatwg.org/#dom-node-childnodes - fn ChildNodes(&self) -> Root { + fn ChildNodes(&self) -> DomRoot { self.child_list.or_init(|| { let doc = self.owner_doc(); let window = doc.window(); @@ -2018,22 +2016,22 @@ impl NodeMethods for Node { } // https://dom.spec.whatwg.org/#dom-node-firstchild - fn GetFirstChild(&self) -> Option> { + fn GetFirstChild(&self) -> Option> { self.first_child.get() } // https://dom.spec.whatwg.org/#dom-node-lastchild - fn GetLastChild(&self) -> Option> { + fn GetLastChild(&self) -> Option> { self.last_child.get() } // https://dom.spec.whatwg.org/#dom-node-previoussibling - fn GetPreviousSibling(&self) -> Option> { + fn GetPreviousSibling(&self) -> Option> { self.prev_sibling.get() } // https://dom.spec.whatwg.org/#dom-node-nextsibling - fn GetNextSibling(&self) -> Option> { + fn GetNextSibling(&self) -> Option> { self.next_sibling.get() } @@ -2078,7 +2076,7 @@ impl NodeMethods for Node { let node = if value.is_empty() { None } else { - Some(Root::upcast(self.owner_doc().CreateTextNode(value))) + Some(DomRoot::upcast(self.owner_doc().CreateTextNode(value))) }; // Step 3. @@ -2094,17 +2092,17 @@ impl NodeMethods for Node { } // https://dom.spec.whatwg.org/#dom-node-insertbefore - fn InsertBefore(&self, node: &Node, child: Option<&Node>) -> Fallible> { + fn InsertBefore(&self, node: &Node, child: Option<&Node>) -> Fallible> { Node::pre_insert(node, self, child) } // https://dom.spec.whatwg.org/#dom-node-appendchild - fn AppendChild(&self, node: &Node) -> Fallible> { + fn AppendChild(&self, node: &Node) -> Fallible> { Node::pre_insert(node, self, None) } // https://dom.spec.whatwg.org/#concept-node-replace - fn ReplaceChild(&self, node: &Node, child: &Node) -> Fallible> { + fn ReplaceChild(&self, node: &Node, child: &Node) -> Fallible> { // Step 1. match self.type_id() { NodeTypeId::Document(_) | @@ -2218,7 +2216,7 @@ impl NodeMethods for Node { // Step 12. rooted_vec!(let mut nodes); let nodes = if node.type_id() == NodeTypeId::DocumentFragment { - nodes.extend(node.children().map(|node| JS::from_ref(&*node))); + nodes.extend(node.children().map(|node| Dom::from_ref(&*node))); nodes.r() } else { ref_slice(&node) @@ -2242,12 +2240,12 @@ impl NodeMethods for Node { MutationObserver::queue_a_mutation_record(&self, mutation); // Step 15. - Ok(Root::from_ref(child)) + Ok(DomRoot::from_ref(child)) } // https://dom.spec.whatwg.org/#dom-node-removechild fn RemoveChild(&self, node: &Node) - -> Fallible> { + -> Fallible> { Node::pre_remove(node, self) } @@ -2278,7 +2276,7 @@ impl NodeMethods for Node { } // https://dom.spec.whatwg.org/#dom-node-clonenode - fn CloneNode(&self, deep: bool) -> Root { + fn CloneNode(&self, deep: bool) -> DomRoot { Node::clone(self, None, if deep { CloneChildrenFlag::CloneChildren } else { @@ -2501,13 +2499,13 @@ impl NodeMethods for Node { } } -pub fn document_from_node + DomObject>(derived: &T) -> Root { +pub fn document_from_node + DomObject>(derived: &T) -> DomRoot { derived.upcast().owner_doc() } -pub fn window_from_node + DomObject>(derived: &T) -> Root { +pub fn window_from_node + DomObject>(derived: &T) -> DomRoot { let document = document_from_node(derived); - Root::from_ref(document.window()) + DomRoot::from_ref(document.window()) } impl VirtualMethods for Node { @@ -2628,7 +2626,7 @@ impl<'a> ChildrenMutation<'a> { /// NOTE: This does not check whether the inserted/removed nodes were elements, so in some /// cases it will return a false positive. This doesn't matter for correctness, because at /// worst the returned element will be restyled unnecessarily. - pub fn modified_edge_element(&self) -> Option> { + pub fn modified_edge_element(&self) -> Option> { match *self { // Add/remove at start of container: Return the first following element. ChildrenMutation::Prepend { next, .. } | @@ -2788,7 +2786,7 @@ pub trait VecPreOrderInsertionHelper { fn insert_pre_order(&mut self, elem: &T, tree_root: &Node); } -impl VecPreOrderInsertionHelper for Vec> +impl VecPreOrderInsertionHelper for Vec> where T: DerivedFrom + DomObject { /// This algorithm relies on the following assumptions: @@ -2802,14 +2800,14 @@ impl VecPreOrderInsertionHelper for Vec> /// the traversal. fn insert_pre_order(&mut self, elem: &T, tree_root: &Node) { if self.is_empty() { - self.push(JS::from_ref(elem)); + self.push(Dom::from_ref(elem)); return; } let elem_node = elem.upcast::(); let mut head: usize = 0; for node in tree_root.traverse_preorder() { - let head_node = Root::upcast::(Root::from_ref(&*self[head])); + let head_node = DomRoot::upcast::(DomRoot::from_ref(&*self[head])); if head_node == node { head += 1; } @@ -2817,6 +2815,6 @@ impl VecPreOrderInsertionHelper for Vec> break; } } - self.insert(head, JS::from_ref(elem)); + self.insert(head, Dom::from_ref(elem)); } } diff --git a/servo/components/script/dom/nodeiterator.rs b/servo/components/script/dom/nodeiterator.rs index 93e50ca46a97..3ee09742e67c 100644 --- a/servo/components/script/dom/nodeiterator.rs +++ b/servo/components/script/dom/nodeiterator.rs @@ -9,8 +9,8 @@ use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants; use dom::bindings::codegen::Bindings::NodeIteratorBinding; use dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, MutJS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutDom}; use dom::document::Document; use dom::node::Node; use dom_struct::dom_struct; @@ -20,9 +20,9 @@ use std::rc::Rc; #[dom_struct] pub struct NodeIterator { reflector_: Reflector, - root_node: JS, + root_node: Dom, #[ignore_heap_size_of = "Defined in rust-mozjs"] - reference_node: MutJS, + reference_node: MutDom, pointer_before_reference_node: Cell, what_to_show: u32, #[ignore_heap_size_of = "Can't measure due to #6870"] @@ -35,8 +35,8 @@ impl NodeIterator { filter: Filter) -> NodeIterator { NodeIterator { reflector_: Reflector::new(), - root_node: JS::from_ref(root_node), - reference_node: MutJS::new(root_node), + root_node: Dom::from_ref(root_node), + reference_node: MutDom::new(root_node), pointer_before_reference_node: Cell::new(true), what_to_show: what_to_show, filter: filter @@ -46,7 +46,7 @@ impl NodeIterator { pub fn new_with_filter(document: &Document, root_node: &Node, what_to_show: u32, - filter: Filter) -> Root { + filter: Filter) -> DomRoot { reflect_dom_object(box NodeIterator::new_inherited(root_node, what_to_show, filter), document.window(), NodeIteratorBinding::Wrap) @@ -55,7 +55,7 @@ impl NodeIterator { pub fn new(document: &Document, root_node: &Node, what_to_show: u32, - node_filter: Option>) -> Root { + node_filter: Option>) -> DomRoot { let filter = match node_filter { None => Filter::None, Some(jsfilter) => Filter::Callback(jsfilter) @@ -66,8 +66,8 @@ impl NodeIterator { impl NodeIteratorMethods for NodeIterator { // https://dom.spec.whatwg.org/#dom-nodeiterator-root - fn Root(&self) -> Root { - Root::from_ref(&*self.root_node) + fn Root(&self) -> DomRoot { + DomRoot::from_ref(&*self.root_node) } // https://dom.spec.whatwg.org/#dom-nodeiterator-whattoshow @@ -84,7 +84,7 @@ impl NodeIteratorMethods for NodeIterator { } // https://dom.spec.whatwg.org/#dom-nodeiterator-referencenode - fn ReferenceNode(&self) -> Root { + fn ReferenceNode(&self) -> DomRoot { self.reference_node.get() } @@ -94,7 +94,7 @@ impl NodeIteratorMethods for NodeIterator { } // https://dom.spec.whatwg.org/#dom-nodeiterator-nextnode - fn NextNode(&self) -> Fallible>> { + fn NextNode(&self) -> Fallible>> { // https://dom.spec.whatwg.org/#concept-NodeIterator-traverse // Step 1. let node = self.reference_node.get(); @@ -138,7 +138,7 @@ impl NodeIteratorMethods for NodeIterator { } // https://dom.spec.whatwg.org/#dom-nodeiterator-previousnode - fn PreviousNode(&self) -> Fallible>> { + fn PreviousNode(&self) -> Fallible>> { // https://dom.spec.whatwg.org/#concept-NodeIterator-traverse // Step 1. let node = self.reference_node.get(); diff --git a/servo/components/script/dom/nodelist.rs b/servo/components/script/dom/nodelist.rs index 7fdfe5b60646..d6c0a394c935 100644 --- a/servo/components/script/dom/nodelist.rs +++ b/servo/components/script/dom/nodelist.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeListBinding; use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; -use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference}; use dom::node::{ChildrenMutation, Node}; use dom::window::Window; use dom_struct::dom_struct; @@ -15,7 +15,7 @@ use std::cell::Cell; #[derive(HeapSizeOf, JSTraceable)] #[must_root] pub enum NodeListType { - Simple(Vec>), + Simple(Vec>), Children(ChildrenList), } @@ -36,26 +36,26 @@ impl NodeList { } #[allow(unrooted_must_root)] - pub fn new(window: &Window, list_type: NodeListType) -> Root { + pub fn new(window: &Window, list_type: NodeListType) -> DomRoot { reflect_dom_object(box NodeList::new_inherited(list_type), window, NodeListBinding::Wrap) } - pub fn new_simple_list(window: &Window, iter: T) -> Root - where T: Iterator> { - NodeList::new(window, NodeListType::Simple(iter.map(|r| JS::from_ref(&*r)).collect())) + pub fn new_simple_list(window: &Window, iter: T) -> DomRoot + where T: Iterator> { + NodeList::new(window, NodeListType::Simple(iter.map(|r| Dom::from_ref(&*r)).collect())) } - pub fn new_simple_list_slice(window: &Window, slice: &[&Node]) -> Root { - NodeList::new(window, NodeListType::Simple(slice.iter().map(|r| JS::from_ref(*r)).collect())) + pub fn new_simple_list_slice(window: &Window, slice: &[&Node]) -> DomRoot { + NodeList::new(window, NodeListType::Simple(slice.iter().map(|r| Dom::from_ref(*r)).collect())) } - pub fn new_child_list(window: &Window, node: &Node) -> Root { + pub fn new_child_list(window: &Window, node: &Node) -> DomRoot { NodeList::new(window, NodeListType::Children(ChildrenList::new(node))) } - pub fn empty(window: &Window) -> Root { + pub fn empty(window: &Window) -> DomRoot { NodeList::new(window, NodeListType::Simple(vec![])) } } @@ -70,17 +70,17 @@ impl NodeListMethods for NodeList { } // https://dom.spec.whatwg.org/#dom-nodelist-item - fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { match self.list_type { NodeListType::Simple(ref elems) => { - elems.get(index as usize).map(|node| Root::from_ref(&**node)) + elems.get(index as usize).map(|node| DomRoot::from_ref(&**node)) }, NodeListType::Children(ref list) => list.item(index), } } // https://dom.spec.whatwg.org/#dom-nodelist-item - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } } @@ -95,7 +95,7 @@ impl NodeList { } } - pub fn as_simple_list(&self) -> &Vec> { + pub fn as_simple_list(&self) -> &Vec> { if let NodeListType::Simple(ref list) = self.list_type { list } else { @@ -103,7 +103,7 @@ impl NodeList { } } - pub fn iter<'a>(&'a self) -> impl Iterator> + 'a { + pub fn iter<'a>(&'a self) -> impl Iterator> + 'a { let len = self.Length(); (0..len).flat_map(move |i| self.Item(i)) } @@ -112,9 +112,9 @@ impl NodeList { #[derive(HeapSizeOf, JSTraceable)] #[must_root] pub struct ChildrenList { - node: JS, + node: Dom, #[ignore_heap_size_of = "Defined in rust-mozjs"] - last_visited: MutNullableJS, + last_visited: MutNullableDom, last_index: Cell, } @@ -122,8 +122,8 @@ impl ChildrenList { pub fn new(node: &Node) -> ChildrenList { let last_visited = node.GetFirstChild(); ChildrenList { - node: JS::from_ref(node), - last_visited: MutNullableJS::new(last_visited.r()), + node: Dom::from_ref(node), + last_visited: MutNullableDom::new(last_visited.r()), last_index: Cell::new(0u32), } } @@ -132,7 +132,7 @@ impl ChildrenList { self.node.children_count() } - pub fn item(&self, index: u32) -> Option> { + pub fn item(&self, index: u32) -> Option> { // This always start traversing the children from the closest element // among parent's first and last children and the last visited one. let len = self.len() as u32; diff --git a/servo/components/script/dom/pagetransitionevent.rs b/servo/components/script/dom/pagetransitionevent.rs index 3757bece84ac..936c262eb52a 100644 --- a/servo/components/script/dom/pagetransitionevent.rs +++ b/servo/components/script/dom/pagetransitionevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::PageTransitionEventBinding; use dom::bindings::codegen::Bindings::PageTransitionEventBinding::PageTransitionEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::Event; use dom::window::Window; @@ -31,7 +31,7 @@ impl PageTransitionEvent { } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { reflect_dom_object(box PageTransitionEvent::new_inherited(), window, PageTransitionEventBinding::Wrap) @@ -42,7 +42,7 @@ impl PageTransitionEvent { bubbles: bool, cancelable: bool, persisted: bool) - -> Root { + -> DomRoot { let ev = PageTransitionEvent::new_uninitialized(window); ev.persisted.set(persisted); { @@ -55,7 +55,7 @@ impl PageTransitionEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &PageTransitionEventBinding::PageTransitionEventInit) - -> Fallible> { + -> Fallible> { Ok(PageTransitionEvent::new(window, Atom::from(type_), init.parent.bubbles, diff --git a/servo/components/script/dom/paintrenderingcontext2d.rs b/servo/components/script/dom/paintrenderingcontext2d.rs index 5a269eaf37a4..b5c47b2c08fe 100644 --- a/servo/components/script/dom/paintrenderingcontext2d.rs +++ b/servo/components/script/dom/paintrenderingcontext2d.rs @@ -16,9 +16,9 @@ use dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; use dom::bindings::error::ErrorResult; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::canvasgradient::CanvasGradient; use dom::canvaspattern::CanvasPattern; @@ -52,7 +52,7 @@ impl PaintRenderingContext2D { } } - pub fn new(global: &PaintWorkletGlobalScope) -> Root { + pub fn new(global: &PaintWorkletGlobalScope) -> DomRoot { reflect_dom_object(box PaintRenderingContext2D::new_inherited(global), global, PaintRenderingContext2DBinding::Wrap) @@ -304,7 +304,7 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D { y0: Finite, x1: Finite, y1: Finite) - -> Root { + -> DomRoot { self.context.CreateLinearGradient(x0, y0, x1, y1) } @@ -316,7 +316,7 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D { x1: Finite, y1: Finite, r1: Finite) - -> Fallible> { + -> Fallible> { self.context.CreateRadialGradient(x0, y0, r0, x1, y1, r1) } @@ -324,7 +324,7 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D { fn CreatePattern(&self, image: HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2DOrCSSStyleValue, repetition: DOMString) - -> Fallible> { + -> Fallible> { self.context.CreatePattern(image, repetition) } diff --git a/servo/components/script/dom/paintsize.rs b/servo/components/script/dom/paintsize.rs index df94bd365662..72ebc9884683 100644 --- a/servo/components/script/dom/paintsize.rs +++ b/servo/components/script/dom/paintsize.rs @@ -4,10 +4,10 @@ use dom::bindings::codegen::Bindings::PaintSizeBinding; use dom::bindings::codegen::Bindings::PaintSizeBinding::PaintSizeMethods; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::Reflector; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::paintworkletglobalscope::PaintWorkletGlobalScope; use dom_struct::dom_struct; use euclid::TypedSize2D; @@ -29,7 +29,7 @@ impl PaintSize { } } - pub fn new(global: &PaintWorkletGlobalScope, size: TypedSize2D) -> Root { + pub fn new(global: &PaintWorkletGlobalScope, size: TypedSize2D) -> DomRoot { reflect_dom_object(box PaintSize::new_inherited(size), global, PaintSizeBinding::Wrap) } } diff --git a/servo/components/script/dom/paintworkletglobalscope.rs b/servo/components/script/dom/paintworkletglobalscope.rs index 8eba2c8bb147..322b6e5a5d86 100644 --- a/servo/components/script/dom/paintworkletglobalscope.rs +++ b/servo/components/script/dom/paintworkletglobalscope.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::callback::CallbackContainer; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::PaintWorkletGlobalScopeBinding; use dom::bindings::codegen::Bindings::PaintWorkletGlobalScopeBinding::PaintWorkletGlobalScopeMethods; use dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction; @@ -12,9 +12,8 @@ use dom::bindings::conversions::get_property_jsval; use dom::bindings::error::Error; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::JS; -use dom::bindings::js::Root; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::cssstylevalue::CSSStyleValue; use dom::paintrenderingcontext2d::PaintRenderingContext2D; @@ -72,21 +71,21 @@ pub struct PaintWorkletGlobalScope { #[ignore_heap_size_of = "Arc"] image_cache: Arc, /// https://drafts.css-houdini.org/css-paint-api/#paint-definitions - paint_definitions: DOMRefCell>>, + paint_definitions: DomRefCell>>, /// https://drafts.css-houdini.org/css-paint-api/#paint-class-instances - paint_class_instances: DOMRefCell>>>, + paint_class_instances: DomRefCell>>>, /// The most recent name the worklet was called with - cached_name: DOMRefCell, + cached_name: DomRefCell, /// The most recent size the worklet was drawn at cached_size: Cell>, /// The most recent device pixel ratio the worklet was drawn at cached_device_pixel_ratio: Cell>, /// The most recent properties the worklet was drawn at - cached_properties: DOMRefCell>, + cached_properties: DomRefCell>, /// The most recent arguments the worklet was drawn at - cached_arguments: DOMRefCell>, + cached_arguments: DomRefCell>, /// The most recent result - cached_result: DOMRefCell, + cached_result: DomRefCell, } impl PaintWorkletGlobalScope { @@ -96,19 +95,19 @@ impl PaintWorkletGlobalScope { base_url: ServoUrl, executor: WorkletExecutor, init: &WorkletGlobalScopeInit) - -> Root { + -> DomRoot { debug!("Creating paint worklet global scope for pipeline {}.", pipeline_id); let global = box PaintWorkletGlobalScope { worklet_global: WorkletGlobalScope::new_inherited(pipeline_id, base_url, executor, init), image_cache: init.image_cache.clone(), paint_definitions: Default::default(), paint_class_instances: Default::default(), - cached_name: DOMRefCell::new(Atom::from("")), + cached_name: DomRefCell::new(Atom::from("")), cached_size: Cell::new(TypedSize2D::zero()), cached_device_pixel_ratio: Cell::new(ScaleFactor::new(1.0)), cached_properties: Default::default(), cached_arguments: Default::default(), - cached_result: DOMRefCell::new(DrawAPaintImageResult { + cached_result: DomRefCell::new(DrawAPaintImageResult { width: 0, height: 0, format: PixelFormat::BGRA8, @@ -223,7 +222,7 @@ impl PaintWorkletGlobalScope { } class_constructor.set(definition.class_constructor.get()); paint_function.set(definition.paint_function.get()); - Root::from_ref(&*definition.context) + DomRoot::from_ref(&*definition.context) } }; @@ -477,7 +476,7 @@ struct PaintDefinition { // TODO: the spec calls for fresh rendering contexts each time a paint image is drawn, // but to avoid having the primary worklet thread create a new renering context, // we recycle them. - context: JS, + context: Dom, } impl PaintDefinition { @@ -494,7 +493,7 @@ impl PaintDefinition { constructor_valid_flag: Cell::new(true), context_alpha_flag: alpha, input_arguments_len: input_arguments_len, - context: JS::from_ref(context), + context: Dom::from_ref(context), }); result.class_constructor.set(class_constructor.get()); result.paint_function.set(paint_function.get()); diff --git a/servo/components/script/dom/performance.rs b/servo/components/script/dom/performance.rs index 7d2b053dda72..0aabbb6fc35b 100644 --- a/servo/components/script/dom/performance.rs +++ b/servo/components/script/dom/performance.rs @@ -2,15 +2,15 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::PerformanceBinding; use dom::bindings::codegen::Bindings::PerformanceBinding::{DOMHighResTimeStamp, PerformanceMethods}; use dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceEntryList as DOMPerformanceEntryList; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::num::Finite; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom::performanceentry::PerformanceEntry; @@ -63,11 +63,11 @@ impl PerformanceEntryList { } pub fn get_entries_by_name_and_type(&self, name: Option, entry_type: Option) - -> Vec> { + -> Vec> { let mut res = self.entries.iter().filter(|e| name.as_ref().map_or(true, |name_| *e.name() == *name_) && entry_type.as_ref().map_or(true, |type_| *e.entry_type() == *type_) - ).map(|e| e.clone()).collect::>>(); + ).map(|e| e.clone()).collect::>>(); res.sort_by(|a, b| a.start_time().partial_cmp(&b.start_time()).unwrap_or(Ordering::Equal)); res } @@ -93,8 +93,8 @@ impl PerformanceEntryList { } impl IntoIterator for PerformanceEntryList { - type Item = Root; - type IntoIter = ::std::vec::IntoIter>; + type Item = DomRoot; + type IntoIter = ::std::vec::IntoIter>; fn into_iter(self) -> Self::IntoIter { self.entries.into_iter() @@ -103,16 +103,16 @@ impl IntoIterator for PerformanceEntryList { #[derive(HeapSizeOf, JSTraceable)] struct PerformanceObserver { - observer: Root, + observer: DomRoot, entry_types: Vec, } #[dom_struct] pub struct Performance { reflector_: Reflector, - timing: Option>, - entries: DOMRefCell, - observers: DOMRefCell>, + timing: Option>, + entries: DomRefCell, + observers: DomRefCell>, pending_notification_observers_task: Cell, navigation_start_precise: f64, } @@ -124,14 +124,14 @@ impl Performance { Performance { reflector_: Reflector::new(), timing: if global.is::() { - Some(JS::from_ref(&*PerformanceTiming::new(global.as_window(), + Some(Dom::from_ref(&*PerformanceTiming::new(global.as_window(), navigation_start, navigation_start_precise))) } else { None }, - entries: DOMRefCell::new(PerformanceEntryList::new(Vec::new())), - observers: DOMRefCell::new(Vec::new()), + entries: DomRefCell::new(PerformanceEntryList::new(Vec::new())), + observers: DomRefCell::new(Vec::new()), pending_notification_observers_task: Cell::new(false), navigation_start_precise, } @@ -139,7 +139,7 @@ impl Performance { pub fn new(global: &GlobalScope, navigation_start: u64, - navigation_start_precise: f64) -> Root { + navigation_start_precise: f64) -> DomRoot { reflect_dom_object(box Performance::new_inherited(global, navigation_start, navigation_start_precise), @@ -169,7 +169,7 @@ impl Performance { Some(p) => observers[p].entry_types = entry_types, // Otherwise, we create and insert the new PerformanceObserver. None => observers.push(PerformanceObserver { - observer: Root::from_ref(observer), + observer: DomRoot::from_ref(observer), entry_types }) }; @@ -214,7 +214,7 @@ impl Performance { // If the "add to performance entry buffer flag" is set, add the // new entry to the buffer. if add_to_performance_entries_buffer { - self.entries.borrow_mut().entries.push(Root::from_ref(entry)); + self.entries.borrow_mut().entries.push(DomRoot::from_ref(entry)); } // Step 5. @@ -242,7 +242,7 @@ impl Performance { // We have to operate over a copy of the performance observers to avoid // the risk of an observer's callback modifying the list of registered // observers. - let observers: Vec> = + let observers: Vec> = self.observers.borrow().iter() .map(|o| DOMPerformanceObserver::new(&self.global(), o.observer.callback(), @@ -266,9 +266,9 @@ impl Performance { impl PerformanceMethods for Performance { // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#performance-timing-attribute - fn Timing(&self) -> Root { + fn Timing(&self) -> DomRoot { match self.timing { - Some(ref timing) => Root::from_ref(&*timing), + Some(ref timing) => DomRoot::from_ref(&*timing), None => unreachable!("Are we trying to expose Performance.timing in workers?"), } } @@ -279,18 +279,18 @@ impl PerformanceMethods for Performance { } // https://www.w3.org/TR/performance-timeline-2/#dom-performance-getentries - fn GetEntries(&self) -> Vec> { + fn GetEntries(&self) -> Vec> { self.entries.borrow().get_entries_by_name_and_type(None, None) } // https://www.w3.org/TR/performance-timeline-2/#dom-performance-getentriesbytype - fn GetEntriesByType(&self, entry_type: DOMString) -> Vec> { + fn GetEntriesByType(&self, entry_type: DOMString) -> Vec> { self.entries.borrow().get_entries_by_name_and_type(None, Some(entry_type)) } // https://www.w3.org/TR/performance-timeline-2/#dom-performance-getentriesbyname fn GetEntriesByName(&self, name: DOMString, entry_type: Option) - -> Vec> { + -> Vec> { self.entries.borrow().get_entries_by_name_and_type(Some(name), entry_type) } diff --git a/servo/components/script/dom/performanceentry.rs b/servo/components/script/dom/performanceentry.rs index 3242d5d5abd7..01b8eb6ee956 100644 --- a/servo/components/script/dom/performanceentry.rs +++ b/servo/components/script/dom/performanceentry.rs @@ -4,9 +4,9 @@ use dom::bindings::codegen::Bindings::PerformanceEntryBinding; use dom::bindings::codegen::Bindings::PerformanceEntryBinding::PerformanceEntryMethods; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -39,7 +39,7 @@ impl PerformanceEntry { name: DOMString, entry_type: DOMString, start_time: f64, - duration: f64) -> Root { + duration: f64) -> DomRoot { let entry = PerformanceEntry::new_inherited(name, entry_type, start_time, duration); reflect_dom_object(box entry, global, PerformanceEntryBinding::Wrap) } diff --git a/servo/components/script/dom/performanceobserver.rs b/servo/components/script/dom/performanceobserver.rs index 24bf84ffd5c7..4393eff6d0f6 100644 --- a/servo/components/script/dom/performanceobserver.rs +++ b/servo/components/script/dom/performanceobserver.rs @@ -3,15 +3,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::callback::ExceptionHandling; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceEntryList as DOMPerformanceEntryList; use dom::bindings::codegen::Bindings::PerformanceObserverBinding; use dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverCallback; use dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverInit; use dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverMethods; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom::performance::PerformanceEntryList; @@ -34,12 +34,12 @@ pub struct PerformanceObserver { reflector_: Reflector, #[ignore_heap_size_of = "can't measure Rc values"] callback: Rc, - entries: DOMRefCell, + entries: DomRefCell, } impl PerformanceObserver { fn new_inherited(callback: Rc, - entries: DOMRefCell) + entries: DomRefCell) -> PerformanceObserver { PerformanceObserver { reflector_: Reflector::new(), @@ -52,19 +52,19 @@ impl PerformanceObserver { pub fn new(global: &GlobalScope, callback: Rc, entries: DOMPerformanceEntryList) - -> Root { - let observer = PerformanceObserver::new_inherited(callback, DOMRefCell::new(entries)); + -> DomRoot { + let observer = PerformanceObserver::new_inherited(callback, DomRefCell::new(entries)); reflect_dom_object(box observer, global, PerformanceObserverBinding::Wrap) } pub fn Constructor(global: &GlobalScope, callback: Rc) - -> Fallible> { + -> Fallible> { Ok(PerformanceObserver::new(global, callback, Vec::new())) } /// Buffer a new performance entry. pub fn queue_entry(&self, entry: &PerformanceEntry) { - self.entries.borrow_mut().push(Root::from_ref(entry)); + self.entries.borrow_mut().push(DomRoot::from_ref(entry)); } /// Trigger performance observer callback with the list of performance entries diff --git a/servo/components/script/dom/performanceobserverentrylist.rs b/servo/components/script/dom/performanceobserverentrylist.rs index 94f62248fbd7..70f329952d85 100644 --- a/servo/components/script/dom/performanceobserverentrylist.rs +++ b/servo/components/script/dom/performanceobserverentrylist.rs @@ -2,11 +2,11 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::PerformanceObserverEntryListBinding; use dom::bindings::codegen::Bindings::PerformanceObserverEntryListBinding::PerformanceObserverEntryListMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom::performance::PerformanceEntryList; @@ -16,20 +16,20 @@ use dom_struct::dom_struct; #[dom_struct] pub struct PerformanceObserverEntryList { reflector_: Reflector, - entries: DOMRefCell, + entries: DomRefCell, } impl PerformanceObserverEntryList { fn new_inherited(entries: PerformanceEntryList) -> PerformanceObserverEntryList { PerformanceObserverEntryList { reflector_: Reflector::new(), - entries: DOMRefCell::new(entries), + entries: DomRefCell::new(entries), } } #[allow(unrooted_must_root)] pub fn new(global: &GlobalScope, entries: PerformanceEntryList) - -> Root { + -> DomRoot { let observer_entry_list = PerformanceObserverEntryList::new_inherited(entries); reflect_dom_object(box observer_entry_list, global, PerformanceObserverEntryListBinding::Wrap) } @@ -37,18 +37,18 @@ impl PerformanceObserverEntryList { impl PerformanceObserverEntryListMethods for PerformanceObserverEntryList { // https://w3c.github.io/performance-timeline/#dom-performanceobserver - fn GetEntries(&self) -> Vec> { + fn GetEntries(&self) -> Vec> { self.entries.borrow().get_entries_by_name_and_type(None, None) } // https://w3c.github.io/performance-timeline/#dom-performanceobserver - fn GetEntriesByType(&self, entry_type: DOMString) -> Vec> { + fn GetEntriesByType(&self, entry_type: DOMString) -> Vec> { self.entries.borrow().get_entries_by_name_and_type(None, Some(entry_type)) } // https://w3c.github.io/performance-timeline/#dom-performanceobserver fn GetEntriesByName(&self, name: DOMString, entry_type: Option) - -> Vec> { + -> Vec> { self.entries.borrow().get_entries_by_name_and_type(Some(name), entry_type) } } diff --git a/servo/components/script/dom/performancepainttiming.rs b/servo/components/script/dom/performancepainttiming.rs index a4e4369ccebc..b798d93a1408 100644 --- a/servo/components/script/dom/performancepainttiming.rs +++ b/servo/components/script/dom/performancepainttiming.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::PerformancePaintTimingBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom::performanceentry::PerformanceEntry; @@ -34,7 +34,7 @@ impl PerformancePaintTiming { #[allow(unrooted_must_root)] pub fn new(global: &GlobalScope, metric_type: PaintMetricType, - start_time: f64) -> Root { + start_time: f64) -> DomRoot { let entry = PerformancePaintTiming::new_inherited(metric_type, start_time); reflect_dom_object(box entry, global, PerformancePaintTimingBinding::Wrap) } diff --git a/servo/components/script/dom/performancetiming.rs b/servo/components/script/dom/performancetiming.rs index 37001f5d15fb..d0833d76f64e 100644 --- a/servo/components/script/dom/performancetiming.rs +++ b/servo/components/script/dom/performancetiming.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::PerformanceTimingBinding; use dom::bindings::codegen::Bindings::PerformanceTimingBinding::PerformanceTimingMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::document::Document; use dom::window::Window; use dom_struct::dom_struct; @@ -16,7 +16,7 @@ pub struct PerformanceTiming { reflector_: Reflector, navigation_start: u64, navigation_start_precise: f64, - document: JS, + document: Dom, } impl PerformanceTiming { @@ -28,7 +28,7 @@ impl PerformanceTiming { reflector_: Reflector::new(), navigation_start: nav_start, navigation_start_precise: nav_start_precise, - document: JS::from_ref(document), + document: Dom::from_ref(document), } } @@ -36,7 +36,7 @@ impl PerformanceTiming { pub fn new(window: &Window, navigation_start: u64, navigation_start_precise: f64) - -> Root { + -> DomRoot { let timing = PerformanceTiming::new_inherited(navigation_start, navigation_start_precise, &window.Document()); diff --git a/servo/components/script/dom/permissions.rs b/servo/components/script/dom/permissions.rs index 99908aa51e9a..74fc675008ed 100644 --- a/servo/components/script/dom/permissions.rs +++ b/servo/components/script/dom/permissions.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionDescri use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusMethods; use dom::bindings::codegen::Bindings::PermissionsBinding::{self, PermissionsMethods}; use dom::bindings::error::Error; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bluetooth::Bluetooth; use dom::bluetoothpermissionresult::BluetoothPermissionResult; use dom::globalscope::GlobalScope; @@ -63,7 +63,7 @@ impl Permissions { } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box Permissions::new_inherited(), global, PermissionsBinding::Wrap) @@ -265,7 +265,7 @@ pub fn get_descriptor_permission_state(permission_name: PermissionName, -> PermissionState { // Step 1. let settings = match env_settings_obj { - Some(env_settings_obj) => Root::from_ref(env_settings_obj), + Some(env_settings_obj) => DomRoot::from_ref(env_settings_obj), None => GlobalScope::current().expect("No current global object"), }; diff --git a/servo/components/script/dom/permissionstatus.rs b/servo/components/script/dom/permissionstatus.rs index ec2138cf23d5..13efaf65a0a6 100644 --- a/servo/components/script/dom/permissionstatus.rs +++ b/servo/components/script/dom/permissionstatus.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::PermissionStatusBinding::{self, PermissionDescriptor, PermissionName}; use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState; use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::eventtarget::EventTarget; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -30,7 +30,7 @@ impl PermissionStatus { } } - pub fn new(global: &GlobalScope, query: &PermissionDescriptor) -> Root { + pub fn new(global: &GlobalScope, query: &PermissionDescriptor) -> DomRoot { reflect_dom_object(box PermissionStatus::new_inherited(query.name), global, PermissionStatusBinding::Wrap) diff --git a/servo/components/script/dom/plugin.rs b/servo/components/script/dom/plugin.rs index 8e3af814ec94..ebdd54782802 100644 --- a/servo/components/script/dom/plugin.rs +++ b/servo/components/script/dom/plugin.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::PluginBinding::PluginMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::Reflector; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::mimetype::MimeType; use dom_struct::dom_struct; @@ -36,22 +36,22 @@ impl PluginMethods for Plugin { } // https://html.spec.whatwg.org/multipage/#dom-plugin-item - fn Item(&self, _index: u32) -> Option> { + fn Item(&self, _index: u32) -> Option> { unreachable!() } // https://html.spec.whatwg.org/multipage/#dom-plugin-nameditem - fn NamedItem(&self, _name: DOMString) -> Option> { + fn NamedItem(&self, _name: DOMString) -> Option> { unreachable!() } // https://html.spec.whatwg.org/multipage/#dom-plugin-item - fn IndexedGetter(&self, _index: u32) -> Option> { + fn IndexedGetter(&self, _index: u32) -> Option> { unreachable!() } // check-tidy: no specs after this line - fn NamedGetter(&self, _name: DOMString) -> Option> { + fn NamedGetter(&self, _name: DOMString) -> Option> { unreachable!() } diff --git a/servo/components/script/dom/pluginarray.rs b/servo/components/script/dom/pluginarray.rs index b359c2b83689..c77b763eb85e 100644 --- a/servo/components/script/dom/pluginarray.rs +++ b/servo/components/script/dom/pluginarray.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::PluginArrayBinding; use dom::bindings::codegen::Bindings::PluginArrayBinding::PluginArrayMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom::plugin::Plugin; @@ -23,7 +23,7 @@ impl PluginArray { } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box PluginArray::new_inherited(), global, PluginArrayBinding::Wrap) @@ -41,22 +41,22 @@ impl PluginArrayMethods for PluginArray { } // https://html.spec.whatwg.org/multipage/#dom-pluginarray-item - fn Item(&self, _index: u32) -> Option> { + fn Item(&self, _index: u32) -> Option> { None } // https://html.spec.whatwg.org/multipage/#dom-pluginarray-nameditem - fn NamedItem(&self, _name: DOMString) -> Option> { + fn NamedItem(&self, _name: DOMString) -> Option> { None } // https://html.spec.whatwg.org/multipage/#dom-pluginarray-item - fn IndexedGetter(&self, _index: u32) -> Option> { + fn IndexedGetter(&self, _index: u32) -> Option> { None } // check-tidy: no specs after this line - fn NamedGetter(&self, _name: DOMString) -> Option> { + fn NamedGetter(&self, _name: DOMString) -> Option> { None } diff --git a/servo/components/script/dom/popstateevent.rs b/servo/components/script/dom/popstateevent.rs index c5e63d4ea50b..0a962dfe5be5 100644 --- a/servo/components/script/dom/popstateevent.rs +++ b/servo/components/script/dom/popstateevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::PopStateEventBinding; use dom::bindings::codegen::Bindings::PopStateEventBinding::PopStateEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::bindings::trace::RootedTraceableBox; use dom::event::Event; @@ -34,7 +34,7 @@ impl PopStateEvent { } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { reflect_dom_object(box PopStateEvent::new_inherited(), window, PopStateEventBinding::Wrap) @@ -45,7 +45,7 @@ impl PopStateEvent { bubbles: bool, cancelable: bool, state: HandleValue) - -> Root { + -> DomRoot { let ev = PopStateEvent::new_uninitialized(window); ev.state.set(state.get()); { @@ -58,7 +58,7 @@ impl PopStateEvent { pub fn Constructor(window: &Window, type_: DOMString, init: RootedTraceableBox) - -> Fallible> { + -> Fallible> { Ok(PopStateEvent::new(window, Atom::from(type_), init.parent.bubbles, diff --git a/servo/components/script/dom/processinginstruction.rs b/servo/components/script/dom/processinginstruction.rs index 31e6737a977e..1cdb5eb1c4ca 100644 --- a/servo/components/script/dom/processinginstruction.rs +++ b/servo/components/script/dom/processinginstruction.rs @@ -4,7 +4,7 @@ use dom::bindings::codegen::Bindings::ProcessingInstructionBinding; use dom::bindings::codegen::Bindings::ProcessingInstructionBinding::ProcessingInstructionMethods; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::characterdata::CharacterData; use dom::document::Document; @@ -26,7 +26,7 @@ impl ProcessingInstruction { } } - pub fn new(target: DOMString, data: DOMString, document: &Document) -> Root { + pub fn new(target: DOMString, data: DOMString, document: &Document) -> DomRoot { Node::reflect_node(box ProcessingInstruction::new_inherited(target, data, document), document, ProcessingInstructionBinding::Wrap) } diff --git a/servo/components/script/dom/progressevent.rs b/servo/components/script/dom/progressevent.rs index e5ca1af2ae1b..1ad4acacc47b 100644 --- a/servo/components/script/dom/progressevent.rs +++ b/servo/components/script/dom/progressevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::ProgressEventBinding; use dom::bindings::codegen::Bindings::ProgressEventBinding::ProgressEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::globalscope::GlobalScope; @@ -32,14 +32,14 @@ impl ProgressEvent { total: total } } - pub fn new_uninitialized(global: &GlobalScope) -> Root { + pub fn new_uninitialized(global: &GlobalScope) -> DomRoot { reflect_dom_object(box ProgressEvent::new_inherited(false, 0, 0), global, ProgressEventBinding::Wrap) } pub fn new(global: &GlobalScope, type_: Atom, can_bubble: EventBubbles, cancelable: EventCancelable, - length_computable: bool, loaded: u64, total: u64) -> Root { + length_computable: bool, loaded: u64, total: u64) -> DomRoot { let ev = reflect_dom_object(box ProgressEvent::new_inherited(length_computable, loaded, total), global, ProgressEventBinding::Wrap); @@ -52,7 +52,7 @@ impl ProgressEvent { pub fn Constructor(global: &GlobalScope, type_: DOMString, init: &ProgressEventBinding::ProgressEventInit) - -> Fallible> { + -> Fallible> { let bubbles = EventBubbles::from(init.parent.bubbles); let cancelable = EventCancelable::from(init.parent.cancelable); let ev = ProgressEvent::new(global, Atom::from(type_), bubbles, cancelable, diff --git a/servo/components/script/dom/promisenativehandler.rs b/servo/components/script/dom/promisenativehandler.rs index 59fe1d7425b9..56c65c9a8011 100644 --- a/servo/components/script/dom/promisenativehandler.rs +++ b/servo/components/script/dom/promisenativehandler.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -26,7 +26,7 @@ impl PromiseNativeHandler { pub fn new(global: &GlobalScope, resolve: Option>, reject: Option>) - -> Root { + -> DomRoot { reflect_dom_object(box PromiseNativeHandler { reflector: Reflector::new(), resolve: resolve, diff --git a/servo/components/script/dom/radionodelist.rs b/servo/components/script/dom/radionodelist.rs index 07f479c6ed49..d9c3a010c34b 100644 --- a/servo/components/script/dom/radionodelist.rs +++ b/servo/components/script/dom/radionodelist.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; use dom::bindings::codegen::Bindings::RadioNodeListBinding; use dom::bindings::codegen::Bindings::RadioNodeListBinding::RadioNodeListMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::htmlinputelement::HTMLInputElement; use dom::node::Node; @@ -30,15 +30,15 @@ impl RadioNodeList { } #[allow(unrooted_must_root)] - pub fn new(window: &Window, list_type: NodeListType) -> Root { + pub fn new(window: &Window, list_type: NodeListType) -> DomRoot { reflect_dom_object(box RadioNodeList::new_inherited(list_type), window, RadioNodeListBinding::Wrap) } - pub fn new_simple_list(window: &Window, iter: T) -> Root - where T: Iterator> { - RadioNodeList::new(window, NodeListType::Simple(iter.map(|r| JS::from_ref(&*r)).collect())) + pub fn new_simple_list(window: &Window, iter: T) -> DomRoot + where T: Iterator> { + RadioNodeList::new(window, NodeListType::Simple(iter.map(|r| Dom::from_ref(&*r)).collect())) } // FIXME: This shouldn't need to be implemented here since NodeList (the parent of @@ -101,7 +101,7 @@ impl RadioNodeListMethods for RadioNodeList { // https://github.com/servo/servo/issues/5875 // // https://dom.spec.whatwg.org/#dom-nodelist-item - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.node_list.IndexedGetter(index) } } diff --git a/servo/components/script/dom/range.rs b/servo/components/script/dom/range.rs index 1e65caedc9dd..b6a05b31881c 100644 --- a/servo/components/script/dom/range.rs +++ b/servo/components/script/dom/range.rs @@ -13,8 +13,8 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::{CharacterDataTypeId, NodeTypeId}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutJS, Root, RootedReference}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutDom, RootedReference}; use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; use dom::bindings::weakref::{WeakRef, WeakRefVec}; @@ -49,7 +49,7 @@ impl Range { } } - pub fn new_with_doc(document: &Document) -> Root { + pub fn new_with_doc(document: &Document) -> DomRoot { let root = document.upcast(); Range::new(document, root, 0, root, 0) } @@ -57,7 +57,7 @@ impl Range { pub fn new(document: &Document, start_container: &Node, start_offset: u32, end_container: &Node, end_offset: u32) - -> Root { + -> DomRoot { let range = reflect_dom_object(box Range::new_inherited(start_container, start_offset, end_container, end_offset), document.window(), @@ -70,7 +70,7 @@ impl Range { } // https://dom.spec.whatwg.org/#dom-range - pub fn Constructor(window: &Window) -> Fallible> { + pub fn Constructor(window: &Window) -> Fallible> { let document = window.Document(); Ok(Range::new_with_doc(&document)) } @@ -91,9 +91,9 @@ impl Range { } // https://dom.spec.whatwg.org/#concept-range-clone - fn contained_children(&self) -> Fallible<(Option>, - Option>, - Vec>)> { + fn contained_children(&self) -> Fallible<(Option>, + Option>, + Vec>)> { let start_node = self.StartContainer(); let end_node = self.EndContainer(); // Steps 5-6. @@ -120,7 +120,7 @@ impl Range { }; // Step 11. - let contained_children: Vec> = + let contained_children: Vec> = common_ancestor.children().filter(|n| self.contains(n)).collect(); // Step 12. @@ -191,7 +191,7 @@ impl Range { impl RangeMethods for Range { // https://dom.spec.whatwg.org/#dom-range-startcontainer - fn StartContainer(&self) -> Root { + fn StartContainer(&self) -> DomRoot { self.start.node.get() } @@ -201,7 +201,7 @@ impl RangeMethods for Range { } // https://dom.spec.whatwg.org/#dom-range-endcontainer - fn EndContainer(&self) -> Root { + fn EndContainer(&self) -> DomRoot { self.end.node.get() } @@ -216,7 +216,7 @@ impl RangeMethods for Range { } // https://dom.spec.whatwg.org/#dom-range-commonancestorcontainer - fn CommonAncestorContainer(&self) -> Root { + fn CommonAncestorContainer(&self) -> DomRoot { let end_container = self.EndContainer(); // Step 1. for container in self.StartContainer().inclusive_ancestors() { @@ -366,7 +366,7 @@ impl RangeMethods for Range { } // https://dom.spec.whatwg.org/#dom-range-clonerange - fn CloneRange(&self) -> Root { + fn CloneRange(&self) -> DomRoot { let start_node = self.StartContainer(); let owner_doc = start_node.owner_doc(); Range::new(&owner_doc, &start_node, self.StartOffset(), @@ -425,7 +425,7 @@ impl RangeMethods for Range { // https://dom.spec.whatwg.org/#dom-range-clonecontents // https://dom.spec.whatwg.org/#concept-range-clone - fn CloneContents(&self) -> Fallible> { + fn CloneContents(&self) -> Fallible> { // Step 3. let start_node = self.StartContainer(); let start_offset = self.StartOffset(); @@ -524,7 +524,7 @@ impl RangeMethods for Range { // https://dom.spec.whatwg.org/#dom-range-extractcontents // https://dom.spec.whatwg.org/#concept-range-extract - fn ExtractContents(&self) -> Fallible> { + fn ExtractContents(&self) -> Fallible> { // Step 3. let start_node = self.StartContainer(); let start_offset = self.StartOffset(); @@ -563,13 +563,13 @@ impl RangeMethods for Range { let (new_node, new_offset) = if start_node.is_inclusive_ancestor_of(&end_node) { // Step 13. - (Root::from_ref(&*start_node), start_offset) + (DomRoot::from_ref(&*start_node), start_offset) } else { // Step 14.1-2. let reference_node = start_node.ancestors() .take_while(|n| !n.is_inclusive_ancestor_of(&end_node)) .last() - .unwrap_or(Root::from_ref(&start_node)); + .unwrap_or(DomRoot::from_ref(&start_node)); // Step 14.3. (reference_node.GetParentNode().unwrap(), reference_node.index() + 1) }; @@ -682,11 +682,11 @@ impl RangeMethods for Range { None => return Err(Error::HierarchyRequest) }; // Step 5. - (Some(Root::from_ref(&*start_node)), parent) + (Some(DomRoot::from_ref(&*start_node)), parent) } else { // Steps 4-5. let child = start_node.ChildNodes().Item(start_offset); - (child, Root::from_ref(&*start_node)) + (child, DomRoot::from_ref(&*start_node)) }; // Step 6. @@ -700,7 +700,7 @@ impl RangeMethods for Range { match start_node.downcast::() { Some(text) => { split_text = text.SplitText(start_offset)?; - let new_reference = Root::upcast::(split_text); + let new_reference = DomRoot::upcast::(split_text); assert!(new_reference.GetParentNode().r() == Some(&parent)); Some(new_reference) }, @@ -770,7 +770,7 @@ impl RangeMethods for Range { let mut next = iter.next(); while let Some(child) = next { if self.contains(&child) { - contained_children.push(JS::from_ref(&*child)); + contained_children.push(Dom::from_ref(&*child)); next = iter.next_skipping_children(); } else { next = iter.next(); @@ -779,11 +779,11 @@ impl RangeMethods for Range { let (new_node, new_offset) = if start_node.is_inclusive_ancestor_of(&end_node) { // Step 5. - (Root::from_ref(&*start_node), start_offset) + (DomRoot::from_ref(&*start_node), start_offset) } else { // Step 6. - fn compute_reference(start_node: &Node, end_node: &Node) -> (Root, u32) { - let mut reference_node = Root::from_ref(start_node); + fn compute_reference(start_node: &Node, end_node: &Node) -> (DomRoot, u32) { + let mut reference_node = DomRoot::from_ref(start_node); while let Some(parent) = reference_node.GetParentNode() { if parent.is_inclusive_ancestor_of(end_node) { return (parent, reference_node.index() + 1) @@ -879,7 +879,7 @@ impl RangeMethods for Range { // Step 4. let ancestor = self.CommonAncestorContainer(); let mut iter = start_node.following_nodes(&ancestor) - .filter_map(Root::downcast::); + .filter_map(DomRoot::downcast::); while let Some(child) = iter.next() { if self.contains(child.upcast()) { @@ -898,13 +898,13 @@ impl RangeMethods for Range { } // https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-range-interface - fn CreateContextualFragment(&self, fragment: DOMString) -> Fallible> { + fn CreateContextualFragment(&self, fragment: DOMString) -> Fallible> { // Step 1. let node = self.StartContainer(); let owner_doc = node.owner_doc(); let element = match node.type_id() { NodeTypeId::Document(_) | NodeTypeId::DocumentFragment => None, - NodeTypeId::Element(_) => Some(Root::downcast::(node).unwrap()), + NodeTypeId::Element(_) => Some(DomRoot::downcast::(node).unwrap()), NodeTypeId::CharacterData(CharacterDataTypeId::Comment) | NodeTypeId::CharacterData(CharacterDataTypeId::Text) => node.GetParentElement(), NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) | @@ -933,7 +933,7 @@ impl RangeMethods for Range { #[derive(DenyPublicFields, HeapSizeOf, JSTraceable)] #[must_root] pub struct BoundaryPoint { - node: MutJS, + node: MutDom, offset: Cell, } @@ -942,7 +942,7 @@ impl BoundaryPoint { debug_assert!(!node.is_doctype()); debug_assert!(offset <= node.len()); BoundaryPoint { - node: MutJS::new(node), + node: MutDom::new(node), offset: Cell::new(offset), } } diff --git a/servo/components/script/dom/request.rs b/servo/components/script/dom/request.rs index 8a673e85455c..204a7084f0a6 100644 --- a/servo/components/script/dom/request.rs +++ b/servo/components/script/dom/request.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use body::{BodyOperations, BodyType, consume_body}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods}; use dom::bindings::codegen::Bindings::RequestBinding; use dom::bindings::codegen::Bindings::RequestBinding::ReferrerPolicy; @@ -17,8 +17,8 @@ use dom::bindings::codegen::Bindings::RequestBinding::RequestMode; use dom::bindings::codegen::Bindings::RequestBinding::RequestRedirect; use dom::bindings::codegen::Bindings::RequestBinding::RequestType; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::{ByteString, DOMString, USVString}; use dom::bindings::trace::RootedTraceableBox; use dom::globalscope::GlobalScope; @@ -44,12 +44,12 @@ use std::rc::Rc; #[dom_struct] pub struct Request { reflector_: Reflector, - request: DOMRefCell, + request: DomRefCell, body_used: Cell, - headers: MutNullableJS, - mime_type: DOMRefCell>, + headers: MutNullableDom, + mime_type: DomRefCell>, #[ignore_heap_size_of = "Rc"] - body_promise: DOMRefCell, BodyType)>>, + body_promise: DomRefCell, BodyType)>>, } impl Request { @@ -57,17 +57,17 @@ impl Request { url: ServoUrl) -> Request { Request { reflector_: Reflector::new(), - request: DOMRefCell::new( + request: DomRefCell::new( net_request_from_global(global, url)), body_used: Cell::new(false), headers: Default::default(), - mime_type: DOMRefCell::new("".to_string().into_bytes()), - body_promise: DOMRefCell::new(None), + mime_type: DomRefCell::new("".to_string().into_bytes()), + body_promise: DomRefCell::new(None), } } pub fn new(global: &GlobalScope, - url: ServoUrl) -> Root { + url: ServoUrl) -> DomRoot { reflect_dom_object(box Request::new_inherited(global, url), global, RequestBinding::Wrap) @@ -77,7 +77,7 @@ impl Request { pub fn Constructor(global: &GlobalScope, input: RequestInfo, init: RootedTraceableBox) - -> Fallible> { + -> Fallible> { // Step 1 let temporary_request: NetTraitsRequest; @@ -293,7 +293,7 @@ impl Request { if let Some(possible_header) = init.headers.as_ref() { match possible_header { &HeadersInit::Headers(ref init_headers) => { - headers_copy = Root::from_ref(&*init_headers); + headers_copy = DomRoot::from_ref(&*init_headers); } &HeadersInit::ByteStringSequenceSequence(ref init_sequence) => { headers_copy.fill(Some( @@ -310,7 +310,7 @@ impl Request { // We cannot empty `r.Headers().header_list` because // we would undo the Step 27 above. One alternative is to set // `headers_copy` as a deep copy of `r.Headers()`. However, - // `r.Headers()` is a `Root`, and therefore it is difficult + // `r.Headers()` is a `DomRoot`, and therefore it is difficult // to obtain a mutable reference to `r.Headers()`. Without the // mutable reference, we cannot mutate `r.Headers()` to be the // deep copied headers in Step 27. @@ -405,14 +405,14 @@ impl Request { impl Request { fn from_net_request(global: &GlobalScope, - net_request: NetTraitsRequest) -> Root { + net_request: NetTraitsRequest) -> DomRoot { let r = Request::new(global, net_request.current_url()); *r.request.borrow_mut() = net_request; r } - fn clone_from(r: &Request) -> Fallible> { + fn clone_from(r: &Request) -> Fallible> { let req = r.request.borrow(); let url = req.url(); let body_used = r.body_used.get(); @@ -523,7 +523,7 @@ impl RequestMethods for Request { } // https://fetch.spec.whatwg.org/#dom-request-headers - fn Headers(&self) -> Root { + fn Headers(&self) -> DomRoot { self.headers.or_init(|| Headers::new(&self.global())) } @@ -590,7 +590,7 @@ impl RequestMethods for Request { } // https://fetch.spec.whatwg.org/#dom-request-clone - fn Clone(&self) -> Fallible> { + fn Clone(&self) -> Fallible> { // Step 1 if request_is_locked(self) { return Err(Error::Type("Request is locked".to_string())); @@ -792,7 +792,7 @@ impl Into for NetTraitsRequestMode { NetTraitsRequestMode::SameOrigin => RequestMode::Same_origin, NetTraitsRequestMode::NoCors => RequestMode::No_cors, NetTraitsRequestMode::CorsMode => RequestMode::Cors, - NetTraitsRequestMode::WebSocket => unreachable!("Websocket request mode should never be exposed to JS"), + NetTraitsRequestMode::WebSocket => unreachable!("Websocket request mode should never be exposed to Dom"), } } } diff --git a/servo/components/script/dom/response.rs b/servo/components/script/dom/response.rs index c2b2dd20346c..a874aac77e68 100644 --- a/servo/components/script/dom/response.rs +++ b/servo/components/script/dom/response.rs @@ -4,14 +4,14 @@ use body::{BodyOperations, BodyType, consume_body, consume_body_with_promise}; use core::cell::Cell; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods}; use dom::bindings::codegen::Bindings::ResponseBinding; use dom::bindings::codegen::Bindings::ResponseBinding::{ResponseMethods, ResponseType as DOMResponseType}; use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::BodyInit; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::{ByteString, USVString}; use dom::globalscope::GlobalScope; use dom::headers::{Headers, Guard}; @@ -33,20 +33,20 @@ use url::Position; #[dom_struct] pub struct Response { reflector_: Reflector, - headers_reflector: MutNullableJS, - mime_type: DOMRefCell>, + headers_reflector: MutNullableDom, + mime_type: DomRefCell>, body_used: Cell, /// `None` can be considered a StatusCode of `0`. #[ignore_heap_size_of = "Defined in hyper"] - status: DOMRefCell>, - raw_status: DOMRefCell)>>, - response_type: DOMRefCell, - url: DOMRefCell>, - url_list: DOMRefCell>, + status: DomRefCell>, + raw_status: DomRefCell)>>, + response_type: DomRefCell, + url: DomRefCell>, + url_list: DomRefCell>, // For now use the existing NetTraitsResponseBody enum - body: DOMRefCell, + body: DomRefCell, #[ignore_heap_size_of = "Rc"] - body_promise: DOMRefCell, BodyType)>>, + body_promise: DomRefCell, BodyType)>>, } impl Response { @@ -54,25 +54,25 @@ impl Response { Response { reflector_: Reflector::new(), headers_reflector: Default::default(), - mime_type: DOMRefCell::new("".to_string().into_bytes()), + mime_type: DomRefCell::new("".to_string().into_bytes()), body_used: Cell::new(false), - status: DOMRefCell::new(Some(StatusCode::Ok)), - raw_status: DOMRefCell::new(Some((200, b"OK".to_vec()))), - response_type: DOMRefCell::new(DOMResponseType::Default), - url: DOMRefCell::new(None), - url_list: DOMRefCell::new(vec![]), - body: DOMRefCell::new(NetTraitsResponseBody::Empty), - body_promise: DOMRefCell::new(None), + status: DomRefCell::new(Some(StatusCode::Ok)), + raw_status: DomRefCell::new(Some((200, b"OK".to_vec()))), + response_type: DomRefCell::new(DOMResponseType::Default), + url: DomRefCell::new(None), + url_list: DomRefCell::new(vec![]), + body: DomRefCell::new(NetTraitsResponseBody::Empty), + body_promise: DomRefCell::new(None), } } // https://fetch.spec.whatwg.org/#dom-response - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box Response::new_inherited(), global, ResponseBinding::Wrap) } pub fn Constructor(global: &GlobalScope, body: Option, init: &ResponseBinding::ResponseInit) - -> Fallible> { + -> Fallible> { // Step 1 if init.status < 200 || init.status > 599 { return Err(Error::Range( @@ -139,7 +139,7 @@ impl Response { } // https://fetch.spec.whatwg.org/#dom-response-error - pub fn Error(global: &GlobalScope) -> Root { + pub fn Error(global: &GlobalScope) -> DomRoot { let r = Response::new(global); *r.response_type.borrow_mut() = DOMResponseType::Error; r.Headers().set_guard(Guard::Immutable); @@ -148,7 +148,7 @@ impl Response { } // https://fetch.spec.whatwg.org/#dom-response-redirect - pub fn Redirect(global: &GlobalScope, url: USVString, status: u16) -> Fallible> { + pub fn Redirect(global: &GlobalScope, url: USVString, status: u16) -> Fallible> { // Step 1 let base_url = global.api_base_url(); let parsed_url = base_url.join(&url.0); @@ -291,12 +291,12 @@ impl ResponseMethods for Response { } // https://fetch.spec.whatwg.org/#dom-response-headers - fn Headers(&self) -> Root { + fn Headers(&self) -> DomRoot { self.headers_reflector.or_init(|| Headers::for_response(&self.global())) } // https://fetch.spec.whatwg.org/#dom-response-clone - fn Clone(&self) -> Fallible> { + fn Clone(&self) -> Fallible> { // Step 1 if self.is_locked() || self.body_used.get() { return Err(Error::Type("cannot clone a disturbed response".to_string())); diff --git a/servo/components/script/dom/screen.rs b/servo/components/script/dom/screen.rs index 80e5bf8d5c6f..88a9025f76f2 100644 --- a/servo/components/script/dom/screen.rs +++ b/servo/components/script/dom/screen.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::ScreenBinding; use dom::bindings::codegen::Bindings::ScreenBinding::ScreenMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::window::Window; use dom_struct::dom_struct; @@ -21,7 +21,7 @@ impl Screen { } } - pub fn new(window: &Window) -> Root { + pub fn new(window: &Window) -> DomRoot { reflect_dom_object(box Screen::new_inherited(), window, ScreenBinding::Wrap) diff --git a/servo/components/script/dom/serviceworker.rs b/servo/components/script/dom/serviceworker.rs index 51c75309050b..95c37d27c8e9 100644 --- a/servo/components/script/dom/serviceworker.rs +++ b/servo/components/script/dom/serviceworker.rs @@ -3,13 +3,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::abstractworker::SimpleWorkerErrorHandler; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::ServiceWorkerBinding::{ServiceWorkerMethods, ServiceWorkerState, Wrap}; use dom::bindings::error::{ErrorResult, Error}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::USVString; use dom::bindings::structuredclone::StructuredCloneData; use dom::eventtarget::EventTarget; @@ -26,7 +26,7 @@ pub type TrustedServiceWorkerAddress = Trusted; #[dom_struct] pub struct ServiceWorker { eventtarget: EventTarget, - script_url: DOMRefCell, + script_url: DomRefCell, scope_url: ServoUrl, state: Cell, skip_waiting: Cell @@ -38,7 +38,7 @@ impl ServiceWorker { scope_url: ServoUrl) -> ServiceWorker { ServiceWorker { eventtarget: EventTarget::new_inherited(), - script_url: DOMRefCell::new(String::from(script_url)), + script_url: DomRefCell::new(String::from(script_url)), state: Cell::new(ServiceWorkerState::Installing), scope_url: scope_url, skip_waiting: Cell::new(skip_waiting) @@ -48,7 +48,7 @@ impl ServiceWorker { pub fn install_serviceworker(global: &GlobalScope, script_url: ServoUrl, scope_url: ServoUrl, - skip_waiting: bool) -> Root { + skip_waiting: bool) -> DomRoot { reflect_dom_object(box ServiceWorker::new_inherited(script_url.as_str(), skip_waiting, scope_url), global, Wrap) diff --git a/servo/components/script/dom/serviceworkercontainer.rs b/servo/components/script/dom/serviceworkercontainer.rs index ed423c0a849a..9c853be24032 100644 --- a/servo/components/script/dom/serviceworkercontainer.rs +++ b/servo/components/script/dom/serviceworkercontainer.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{ServiceWorkerContainerMethods, Wrap}; use dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions; use dom::bindings::error::Error; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::USVString; use dom::client::Client; use dom::eventtarget::EventTarget; @@ -23,8 +23,8 @@ use std::rc::Rc; #[dom_struct] pub struct ServiceWorkerContainer { eventtarget: EventTarget, - controller: MutNullableJS, - client: JS + controller: MutNullableDom, + client: Dom } impl ServiceWorkerContainer { @@ -32,12 +32,12 @@ impl ServiceWorkerContainer { ServiceWorkerContainer { eventtarget: EventTarget::new_inherited(), controller: Default::default(), - client: JS::from_ref(client), + client: Dom::from_ref(client), } } #[allow(unrooted_must_root)] - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { let client = Client::new(&global.as_window()); let container = ServiceWorkerContainer::new_inherited(&*client); reflect_dom_object(box container, global, Wrap) @@ -46,7 +46,7 @@ impl ServiceWorkerContainer { impl ServiceWorkerContainerMethods for ServiceWorkerContainer { // https://w3c.github.io/ServiceWorker/#service-worker-container-controller-attribute - fn GetController(&self) -> Option> { + fn GetController(&self) -> Option> { self.client.get_controller() } diff --git a/servo/components/script/dom/serviceworkerglobalscope.rs b/servo/components/script/dom/serviceworkerglobalscope.rs index 5f3a2b82aa2a..5e4ad439c904 100644 --- a/servo/components/script/dom/serviceworkerglobalscope.rs +++ b/servo/components/script/dom/serviceworkerglobalscope.rs @@ -8,8 +8,8 @@ use dom::abstractworker::WorkerScriptMsg; use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding; use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding::ServiceWorkerGlobalScopeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{Root, RootCollection}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{DomRoot, RootCollection}; use dom::bindings::str::DOMString; use dom::event::Event; use dom::eventtarget::EventTarget; @@ -120,7 +120,7 @@ impl ServiceWorkerGlobalScope { timer_event_port: Receiver<()>, swmanager_sender: IpcSender, scope_url: ServoUrl) - -> Root { + -> DomRoot { let cx = runtime.cx(); let scope = box ServiceWorkerGlobalScope::new_inherited(init, worker_url, @@ -322,7 +322,7 @@ impl ServiceWorkerGlobalScope { #[allow(unsafe_code)] unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool { let worker = - Root::downcast::(GlobalScope::from_context(cx)) + DomRoot::downcast::(GlobalScope::from_context(cx)) .expect("global is not a worker scope"); assert!(worker.is::()); diff --git a/servo/components/script/dom/serviceworkerregistration.rs b/servo/components/script/dom/serviceworkerregistration.rs index b296b62b6c5b..aab043909437 100644 --- a/servo/components/script/dom/serviceworkerregistration.rs +++ b/servo/components/script/dom/serviceworkerregistration.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::ServiceWorkerBinding::ServiceWorkerState; use dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::{ServiceWorkerRegistrationMethods, Wrap}; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::USVString; use dom::eventtarget::EventTarget; use dom::globalscope::GlobalScope; @@ -20,9 +20,9 @@ use std::cell::Cell; #[dom_struct] pub struct ServiceWorkerRegistration { eventtarget: EventTarget, - active: Option>, - installing: Option>, - waiting: Option>, + active: Option>, + installing: Option>, + waiting: Option>, scope: ServoUrl, uninstalling: Cell } @@ -31,7 +31,7 @@ impl ServiceWorkerRegistration { fn new_inherited(active_sw: &ServiceWorker, scope: ServoUrl) -> ServiceWorkerRegistration { ServiceWorkerRegistration { eventtarget: EventTarget::new_inherited(), - active: Some(JS::from_ref(active_sw)), + active: Some(Dom::from_ref(active_sw)), installing: None, waiting: None, scope: scope, @@ -41,7 +41,7 @@ impl ServiceWorkerRegistration { #[allow(unrooted_must_root)] pub fn new(global: &GlobalScope, script_url: &ServoUrl, - scope: ServoUrl) -> Root { + scope: ServoUrl) -> DomRoot { let active_worker = ServiceWorker::install_serviceworker(global, script_url.clone(), scope.clone(), true); active_worker.set_transition_state(ServiceWorkerState::Installed); reflect_dom_object(box ServiceWorkerRegistration::new_inherited(&*active_worker, scope), global, Wrap) @@ -79,13 +79,13 @@ impl ServiceWorkerRegistration { } // https://w3c.github.io/ServiceWorker/#get-newest-worker-algorithm - pub fn get_newest_worker(&self) -> Option> { + pub fn get_newest_worker(&self) -> Option> { if self.installing.as_ref().is_some() { - self.installing.as_ref().map(|sw| Root::from_ref(&**sw)) + self.installing.as_ref().map(|sw| DomRoot::from_ref(&**sw)) } else if self.waiting.as_ref().is_some() { - self.waiting.as_ref().map(|sw| Root::from_ref(&**sw)) + self.waiting.as_ref().map(|sw| DomRoot::from_ref(&**sw)) } else { - self.active.as_ref().map(|sw| Root::from_ref(&**sw)) + self.active.as_ref().map(|sw| DomRoot::from_ref(&**sw)) } } } @@ -105,18 +105,18 @@ pub fn longest_prefix_match(stored_scope: &ServoUrl, potential_match: &ServoUrl) impl ServiceWorkerRegistrationMethods for ServiceWorkerRegistration { // https://w3c.github.io/ServiceWorker/#service-worker-registration-installing-attribute - fn GetInstalling(&self) -> Option> { - self.installing.as_ref().map(|sw| Root::from_ref(&**sw)) + fn GetInstalling(&self) -> Option> { + self.installing.as_ref().map(|sw| DomRoot::from_ref(&**sw)) } // https://w3c.github.io/ServiceWorker/#service-worker-registration-active-attribute - fn GetActive(&self) -> Option> { - self.active.as_ref().map(|sw| Root::from_ref(&**sw)) + fn GetActive(&self) -> Option> { + self.active.as_ref().map(|sw| DomRoot::from_ref(&**sw)) } // https://w3c.github.io/ServiceWorker/#service-worker-registration-waiting-attribute - fn GetWaiting(&self) -> Option> { - self.waiting.as_ref().map(|sw| Root::from_ref(&**sw)) + fn GetWaiting(&self) -> Option> { + self.waiting.as_ref().map(|sw| DomRoot::from_ref(&**sw)) } // https://w3c.github.io/ServiceWorker/#service-worker-registration-scope-attribute diff --git a/servo/components/script/dom/servoparser/async_html.rs b/servo/components/script/dom/servoparser/async_html.rs index ec4bc6e070b7..05df90c5c84a 100644 --- a/servo/components/script/dom/servoparser/async_html.rs +++ b/servo/components/script/dom/servoparser/async_html.rs @@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::comment::Comment; use dom::document::Document; @@ -168,13 +168,13 @@ fn create_buffer_queue(mut buffers: VecDeque>) -> BufferQueue #[derive(HeapSizeOf, JSTraceable)] #[must_root] pub struct Tokenizer { - document: JS, + document: Dom, #[ignore_heap_size_of = "Defined in std"] receiver: Receiver, #[ignore_heap_size_of = "Defined in std"] html_tokenizer_sender: Sender, #[ignore_heap_size_of = "Defined in std"] - nodes: HashMap>, + nodes: HashMap>, url: ServoUrl, } @@ -190,13 +190,13 @@ impl Tokenizer { let (to_tokenizer_sender, tokenizer_receiver) = channel(); let mut tokenizer = Tokenizer { - document: JS::from_ref(document), + document: Dom::from_ref(document), receiver: tokenizer_receiver, html_tokenizer_sender: to_html_tokenizer_sender, nodes: HashMap::new(), url: url }; - tokenizer.insert_node(0, JS::from_ref(document.upcast())); + tokenizer.insert_node(0, Dom::from_ref(document.upcast())); let mut sink = Sink::new(to_tokenizer_sender.clone()); let mut ctxt_parse_node = None; @@ -204,12 +204,12 @@ impl Tokenizer { let mut fragment_context_is_some = false; if let Some(fc) = fragment_context { let node = sink.new_parse_node(); - tokenizer.insert_node(node.id, JS::from_ref(fc.context_elem)); + tokenizer.insert_node(node.id, Dom::from_ref(fc.context_elem)); ctxt_parse_node = Some(node); form_parse_node = fc.form_elem.map(|form_elem| { let node = sink.new_parse_node(); - tokenizer.insert_node(node.id, JS::from_ref(form_elem)); + tokenizer.insert_node(node.id, Dom::from_ref(form_elem)); node }); fragment_context_is_some = true; @@ -230,7 +230,7 @@ impl Tokenizer { tokenizer } - pub fn feed(&mut self, input: &mut BufferQueue) -> Result<(), Root> { + pub fn feed(&mut self, input: &mut BufferQueue) -> Result<(), DomRoot> { let mut send_tendrils = VecDeque::new(); while let Some(str) = input.pop_front() { send_tendrils.push_back(SendTendril::from(str)); @@ -252,7 +252,7 @@ impl Tokenizer { let buffer_queue = create_buffer_queue(updated_input); *input = buffer_queue; let script = self.get_node(&script.id); - return Err(Root::from_ref(script.downcast().unwrap())); + return Err(DomRoot::from_ref(script.downcast().unwrap())); } ToTokenizerMsg::End => unreachable!(), }; @@ -278,18 +278,18 @@ impl Tokenizer { self.html_tokenizer_sender.send(ToHtmlTokenizerMsg::SetPlainTextState).unwrap(); } - fn insert_node(&mut self, id: ParseNodeId, node: JS) { + fn insert_node(&mut self, id: ParseNodeId, node: Dom) { assert!(self.nodes.insert(id, node).is_none()); } - fn get_node<'a>(&'a self, id: &ParseNodeId) -> &'a JS { + fn get_node<'a>(&'a self, id: &ParseNodeId) -> &'a Dom { self.nodes.get(id).expect("Node not found!") } fn append_before_sibling(&mut self, sibling: ParseNodeId, node: NodeOrText) { let node = match node { - NodeOrText::Node(n) => HtmlNodeOrText::AppendNode(JS::from_ref(&**self.get_node(&n.id))), + NodeOrText::Node(n) => HtmlNodeOrText::AppendNode(Dom::from_ref(&**self.get_node(&n.id))), NodeOrText::Text(text) => HtmlNodeOrText::AppendText( Tendril::from(text) ) @@ -302,7 +302,7 @@ impl Tokenizer { fn append(&mut self, parent: ParseNodeId, node: NodeOrText) { let node = match node { - NodeOrText::Node(n) => HtmlNodeOrText::AppendNode(JS::from_ref(&**self.get_node(&n.id))), + NodeOrText::Node(n) => HtmlNodeOrText::AppendNode(Dom::from_ref(&**self.get_node(&n.id))), NodeOrText::Text(text) => HtmlNodeOrText::AppendText( Tendril::from(text) ) @@ -326,14 +326,14 @@ impl Tokenizer { } fn process_operation(&mut self, op: ParseOperation) { - let document = Root::from_ref(&**self.get_node(&0)); + let document = DomRoot::from_ref(&**self.get_node(&0)); let document = document.downcast::().expect("Document node should be downcasted!"); match op { ParseOperation::GetTemplateContents { target, contents } => { - let target = Root::from_ref(&**self.get_node(&target)); + let target = DomRoot::from_ref(&**self.get_node(&target)); let template = target.downcast::().expect( "Tried to extract contents from non-template element while parsing"); - self.insert_node(contents, JS::from_ref(template.Content().upcast())); + self.insert_node(contents, Dom::from_ref(template.Content().upcast())); } ParseOperation::CreateElement { node, name, attrs, current_line } => { let is = attrs.iter() @@ -349,11 +349,11 @@ impl Tokenizer { elem.set_attribute_from_parser(attr.name, DOMString::from(attr.value), None); } - self.insert_node(node, JS::from_ref(elem.upcast())); + self.insert_node(node, Dom::from_ref(elem.upcast())); } ParseOperation::CreateComment { text, node } => { let comment = Comment::new(DOMString::from(text), document); - self.insert_node(node, JS::from_ref(&comment.upcast())); + self.insert_node(node, Dom::from_ref(&comment.upcast())); } ParseOperation::AppendBeforeSibling { sibling, node } => { self.append_before_sibling(sibling, node); @@ -407,7 +407,7 @@ impl Tokenizer { return; } let form = self.get_node(&form); - let form = Root::downcast::(Root::from_ref(&**form)) + let form = DomRoot::downcast::(DomRoot::from_ref(&**form)) .expect("Owner must be a form element"); let node = self.get_node(&target); @@ -429,7 +429,7 @@ impl Tokenizer { DOMString::from(target), DOMString::from(data), document); - self.insert_node(node, JS::from_ref(pi.upcast())); + self.insert_node(node, Dom::from_ref(pi.upcast())); } ParseOperation::SetQuirksMode { mode } => { document.set_quirks_mode(mode); diff --git a/servo/components/script/dom/servoparser/html.rs b/servo/components/script/dom/servoparser/html.rs index 4621faacf545..86c2b5519403 100644 --- a/servo/components/script/dom/servoparser/html.rs +++ b/servo/components/script/dom/servoparser/html.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use dom::bindings::inheritance::{Castable, CharacterDataTypeId, NodeTypeId}; -use dom::bindings::js::{JS, Root}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::trace::JSTraceable; use dom::characterdata::CharacterData; use dom::document::Document; @@ -32,7 +32,7 @@ use std::io; #[must_root] pub struct Tokenizer { #[ignore_heap_size_of = "Defined in html5ever"] - inner: HtmlTokenizer, Sink>>, + inner: HtmlTokenizer, Sink>>, } impl Tokenizer { @@ -43,7 +43,7 @@ impl Tokenizer { -> Self { let sink = Sink { base_url: url, - document: JS::from_ref(document), + document: Dom::from_ref(document), current_line: 1, script: Default::default(), }; @@ -56,8 +56,8 @@ impl Tokenizer { let inner = if let Some(fc) = fragment_context { let tb = TreeBuilder::new_for_fragment( sink, - JS::from_ref(fc.context_elem), - fc.form_elem.map(|n| JS::from_ref(n)), + Dom::from_ref(fc.context_elem), + fc.form_elem.map(|n| Dom::from_ref(n)), options); let tok_options = TokenizerOpts { @@ -75,10 +75,10 @@ impl Tokenizer { } } - pub fn feed(&mut self, input: &mut BufferQueue) -> Result<(), Root> { + pub fn feed(&mut self, input: &mut BufferQueue) -> Result<(), DomRoot> { match self.inner.feed(input) { TokenizerResult::Done => Ok(()), - TokenizerResult::Script(script) => Err(Root::from_ref(script.downcast().unwrap())), + TokenizerResult::Script(script) => Err(DomRoot::from_ref(script.downcast().unwrap())), } } @@ -96,15 +96,15 @@ impl Tokenizer { } #[allow(unsafe_code)] -unsafe impl JSTraceable for HtmlTokenizer, Sink>> { +unsafe impl JSTraceable for HtmlTokenizer, Sink>> { unsafe fn trace(&self, trc: *mut JSTracer) { struct Tracer(*mut JSTracer); let tracer = Tracer(trc); impl HtmlTracer for Tracer { - type Handle = JS; + type Handle = Dom; #[allow(unrooted_must_root)] - fn trace_handle(&self, node: &JS) { + fn trace_handle(&self, node: &Dom) { unsafe { node.trace(self.0); } } } @@ -140,16 +140,16 @@ fn end_element(node: &Element, serializer: &mut S) -> io::Result< enum SerializationCommand { - OpenElement(Root), - CloseElement(Root), - SerializeNonelement(Root), + OpenElement(DomRoot), + CloseElement(DomRoot), + SerializeNonelement(DomRoot), } struct SerializationIterator { stack: Vec, } -fn rev_children_iter(n: &Node) -> impl Iterator>{ +fn rev_children_iter(n: &Node) -> impl Iterator>{ match n.downcast::() { Some(t) => t.Content().upcast::().rev_children(), None => n.rev_children(), @@ -173,8 +173,8 @@ impl SerializationIterator { fn push_node(&mut self, n: &Node) { match n.downcast::() { - Some(e) => self.stack.push(SerializationCommand::OpenElement(Root::from_ref(e))), - None => self.stack.push(SerializationCommand::SerializeNonelement(Root::from_ref(n))), + Some(e) => self.stack.push(SerializationCommand::OpenElement(DomRoot::from_ref(e))), + None => self.stack.push(SerializationCommand::SerializeNonelement(DomRoot::from_ref(n))), } } } diff --git a/servo/components/script/dom/servoparser/mod.rs b/servo/components/script/dom/servoparser/mod.rs index d0e08664e73a..b458bc047be3 100644 --- a/servo/components/script/dom/servoparser/mod.rs +++ b/servo/components/script/dom/servoparser/mod.rs @@ -3,16 +3,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use document_loader::{DocumentLoader, LoadType}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState}; use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods; use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::ServoParserBinding; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::characterdata::CharacterData; use dom::comment::Comment; @@ -72,18 +72,18 @@ mod xml; pub struct ServoParser { reflector: Reflector, /// The document associated with this parser. - document: JS, + document: Dom, /// Input received from network. #[ignore_heap_size_of = "Defined in html5ever"] - network_input: DOMRefCell, + network_input: DomRefCell, /// Part of an UTF-8 code point spanning input chunks #[ignore_heap_size_of = "Defined in html5ever"] - incomplete_utf8: DOMRefCell>, + incomplete_utf8: DomRefCell>, /// Input received from script. Used only to support document.write(). #[ignore_heap_size_of = "Defined in html5ever"] - script_input: DOMRefCell, + script_input: DomRefCell, /// The tokenizer of this parser. - tokenizer: DOMRefCell, + tokenizer: DomRefCell, /// Whether to expect any further input from the associated network request. last_chunk_received: Cell, /// Whether this parser should avoid passing any further data to the tokenizer. @@ -119,7 +119,7 @@ impl ServoParser { } // https://html.spec.whatwg.org/multipage/#parsing-html-fragments - pub fn parse_html_fragment(context: &Element, input: DOMString) -> impl Iterator> { + pub fn parse_html_fragment(context: &Element, input: DOMString) -> impl Iterator> { let context_node = context.upcast::(); let context_document = context_node.owner_doc(); let window = context_document.window(); @@ -319,11 +319,11 @@ impl ServoParser { -> Self { ServoParser { reflector: Reflector::new(), - document: JS::from_ref(document), - incomplete_utf8: DOMRefCell::new(None), - network_input: DOMRefCell::new(BufferQueue::new()), - script_input: DOMRefCell::new(BufferQueue::new()), - tokenizer: DOMRefCell::new(tokenizer), + document: Dom::from_ref(document), + incomplete_utf8: DomRefCell::new(None), + network_input: DomRefCell::new(BufferQueue::new()), + script_input: DomRefCell::new(BufferQueue::new()), + tokenizer: DomRefCell::new(tokenizer), last_chunk_received: Cell::new(last_chunk_state == LastChunkState::Received), suspended: Default::default(), script_nesting_level: Default::default(), @@ -337,7 +337,7 @@ impl ServoParser { tokenizer: Tokenizer, last_chunk_state: LastChunkState, kind: ParserKind) - -> Root { + -> DomRoot { reflect_dom_object(box ServoParser::new_inherited(document, tokenizer, last_chunk_state, kind), document.window(), ServoParserBinding::Wrap) @@ -422,7 +422,7 @@ impl ServoParser { } fn tokenize(&self, mut feed: F) - where F: FnMut(&mut Tokenizer) -> Result<(), Root>, + where F: FnMut(&mut Tokenizer) -> Result<(), DomRoot>, { loop { assert!(!self.suspended.get()); @@ -469,17 +469,17 @@ impl ServoParser { } struct FragmentParsingResult - where I: Iterator> + where I: Iterator> { inner: I, } impl Iterator for FragmentParsingResult - where I: Iterator> + where I: Iterator> { - type Item = Root; + type Item = DomRoot; - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option> { let next = match self.inner.next() { Some(next) => next, None => return None, @@ -508,7 +508,7 @@ enum Tokenizer { } impl Tokenizer { - fn feed(&mut self, input: &mut BufferQueue) -> Result<(), Root> { + fn feed(&mut self, input: &mut BufferQueue) -> Result<(), DomRoot> { match *self { Tokenizer::Html(ref mut tokenizer) => tokenizer.feed(input), Tokenizer::AsyncHtml(ref mut tokenizer) => tokenizer.feed(input), @@ -624,10 +624,10 @@ impl FetchResponseListener for ParserContext { parser.parse_sync(); let doc = &parser.document; - let doc_body = Root::upcast::(doc.GetBody().unwrap()); + let doc_body = DomRoot::upcast::(doc.GetBody().unwrap()); let img = HTMLImageElement::new(local_name!("img"), None, doc); img.SetSrc(DOMString::from(self.url.to_string())); - doc_body.AppendChild(&Root::upcast::(img)).expect("Appending failed"); + doc_body.AppendChild(&DomRoot::upcast::(img)).expect("Appending failed"); }, Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) => { @@ -721,7 +721,7 @@ pub struct FragmentContext<'a> { } #[allow(unrooted_must_root)] -fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText>) { +fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText>) { match child { NodeOrText::AppendNode(n) => { parent.InsertBefore(&n, reference_child).unwrap(); @@ -730,7 +730,7 @@ fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText); + .and_then(DomRoot::downcast::); if let Some(text) = text { text.upcast::().append_data(&t); @@ -746,9 +746,9 @@ fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText, + document: Dom, current_line: u64, - script: MutNullableJS, + script: MutNullableDom, } #[allow(unrooted_must_root)] // FIXME: really? @@ -756,23 +756,23 @@ impl TreeSink for Sink { type Output = Self; fn finish(self) -> Self { self } - type Handle = JS; + type Handle = Dom; - fn get_document(&mut self) -> JS { - JS::from_ref(self.document.upcast()) + fn get_document(&mut self) -> Dom { + Dom::from_ref(self.document.upcast()) } - fn get_template_contents(&mut self, target: &JS) -> JS { + fn get_template_contents(&mut self, target: &Dom) -> Dom { let template = target.downcast::() .expect("tried to get template contents of non-HTMLTemplateElement in HTML parsing"); - JS::from_ref(template.Content().upcast()) + Dom::from_ref(template.Content().upcast()) } - fn same_node(&self, x: &JS, y: &JS) -> bool { + fn same_node(&self, x: &Dom, y: &Dom) -> bool { x == y } - fn elem_name<'a>(&self, target: &'a JS) -> ExpandedName<'a> { + fn elem_name<'a>(&self, target: &'a Dom) -> ExpandedName<'a> { let elem = target.downcast::() .expect("tried to get name of non-Element in HTML parsing"); ExpandedName { @@ -781,7 +781,7 @@ impl TreeSink for Sink { } } - fn same_tree(&self, x: &JS, y: &JS) -> bool { + fn same_tree(&self, x: &Dom, y: &Dom) -> bool { let x = x.downcast::().expect("Element node expected"); let y = y.downcast::().expect("Element node expected"); @@ -789,7 +789,7 @@ impl TreeSink for Sink { } fn create_element(&mut self, name: QualName, attrs: Vec, _flags: ElementFlags) - -> JS { + -> Dom { let is = attrs.iter() .find(|attr| attr.name.local.eq_str_ignore_ascii_case("is")) .map(|attr| LocalName::from(&*attr.value)); @@ -804,27 +804,27 @@ impl TreeSink for Sink { elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None); } - JS::from_ref(elem.upcast()) + Dom::from_ref(elem.upcast()) } - fn create_comment(&mut self, text: StrTendril) -> JS { + fn create_comment(&mut self, text: StrTendril) -> Dom { let comment = Comment::new(DOMString::from(String::from(text)), &*self.document); - JS::from_ref(comment.upcast()) + Dom::from_ref(comment.upcast()) } - fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> JS { + fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Dom { let doc = &*self.document; let pi = ProcessingInstruction::new( DOMString::from(String::from(target)), DOMString::from(String::from(data)), doc); - JS::from_ref(pi.upcast()) + Dom::from_ref(pi.upcast()) } - fn has_parent_node(&self, node: &JS) -> bool { + fn has_parent_node(&self, node: &Dom) -> bool { node.GetParentNode().is_some() } - fn associate_with_form(&mut self, target: &JS, form: &JS, nodes: (&JS, Option<&JS>)) { + fn associate_with_form(&mut self, target: &Dom, form: &Dom, nodes: (&Dom, Option<&Dom>)) { let (element, prev_element) = nodes; let tree_node = prev_element.map_or(element, |prev| { if self.has_parent_node(element) { element } else { prev } @@ -834,7 +834,7 @@ impl TreeSink for Sink { } let node = target; - let form = Root::downcast::(Root::from_ref(&**form)) + let form = DomRoot::downcast::(DomRoot::from_ref(&**form)) .expect("Owner must be a form element"); let elem = node.downcast::(); @@ -849,8 +849,8 @@ impl TreeSink for Sink { } fn append_before_sibling(&mut self, - sibling: &JS, - new_node: NodeOrText>) { + sibling: &Dom, + new_node: NodeOrText>) { let parent = sibling.GetParentNode() .expect("append_before_sibling called on node without parent"); @@ -870,15 +870,15 @@ impl TreeSink for Sink { self.document.set_quirks_mode(mode); } - fn append(&mut self, parent: &JS, child: NodeOrText>) { + fn append(&mut self, parent: &Dom, child: NodeOrText>) { insert(&parent, None, child); } fn append_based_on_parent_node( &mut self, - elem: &JS, - prev_elem: &JS, - child: NodeOrText>, + elem: &Dom, + prev_elem: &Dom, + child: NodeOrText>, ) { if self.has_parent_node(elem) { self.append_before_sibling(elem, child); @@ -896,7 +896,7 @@ impl TreeSink for Sink { doc.upcast::().AppendChild(doctype.upcast()).expect("Appending failed"); } - fn add_attrs_if_missing(&mut self, target: &JS, attrs: Vec) { + fn add_attrs_if_missing(&mut self, target: &Dom, attrs: Vec) { let elem = target.downcast::() .expect("tried to set attrs on non-Element in HTML parsing"); for attr in attrs { @@ -904,18 +904,18 @@ impl TreeSink for Sink { } } - fn remove_from_parent(&mut self, target: &JS) { + fn remove_from_parent(&mut self, target: &Dom) { if let Some(ref parent) = target.GetParentNode() { parent.RemoveChild(&*target).unwrap(); } } - fn mark_script_already_started(&mut self, node: &JS) { + fn mark_script_already_started(&mut self, node: &Dom) { let script = node.downcast::(); script.map(|script| script.set_already_started(true)); } - fn complete_script(&mut self, node: &JS) -> NextParserState { + fn complete_script(&mut self, node: &Dom) -> NextParserState { if let Some(script) = node.downcast() { self.script.set(Some(script)); NextParserState::Suspend @@ -924,7 +924,7 @@ impl TreeSink for Sink { } } - fn reparent_children(&mut self, node: &JS, new_parent: &JS) { + fn reparent_children(&mut self, node: &Dom, new_parent: &Dom) { while let Some(ref child) = node.GetFirstChild() { new_parent.AppendChild(&child).unwrap(); } @@ -932,7 +932,7 @@ impl TreeSink for Sink { /// https://html.spec.whatwg.org/multipage/#html-integration-point /// Specifically, the cases. - fn is_mathml_annotation_xml_integration_point(&self, handle: &JS) -> bool { + fn is_mathml_annotation_xml_integration_point(&self, handle: &Dom) -> bool { let elem = handle.downcast::().unwrap(); elem.get_attribute(&ns!(), &local_name!("encoding")).map_or(false, |attr| { attr.value().eq_ignore_ascii_case("text/html") @@ -944,8 +944,8 @@ impl TreeSink for Sink { self.current_line = line_number; } - fn pop(&mut self, node: &JS) { - let node = Root::from_ref(&**node); + fn pop(&mut self, node: &Dom) { + let node = DomRoot::from_ref(&**node); vtable_for(&node).pop(); } } diff --git a/servo/components/script/dom/servoparser/xml.rs b/servo/components/script/dom/servoparser/xml.rs index 508a66929195..fe74d6273490 100644 --- a/servo/components/script/dom/servoparser/xml.rs +++ b/servo/components/script/dom/servoparser/xml.rs @@ -4,7 +4,7 @@ #![allow(unrooted_must_root)] -use dom::bindings::js::{JS, Root}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::trace::JSTraceable; use dom::document::Document; use dom::htmlscriptelement::HTMLScriptElement; @@ -20,14 +20,14 @@ use xml5ever::tree_builder::{Tracer as XmlTracer, XmlTreeBuilder}; #[must_root] pub struct Tokenizer { #[ignore_heap_size_of = "Defined in xml5ever"] - inner: XmlTokenizer, Sink>>, + inner: XmlTokenizer, Sink>>, } impl Tokenizer { pub fn new(document: &Document, url: ServoUrl) -> Self { let sink = Sink { base_url: url, - document: JS::from_ref(document), + document: Dom::from_ref(document), current_line: 1, script: Default::default(), }; @@ -40,7 +40,7 @@ impl Tokenizer { } } - pub fn feed(&mut self, input: &mut BufferQueue) -> Result<(), Root> { + pub fn feed(&mut self, input: &mut BufferQueue) -> Result<(), DomRoot> { if !input.is_empty() { while let Some(chunk) = input.pop_front() { self.inner.feed(chunk); @@ -67,15 +67,15 @@ impl Tokenizer { } #[allow(unsafe_code)] -unsafe impl JSTraceable for XmlTokenizer, Sink>> { +unsafe impl JSTraceable for XmlTokenizer, Sink>> { unsafe fn trace(&self, trc: *mut JSTracer) { struct Tracer(*mut JSTracer); let tracer = Tracer(trc); impl XmlTracer for Tracer { - type Handle = JS; + type Handle = Dom; #[allow(unrooted_must_root)] - fn trace_handle(&self, node: &JS) { + fn trace_handle(&self, node: &Dom) { unsafe { node.trace(self.0); } } } diff --git a/servo/components/script/dom/storage.rs b/servo/components/script/dom/storage.rs index e7b948e46d6d..56d5e8328709 100644 --- a/servo/components/script/dom/storage.rs +++ b/servo/components/script/dom/storage.rs @@ -6,9 +6,9 @@ use dom::bindings::codegen::Bindings::StorageBinding; use dom::bindings::codegen::Bindings::StorageBinding::StorageMethods; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::storageevent::StorageEvent; @@ -35,7 +35,7 @@ impl Storage { } } - pub fn new(global: &Window, storage_type: StorageType) -> Root { + pub fn new(global: &Window, storage_type: StorageType) -> DomRoot { reflect_dom_object(box Storage::new_inherited(storage_type), global, StorageBinding::Wrap) } diff --git a/servo/components/script/dom/storageevent.rs b/servo/components/script/dom/storageevent.rs index b0cab81eb7b9..382cdc612b4a 100644 --- a/servo/components/script/dom/storageevent.rs +++ b/servo/components/script/dom/storageevent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::StorageEventBinding; use dom::bindings::codegen::Bindings::StorageEventBinding::StorageEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::storage::Storage; @@ -23,7 +23,7 @@ pub struct StorageEvent { old_value: Option, new_value: Option, url: DOMString, - storage_area: MutNullableJS + storage_area: MutNullableDom } @@ -39,12 +39,12 @@ impl StorageEvent { old_value: old_value, new_value: new_value, url: url, - storage_area: MutNullableJS::new(storage_area) + storage_area: MutNullableDom::new(storage_area) } } pub fn new_uninitialized(window: &Window, - url: DOMString) -> Root { + url: DOMString) -> DomRoot { reflect_dom_object(box StorageEvent::new_inherited(None, None, None, url, None), window, StorageEventBinding::Wrap) @@ -58,7 +58,7 @@ impl StorageEvent { oldValue: Option, newValue: Option, url: DOMString, - storageArea: Option<&Storage>) -> Root { + storageArea: Option<&Storage>) -> DomRoot { let ev = reflect_dom_object(box StorageEvent::new_inherited(key, oldValue, newValue, url, storageArea), global, @@ -72,7 +72,7 @@ impl StorageEvent { pub fn Constructor(global: &Window, type_: DOMString, - init: &StorageEventBinding::StorageEventInit) -> Fallible> { + init: &StorageEventBinding::StorageEventInit) -> Fallible> { let key = init.key.clone(); let oldValue = init.oldValue.clone(); let newValue = init.newValue.clone(); @@ -110,7 +110,7 @@ impl StorageEventMethods for StorageEvent { } // https://html.spec.whatwg.org/multipage/#dom-storageevent-storagearea - fn GetStorageArea(&self) -> Option> { + fn GetStorageArea(&self) -> Option> { self.storage_area.get() } diff --git a/servo/components/script/dom/stylepropertymapreadonly.rs b/servo/components/script/dom/stylepropertymapreadonly.rs index 02f8a3423217..4002a68c0d49 100644 --- a/servo/components/script/dom/stylepropertymapreadonly.rs +++ b/servo/components/script/dom/stylepropertymapreadonly.rs @@ -4,10 +4,9 @@ use dom::bindings::codegen::Bindings::StylePropertyMapReadOnlyBinding::StylePropertyMapReadOnlyMethods; use dom::bindings::codegen::Bindings::StylePropertyMapReadOnlyBinding::Wrap; -use dom::bindings::js::JS; -use dom::bindings::js::Root; use dom::bindings::reflector::Reflector; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::cssstylevalue::CSSStyleValue; use dom::globalscope::GlobalScope; @@ -21,12 +20,12 @@ use style::custom_properties; #[dom_struct] pub struct StylePropertyMapReadOnly { reflector: Reflector, - entries: HashMap>, + entries: HashMap>, } impl StylePropertyMapReadOnly { fn new_inherited(entries: Entries) -> StylePropertyMapReadOnly where - Entries: IntoIterator)> + Entries: IntoIterator)> { StylePropertyMapReadOnly { reflector: Reflector::new(), @@ -34,7 +33,7 @@ impl StylePropertyMapReadOnly { } } - pub fn from_iter(global: &GlobalScope, entries: Entries) -> Root where + pub fn from_iter(global: &GlobalScope, entries: Entries) -> DomRoot where Entries: IntoIterator, { let mut keys = Vec::new(); @@ -46,7 +45,7 @@ impl StylePropertyMapReadOnly { for (key, value) in iter { let value = CSSStyleValue::new(global, value); keys.push(key); - values.push(JS::from_ref(&*value)); + values.push(Dom::from_ref(&*value)); } let iter = keys.drain(..).zip(values.iter().cloned()); reflect_dom_object(box StylePropertyMapReadOnly::new_inherited(iter), global, Wrap) @@ -55,9 +54,9 @@ impl StylePropertyMapReadOnly { impl StylePropertyMapReadOnlyMethods for StylePropertyMapReadOnly { /// https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymapreadonly-get - fn Get(&self, property: DOMString) -> Option> { + fn Get(&self, property: DOMString) -> Option> { // TODO: avoid constructing an Atom - self.entries.get(&Atom::from(property)).map(|value| Root::from_ref(&**value)) + self.entries.get(&Atom::from(property)).map(|value| DomRoot::from_ref(&**value)) } /// https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymapreadonly-has diff --git a/servo/components/script/dom/stylesheet.rs b/servo/components/script/dom/stylesheet.rs index bf4b1c562e3d..6315fe19ccd0 100644 --- a/servo/components/script/dom/stylesheet.rs +++ b/servo/components/script/dom/stylesheet.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::StyleSheetBinding; use dom::bindings::codegen::Bindings::StyleSheetBinding::StyleSheetMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; @@ -36,7 +36,7 @@ impl StyleSheet { #[allow(unrooted_must_root)] pub fn new(window: &Window, type_: DOMString, href: Option, - title: Option) -> Root { + title: Option) -> DomRoot { reflect_dom_object(box StyleSheet::new_inherited(type_, href, title), window, StyleSheetBinding::Wrap) diff --git a/servo/components/script/dom/stylesheetlist.rs b/servo/components/script/dom/stylesheetlist.rs index faeb04c1dda5..15c524e83a3a 100644 --- a/servo/components/script/dom/stylesheetlist.rs +++ b/servo/components/script/dom/stylesheetlist.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::StyleSheetListBinding; use dom::bindings::codegen::Bindings::StyleSheetListBinding::StyleSheetListMethods; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::document::Document; use dom::stylesheet::StyleSheet; use dom::window::Window; @@ -14,12 +14,12 @@ use dom_struct::dom_struct; #[dom_struct] pub struct StyleSheetList { reflector_: Reflector, - document: JS, + document: Dom, } impl StyleSheetList { #[allow(unrooted_must_root)] - fn new_inherited(doc: JS) -> StyleSheetList { + fn new_inherited(doc: Dom) -> StyleSheetList { StyleSheetList { reflector_: Reflector::new(), document: doc @@ -27,7 +27,7 @@ impl StyleSheetList { } #[allow(unrooted_must_root)] - pub fn new(window: &Window, document: JS) -> Root { + pub fn new(window: &Window, document: Dom) -> DomRoot { reflect_dom_object(box StyleSheetList::new_inherited(document), window, StyleSheetListBinding::Wrap) } @@ -40,14 +40,14 @@ impl StyleSheetListMethods for StyleSheetList { } // https://drafts.csswg.org/cssom/#dom-stylesheetlist-item - fn Item(&self, index: u32) -> Option> { + fn Item(&self, index: u32) -> Option> { // XXXManishearth this doesn't handle the origin clean flag and is a // cors vulnerability - self.document.stylesheet_at(index as usize).map(Root::upcast) + self.document.stylesheet_at(index as usize).map(DomRoot::upcast) } // check-tidy: no specs after this line - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } } diff --git a/servo/components/script/dom/svgsvgelement.rs b/servo/components/script/dom/svgsvgelement.rs index 90a272885a01..b7ee599b1025 100644 --- a/servo/components/script/dom/svgsvgelement.rs +++ b/servo/components/script/dom/svgsvgelement.rs @@ -5,7 +5,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::SVGSVGElementBinding; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{LayoutJS, Root}; +use dom::bindings::root::{DomRoot, LayoutDom}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; @@ -38,7 +38,7 @@ impl SVGSVGElement { #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option, - document: &Document) -> Root { + document: &Document) -> DomRoot { Node::reflect_node(box SVGSVGElement::new_inherited(local_name, prefix, document), document, SVGSVGElementBinding::Wrap) @@ -49,7 +49,7 @@ pub trait LayoutSVGSVGElementHelpers { fn data(&self) -> SVGSVGData; } -impl LayoutSVGSVGElementHelpers for LayoutJS { +impl LayoutSVGSVGElementHelpers for LayoutDom { #[allow(unsafe_code)] fn data(&self) -> SVGSVGData { unsafe { diff --git a/servo/components/script/dom/testbinding.rs b/servo/components/script/dom/testbinding.rs index 22f8066d24ad..3f76dab22471 100644 --- a/servo/components/script/dom/testbinding.rs +++ b/servo/components/script/dom/testbinding.rs @@ -21,11 +21,11 @@ use dom::bindings::codegen::UnionTypes::{HTMLElementOrUnsignedLongOrStringOrBool use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong}; use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean}; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::Root; use dom::bindings::mozmap::MozMap; use dom::bindings::num::Finite; use dom::bindings::refcounted::TrustedPromise; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{ByteString, DOMString, USVString}; use dom::bindings::trace::RootedTraceableBox; use dom::bindings::weakref::MutableWeakRef; @@ -59,22 +59,22 @@ impl TestBinding { } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box TestBinding::new_inherited(), global, TestBindingBinding::Wrap) } - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Ok(TestBinding::new(global)) } #[allow(unused_variables)] - pub fn Constructor_(global: &GlobalScope, nums: Vec) -> Fallible> { + pub fn Constructor_(global: &GlobalScope, nums: Vec) -> Fallible> { Ok(TestBinding::new(global)) } #[allow(unused_variables)] - pub fn Constructor__(global: &GlobalScope, num: f64) -> Fallible> { + pub fn Constructor__(global: &GlobalScope, num: f64) -> Fallible> { Ok(TestBinding::new(global)) } } @@ -114,7 +114,7 @@ impl TestBindingMethods for TestBinding { fn SetByteStringAttribute(&self, _: ByteString) {} fn EnumAttribute(&self) -> TestEnum { TestEnum::_empty } fn SetEnumAttribute(&self, _: TestEnum) {} - fn InterfaceAttribute(&self) -> Root { + fn InterfaceAttribute(&self) -> DomRoot { Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned()) } fn SetInterfaceAttribute(&self, _: &Blob) {} @@ -202,18 +202,18 @@ impl TestBindingMethods for TestBinding { fn GetUsvstringAttributeNullable(&self) -> Option { Some(USVString("".to_owned())) } fn SetUsvstringAttributeNullable(&self, _: Option) {} fn SetBinaryRenamedAttribute(&self, _: DOMString) {} - fn ForwardedAttribute(&self) -> Root { Root::from_ref(self) } + fn ForwardedAttribute(&self) -> DomRoot { DomRoot::from_ref(self) } fn BinaryRenamedAttribute(&self) -> DOMString { DOMString::new() } fn SetBinaryRenamedAttribute2(&self, _: DOMString) {} fn BinaryRenamedAttribute2(&self) -> DOMString { DOMString::new() } fn Attr_to_automatically_rename(&self) -> DOMString { DOMString::new() } fn SetAttr_to_automatically_rename(&self, _: DOMString) {} fn GetEnumAttributeNullable(&self) -> Option { Some(TestEnum::_empty) } - fn GetInterfaceAttributeNullable(&self) -> Option> { + fn GetInterfaceAttributeNullable(&self) -> Option> { Some(Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned())) } fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {} - fn GetInterfaceAttributeWeak(&self) -> Option> { + fn GetInterfaceAttributeWeak(&self) -> Option> { self.url.root() } fn SetInterfaceAttributeWeak(&self, url: Option<&URL>) { @@ -266,7 +266,7 @@ impl TestBindingMethods for TestBinding { fn ReceiveUsvstring(&self) -> USVString { USVString("".to_owned()) } fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) } fn ReceiveEnum(&self) -> TestEnum { TestEnum::_empty } - fn ReceiveInterface(&self) -> Root { + fn ReceiveInterface(&self) -> DomRoot { Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned()) } #[allow(unsafe_code)] @@ -291,7 +291,7 @@ impl TestBindingMethods for TestBinding { ByteStringSequenceOrLongOrString::ByteStringSequence(vec!(ByteString::new(vec!()))) } fn ReceiveSequence(&self) -> Vec { vec![1] } - fn ReceiveInterfaceSequence(&self) -> Vec> { + fn ReceiveInterfaceSequence(&self) -> Vec> { vec![Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned())] } @@ -312,7 +312,7 @@ impl TestBindingMethods for TestBinding { fn ReceiveNullableUsvstring(&self) -> Option { Some(USVString("".to_owned())) } fn ReceiveNullableByteString(&self) -> Option { Some(ByteString::new(vec!())) } fn ReceiveNullableEnum(&self) -> Option { Some(TestEnum::_empty) } - fn ReceiveNullableInterface(&self) -> Option> { + fn ReceiveNullableInterface(&self) -> Option> { Some(Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned())) } #[allow(unsafe_code)] @@ -449,7 +449,7 @@ impl TestBindingMethods for TestBinding { fn PassCallbackInterface(&self, _: Rc) {} fn PassSequence(&self, _: Vec) {} fn PassStringSequence(&self, _: Vec) {} - fn PassInterfaceSequence(&self, _: Vec>) {} + fn PassInterfaceSequence(&self, _: Vec>) {} fn PassNullableBoolean(&self, _: Option) {} fn PassNullableByte(&self, _: Option) {} @@ -651,14 +651,14 @@ impl TestBindingMethods for TestBinding { fn PassMozMapOfNullableInts(&self, _: MozMap>) {} fn PassOptionalMozMapOfNullableInts(&self, _: Option>>) {} fn PassOptionalNullableMozMapOfNullableInts(&self, _: Option> >>) {} - fn PassCastableObjectMozMap(&self, _: MozMap>) {} - fn PassNullableCastableObjectMozMap(&self, _: MozMap>>) {} - fn PassCastableObjectNullableMozMap(&self, _: Option>>) {} - fn PassNullableCastableObjectNullableMozMap(&self, _: Option>>>) {} + fn PassCastableObjectMozMap(&self, _: MozMap>) {} + fn PassNullableCastableObjectMozMap(&self, _: MozMap>>) {} + fn PassCastableObjectNullableMozMap(&self, _: Option>>) {} + fn PassNullableCastableObjectNullableMozMap(&self, _: Option>>>) {} fn PassOptionalMozMap(&self, _: Option>) {} fn PassOptionalNullableMozMap(&self, _: Option>>) {} fn PassOptionalNullableMozMapWithDefaultValue(&self, _: Option>) {} - fn PassOptionalObjectMozMap(&self, _: Option>>) {} + fn PassOptionalObjectMozMap(&self, _: Option>>) {} fn PassStringMozMap(&self, _: MozMap) {} fn PassByteStringMozMap(&self, _: MozMap) {} fn PassMozMapOfMozMaps(&self, _: MozMap>) {} @@ -776,10 +776,10 @@ impl TestBindingMethods for TestBinding { fn Panic(&self) { panic!("explicit panic from script") } - fn EntryGlobal(&self) -> Root { + fn EntryGlobal(&self) -> DomRoot { GlobalScope::entry() } - fn IncumbentGlobal(&self) -> Root { + fn IncumbentGlobal(&self) -> DomRoot { GlobalScope::incumbent().unwrap() } } diff --git a/servo/components/script/dom/testbindingiterable.rs b/servo/components/script/dom/testbindingiterable.rs index d89d7345f912..9f9354b88157 100644 --- a/servo/components/script/dom/testbindingiterable.rs +++ b/servo/components/script/dom/testbindingiterable.rs @@ -4,11 +4,11 @@ // check-tidy: no specs after this line -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::TestBindingIterableBinding::{self, TestBindingIterableMethods}; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -16,18 +16,18 @@ use dom_struct::dom_struct; #[dom_struct] pub struct TestBindingIterable { reflector: Reflector, - vals: DOMRefCell>, + vals: DomRefCell>, } impl TestBindingIterable { - fn new(global: &GlobalScope) -> Root { + fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box TestBindingIterable { reflector: Reflector::new(), - vals: DOMRefCell::new(vec![]), + vals: DomRefCell::new(vec![]), }, global, TestBindingIterableBinding::Wrap) } - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Ok(TestBindingIterable::new(global)) } } diff --git a/servo/components/script/dom/testbindingpairiterable.rs b/servo/components/script/dom/testbindingpairiterable.rs index c31d0e34fb52..5fae49893aa6 100644 --- a/servo/components/script/dom/testbindingpairiterable.rs +++ b/servo/components/script/dom/testbindingpairiterable.rs @@ -4,13 +4,13 @@ // check-tidy: no specs after this line -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::TestBindingPairIterableBinding; use dom::bindings::codegen::Bindings::TestBindingPairIterableBinding::TestBindingPairIterableMethods; use dom::bindings::error::Fallible; use dom::bindings::iterable::Iterable; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -18,7 +18,7 @@ use dom_struct::dom_struct; #[dom_struct] pub struct TestBindingPairIterable { reflector: Reflector, - map: DOMRefCell>, + map: DomRefCell>, } impl Iterable for TestBindingPairIterable { @@ -36,14 +36,14 @@ impl Iterable for TestBindingPairIterable { } impl TestBindingPairIterable { - fn new(global: &GlobalScope) -> Root { + fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box TestBindingPairIterable { reflector: Reflector::new(), - map: DOMRefCell::new(vec![]), + map: DomRefCell::new(vec![]), }, global, TestBindingPairIterableBinding::TestBindingPairIterableWrap) } - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Ok(TestBindingPairIterable::new(global)) } } diff --git a/servo/components/script/dom/testrunner.rs b/servo/components/script/dom/testrunner.rs index 1783fce72238..972bc7297234 100644 --- a/servo/components/script/dom/testrunner.rs +++ b/servo/components/script/dom/testrunner.rs @@ -6,8 +6,8 @@ use bluetooth_traits::BluetoothRequest; use dom::bindings::codegen::Bindings::TestRunnerBinding; use dom::bindings::codegen::Bindings::TestRunnerBinding::TestRunnerMethods; use dom::bindings::error::{Error, ErrorResult}; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -26,7 +26,7 @@ impl TestRunner { } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box TestRunner::new_inherited(), global, TestRunnerBinding::Wrap) diff --git a/servo/components/script/dom/testworklet.rs b/servo/components/script/dom/testworklet.rs index ea032e66faa2..04ed5ffc3c43 100644 --- a/servo/components/script/dom/testworklet.rs +++ b/servo/components/script/dom/testworklet.rs @@ -9,10 +9,9 @@ use dom::bindings::codegen::Bindings::TestWorkletBinding::Wrap; use dom::bindings::codegen::Bindings::WorkletBinding::WorkletBinding::WorkletMethods; use dom::bindings::codegen::Bindings::WorkletBinding::WorkletOptions; use dom::bindings::error::Fallible; -use dom::bindings::js::JS; -use dom::bindings::js::Root; use dom::bindings::reflector::Reflector; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::bindings::str::USVString; use dom::promise::Promise; @@ -26,23 +25,23 @@ use std::rc::Rc; #[dom_struct] pub struct TestWorklet { reflector: Reflector, - worklet: JS, + worklet: Dom, } impl TestWorklet { fn new_inherited(worklet: &Worklet) -> TestWorklet { TestWorklet { reflector: Reflector::new(), - worklet: JS::from_ref(worklet), + worklet: Dom::from_ref(worklet), } } - fn new(window: &Window) -> Root { + fn new(window: &Window) -> DomRoot { let worklet = Worklet::new(window, WorkletGlobalScopeType::Test); reflect_dom_object(box TestWorklet::new_inherited(&*worklet), window, Wrap) } - pub fn Constructor(window: &Window) -> Fallible> { + pub fn Constructor(window: &Window) -> Fallible> { Ok(TestWorklet::new(window)) } } diff --git a/servo/components/script/dom/testworkletglobalscope.rs b/servo/components/script/dom/testworkletglobalscope.rs index 5c9641d5fd2e..54b2c299df78 100644 --- a/servo/components/script/dom/testworkletglobalscope.rs +++ b/servo/components/script/dom/testworkletglobalscope.rs @@ -2,10 +2,10 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBinding; use dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBinding::TestWorkletGlobalScopeMethods; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::worklet::WorkletExecutor; use dom::workletglobalscope::WorkletGlobalScope; @@ -24,7 +24,7 @@ pub struct TestWorkletGlobalScope { // The worklet global for this object worklet_global: WorkletGlobalScope, // The key/value pairs - lookup_table: DOMRefCell>, + lookup_table: DomRefCell>, } impl TestWorkletGlobalScope { @@ -34,7 +34,7 @@ impl TestWorkletGlobalScope { base_url: ServoUrl, executor: WorkletExecutor, init: &WorkletGlobalScopeInit) - -> Root + -> DomRoot { debug!("Creating test worklet global scope for pipeline {}.", pipeline_id); let global = box TestWorkletGlobalScope { diff --git a/servo/components/script/dom/text.rs b/servo/components/script/dom/text.rs index 0343b373931a..2e37edc1a8dd 100644 --- a/servo/components/script/dom/text.rs +++ b/servo/components/script/dom/text.rs @@ -9,8 +9,7 @@ use dom::bindings::codegen::Bindings::TextBinding::{self, TextMethods}; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; -use dom::bindings::js::RootedReference; +use dom::bindings::root::{DomRoot, RootedReference}; use dom::bindings::str::DOMString; use dom::characterdata::CharacterData; use dom::document::Document; @@ -31,12 +30,12 @@ impl Text { } } - pub fn new(text: DOMString, document: &Document) -> Root { + pub fn new(text: DOMString, document: &Document) -> DomRoot { Node::reflect_node(box Text::new_inherited(text, document), document, TextBinding::Wrap) } - pub fn Constructor(window: &Window, text: DOMString) -> Fallible> { + pub fn Constructor(window: &Window, text: DOMString) -> Fallible> { let document = window.Document(); Ok(Text::new(text, &document)) } @@ -45,7 +44,7 @@ impl Text { impl TextMethods for Text { // https://dom.spec.whatwg.org/#dom-text-splittext // https://dom.spec.whatwg.org/#concept-text-split - fn SplitText(&self, offset: u32) -> Fallible> { + fn SplitText(&self, offset: u32) -> Fallible> { let cdata = self.upcast::(); // Step 1. let length = cdata.Length(); diff --git a/servo/components/script/dom/textdecoder.rs b/servo/components/script/dom/textdecoder.rs index e1b1edc10480..56e32ed5245f 100644 --- a/servo/components/script/dom/textdecoder.rs +++ b/servo/components/script/dom/textdecoder.rs @@ -5,8 +5,8 @@ use dom::bindings::codegen::Bindings::TextDecoderBinding; use dom::bindings::codegen::Bindings::TextDecoderBinding::TextDecoderMethods; use dom::bindings::error::{Error, Fallible}; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{DOMString, USVString}; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -32,11 +32,11 @@ impl TextDecoder { } } - fn make_range_error() -> Fallible> { + fn make_range_error() -> Fallible> { Err(Error::Range("The given encoding is not supported.".to_owned())) } - pub fn new(global: &GlobalScope, encoding: EncodingRef, fatal: bool) -> Root { + pub fn new(global: &GlobalScope, encoding: EncodingRef, fatal: bool) -> DomRoot { reflect_dom_object(box TextDecoder::new_inherited(encoding, fatal), global, TextDecoderBinding::Wrap) @@ -46,7 +46,7 @@ impl TextDecoder { pub fn Constructor(global: &GlobalScope, label: DOMString, options: &TextDecoderBinding::TextDecoderOptions) - -> Fallible> { + -> Fallible> { let encoding = match encoding_from_whatwg_label(&label) { None => return TextDecoder::make_range_error(), Some(enc) => enc diff --git a/servo/components/script/dom/textencoder.rs b/servo/components/script/dom/textencoder.rs index fa527d710732..765024522388 100644 --- a/servo/components/script/dom/textencoder.rs +++ b/servo/components/script/dom/textencoder.rs @@ -6,8 +6,8 @@ use core::nonzero::NonZero; use dom::bindings::codegen::Bindings::TextEncoderBinding; use dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{DOMString, USVString}; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; @@ -27,14 +27,14 @@ impl TextEncoder { } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box TextEncoder::new_inherited(), global, TextEncoderBinding::Wrap) } // https://encoding.spec.whatwg.org/#dom-textencoder - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Ok(TextEncoder::new(global)) } } diff --git a/servo/components/script/dom/touch.rs b/servo/components/script/dom/touch.rs index 3ebfd17af125..e12fce6379c4 100644 --- a/servo/components/script/dom/touch.rs +++ b/servo/components/script/dom/touch.rs @@ -4,9 +4,9 @@ use dom::bindings::codegen::Bindings::TouchBinding; use dom::bindings::codegen::Bindings::TouchBinding::TouchMethods; -use dom::bindings::js::{MutJS, Root}; use dom::bindings::num::Finite; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutDom}; use dom::eventtarget::EventTarget; use dom::window::Window; use dom_struct::dom_struct; @@ -15,7 +15,7 @@ use dom_struct::dom_struct; pub struct Touch { reflector_: Reflector, identifier: i32, - target: MutJS, + target: MutDom, screen_x: f64, screen_y: f64, client_x: f64, @@ -32,7 +32,7 @@ impl Touch { Touch { reflector_: Reflector::new(), identifier: identifier, - target: MutJS::new(target), + target: MutDom::new(target), screen_x: *screen_x, screen_y: *screen_y, client_x: *client_x, @@ -45,7 +45,7 @@ impl Touch { pub fn new(window: &Window, identifier: i32, target: &EventTarget, screen_x: Finite, screen_y: Finite, client_x: Finite, client_y: Finite, - page_x: Finite, page_y: Finite) -> Root { + page_x: Finite, page_y: Finite) -> DomRoot { reflect_dom_object(box Touch::new_inherited(identifier, target, screen_x, screen_y, client_x, client_y, @@ -62,7 +62,7 @@ impl TouchMethods for Touch { } /// https://w3c.github.io/touch-events/#widl-Touch-target - fn Target(&self) -> Root { + fn Target(&self) -> DomRoot { self.target.get() } diff --git a/servo/components/script/dom/touchevent.rs b/servo/components/script/dom/touchevent.rs index 30044094fcdf..6a33b7f244ee 100644 --- a/servo/components/script/dom/touchevent.rs +++ b/servo/components/script/dom/touchevent.rs @@ -6,8 +6,8 @@ use dom::bindings::codegen::Bindings::TouchEventBinding; use dom::bindings::codegen::Bindings::TouchEventBinding::TouchEventMethods; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutJS, Root}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, MutDom}; use dom::bindings::str::DOMString; use dom::event::{EventBubbles, EventCancelable}; use dom::touchlist::TouchList; @@ -19,9 +19,9 @@ use std::cell::Cell; #[dom_struct] pub struct TouchEvent { uievent: UIEvent, - touches: MutJS, - target_touches: MutJS, - changed_touches: MutJS, + touches: MutDom, + target_touches: MutDom, + changed_touches: MutDom, alt_key: Cell, meta_key: Cell, ctrl_key: Cell, @@ -34,9 +34,9 @@ impl TouchEvent { target_touches: &TouchList) -> TouchEvent { TouchEvent { uievent: UIEvent::new_inherited(), - touches: MutJS::new(touches), - target_touches: MutJS::new(target_touches), - changed_touches: MutJS::new(changed_touches), + touches: MutDom::new(touches), + target_touches: MutDom::new(target_touches), + changed_touches: MutDom::new(changed_touches), ctrl_key: Cell::new(false), shift_key: Cell::new(false), alt_key: Cell::new(false), @@ -47,7 +47,7 @@ impl TouchEvent { pub fn new_uninitialized(window: &Window, touches: &TouchList, changed_touches: &TouchList, - target_touches: &TouchList) -> Root { + target_touches: &TouchList) -> DomRoot { reflect_dom_object(box TouchEvent::new_inherited(touches, changed_touches, target_touches), window, TouchEventBinding::Wrap) @@ -65,7 +65,7 @@ impl TouchEvent { ctrl_key: bool, alt_key: bool, shift_key: bool, - meta_key: bool) -> Root { + meta_key: bool) -> DomRoot { let ev = TouchEvent::new_uninitialized(window, touches, changed_touches, target_touches); ev.upcast::().InitUIEvent(type_, bool::from(can_bubble), @@ -101,17 +101,17 @@ impl<'a> TouchEventMethods for &'a TouchEvent { } /// https://w3c.github.io/touch-events/#widl-TouchEventInit-touches - fn Touches(&self) -> Root { + fn Touches(&self) -> DomRoot { self.touches.get() } /// https://w3c.github.io/touch-events/#widl-TouchEvent-targetTouches - fn TargetTouches(&self) -> Root { + fn TargetTouches(&self) -> DomRoot { self.target_touches.get() } /// https://w3c.github.io/touch-events/#widl-TouchEvent-changedTouches - fn ChangedTouches(&self) -> Root { + fn ChangedTouches(&self) -> DomRoot { self.changed_touches.get() } diff --git a/servo/components/script/dom/touchlist.rs b/servo/components/script/dom/touchlist.rs index 829b6f0d5a6d..8881bec0faac 100644 --- a/servo/components/script/dom/touchlist.rs +++ b/servo/components/script/dom/touchlist.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::TouchListBinding; use dom::bindings::codegen::Bindings::TouchListBinding::TouchListMethods; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::touch::Touch; use dom::window::Window; use dom_struct::dom_struct; @@ -13,18 +13,18 @@ use dom_struct::dom_struct; #[dom_struct] pub struct TouchList { reflector_: Reflector, - touches: Vec>, + touches: Vec>, } impl TouchList { fn new_inherited(touches: &[&Touch]) -> TouchList { TouchList { reflector_: Reflector::new(), - touches: touches.iter().map(|touch| JS::from_ref(*touch)).collect(), + touches: touches.iter().map(|touch| Dom::from_ref(*touch)).collect(), } } - pub fn new(window: &Window, touches: &[&Touch]) -> Root { + pub fn new(window: &Window, touches: &[&Touch]) -> DomRoot { reflect_dom_object(box TouchList::new_inherited(touches), window, TouchListBinding::Wrap) } @@ -37,12 +37,12 @@ impl TouchListMethods for TouchList { } /// https://w3c.github.io/touch-events/#widl-TouchList-item-getter-Touch-unsigned-long-index - fn Item(&self, index: u32) -> Option> { - self.touches.get(index as usize).map(|js| Root::from_ref(&**js)) + fn Item(&self, index: u32) -> Option> { + self.touches.get(index as usize).map(|js| DomRoot::from_ref(&**js)) } /// https://w3c.github.io/touch-events/#widl-TouchList-item-getter-Touch-unsigned-long-index - fn IndexedGetter(&self, index: u32) -> Option> { + fn IndexedGetter(&self, index: u32) -> Option> { self.Item(index) } } diff --git a/servo/components/script/dom/transitionevent.rs b/servo/components/script/dom/transitionevent.rs index 28aec7097f88..7a3caea99ad6 100644 --- a/servo/components/script/dom/transitionevent.rs +++ b/servo/components/script/dom/transitionevent.rs @@ -7,9 +7,9 @@ use dom::bindings::codegen::Bindings::TransitionEventBinding; use dom::bindings::codegen::Bindings::TransitionEventBinding::{TransitionEventInit, TransitionEventMethods}; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::Event; use dom::window::Window; @@ -36,7 +36,7 @@ impl TransitionEvent { pub fn new(window: &Window, type_: Atom, - init: &TransitionEventInit) -> Root { + init: &TransitionEventInit) -> DomRoot { let ev = reflect_dom_object(box TransitionEvent::new_inherited(init), window, TransitionEventBinding::Wrap); @@ -49,7 +49,7 @@ impl TransitionEvent { pub fn Constructor(window: &Window, type_: DOMString, - init: &TransitionEventInit) -> Fallible> { + init: &TransitionEventInit) -> Fallible> { Ok(TransitionEvent::new(window, Atom::from(type_), init)) } } diff --git a/servo/components/script/dom/treewalker.rs b/servo/components/script/dom/treewalker.rs index 8515d7b6ae7d..b4cead438ffd 100644 --- a/servo/components/script/dom/treewalker.rs +++ b/servo/components/script/dom/treewalker.rs @@ -9,9 +9,8 @@ use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants; use dom::bindings::codegen::Bindings::TreeWalkerBinding; use dom::bindings::codegen::Bindings::TreeWalkerBinding::TreeWalkerMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, MutJS}; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutDom}; use dom::document::Document; use dom::node::Node; use dom_struct::dom_struct; @@ -21,8 +20,8 @@ use std::rc::Rc; #[dom_struct] pub struct TreeWalker { reflector_: Reflector, - root_node: JS, - current_node: MutJS, + root_node: Dom, + current_node: MutDom, what_to_show: u32, #[ignore_heap_size_of = "function pointers and Rc are hard"] filter: Filter @@ -34,8 +33,8 @@ impl TreeWalker { filter: Filter) -> TreeWalker { TreeWalker { reflector_: Reflector::new(), - root_node: JS::from_ref(root_node), - current_node: MutJS::new(root_node), + root_node: Dom::from_ref(root_node), + current_node: MutDom::new(root_node), what_to_show: what_to_show, filter: filter } @@ -44,7 +43,7 @@ impl TreeWalker { pub fn new_with_filter(document: &Document, root_node: &Node, what_to_show: u32, - filter: Filter) -> Root { + filter: Filter) -> DomRoot { reflect_dom_object(box TreeWalker::new_inherited(root_node, what_to_show, filter), document.window(), TreeWalkerBinding::Wrap) @@ -53,10 +52,10 @@ impl TreeWalker { pub fn new(document: &Document, root_node: &Node, what_to_show: u32, - node_filter: Option>) -> Root { + node_filter: Option>) -> DomRoot { let filter = match node_filter { None => Filter::None, - Some(jsfilter) => Filter::JS(jsfilter) + Some(jsfilter) => Filter::Dom(jsfilter) }; TreeWalker::new_with_filter(document, root_node, what_to_show, filter) } @@ -64,8 +63,8 @@ impl TreeWalker { impl TreeWalkerMethods for TreeWalker { // https://dom.spec.whatwg.org/#dom-treewalker-root - fn Root(&self) -> Root { - Root::from_ref(&*self.root_node) + fn Root(&self) -> DomRoot { + DomRoot::from_ref(&*self.root_node) } // https://dom.spec.whatwg.org/#dom-treewalker-whattoshow @@ -77,13 +76,13 @@ impl TreeWalkerMethods for TreeWalker { fn GetFilter(&self) -> Option> { match self.filter { Filter::None => None, - Filter::JS(ref nf) => Some(nf.clone()), + Filter::Dom(ref nf) => Some(nf.clone()), Filter::Native(_) => panic!("Cannot convert native node filter to DOM NodeFilter") } } // https://dom.spec.whatwg.org/#dom-treewalker-currentnode - fn CurrentNode(&self) -> Root { + fn CurrentNode(&self) -> DomRoot { self.current_node.get() } @@ -93,7 +92,7 @@ impl TreeWalkerMethods for TreeWalker { } // https://dom.spec.whatwg.org/#dom-treewalker-parentnode - fn ParentNode(&self) -> Fallible>> { + fn ParentNode(&self) -> Fallible>> { // "1. Let node be the value of the currentNode attribute." let mut node = self.current_node.get(); // "2. While node is not null and is not root, run these substeps:" @@ -117,35 +116,35 @@ impl TreeWalkerMethods for TreeWalker { } // https://dom.spec.whatwg.org/#dom-treewalker-firstchild - fn FirstChild(&self) -> Fallible>> { + fn FirstChild(&self) -> Fallible>> { // "The firstChild() method must traverse children of type first." self.traverse_children(|node| node.GetFirstChild(), |node| node.GetNextSibling()) } // https://dom.spec.whatwg.org/#dom-treewalker-lastchild - fn LastChild(&self) -> Fallible>> { + fn LastChild(&self) -> Fallible>> { // "The lastChild() method must traverse children of type last." self.traverse_children(|node| node.GetLastChild(), |node| node.GetPreviousSibling()) } // https://dom.spec.whatwg.org/#dom-treewalker-previoussibling - fn PreviousSibling(&self) -> Fallible>> { + fn PreviousSibling(&self) -> Fallible>> { // "The nextSibling() method must traverse siblings of type next." self.traverse_siblings(|node| node.GetLastChild(), |node| node.GetPreviousSibling()) } // https://dom.spec.whatwg.org/#dom-treewalker-nextsibling - fn NextSibling(&self) -> Fallible>> { + fn NextSibling(&self) -> Fallible>> { // "The previousSibling() method must traverse siblings of type previous." self.traverse_siblings(|node| node.GetFirstChild(), |node| node.GetNextSibling()) } // https://dom.spec.whatwg.org/#dom-treewalker-previousnode - fn PreviousNode(&self) -> Fallible>> { + fn PreviousNode(&self) -> Fallible>> { // "1. Let node be the value of the currentNode attribute." let mut node = self.current_node.get(); // "2. While node is not root, run these substeps:" @@ -202,7 +201,7 @@ impl TreeWalkerMethods for TreeWalker { } // https://dom.spec.whatwg.org/#dom-treewalker-nextnode - fn NextNode(&self) -> Fallible>> { + fn NextNode(&self) -> Fallible>> { // "1. Let node be the value of the currentNode attribute." let mut node = self.current_node.get(); // "2. Let result be FILTER_ACCEPT." @@ -257,9 +256,9 @@ impl TreeWalker { fn traverse_children(&self, next_child: F, next_sibling: G) - -> Fallible>> - where F: Fn(&Node) -> Option>, - G: Fn(&Node) -> Option> + -> Fallible>> + where F: Fn(&Node) -> Option>, + G: Fn(&Node) -> Option> { // "To **traverse children** of type *type*, run these steps:" // "1. Let node be the value of the currentNode attribute." @@ -281,7 +280,7 @@ impl TreeWalker { // attribute to node and return node." NodeFilterConstants::FILTER_ACCEPT => { self.current_node.set(&node); - return Ok(Some(Root::from_ref(&node))) + return Ok(Some(DomRoot::from_ref(&node))) }, // "3. If result is FILTER_SKIP, run these subsubsteps:" NodeFilterConstants::FILTER_SKIP => { @@ -329,9 +328,9 @@ impl TreeWalker { fn traverse_siblings(&self, next_child: F, next_sibling: G) - -> Fallible>> - where F: Fn(&Node) -> Option>, - G: Fn(&Node) -> Option> + -> Fallible>> + where F: Fn(&Node) -> Option>, + G: Fn(&Node) -> Option> { // "To **traverse siblings** of type *type* run these steps:" // "1. Let node be the value of the currentNode attribute." @@ -389,12 +388,12 @@ impl TreeWalker { // https://dom.spec.whatwg.org/#concept-tree-following fn first_following_node_not_following_root(&self, node: &Node) - -> Option> { + -> Option> { // "An object A is following an object B if A and B are in the same tree // and A comes after B in tree order." match node.GetNextSibling() { None => { - let mut candidate = Root::from_ref(node); + let mut candidate = DomRoot::from_ref(node); while !self.is_root_node(&candidate) && candidate.GetNextSibling().is_none() { match candidate.GetParentNode() { None => @@ -431,12 +430,12 @@ impl TreeWalker { match self.filter { Filter::None => Ok(NodeFilterConstants::FILTER_ACCEPT), Filter::Native(f) => Ok((f)(node)), - Filter::JS(ref callback) => callback.AcceptNode_(self, node, Rethrow) + Filter::Dom(ref callback) => callback.AcceptNode_(self, node, Rethrow) } } fn is_root_node(&self, node: &Node) -> bool { - JS::from_ref(node) == self.root_node + Dom::from_ref(node) == self.root_node } fn is_current_node(&self, node: &Node) -> bool { @@ -445,9 +444,9 @@ impl TreeWalker { } impl<'a> Iterator for &'a TreeWalker { - type Item = Root; + type Item = DomRoot; - fn next(&mut self) -> Option> { + fn next(&mut self) -> Option> { match self.NextNode() { Ok(node) => node, Err(_) => @@ -465,5 +464,5 @@ impl<'a> Iterator for &'a TreeWalker { pub enum Filter { None, Native(fn (node: &Node) -> u16), - JS(Rc) + Dom(Rc) } diff --git a/servo/components/script/dom/uievent.rs b/servo/components/script/dom/uievent.rs index f3f77953c292..6d54a48a0cd3 100644 --- a/servo/components/script/dom/uievent.rs +++ b/servo/components/script/dom/uievent.rs @@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::UIEventBinding; use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{DomRoot, MutNullableDom, RootedReference}; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::window::Window; @@ -21,7 +21,7 @@ use std::default::Default; #[dom_struct] pub struct UIEvent { event: Event, - view: MutNullableJS, + view: MutNullableDom, detail: Cell } @@ -34,7 +34,7 @@ impl UIEvent { } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { reflect_dom_object(box UIEvent::new_inherited(), window, UIEventBinding::Wrap) @@ -45,7 +45,7 @@ impl UIEvent { can_bubble: EventBubbles, cancelable: EventCancelable, view: Option<&Window>, - detail: i32) -> Root { + detail: i32) -> DomRoot { let ev = UIEvent::new_uninitialized(window); ev.InitUIEvent(type_, bool::from(can_bubble), bool::from(cancelable), view, detail); ev @@ -53,7 +53,7 @@ impl UIEvent { pub fn Constructor(window: &Window, type_: DOMString, - init: &UIEventBinding::UIEventInit) -> Fallible> { + init: &UIEventBinding::UIEventInit) -> Fallible> { let bubbles = EventBubbles::from(init.parent.bubbles); let cancelable = EventCancelable::from(init.parent.cancelable); let event = UIEvent::new(window, @@ -66,7 +66,7 @@ impl UIEvent { impl UIEventMethods for UIEvent { // https://w3c.github.io/uievents/#widl-UIEvent-view - fn GetView(&self) -> Option> { + fn GetView(&self) -> Option> { self.view.get() } diff --git a/servo/components/script/dom/url.rs b/servo/components/script/dom/url.rs index 41de4dcc0c72..9134f0cc104d 100644 --- a/servo/components/script/dom/url.rs +++ b/servo/components/script/dom/url.rs @@ -2,11 +2,11 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods}; use dom::bindings::error::{Error, ErrorResult, Fallible}; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::{DOMString, USVString}; use dom::blob::Blob; use dom::globalscope::GlobalScope; @@ -27,22 +27,22 @@ pub struct URL { reflector_: Reflector, // https://url.spec.whatwg.org/#concept-url-url - url: DOMRefCell, + url: DomRefCell, // https://url.spec.whatwg.org/#dom-url-searchparams - search_params: MutNullableJS, + search_params: MutNullableDom, } impl URL { fn new_inherited(url: ServoUrl) -> URL { URL { reflector_: Reflector::new(), - url: DOMRefCell::new(url), + url: DomRefCell::new(url), search_params: Default::default(), } } - pub fn new(global: &GlobalScope, url: ServoUrl) -> Root { + pub fn new(global: &GlobalScope, url: ServoUrl) -> DomRoot { reflect_dom_object(box URL::new_inherited(url), global, URLBinding::Wrap) } @@ -61,7 +61,7 @@ impl URL { // https://url.spec.whatwg.org/#constructors pub fn Constructor(global: &GlobalScope, url: USVString, base: Option) - -> Fallible> { + -> Fallible> { let parsed_base = match base { None => { // Step 1. @@ -254,7 +254,7 @@ impl URLMethods for URL { } // https://url.spec.whatwg.org/#dom-url-searchparams - fn SearchParams(&self) -> Root { + fn SearchParams(&self) -> DomRoot { self.search_params.or_init(|| { URLSearchParams::new(&self.global(), Some(self)) }) diff --git a/servo/components/script/dom/urlsearchparams.rs b/servo/components/script/dom/urlsearchparams.rs index 58391d651516..c5eef3d7837c 100644 --- a/servo/components/script/dom/urlsearchparams.rs +++ b/servo/components/script/dom/urlsearchparams.rs @@ -2,14 +2,14 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsMethods; use dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsWrap; use dom::bindings::codegen::UnionTypes::USVStringOrURLSearchParams; use dom::bindings::error::Fallible; use dom::bindings::iterable::Iterable; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{DOMString, USVString}; use dom::bindings::weakref::MutableWeakRef; use dom::globalscope::GlobalScope; @@ -23,7 +23,7 @@ use url::form_urlencoded; pub struct URLSearchParams { reflector_: Reflector, // https://url.spec.whatwg.org/#concept-urlsearchparams-list - list: DOMRefCell>, + list: DomRefCell>, // https://url.spec.whatwg.org/#concept-urlsearchparams-url-object url: MutableWeakRef, } @@ -32,19 +32,19 @@ impl URLSearchParams { fn new_inherited(url: Option<&URL>) -> URLSearchParams { URLSearchParams { reflector_: Reflector::new(), - list: DOMRefCell::new(url.map_or(Vec::new(), |url| url.query_pairs())), + list: DomRefCell::new(url.map_or(Vec::new(), |url| url.query_pairs())), url: MutableWeakRef::new(url), } } - pub fn new(global: &GlobalScope, url: Option<&URL>) -> Root { + pub fn new(global: &GlobalScope, url: Option<&URL>) -> DomRoot { reflect_dom_object(box URLSearchParams::new_inherited(url), global, URLSearchParamsWrap) } // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams pub fn Constructor(global: &GlobalScope, init: Option) -> - Fallible> { + Fallible> { // Step 1. let query = URLSearchParams::new(global, None); match init { diff --git a/servo/components/script/dom/validitystate.rs b/servo/components/script/dom/validitystate.rs index 4b4273bf353d..d99eba8c1095 100755 --- a/servo/components/script/dom/validitystate.rs +++ b/servo/components/script/dom/validitystate.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::ValidityStateBinding; use dom::bindings::codegen::Bindings::ValidityStateBinding::ValidityStateMethods; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::element::Element; use dom::window::Window; use dom_struct::dom_struct; @@ -46,7 +46,7 @@ bitflags!{ #[dom_struct] pub struct ValidityState { reflector_: Reflector, - element: JS, + element: Dom, state: ValidityStatus } @@ -55,12 +55,12 @@ impl ValidityState { fn new_inherited(element: &Element) -> ValidityState { ValidityState { reflector_: Reflector::new(), - element: JS::from_ref(element), + element: Dom::from_ref(element), state: ValidityStatus::Valid } } - pub fn new(window: &Window, element: &Element) -> Root { + pub fn new(window: &Window, element: &Element) -> DomRoot { reflect_dom_object(box ValidityState::new_inherited(element), window, ValidityStateBinding::Wrap) diff --git a/servo/components/script/dom/vr.rs b/servo/components/script/dom/vr.rs index 04c63a2f002f..d4b0429ebacc 100644 --- a/servo/components/script/dom/vr.rs +++ b/servo/components/script/dom/vr.rs @@ -2,14 +2,14 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::VRBinding; use dom::bindings::codegen::Bindings::VRBinding::VRMethods; use dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods; use dom::bindings::error::Error; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::event::Event; use dom::eventtarget::EventTarget; use dom::gamepad::Gamepad; @@ -28,20 +28,20 @@ use webvr_traits::{WebVRGamepadData, WebVRGamepadEvent, WebVRGamepadState}; #[dom_struct] pub struct VR { reflector_: Reflector, - displays: DOMRefCell>>, - gamepads: DOMRefCell>> + displays: DomRefCell>>, + gamepads: DomRefCell>> } impl VR { fn new_inherited() -> VR { VR { reflector_: Reflector::new(), - displays: DOMRefCell::new(Vec::new()), - gamepads: DOMRefCell::new(Vec::new()), + displays: DomRefCell::new(Vec::new()), + gamepads: DomRefCell::new(Vec::new()), } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { let root = reflect_dom_object(box VR::new_inherited(), global, VRBinding::Wrap); @@ -83,9 +83,9 @@ impl VRMethods for VR { return promise; } - // convert from JS to Root - let displays: Vec> = self.displays.borrow().iter() - .map(|d| Root::from_ref(&**d)) + // convert from Dom to DomRoot + let displays: Vec> = self.displays.borrow().iter() + .map(|d| DomRoot::from_ref(&**d)) .collect(); promise.resolve_native(&displays); @@ -99,11 +99,11 @@ impl VR { self.global().as_window().webvr_thread() } - fn find_display(&self, display_id: u32) -> Option> { + fn find_display(&self, display_id: u32) -> Option> { self.displays.borrow() .iter() .find(|d| d.DisplayId() == display_id) - .map(|d| Root::from_ref(&**d)) + .map(|d| DomRoot::from_ref(&**d)) } fn register(&self) { @@ -120,13 +120,13 @@ impl VR { } } - fn sync_display(&self, display: &WebVRDisplayData) -> Root { + fn sync_display(&self, display: &WebVRDisplayData) -> DomRoot { if let Some(existing) = self.find_display(display.display_id) { existing.update_display(&display); existing } else { let root = VRDisplay::new(&self.global(), display.clone()); - self.displays.borrow_mut().push(JS::from_ref(&*root)); + self.displays.borrow_mut().push(Dom::from_ref(&*root)); root } } @@ -206,11 +206,11 @@ impl VR { // Gamepad impl VR { - fn find_gamepad(&self, gamepad_id: u32) -> Option> { + fn find_gamepad(&self, gamepad_id: u32) -> Option> { self.gamepads.borrow() .iter() .find(|g| g.gamepad_id() == gamepad_id) - .map(|g| Root::from_ref(&**g)) + .map(|g| DomRoot::from_ref(&**g)) } fn sync_gamepad(&self, data: Option, state: &WebVRGamepadState) { @@ -223,7 +223,7 @@ impl VR { index as i32, &data, &state); - self.gamepads.borrow_mut().push(JS::from_ref(&*root)); + self.gamepads.borrow_mut().push(Dom::from_ref(&*root)); if state.connected { root.notify_event(GamepadEventType::Connected); } @@ -234,7 +234,7 @@ impl VR { // The current approach allows the to sample gamepad state multiple times per frame. This // guarantees that the gamepads always have a valid state and can be very useful for // motion capture or drawing applications. - pub fn get_gamepads(&self) -> Vec> { + pub fn get_gamepads(&self) -> Vec> { if let Some(wevbr_sender) = self.webvr_thread() { let (sender, receiver) = ipc::channel().unwrap(); let synced_ids = self.gamepads.borrow().iter().map(|g| g.gamepad_id()).collect(); @@ -252,7 +252,7 @@ impl VR { // We can add other not VR related gamepad providers here self.gamepads.borrow().iter() - .map(|g| Root::from_ref(&**g)) + .map(|g| DomRoot::from_ref(&**g)) .collect() } } diff --git a/servo/components/script/dom/vrdisplay.rs b/servo/components/script/dom/vrdisplay.rs index 97e126db4edf..d8457d468008 100644 --- a/servo/components/script/dom/vrdisplay.rs +++ b/servo/components/script/dom/vrdisplay.rs @@ -5,7 +5,7 @@ use canvas_traits::webgl::{webgl_channel, WebGLReceiver, WebVRCommand}; use core::ops::Deref; use dom::bindings::callback::ExceptionHandling; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::PerformanceMethods; use dom::bindings::codegen::Bindings::VRDisplayBinding; use dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods; @@ -15,10 +15,10 @@ use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderi use dom::bindings::codegen::Bindings::WindowBinding::FrameRequestCallback; use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, MutJS, Root}; use dom::bindings::num::Finite; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutDom, MutNullableDom}; use dom::bindings::str::DOMString; use dom::event::Event; use dom::eventtarget::EventTarget; @@ -47,28 +47,28 @@ use webvr_traits::{WebVRDisplayData, WebVRDisplayEvent, WebVRFrameData, WebVRLay pub struct VRDisplay { eventtarget: EventTarget, #[ignore_heap_size_of = "Defined in rust-webvr"] - display: DOMRefCell, + display: DomRefCell, depth_near: Cell, depth_far: Cell, presenting: Cell, - left_eye_params: MutJS, - right_eye_params: MutJS, - capabilities: MutJS, - stage_params: MutNullableJS, + left_eye_params: MutDom, + right_eye_params: MutDom, + capabilities: MutDom, + stage_params: MutNullableDom, #[ignore_heap_size_of = "Defined in rust-webvr"] - frame_data: DOMRefCell, + frame_data: DomRefCell, #[ignore_heap_size_of = "Defined in rust-webvr"] - layer: DOMRefCell, - layer_ctx: MutNullableJS, + layer: DomRefCell, + layer_ctx: MutNullableDom, #[ignore_heap_size_of = "Defined in rust-webvr"] next_raf_id: Cell, /// List of request animation frame callbacks #[ignore_heap_size_of = "closures are hard"] - raf_callback_list: DOMRefCell>)>>, + raf_callback_list: DomRefCell>)>>, // Compositor VRFrameData synchonization frame_data_status: Cell, #[ignore_heap_size_of = "channels are hard"] - frame_data_receiver: DOMRefCell, ()>>>>, + frame_data_receiver: DomRefCell, ()>>>>, running_display_raf: Cell, paused: Cell, stopped_on_pause: Cell, @@ -96,21 +96,21 @@ impl VRDisplay { VRDisplay { eventtarget: EventTarget::new_inherited(), - display: DOMRefCell::new(display.clone()), + display: DomRefCell::new(display.clone()), depth_near: Cell::new(0.01), depth_far: Cell::new(10000.0), presenting: Cell::new(false), - left_eye_params: MutJS::new(&*VREyeParameters::new(display.left_eye_parameters.clone(), &global)), - right_eye_params: MutJS::new(&*VREyeParameters::new(display.right_eye_parameters.clone(), &global)), - capabilities: MutJS::new(&*VRDisplayCapabilities::new(display.capabilities.clone(), &global)), - stage_params: MutNullableJS::new(stage.as_ref().map(|v| v.deref())), - frame_data: DOMRefCell::new(Default::default()), - layer: DOMRefCell::new(Default::default()), - layer_ctx: MutNullableJS::default(), + left_eye_params: MutDom::new(&*VREyeParameters::new(display.left_eye_parameters.clone(), &global)), + right_eye_params: MutDom::new(&*VREyeParameters::new(display.right_eye_parameters.clone(), &global)), + capabilities: MutDom::new(&*VRDisplayCapabilities::new(display.capabilities.clone(), &global)), + stage_params: MutNullableDom::new(stage.as_ref().map(|v| v.deref())), + frame_data: DomRefCell::new(Default::default()), + layer: DomRefCell::new(Default::default()), + layer_ctx: MutNullableDom::default(), next_raf_id: Cell::new(1), - raf_callback_list: DOMRefCell::new(vec![]), + raf_callback_list: DomRefCell::new(vec![]), frame_data_status: Cell::new(VRFrameDataStatus::Waiting), - frame_data_receiver: DOMRefCell::new(None), + frame_data_receiver: DomRefCell::new(None), running_display_raf: Cell::new(false), // Some VR implementations (e.g. Daydream) can be paused in some life cycle situations // such as showing and hiding the controller pairing screen. @@ -121,7 +121,7 @@ impl VRDisplay { } } - pub fn new(global: &GlobalScope, display: WebVRDisplayData) -> Root { + pub fn new(global: &GlobalScope, display: WebVRDisplayData) -> DomRoot { reflect_dom_object(box VRDisplay::new_inherited(&global, display), global, VRDisplayBinding::Wrap) @@ -148,20 +148,20 @@ impl VRDisplayMethods for VRDisplay { } // https://w3c.github.io/webvr/#dom-vrdisplay-capabilities - fn Capabilities(&self) -> Root { - Root::from_ref(&*self.capabilities.get()) + fn Capabilities(&self) -> DomRoot { + DomRoot::from_ref(&*self.capabilities.get()) } // https://w3c.github.io/webvr/#dom-vrdisplay-stageparameters - fn GetStageParameters(&self) -> Option> { - self.stage_params.get().map(|s| Root::from_ref(&*s)) + fn GetStageParameters(&self) -> Option> { + self.stage_params.get().map(|s| DomRoot::from_ref(&*s)) } // https://w3c.github.io/webvr/#dom-vrdisplay-geteyeparameters - fn GetEyeParameters(&self, eye: VREye) -> Root { + fn GetEyeParameters(&self, eye: VREye) -> DomRoot { match eye { - VREye::Left => Root::from_ref(&*self.left_eye_params.get()), - VREye::Right => Root::from_ref(&*self.right_eye_params.get()) + VREye::Left => DomRoot::from_ref(&*self.left_eye_params.get()), + VREye::Right => DomRoot::from_ref(&*self.right_eye_params.get()) } } @@ -211,7 +211,7 @@ impl VRDisplayMethods for VRDisplay { } // https://w3c.github.io/webvr/#dom-vrdisplay-getpose - fn GetPose(&self) -> Root { + fn GetPose(&self) -> DomRoot { VRPose::new(&self.global(), &self.frame_data.borrow().pose) } @@ -478,7 +478,7 @@ impl VRDisplay { } fn notify_event(&self, event: &WebVRDisplayEvent) { - let root = Root::from_ref(&*self); + let root = DomRoot::from_ref(&*self); let event = VRDisplayEvent::new_from_webvr(&self.global(), &root, &event); event.upcast::().fire(self.global().upcast::()); } @@ -630,7 +630,7 @@ fn parse_bounds(src: &Option>>, dst: &mut [f32; 4]) -> Result<() fn validate_layer(cx: *mut JSContext, layer: &VRLayer) - -> Result<(WebVRLayer, Root), &'static str> { + -> Result<(WebVRLayer, DomRoot), &'static str> { let ctx = layer.source.as_ref().map(|ref s| s.get_or_init_webgl_context(cx, None)).unwrap_or(None); if let Some(ctx) = ctx { let mut data = WebVRLayer::default(); diff --git a/servo/components/script/dom/vrdisplaycapabilities.rs b/servo/components/script/dom/vrdisplaycapabilities.rs index 349fd2721406..bf16b0cbf4f1 100644 --- a/servo/components/script/dom/vrdisplaycapabilities.rs +++ b/servo/components/script/dom/vrdisplaycapabilities.rs @@ -2,11 +2,11 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::VRDisplayCapabilitiesBinding; use dom::bindings::codegen::Bindings::VRDisplayCapabilitiesBinding::VRDisplayCapabilitiesMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use webvr_traits::WebVRDisplayCapabilities; @@ -15,7 +15,7 @@ use webvr_traits::WebVRDisplayCapabilities; pub struct VRDisplayCapabilities { reflector_: Reflector, #[ignore_heap_size_of = "Defined in rust-webvr"] - capabilities: DOMRefCell + capabilities: DomRefCell } unsafe_no_jsmanaged_fields!(WebVRDisplayCapabilities); @@ -24,11 +24,11 @@ impl VRDisplayCapabilities { fn new_inherited(capabilities: WebVRDisplayCapabilities) -> VRDisplayCapabilities { VRDisplayCapabilities { reflector_: Reflector::new(), - capabilities: DOMRefCell::new(capabilities) + capabilities: DomRefCell::new(capabilities) } } - pub fn new(capabilities: WebVRDisplayCapabilities, global: &GlobalScope) -> Root { + pub fn new(capabilities: WebVRDisplayCapabilities, global: &GlobalScope) -> DomRoot { reflect_dom_object(box VRDisplayCapabilities::new_inherited(capabilities), global, VRDisplayCapabilitiesBinding::Wrap) diff --git a/servo/components/script/dom/vrdisplayevent.rs b/servo/components/script/dom/vrdisplayevent.rs index 1e931f6983d6..26072b499c5c 100644 --- a/servo/components/script/dom/vrdisplayevent.rs +++ b/servo/components/script/dom/vrdisplayevent.rs @@ -8,8 +8,8 @@ use dom::bindings::codegen::Bindings::VRDisplayEventBinding::VRDisplayEventMetho use dom::bindings::codegen::Bindings::VRDisplayEventBinding::VRDisplayEventReason; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::bindings::str::DOMString; use dom::event::Event; use dom::globalscope::GlobalScope; @@ -22,7 +22,7 @@ use webvr_traits::{WebVRDisplayEvent, WebVRDisplayEventReason}; #[dom_struct] pub struct VRDisplayEvent { event: Event, - display: JS, + display: Dom, reason: Option } @@ -32,7 +32,7 @@ impl VRDisplayEvent { -> VRDisplayEvent { VRDisplayEvent { event: Event::new_inherited(), - display: JS::from_ref(display), + display: Dom::from_ref(display), reason: reason.clone() } } @@ -43,7 +43,7 @@ impl VRDisplayEvent { cancelable: bool, display: &VRDisplay, reason: Option) - -> Root { + -> DomRoot { let ev = reflect_dom_object(box VRDisplayEvent::new_inherited(&display, reason), global, VRDisplayEventBinding::Wrap); @@ -57,7 +57,7 @@ impl VRDisplayEvent { pub fn new_from_webvr(global: &GlobalScope, display: &VRDisplay, event: &WebVRDisplayEvent) - -> Root { + -> DomRoot { let (name, reason) = match *event { WebVRDisplayEvent::Connect(_) => ("vrdisplayconnect", None), WebVRDisplayEvent::Disconnect(_) => ("vrdisplaydisconnect", None), @@ -94,7 +94,7 @@ impl VRDisplayEvent { pub fn Constructor(window: &Window, type_: DOMString, init: &VRDisplayEventBinding::VRDisplayEventInit) - -> Fallible> { + -> Fallible> { Ok(VRDisplayEvent::new(&window.global(), Atom::from(type_), init.parent.bubbles, @@ -106,8 +106,8 @@ impl VRDisplayEvent { impl VRDisplayEventMethods for VRDisplayEvent { // https://w3c.github.io/webvr/#dom-vrdisplayevent-display - fn Display(&self) -> Root { - Root::from_ref(&*self.display) + fn Display(&self) -> DomRoot { + DomRoot::from_ref(&*self.display) } // https://w3c.github.io/webvr/#enumdef-vrdisplayeventreason diff --git a/servo/components/script/dom/vreyeparameters.rs b/servo/components/script/dom/vreyeparameters.rs index d77350ae1402..5db556cdf073 100644 --- a/servo/components/script/dom/vreyeparameters.rs +++ b/servo/components/script/dom/vreyeparameters.rs @@ -3,11 +3,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::VREyeParametersBinding; use dom::bindings::codegen::Bindings::VREyeParametersBinding::VREyeParametersMethods; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::globalscope::GlobalScope; use dom::vrfieldofview::VRFieldOfView; use dom_struct::dom_struct; @@ -21,9 +21,9 @@ use webvr_traits::WebVREyeParameters; pub struct VREyeParameters { reflector_: Reflector, #[ignore_heap_size_of = "Defined in rust-webvr"] - parameters: DOMRefCell, + parameters: DomRefCell, offset: Heap<*mut JSObject>, - fov: JS, + fov: Dom, } unsafe_no_jsmanaged_fields!(WebVREyeParameters); @@ -32,14 +32,14 @@ impl VREyeParameters { fn new_inherited(parameters: WebVREyeParameters, fov: &VRFieldOfView) -> VREyeParameters { VREyeParameters { reflector_: Reflector::new(), - parameters: DOMRefCell::new(parameters), + parameters: DomRefCell::new(parameters), offset: Heap::default(), - fov: JS::from_ref(&*fov) + fov: Dom::from_ref(&*fov) } } #[allow(unsafe_code)] - pub fn new(parameters: WebVREyeParameters, global: &GlobalScope) -> Root { + pub fn new(parameters: WebVREyeParameters, global: &GlobalScope) -> DomRoot { let fov = VRFieldOfView::new(&global, parameters.field_of_view.clone()); let cx = global.get_cx(); @@ -65,8 +65,8 @@ impl VREyeParametersMethods for VREyeParameters { } // https://w3c.github.io/webvr/#dom-vreyeparameters-fieldofview - fn FieldOfView(&self) -> Root { - Root::from_ref(&*self.fov) + fn FieldOfView(&self) -> DomRoot { + DomRoot::from_ref(&*self.fov) } // https://w3c.github.io/webvr/#dom-vreyeparameters-renderwidth diff --git a/servo/components/script/dom/vrfieldofview.rs b/servo/components/script/dom/vrfieldofview.rs index 80a2f767d81e..389c2edeef46 100644 --- a/servo/components/script/dom/vrfieldofview.rs +++ b/servo/components/script/dom/vrfieldofview.rs @@ -2,12 +2,12 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::VRFieldOfViewBinding; use dom::bindings::codegen::Bindings::VRFieldOfViewBinding::VRFieldOfViewMethods; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use webvr_traits::WebVRFieldOfView; @@ -16,7 +16,7 @@ use webvr_traits::WebVRFieldOfView; pub struct VRFieldOfView { reflector_: Reflector, #[ignore_heap_size_of = "Defined in rust-webvr"] - fov: DOMRefCell + fov: DomRefCell } unsafe_no_jsmanaged_fields!(WebVRFieldOfView); @@ -25,11 +25,11 @@ impl VRFieldOfView { fn new_inherited(fov: WebVRFieldOfView) -> VRFieldOfView { VRFieldOfView { reflector_: Reflector::new(), - fov: DOMRefCell::new(fov) + fov: DomRefCell::new(fov) } } - pub fn new(global: &GlobalScope, fov: WebVRFieldOfView) -> Root { + pub fn new(global: &GlobalScope, fov: WebVRFieldOfView) -> DomRoot { reflect_dom_object(box VRFieldOfView::new_inherited(fov), global, VRFieldOfViewBinding::Wrap) diff --git a/servo/components/script/dom/vrframedata.rs b/servo/components/script/dom/vrframedata.rs index 70e238e9fb5f..4ed95a2a4b40 100644 --- a/servo/components/script/dom/vrframedata.rs +++ b/servo/components/script/dom/vrframedata.rs @@ -6,9 +6,9 @@ use core::nonzero::NonZero; use dom::bindings::codegen::Bindings::VRFrameDataBinding; use dom::bindings::codegen::Bindings::VRFrameDataBinding::VRFrameDataMethods; use dom::bindings::error::Fallible; -use dom::bindings::js::{JS, Root}; use dom::bindings::num::Finite; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot}; use dom::globalscope::GlobalScope; use dom::vrpose::VRPose; use dom::window::Window; @@ -26,7 +26,7 @@ pub struct VRFrameData { left_view: Heap<*mut JSObject>, right_proj: Heap<*mut JSObject>, right_view: Heap<*mut JSObject>, - pose: JS, + pose: Dom, timestamp: Cell, first_timestamp: Cell } @@ -39,14 +39,14 @@ impl VRFrameData { left_view: Heap::default(), right_proj: Heap::default(), right_view: Heap::default(), - pose: JS::from_ref(&*pose), + pose: Dom::from_ref(&*pose), timestamp: Cell::new(0.0), first_timestamp: Cell::new(0.0) } } #[allow(unsafe_code)] - fn new(global: &GlobalScope) -> Root { + fn new(global: &GlobalScope) -> DomRoot { let matrix = [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, @@ -65,7 +65,7 @@ impl VRFrameData { root } - pub fn Constructor(window: &Window) -> Fallible> { + pub fn Constructor(window: &Window) -> Fallible> { Ok(VRFrameData::new(&window.global())) } } @@ -141,7 +141,7 @@ impl VRFrameDataMethods for VRFrameData { } // https://w3c.github.io/webvr/#dom-vrframedata-pose - fn Pose(&self) -> Root { - Root::from_ref(&*self.pose) + fn Pose(&self) -> DomRoot { + DomRoot::from_ref(&*self.pose) } } diff --git a/servo/components/script/dom/vrpose.rs b/servo/components/script/dom/vrpose.rs index 539a42e5e3bc..d80a4c5a0498 100644 --- a/servo/components/script/dom/vrpose.rs +++ b/servo/components/script/dom/vrpose.rs @@ -5,8 +5,8 @@ use core::nonzero::NonZero; use dom::bindings::codegen::Bindings::VRPoseBinding; use dom::bindings::codegen::Bindings::VRPoseBinding::VRPoseMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use js::jsapi::{Heap, JSContext, JSObject}; @@ -76,7 +76,7 @@ impl VRPose { } } - pub fn new(global: &GlobalScope, pose: &webvr::VRPose) -> Root { + pub fn new(global: &GlobalScope, pose: &webvr::VRPose) -> DomRoot { let root = reflect_dom_object(box VRPose::new_inherited(), global, VRPoseBinding::Wrap); diff --git a/servo/components/script/dom/vrstageparameters.rs b/servo/components/script/dom/vrstageparameters.rs index 7bfaa95ea76d..d7287249a89c 100644 --- a/servo/components/script/dom/vrstageparameters.rs +++ b/servo/components/script/dom/vrstageparameters.rs @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::VRStageParametersBinding; use dom::bindings::codegen::Bindings::VRStageParametersBinding::VRStageParametersMethods; -use dom::bindings::js::Root; use dom::bindings::num::Finite; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use js::jsapi::{Heap, JSContext, JSObject}; @@ -20,7 +20,7 @@ use webvr_traits::WebVRStageParameters; pub struct VRStageParameters { reflector_: Reflector, #[ignore_heap_size_of = "Defined in rust-webvr"] - parameters: DOMRefCell, + parameters: DomRefCell, transform: Heap<*mut JSObject>, } @@ -30,13 +30,13 @@ impl VRStageParameters { fn new_inherited(parameters: WebVRStageParameters) -> VRStageParameters { VRStageParameters { reflector_: Reflector::new(), - parameters: DOMRefCell::new(parameters), + parameters: DomRefCell::new(parameters), transform: Heap::default() } } #[allow(unsafe_code)] - pub fn new(parameters: WebVRStageParameters, global: &GlobalScope) -> Root { + pub fn new(parameters: WebVRStageParameters, global: &GlobalScope) -> DomRoot { let cx = global.get_cx(); rooted!(in (cx) let mut array = ptr::null_mut()); unsafe { diff --git a/servo/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs b/servo/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs index 573ebe8387d2..3740db147513 100644 --- a/servo/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs +++ b/servo/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::OESStandardDerivativesBinding; use dom::bindings::codegen::Bindings::OESStandardDerivativesBinding::OESStandardDerivativesConstants; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use super::{WebGLExtension, WebGLExtensions}; @@ -25,7 +25,7 @@ impl OESStandardDerivatives { impl WebGLExtension for OESStandardDerivatives { type Extension = OESStandardDerivatives; - fn new(ctx: &WebGLRenderingContext) -> Root { + fn new(ctx: &WebGLRenderingContext) -> DomRoot { reflect_dom_object(box OESStandardDerivatives::new_inherited(), &*ctx.global(), OESStandardDerivativesBinding::Wrap) diff --git a/servo/components/script/dom/webgl_extensions/ext/oestexturefloat.rs b/servo/components/script/dom/webgl_extensions/ext/oestexturefloat.rs index 58983c46caf1..967df546cc9c 100644 --- a/servo/components/script/dom/webgl_extensions/ext/oestexturefloat.rs +++ b/servo/components/script/dom/webgl_extensions/ext/oestexturefloat.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::OESTextureFloatBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use super::{constants as webgl, ext_constants as gl, WebGLExtension, WebGLExtensions}; @@ -24,7 +24,7 @@ impl OESTextureFloat { impl WebGLExtension for OESTextureFloat { type Extension = OESTextureFloat; - fn new(ctx: &WebGLRenderingContext) -> Root { + fn new(ctx: &WebGLRenderingContext) -> DomRoot { reflect_dom_object(box OESTextureFloat::new_inherited(), &*ctx.global(), OESTextureFloatBinding::Wrap) diff --git a/servo/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs b/servo/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs index d9bd061a7f11..2a730f2e85fd 100644 --- a/servo/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs +++ b/servo/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::OESTextureFloatLinearBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use super::{constants as webgl, WebGLExtension, WebGLExtensions}; @@ -24,7 +24,7 @@ impl OESTextureFloatLinear { impl WebGLExtension for OESTextureFloatLinear { type Extension = OESTextureFloatLinear; - fn new(ctx: &WebGLRenderingContext) -> Root { + fn new(ctx: &WebGLRenderingContext) -> DomRoot { reflect_dom_object(box OESTextureFloatLinear::new_inherited(), &*ctx.global(), OESTextureFloatLinearBinding::Wrap) diff --git a/servo/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs b/servo/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs index 7fe58f9b6b98..f5db59e097df 100644 --- a/servo/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs +++ b/servo/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::{self, OESTextureHalfFloatConstants}; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use super::{constants as webgl, ext_constants as gl, WebGLExtension, WebGLExtensions}; @@ -24,7 +24,7 @@ impl OESTextureHalfFloat { impl WebGLExtension for OESTextureHalfFloat { type Extension = OESTextureHalfFloat; - fn new(ctx: &WebGLRenderingContext) -> Root { + fn new(ctx: &WebGLRenderingContext) -> DomRoot { reflect_dom_object(box OESTextureHalfFloat::new_inherited(), &*ctx.global(), OESTextureHalfFloatBinding::Wrap) diff --git a/servo/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs b/servo/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs index 3bf9869b26a3..52f15ada5c2d 100644 --- a/servo/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs +++ b/servo/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants; use dom::bindings::codegen::Bindings::OESTextureHalfFloatLinearBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::webglrenderingcontext::WebGLRenderingContext; use dom_struct::dom_struct; use super::{WebGLExtension, WebGLExtensions}; @@ -25,7 +25,7 @@ impl OESTextureHalfFloatLinear { impl WebGLExtension for OESTextureHalfFloatLinear { type Extension = OESTextureHalfFloatLinear; - fn new(ctx: &WebGLRenderingContext) -> Root { + fn new(ctx: &WebGLRenderingContext) -> DomRoot { reflect_dom_object(box OESTextureHalfFloatLinear::new_inherited(), &*ctx.global(), OESTextureHalfFloatLinearBinding::Wrap) diff --git a/servo/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs b/servo/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs index 48385a3d50fa..cf2f3ab0f506 100644 --- a/servo/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs +++ b/servo/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs @@ -5,8 +5,8 @@ use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLError}; use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{self, OESVertexArrayObjectMethods}; use dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::webglrenderingcontext::WebGLRenderingContext; use dom::webglvertexarrayobjectoes::WebGLVertexArrayObjectOES; use dom_struct::dom_struct; @@ -19,16 +19,16 @@ use super::{WebGLExtension, WebGLExtensions}; #[dom_struct] pub struct OESVertexArrayObject { reflector_: Reflector, - ctx: JS, - bound_vao: MutNullableJS, + ctx: Dom, + bound_vao: MutNullableDom, } impl OESVertexArrayObject { fn new_inherited(ctx: &WebGLRenderingContext) -> OESVertexArrayObject { Self { reflector_: Reflector::new(), - ctx: JS::from_ref(ctx), - bound_vao: MutNullableJS::new(None) + ctx: Dom::from_ref(ctx), + bound_vao: MutNullableDom::new(None) } } @@ -46,7 +46,7 @@ impl OESVertexArrayObject { impl OESVertexArrayObjectMethods for OESVertexArrayObject { // https://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/ - fn CreateVertexArrayOES(&self) -> Option> { + fn CreateVertexArrayOES(&self) -> Option> { let (sender, receiver) = webgl_channel().unwrap(); self.ctx.send_command(WebGLCommand::CreateVertexArray(sender)); @@ -132,7 +132,7 @@ impl OESVertexArrayObjectMethods for OESVertexArrayObject { impl WebGLExtension for OESVertexArrayObject { type Extension = OESVertexArrayObject; - fn new(ctx: &WebGLRenderingContext) -> Root { + fn new(ctx: &WebGLRenderingContext) -> DomRoot { reflect_dom_object(box OESVertexArrayObject::new_inherited(ctx), &*ctx.global(), OESVertexArrayObjectBinding::Wrap) diff --git a/servo/components/script/dom/webgl_extensions/ext/webglvertexarrayobjectoes.rs b/servo/components/script/dom/webgl_extensions/ext/webglvertexarrayobjectoes.rs index 2fe109cafa68..8433b3453281 100644 --- a/servo/components/script/dom/webgl_extensions/ext/webglvertexarrayobjectoes.rs +++ b/servo/components/script/dom/webgl_extensions/ext/webglvertexarrayobjectoes.rs @@ -5,11 +5,10 @@ use canvas_traits::webgl::WebGLVertexArrayId; use core::cell::Ref; use core::iter::FromIterator; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WebGLVertexArrayObjectOESBinding; -use dom::bindings::js::{JS, MutNullableJS}; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::globalscope::GlobalScope; use dom::webglbuffer::WebGLBuffer; use dom::webglobject::WebGLObject; @@ -23,8 +22,8 @@ pub struct WebGLVertexArrayObjectOES { id: WebGLVertexArrayId, ever_bound: Cell, is_deleted: Cell, - bound_attrib_buffers: DOMRefCell>>, - bound_buffer_element_array: MutNullableJS, + bound_attrib_buffers: DomRefCell>>, + bound_buffer_element_array: MutNullableDom, } impl WebGLVertexArrayObjectOES { @@ -34,12 +33,12 @@ impl WebGLVertexArrayObjectOES { id: id, ever_bound: Cell::new(false), is_deleted: Cell::new(false), - bound_attrib_buffers: DOMRefCell::new(HashMap::new()), - bound_buffer_element_array: MutNullableJS::new(None), + bound_attrib_buffers: DomRefCell::new(HashMap::new()), + bound_buffer_element_array: MutNullableDom::new(None), } } - pub fn new(global: &GlobalScope, id: WebGLVertexArrayId) -> Root { + pub fn new(global: &GlobalScope, id: WebGLVertexArrayId) -> DomRoot { reflect_dom_object(box WebGLVertexArrayObjectOES::new_inherited(id), global, WebGLVertexArrayObjectOESBinding::Wrap) @@ -65,19 +64,19 @@ impl WebGLVertexArrayObjectOES { self.ever_bound.set(true); } - pub fn borrow_bound_attrib_buffers(&self) -> Ref>> { + pub fn borrow_bound_attrib_buffers(&self) -> Ref>> { self.bound_attrib_buffers.borrow() } - pub fn bound_attrib_buffers(&self) -> Vec> { - self.bound_attrib_buffers.borrow().iter().map(|(_, b)| Root::from_ref(&**b)).collect() + pub fn bound_attrib_buffers(&self) -> Vec> { + self.bound_attrib_buffers.borrow().iter().map(|(_, b)| DomRoot::from_ref(&**b)).collect() } pub fn set_bound_attrib_buffers<'a, T>(&self, iter: T) where T: Iterator { - *self.bound_attrib_buffers.borrow_mut() = HashMap::from_iter(iter.map(|(k,v)| (k, JS::from_ref(v)))); + *self.bound_attrib_buffers.borrow_mut() = HashMap::from_iter(iter.map(|(k,v)| (k, Dom::from_ref(v)))); } - pub fn bound_buffer_element_array(&self) -> Option> { + pub fn bound_buffer_element_array(&self) -> Option> { self.bound_buffer_element_array.get() } diff --git a/servo/components/script/dom/webgl_extensions/extension.rs b/servo/components/script/dom/webgl_extensions/extension.rs index 3463a1d32732..6b4a28153472 100644 --- a/servo/components/script/dom/webgl_extensions/extension.rs +++ b/servo/components/script/dom/webgl_extensions/extension.rs @@ -2,8 +2,8 @@ * 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/. */ -use dom::bindings::js::Root; use dom::bindings::reflector::DomObject; +use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; use dom::webglrenderingcontext::WebGLRenderingContext; use super::WebGLExtensions; @@ -13,7 +13,7 @@ pub trait WebGLExtension: Sized where Self::Extension: DomObject + JSTraceable { type Extension; /// Creates the DOM object of the WebGL extension. - fn new(ctx: &WebGLRenderingContext) -> Root; + fn new(ctx: &WebGLRenderingContext) -> DomRoot; /// Checks if the extension is supported. fn is_supported(ext: &WebGLExtensions) -> bool; diff --git a/servo/components/script/dom/webgl_extensions/extensions.rs b/servo/components/script/dom/webgl_extensions/extensions.rs index 62ee5f260864..8f340b7835d8 100644 --- a/servo/components/script/dom/webgl_extensions/extensions.rs +++ b/servo/components/script/dom/webgl_extensions/extensions.rs @@ -5,11 +5,11 @@ use canvas_traits::webgl::WebGLError; use core::iter::FromIterator; use core::nonzero::NonZero; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::OESStandardDerivativesBinding::OESStandardDerivativesConstants; use dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::trace::JSTraceable; use dom::webglrenderingcontext::WebGLRenderingContext; use fnv::{FnvHashMap, FnvHashSet}; @@ -76,15 +76,15 @@ impl Default for WebGLExtensionFeatures { #[must_root] #[derive(HeapSizeOf, JSTraceable)] pub struct WebGLExtensions { - extensions: DOMRefCell>>, - features: DOMRefCell, + extensions: DomRefCell>>, + features: DomRefCell, } impl WebGLExtensions { pub fn new() -> WebGLExtensions { Self { - extensions: DOMRefCell::new(HashMap::new()), - features: DOMRefCell::new(Default::default()) + extensions: DomRefCell::new(HashMap::new()), + features: DomRefCell::new(Default::default()) } } @@ -128,7 +128,7 @@ impl WebGLExtensions { self.extensions.borrow().get(&name).map_or(false, |ext| { ext.is_enabled() }) } - pub fn get_dom_object(&self) -> Option> + pub fn get_dom_object(&self) -> Option> where T: 'static + WebGLExtension + JSTraceable + HeapSizeOf { diff --git a/servo/components/script/dom/webgl_extensions/wrapper.rs b/servo/components/script/dom/webgl_extensions/wrapper.rs index 3d3f8128e338..7b4452ad7dc8 100644 --- a/servo/components/script/dom/webgl_extensions/wrapper.rs +++ b/servo/components/script/dom/webgl_extensions/wrapper.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::trace::JSTraceable; use dom::webglrenderingcontext::WebGLRenderingContext; use heapsize::HeapSizeOf; @@ -29,15 +29,15 @@ pub trait WebGLExtensionWrapper: JSTraceable + HeapSizeOf { #[must_root] #[derive(HeapSizeOf, JSTraceable)] pub struct TypedWebGLExtensionWrapper { - extension: MutNullableJS + extension: MutNullableDom } /// Typed WebGL Extension implementation. -/// Exposes the exact MutNullableJS type defined by the extension. +/// Exposes the exact MutNullableDom type defined by the extension. impl TypedWebGLExtensionWrapper { pub fn new() -> TypedWebGLExtensionWrapper { TypedWebGLExtensionWrapper { - extension: MutNullableJS::new(None) + extension: MutNullableDom::new(None) } } } @@ -84,7 +84,7 @@ impl WebGLExtensionWrapper for TypedWebGLExtensionWrapper } impl TypedWebGLExtensionWrapper where T: WebGLExtension + JSTraceable + HeapSizeOf + 'static { - pub fn dom_object(&self) -> Option> { + pub fn dom_object(&self) -> Option> { self.extension.get() } } diff --git a/servo/components/script/dom/webgl_validations/tex_image_2d.rs b/servo/components/script/dom/webgl_validations/tex_image_2d.rs index cd5320453c74..5be0c6f44fd7 100644 --- a/servo/components/script/dom/webgl_validations/tex_image_2d.rs +++ b/servo/components/script/dom/webgl_validations/tex_image_2d.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use canvas_traits::webgl::WebGLError::*; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::webglrenderingcontext::WebGLRenderingContext; use dom::webgltexture::WebGLTexture; use std::{self, fmt}; @@ -97,7 +97,7 @@ pub struct CommonTexImage2DValidator<'a> { } pub struct CommonTexImage2DValidatorResult { - pub texture: Root, + pub texture: DomRoot, pub target: TexImageTarget, pub level: u32, pub internal_format: TexFormat, @@ -263,7 +263,7 @@ pub struct TexImage2DValidatorResult { pub height: u32, pub level: u32, pub border: u32, - pub texture: Root, + pub texture: DomRoot, pub target: TexImageTarget, pub format: TexFormat, pub data_type: TexDataType, diff --git a/servo/components/script/dom/webglactiveinfo.rs b/servo/components/script/dom/webglactiveinfo.rs index 359a772a2683..6712e61fea4e 100644 --- a/servo/components/script/dom/webglactiveinfo.rs +++ b/servo/components/script/dom/webglactiveinfo.rs @@ -5,8 +5,8 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use dom::bindings::codegen::Bindings::WebGLActiveInfoBinding; use dom::bindings::codegen::Bindings::WebGLActiveInfoBinding::WebGLActiveInfoMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::window::Window; use dom_struct::dom_struct; @@ -30,7 +30,7 @@ impl WebGLActiveInfo { } } - pub fn new(window: &Window, size: i32, ty: u32, name: DOMString) -> Root { + pub fn new(window: &Window, size: i32, ty: u32, name: DOMString) -> DomRoot { reflect_dom_object(box WebGLActiveInfo::new_inherited(size, ty, name), window, WebGLActiveInfoBinding::Wrap) } } diff --git a/servo/components/script/dom/webglbuffer.rs b/servo/components/script/dom/webglbuffer.rs index 96db4466d56b..4510a74fd1b2 100644 --- a/servo/components/script/dom/webglbuffer.rs +++ b/servo/components/script/dom/webglbuffer.rs @@ -5,10 +5,10 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{WebGLBufferId, WebGLCommand, WebGLError, WebGLMsgSender, WebGLResult, WebGLVertexArrayId}; use canvas_traits::webgl::webgl_channel; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WebGLBufferBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::webglobject::WebGLObject; use dom::window::Window; use dom_struct::dom_struct; @@ -25,7 +25,7 @@ pub struct WebGLBuffer { capacity: Cell, is_deleted: Cell, // The Vertex Array Objects that are referencing this buffer - vao_references: DOMRefCell>>, + vao_references: DomRefCell>>, pending_delete: Cell, #[ignore_heap_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, @@ -41,14 +41,14 @@ impl WebGLBuffer { target: Cell::new(None), capacity: Cell::new(0), is_deleted: Cell::new(false), - vao_references: DOMRefCell::new(None), + vao_references: DomRefCell::new(None), pending_delete: Cell::new(false), renderer: renderer, } } pub fn maybe_new(window: &Window, renderer: WebGLMsgSender) - -> Option> { + -> Option> { let (sender, receiver) = webgl_channel().unwrap(); renderer.send(WebGLCommand::CreateBuffer(sender)).unwrap(); @@ -59,7 +59,7 @@ impl WebGLBuffer { pub fn new(window: &Window, renderer: WebGLMsgSender, id: WebGLBufferId) - -> Root { + -> DomRoot { reflect_dom_object(box WebGLBuffer::new_inherited(renderer, id), window, WebGLBufferBinding::Wrap) } diff --git a/servo/components/script/dom/webglcontextevent.rs b/servo/components/script/dom/webglcontextevent.rs index ce569ee8cbc5..3e28af76d6e1 100644 --- a/servo/components/script/dom/webglcontextevent.rs +++ b/servo/components/script/dom/webglcontextevent.rs @@ -8,8 +8,8 @@ use dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEven use dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventMethods; use dom::bindings::error::Fallible; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::window::Window; @@ -42,7 +42,7 @@ impl WebGLContextEvent { } } - pub fn new_uninitialized(window: &Window) -> Root { + pub fn new_uninitialized(window: &Window) -> DomRoot { // according to https://www.khronos.org/registry/webgl/specs/1.0/#5.15 this is // additional information or the empty string if no additional information is // available. @@ -57,7 +57,7 @@ impl WebGLContextEvent { type_: Atom, bubbles: EventBubbles, cancelable: EventCancelable, - status_message: DOMString) -> Root { + status_message: DOMString) -> DomRoot { let event = reflect_dom_object( box WebGLContextEvent::new_inherited(status_message), window, @@ -73,7 +73,7 @@ impl WebGLContextEvent { pub fn Constructor(window: &Window, type_: DOMString, - init: &WebGLContextEventInit) -> Fallible> { + init: &WebGLContextEventInit) -> Fallible> { let status_message = match init.statusMessage.as_ref() { Some(message) => message.clone(), None => DOMString::new(), diff --git a/servo/components/script/dom/webglframebuffer.rs b/servo/components/script/dom/webglframebuffer.rs index d4f524521781..211a4a5d8b90 100644 --- a/servo/components/script/dom/webglframebuffer.rs +++ b/servo/components/script/dom/webglframebuffer.rs @@ -6,11 +6,11 @@ use canvas_traits::webgl::{WebGLCommand, WebGLFramebufferBindingRequest, WebGLFramebufferId}; use canvas_traits::webgl::{WebGLMsgSender, WebGLResult, WebGLError}; use canvas_traits::webgl::webgl_channel; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WebGLFramebufferBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot}; use dom::webglobject::WebGLObject; use dom::webglrenderbuffer::WebGLRenderbuffer; use dom::webgltexture::WebGLTexture; @@ -21,8 +21,8 @@ use std::cell::Cell; #[must_root] #[derive(Clone, HeapSizeOf, JSTraceable)] enum WebGLFramebufferAttachment { - Renderbuffer(JS), - Texture { texture: JS, level: i32 }, + Renderbuffer(Dom), + Texture { texture: Dom, level: i32 }, } #[dom_struct] @@ -39,10 +39,10 @@ pub struct WebGLFramebuffer { // The attachment points for textures and renderbuffers on this // FBO. - color: DOMRefCell>, - depth: DOMRefCell>, - stencil: DOMRefCell>, - depthstencil: DOMRefCell>, + color: DomRefCell>, + depth: DomRefCell>, + stencil: DomRefCell>, + depthstencil: DomRefCell>, } impl WebGLFramebuffer { @@ -57,15 +57,15 @@ impl WebGLFramebuffer { renderer: renderer, size: Cell::new(None), status: Cell::new(constants::FRAMEBUFFER_UNSUPPORTED), - color: DOMRefCell::new(None), - depth: DOMRefCell::new(None), - stencil: DOMRefCell::new(None), - depthstencil: DOMRefCell::new(None), + color: DomRefCell::new(None), + depth: DomRefCell::new(None), + stencil: DomRefCell::new(None), + depthstencil: DomRefCell::new(None), } } pub fn maybe_new(window: &Window, renderer: WebGLMsgSender) - -> Option> { + -> Option> { let (sender, receiver) = webgl_channel().unwrap(); renderer.send(WebGLCommand::CreateFramebuffer(sender)).unwrap(); @@ -76,7 +76,7 @@ impl WebGLFramebuffer { pub fn new(window: &Window, renderer: WebGLMsgSender, id: WebGLFramebufferId) - -> Root { + -> DomRoot { reflect_dom_object(box WebGLFramebuffer::new_inherited(renderer, id), window, WebGLFramebufferBinding::Wrap) @@ -194,7 +194,7 @@ impl WebGLFramebuffer { let rb_id = match rb { Some(rb) => { - *binding.borrow_mut() = Some(WebGLFramebufferAttachment::Renderbuffer(JS::from_ref(rb))); + *binding.borrow_mut() = Some(WebGLFramebufferAttachment::Renderbuffer(Dom::from_ref(rb))); Some(rb.id()) } @@ -267,7 +267,7 @@ impl WebGLFramebuffer { } *binding.borrow_mut() = Some(WebGLFramebufferAttachment::Texture { - texture: JS::from_ref(texture), + texture: Dom::from_ref(texture), level: level } ); @@ -291,7 +291,7 @@ impl WebGLFramebuffer { } fn with_matching_renderbuffers(&self, rb: &WebGLRenderbuffer, mut closure: F) - where F: FnMut(&DOMRefCell>) + where F: FnMut(&DomRefCell>) { let attachments = [&self.color, &self.depth, @@ -314,7 +314,7 @@ impl WebGLFramebuffer { } fn with_matching_textures(&self, texture: &WebGLTexture, mut closure: F) - where F: FnMut(&DOMRefCell>) + where F: FnMut(&DomRefCell>) { let attachments = [&self.color, &self.depth, diff --git a/servo/components/script/dom/webglprogram.rs b/servo/components/script/dom/webglprogram.rs index 6c298bb83fbb..50c61397bb85 100644 --- a/servo/components/script/dom/webglprogram.rs +++ b/servo/components/script/dom/webglprogram.rs @@ -7,8 +7,8 @@ use canvas_traits::webgl::{WebGLCommand, WebGLError, WebGLMsgSender, WebGLParame use canvas_traits::webgl::webgl_channel; use dom::bindings::codegen::Bindings::WebGLProgramBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::webglactiveinfo::WebGLActiveInfo; use dom::webglobject::WebGLObject; @@ -25,8 +25,8 @@ pub struct WebGLProgram { is_deleted: Cell, link_called: Cell, linked: Cell, - fragment_shader: MutNullableJS, - vertex_shader: MutNullableJS, + fragment_shader: MutNullableDom, + vertex_shader: MutNullableDom, #[ignore_heap_size_of = "Defined in ipc-channel"] renderer: WebGLMsgSender, } @@ -48,7 +48,7 @@ impl WebGLProgram { } pub fn maybe_new(window: &Window, renderer: WebGLMsgSender) - -> Option> { + -> Option> { let (sender, receiver) = webgl_channel().unwrap(); renderer.send(WebGLCommand::CreateProgram(sender)).unwrap(); @@ -59,7 +59,7 @@ impl WebGLProgram { pub fn new(window: &Window, renderer: WebGLMsgSender, id: WebGLProgramId) - -> Root { + -> DomRoot { reflect_dom_object(box WebGLProgram::new_inherited(renderer, id), window, WebGLProgramBinding::Wrap) @@ -219,7 +219,7 @@ impl WebGLProgram { Ok(()) } - pub fn get_active_uniform(&self, index: u32) -> WebGLResult> { + pub fn get_active_uniform(&self, index: u32) -> WebGLResult> { if self.is_deleted() { return Err(WebGLError::InvalidValue); } @@ -233,7 +233,7 @@ impl WebGLProgram { } /// glGetActiveAttrib - pub fn get_active_attrib(&self, index: u32) -> WebGLResult> { + pub fn get_active_attrib(&self, index: u32) -> WebGLResult> { if self.is_deleted() { return Err(WebGLError::InvalidValue); } diff --git a/servo/components/script/dom/webglrenderbuffer.rs b/servo/components/script/dom/webglrenderbuffer.rs index 9a855651cc92..89151a07f8de 100644 --- a/servo/components/script/dom/webglrenderbuffer.rs +++ b/servo/components/script/dom/webglrenderbuffer.rs @@ -6,8 +6,8 @@ use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLError, WebGLMsgSender, WebGLRenderbufferId, WebGLResult}; use dom::bindings::codegen::Bindings::WebGLRenderbufferBinding; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::webglobject::WebGLObject; use dom::window::Window; use dom_struct::dom_struct; @@ -41,7 +41,7 @@ impl WebGLRenderbuffer { } pub fn maybe_new(window: &Window, renderer: WebGLMsgSender) - -> Option> { + -> Option> { let (sender, receiver) = webgl_channel().unwrap(); renderer.send(WebGLCommand::CreateRenderbuffer(sender)).unwrap(); @@ -52,7 +52,7 @@ impl WebGLRenderbuffer { pub fn new(window: &Window, renderer: WebGLMsgSender, id: WebGLRenderbufferId) - -> Root { + -> DomRoot { reflect_dom_object(box WebGLRenderbuffer::new_inherited(renderer, id), window, WebGLRenderbufferBinding::Wrap) diff --git a/servo/components/script/dom/webglrenderingcontext.rs b/servo/components/script/dom/webglrenderingcontext.rs index c9112ddc9ff9..6ff48147144a 100644 --- a/servo/components/script/dom/webglrenderingcontext.rs +++ b/servo/components/script/dom/webglrenderingcontext.rs @@ -11,7 +11,7 @@ use canvas_traits::webgl::webgl_channel; use core::cell::Ref; use core::iter::FromIterator; use core::nonzero::NonZero; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{self, WebGLContextAttributes}; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; @@ -19,8 +19,8 @@ use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasE use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible}; use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, LayoutJS, MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom}; use dom::bindings::str::DOMString; use dom::event::{Event, EventBubbles, EventCancelable}; use dom::htmlcanvaselement::HTMLCanvasElement; @@ -140,19 +140,19 @@ pub struct WebGLRenderingContext { share_mode: WebGLContextShareMode, #[ignore_heap_size_of = "Defined in offscreen_gl_context"] limits: GLLimits, - canvas: JS, + canvas: Dom, #[ignore_heap_size_of = "Defined in canvas_traits"] last_error: Cell>, texture_unpacking_settings: Cell, texture_unpacking_alignment: Cell, - bound_framebuffer: MutNullableJS, - bound_renderbuffer: MutNullableJS, - bound_texture_2d: MutNullableJS, - bound_texture_cube_map: MutNullableJS, - bound_buffer_array: MutNullableJS, - bound_buffer_element_array: MutNullableJS, - bound_attrib_buffers: DOMRefCell>>, - current_program: MutNullableJS, + bound_framebuffer: MutNullableDom, + bound_renderbuffer: MutNullableDom, + bound_texture_2d: MutNullableDom, + bound_texture_cube_map: MutNullableDom, + bound_buffer_array: MutNullableDom, + bound_buffer_element_array: MutNullableDom, + bound_attrib_buffers: DomRefCell>>, + current_program: MutNullableDom, #[ignore_heap_size_of = "Because it's small"] current_vertex_attrib_0: Cell<(f32, f32, f32, f32)>, #[ignore_heap_size_of = "Because it's small"] @@ -185,18 +185,18 @@ impl WebGLRenderingContext { webrender_image: Cell::new(None), share_mode: ctx_data.share_mode, limits: ctx_data.limits, - canvas: JS::from_ref(canvas), + canvas: Dom::from_ref(canvas), last_error: Cell::new(None), texture_unpacking_settings: Cell::new(CONVERT_COLORSPACE), texture_unpacking_alignment: Cell::new(4), - bound_framebuffer: MutNullableJS::new(None), - bound_texture_2d: MutNullableJS::new(None), - bound_texture_cube_map: MutNullableJS::new(None), - bound_buffer_array: MutNullableJS::new(None), - bound_buffer_element_array: MutNullableJS::new(None), - bound_attrib_buffers: DOMRefCell::new(Default::default()), - bound_renderbuffer: MutNullableJS::new(None), - current_program: MutNullableJS::new(None), + bound_framebuffer: MutNullableDom::new(None), + bound_texture_2d: MutNullableDom::new(None), + bound_texture_cube_map: MutNullableDom::new(None), + bound_buffer_array: MutNullableDom::new(None), + bound_buffer_element_array: MutNullableDom::new(None), + bound_attrib_buffers: DomRefCell::new(Default::default()), + bound_renderbuffer: MutNullableDom::new(None), + current_program: MutNullableDom::new(None), current_vertex_attrib_0: Cell::new((0f32, 0f32, 0f32, 1f32)), current_scissor: Cell::new((0, 0, size.width, size.height)), current_clear_color: Cell::new((0.0, 0.0, 0.0, 0.0)), @@ -207,7 +207,7 @@ impl WebGLRenderingContext { #[allow(unrooted_must_root)] pub fn new(window: &Window, canvas: &HTMLCanvasElement, size: Size2D, attrs: GLContextAttributes) - -> Option> { + -> Option> { match WebGLRenderingContext::new_inherited(window, canvas, size, attrs) { Ok(ctx) => Some(reflect_dom_object(box ctx, window, WebGLRenderingContextBinding::Wrap)), Err(msg) => { @@ -227,7 +227,7 @@ impl WebGLRenderingContext { &self.limits } - pub fn bound_texture_for_target(&self, target: &TexImageTarget) -> Option> { + pub fn bound_texture_for_target(&self, target: &TexImageTarget) -> Option> { match *target { TexImageTarget::Texture2D => self.bound_texture_2d.get(), TexImageTarget::CubeMapPositiveX | @@ -239,15 +239,15 @@ impl WebGLRenderingContext { } } - pub fn borrow_bound_attrib_buffers(&self) -> Ref>> { + pub fn borrow_bound_attrib_buffers(&self) -> Ref>> { self.bound_attrib_buffers.borrow() } pub fn set_bound_attrib_buffers<'a, T>(&self, iter: T) where T: Iterator { - *self.bound_attrib_buffers.borrow_mut() = FnvHashMap::from_iter(iter.map(|(k,v)| (k, JS::from_ref(v)))); + *self.bound_attrib_buffers.borrow_mut() = FnvHashMap::from_iter(iter.map(|(k,v)| (k, Dom::from_ref(v)))); } - pub fn bound_buffer_element_array(&self) -> Option> { + pub fn bound_buffer_element_array(&self) -> Option> { self.bound_buffer_element_array.get() } @@ -992,7 +992,7 @@ impl WebGLRenderingContext { } fn tex_sub_image_2d(&self, - texture: Root, + texture: DomRoot, target: TexImageTarget, level: u32, xoffset: i32, @@ -1133,8 +1133,8 @@ unsafe fn fallible_array_buffer_view_to_vec(cx: *mut JSContext, abv: *mut JSObje impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1 - fn Canvas(&self) -> Root { - Root::from_ref(&*self.canvas) + fn Canvas(&self) -> DomRoot { + DomRoot::from_ref(&*self.canvas) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.11 @@ -1840,32 +1840,32 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // TODO(emilio): Probably in the future we should keep track of the // generated objects, either here or in the webgl thread // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5 - fn CreateBuffer(&self) -> Option> { + fn CreateBuffer(&self) -> Option> { WebGLBuffer::maybe_new(self.global().as_window(), self.webgl_sender.clone()) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6 - fn CreateFramebuffer(&self) -> Option> { + fn CreateFramebuffer(&self) -> Option> { WebGLFramebuffer::maybe_new(self.global().as_window(), self.webgl_sender.clone()) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7 - fn CreateRenderbuffer(&self) -> Option> { + fn CreateRenderbuffer(&self) -> Option> { WebGLRenderbuffer::maybe_new(self.global().as_window(), self.webgl_sender.clone()) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 - fn CreateTexture(&self) -> Option> { + fn CreateTexture(&self) -> Option> { WebGLTexture::maybe_new(self.global().as_window(), self.webgl_sender.clone()) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 - fn CreateProgram(&self) -> Option> { + fn CreateProgram(&self) -> Option> { WebGLProgram::maybe_new(self.global().as_window(), self.webgl_sender.clone()) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 - fn CreateShader(&self, shader_type: u32) -> Option> { + fn CreateShader(&self, shader_type: u32) -> Option> { match shader_type { constants::VERTEX_SHADER | constants::FRAGMENT_SHADER => {}, _ => { @@ -2087,7 +2087,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - fn GetActiveUniform(&self, program: Option<&WebGLProgram>, index: u32) -> Option> { + fn GetActiveUniform(&self, program: Option<&WebGLProgram>, index: u32) -> Option> { let program = match program { Some(program) => program, None => { @@ -2114,7 +2114,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 - fn GetActiveAttrib(&self, program: Option<&WebGLProgram>, index: u32) -> Option> { + fn GetActiveAttrib(&self, program: Option<&WebGLProgram>, index: u32) -> Option> { let program = match program { Some(program) => program, None => { @@ -2212,7 +2212,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { fn GetShaderPrecisionFormat(&self, shader_type: u32, precision_type: u32) - -> Option> { + -> Option> { let (sender, receiver) = webgl_channel().unwrap(); self.send_command(WebGLCommand::GetShaderPrecisionFormat(shader_type, precision_type, @@ -2232,7 +2232,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn GetUniformLocation(&self, program: Option<&WebGLProgram>, - name: DOMString) -> Option> { + name: DOMString) -> Option> { program.and_then(|p| { handle_potential_webgl_error!(self, p.get_uniform_location(name), None) .map(|location| WebGLUniformLocation::new(self.global().as_window(), location, p.id())) @@ -3024,7 +3024,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } - self.bound_attrib_buffers.borrow_mut().insert(attrib_id, JS::from_ref(&*buffer_array)); + self.bound_attrib_buffers.borrow_mut().insert(attrib_id, Dom::from_ref(&*buffer_array)); let msg = WebGLCommand::VertexAttribPointer(attrib_id, size, data_type, normalized, stride, offset as u32); self.send_command(msg); @@ -3384,7 +3384,7 @@ pub trait LayoutCanvasWebGLRenderingContextHelpers { unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource; } -impl LayoutCanvasWebGLRenderingContextHelpers for LayoutJS { +impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom { #[allow(unsafe_code)] unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource { HTMLCanvasDataSource::WebGL((*self.unsafe_get()).layout_handle()) diff --git a/servo/components/script/dom/webglshader.rs b/servo/components/script/dom/webglshader.rs index cd33092f26e1..2a48ca21e73a 100644 --- a/servo/components/script/dom/webglshader.rs +++ b/servo/components/script/dom/webglshader.rs @@ -5,10 +5,10 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, ShaderValidator}; use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLMsgSender, WebGLParameter, WebGLResult, WebGLShaderId}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WebGLShaderBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::webgl_extensions::WebGLExtensions; use dom::webgl_extensions::ext::oesstandardderivatives::OESStandardDerivatives; @@ -30,8 +30,8 @@ pub struct WebGLShader { webgl_object: WebGLObject, id: WebGLShaderId, gl_type: u32, - source: DOMRefCell>, - info_log: DOMRefCell>, + source: DomRefCell>, + info_log: DomRefCell>, is_deleted: Cell, attached_counter: Cell, compilation_status: Cell, @@ -57,8 +57,8 @@ impl WebGLShader { webgl_object: WebGLObject::new_inherited(), id: id, gl_type: shader_type, - source: DOMRefCell::new(None), - info_log: DOMRefCell::new(None), + source: DomRefCell::new(None), + info_log: DomRefCell::new(None), is_deleted: Cell::new(false), attached_counter: Cell::new(0), compilation_status: Cell::new(ShaderCompilationStatus::NotCompiled), @@ -69,7 +69,7 @@ impl WebGLShader { pub fn maybe_new(window: &Window, renderer: WebGLMsgSender, shader_type: u32) - -> Option> { + -> Option> { let (sender, receiver) = webgl_channel().unwrap(); renderer.send(WebGLCommand::CreateShader(shader_type, sender)).unwrap(); @@ -81,7 +81,7 @@ impl WebGLShader { renderer: WebGLMsgSender, id: WebGLShaderId, shader_type: u32) - -> Root { + -> DomRoot { reflect_dom_object(box WebGLShader::new_inherited(renderer, id, shader_type), window, WebGLShaderBinding::Wrap) diff --git a/servo/components/script/dom/webglshaderprecisionformat.rs b/servo/components/script/dom/webglshaderprecisionformat.rs index 10a76b73fe1b..5ea5d8e83cf9 100644 --- a/servo/components/script/dom/webglshaderprecisionformat.rs +++ b/servo/components/script/dom/webglshaderprecisionformat.rs @@ -7,8 +7,8 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding; use dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding::WebGLShaderPrecisionFormatMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::window::Window; use dom_struct::dom_struct; @@ -33,7 +33,7 @@ impl WebGLShaderPrecisionFormat { pub fn new(window: &Window, range_min: i32, range_max: i32, - precision: i32) -> Root { + precision: i32) -> DomRoot { reflect_dom_object( box WebGLShaderPrecisionFormat::new_inherited(range_min, range_max, precision), window, diff --git a/servo/components/script/dom/webgltexture.rs b/servo/components/script/dom/webgltexture.rs index b4466ee93965..ec8dee281720 100644 --- a/servo/components/script/dom/webgltexture.rs +++ b/servo/components/script/dom/webgltexture.rs @@ -5,11 +5,11 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLError, WebGLMsgSender, WebGLResult, WebGLTextureId}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::codegen::Bindings::WebGLTextureBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::webgl_validations::types::{TexImageTarget, TexFormat, TexDataType}; use dom::webglobject::WebGLObject; use dom::window::Window; @@ -36,7 +36,7 @@ pub struct WebGLTexture { is_deleted: Cell, /// Stores information about mipmap levels and cubemap faces. #[ignore_heap_size_of = "Arrays are cumbersome"] - image_info_array: DOMRefCell<[ImageInfo; MAX_LEVEL_COUNT * MAX_FACE_COUNT]>, + image_info_array: DomRefCell<[ImageInfo; MAX_LEVEL_COUNT * MAX_FACE_COUNT]>, /// Face count can only be 1 or 6 face_count: Cell, base_mipmap_level: u32, @@ -60,13 +60,13 @@ impl WebGLTexture { base_mipmap_level: 0, min_filter: Cell::new(None), mag_filter: Cell::new(None), - image_info_array: DOMRefCell::new([ImageInfo::new(); MAX_LEVEL_COUNT * MAX_FACE_COUNT]), + image_info_array: DomRefCell::new([ImageInfo::new(); MAX_LEVEL_COUNT * MAX_FACE_COUNT]), renderer: renderer, } } pub fn maybe_new(window: &Window, renderer: WebGLMsgSender) - -> Option> { + -> Option> { let (sender, receiver) = webgl_channel().unwrap(); renderer.send(WebGLCommand::CreateTexture(sender)).unwrap(); @@ -77,7 +77,7 @@ impl WebGLTexture { pub fn new(window: &Window, renderer: WebGLMsgSender, id: WebGLTextureId) - -> Root { + -> DomRoot { reflect_dom_object(box WebGLTexture::new_inherited(renderer, id), window, WebGLTextureBinding::Wrap) diff --git a/servo/components/script/dom/webgluniformlocation.rs b/servo/components/script/dom/webgluniformlocation.rs index 47292adeb18b..080dda92d8b6 100644 --- a/servo/components/script/dom/webgluniformlocation.rs +++ b/servo/components/script/dom/webgluniformlocation.rs @@ -5,8 +5,8 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::webgl::WebGLProgramId; use dom::bindings::codegen::Bindings::WebGLUniformLocationBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::window::Window; use dom_struct::dom_struct; @@ -31,7 +31,7 @@ impl WebGLUniformLocation { pub fn new(window: &Window, id: i32, program_id: WebGLProgramId) - -> Root { + -> DomRoot { reflect_dom_object(box WebGLUniformLocation::new_inherited(id, program_id), window, WebGLUniformLocationBinding::Wrap) diff --git a/servo/components/script/dom/websocket.rs b/servo/components/script/dom/websocket.rs index 3d482bb4fa56..49a77dd3db5d 100644 --- a/servo/components/script/dom/websocket.rs +++ b/servo/components/script/dom/websocket.rs @@ -2,7 +2,7 @@ * 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/. */ -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::Bindings::WebSocketBinding; use dom::bindings::codegen::Bindings::WebSocketBinding::{BinaryType, WebSocketMethods}; @@ -10,9 +10,9 @@ use dom::bindings::codegen::UnionTypes::StringOrStringSequence; use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{DOMString, USVString, is_token}; use dom::blob::{Blob, BlobImpl}; use dom::closeevent::CloseEvent; @@ -105,9 +105,9 @@ pub struct WebSocket { buffered_amount: Cell, clearing_buffer: Cell, //Flag to tell if there is a running thread to clear buffered_amount #[ignore_heap_size_of = "Defined in std"] - sender: DOMRefCell>>, + sender: DomRefCell>>, binary_type: Cell, - protocol: DOMRefCell, //Subprotocol selected by server + protocol: DomRefCell, //Subprotocol selected by server } impl WebSocket { @@ -118,13 +118,13 @@ impl WebSocket { ready_state: Cell::new(WebSocketRequestState::Connecting), buffered_amount: Cell::new(0), clearing_buffer: Cell::new(false), - sender: DOMRefCell::new(None), + sender: DomRefCell::new(None), binary_type: Cell::new(BinaryType::Blob), - protocol: DOMRefCell::new("".to_owned()), + protocol: DomRefCell::new("".to_owned()), } } - fn new(global: &GlobalScope, url: ServoUrl) -> Root { + fn new(global: &GlobalScope, url: ServoUrl) -> DomRoot { reflect_dom_object(box WebSocket::new_inherited(url), global, WebSocketBinding::Wrap) } @@ -133,7 +133,7 @@ impl WebSocket { pub fn Constructor(global: &GlobalScope, url: DOMString, protocols: Option) - -> Fallible> { + -> Fallible> { // Steps 1-2. let url_record = ServoUrl::parse(&url).or(Err(Error::Syntax))?; diff --git a/servo/components/script/dom/window.rs b/servo/components/script/dom/window.rs index 7ad5d0c02ace..7a7b628ceccc 100644 --- a/servo/components/script/dom/window.rs +++ b/servo/components/script/dom/window.rs @@ -8,7 +8,7 @@ use bluetooth_traits::BluetoothRequest; use canvas_traits::webgl::WebGLChan; use cssparser::{Parser, ParserInput}; use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState}; use dom::bindings::codegen::Bindings::FunctionBinding::Function; use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState; @@ -18,10 +18,10 @@ use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOp use dom::bindings::codegen::UnionTypes::RequestOrUSVString; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::num::Finite; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::bindings::structuredclone::StructuredCloneData; use dom::bindings::trace::RootedTraceableBox; @@ -176,29 +176,29 @@ pub struct Window { file_reading_task_source: FileReadingTaskSource, #[ignore_heap_size_of = "task sources are hard"] performance_timeline_task_source: PerformanceTimelineTaskSource, - navigator: MutNullableJS, + navigator: MutNullableDom, #[ignore_heap_size_of = "Arc"] image_cache: Arc, #[ignore_heap_size_of = "channels are hard"] image_cache_chan: Sender, - window_proxy: MutNullableJS, - document: MutNullableJS, - location: MutNullableJS, - history: MutNullableJS, - custom_element_registry: MutNullableJS, - performance: MutNullableJS, + window_proxy: MutNullableDom, + document: MutNullableDom, + location: MutNullableDom, + history: MutNullableDom, + custom_element_registry: MutNullableDom, + performance: MutNullableDom, navigation_start: Cell, navigation_start_precise: Cell, - screen: MutNullableJS, - session_storage: MutNullableJS, - local_storage: MutNullableJS, - status: DOMRefCell, + screen: MutNullableDom, + session_storage: MutNullableDom, + local_storage: MutNullableDom, + status: DomRefCell, /// For sending timeline markers. Will be ignored if /// no devtools server - devtools_markers: DOMRefCell>, + devtools_markers: DomRefCell>, #[ignore_heap_size_of = "channels are hard"] - devtools_marker_sender: DOMRefCell>>>, + devtools_marker_sender: DomRefCell>>>, /// Pending resize event, if any. resize_event: Cell>, @@ -211,7 +211,7 @@ pub struct Window { /// The JavaScript runtime. #[ignore_heap_size_of = "Rc is hard"] - js_runtime: DOMRefCell>>, + js_runtime: DomRefCell>>, /// A handle for communicating messages to the layout thread. #[ignore_heap_size_of = "channels are hard"] @@ -244,7 +244,7 @@ pub struct Window { /// A channel for communicating results of async scripts back to the webdriver server #[ignore_heap_size_of = "channels are hard"] - webdriver_script_chan: DOMRefCell>>, + webdriver_script_chan: DomRefCell>>, /// The current state of the window object current_state: Cell, @@ -253,17 +253,17 @@ pub struct Window { /// A flag to prevent async events from attempting to interact with this window. #[ignore_heap_size_of = "defined in std"] - ignore_further_async_events: DOMRefCell>, + ignore_further_async_events: DomRefCell>, error_reporter: CSSErrorReporter, /// A list of scroll offsets for each scrollable element. - scroll_offsets: DOMRefCell>>, + scroll_offsets: DomRefCell>>, /// All the MediaQueryLists we need to update media_query_lists: WeakMediaQueryListVec, - test_runner: MutNullableJS, + test_runner: MutNullableDom, /// A handle for communicating messages to the webvr thread, if available. #[ignore_heap_size_of = "channels are hard"] @@ -274,22 +274,22 @@ pub struct Window { webvr_chan: Option>, /// A map for storing the previous permission state read results. - permission_state_invocation_results: DOMRefCell>, + permission_state_invocation_results: DomRefCell>, /// All of the elements that have an outstanding image request that was /// initiated by layout during a reflow. They are stored in the script thread /// to ensure that the element can be marked dirty when the image data becomes /// available at some point in the future. - pending_layout_images: DOMRefCell>>>, + pending_layout_images: DomRefCell>>>, /// Directory to store unminified scripts for this window if unminify-js /// opt is enabled. - unminified_js_dir: DOMRefCell>, + unminified_js_dir: DomRefCell>, /// Worklets - test_worklet: MutNullableJS, + test_worklet: MutNullableDom, /// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet - paint_worklet: MutNullableJS, + paint_worklet: MutNullableDom, } impl Window { @@ -353,13 +353,13 @@ impl Window { } /// This can panic if it is called after the browsing context has been discarded - pub fn window_proxy(&self) -> Root { + pub fn window_proxy(&self) -> DomRoot { self.window_proxy.get().unwrap() } /// Returns the window proxy if it has not been discarded. /// https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded - pub fn undiscarded_window_proxy(&self) -> Option> { + pub fn undiscarded_window_proxy(&self) -> Option> { self.window_proxy.get() .and_then(|window_proxy| if window_proxy.is_browsing_context_discarded() { None @@ -399,12 +399,12 @@ impl Window { self.webvr_chan.clone() } - fn new_paint_worklet(&self) -> Root { + fn new_paint_worklet(&self) -> DomRoot { debug!("Creating new paint worklet."); Worklet::new(self, WorkletGlobalScopeType::Paint) } - pub fn permission_state_invocation_results(&self) -> &DOMRefCell> { + pub fn permission_state_invocation_results(&self) -> &DomRefCell> { &self.permission_state_invocation_results } @@ -553,42 +553,42 @@ impl WindowMethods for Window { } // https://html.spec.whatwg.org/multipage/#dom-document-2 - fn Document(&self) -> Root { + fn Document(&self) -> DomRoot { self.document.get().expect("Document accessed before initialization.") } // https://html.spec.whatwg.org/multipage/#dom-history - fn History(&self) -> Root { + fn History(&self) -> DomRoot { self.history.or_init(|| History::new(self)) } // https://html.spec.whatwg.org/multipage/#dom-window-customelements - fn CustomElements(&self) -> Root { + fn CustomElements(&self) -> DomRoot { self.custom_element_registry.or_init(|| CustomElementRegistry::new(self)) } // https://html.spec.whatwg.org/multipage/#dom-location - fn Location(&self) -> Root { + fn Location(&self) -> DomRoot { self.location.or_init(|| Location::new(self)) } // https://html.spec.whatwg.org/multipage/#dom-sessionstorage - fn SessionStorage(&self) -> Root { + fn SessionStorage(&self) -> DomRoot { self.session_storage.or_init(|| Storage::new(self, StorageType::Session)) } // https://html.spec.whatwg.org/multipage/#dom-localstorage - fn LocalStorage(&self) -> Root { + fn LocalStorage(&self) -> DomRoot { self.local_storage.or_init(|| Storage::new(self, StorageType::Local)) } // https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-GlobalCrypto - fn Crypto(&self) -> Root { + fn Crypto(&self) -> DomRoot { self.upcast::().crypto() } // https://html.spec.whatwg.org/multipage/#dom-frameelement - fn GetFrameElement(&self) -> Option> { + fn GetFrameElement(&self) -> Option> { // Steps 1-3. let window_proxy = match self.window_proxy.get() { None => return None, @@ -606,11 +606,11 @@ impl WindowMethods for Window { return None; } // Step 7. - Some(Root::from_ref(container)) + Some(DomRoot::from_ref(container)) } // https://html.spec.whatwg.org/multipage/#dom-navigator - fn Navigator(&self) -> Root { + fn Navigator(&self) -> DomRoot { self.navigator.or_init(|| Navigator::new(self)) } @@ -669,22 +669,22 @@ impl WindowMethods for Window { } // https://html.spec.whatwg.org/multipage/#dom-window - fn Window(&self) -> Root { + fn Window(&self) -> DomRoot { self.window_proxy() } // https://html.spec.whatwg.org/multipage/#dom-self - fn Self_(&self) -> Root { + fn Self_(&self) -> DomRoot { self.window_proxy() } // https://html.spec.whatwg.org/multipage/#dom-frames - fn Frames(&self) -> Root { + fn Frames(&self) -> DomRoot { self.window_proxy() } // https://html.spec.whatwg.org/multipage/#dom-parent - fn GetParent(&self) -> Option> { + fn GetParent(&self) -> Option> { // Steps 1-3. let window_proxy = match self.undiscarded_window_proxy() { Some(window_proxy) => window_proxy, @@ -692,26 +692,26 @@ impl WindowMethods for Window { }; // Step 4. if let Some(parent) = window_proxy.parent() { - return Some(Root::from_ref(parent)); + return Some(DomRoot::from_ref(parent)); } // Step 5. Some(window_proxy) } // https://html.spec.whatwg.org/multipage/#dom-top - fn GetTop(&self) -> Option> { + fn GetTop(&self) -> Option> { // Steps 1-3. let window_proxy = match self.undiscarded_window_proxy() { Some(window_proxy) => window_proxy, None => return None, }; // Steps 4-5. - Some(Root::from_ref(window_proxy.top())) + Some(DomRoot::from_ref(window_proxy.top())) } // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/ // NavigationTiming/Overview.html#sec-window.performance-attribute - fn Performance(&self) -> Root { + fn Performance(&self) -> DomRoot { self.performance.or_init(|| { let global_scope = self.upcast::(); Performance::new(global_scope, self.navigation_start.get(), @@ -726,7 +726,7 @@ impl WindowMethods for Window { window_event_handlers!(); // https://developer.mozilla.org/en-US/docs/Web/API/Window/screen - fn Screen(&self) -> Root { + fn Screen(&self) -> DomRoot { self.screen.or_init(|| Screen::new(self)) } @@ -828,7 +828,7 @@ impl WindowMethods for Window { // https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle fn GetComputedStyle(&self, element: &Element, - pseudo: Option) -> Root { + pseudo: Option) -> DomRoot { // Steps 1-4. let pseudo = match pseudo.map(|mut s| { s.make_ascii_lowercase(); s }) { Some(ref pseudo) if pseudo == ":before" || pseudo == "::before" => @@ -840,7 +840,7 @@ impl WindowMethods for Window { // Step 5. CSSStyleDeclaration::new(self, - CSSStyleOwner::Element(JS::from_ref(element)), + CSSStyleOwner::Element(Dom::from_ref(element)), pseudo, CSSModificationAccess::Readonly) } @@ -1007,7 +1007,7 @@ impl WindowMethods for Window { } // https://drafts.csswg.org/cssom-view/#dom-window-matchmedia - fn MatchMedia(&self, query: DOMString) -> Root { + fn MatchMedia(&self, query: DOMString) -> DomRoot { let mut input = ParserInput::new(&query); let mut parser = Parser::new(&mut input); let url = self.get_url(); @@ -1030,11 +1030,11 @@ impl WindowMethods for Window { } // https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet - fn PaintWorklet(&self) -> Root { + fn PaintWorklet(&self) -> DomRoot { self.paint_worklet.or_init(|| self.new_paint_worklet()) } - fn TestRunner(&self) -> Root { + fn TestRunner(&self) -> DomRoot { self.test_runner.or_init(|| TestRunner::new(self.upcast())) } } @@ -1305,7 +1305,7 @@ impl Window { let _ = image_cache_chan.send((pipeline, message.to().unwrap())); }); self.image_cache.add_listener(id, ImageResponder::new(responder, id)); - nodes.push(JS::from_ref(&*node)); + nodes.push(Dom::from_ref(&*node)); } } @@ -1500,7 +1500,7 @@ impl Window { } #[allow(unsafe_code)] - pub fn offset_parent_query(&self, node: TrustedNodeAddress) -> (Option>, Rect) { + pub fn offset_parent_query(&self, node: TrustedNodeAddress) -> (Option>, Rect) { if !self.reflow(ReflowGoal::ForScriptQuery, ReflowQueryType::OffsetParentQuery(node), ReflowReason::Query) { @@ -1512,7 +1512,7 @@ impl Window { let js_runtime = js_runtime.as_ref().unwrap(); let element = response.node_address.and_then(|parent_node_address| { let node = unsafe { from_untrusted_node_address(js_runtime.rt(), parent_node_address) }; - Root::downcast(node) + DomRoot::downcast(node) }); (element, response.rect) } @@ -1661,7 +1661,7 @@ impl Window { } // https://html.spec.whatwg.org/multipage/#accessing-other-browsing-contexts - pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option> { + pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option> { None } @@ -1822,7 +1822,7 @@ impl Window { webgl_chan: WebGLChan, webvr_chan: Option>, microtask_queue: Rc, - ) -> Root { + ) -> DomRoot { let layout_rpc: Box = { let (rpc_send, rpc_recv) = channel(); layout_chan.send(Msg::GetRPC(rpc_send)).unwrap(); @@ -1866,10 +1866,10 @@ impl Window { screen: Default::default(), session_storage: Default::default(), local_storage: Default::default(), - status: DOMRefCell::new(DOMString::new()), + status: DomRefCell::new(DOMString::new()), parent_info, dom_static: GlobalStaticData::new(), - js_runtime: DOMRefCell::new(Some(runtime.clone())), + js_runtime: DomRefCell::new(Some(runtime.clone())), bluetooth_thread, bluetooth_extra_permission_data: BluetoothExtraPermissionData::new(), page_clip_rect: Cell::new(max_rect()), diff --git a/servo/components/script/dom/windowproxy.rs b/servo/components/script/dom/windowproxy.rs index 2578bb3b46c6..3d5faba1ad33 100644 --- a/servo/components/script/dom/windowproxy.rs +++ b/servo/components/script/dom/windowproxy.rs @@ -5,9 +5,9 @@ use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject}; use dom::bindings::error::{Error, throw_dom_exception}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root, RootedReference}; use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor}; use dom::bindings::reflector::{DomObject, Reflector}; +use dom::bindings::root::{Dom, DomRoot, RootedReference}; use dom::bindings::trace::JSTraceable; use dom::bindings::utils::{WindowProxyHandler, get_array_index_from_id, AsVoidPtr}; use dom::dissimilaroriginwindow::DissimilarOriginWindow; @@ -66,10 +66,10 @@ pub struct WindowProxy { discarded: Cell, /// The containing iframe element, if this is a same-origin iframe - frame_element: Option>, + frame_element: Option>, /// The parent browsing context's window proxy, if this is a nested browsing context - parent: Option>, + parent: Option>, } impl WindowProxy { @@ -86,8 +86,8 @@ impl WindowProxy { top_level_browsing_context_id: top_level_browsing_context_id, currently_active: Cell::new(currently_active), discarded: Cell::new(false), - frame_element: frame_element.map(JS::from_ref), - parent: parent.map(JS::from_ref), + frame_element: frame_element.map(Dom::from_ref), + parent: parent.map(Dom::from_ref), } } @@ -97,7 +97,7 @@ impl WindowProxy { top_level_browsing_context_id: TopLevelBrowsingContextId, frame_element: Option<&Element>, parent: Option<&WindowProxy>) - -> Root + -> DomRoot { unsafe { let WindowProxyHandler(handler) = window.windowproxy_handler(); @@ -131,7 +131,7 @@ impl WindowProxy { // Set the reflector. debug!("Initializing reflector of {:p} to {:p}.", window_proxy, js_proxy.get()); window_proxy.reflector.set_jsobject(js_proxy.get()); - Root::from_ref(&*Box::into_raw(window_proxy)) + DomRoot::from_ref(&*Box::into_raw(window_proxy)) } } @@ -140,7 +140,7 @@ impl WindowProxy { browsing_context_id: BrowsingContextId, top_level_browsing_context_id: TopLevelBrowsingContextId, parent: Option<&WindowProxy>) - -> Root + -> DomRoot { unsafe { let handler = CreateWrapperProxyHandler(&XORIGIN_PROXY_HANDLER); @@ -176,7 +176,7 @@ impl WindowProxy { // Set the reflector. debug!("Initializing reflector of {:p} to {:p}.", window_proxy, js_proxy.get()); window_proxy.reflector.set_jsobject(js_proxy.get()); - Root::from_ref(&*Box::into_raw(window_proxy)) + DomRoot::from_ref(&*Box::into_raw(window_proxy)) } } @@ -278,7 +278,7 @@ impl WindowProxy { unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: HandleObject, id: HandleId) - -> Option> { + -> Option> { let index = get_array_index_from_id(cx, id); if let Some(index) = index { rooted!(in(cx) let target = GetProxyPrivate(*proxy.ptr).to_object()); diff --git a/servo/components/script/dom/worker.rs b/servo/components/script/dom/worker.rs index 7d9a3875f1b2..d437b19c1489 100644 --- a/servo/components/script/dom/worker.rs +++ b/servo/components/script/dom/worker.rs @@ -9,9 +9,9 @@ use dom::bindings::codegen::Bindings::WorkerBinding; use dom::bindings::codegen::Bindings::WorkerBinding::WorkerMethods; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::bindings::structuredclone::StructuredCloneData; use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope; @@ -60,7 +60,7 @@ impl Worker { pub fn new(global: &GlobalScope, sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>, - closing: Arc) -> Root { + closing: Arc) -> DomRoot { reflect_dom_object(box Worker::new_inherited(sender, closing), global, WorkerBinding::Wrap) @@ -68,7 +68,7 @@ impl Worker { // https://html.spec.whatwg.org/multipage/#dom-worker #[allow(unsafe_code)] - pub fn Constructor(global: &GlobalScope, script_url: DOMString) -> Fallible> { + pub fn Constructor(global: &GlobalScope, script_url: DOMString) -> Fallible> { // Step 2-4. let worker_url = match global.api_base_url().join(&script_url) { Ok(url) => url, diff --git a/servo/components/script/dom/workerglobalscope.rs b/servo/components/script/dom/workerglobalscope.rs index 8ea1a49ccbec..ca7e2c3b7a91 100644 --- a/servo/components/script/dom/workerglobalscope.rs +++ b/servo/components/script/dom/workerglobalscope.rs @@ -9,8 +9,8 @@ use dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScop use dom::bindings::codegen::UnionTypes::RequestOrUSVString; use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::settings_stack::AutoEntryScript; use dom::bindings::str::DOMString; use dom::bindings::trace::RootedTraceableBox; @@ -77,8 +77,8 @@ pub struct WorkerGlobalScope { closing: Option>, #[ignore_heap_size_of = "Defined in js"] runtime: Runtime, - location: MutNullableJS, - navigator: MutNullableJS, + location: MutNullableDom, + navigator: MutNullableDom, #[ignore_heap_size_of = "Defined in ipc-channel"] /// Optional `IpcSender` for sending the `DevtoolScriptControlMsg` @@ -91,7 +91,7 @@ pub struct WorkerGlobalScope { from_devtools_receiver: Receiver, navigation_start_precise: f64, - performance: MutNullableJS, + performance: MutNullableDom, } impl WorkerGlobalScope { @@ -170,12 +170,12 @@ impl WorkerGlobalScope { impl WorkerGlobalScopeMethods for WorkerGlobalScope { // https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-self - fn Self_(&self) -> Root { - Root::from_ref(self) + fn Self_(&self) -> DomRoot { + DomRoot::from_ref(self) } // https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-location - fn Location(&self) -> Root { + fn Location(&self) -> DomRoot { self.location.or_init(|| { WorkerLocation::new(self, self.worker_url.clone()) }) @@ -236,12 +236,12 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope { } // https://html.spec.whatwg.org/multipage/#dom-worker-navigator - fn Navigator(&self) -> Root { + fn Navigator(&self) -> DomRoot { self.navigator.or_init(|| WorkerNavigator::new(self)) } // https://html.spec.whatwg.org/multipage/#dfn-Crypto - fn Crypto(&self) -> Root { + fn Crypto(&self) -> DomRoot { self.upcast::().crypto() } @@ -316,7 +316,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope { } // https://w3c.github.io/hr-time/#the-performance-attribute - fn Performance(&self) -> Root { + fn Performance(&self) -> DomRoot { self.performance.or_init(|| { let global_scope = self.upcast::(); Performance::new(global_scope, diff --git a/servo/components/script/dom/workerlocation.rs b/servo/components/script/dom/workerlocation.rs index f52e0efb69a1..ca7d30d4d3cb 100644 --- a/servo/components/script/dom/workerlocation.rs +++ b/servo/components/script/dom/workerlocation.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::WorkerLocationBinding; use dom::bindings::codegen::Bindings::WorkerLocationBinding::WorkerLocationMethods; -use dom::bindings::js::Root; use dom::bindings::reflector::{Reflector, reflect_dom_object}; +use dom::bindings::root::DomRoot; use dom::bindings::str::{DOMString, USVString}; use dom::urlhelper::UrlHelper; use dom::workerglobalscope::WorkerGlobalScope; @@ -27,7 +27,7 @@ impl WorkerLocation { } } - pub fn new(global: &WorkerGlobalScope, url: ServoUrl) -> Root { + pub fn new(global: &WorkerGlobalScope, url: ServoUrl) -> DomRoot { reflect_dom_object(box WorkerLocation::new_inherited(url), global, WorkerLocationBinding::Wrap) diff --git a/servo/components/script/dom/workernavigator.rs b/servo/components/script/dom/workernavigator.rs index dafa3325b388..e11347c34c64 100644 --- a/servo/components/script/dom/workernavigator.rs +++ b/servo/components/script/dom/workernavigator.rs @@ -4,8 +4,8 @@ use dom::bindings::codegen::Bindings::WorkerNavigatorBinding; use dom::bindings::codegen::Bindings::WorkerNavigatorBinding::WorkerNavigatorMethods; -use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; +use dom::bindings::root::{DomRoot, MutNullableDom}; use dom::bindings::str::DOMString; use dom::navigatorinfo; use dom::permissions::Permissions; @@ -16,7 +16,7 @@ use dom_struct::dom_struct; #[dom_struct] pub struct WorkerNavigator { reflector_: Reflector, - permissions: MutNullableJS, + permissions: MutNullableDom, } impl WorkerNavigator { @@ -27,7 +27,7 @@ impl WorkerNavigator { } } - pub fn new(global: &WorkerGlobalScope) -> Root { + pub fn new(global: &WorkerGlobalScope) -> DomRoot { reflect_dom_object(box WorkerNavigator::new_inherited(), global, WorkerNavigatorBinding::Wrap) @@ -76,7 +76,7 @@ impl WorkerNavigatorMethods for WorkerNavigator { } // https://w3c.github.io/permissions/#navigator-and-workernavigator-extension - fn Permissions(&self) -> Root { + fn Permissions(&self) -> DomRoot { self.permissions.or_init(|| Permissions::new(&self.global())) } } diff --git a/servo/components/script/dom/worklet.rs b/servo/components/script/dom/worklet.rs index 6049f7cf0e00..4f13fac1b1ac 100644 --- a/servo/components/script/dom/worklet.rs +++ b/servo/components/script/dom/worklet.rs @@ -17,12 +17,10 @@ use dom::bindings::codegen::Bindings::WorkletBinding::WorkletOptions; use dom::bindings::codegen::Bindings::WorkletBinding::Wrap; use dom::bindings::error::Error; use dom::bindings::inheritance::Castable; -use dom::bindings::js::JS; -use dom::bindings::js::Root; -use dom::bindings::js::RootCollection; use dom::bindings::refcounted::TrustedPromise; use dom::bindings::reflector::Reflector; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::{Dom, DomRoot, RootCollection}; use dom::bindings::str::USVString; use dom::bindings::trace::JSTraceable; use dom::bindings::trace::RootedTraceableBox; @@ -80,7 +78,7 @@ const MIN_GC_THRESHOLD: u32 = 1_000_000; /// https://drafts.css-houdini.org/worklets/#worklet pub struct Worklet { reflector: Reflector, - window: JS, + window: Dom, worklet_id: WorkletId, global_type: WorkletGlobalScopeType, } @@ -89,13 +87,13 @@ impl Worklet { fn new_inherited(window: &Window, global_type: WorkletGlobalScopeType) -> Worklet { Worklet { reflector: Reflector::new(), - window: JS::from_ref(window), + window: Dom::from_ref(window), worklet_id: WorkletId::new(), global_type: global_type, } } - pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> Root { + pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot { debug!("Creating worklet {:?}.", global_type); reflect_dom_object(box Worklet::new_inherited(window, global_type), window, Wrap) } @@ -398,7 +396,7 @@ struct WorkletThread { global_init: WorkletGlobalScopeInit, /// The global scopes created by this thread - global_scopes: HashMap>, + global_scopes: HashMap>, /// A one-place buffer for control messages control_buffer: Option, @@ -540,15 +538,15 @@ impl WorkletThread { worklet_id: WorkletId, global_type: WorkletGlobalScopeType, base_url: ServoUrl) - -> Root + -> DomRoot { match self.global_scopes.entry(worklet_id) { - hash_map::Entry::Occupied(entry) => Root::from_ref(entry.get()), + hash_map::Entry::Occupied(entry) => DomRoot::from_ref(entry.get()), hash_map::Entry::Vacant(entry) => { debug!("Creating new worklet global scope."); let executor = WorkletExecutor::new(worklet_id, self.primary_sender.clone()); let result = global_type.new(&self.runtime, pipeline_id, base_url, executor, &self.global_init); - entry.insert(JS::from_ref(&*result)); + entry.insert(Dom::from_ref(&*result)); result }, } diff --git a/servo/components/script/dom/workletglobalscope.rs b/servo/components/script/dom/workletglobalscope.rs index 210ede4172e6..adae76e22bb8 100644 --- a/servo/components/script/dom/workletglobalscope.rs +++ b/servo/components/script/dom/workletglobalscope.rs @@ -4,7 +4,7 @@ use devtools_traits::ScriptToDevtoolsControlMsg; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom::paintworkletglobalscope::PaintWorkletGlobalScope; use dom::paintworkletglobalscope::PaintWorkletTask; @@ -86,7 +86,7 @@ impl WorkletGlobalScope { /// Evaluate a JS script in this global. pub fn evaluate_js(&self, script: &str) -> bool { - debug!("Evaluating JS."); + debug!("Evaluating Dom."); rooted!(in (self.globalscope.get_cx()) let mut rval = UndefinedValue()); self.globalscope.evaluate_js_on_global_with_result(&*script, rval.handle_mut()) } @@ -171,13 +171,13 @@ impl WorkletGlobalScopeType { base_url: ServoUrl, executor: WorkletExecutor, init: &WorkletGlobalScopeInit) - -> Root + -> DomRoot { match *self { WorkletGlobalScopeType::Test => - Root::upcast(TestWorkletGlobalScope::new(runtime, pipeline_id, base_url, executor, init)), + DomRoot::upcast(TestWorkletGlobalScope::new(runtime, pipeline_id, base_url, executor, init)), WorkletGlobalScopeType::Paint => - Root::upcast(PaintWorkletGlobalScope::new(runtime, pipeline_id, base_url, executor, init)), + DomRoot::upcast(PaintWorkletGlobalScope::new(runtime, pipeline_id, base_url, executor, init)), } } } diff --git a/servo/components/script/dom/xmldocument.rs b/servo/components/script/dom/xmldocument.rs index 59c6739fb2d8..f5ef640abce9 100644 --- a/servo/components/script/dom/xmldocument.rs +++ b/servo/components/script/dom/xmldocument.rs @@ -7,8 +7,8 @@ use document_loader::DocumentLoader; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::XMLDocumentBinding::{self, XMLDocumentMethods}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument}; use dom::location::Location; @@ -62,7 +62,7 @@ impl XMLDocument { activity: DocumentActivity, source: DocumentSource, doc_loader: DocumentLoader) - -> Root { + -> DomRoot { let doc = reflect_dom_object( box XMLDocument::new_inherited(window, has_browsing_context, @@ -86,7 +86,7 @@ impl XMLDocument { impl XMLDocumentMethods for XMLDocument { // https://html.spec.whatwg.org/multipage/#dom-document-location - fn GetLocation(&self) -> Option> { + fn GetLocation(&self) -> Option> { self.upcast::().GetLocation() } diff --git a/servo/components/script/dom/xmlhttprequest.rs b/servo/components/script/dom/xmlhttprequest.rs index 559c7ef31a6b..4b9b2b45a4c7 100644 --- a/servo/components/script/dom/xmlhttprequest.rs +++ b/servo/components/script/dom/xmlhttprequest.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use document_loader::DocumentLoader; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::BlobBinding::BlobBinding::BlobMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::Bindings::XMLHttpRequestBinding; @@ -14,9 +14,9 @@ use dom::bindings::codegen::UnionTypes::DocumentOrBodyInit; use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{DomObject, reflect_dom_object}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use dom::bindings::str::{ByteString, DOMString, USVString, is_token}; use dom::blob::{Blob, BlobImpl}; use dom::document::{Document, HasBrowsingContext, IsHTMLDocument}; @@ -90,8 +90,8 @@ pub struct GenerationId(u32); struct XHRContext { xhr: TrustedXHRAddress, gen_id: GenerationId, - buf: DOMRefCell>, - sync_status: DOMRefCell>, + buf: DomRefCell>, + sync_status: DomRefCell>, } #[derive(Clone)] @@ -123,35 +123,35 @@ pub struct XMLHttpRequest { ready_state: Cell, timeout: Cell, with_credentials: Cell, - upload: JS, - response_url: DOMRefCell, + upload: Dom, + response_url: DomRefCell, status: Cell, - status_text: DOMRefCell, - response: DOMRefCell, + status_text: DomRefCell, + response: DomRefCell, response_type: Cell, - response_xml: MutNullableJS, - response_blob: MutNullableJS, + response_xml: MutNullableDom, + response_blob: MutNullableDom, #[ignore_heap_size_of = "Defined in rust-mozjs"] response_json: Heap, #[ignore_heap_size_of = "Defined in hyper"] - response_headers: DOMRefCell, + response_headers: DomRefCell, #[ignore_heap_size_of = "Defined in hyper"] - override_mime_type: DOMRefCell>, + override_mime_type: DomRefCell>, #[ignore_heap_size_of = "Defined in rust-encoding"] - override_charset: DOMRefCell>, + override_charset: DomRefCell>, // Associated concepts #[ignore_heap_size_of = "Defined in hyper"] - request_method: DOMRefCell, - request_url: DOMRefCell>, + request_method: DomRefCell, + request_url: DomRefCell>, #[ignore_heap_size_of = "Defined in hyper"] - request_headers: DOMRefCell, + request_headers: DomRefCell, request_body_len: Cell, sync: Cell, upload_complete: Cell, send_flag: Cell, - timeout_cancel: DOMRefCell>, + timeout_cancel: DomRefCell>, fetch_time: Cell, generation_id: Cell, response_status: Cell>, @@ -174,28 +174,28 @@ impl XMLHttpRequest { ready_state: Cell::new(XMLHttpRequestState::Unsent), timeout: Cell::new(0u32), with_credentials: Cell::new(false), - upload: JS::from_ref(&*XMLHttpRequestUpload::new(global)), - response_url: DOMRefCell::new(String::new()), + upload: Dom::from_ref(&*XMLHttpRequestUpload::new(global)), + response_url: DomRefCell::new(String::new()), status: Cell::new(0), - status_text: DOMRefCell::new(ByteString::new(vec!())), - response: DOMRefCell::new(ByteString::new(vec!())), + status_text: DomRefCell::new(ByteString::new(vec!())), + response: DomRefCell::new(ByteString::new(vec!())), response_type: Cell::new(XMLHttpRequestResponseType::_empty), response_xml: Default::default(), response_blob: Default::default(), response_json: Heap::default(), - response_headers: DOMRefCell::new(Headers::new()), - override_mime_type: DOMRefCell::new(None), - override_charset: DOMRefCell::new(None), + response_headers: DomRefCell::new(Headers::new()), + override_mime_type: DomRefCell::new(None), + override_charset: DomRefCell::new(None), - request_method: DOMRefCell::new(Method::Get), - request_url: DOMRefCell::new(None), - request_headers: DOMRefCell::new(Headers::new()), + request_method: DomRefCell::new(Method::Get), + request_url: DomRefCell::new(None), + request_headers: DomRefCell::new(Headers::new()), request_body_len: Cell::new(0), sync: Cell::new(false), upload_complete: Cell::new(false), send_flag: Cell::new(false), - timeout_cancel: DOMRefCell::new(None), + timeout_cancel: DomRefCell::new(None), fetch_time: Cell::new(0), generation_id: Cell::new(GenerationId(0)), response_status: Cell::new(Ok(())), @@ -203,14 +203,14 @@ impl XMLHttpRequest { referrer_policy: referrer_policy, } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box XMLHttpRequest::new_inherited(global), global, XMLHttpRequestBinding::Wrap) } // https://xhr.spec.whatwg.org/#constructors - pub fn Constructor(global: &GlobalScope) -> Fallible> { + pub fn Constructor(global: &GlobalScope) -> Fallible> { Ok(XMLHttpRequest::new(global)) } @@ -289,7 +289,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest { fn Open_(&self, method: ByteString, url: USVString, async: bool, username: Option, password: Option) -> ErrorResult { // Step 1 - if let Some(window) = Root::downcast::(self.global()) { + if let Some(window) = DomRoot::downcast::(self.global()) { if !window.Document().is_fully_active() { return Err(Error::InvalidState); } @@ -481,8 +481,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest { } // https://xhr.spec.whatwg.org/#the-upload-attribute - fn Upload(&self) -> Root { - Root::from_ref(&*self.upload) + fn Upload(&self) -> DomRoot { + DomRoot::from_ref(&*self.upload) } // https://xhr.spec.whatwg.org/#the-send()-method @@ -570,7 +570,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest { // preference is enabled, we allow bypassing the CORS check. // This is a temporary measure until we figure out Servo privilege // story. See https://github.com/servo/servo/issues/9582 - if let Some(win) = Root::downcast::(self.global()) { + if let Some(win) = DomRoot::downcast::(self.global()) { let is_root_pipeline = win.parent_info().is_none(); is_root_pipeline && PREFS.is_mozbrowser_enabled() } else { @@ -811,7 +811,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest { } // https://xhr.spec.whatwg.org/#the-responsexml-attribute - fn GetResponseXML(&self) -> Fallible>> { + fn GetResponseXML(&self) -> Fallible>> { // TODO(#2823): Until [Exposed] is implemented, this attribute needs to return null // explicitly in the worker scope. if self.global().is::() { @@ -1088,7 +1088,7 @@ impl XMLHttpRequest { } // https://xhr.spec.whatwg.org/#blob-response - fn blob_response(&self) -> Root { + fn blob_response(&self) -> DomRoot { // Step 1 if let Some(response) = self.response_blob.get() { return response; @@ -1104,7 +1104,7 @@ impl XMLHttpRequest { } // https://xhr.spec.whatwg.org/#document-response - fn document_response(&self) -> Option> { + fn document_response(&self) -> Option> { // Step 1 let response = self.response_xml.get(); if response.is_some() { @@ -1114,7 +1114,7 @@ impl XMLHttpRequest { let mime_type = self.final_mime_type(); // TODO: prescan the response to determine encoding if final charset is null let charset = self.final_charset().unwrap_or(UTF_8); - let temp_doc: Root; + let temp_doc: DomRoot; match mime_type { Some(Mime(mime::TopLevel::Text, mime::SubLevel::Html, _)) => { // Step 5 @@ -1181,7 +1181,7 @@ impl XMLHttpRequest { self.response_json.get() } - fn document_text_html(&self) -> Root { + fn document_text_html(&self) -> DomRoot { let charset = self.final_charset().unwrap_or(UTF_8); let wr = self.global(); let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap(); @@ -1194,7 +1194,7 @@ impl XMLHttpRequest { document } - fn handle_xml(&self) -> Root { + fn handle_xml(&self) -> DomRoot { let charset = self.final_charset().unwrap_or(UTF_8); let wr = self.global(); let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap(); @@ -1207,7 +1207,7 @@ impl XMLHttpRequest { document } - fn new_doc(&self, is_html_document: IsHTMLDocument) -> Root { + fn new_doc(&self, is_html_document: IsHTMLDocument) -> DomRoot { let wr = self.global(); let win = wr.as_window(); let doc = win.Document(); @@ -1279,8 +1279,8 @@ impl XMLHttpRequest { let context = Arc::new(Mutex::new(XHRContext { xhr: xhr, gen_id: self.generation_id.get(), - buf: DOMRefCell::new(vec!()), - sync_status: DOMRefCell::new(None), + buf: DomRefCell::new(vec!()), + sync_status: DomRefCell::new(None), })); let (task_source, script_port) = if self.sync.get() { diff --git a/servo/components/script/dom/xmlhttprequestupload.rs b/servo/components/script/dom/xmlhttprequestupload.rs index 02a54001388e..7c6a1a4f5131 100644 --- a/servo/components/script/dom/xmlhttprequestupload.rs +++ b/servo/components/script/dom/xmlhttprequestupload.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::XMLHttpRequestUploadBinding; -use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom::xmlhttprequesteventtarget::XMLHttpRequestEventTarget; use dom_struct::dom_struct; @@ -20,7 +20,7 @@ impl XMLHttpRequestUpload { eventtarget: XMLHttpRequestEventTarget::new_inherited(), } } - pub fn new(global: &GlobalScope) -> Root { + pub fn new(global: &GlobalScope) -> DomRoot { reflect_dom_object(box XMLHttpRequestUpload::new_inherited(), global, XMLHttpRequestUploadBinding::Wrap) diff --git a/servo/components/script/fetch.rs b/servo/components/script/fetch.rs index 47be4ced1309..7a6f63f7b406 100644 --- a/servo/components/script/fetch.rs +++ b/servo/components/script/fetch.rs @@ -8,9 +8,9 @@ use dom::bindings::codegen::Bindings::ResponseBinding::ResponseBinding::Response use dom::bindings::codegen::Bindings::ResponseBinding::ResponseType as DOMResponseType; use dom::bindings::error::Error; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::DomRoot; use dom::bindings::trace::RootedTraceableBox; use dom::globalscope::GlobalScope; use dom::headers::Guard; @@ -184,7 +184,7 @@ impl FetchResponseListener for FetchContext { } } -fn fill_headers_with_metadata(r: Root, m: Metadata) { +fn fill_headers_with_metadata(r: DomRoot, m: Metadata) { r.set_headers(m.headers); r.set_raw_status(m.status); r.set_final_url(m.final_url); diff --git a/servo/components/script/lib.rs b/servo/components/script/lib.rs index 0e63fef2a02b..6a6a40417e3c 100644 --- a/servo/components/script/lib.rs +++ b/servo/components/script/lib.rs @@ -141,7 +141,7 @@ mod webdriver_handlers; pub mod layout_exports { pub use dom::bindings::inheritance::{CharacterDataTypeId, ElementTypeId}; pub use dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId}; - pub use dom::bindings::js::LayoutJS; + pub use dom::bindings::root::LayoutDom; pub use dom::characterdata::LayoutCharacterDataHelpers; pub use dom::document::{Document, LayoutDocumentHelpers, PendingRestyle}; pub use dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; diff --git a/servo/components/script/microtask.rs b/servo/components/script/microtask.rs index 23288fefc8cd..f0ec5d44ae53 100644 --- a/servo/components/script/microtask.rs +++ b/servo/components/script/microtask.rs @@ -7,9 +7,9 @@ //! perform checkpoints at appropriate times, as well as enqueue microtasks as required. use dom::bindings::callback::ExceptionHandling; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::globalscope::GlobalScope; use dom::htmlimageelement::ImageElementMicrotask; use dom::htmlmediaelement::MediaElementMicrotask; @@ -24,7 +24,7 @@ use std::rc::Rc; #[derive(Default, HeapSizeOf, JSTraceable)] pub struct MicrotaskQueue { /// The list of enqueued microtasks that will be invoked at the next microtask checkpoint. - microtask_queue: DOMRefCell>, + microtask_queue: DomRefCell>, /// https://html.spec.whatwg.org/multipage/#performing-a-microtask-checkpoint performing_a_microtask_checkpoint: Cell, } @@ -60,7 +60,7 @@ impl MicrotaskQueue { /// https://html.spec.whatwg.org/multipage/#perform-a-microtask-checkpoint /// Perform a microtask checkpoint, executing all queued microtasks until the queue is empty. pub fn checkpoint(&self, target_provider: F) - where F: Fn(PipelineId) -> Option> + where F: Fn(PipelineId) -> Option> { if self.performing_a_microtask_checkpoint.get() { return; diff --git a/servo/components/script/script_runtime.rs b/servo/components/script/script_runtime.rs index be5acd33a6ac..e437e1a60019 100644 --- a/servo/components/script/script_runtime.rs +++ b/servo/components/script/script_runtime.rs @@ -6,8 +6,8 @@ //! script thread, the dom, and the worker threads. use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback; -use dom::bindings::js::{RootCollection, RootCollectionPtr, trace_roots}; use dom::bindings::refcounted::{LiveDOMReferences, trace_refcounted_objects}; +use dom::bindings::root::{RootCollection, RootCollectionPtr, trace_roots}; use dom::bindings::settings_stack; use dom::bindings::trace::{JSTraceable, trace_traceables}; use dom::bindings::utils::DOM_CALLBACKS; diff --git a/servo/components/script/script_thread.rs b/servo/components/script/script_thread.rs index b9bcf5be7c88..4b9984845e8b 100644 --- a/servo/components/script/script_thread.rs +++ b/servo/components/script/script_thread.rs @@ -24,7 +24,7 @@ use devtools_traits::{DevtoolScriptControlMsg, DevtoolsPageInfo}; use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; use devtools_traits::CSSError; use document_loader::DocumentLoader; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState}; use dom::bindings::codegen::Bindings::EventBinding::EventInit; @@ -32,10 +32,10 @@ use dom::bindings::codegen::Bindings::TransitionEventBinding::TransitionEventIni use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, StringificationBehavior}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root, RootCollection}; -use dom::bindings::js::{RootCollectionPtr, RootedReference}; use dom::bindings::num::Finite; use dom::bindings::reflector::DomObject; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootCollection}; +use dom::bindings::root::{RootCollectionPtr, RootedReference}; use dom::bindings::str::DOMString; use dom::bindings::structuredclone::StructuredCloneData; use dom::bindings::trace::JSTraceable; @@ -320,7 +320,7 @@ impl OpaqueSender for Sender { #[derive(JSTraceable)] #[must_root] pub struct Documents { - map: HashMap>, + map: HashMap>, } impl Documents { @@ -331,31 +331,31 @@ impl Documents { } pub fn insert(&mut self, pipeline_id: PipelineId, doc: &Document) { - self.map.insert(pipeline_id, JS::from_ref(doc)); + self.map.insert(pipeline_id, Dom::from_ref(doc)); } - pub fn remove(&mut self, pipeline_id: PipelineId) -> Option> { - self.map.remove(&pipeline_id).map(|ref doc| Root::from_ref(&**doc)) + pub fn remove(&mut self, pipeline_id: PipelineId) -> Option> { + self.map.remove(&pipeline_id).map(|ref doc| DomRoot::from_ref(&**doc)) } pub fn is_empty(&self) -> bool { self.map.is_empty() } - pub fn find_document(&self, pipeline_id: PipelineId) -> Option> { - self.map.get(&pipeline_id).map(|doc| Root::from_ref(&**doc)) + pub fn find_document(&self, pipeline_id: PipelineId) -> Option> { + self.map.get(&pipeline_id).map(|doc| DomRoot::from_ref(&**doc)) } - pub fn find_window(&self, pipeline_id: PipelineId) -> Option> { - self.find_document(pipeline_id).map(|doc| Root::from_ref(doc.window())) + pub fn find_window(&self, pipeline_id: PipelineId) -> Option> { + self.find_document(pipeline_id).map(|doc| DomRoot::from_ref(doc.window())) } - pub fn find_global(&self, pipeline_id: PipelineId) -> Option> { - self.find_window(pipeline_id).map(|window| Root::from_ref(window.upcast())) + pub fn find_global(&self, pipeline_id: PipelineId) -> Option> { + self.find_window(pipeline_id).map(|window| DomRoot::from_ref(window.upcast())) } pub fn find_iframe(&self, pipeline_id: PipelineId, browsing_context_id: BrowsingContextId) - -> Option> + -> Option> { self.find_document(pipeline_id).and_then(|doc| doc.find_iframe(browsing_context_id)) } @@ -369,14 +369,14 @@ impl Documents { #[allow(unrooted_must_root)] pub struct DocumentsIter<'a> { - iter: hash_map::Iter<'a, PipelineId, JS>, + iter: hash_map::Iter<'a, PipelineId, Dom>, } impl<'a> Iterator for DocumentsIter<'a> { - type Item = (PipelineId, Root); + type Item = (PipelineId, DomRoot); - fn next(&mut self) -> Option<(PipelineId, Root)> { - self.iter.next().map(|(id, doc)| (*id, Root::from_ref(&**doc))) + fn next(&mut self) -> Option<(PipelineId, DomRoot)> { + self.iter.next().map(|(id, doc)| (*id, DomRoot::from_ref(&**doc))) } } @@ -385,16 +385,16 @@ impl<'a> Iterator for DocumentsIter<'a> { #[allow(unrooted_must_root)] pub struct ScriptThread { /// The documents for pipelines managed by this thread - documents: DOMRefCell, + documents: DomRefCell, /// The window proxies known by this thread /// TODO: this map grows, but never shrinks. Issue #15258. - window_proxies: DOMRefCell>>, + window_proxies: DomRefCell>>, /// A list of data pertaining to loads that have not yet received a network response - incomplete_loads: DOMRefCell>, + incomplete_loads: DomRefCell>, /// A vector containing parser contexts which have not yet been fully processed - incomplete_parser_contexts: DOMRefCell>, + incomplete_parser_contexts: DomRefCell>, /// A map to store service worker registrations for a given origin - registration_map: DOMRefCell>>, + registration_map: DomRefCell>>, /// A job queue for Service Workers keyed by their scope url job_queue_map: Rc, /// Image cache for this script thread. @@ -458,10 +458,10 @@ pub struct ScriptThread { js_runtime: Rc, /// The topmost element over the mouse. - topmost_mouse_over_target: MutNullableJS, + topmost_mouse_over_target: MutNullableDom, /// List of pipelines that have been owned and closed by this script thread. - closed_pipelines: DOMRefCell>, + closed_pipelines: DomRefCell>, scheduler_chan: IpcSender, timer_event_chan: Sender, @@ -476,7 +476,7 @@ pub struct ScriptThread { mutation_observer_compound_microtask_queued: Cell, /// The unit of related similar-origin browsing contexts' list of MutationObserver objects - mutation_observers: DOMRefCell>>, + mutation_observers: DomRefCell>>, /// A handle to the webgl thread webgl_chan: WebGLPipeline, @@ -485,15 +485,15 @@ pub struct ScriptThread { webvr_chan: Option>, /// The worklet thread pool - worklet_thread_pool: DOMRefCell>>, + worklet_thread_pool: DomRefCell>>, /// A list of pipelines containing documents that finished loading all their blocking /// resources during a turn of the event loop. - docs_with_no_blocking_loads: DOMRefCell>>, + docs_with_no_blocking_loads: DomRefCell>>, /// A list of nodes with in-progress CSS transitions, which roots them for the duration /// of the transition. - transitioning_nodes: DOMRefCell>>, + transitioning_nodes: DomRefCell>>, /// https://html.spec.whatwg.org/multipage/#custom-element-reactions-stack custom_element_reaction_stack: CustomElementReactionStack, @@ -588,7 +588,7 @@ impl ScriptThread { let js_runtime = script_thread.js_runtime.rt(); let new_nodes = nodes .into_iter() - .map(|n| JS::from_ref(&*from_untrusted_node_address(js_runtime, n))); + .map(|n| Dom::from_ref(&*from_untrusted_node_address(js_runtime, n))); script_thread.transitioning_nodes.borrow_mut().extend(new_nodes); }) } @@ -612,14 +612,14 @@ impl ScriptThread { let script_thread = unsafe { &*root.get().unwrap() }; script_thread.mutation_observers .borrow_mut() - .push(JS::from_ref(observer)); + .push(Dom::from_ref(observer)); }) } - pub fn get_mutation_observers() -> Vec> { + pub fn get_mutation_observers() -> Vec> { SCRIPT_THREAD_ROOT.with(|root| { let script_thread = unsafe { &*root.get().unwrap() }; - script_thread.mutation_observers.borrow().iter().map(|o| Root::from_ref(&**o)).collect() + script_thread.mutation_observers.borrow().iter().map(|o| DomRoot::from_ref(&**o)).collect() }) } @@ -628,7 +628,7 @@ impl ScriptThread { let script_thread = unsafe { &*root.get().unwrap() }; script_thread.docs_with_no_blocking_loads .borrow_mut() - .insert(JS::from_ref(doc)); + .insert(Dom::from_ref(doc)); }) } @@ -640,7 +640,7 @@ impl ScriptThread { } pub fn page_headers_available(id: &PipelineId, metadata: Option) - -> Option> { + -> Option> { SCRIPT_THREAD_ROOT.with(|root| { let script_thread = unsafe { &*root.get().unwrap() }; script_thread.handle_page_headers_available(id, metadata) @@ -686,18 +686,18 @@ impl ScriptThread { }); } - pub fn find_document(id: PipelineId) -> Option> { + pub fn find_document(id: PipelineId) -> Option> { SCRIPT_THREAD_ROOT.with(|root| root.get().and_then(|script_thread| { let script_thread = unsafe { &*script_thread }; script_thread.documents.borrow().find_document(id) })) } - pub fn find_window_proxy(id: BrowsingContextId) -> Option> { + pub fn find_window_proxy(id: BrowsingContextId) -> Option> { SCRIPT_THREAD_ROOT.with(|root| root.get().and_then(|script_thread| { let script_thread = unsafe { &*script_thread }; script_thread.window_proxies.borrow().get(&id) - .map(|context| Root::from_ref(&**context)) + .map(|context| DomRoot::from_ref(&**context)) })) } @@ -811,11 +811,11 @@ impl ScriptThread { let (image_cache_channel, image_cache_port) = channel(); ScriptThread { - documents: DOMRefCell::new(Documents::new()), - window_proxies: DOMRefCell::new(HashMap::new()), - incomplete_loads: DOMRefCell::new(vec!()), - incomplete_parser_contexts: DOMRefCell::new(vec!()), - registration_map: DOMRefCell::new(HashMap::new()), + documents: DomRefCell::new(Documents::new()), + window_proxies: DomRefCell::new(HashMap::new()), + incomplete_loads: DomRefCell::new(vec!()), + incomplete_parser_contexts: DomRefCell::new(vec!()), + registration_map: DomRefCell::new(HashMap::new()), job_queue_map: Rc::new(JobQueue::new()), image_cache: state.image_cache.clone(), @@ -846,8 +846,8 @@ impl ScriptThread { devtools_sender: ipc_devtools_sender, js_runtime: Rc::new(runtime), - topmost_mouse_over_target: MutNullableJS::new(Default::default()), - closed_pipelines: DOMRefCell::new(HashSet::new()), + topmost_mouse_over_target: MutNullableDom::new(Default::default()), + closed_pipelines: DomRefCell::new(HashSet::new()), scheduler_chan: state.scheduler_chan, timer_event_chan: timer_event_chan, @@ -1657,7 +1657,7 @@ impl ScriptThread { /// We have received notification that the response associated with a load has completed. /// Kick off the document and frame tree creation process using the result. fn handle_page_headers_available(&self, id: &PipelineId, - metadata: Option) -> Option> { + metadata: Option) -> Option> { let idx = self.incomplete_loads.borrow().iter().position(|load| { load.pipeline_id == *id }); // The matching in progress load structure may not exist if // the pipeline exited before the page load completed. @@ -1685,9 +1685,9 @@ impl ScriptThread { } } - pub fn handle_get_registration(&self, scope_url: &ServoUrl) -> Option> { + pub fn handle_get_registration(&self, scope_url: &ServoUrl) -> Option> { let maybe_registration_ref = self.registration_map.borrow(); - maybe_registration_ref.get(scope_url).map(|x| Root::from_ref(&**x)) + maybe_registration_ref.get(scope_url).map(|x| DomRoot::from_ref(&**x)) } pub fn handle_serviceworker_registration(&self, @@ -1699,7 +1699,7 @@ impl ScriptThread { // according to spec we should replace if an older registration exists for // same scope otherwise just insert the new one let _ = reg_ref.remove(scope); - reg_ref.insert(scope.clone(), JS::from_ref(registration)); + reg_ref.insert(scope.clone(), Dom::from_ref(registration)); } // send ScopeThings to sw-manager @@ -1940,14 +1940,14 @@ impl ScriptThread { global_to_clone: &GlobalScope, top_level_browsing_context_id: TopLevelBrowsingContextId, pipeline_id: PipelineId) - -> Option> + -> Option> { let browsing_context_id = match self.ask_constellation_for_browsing_context_id(pipeline_id) { Some(browsing_context_id) => browsing_context_id, None => return None, }; if let Some(window_proxy) = self.window_proxies.borrow().get(&browsing_context_id) { - return Some(Root::from_ref(window_proxy)); + return Some(DomRoot::from_ref(window_proxy)); } let parent = match self.ask_constellation_for_parent_info(pipeline_id) { Some((parent_id, FrameType::IFrame)) => self.remote_window_proxy(global_to_clone, @@ -1959,7 +1959,7 @@ impl ScriptThread { browsing_context_id, top_level_browsing_context_id, parent.r()); - self.window_proxies.borrow_mut().insert(browsing_context_id, JS::from_ref(&*window_proxy)); + self.window_proxies.borrow_mut().insert(browsing_context_id, Dom::from_ref(&*window_proxy)); Some(window_proxy) } @@ -1974,11 +1974,11 @@ impl ScriptThread { browsing_context_id: BrowsingContextId, top_level_browsing_context_id: TopLevelBrowsingContextId, parent_info: Option<(PipelineId, FrameType)>) - -> Root + -> DomRoot { if let Some(window_proxy) = self.window_proxies.borrow().get(&browsing_context_id) { window_proxy.set_currently_active(&*window); - return Root::from_ref(window_proxy); + return DomRoot::from_ref(window_proxy); } let iframe = match parent_info { Some((parent_id, FrameType::IFrame)) => self.documents.borrow().find_iframe(parent_id, browsing_context_id), @@ -1996,13 +1996,13 @@ impl ScriptThread { top_level_browsing_context_id, iframe.r().map(Castable::upcast), parent.r()); - self.window_proxies.borrow_mut().insert(browsing_context_id, JS::from_ref(&*window_proxy)); + self.window_proxies.borrow_mut().insert(browsing_context_id, Dom::from_ref(&*window_proxy)); window_proxy } /// The entry point to document loading. Defines bindings, sets up the window and document /// objects, parses HTML and CSS, and kicks off initial layout. - fn load(&self, metadata: Metadata, incomplete: InProgressLoad) -> Root { + fn load(&self, metadata: Metadata, incomplete: InProgressLoad) -> DomRoot { let final_url = metadata.final_url.clone(); { // send the final url to the layout thread. @@ -2213,7 +2213,7 @@ impl ScriptThread { if let Some(target) = self.topmost_mouse_over_target.get() { if let Some(anchor) = target.upcast::() .inclusive_ancestors() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .next() { let status = anchor.upcast::() .get_attribute(&ns!(), &local_name!("href")) @@ -2235,7 +2235,7 @@ impl ScriptThread { if let Some(target) = prev_mouse_over_target { if let Some(_) = target.upcast::() .inclusive_ancestors() - .filter_map(Root::downcast::) + .filter_map(DomRoot::downcast::) .next() { let event = ScriptMsg::NodeStatus(None); self.script_sender.send((pipeline_id, event)).unwrap(); diff --git a/servo/components/script/serviceworkerjob.rs b/servo/components/script/serviceworkerjob.rs index 879b2b81e291..1a146f82c618 100644 --- a/servo/components/script/serviceworkerjob.rs +++ b/servo/components/script/serviceworkerjob.rs @@ -7,11 +7,11 @@ //! the script thread. The script thread contains a JobQueue, which stores all scheduled Jobs //! by multiple service worker clients in a Vec. -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::error::Error; -use dom::bindings::js::JS; use dom::bindings::refcounted::{Trusted, TrustedPromise}; use dom::bindings::reflector::DomObject; +use dom::bindings::root::Dom; use dom::client::Client; use dom::promise::Promise; use dom::serviceworkerregistration::ServiceWorkerRegistration; @@ -46,7 +46,7 @@ pub struct Job { pub promise: Rc, pub equivalent_jobs: Vec, // client can be a window client, worker client so `Client` will be an enum in future - pub client: JS, + pub client: Dom, pub referrer: ServoUrl } @@ -64,7 +64,7 @@ impl Job { script_url: script_url, promise: promise, equivalent_jobs: vec![], - client: JS::from_ref(client), + client: Dom::from_ref(client), referrer: client.creation_url() } } @@ -93,11 +93,11 @@ impl PartialEq for Job { #[must_root] #[derive(JSTraceable)] -pub struct JobQueue(pub DOMRefCell>>); +pub struct JobQueue(pub DomRefCell>>); impl JobQueue { pub fn new() -> JobQueue { - JobQueue(DOMRefCell::new(HashMap::new())) + JobQueue(DomRefCell::new(HashMap::new())) } #[allow(unrooted_must_root)] // https://w3c.github.io/ServiceWorker/#schedule-job-algorithm diff --git a/servo/components/script/test.rs b/servo/components/script/test.rs index bdd84d681b86..0ff6811b14da 100644 --- a/servo/components/script/test.rs +++ b/servo/components/script/test.rs @@ -6,8 +6,8 @@ pub use dom::bindings::str::{ByteString, DOMString}; pub use dom::headers::normalize_value; // For compile-fail tests only. -pub use dom::bindings::cell::DOMRefCell; -pub use dom::bindings::js::JS; +pub use dom::bindings::cell::DomRefCell; +pub use dom::bindings::root::Dom; pub use dom::node::Node; pub use dom::bindings::refcounted::TrustedPromise; diff --git a/servo/components/script/timers.rs b/servo/components/script/timers.rs index 7d219bbb199d..1f69eca03ba9 100644 --- a/servo/components/script/timers.rs +++ b/servo/components/script/timers.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::callback::ExceptionHandling::Report; -use dom::bindings::cell::DOMRefCell; +use dom::bindings::cell::DomRefCell; use dom::bindings::codegen::Bindings::FunctionBinding::Function; use dom::bindings::reflector::DomObject; use dom::bindings::str::DOMString; @@ -38,7 +38,7 @@ pub struct OneshotTimers { #[ignore_heap_size_of = "Defined in std"] scheduler_chan: IpcSender, next_timer_handle: Cell, - timers: DOMRefCell>, + timers: DomRefCell>, suspended_since: Cell>, /// Initially 0, increased whenever the associated document is reactivated /// by the amount of ms the document was inactive. The current time can be @@ -117,7 +117,7 @@ impl OneshotTimers { timer_event_chan: timer_event_chan, scheduler_chan: scheduler_chan, next_timer_handle: Cell::new(OneshotTimerHandle(1)), - timers: DOMRefCell::new(Vec::new()), + timers: DomRefCell::new(Vec::new()), suspended_since: Cell::new(None), suspension_offset: Cell::new(Length::new(0)), expected_event_id: Cell::new(TimerEventId(0)), @@ -307,7 +307,7 @@ pub struct JsTimerHandle(i32); #[derive(DenyPublicFields, HeapSizeOf, JSTraceable)] pub struct JsTimers { next_timer_handle: Cell, - active_timers: DOMRefCell>, + active_timers: DomRefCell>, /// The nesting level of the currently executing timer task or 0. nesting_level: Cell, /// Used to introduce a minimum delay in event intervals @@ -364,7 +364,7 @@ impl JsTimers { pub fn new() -> JsTimers { JsTimers { next_timer_handle: Cell::new(JsTimerHandle(1)), - active_timers: DOMRefCell::new(HashMap::new()), + active_timers: DomRefCell::new(HashMap::new()), nesting_level: Cell::new(0), min_duration: Cell::new(None), } diff --git a/servo/components/script/webdriver_handlers.rs b/servo/components/script/webdriver_handlers.rs index c01a7d9a51a8..39dba228ba3c 100644 --- a/servo/components/script/webdriver_handlers.rs +++ b/servo/components/script/webdriver_handlers.rs @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, StringificationBehavior}; use dom::bindings::inheritance::Castable; -use dom::bindings::js::Root; +use dom::bindings::root::DomRoot; use dom::bindings::str::DOMString; use dom::element::Element; use dom::globalscope::GlobalScope; @@ -40,7 +40,7 @@ use servo_url::ServoUrl; fn find_node_by_unique_id(documents: &Documents, pipeline: PipelineId, node_id: String) - -> Option> { + -> Option> { documents.find_document(pipeline).and_then(|document| document.upcast::().traverse_preorder().find(|candidate| candidate.unique_id() == node_id) ) diff --git a/servo/components/script_layout_interface/wrapper_traits.rs b/servo/components/script_layout_interface/wrapper_traits.rs index d022360305b6..8221a3f885c3 100644 --- a/servo/components/script_layout_interface/wrapper_traits.rs +++ b/servo/components/script_layout_interface/wrapper_traits.rs @@ -79,7 +79,7 @@ pub trait GetLayoutData { } /// A wrapper so that layout can access only the methods that it should have access to. Layout must -/// only ever see these and must never see instances of `LayoutJS`. +/// only ever see these and must never see instances of `LayoutDom`. pub trait LayoutNode: Debug + GetLayoutData + TNode { type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode; fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode; diff --git a/servo/components/script_plugins/unrooted_must_root.rs b/servo/components/script_plugins/unrooted_must_root.rs index b0b409862c51..5b5647794dcb 100644 --- a/servo/components/script_plugins/unrooted_must_root.rs +++ b/servo/components/script_plugins/unrooted_must_root.rs @@ -186,11 +186,11 @@ impl<'a, 'b, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'b, 'tcx> { hir::ExprCast(ref subexpr, _) => require_rooted(cx, self.in_new_function, &*subexpr), // This catches assignments... the main point of this would be to catch mutable // references to `JS`. - // FIXME: Enable this? Triggers on certain kinds of uses of DOMRefCell. + // FIXME: Enable this? Triggers on certain kinds of uses of DomRefCell. // hir::ExprAssign(_, ref rhs) => require_rooted(cx, self.in_new_function, &*rhs), // This catches calls; basically, this enforces the constraint that only constructors // can call other constructors. - // FIXME: Enable this? Currently triggers with constructs involving DOMRefCell, and + // FIXME: Enable this? Currently triggers with constructs involving DomRefCell, and // constructs like Vec> and RootedVec>. // hir::ExprCall(..) if !self.in_new_function => { // require_rooted(cx, self.in_new_function, expr); diff --git a/servo/python/tidy/servo_tidy/tidy.py b/servo/python/tidy/servo_tidy/tidy.py index e88f4dc14586..e23834c0c58c 100644 --- a/servo/python/tidy/servo_tidy/tidy.py +++ b/servo/python/tidy/servo_tidy/tidy.py @@ -574,11 +574,11 @@ def check_rust(file_name, lines): # No benefit over using &str (r": &String", "use &str instead of &String", no_filter), # There should be any use of banned types: - # Cell, Cell>, DOMRefCell>, DOMRefCell> - (r"(\s|:)+Cell", "Banned type Cell detected. Use MutJS instead", no_filter), - (r"(\s|:)+Cell>", "Banned type Cell> detected. Use MutJS> instead", no_filter), - (r"DOMRefCell>", "Banned type DOMRefCell> detected. Use MutJS> instead", no_filter), - (r"DOMRefCell>", "Banned type DOMRefCell> detected. Use MutJS> instead", no_filter), + # Cell, Cell>, DomRefCell>, DomRefCell> + (r"(\s|:)+Cell", "Banned type Cell detected. Use MutDom instead", no_filter), + (r"(\s|:)+Cell>", "Banned type Cell> detected. Use MutDom instead", no_filter), + (r"DomRefCell>", "Banned type DomRefCell> detected. Use MutDom instead", no_filter), + (r"DomRefCell>", "Banned type DomRefCell> detected. Use MutDom instead", no_filter), # No benefit to using &Root (r": &Root<", "use &T instead of &Root", no_filter), (r"^&&", "operators should go at the end of the first line", no_filter), diff --git a/servo/python/tidy/servo_tidy_tests/ban-domrefcell.rs b/servo/python/tidy/servo_tidy_tests/ban-domrefcell.rs index a5953590d694..74b79e813cfa 100644 --- a/servo/python/tidy/servo_tidy_tests/ban-domrefcell.rs +++ b/servo/python/tidy/servo_tidy_tests/ban-domrefcell.rs @@ -7,13 +7,13 @@ extern crate script; -use script::test::DOMRefCell; -use script::test::JS; +use script::test::Dom; +use script::test::DomRefCell; use script::test::Node; struct Foo { - bar: DOMRefCell> - //~^ ERROR Banned type DOMRefCell> detected. Use MutJS> instead + bar: DomRefCell> + //~^ ERROR Banned type DomRefCell> detected. Use MutDom instead } fn main() {} diff --git a/servo/python/tidy/servo_tidy_tests/ban.rs b/servo/python/tidy/servo_tidy_tests/ban.rs index f828053d289c..fc5c600041a9 100644 --- a/servo/python/tidy/servo_tidy_tests/ban.rs +++ b/servo/python/tidy/servo_tidy_tests/ban.rs @@ -13,7 +13,7 @@ use std::cell::UnsafeCell; struct Foo { bar: Cell, - //~^ ERROR Banned type Cell detected. Use MutJS instead + //~^ ERROR Banned type Cell detected. Use MutDom instead foo: UnsafeCell //~^ NOT AN ERROR } diff --git a/servo/python/tidy/servo_tidy_tests/test_tidy.py b/servo/python/tidy/servo_tidy_tests/test_tidy.py index 4631d20ded78..3826e4537b5c 100644 --- a/servo/python/tidy/servo_tidy_tests/test_tidy.py +++ b/servo/python/tidy/servo_tidy_tests/test_tidy.py @@ -147,11 +147,11 @@ class CheckTidiness(unittest.TestCase): self.assertNoMoreErrors(feature_errors) ban_errors = tidy.collect_errors_for_files(iterFile('ban.rs'), [], [tidy.check_rust], print_text=False) - self.assertEqual('Banned type Cell detected. Use MutJS instead', ban_errors.next()[2]) + self.assertEqual('Banned type Cell detected. Use MutDom instead', ban_errors.next()[2]) self.assertNoMoreErrors(ban_errors) ban_errors = tidy.collect_errors_for_files(iterFile('ban-domrefcell.rs'), [], [tidy.check_rust], print_text=False) - self.assertEqual('Banned type DOMRefCell> detected. Use MutJS> instead', ban_errors.next()[2]) + self.assertEqual('Banned type DomRefCell> detected. Use MutDom instead', ban_errors.next()[2]) self.assertNoMoreErrors(ban_errors) def test_spec_link(self):