From 093b7b7710a71955ccce8bef74c39178f378116b Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 7 Jun 2016 10:30:52 +0200 Subject: [PATCH 1/8] Move the definition of ServoThreadSafeLayoutNode::selection to script. --- components/layout/wrapper.rs | 15 ++++----------- components/script/dom/node.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 10dde4b2ff0..98f71d309ea 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -49,8 +49,6 @@ use script::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelper use script::dom::htmlcanvaselement::{LayoutHTMLCanvasElementHelpers, HTMLCanvasData}; use script::dom::htmliframeelement::HTMLIFrameElement; use script::dom::htmlimageelement::LayoutHTMLImageElementHelpers; -use script::dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers}; -use script::dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers}; use script::dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; use script::dom::node::{LayoutNodeHelpers, Node, OpaqueStyleAndLayoutData}; use script::dom::text::Text; @@ -1142,15 +1140,10 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { fn selection(&self) -> Option> { let this = unsafe { self.get_jsmanaged() }; - let selection = if let Some(area) = this.downcast::() { - unsafe { area.selection_for_layout() } - } else if let Some(input) = this.downcast::() { - unsafe { input.selection_for_layout() } - } else { - return None; - }; - selection.map(|range| Range::new(ByteIndex(range.start as isize), - ByteIndex(range.len() as isize))) + this.selection().map(|range| { + Range::new(ByteIndex(range.start as isize), + ByteIndex(range.len() as isize)) + }) } fn image_url(&self) -> Option { diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 384465a8039..b46b48bc050 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -68,6 +68,7 @@ use std::cmp::max; use std::default::Default; use std::iter::{self, FilterMap, Peekable}; use std::mem; +use std::ops::Range; use string_cache::{Atom, Namespace, QualName}; use style::selector_impl::ServoSelectorImpl; use util::thread_state; @@ -960,6 +961,7 @@ pub trait LayoutNodeHelpers { unsafe fn init_style_and_layout_data(&self, OpaqueStyleAndLayoutData); fn text_content(&self) -> String; + fn selection(&self) -> Option>; } impl LayoutNodeHelpers for LayoutJS { @@ -1067,6 +1069,19 @@ impl LayoutNodeHelpers for LayoutJS { panic!("not text!") } + + #[allow(unsafe_code)] + fn selection(&self) -> Option> { + if let Some(area) = self.downcast::() { + return unsafe { area.selection_for_layout() }; + } + + if let Some(input) = self.downcast::() { + return unsafe { input.selection_for_layout() }; + } + + None + } } From ef3c6a7773f31fd8dbdee074893346692adbf8d3 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 7 Jun 2016 10:57:20 +0200 Subject: [PATCH 2/8] Move the definition of ServoThreadSafeLayoutNode::image_url to script. --- components/layout/wrapper.rs | 8 ++------ components/script/dom/node.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 98f71d309ea..c7e400cb588 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -48,7 +48,6 @@ use script::dom::document::{Document, LayoutDocumentHelpers}; use script::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; use script::dom::htmlcanvaselement::{LayoutHTMLCanvasElementHelpers, HTMLCanvasData}; use script::dom::htmliframeelement::HTMLIFrameElement; -use script::dom::htmlimageelement::LayoutHTMLImageElementHelpers; use script::dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; use script::dom::node::{LayoutNodeHelpers, Node, OpaqueStyleAndLayoutData}; use script::dom::text::Text; @@ -1147,11 +1146,8 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { } fn image_url(&self) -> Option { - unsafe { - self.get_jsmanaged().downcast() - .expect("not an image!") - .image_url() - } + let this = unsafe { self.get_jsmanaged() }; + this.image_url() } fn canvas_data(&self) -> Option { diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index b46b48bc050..9575a7bea16 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -40,6 +40,7 @@ use dom::eventtarget::EventTarget; use dom::htmlbodyelement::HTMLBodyElement; use dom::htmlcollection::HTMLCollection; use dom::htmlelement::HTMLElement; +use dom::htmlimageelement::{HTMLImageElement, LayoutHTMLImageElementHelpers}; use dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers}; use dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers}; use dom::nodelist::NodeList; @@ -71,6 +72,7 @@ use std::mem; use std::ops::Range; use string_cache::{Atom, Namespace, QualName}; use style::selector_impl::ServoSelectorImpl; +use url::Url; use util::thread_state; use uuid::Uuid; @@ -962,6 +964,7 @@ pub trait LayoutNodeHelpers { fn text_content(&self) -> String; fn selection(&self) -> Option>; + fn image_url(&self) -> Option; } impl LayoutNodeHelpers for LayoutJS { @@ -1082,6 +1085,15 @@ impl LayoutNodeHelpers for LayoutJS { None } + + #[allow(unsafe_code)] + fn image_url(&self) -> Option { + unsafe { + self.downcast::() + .expect("not an image!") + .image_url() + } + } } From 5859109197f35edaee07682547c22d27201a60ae Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 7 Jun 2016 11:10:40 +0200 Subject: [PATCH 3/8] Move the definition of ServoThreadSafeLayoutNode::canvas_data to script. --- components/layout/wrapper.rs | 8 +++----- components/script/dom/node.rs | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index c7e400cb588..30435fb884a 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -46,7 +46,7 @@ use script::dom::bindings::js::LayoutJS; use script::dom::characterdata::LayoutCharacterDataHelpers; use script::dom::document::{Document, LayoutDocumentHelpers}; use script::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; -use script::dom::htmlcanvaselement::{LayoutHTMLCanvasElementHelpers, HTMLCanvasData}; +use script::dom::htmlcanvaselement::HTMLCanvasData; use script::dom::htmliframeelement::HTMLIFrameElement; use script::dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; use script::dom::node::{LayoutNodeHelpers, Node, OpaqueStyleAndLayoutData}; @@ -1151,10 +1151,8 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { } fn canvas_data(&self) -> Option { - unsafe { - let canvas_element = self.get_jsmanaged().downcast(); - canvas_element.map(|canvas| canvas.data()) - } + let this = unsafe { self.get_jsmanaged() }; + this.canvas_data() } fn iframe_pipeline_id(&self) -> PipelineId { diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 9575a7bea16..f265f83a098 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -38,6 +38,7 @@ use dom::documenttype::DocumentType; use dom::element::{Element, ElementCreator}; use dom::eventtarget::EventTarget; use dom::htmlbodyelement::HTMLBodyElement; +use dom::htmlcanvaselement::{LayoutHTMLCanvasElementHelpers, HTMLCanvasData}; use dom::htmlcollection::HTMLCollection; use dom::htmlelement::HTMLElement; use dom::htmlimageelement::{HTMLImageElement, LayoutHTMLImageElementHelpers}; @@ -965,6 +966,7 @@ pub trait LayoutNodeHelpers { fn text_content(&self) -> String; fn selection(&self) -> Option>; fn image_url(&self) -> Option; + fn canvas_data(&self) -> Option; } impl LayoutNodeHelpers for LayoutJS { @@ -1094,6 +1096,11 @@ impl LayoutNodeHelpers for LayoutJS { .image_url() } } + + fn canvas_data(&self) -> Option { + self.downcast() + .map(|canvas| canvas.data()) + } } From 858ea2eb9afdee0767a4d35b7f858fde03dd6108 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 7 Jun 2016 11:39:28 +0200 Subject: [PATCH 4/8] Move the definition of ServoThreadSafeLayoutNode::iframe_pipeline_id to script. --- components/layout/wrapper.rs | 9 ++------- components/script/dom/node.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 30435fb884a..753f519f013 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -47,7 +47,6 @@ use script::dom::characterdata::LayoutCharacterDataHelpers; use script::dom::document::{Document, LayoutDocumentHelpers}; use script::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; use script::dom::htmlcanvaselement::HTMLCanvasData; -use script::dom::htmliframeelement::HTMLIFrameElement; use script::dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; use script::dom::node::{LayoutNodeHelpers, Node, OpaqueStyleAndLayoutData}; use script::dom::text::Text; @@ -1156,12 +1155,8 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { } fn iframe_pipeline_id(&self) -> PipelineId { - use script::dom::htmliframeelement::HTMLIFrameElementLayoutMethods; - unsafe { - let iframe_element = self.get_jsmanaged().downcast::() - .expect("not an iframe element!"); - iframe_element.pipeline_id().unwrap() - } + let this = unsafe { self.get_jsmanaged() }; + this.iframe_pipeline_id() } fn get_colspan(&self) -> u32 { diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index f265f83a098..d3e6a955284 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -41,6 +41,7 @@ use dom::htmlbodyelement::HTMLBodyElement; use dom::htmlcanvaselement::{LayoutHTMLCanvasElementHelpers, HTMLCanvasData}; use dom::htmlcollection::HTMLCollection; use dom::htmlelement::HTMLElement; +use dom::htmliframeelement::{HTMLIFrameElement, HTMLIFrameElementLayoutMethods}; use dom::htmlimageelement::{HTMLImageElement, LayoutHTMLImageElementHelpers}; use dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers}; use dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers}; @@ -58,6 +59,7 @@ use html5ever::tree_builder::QuirksMode; use js::jsapi::{JSContext, JSObject, JSRuntime}; use layout_interface::Msg; use libc::{self, c_void, uintptr_t}; +use msg::constellation_msg::PipelineId; use parse::html::parse_html_fragment; use ref_slice::ref_slice; use script_traits::UntrustedNodeAddress; @@ -967,6 +969,7 @@ pub trait LayoutNodeHelpers { fn selection(&self) -> Option>; fn image_url(&self) -> Option; fn canvas_data(&self) -> Option; + fn iframe_pipeline_id(&self) -> PipelineId; } impl LayoutNodeHelpers for LayoutJS { @@ -1101,6 +1104,12 @@ impl LayoutNodeHelpers for LayoutJS { self.downcast() .map(|canvas| canvas.data()) } + + fn iframe_pipeline_id(&self) -> PipelineId { + let iframe_element = self.downcast::() + .expect("not an iframe element!"); + iframe_element.pipeline_id().unwrap() + } } From 684510bc94611ef0e9279d5fe8139a2f5a4c0157 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 7 Jun 2016 13:15:23 +0200 Subject: [PATCH 5/8] Stop re-exporting AttrValue. --- components/layout/wrapper.rs | 2 +- components/script/dom/attr.rs | 2 +- components/script/dom/document.rs | 3 ++- components/script/dom/element.rs | 3 +-- components/script/dom/htmlanchorelement.rs | 3 +-- components/script/dom/htmlappletelement.rs | 2 +- components/script/dom/htmlareaelement.rs | 2 +- components/script/dom/htmlbaseelement.rs | 3 ++- components/script/dom/htmlbodyelement.rs | 3 ++- components/script/dom/htmlcanvaselement.rs | 2 +- components/script/dom/htmlelement.rs | 2 +- components/script/dom/htmlfontelement.rs | 2 +- components/script/dom/htmlformelement.rs | 2 +- components/script/dom/htmlhrelement.rs | 3 +-- components/script/dom/htmliframeelement.rs | 4 ++-- components/script/dom/htmlimageelement.rs | 3 +-- components/script/dom/htmlinputelement.rs | 3 ++- components/script/dom/htmllabelelement.rs | 2 +- components/script/dom/htmllinkelement.rs | 3 ++- components/script/dom/htmlmetaelement.rs | 3 ++- components/script/dom/htmlselectelement.rs | 3 ++- components/script/dom/htmltablecellelement.rs | 3 +-- components/script/dom/htmltableelement.rs | 4 ++-- components/script/dom/htmltablerowelement.rs | 3 +-- components/script/dom/htmltablesectionelement.rs | 2 +- components/script/dom/htmltextareaelement.rs | 3 ++- components/script/dom/macros.rs | 2 +- components/script/dom/virtualmethods.rs | 4 ++-- 28 files changed, 39 insertions(+), 37 deletions(-) diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 753f519f013..7c60ed4625b 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -39,7 +39,6 @@ use incremental::RestyleDamage; use msg::constellation_msg::PipelineId; use opaque_node::OpaqueNodeMethods; use range::Range; -use script::dom::attr::AttrValue; use script::dom::bindings::inheritance::{CharacterDataTypeId, ElementTypeId}; use script::dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId}; use script::dom::bindings::js::LayoutJS; @@ -59,6 +58,7 @@ use std::marker::PhantomData; use std::mem::{transmute, transmute_copy}; use std::sync::Arc; use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace}; +use style::attr::AttrValue; use style::computed_values::content::ContentItem; use style::computed_values::{content, display}; use style::dom::{PresentationalHintsSynthetizer, TDocument, TElement, TNode, UnsafeNode}; diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 43c1226b295..d5a00e6c1fa 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -18,7 +18,7 @@ use std::borrow::ToOwned; use std::cell::Ref; use std::mem; use string_cache::{Atom, Namespace}; -pub use style::attr::{AttrIdentifier, AttrValue}; +use style::attr::{AttrIdentifier, AttrValue}; // https://dom.spec.whatwg.org/#interface-attr #[dom_struct] diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 0897ccc24ae..a3a9d4beeaa 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -4,7 +4,7 @@ use document_loader::{DocumentLoader, LoadType}; use dom::activation::{ActivationSource, synthetic_click_activation}; -use dom::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use dom::bindings::codegen::Bindings::DocumentBinding; @@ -120,6 +120,7 @@ use std::ptr; use std::rc::Rc; use std::sync::Arc; use string_cache::{Atom, QualName}; +use style::attr::AttrValue; use style::context::ReflowGoal; use style::restyle_hints::ElementSnapshot; use style::servo::Stylesheet; diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 0432be3987c..34791c3417c 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -8,7 +8,6 @@ use app_units::Au; use cssparser::{Color, ToCss}; use devtools_traits::AttrInfo; use dom::activation::Activatable; -use dom::attr::AttrValue; use dom::attr::{Attr, AttrHelpersForLayout}; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; @@ -85,7 +84,7 @@ use std::mem; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace, QualName}; -use style::attr::LengthOrPercentageOrAuto; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use style::element_state::*; use style::parser::ParserContextExtraData; use style::properties::DeclaredValue; diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 4fb575dd1e2..161a7d43eaf 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -2,9 +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::activation::Activatable; -use dom::attr::AttrValue; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use dom::bindings::codegen::Bindings::HTMLAnchorElementBinding; @@ -29,6 +27,7 @@ use num_traits::ToPrimitive; use script_traits::MozBrowserEvent; use std::default::Default; use string_cache::Atom; +use style::attr::AttrValue; use url::Url; use util::prefs::mozbrowser_enabled; diff --git a/components/script/dom/htmlappletelement.rs b/components/script/dom/htmlappletelement.rs index df46e89f06f..16d7e46b10e 100644 --- a/components/script/dom/htmlappletelement.rs +++ b/components/script/dom/htmlappletelement.rs @@ -2,7 +2,6 @@ * 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::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLAppletElementBinding; use dom::bindings::codegen::Bindings::HTMLAppletElementBinding::HTMLAppletElementMethods; use dom::bindings::inheritance::Castable; @@ -13,6 +12,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; +use style::attr::AttrValue; #[dom_struct] pub struct HTMLAppletElement { diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 4e8139374f0..7998333810e 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -2,7 +2,6 @@ * 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::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLAreaElementBinding; use dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods; use dom::bindings::inheritance::Castable; @@ -15,6 +14,7 @@ use dom::node::Node; use dom::virtualmethods::VirtualMethods; use std::default::Default; use string_cache::Atom; +use style::attr::AttrValue; #[dom_struct] pub struct HTMLAreaElement { diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs index 944b3675cba..e0c38b1ab41 100644 --- a/components/script/dom/htmlbaseelement.rs +++ b/components/script/dom/htmlbaseelement.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::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLBaseElementBinding; use dom::bindings::codegen::Bindings::HTMLBaseElementBinding::HTMLBaseElementMethods; use dom::bindings::inheritance::Castable; @@ -14,6 +14,7 @@ use dom::htmlelement::HTMLElement; use dom::node::{Node, UnbindContext, document_from_node}; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; +use style::attr::AttrValue; use url::Url; #[dom_struct] diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index b5408d877ac..79dbd1438e4 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use dom::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::codegen::Bindings::EventHandlerBinding::{EventHandlerNonNull, OnBeforeUnloadEventHandlerNonNull}; use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{self, HTMLBodyElementMethods}; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; @@ -18,6 +18,7 @@ use dom::node::{Node, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use script_traits::ScriptMsg as ConstellationMsg; use string_cache::Atom; +use style::attr::AttrValue; use time; use url::Url; diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 18dcb6d2e34..95073d49cd3 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -4,7 +4,6 @@ use canvas_traits::{CanvasMsg, FromLayoutMsg, CanvasData}; use dom::attr::Attr; -use dom::attr::AttrValue; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasRenderingContext2DMethods; use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding; @@ -33,6 +32,7 @@ use offscreen_gl_context::GLContextAttributes; use rustc_serialize::base64::{STANDARD, ToBase64}; use std::iter::repeat; use string_cache::Atom; +use style::attr::AttrValue; const DEFAULT_WIDTH: u32 = 300; const DEFAULT_HEIGHT: u32 = 150; diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 086eb6ff687..87bf5d92ff4 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -4,7 +4,6 @@ use dom::activation::{ActivationSource, synthetic_click_activation}; use dom::attr::Attr; -use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull; @@ -35,6 +34,7 @@ use std::borrow::ToOwned; use std::default::Default; use std::rc::Rc; use string_cache::Atom; +use style::attr::AttrValue; use style::element_state::*; #[dom_struct] diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index 74526b569bb..5968efc7948 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLFontElementBinding; use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods; use dom::bindings::inheritance::Castable; @@ -15,6 +14,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; +use style::attr::AttrValue; use style::values::specified; use util::str::{HTML_SPACE_CHARACTERS, read_numbers}; diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 66121a422bb..fcc10e3d134 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -2,7 +2,6 @@ * 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::attr::AttrValue; use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; @@ -50,6 +49,7 @@ use std::borrow::ToOwned; use std::cell::Cell; use std::sync::mpsc::Sender; use string_cache::Atom; +use style::attr::AttrValue; use task_source::TaskSource; use task_source::dom_manipulation::DOMManipulationTask; use url::form_urlencoded; diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index 1041319f907..a3127449fcc 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLHRElementBinding::{self, HTMLHRElementMethods}; use dom::bindings::inheritance::Castable; use dom::bindings::js::{LayoutJS, Root}; @@ -14,7 +13,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; -use style::attr::LengthOrPercentageOrAuto; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; #[dom_struct] pub struct HTMLHRElement { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index bc37f526f88..6d37513d01a 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use document_loader::{LoadType, LoadBlocker}; -use dom::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementErrorEventDetail; use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementIconChangeEventDetail; @@ -42,7 +42,7 @@ use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed}; use script_traits::{IFrameLoadInfo, MozBrowserEvent, ScriptMsg as ConstellationMsg}; use std::cell::Cell; use string_cache::Atom; -use style::attr::LengthOrPercentageOrAuto; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use style::context::ReflowGoal; use url::Url; use util::prefs::mozbrowser_enabled; diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 49f771824d3..06a5bf93abf 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -4,7 +4,6 @@ use app_units::Au; use dom::attr::Attr; -use dom::attr::AttrValue; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLImageElementBinding; use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods; @@ -31,7 +30,7 @@ use script_runtime::ScriptThreadEventCategory::UpdateReplacedElement; use script_thread::Runnable; use std::sync::Arc; use string_cache::Atom; -use style::attr::LengthOrPercentageOrAuto; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use url::Url; #[derive(JSTraceable, HeapSizeOf)] diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index a7bb9846bb9..4c164f2c819 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -4,7 +4,7 @@ use caseless::compatibility_caseless_match_str; use dom::activation::{Activatable, ActivationSource, synthetic_click_activation}; -use dom::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::FileListBinding::FileListMethods; @@ -39,6 +39,7 @@ use std::borrow::ToOwned; use std::cell::Cell; use std::ops::Range; use string_cache::Atom; +use style::attr::AttrValue; use style::element_state::*; use textinput::KeyReaction::{DispatchInput, Nothing, RedrawSelection, TriggerDefaultAction}; use textinput::Lines::Single; diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index e14dce36b88..6e808a14fc3 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::activation::{Activatable, ActivationSource, synthetic_click_activation}; -use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLLabelElementBinding; use dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods; use dom::bindings::inheritance::Castable; @@ -18,6 +17,7 @@ use dom::htmlformelement::{FormControl, HTMLFormElement}; use dom::node::{document_from_node, Node}; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; +use style::attr::AttrValue; #[dom_struct] pub struct HTMLLabelElement { diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index a69ec5b9aa5..2b0056a8d65 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -4,7 +4,7 @@ use cssparser::Parser as CssParser; use document_loader::LoadType; -use dom::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLLinkElementBinding; use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods; @@ -36,6 +36,7 @@ use std::default::Default; use std::mem; use std::sync::{Arc, Mutex}; use string_cache::Atom; +use style::attr::AttrValue; use style::media_queries::{MediaQueryList, parse_media_query_list}; use style::parser::ParserContextExtraData; use style::servo::Stylesheet; diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 13bf926cded..160b4a9c68e 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.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::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::HTMLMetaElementBinding; use dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods; @@ -19,6 +19,7 @@ use dom::virtualmethods::VirtualMethods; use std::ascii::AsciiExt; use std::sync::Arc; use string_cache::Atom; +use style::attr::AttrValue; use style::servo::Stylesheet; use style::stylesheets::{CSSRule, Origin}; use style::viewport::ViewportRule; diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index 8b04c9b00eb..26e1ad9b0c4 100644 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.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::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding; use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods; @@ -23,6 +23,7 @@ use dom::validation::Validatable; use dom::validitystate::ValidityState; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; +use style::attr::AttrValue; use style::element_state::*; #[dom_struct] diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index ae54b915342..eeeafd8f977 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::Castable; @@ -16,7 +15,7 @@ use dom::htmltablerowelement::HTMLTableRowElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; -use style::attr::LengthOrPercentageOrAuto; +use style::attr::{AttrValue, LengthOrPercentageOrAuto}; const DEFAULT_COLSPAN: u32 = 1; diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index a86381967b4..ec6e4b59efe 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use dom::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use dom::bindings::codegen::Bindings::HTMLTableElementBinding; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; @@ -24,7 +24,7 @@ use dom::node::{Node, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use std::cell::Cell; use string_cache::Atom; -use style::attr::{LengthOrPercentageOrAuto, parse_unsigned_integer}; +use style::attr::{AttrValue, LengthOrPercentageOrAuto, parse_unsigned_integer}; #[dom_struct] pub struct HTMLTableElement { diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index 06669b74c18..92c62115bd4 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use dom::bindings::codegen::Bindings::HTMLTableRowElementBinding::{self, HTMLTableRowElementMethods}; use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableSectionElementMethods; @@ -23,7 +22,7 @@ use dom::htmltablesectionelement::HTMLTableSectionElement; use dom::node::{Node, window_from_node}; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; - +use style::attr::AttrValue; #[derive(JSTraceable)] struct CellsFilter; diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index bc907c16324..7b047439743 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::RGBA; -use dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{self, HTMLTableSectionElementMethods}; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::error::{ErrorResult, Fallible}; @@ -18,6 +17,7 @@ use dom::htmltablerowelement::HTMLTableRowElement; use dom::node::{Node, window_from_node}; use dom::virtualmethods::VirtualMethods; use string_cache::Atom; +use style::attr::AttrValue; #[dom_struct] pub struct HTMLTableSectionElement { diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 19d108d95cc..69fe9046dad 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.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::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding; @@ -29,6 +29,7 @@ use script_traits::ScriptMsg as ConstellationMsg; use std::cell::Cell; use std::ops::Range; use string_cache::Atom; +use style::attr::AttrValue; use style::element_state::*; use textinput::{KeyReaction, Lines, TextInput, SelectionDirection}; diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 5983890e51a..3ad9713fb70 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -228,9 +228,9 @@ macro_rules! make_atomic_setter( macro_rules! make_legacy_color_setter( ( $attr:ident, $htmlname:tt ) => ( fn $attr(&self, value: DOMString) { - use dom::attr::AttrValue; use dom::bindings::inheritance::Castable; use dom::element::Element; + use style::attr::AttrValue; let element = self.upcast::(); let value = AttrValue::from_legacy_color(value.into()); element.set_attribute(&atom!($htmlname), value) diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index d8259307274..b42e8b676c3 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.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::attr::{Attr, AttrValue}; +use dom::attr::Attr; use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::ElementTypeId; use dom::bindings::inheritance::HTMLElementTypeId; @@ -47,7 +47,7 @@ use dom::htmltextareaelement::HTMLTextAreaElement; use dom::htmltitleelement::HTMLTitleElement; use dom::node::{ChildrenMutation, CloneChildrenFlag, Node, UnbindContext}; use string_cache::Atom; - +use style::attr::AttrValue; /// Trait to allow DOM nodes to opt-in to overriding (or adding to) common /// behaviours. Replicates the effect of C++ virtual methods. From 6a1722e18d926aa0a177e4b9a672a90bf4c541f5 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 7 Jun 2016 13:44:54 +0200 Subject: [PATCH 6/8] Make layout only depend on script::layout_interface. --- components/layout/construct.rs | 6 +++--- components/layout/fragment.rs | 2 +- components/layout/layout_thread.rs | 2 +- components/layout/opaque_node.rs | 4 ++-- components/layout/wrapper.rs | 17 ++++++----------- components/script/layout_interface.rs | 15 ++++++++++++++- 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 8d37b6aa6ba..3dfcfdf2689 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -34,9 +34,9 @@ use inline::{InlineFragmentNodeInfo, LAST_FRAGMENT_OF_ELEMENT}; use list_item::{ListItemFlow, ListStyleTypeContent}; use multicol::{MulticolFlow, MulticolColumnFlow}; use parallel; -use script::dom::bindings::inheritance::{CharacterDataTypeId, ElementTypeId}; -use script::dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId}; -use script::dom::htmlobjectelement::is_image_data; +use script::layout_interface::is_image_data; +use script::layout_interface::{CharacterDataTypeId, ElementTypeId}; +use script::layout_interface::{HTMLElementTypeId, NodeTypeId}; use std::borrow::ToOwned; use std::collections::LinkedList; use std::marker::PhantomData; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 705868a5afe..640b7acce1a 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -30,7 +30,7 @@ use net_traits::image::base::{Image, ImageMetadata}; use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder}; use range::*; use rustc_serialize::{Encodable, Encoder}; -use script::dom::htmlcanvaselement::HTMLCanvasData; +use script::layout_interface::HTMLCanvasData; use std::borrow::ToOwned; use std::cmp::{max, min}; use std::collections::LinkedList; diff --git a/components/layout/layout_thread.rs b/components/layout/layout_thread.rs index b48813a0c31..da6fe4908db 100644 --- a/components/layout/layout_thread.rs +++ b/components/layout/layout_thread.rs @@ -47,7 +47,7 @@ use query::process_offset_parent_query; use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request}; use query::{process_node_geometry_request, process_node_layer_id_request, process_node_scroll_area_request}; use query::{process_node_overflow_request, process_resolved_style_request, process_margin_style_query}; -use script::dom::node::OpaqueStyleAndLayoutData; +use script::layout_interface::OpaqueStyleAndLayoutData; use script::layout_interface::{LayoutRPC, OffsetParentResponse, NodeOverflowResponse, MarginStyleResponse}; use script::layout_interface::{Msg, NewLayoutThreadInfo, Reflow, ReflowQueryType, ScriptReflow}; use script::reporter::CSSErrorReporter; diff --git a/components/layout/opaque_node.rs b/components/layout/opaque_node.rs index 023b9cb34c0..a05a49d48e6 100644 --- a/components/layout/opaque_node.rs +++ b/components/layout/opaque_node.rs @@ -6,8 +6,8 @@ use gfx::display_list::OpaqueNode; use libc::{c_void, uintptr_t}; -use script::dom::bindings::js::LayoutJS; -use script::dom::node::Node; +use script::layout_interface::LayoutJS; +use script::layout_interface::Node; use script::layout_interface::TrustedNodeAddress; use script_traits::UntrustedNodeAddress; diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 7c60ed4625b..b6c5266c2cb 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -39,17 +39,12 @@ use incremental::RestyleDamage; use msg::constellation_msg::PipelineId; use opaque_node::OpaqueNodeMethods; use range::Range; -use script::dom::bindings::inheritance::{CharacterDataTypeId, ElementTypeId}; -use script::dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId}; -use script::dom::bindings::js::LayoutJS; -use script::dom::characterdata::LayoutCharacterDataHelpers; -use script::dom::document::{Document, LayoutDocumentHelpers}; -use script::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; -use script::dom::htmlcanvaselement::HTMLCanvasData; -use script::dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; -use script::dom::node::{LayoutNodeHelpers, Node, OpaqueStyleAndLayoutData}; -use script::dom::text::Text; -use script::layout_interface::TrustedNodeAddress; +use script::layout_interface::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; +use script::layout_interface::{CharacterDataTypeId, Document, Element, ElementTypeId}; +use script::layout_interface::{HTMLCanvasData, HTMLElementTypeId, LayoutCharacterDataHelpers}; +use script::layout_interface::{LayoutDocumentHelpers, LayoutElementHelpers, LayoutJS}; +use script::layout_interface::{LayoutNodeHelpers, Node, NodeTypeId, OpaqueStyleAndLayoutData}; +use script::layout_interface::{RawLayoutElementHelpers, Text, TrustedNodeAddress}; use selectors::matching::{DeclarationBlock, ElementFlags}; use selectors::parser::{AttrSelector, NamespaceConstraint}; use smallvec::VecLike; diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index 61c99bc530b..37b6d169481 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -7,7 +7,6 @@ //! the DOM to be placed in a separate crate from layout. use app_units::Au; -use dom::node::OpaqueStyleAndLayoutData; use euclid::point::Point2D; use euclid::rect::Rect; use gfx_traits::{Epoch, LayerId}; @@ -27,7 +26,21 @@ use style::servo::Stylesheet; use url::Url; use util::ipc::OptionalOpaqueIpcSender; +pub use dom::bindings::inheritance::{CharacterDataTypeId, ElementTypeId}; +pub use dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId}; +pub use dom::bindings::js::LayoutJS; +pub use dom::characterdata::LayoutCharacterDataHelpers; +pub use dom::document::{Document, LayoutDocumentHelpers}; +pub use dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; +pub use dom::htmlcanvaselement::HTMLCanvasData; +pub use dom::htmlobjectelement::is_image_data; +pub use dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY}; +pub use dom::node::LayoutNodeHelpers; +pub use dom::node::Node; +pub use dom::node::OpaqueStyleAndLayoutData; pub use dom::node::TrustedNodeAddress; +pub use dom::text::Text; + /// Asynchronous messages that script can send to layout. pub enum Msg { From 80fc66673473910ec325eb35d1e2e040f9e5277a Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 7 Jun 2016 14:01:26 +0200 Subject: [PATCH 7/8] Move trim_http_whitespace to net_traits. --- components/net_traits/lib.rs | 24 ++++++++++++++++++++++ components/script/dom/xmlhttprequest.rs | 25 +---------------------- tests/unit/net_traits/lib.rs | 22 ++++++++++++++++++++ tests/unit/script/dom/xmlhttprequest.rs | 27 ------------------------- tests/unit/script/lib.rs | 1 - 5 files changed, 47 insertions(+), 52 deletions(-) delete mode 100644 tests/unit/script/dom/xmlhttprequest.rs diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 4eab3e725e9..be6cbf4ee95 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -573,3 +573,27 @@ pub enum NetworkError { /// SSL validation error that has to be handled in the HTML parser SslValidation(Url), } + +/// Normalize `slice`, as defined by +/// [the Fetch Spec](https://fetch.spec.whatwg.org/#concept-header-value-normalize). +pub fn trim_http_whitespace(mut slice: &[u8]) -> &[u8] { + const HTTP_WS_BYTES: &'static [u8] = b"\x09\x0A\x0D\x20"; + + loop { + match slice.split_first() { + Some((first, remainder)) if HTTP_WS_BYTES.contains(first) => + slice = remainder, + _ => break, + } + } + + loop { + match slice.split_last() { + Some((last, remainder)) if HTTP_WS_BYTES.contains(last) => + slice = remainder, + _ => break, + } + } + + slice +} diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 18131bd5fd8..318d3bbc1ec 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -46,6 +46,7 @@ use js::jsapi::{JSContext, JS_ParseJSON, RootedValue}; use js::jsval::{JSVal, NullValue, UndefinedValue}; use msg::constellation_msg::{PipelineId, ReferrerPolicy}; use net_traits::CoreResourceMsg::Load; +use net_traits::trim_http_whitespace; use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata, NetworkError, RequestSource}; use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, CoreResourceThread, LoadOrigin}; use network_listener::{NetworkListener, PreInvoke}; @@ -1506,27 +1507,3 @@ pub fn is_field_value(slice: &[u8]) -> bool { } }) } - -/// Normalize `self`, as defined by -/// [the Fetch Spec](https://fetch.spec.whatwg.org/#concept-header-value-normalize). -pub fn trim_http_whitespace(mut slice: &[u8]) -> &[u8] { - const HTTP_WS_BYTES: &'static [u8] = b"\x09\x0A\x0D\x20"; - - loop { - match slice.split_first() { - Some((first, remainder)) if HTTP_WS_BYTES.contains(first) => - slice = remainder, - _ => break, - } - } - - loop { - match slice.split_last() { - Some((last, remainder)) if HTTP_WS_BYTES.contains(last) => - slice = remainder, - _ => break, - } - } - - slice -} diff --git a/tests/unit/net_traits/lib.rs b/tests/unit/net_traits/lib.rs index 89bded99c22..0ea8e4cfe78 100644 --- a/tests/unit/net_traits/lib.rs +++ b/tests/unit/net_traits/lib.rs @@ -5,3 +5,25 @@ extern crate net_traits; #[cfg(test)] mod image; + +#[test] +fn test_trim_http_whitespace() { + fn test_trim(in_: &[u8], out: &[u8]) { + let b = net_traits::trim_http_whitespace(in_); + assert_eq!(b, out); + } + + test_trim(b"", b""); + + test_trim(b" ", b""); + test_trim(b"a", b"a"); + test_trim(b" a", b"a"); + test_trim(b"a ", b"a"); + test_trim(b" a ", b"a"); + + test_trim(b"\t", b""); + test_trim(b"a", b"a"); + test_trim(b"\ta", b"a"); + test_trim(b"a\t", b"a"); + test_trim(b"\ta\t", b"a"); +} diff --git a/tests/unit/script/dom/xmlhttprequest.rs b/tests/unit/script/dom/xmlhttprequest.rs deleted file mode 100644 index f9d4ebc25e8..00000000000 --- a/tests/unit/script/dom/xmlhttprequest.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use script::dom::xmlhttprequest::trim_http_whitespace; - -#[test] -fn test_trim_http_whitespace() { - fn test_trim(in_: &[u8], out: &[u8]) { - let b = trim_http_whitespace(in_); - assert_eq!(b, out); - } - - test_trim(b"", b""); - - test_trim(b" ", b""); - test_trim(b"a", b"a"); - test_trim(b" a", b"a"); - test_trim(b"a ", b"a"); - test_trim(b" a ", b"a"); - - test_trim(b"\t", b""); - test_trim(b"a", b"a"); - test_trim(b"\ta", b"a"); - test_trim(b"a\t", b"a"); - test_trim(b"\ta\t", b"a"); -} diff --git a/tests/unit/script/lib.rs b/tests/unit/script/lib.rs index cab595e0500..c2829292bb9 100644 --- a/tests/unit/script/lib.rs +++ b/tests/unit/script/lib.rs @@ -15,5 +15,4 @@ extern crate url; #[cfg(test)] mod dom { mod bindings; mod blob; - mod xmlhttprequest; } From aea03b2f921a41bf78791a877539f1fafab887dd Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 7 Jun 2016 14:20:44 +0200 Subject: [PATCH 8/8] Remove unused ByteString::bytes() and its unit test. --- components/script/dom/bindings/str.rs | 7 ------- tests/unit/script/dom/bindings.rs | 17 ----------------- tests/unit/script/lib.rs | 1 - 3 files changed, 25 deletions(-) delete mode 100644 tests/unit/script/dom/bindings.rs diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index 3ee685fbe02..69565520899 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -8,7 +8,6 @@ use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::fmt; use std::hash::{Hash, Hasher}; -use std::mem; use std::ops; use std::ops::{Deref, DerefMut}; use std::str; @@ -31,12 +30,6 @@ impl ByteString { str::from_utf8(&self.0).ok() } - /// Returns ownership of the underlying Vec and copies an empty - /// vec in its place - pub fn bytes(&mut self) -> Vec { - mem::replace(&mut self.0, Vec::new()) - } - /// Returns the length. pub fn len(&self) -> usize { self.0.len() diff --git a/tests/unit/script/dom/bindings.rs b/tests/unit/script/dom/bindings.rs deleted file mode 100644 index 7dfb308e1ed..00000000000 --- a/tests/unit/script/dom/bindings.rs +++ /dev/null @@ -1,17 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use script::dom::bindings::str::ByteString; - -#[test] -fn test_byte_string_move() { - let mut byte_str = ByteString::new(vec![0x73, 0x65, 0x72, 0x76, 0x6f]); - let mut byte_vec = byte_str.bytes(); - - assert_eq!(byte_vec, "servo".as_bytes()); - assert_eq!(&*byte_str, &*Vec::::new()); - - byte_vec = byte_str.into(); - assert_eq!(byte_vec, Vec::::new()); -} diff --git a/tests/unit/script/lib.rs b/tests/unit/script/lib.rs index c2829292bb9..8446ddc2330 100644 --- a/tests/unit/script/lib.rs +++ b/tests/unit/script/lib.rs @@ -13,6 +13,5 @@ extern crate url; #[cfg(all(test, target_pointer_width = "64"))] mod size_of; #[cfg(test)] mod textinput; #[cfg(test)] mod dom { - mod bindings; mod blob; }