зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #7401 - Remove helper traits (from nox:rm-helpers); r=Manishearth
Now that `JSRef<T>` is gone, there is no need to have helper traits. Source-Repo: https://github.com/servo/servo Source-Revision: 909429702972d53bf02dfe9a4aa93ea0cb588cf4
This commit is contained in:
Родитель
d39bd47b08
Коммит
d2ee701ee9
|
@ -13,9 +13,7 @@ use dom::bindings::conversions::FromJSValConvertible;
|
|||
use dom::bindings::conversions::jsstring_to_str;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::DocumentHelpers;
|
||||
use dom::node::{Node, NodeHelpers};
|
||||
use dom::window::{WindowHelpers, ScriptHelpers};
|
||||
use dom::node::Node;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsapi::{ObjectClassName, RootedObject, RootedValue};
|
||||
use js::jsval::UndefinedValue;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{EventCast, EventTargetCast};
|
||||
use dom::element::{Element, ActivationElementHelpers};
|
||||
use dom::event::{Event, EventHelpers, EventBubbles, EventCancelable};
|
||||
use dom::element::Element;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::mouseevent::MouseEvent;
|
||||
use dom::node::window_from_node;
|
||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::{JS, MutNullableHeap};
|
||||
use dom::bindings::js::{Root, RootedReference, LayoutJS};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::element::Element;
|
||||
use dom::virtualmethods::vtable_for;
|
||||
use dom::window::Window;
|
||||
|
||||
|
@ -234,17 +234,9 @@ impl<'a> AttrMethods for &'a Attr {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait AttrHelpers<'a> {
|
||||
fn set_value(self, set_type: AttrSettingType, value: AttrValue, owner: &Element);
|
||||
fn value(self) -> Ref<'a, AttrValue>;
|
||||
fn local_name(self) -> &'a Atom;
|
||||
fn set_owner(self, owner: Option<&Element>);
|
||||
fn owner(self) -> Option<Root<Element>>;
|
||||
fn summarize(self) -> AttrInfo;
|
||||
}
|
||||
|
||||
impl<'a> AttrHelpers<'a> for &'a Attr {
|
||||
fn set_value(self, set_type: AttrSettingType, value: AttrValue, owner: &Element) {
|
||||
impl Attr {
|
||||
pub fn set_value(&self, set_type: AttrSettingType, value: AttrValue, owner: &Element) {
|
||||
assert!(Some(owner) == self.owner().r());
|
||||
|
||||
let node = NodeCast::from_ref(owner);
|
||||
|
@ -263,17 +255,17 @@ impl<'a> AttrHelpers<'a> for &'a Attr {
|
|||
}
|
||||
}
|
||||
|
||||
fn value(self) -> Ref<'a, AttrValue> {
|
||||
pub fn value(&self) -> Ref<AttrValue> {
|
||||
self.value.borrow()
|
||||
}
|
||||
|
||||
fn local_name(self) -> &'a Atom {
|
||||
pub fn local_name(&self) -> &Atom {
|
||||
&self.local_name
|
||||
}
|
||||
|
||||
/// Sets the owner element. Should be called after the attribute is added
|
||||
/// or removed from its older parent.
|
||||
fn set_owner(self, owner: Option<&Element>) {
|
||||
pub fn set_owner(&self, owner: Option<&Element>) {
|
||||
let ref ns = self.namespace;
|
||||
match (self.owner().r(), owner) {
|
||||
(None, Some(new)) => {
|
||||
|
@ -289,11 +281,11 @@ impl<'a> AttrHelpers<'a> for &'a Attr {
|
|||
self.owner.set(owner.map(JS::from_ref))
|
||||
}
|
||||
|
||||
fn owner(self) -> Option<Root<Element>> {
|
||||
pub fn owner(&self) -> Option<Root<Element>> {
|
||||
self.owner.get().map(Root::from_rooted)
|
||||
}
|
||||
|
||||
fn summarize(self) -> AttrInfo {
|
||||
pub fn summarize(&self) -> AttrInfo {
|
||||
let Namespace(ref ns) = self.namespace;
|
||||
AttrInfo {
|
||||
namespace: (**ns).to_owned(),
|
||||
|
|
|
@ -12,9 +12,8 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|||
use dom::bindings::conversions::native_from_reflector_jsmanaged;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::document::DocumentHelpers;
|
||||
use dom::window::{self, WindowHelpers, ScriptHelpers};
|
||||
use dom::workerglobalscope::{WorkerGlobalScope, WorkerGlobalScopeHelpers};
|
||||
use dom::window::{self, ScriptHelpers};
|
||||
use dom::workerglobalscope::WorkerGlobalScope;
|
||||
use script_task::{ScriptChan, ScriptPort, CommonScriptMsg, ScriptTask};
|
||||
|
||||
use msg::constellation_msg::{ConstellationChan, PipelineId, WorkerId};
|
||||
|
|
|
@ -79,12 +79,9 @@ impl Blob {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait BlobHelpers {
|
||||
fn read_out_buffer(self, send: Sender<Vec<u8>>);
|
||||
}
|
||||
|
||||
impl<'a> BlobHelpers for &'a Blob {
|
||||
fn read_out_buffer(self, send: Sender<Vec<u8>>) {
|
||||
impl Blob {
|
||||
pub fn read_out_buffer(&self, send: Sender<Vec<u8>>) {
|
||||
send.send(self.bytes.clone().unwrap_or(vec![])).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,9 @@ use dom::bindings::js::{JS, Root};
|
|||
use dom::bindings::proxyhandler::{get_property_descriptor, fill_property_descriptor};
|
||||
use dom::bindings::utils::get_array_index_from_id;
|
||||
use dom::bindings::utils::{Reflectable, WindowProxyHandler};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::element::Element;
|
||||
use dom::window::Window;
|
||||
use dom::window::WindowHelpers;
|
||||
|
||||
use js::glue::{GetProxyPrivate};
|
||||
use js::glue::{WrapperNew, CreateWrapperProxyHandler, ProxyTraps};
|
||||
|
|
|
@ -17,11 +17,11 @@ use dom::bindings::num::Finite;
|
|||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
|
||||
use dom::canvaspattern::CanvasPattern;
|
||||
use dom::htmlcanvaselement::HTMLCanvasElement;
|
||||
use dom::htmlcanvaselement::utils as canvas_utils;
|
||||
use dom::htmlcanvaselement::{HTMLCanvasElement, HTMLCanvasElementHelpers};
|
||||
use dom::htmlimageelement::{HTMLImageElement, HTMLImageElementHelpers};
|
||||
use dom::imagedata::{ImageData, ImageDataHelpers};
|
||||
use dom::node::{window_from_node, NodeHelpers, NodeDamage};
|
||||
use dom::htmlimageelement::HTMLImageElement;
|
||||
use dom::imagedata::ImageData;
|
||||
use dom::node::{window_from_node, NodeDamage};
|
||||
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use net_traits::image::base::PixelFormat;
|
||||
|
@ -409,16 +409,12 @@ impl CanvasRenderingContext2D {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait CanvasRenderingContext2DHelpers {
|
||||
fn get_renderer_id(self) -> usize;
|
||||
fn get_ipc_renderer(self) -> IpcSender<CanvasMsg>;
|
||||
}
|
||||
|
||||
impl<'a> CanvasRenderingContext2DHelpers for &'a CanvasRenderingContext2D {
|
||||
fn get_renderer_id(self) -> usize {
|
||||
impl CanvasRenderingContext2D {
|
||||
pub fn get_renderer_id(&self) -> usize {
|
||||
self.renderer_id
|
||||
}
|
||||
fn get_ipc_renderer(self) -> IpcSender<CanvasMsg> {
|
||||
pub fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> {
|
||||
self.ipc_renderer.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom::bindings::js::{LayoutJS, Root};
|
|||
use dom::document::Document;
|
||||
use dom::element::Element;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
|
||||
use util::str::{DOMString, slice_chars};
|
||||
|
||||
|
@ -157,18 +157,14 @@ pub enum CharacterDataTypeId {
|
|||
ProcessingInstruction,
|
||||
}
|
||||
|
||||
pub trait CharacterDataHelpers<'a> {
|
||||
fn data(self) -> Ref<'a, DOMString>;
|
||||
fn append_data(self, data: &str);
|
||||
}
|
||||
|
||||
impl<'a> CharacterDataHelpers<'a> for &'a CharacterData {
|
||||
impl CharacterData {
|
||||
#[inline]
|
||||
fn data(self) -> Ref<'a, DOMString> {
|
||||
pub fn data(&self) -> Ref<DOMString> {
|
||||
self.data.borrow()
|
||||
}
|
||||
#[inline]
|
||||
fn append_data(self, data: &str) {
|
||||
pub fn append_data(&self, data: &str) {
|
||||
self.data.borrow_mut().push_str(data)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ use dom::bindings::codegen::Bindings::ConsoleBinding::ConsoleMethods;
|
|||
use dom::bindings::global::{GlobalRef, GlobalField};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::window::WindowHelpers;
|
||||
use util::str::DOMString;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Console
|
||||
|
|
|
@ -8,10 +8,9 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::document::DocumentHelpers;
|
||||
use dom::element::{ElementHelpers, StylePriority, Element};
|
||||
use dom::node::{window_from_node, document_from_node, NodeDamage, NodeHelpers};
|
||||
use dom::window::{Window, WindowHelpers};
|
||||
use dom::element::{StylePriority, Element};
|
||||
use dom::node::{window_from_node, document_from_node, NodeDamage};
|
||||
use dom::window::Window;
|
||||
use selectors::parser::PseudoElement;
|
||||
use string_cache::Atom;
|
||||
use style::properties::PropertyDeclaration;
|
||||
|
|
|
@ -6,7 +6,6 @@ use devtools;
|
|||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
|
||||
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods;
|
||||
use dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods;
|
||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
use dom::bindings::codegen::InheritTypes::DedicatedWorkerGlobalScopeDerived;
|
||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, WorkerGlobalScopeCast};
|
||||
|
@ -16,11 +15,10 @@ use dom::bindings::js::{RootCollection, Root};
|
|||
use dom::bindings::refcounted::LiveDOMReferences;
|
||||
use dom::bindings::structuredclone::StructuredCloneData;
|
||||
use dom::bindings::utils::Reflectable;
|
||||
use dom::errorevent::ErrorEvent;
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::messageevent::MessageEvent;
|
||||
use dom::worker::{TrustedWorkerAddress, WorkerMessageHandler, WorkerEventHandler, WorkerErrorHandler};
|
||||
use dom::workerglobalscope::{WorkerGlobalScope, WorkerGlobalScopeHelpers};
|
||||
use dom::worker::{TrustedWorkerAddress, WorkerMessageHandler, WorkerEventHandler};
|
||||
use dom::workerglobalscope::WorkerGlobalScope;
|
||||
use dom::workerglobalscope::{WorkerGlobalScopeTypeId, WorkerGlobalScopeInit};
|
||||
use script_task::{ScriptTask, ScriptChan, TimerSource, ScriptPort, StackRootTLS, CommonScriptMsg};
|
||||
|
||||
|
@ -245,26 +243,20 @@ impl DedicatedWorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait DedicatedWorkerGlobalScopeHelpers {
|
||||
fn script_chan(self) -> Box<ScriptChan + Send>;
|
||||
fn pipeline(self) -> PipelineId;
|
||||
fn new_script_pair(self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>);
|
||||
fn process_event(self, msg: CommonScriptMsg);
|
||||
}
|
||||
|
||||
impl<'a> DedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalScope {
|
||||
fn script_chan(self) -> Box<ScriptChan + Send> {
|
||||
impl DedicatedWorkerGlobalScope {
|
||||
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
|
||||
box WorkerThreadWorkerChan {
|
||||
sender: self.own_sender.clone(),
|
||||
worker: self.worker.borrow().as_ref().unwrap().clone(),
|
||||
}
|
||||
}
|
||||
|
||||
fn pipeline(self) -> PipelineId {
|
||||
pub fn pipeline(&self) -> PipelineId {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn new_script_pair(self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
|
||||
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
|
||||
let (tx, rx) = channel();
|
||||
let chan = box SendableWorkerScriptChan {
|
||||
sender: tx,
|
||||
|
@ -273,21 +265,15 @@ impl<'a> DedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalScope {
|
|||
(chan, box rx)
|
||||
}
|
||||
|
||||
fn process_event(self, msg: CommonScriptMsg) {
|
||||
pub fn process_event(&self, msg: CommonScriptMsg) {
|
||||
self.handle_script_event(WorkerScriptMsg::Common(msg));
|
||||
}
|
||||
}
|
||||
|
||||
trait PrivateDedicatedWorkerGlobalScopeHelpers {
|
||||
fn handle_script_event(self, msg: WorkerScriptMsg);
|
||||
fn dispatch_error_to_worker(self, &ErrorEvent);
|
||||
fn receive_event(self) -> Result<MixedMessage, RecvError>;
|
||||
fn handle_event(self, event: MixedMessage);
|
||||
}
|
||||
|
||||
impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalScope {
|
||||
impl DedicatedWorkerGlobalScope {
|
||||
#[allow(unsafe_code)]
|
||||
fn receive_event(self) -> Result<MixedMessage, RecvError> {
|
||||
fn receive_event(&self) -> Result<MixedMessage, RecvError> {
|
||||
let scope = WorkerGlobalScopeCast::from_ref(self);
|
||||
let worker_port = &self.receiver;
|
||||
let devtools_port = scope.from_devtools_receiver();
|
||||
|
@ -311,7 +297,7 @@ impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalS
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_script_event(self, msg: WorkerScriptMsg) {
|
||||
fn handle_script_event(&self, msg: WorkerScriptMsg) {
|
||||
match msg {
|
||||
WorkerScriptMsg::DOMMessage(data) => {
|
||||
let scope = WorkerGlobalScopeCast::from_ref(self);
|
||||
|
@ -346,7 +332,7 @@ impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalS
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_event(self, event: MixedMessage) {
|
||||
fn handle_event(&self, event: MixedMessage) {
|
||||
match event {
|
||||
MixedMessage::FromDevtools(msg) => {
|
||||
let global_ref = GlobalRef::Worker(WorkerGlobalScopeCast::from_ref(self));
|
||||
|
@ -366,16 +352,6 @@ impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalS
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn dispatch_error_to_worker(self, errorevent: &ErrorEvent) {
|
||||
let msg = errorevent.Message();
|
||||
let file_name = errorevent.Filename();
|
||||
let line_num = errorevent.Lineno();
|
||||
let col_num = errorevent.Colno();
|
||||
let worker = self.worker.borrow().as_ref().unwrap().clone();
|
||||
self.parent_sender.send(CommonScriptMsg::RunnableMsg(
|
||||
box WorkerErrorHandler::new(worker, msg, file_name, line_num, col_num))).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DedicatedWorkerGlobalScopeMethods for &'a DedicatedWorkerGlobalScope {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use document_loader::{DocumentLoader, LoadType};
|
||||
use dom::attr::{Attr, AttrHelpers, AttrValue};
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::DocumentBinding;
|
||||
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
|
||||
|
@ -41,10 +41,9 @@ use dom::customevent::CustomEvent;
|
|||
use dom::documentfragment::DocumentFragment;
|
||||
use dom::documenttype::DocumentType;
|
||||
use dom::domimplementation::DOMImplementation;
|
||||
use dom::element::{Element, ElementCreator, ElementHelpers, AttributeHandlers};
|
||||
use dom::element::{ElementTypeId, ActivationElementHelpers, FocusElementHelpers};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable, EventHelpers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId, EventTargetHelpers};
|
||||
use dom::element::{Element, ElementCreator, ElementTypeId};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlanchorelement::HTMLAnchorElement;
|
||||
use dom::htmlbaseelement::HTMLBaseElement;
|
||||
use dom::htmlcollection::{HTMLCollection, CollectionFilter};
|
||||
|
@ -57,7 +56,7 @@ use dom::keyboardevent::KeyboardEvent;
|
|||
use dom::location::Location;
|
||||
use dom::messageevent::MessageEvent;
|
||||
use dom::mouseevent::MouseEvent;
|
||||
use dom::node::{self, Node, NodeHelpers, NodeTypeId, CloneChildrenFlag, NodeDamage, window_from_node};
|
||||
use dom::node::{self, Node, NodeTypeId, CloneChildrenFlag, NodeDamage, window_from_node};
|
||||
use dom::nodeiterator::NodeIterator;
|
||||
use dom::nodelist::NodeList;
|
||||
use dom::processinginstruction::ProcessingInstruction;
|
||||
|
@ -66,7 +65,7 @@ use dom::servohtmlparser::ServoHTMLParser;
|
|||
use dom::text::Text;
|
||||
use dom::treewalker::TreeWalker;
|
||||
use dom::uievent::UIEvent;
|
||||
use dom::window::{Window, WindowHelpers, ReflowReason};
|
||||
use dom::window::{Window, ReflowReason};
|
||||
|
||||
use layout_interface::{HitTestResponse, MouseOverResponse};
|
||||
use layout_interface::{ReflowGoal, ReflowQueryType};
|
||||
|
@ -228,113 +227,35 @@ impl CollectionFilter for AppletsFilter {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait DocumentHelpers<'a> {
|
||||
fn loader(&self) -> Ref<DocumentLoader>;
|
||||
fn mut_loader(&self) -> RefMut<DocumentLoader>;
|
||||
fn window(self) -> Root<Window>;
|
||||
fn encoding_name(self) -> Ref<'a, DOMString>;
|
||||
fn is_html_document(self) -> bool;
|
||||
fn is_fully_active(self) -> bool;
|
||||
/// https://dom.spec.whatwg.org/#concept-document-url
|
||||
fn url(self) -> Url;
|
||||
/// https://html.spec.whatwg.org/multipage/#fallback-base-url
|
||||
fn fallback_base_url(self) -> Url;
|
||||
/// https://html.spec.whatwg.org/multipage/#document-base-url
|
||||
fn base_url(self) -> Url;
|
||||
/// Returns the first `base` element in the DOM that has an `href` attribute.
|
||||
fn base_element(self) -> Option<Root<HTMLBaseElement>>;
|
||||
/// Refresh the cached first base element in the DOM.
|
||||
fn refresh_base_element(self);
|
||||
fn quirks_mode(self) -> QuirksMode;
|
||||
fn set_quirks_mode(self, mode: QuirksMode);
|
||||
fn set_encoding_name(self, name: DOMString);
|
||||
fn content_changed(self, node: &Node, damage: NodeDamage);
|
||||
fn content_and_heritage_changed(self, node: &Node, damage: NodeDamage);
|
||||
fn reflow_if_reflow_timer_expired(self);
|
||||
fn set_reflow_timeout(self, timeout: u64);
|
||||
fn disarm_reflow_timeout(self);
|
||||
fn unregister_named_element(self, to_unregister: &Element, id: Atom);
|
||||
fn register_named_element(self, element: &Element, id: Atom);
|
||||
fn find_fragment_node(self, fragid: &str) -> Option<Root<Element>>;
|
||||
fn hit_test(self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress>;
|
||||
fn get_nodes_under_mouse(self, point: &Point2D<f32>) -> Vec<UntrustedNodeAddress>;
|
||||
fn set_ready_state(self, state: DocumentReadyState);
|
||||
fn get_focused_element(self) -> Option<Root<Element>>;
|
||||
fn is_scripting_enabled(self) -> bool;
|
||||
fn begin_focus_transaction(self);
|
||||
fn request_focus(self, elem: &Element);
|
||||
fn commit_focus_transaction(self, focus_type: FocusType);
|
||||
fn title_changed(self);
|
||||
fn send_title_to_compositor(self);
|
||||
fn dirty_all_nodes(self);
|
||||
fn dispatch_key_event(self,
|
||||
key: Key,
|
||||
state: KeyState,
|
||||
modifiers: KeyModifiers,
|
||||
compositor: &mut IpcSender<ScriptToCompositorMsg>);
|
||||
fn node_from_nodes_and_strings(self, nodes: Vec<NodeOrString>)
|
||||
-> Fallible<Root<Node>>;
|
||||
fn get_body_attribute(self, local_name: &Atom) -> DOMString;
|
||||
fn set_body_attribute(self, local_name: &Atom, value: DOMString);
|
||||
|
||||
fn fire_mouse_event(self, point: Point2D<f32>,
|
||||
target: &EventTarget,
|
||||
event_name: String);
|
||||
fn handle_mouse_event(self, js_runtime: *mut JSRuntime,
|
||||
button: MouseButton, point: Point2D<f32>,
|
||||
mouse_event_type: MouseEventType);
|
||||
/// Handles a mouse-move event coming from the compositor.
|
||||
fn handle_mouse_move_event(self,
|
||||
js_runtime: *mut JSRuntime,
|
||||
point: Point2D<f32>,
|
||||
prev_mouse_over_targets: &mut RootedVec<JS<Node>>);
|
||||
|
||||
fn set_current_script(self, script: Option<&HTMLScriptElement>);
|
||||
fn trigger_mozbrowser_event(self, event: MozBrowserEvent);
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
||||
fn request_animation_frame(self, callback: Box<FnBox(f64, )>) -> i32;
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
||||
fn cancel_animation_frame(self, ident: i32);
|
||||
/// https://html.spec.whatwg.org/multipage/#run-the-animation-frame-callbacks
|
||||
fn run_the_animation_frame_callbacks(self);
|
||||
fn prepare_async_load(self, load: LoadType) -> PendingAsyncLoad;
|
||||
fn load_async(self, load: LoadType, listener: AsyncResponseTarget);
|
||||
fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec<u8>), String>;
|
||||
fn finish_load(self, load: LoadType);
|
||||
fn notify_constellation_load(self);
|
||||
fn set_current_parser(self, script: Option<&ServoHTMLParser>);
|
||||
fn get_current_parser(self) -> Option<Root<ServoHTMLParser>>;
|
||||
fn find_iframe(self, subpage_id: SubpageId) -> Option<Root<HTMLIFrameElement>>;
|
||||
}
|
||||
|
||||
impl<'a> DocumentHelpers<'a> for &'a Document {
|
||||
impl Document {
|
||||
#[inline]
|
||||
fn loader(&self) -> Ref<DocumentLoader> {
|
||||
pub fn loader(&self) -> Ref<DocumentLoader> {
|
||||
self.loader.borrow()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mut_loader(&self) -> RefMut<DocumentLoader> {
|
||||
pub fn mut_loader(&self) -> RefMut<DocumentLoader> {
|
||||
self.loader.borrow_mut()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn window(self) -> Root<Window> {
|
||||
pub fn window(&self) -> Root<Window> {
|
||||
self.window.root()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn encoding_name(self) -> Ref<'a, DOMString> {
|
||||
pub fn encoding_name(&self) -> Ref<DOMString> {
|
||||
self.encoding_name.borrow()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_html_document(self) -> bool {
|
||||
pub fn is_html_document(&self) -> bool {
|
||||
self.is_html_document
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#fully-active
|
||||
fn is_fully_active(self) -> bool {
|
||||
pub fn is_fully_active(&self) -> bool {
|
||||
let window = self.window.root();
|
||||
let window = window.r();
|
||||
let browsing_context = window.browsing_context();
|
||||
|
@ -349,12 +270,12 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-document-url
|
||||
fn url(self) -> Url {
|
||||
pub fn url(&self) -> Url {
|
||||
self.url.clone()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#fallback-base-url
|
||||
fn fallback_base_url(self) -> Url {
|
||||
pub fn fallback_base_url(&self) -> Url {
|
||||
// Step 1: iframe srcdoc (#4767).
|
||||
// Step 2: about:blank with a creator browsing context.
|
||||
// Step 3.
|
||||
|
@ -362,7 +283,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#document-base-url
|
||||
fn base_url(self) -> Url {
|
||||
pub fn base_url(&self) -> Url {
|
||||
match self.base_element() {
|
||||
// Step 1.
|
||||
None => self.fallback_base_url(),
|
||||
|
@ -372,12 +293,12 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// Returns the first `base` element in the DOM that has an `href` attribute.
|
||||
fn base_element(self) -> Option<Root<HTMLBaseElement>> {
|
||||
pub fn base_element(&self) -> Option<Root<HTMLBaseElement>> {
|
||||
self.base_element.get().map(Root::from_rooted)
|
||||
}
|
||||
|
||||
/// Refresh the cached first base element in the DOM.
|
||||
fn refresh_base_element(self) {
|
||||
pub fn refresh_base_element(&self) {
|
||||
let base = NodeCast::from_ref(self)
|
||||
.traverse_preorder()
|
||||
.filter_map(HTMLBaseElementCast::to_root)
|
||||
|
@ -386,11 +307,11 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
self.base_element.set(base.map(|element| JS::from_ref(&*element)));
|
||||
}
|
||||
|
||||
fn quirks_mode(self) -> QuirksMode {
|
||||
pub fn quirks_mode(&self) -> QuirksMode {
|
||||
self.quirks_mode.get()
|
||||
}
|
||||
|
||||
fn set_quirks_mode(self, mode: QuirksMode) {
|
||||
pub fn set_quirks_mode(&self, mode: QuirksMode) {
|
||||
self.quirks_mode.set(mode);
|
||||
|
||||
if mode == Quirks {
|
||||
|
@ -401,21 +322,21 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_encoding_name(self, name: DOMString) {
|
||||
pub fn set_encoding_name(&self, name: DOMString) {
|
||||
*self.encoding_name.borrow_mut() = name;
|
||||
}
|
||||
|
||||
fn content_changed(self, node: &Node, damage: NodeDamage) {
|
||||
pub fn content_changed(&self, node: &Node, damage: NodeDamage) {
|
||||
node.dirty(damage);
|
||||
}
|
||||
|
||||
fn content_and_heritage_changed(self, node: &Node, damage: NodeDamage) {
|
||||
pub fn content_and_heritage_changed(&self, node: &Node, damage: NodeDamage) {
|
||||
node.force_dirty_ancestors(damage);
|
||||
node.dirty(damage);
|
||||
}
|
||||
|
||||
/// Reflows and disarms the timer if the reflow timer has expired.
|
||||
fn reflow_if_reflow_timer_expired(self) {
|
||||
pub fn reflow_if_reflow_timer_expired(&self) {
|
||||
if let Some(reflow_timeout) = self.reflow_timeout.get() {
|
||||
if time::precise_time_ns() < reflow_timeout {
|
||||
return
|
||||
|
@ -432,7 +353,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
/// Schedules a reflow to be kicked off at the given `timeout` (in `time::precise_time_ns()`
|
||||
/// units). This reflow happens even if the event loop is busy. This is used to display initial
|
||||
/// page content during parsing.
|
||||
fn set_reflow_timeout(self, timeout: u64) {
|
||||
pub fn set_reflow_timeout(&self, timeout: u64) {
|
||||
if let Some(existing_timeout) = self.reflow_timeout.get() {
|
||||
if existing_timeout < timeout {
|
||||
return
|
||||
|
@ -442,12 +363,12 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// Disables any pending reflow timeouts.
|
||||
fn disarm_reflow_timeout(self) {
|
||||
pub fn disarm_reflow_timeout(&self) {
|
||||
self.reflow_timeout.set(None)
|
||||
}
|
||||
|
||||
/// Remove any existing association between the provided id and any elements in this document.
|
||||
fn unregister_named_element(self,
|
||||
pub fn unregister_named_element(&self,
|
||||
to_unregister: &Element,
|
||||
id: Atom) {
|
||||
debug!("Removing named element from document {:p}: {:p} id={}", self, to_unregister, id);
|
||||
|
@ -469,7 +390,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// Associate an element present in this document with the provided id.
|
||||
fn register_named_element(self,
|
||||
pub fn register_named_element(&self,
|
||||
element: &Element,
|
||||
id: Atom) {
|
||||
debug!("Adding named element to document {:p}: {:p} id={}", self, element, id);
|
||||
|
@ -512,7 +433,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
|
||||
/// Attempt to find a named element in this page's document.
|
||||
/// https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document
|
||||
fn find_fragment_node(self, fragid: &str) -> Option<Root<Element>> {
|
||||
pub fn find_fragment_node(&self, fragid: &str) -> Option<Root<Element>> {
|
||||
self.GetElementById(fragid.to_owned()).or_else(|| {
|
||||
let check_anchor = |&node: &&HTMLAnchorElement| {
|
||||
let elem = ElementCast::from_ref(node);
|
||||
|
@ -528,7 +449,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
})
|
||||
}
|
||||
|
||||
fn hit_test(self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress> {
|
||||
pub fn hit_test(&self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress> {
|
||||
let root = self.GetDocumentElement();
|
||||
let root = match root.r() {
|
||||
Some(root) => root,
|
||||
|
@ -546,7 +467,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
address
|
||||
}
|
||||
|
||||
fn get_nodes_under_mouse(self, point: &Point2D<f32>) -> Vec<UntrustedNodeAddress> {
|
||||
pub fn get_nodes_under_mouse(&self, point: &Point2D<f32>) -> Vec<UntrustedNodeAddress> {
|
||||
let root = self.GetDocumentElement();
|
||||
let root = match root.r() {
|
||||
Some(root) => root,
|
||||
|
@ -561,7 +482,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#current-document-readiness
|
||||
fn set_ready_state(self, state: DocumentReadyState) {
|
||||
pub fn set_ready_state(&self, state: DocumentReadyState) {
|
||||
self.ready_state.set(state);
|
||||
|
||||
let window = self.window.root();
|
||||
|
@ -573,24 +494,24 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// Return whether scripting is enabled or not
|
||||
fn is_scripting_enabled(self) -> bool {
|
||||
pub fn is_scripting_enabled(&self) -> bool {
|
||||
self.scripting_enabled.get()
|
||||
}
|
||||
|
||||
/// Return the element that currently has focus.
|
||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-focusevent-doc-focus
|
||||
fn get_focused_element(self) -> Option<Root<Element>> {
|
||||
pub fn get_focused_element(&self) -> Option<Root<Element>> {
|
||||
self.focused.get().map(Root::from_rooted)
|
||||
}
|
||||
|
||||
/// Initiate a new round of checking for elements requesting focus. The last element to call
|
||||
/// `request_focus` before `commit_focus_transaction` is called will receive focus.
|
||||
fn begin_focus_transaction(self) {
|
||||
pub fn begin_focus_transaction(&self) {
|
||||
self.possibly_focused.set(None);
|
||||
}
|
||||
|
||||
/// Request that the given element receive focus once the current transaction is complete.
|
||||
fn request_focus(self, elem: &Element) {
|
||||
pub fn request_focus(&self, elem: &Element) {
|
||||
if elem.is_focusable_area() {
|
||||
self.possibly_focused.set(Some(JS::from_ref(elem)))
|
||||
}
|
||||
|
@ -598,7 +519,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
|
||||
/// Reassign the focus context to the element that last requested focus during this
|
||||
/// transaction, or none if no elements requested it.
|
||||
fn commit_focus_transaction(self, focus_type: FocusType) {
|
||||
pub fn commit_focus_transaction(&self, focus_type: FocusType) {
|
||||
//TODO: dispatch blur, focus, focusout, and focusin events
|
||||
|
||||
if let Some(ref elem) = self.focused.get().map(|t| t.root()) {
|
||||
|
@ -624,7 +545,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// Handles any updates when the document's title has changed.
|
||||
fn title_changed(self) {
|
||||
pub fn title_changed(&self) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsertitlechange
|
||||
self.trigger_mozbrowser_event(MozBrowserEvent::TitleChange(self.Title()));
|
||||
|
||||
|
@ -632,7 +553,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// Sends this document's title to the compositor.
|
||||
fn send_title_to_compositor(self) {
|
||||
pub fn send_title_to_compositor(&self) {
|
||||
let window = self.window();
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let window = window.r();
|
||||
|
@ -640,14 +561,14 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
compositor.send(ScriptToCompositorMsg::SetTitle(window.pipeline(), Some(self.Title()))).unwrap();
|
||||
}
|
||||
|
||||
fn dirty_all_nodes(self) {
|
||||
pub fn dirty_all_nodes(&self) {
|
||||
let root = NodeCast::from_ref(self);
|
||||
for node in root.traverse_preorder() {
|
||||
node.r().dirty(NodeDamage::OtherNodeDamage)
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_mouse_event(self, js_runtime: *mut JSRuntime,
|
||||
pub fn handle_mouse_event(&self, js_runtime: *mut JSRuntime,
|
||||
_button: MouseButton, point: Point2D<f32>,
|
||||
mouse_event_type: MouseEventType) {
|
||||
let mouse_event_type_string = match mouse_event_type {
|
||||
|
@ -721,7 +642,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::MouseEvent);
|
||||
}
|
||||
|
||||
fn fire_mouse_event(self,
|
||||
pub fn fire_mouse_event(&self,
|
||||
point: Point2D<f32>,
|
||||
target: &EventTarget,
|
||||
event_name: String) {
|
||||
|
@ -744,7 +665,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
event.fire(target);
|
||||
}
|
||||
|
||||
fn handle_mouse_move_event(self,
|
||||
pub fn handle_mouse_move_event(&self,
|
||||
js_runtime: *mut JSRuntime,
|
||||
point: Point2D<f32>,
|
||||
prev_mouse_over_targets: &mut RootedVec<JS<Node>>) {
|
||||
|
@ -808,7 +729,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// The entry point for all key processing for web content
|
||||
fn dispatch_key_event(self,
|
||||
pub fn dispatch_key_event(&self,
|
||||
key: Key,
|
||||
state: KeyState,
|
||||
modifiers: KeyModifiers,
|
||||
|
@ -887,7 +808,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::KeyEvent);
|
||||
}
|
||||
|
||||
fn node_from_nodes_and_strings(self, nodes: Vec<NodeOrString>)
|
||||
pub fn node_from_nodes_and_strings(&self, nodes: Vec<NodeOrString>)
|
||||
-> Fallible<Root<Node>> {
|
||||
if nodes.len() == 1 {
|
||||
match nodes.into_iter().next().unwrap() {
|
||||
|
@ -915,7 +836,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_body_attribute(self, local_name: &Atom) -> DOMString {
|
||||
pub fn get_body_attribute(&self, local_name: &Atom) -> DOMString {
|
||||
match self.GetBody().and_then(HTMLBodyElementCast::to_root) {
|
||||
Some(ref body) => {
|
||||
ElementCast::from_ref(body.r()).get_string_attribute(local_name)
|
||||
|
@ -924,17 +845,17 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_body_attribute(self, local_name: &Atom, value: DOMString) {
|
||||
pub fn set_body_attribute(&self, local_name: &Atom, value: DOMString) {
|
||||
if let Some(ref body) = self.GetBody().and_then(HTMLBodyElementCast::to_root) {
|
||||
ElementCast::from_ref(body.r()).set_string_attribute(local_name, value);
|
||||
}
|
||||
}
|
||||
|
||||
fn set_current_script(self, script: Option<&HTMLScriptElement>) {
|
||||
pub fn set_current_script(&self, script: Option<&HTMLScriptElement>) {
|
||||
self.current_script.set(script.map(JS::from_ref));
|
||||
}
|
||||
|
||||
fn trigger_mozbrowser_event(self, event: MozBrowserEvent) {
|
||||
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||
if opts::experimental_enabled() {
|
||||
let window = self.window.root();
|
||||
|
||||
|
@ -949,7 +870,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe
|
||||
fn request_animation_frame(self, callback: Box<FnBox(f64)>) -> i32 {
|
||||
pub fn request_animation_frame(&self, callback: Box<FnBox(f64)>) -> i32 {
|
||||
let window = self.window.root();
|
||||
let window = window.r();
|
||||
let ident = self.animation_frame_ident.get() + 1;
|
||||
|
@ -967,7 +888,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#dom-window-cancelanimationframe
|
||||
fn cancel_animation_frame(self, ident: i32) {
|
||||
pub fn cancel_animation_frame(&self, ident: i32) {
|
||||
self.animation_frame_list.borrow_mut().remove(&ident);
|
||||
if self.animation_frame_list.borrow().is_empty() {
|
||||
let window = self.window.root();
|
||||
|
@ -980,7 +901,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#run-the-animation-frame-callbacks
|
||||
fn run_the_animation_frame_callbacks(self) {
|
||||
pub fn run_the_animation_frame_callbacks(&self) {
|
||||
let animation_frame_list;
|
||||
{
|
||||
let mut list = self.animation_frame_list.borrow_mut();
|
||||
|
@ -1008,27 +929,27 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
ReflowReason::RequestAnimationFrame);
|
||||
}
|
||||
|
||||
fn prepare_async_load(self, load: LoadType) -> PendingAsyncLoad {
|
||||
pub fn prepare_async_load(&self, load: LoadType) -> PendingAsyncLoad {
|
||||
let mut loader = self.loader.borrow_mut();
|
||||
loader.prepare_async_load(load)
|
||||
}
|
||||
|
||||
fn load_async(self, load: LoadType, listener: AsyncResponseTarget) {
|
||||
pub fn load_async(&self, load: LoadType, listener: AsyncResponseTarget) {
|
||||
let mut loader = self.loader.borrow_mut();
|
||||
loader.load_async(load, listener)
|
||||
}
|
||||
|
||||
fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec<u8>), String> {
|
||||
pub fn load_sync(&self, load: LoadType) -> Result<(Metadata, Vec<u8>), String> {
|
||||
let mut loader = self.loader.borrow_mut();
|
||||
loader.load_sync(load)
|
||||
}
|
||||
|
||||
fn finish_load(self, load: LoadType) {
|
||||
pub fn finish_load(&self, load: LoadType) {
|
||||
let mut loader = self.loader.borrow_mut();
|
||||
loader.finish_load(load);
|
||||
}
|
||||
|
||||
fn notify_constellation_load(self) {
|
||||
pub fn notify_constellation_load(&self) {
|
||||
let window = self.window.root();
|
||||
let pipeline_id = window.r().pipeline();
|
||||
let ConstellationChan(ref chan) = window.r().constellation_chan();
|
||||
|
@ -1037,16 +958,16 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
|
||||
}
|
||||
|
||||
fn set_current_parser(self, script: Option<&ServoHTMLParser>) {
|
||||
pub fn set_current_parser(&self, script: Option<&ServoHTMLParser>) {
|
||||
self.current_parser.set(script.map(JS::from_ref));
|
||||
}
|
||||
|
||||
fn get_current_parser(self) -> Option<Root<ServoHTMLParser>> {
|
||||
pub fn get_current_parser(&self) -> Option<Root<ServoHTMLParser>> {
|
||||
self.current_parser.get().map(Root::from_rooted)
|
||||
}
|
||||
|
||||
/// Find an iframe element in the document.
|
||||
fn find_iframe(self, subpage_id: SubpageId) -> Option<Root<HTMLIFrameElement>> {
|
||||
pub fn find_iframe(&self, subpage_id: SubpageId) -> Option<Root<HTMLIFrameElement>> {
|
||||
NodeCast::from_ref(self).traverse_preorder()
|
||||
.filter_map(HTMLIFrameElementCast::to_root)
|
||||
.find(|node| node.r().subpage_id() == Some(subpage_id))
|
||||
|
@ -1171,13 +1092,9 @@ impl Document {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateDocumentHelpers {
|
||||
fn create_node_list<F: Fn(&Node) -> bool>(self, callback: F) -> Root<NodeList>;
|
||||
fn get_html_element(self) -> Option<Root<HTMLHtmlElement>>;
|
||||
}
|
||||
|
||||
impl<'a> PrivateDocumentHelpers for &'a Document {
|
||||
fn create_node_list<F: Fn(&Node) -> bool>(self, callback: F) -> Root<NodeList> {
|
||||
impl Document {
|
||||
fn create_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> Root<NodeList> {
|
||||
let window = self.window.root();
|
||||
let doc = self.GetDocumentElement();
|
||||
let maybe_node = doc.r().map(NodeCast::from_ref);
|
||||
|
@ -1186,7 +1103,7 @@ impl<'a> PrivateDocumentHelpers for &'a Document {
|
|||
NodeList::new_simple_list(window.r(), iter)
|
||||
}
|
||||
|
||||
fn get_html_element(self) -> Option<Root<HTMLHtmlElement>> {
|
||||
fn get_html_element(&self) -> Option<Root<HTMLHtmlElement>> {
|
||||
self.GetDocumentElement()
|
||||
.r()
|
||||
.and_then(HTMLHtmlElementCast::to_ref)
|
||||
|
@ -1194,12 +1111,9 @@ impl<'a> PrivateDocumentHelpers for &'a Document {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateClickEventHelpers {
|
||||
fn click_event_filter_by_disabled_state(self) -> bool;
|
||||
}
|
||||
|
||||
impl<'a> PrivateClickEventHelpers for &'a Node {
|
||||
fn click_event_filter_by_disabled_state(self) -> bool {
|
||||
impl Node {
|
||||
fn click_event_filter_by_disabled_state(&self) -> bool {
|
||||
match self.type_id() {
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) |
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom::document::Document;
|
|||
use dom::element::Element;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlcollection::HTMLCollection;
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
||||
use dom::node::{Node, NodeTypeId, window_from_node};
|
||||
use dom::nodelist::NodeList;
|
||||
use util::str::DOMString;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::error::ErrorResult;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
use util::str::DOMString;
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
|
|
|
@ -14,7 +14,7 @@ use dom::bindings::js::{JS, Root};
|
|||
use dom::bindings::utils::validate_qualified_name;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::document::DocumentSource;
|
||||
use dom::document::{Document, DocumentHelpers, IsHTMLDocument};
|
||||
use dom::document::{Document, IsHTMLDocument};
|
||||
use dom::documenttype::DocumentType;
|
||||
use dom::htmlbodyelement::HTMLBodyElement;
|
||||
use dom::htmlheadelement::HTMLHeadElement;
|
||||
|
|
|
@ -13,8 +13,8 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::document::DocumentSource;
|
||||
use dom::document::{Document, DocumentHelpers, IsHTMLDocument};
|
||||
use dom::window::{Window, WindowHelpers};
|
||||
use dom::document::{Document, IsHTMLDocument};
|
||||
use dom::window::Window;
|
||||
use parse::html::{ParseContext, parse_html};
|
||||
use util::str::DOMString;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::error::ErrorResult;
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementCustomAttributeHelpers};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::window_from_node;
|
||||
use util::str::DOMString;
|
||||
|
||||
|
|
|
@ -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, AttrHelpers};
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::codegen::Bindings::DOMTokenListBinding;
|
||||
use dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods;
|
||||
use dom::bindings::error::Error::{InvalidCharacter, Syntax};
|
||||
|
@ -10,7 +10,7 @@ use dom::bindings::error::{ErrorResult, Fallible};
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::element::Element;
|
||||
use dom::node::window_from_node;
|
||||
|
||||
use string_cache::Atom;
|
||||
|
@ -42,18 +42,14 @@ impl DOMTokenList {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateDOMTokenListHelpers {
|
||||
fn attribute(self) -> Option<Root<Attr>>;
|
||||
fn check_token_exceptions(self, token: &str) -> Fallible<Atom>;
|
||||
}
|
||||
|
||||
impl<'a> PrivateDOMTokenListHelpers for &'a DOMTokenList {
|
||||
fn attribute(self) -> Option<Root<Attr>> {
|
||||
impl DOMTokenList {
|
||||
fn attribute(&self) -> Option<Root<Attr>> {
|
||||
let element = self.element.root();
|
||||
element.r().get_attribute(&ns!(""), &self.local_name)
|
||||
}
|
||||
|
||||
fn check_token_exceptions(self, token: &str) -> Fallible<Atom> {
|
||||
fn check_token_exceptions(&self, token: &str) -> Fallible<Atom> {
|
||||
match token {
|
||||
"" => Err(Syntax),
|
||||
slice if slice.find(HTML_SPACE_CHARACTERS).is_some() => Err(InvalidCharacter),
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use dom::activation::Activatable;
|
||||
use dom::attr::AttrValue;
|
||||
use dom::attr::{Attr, AttrSettingType, AttrHelpers, AttrHelpersForLayout};
|
||||
use dom::attr::{Attr, AttrSettingType, AttrHelpersForLayout};
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||
use dom::bindings::codegen::Bindings::ElementBinding;
|
||||
|
@ -35,27 +35,26 @@ use dom::bindings::js::{Root, RootedReference};
|
|||
use dom::bindings::trace::RootedVec;
|
||||
use dom::bindings::utils::XMLName::InvalidXMLName;
|
||||
use dom::bindings::utils::{namespace_from_domstring, xml_name_type, validate_and_extract};
|
||||
use dom::characterdata::CharacterDataHelpers;
|
||||
use dom::create::create_element;
|
||||
use dom::document::{Document, DocumentHelpers, LayoutDocumentHelpers};
|
||||
use dom::document::{Document, LayoutDocumentHelpers};
|
||||
use dom::domrect::DOMRect;
|
||||
use dom::domrectlist::DOMRectList;
|
||||
use dom::domtokenlist::DOMTokenList;
|
||||
use dom::event::{Event, EventHelpers};
|
||||
use dom::event::Event;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlbodyelement::{HTMLBodyElement, HTMLBodyElementHelpers};
|
||||
use dom::htmlbodyelement::HTMLBodyElement;
|
||||
use dom::htmlcollection::HTMLCollection;
|
||||
use dom::htmlelement::HTMLElementTypeId;
|
||||
use dom::htmlfontelement::{HTMLFontElement, HTMLFontElementHelpers};
|
||||
use dom::htmliframeelement::{HTMLIFrameElement, RawHTMLIFrameElementHelpers};
|
||||
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers, HTMLInputElementHelpers};
|
||||
use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelpers};
|
||||
use dom::htmltableelement::{HTMLTableElement, HTMLTableElementHelpers};
|
||||
use dom::htmltablerowelement::{HTMLTableRowElement, HTMLTableRowElementHelpers};
|
||||
use dom::htmltablesectionelement::{HTMLTableSectionElement, HTMLTableSectionElementHelpers};
|
||||
use dom::htmlfontelement::HTMLFontElement;
|
||||
use dom::htmliframeelement::HTMLIFrameElement;
|
||||
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers};
|
||||
use dom::htmltablecellelement::HTMLTableCellElement;
|
||||
use dom::htmltableelement::HTMLTableElement;
|
||||
use dom::htmltablerowelement::HTMLTableRowElement;
|
||||
use dom::htmltablesectionelement::HTMLTableSectionElement;
|
||||
use dom::htmltextareaelement::{HTMLTextAreaElement, RawLayoutHTMLTextAreaElementHelpers};
|
||||
use dom::namednodemap::NamedNodeMap;
|
||||
use dom::node::{CLICK_IN_PROGRESS, LayoutNodeHelpers, Node, NodeHelpers, NodeTypeId, SEQUENTIALLY_FOCUSABLE};
|
||||
use dom::node::{CLICK_IN_PROGRESS, LayoutNodeHelpers, Node, NodeTypeId, SEQUENTIALLY_FOCUSABLE};
|
||||
use dom::node::{document_from_node, NodeDamage};
|
||||
use dom::node::{window_from_node};
|
||||
use dom::nodelist::NodeList;
|
||||
|
@ -568,38 +567,18 @@ pub enum StylePriority {
|
|||
Normal,
|
||||
}
|
||||
|
||||
pub trait ElementHelpers<'a> {
|
||||
fn html_element_in_html_document(self) -> bool;
|
||||
fn local_name(self) -> &'a Atom;
|
||||
fn parsed_name(self, name: DOMString) -> Atom;
|
||||
fn namespace(self) -> &'a Namespace;
|
||||
fn prefix(self) -> &'a Option<DOMString>;
|
||||
fn attrs(&self) -> Ref<Vec<JS<Attr>>>;
|
||||
fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>>;
|
||||
fn style_attribute(self) -> &'a DOMRefCell<Option<PropertyDeclarationBlock>>;
|
||||
fn summarize(self) -> Vec<AttrInfo>;
|
||||
fn is_void(self) -> bool;
|
||||
fn remove_inline_style_property(self, property: &str);
|
||||
fn update_inline_style(self, property_decl: PropertyDeclaration, style_priority: StylePriority);
|
||||
fn set_inline_style_property_priority(self, properties: &[&str], style_priority: StylePriority);
|
||||
fn get_inline_style_declaration(self, property: &Atom) -> Option<Ref<'a, PropertyDeclaration>>;
|
||||
fn get_important_inline_style_declaration(self, property: &Atom) -> Option<Ref<'a, PropertyDeclaration>>;
|
||||
fn serialize(self, traversal_scope: TraversalScope) -> Fallible<DOMString>;
|
||||
fn get_root_element(self) -> Root<Element>;
|
||||
fn lookup_prefix(self, namespace: Namespace) -> Option<DOMString>;
|
||||
}
|
||||
|
||||
impl<'a> ElementHelpers<'a> for &'a Element {
|
||||
fn html_element_in_html_document(self) -> bool {
|
||||
impl Element {
|
||||
pub fn html_element_in_html_document(&self) -> bool {
|
||||
let node = NodeCast::from_ref(self);
|
||||
self.namespace == ns!(HTML) && node.is_in_html_doc()
|
||||
}
|
||||
|
||||
fn local_name(self) -> &'a Atom {
|
||||
pub fn local_name(&self) -> &Atom {
|
||||
&self.local_name
|
||||
}
|
||||
|
||||
fn parsed_name(self, name: DOMString) -> Atom {
|
||||
pub fn parsed_name(&self, name: DOMString) -> Atom {
|
||||
if self.html_element_in_html_document() {
|
||||
Atom::from_slice(&name.to_ascii_lowercase())
|
||||
} else {
|
||||
|
@ -607,27 +586,27 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
fn namespace(self) -> &'a Namespace {
|
||||
pub fn namespace(&self) -> &Namespace {
|
||||
&self.namespace
|
||||
}
|
||||
|
||||
fn prefix(self) -> &'a Option<DOMString> {
|
||||
pub fn prefix(&self) -> &Option<DOMString> {
|
||||
&self.prefix
|
||||
}
|
||||
|
||||
fn attrs(&self) -> Ref<Vec<JS<Attr>>> {
|
||||
pub fn attrs(&self) -> Ref<Vec<JS<Attr>>> {
|
||||
self.attrs.borrow()
|
||||
}
|
||||
|
||||
fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>> {
|
||||
pub fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>> {
|
||||
self.attrs.borrow_mut()
|
||||
}
|
||||
|
||||
fn style_attribute(self) -> &'a DOMRefCell<Option<PropertyDeclarationBlock>> {
|
||||
pub fn style_attribute(&self) -> &DOMRefCell<Option<PropertyDeclarationBlock>> {
|
||||
&self.style_attribute
|
||||
}
|
||||
|
||||
fn summarize(self) -> Vec<AttrInfo> {
|
||||
pub fn summarize(&self) -> Vec<AttrInfo> {
|
||||
let attrs = self.Attributes();
|
||||
let mut summarized = vec!();
|
||||
for i in 0..attrs.r().Length() {
|
||||
|
@ -637,7 +616,7 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
summarized
|
||||
}
|
||||
|
||||
fn is_void(self) -> bool {
|
||||
pub fn is_void(&self) -> bool {
|
||||
if self.namespace != ns!(HTML) {
|
||||
return false
|
||||
}
|
||||
|
@ -651,7 +630,7 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
fn remove_inline_style_property(self, property: &str) {
|
||||
pub fn remove_inline_style_property(&self, property: &str) {
|
||||
let mut inline_declarations = self.style_attribute.borrow_mut();
|
||||
if let &mut Some(ref mut declarations) = &mut *inline_declarations {
|
||||
let index = declarations.normal
|
||||
|
@ -672,7 +651,7 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
fn update_inline_style(self, property_decl: PropertyDeclaration, style_priority: StylePriority) {
|
||||
pub fn update_inline_style(&self, property_decl: PropertyDeclaration, style_priority: StylePriority) {
|
||||
let mut inline_declarations = self.style_attribute().borrow_mut();
|
||||
if let &mut Some(ref mut declarations) = &mut *inline_declarations {
|
||||
let existing_declarations = if style_priority == StylePriority::Important {
|
||||
|
@ -706,7 +685,7 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
});
|
||||
}
|
||||
|
||||
fn set_inline_style_property_priority(self, properties: &[&str], style_priority: StylePriority) {
|
||||
pub fn set_inline_style_property_priority(&self, properties: &[&str], style_priority: StylePriority) {
|
||||
let mut inline_declarations = self.style_attribute().borrow_mut();
|
||||
if let &mut Some(ref mut declarations) = &mut *inline_declarations {
|
||||
let (from, to) = if style_priority == StylePriority::Important {
|
||||
|
@ -731,7 +710,7 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_inline_style_declaration(self, property: &Atom) -> Option<Ref<'a, PropertyDeclaration>> {
|
||||
pub fn get_inline_style_declaration(&self, property: &Atom) -> Option<Ref<PropertyDeclaration>> {
|
||||
Ref::filter_map(self.style_attribute.borrow(), |inline_declarations| {
|
||||
inline_declarations.as_ref().and_then(|declarations| {
|
||||
declarations.normal
|
||||
|
@ -742,7 +721,8 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
})
|
||||
}
|
||||
|
||||
fn get_important_inline_style_declaration(self, property: &Atom) -> Option<Ref<'a, PropertyDeclaration>> {
|
||||
pub fn get_important_inline_style_declaration(&self, property: &Atom)
|
||||
-> Option<Ref<PropertyDeclaration>> {
|
||||
Ref::filter_map(self.style_attribute.borrow(), |inline_declarations| {
|
||||
inline_declarations.as_ref().and_then(|declarations| {
|
||||
declarations.important
|
||||
|
@ -752,7 +732,7 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
})
|
||||
}
|
||||
|
||||
fn serialize(self, traversal_scope: TraversalScope) -> Fallible<DOMString> {
|
||||
pub fn serialize(&self, traversal_scope: TraversalScope) -> Fallible<DOMString> {
|
||||
let node = NodeCast::from_ref(self);
|
||||
let mut writer = vec![];
|
||||
match serialize(&mut writer, &node,
|
||||
|
@ -766,7 +746,7 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#root-element
|
||||
fn get_root_element(self) -> Root<Element> {
|
||||
pub fn get_root_element(&self) -> Root<Element> {
|
||||
let node = NodeCast::from_ref(self);
|
||||
node.inclusive_ancestors()
|
||||
.filter_map(ElementCast::to_root)
|
||||
|
@ -775,7 +755,7 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#locate-a-namespace-prefix
|
||||
fn lookup_prefix(self, namespace: Namespace) -> Option<DOMString> {
|
||||
pub fn lookup_prefix(&self, namespace: Namespace) -> Option<DOMString> {
|
||||
for node in NodeCast::from_ref(self).inclusive_ancestors() {
|
||||
match ElementCast::to_ref(node.r()) {
|
||||
Some(element) => {
|
||||
|
@ -803,16 +783,9 @@ impl<'a> ElementHelpers<'a> for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait FocusElementHelpers {
|
||||
/// https://html.spec.whatwg.org/multipage/#focusable-area
|
||||
fn is_focusable_area(self) -> bool;
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#concept-element-disabled
|
||||
fn is_actually_disabled(self) -> bool;
|
||||
}
|
||||
|
||||
impl<'a> FocusElementHelpers for &'a Element {
|
||||
fn is_focusable_area(self) -> bool {
|
||||
impl Element {
|
||||
pub fn is_focusable_area(&self) -> bool {
|
||||
if self.is_actually_disabled() {
|
||||
return false;
|
||||
}
|
||||
|
@ -833,7 +806,7 @@ impl<'a> FocusElementHelpers for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_actually_disabled(self) -> bool {
|
||||
pub fn is_actually_disabled(&self) -> bool {
|
||||
let node = NodeCast::from_ref(self);
|
||||
match node.type_id() {
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) |
|
||||
|
@ -852,58 +825,9 @@ impl<'a> FocusElementHelpers for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait AttributeHandlers {
|
||||
/// Returns the attribute with given namespace and case-sensitive local
|
||||
/// name, if any.
|
||||
fn get_attribute(self, namespace: &Namespace, local_name: &Atom)
|
||||
-> Option<Root<Attr>>;
|
||||
/// Returns the first attribute with any namespace and given case-sensitive
|
||||
/// name, if any.
|
||||
fn get_attribute_by_name(self, name: DOMString) -> Option<Root<Attr>>;
|
||||
fn get_attributes(self, local_name: &Atom, attributes: &mut RootedVec<JS<Attr>>);
|
||||
fn set_attribute_from_parser(self,
|
||||
name: QualName,
|
||||
value: DOMString,
|
||||
prefix: Option<Atom>);
|
||||
fn set_attribute(self, name: &Atom, value: AttrValue);
|
||||
fn set_custom_attribute(self, name: DOMString, value: DOMString) -> ErrorResult;
|
||||
fn do_set_attribute<F>(self, local_name: Atom, value: AttrValue,
|
||||
name: Atom, namespace: Namespace,
|
||||
prefix: Option<Atom>, cb: F)
|
||||
where F: Fn(&Attr) -> bool;
|
||||
fn parse_attribute(self, namespace: &Namespace, local_name: &Atom,
|
||||
value: DOMString) -> AttrValue;
|
||||
|
||||
/// Removes the first attribute with any given namespace and case-sensitive local
|
||||
/// name, if any.
|
||||
fn remove_attribute(self, namespace: &Namespace, local_name: &Atom)
|
||||
-> Option<Root<Attr>>;
|
||||
/// Removes the first attribute with any namespace and given case-sensitive name.
|
||||
fn remove_attribute_by_name(self, name: &Atom) -> Option<Root<Attr>>;
|
||||
/// Removes the first attribute that satisfies `find`.
|
||||
fn do_remove_attribute<F>(self, find: F) -> Option<Root<Attr>>
|
||||
where F: Fn(&Attr) -> bool;
|
||||
|
||||
fn has_class(self, name: &Atom) -> bool;
|
||||
|
||||
fn set_atomic_attribute(self, local_name: &Atom, value: DOMString);
|
||||
|
||||
// https://www.whatwg.org/html/#reflecting-content-attributes-in-idl-attributes
|
||||
fn has_attribute(self, local_name: &Atom) -> bool;
|
||||
fn set_bool_attribute(self, local_name: &Atom, value: bool);
|
||||
fn get_url_attribute(self, local_name: &Atom) -> DOMString;
|
||||
fn set_url_attribute(self, local_name: &Atom, value: DOMString);
|
||||
fn get_string_attribute(self, local_name: &Atom) -> DOMString;
|
||||
fn set_string_attribute(self, local_name: &Atom, value: DOMString);
|
||||
fn get_tokenlist_attribute(self, local_name: &Atom) -> Vec<Atom>;
|
||||
fn set_tokenlist_attribute(self, local_name: &Atom, value: DOMString);
|
||||
fn set_atomic_tokenlist_attribute(self, local_name: &Atom, tokens: Vec<Atom>);
|
||||
fn get_uint_attribute(self, local_name: &Atom, default: u32) -> u32;
|
||||
fn set_uint_attribute(self, local_name: &Atom, value: u32);
|
||||
}
|
||||
|
||||
impl<'a> AttributeHandlers for &'a Element {
|
||||
fn get_attribute(self, namespace: &Namespace, local_name: &Atom) -> Option<Root<Attr>> {
|
||||
impl Element {
|
||||
pub fn get_attribute(&self, namespace: &Namespace, local_name: &Atom) -> Option<Root<Attr>> {
|
||||
let mut attributes = RootedVec::new();
|
||||
self.get_attributes(local_name, &mut attributes);
|
||||
attributes.r().iter()
|
||||
|
@ -912,14 +836,14 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||
fn get_attribute_by_name(self, name: DOMString) -> Option<Root<Attr>> {
|
||||
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<Root<Attr>> {
|
||||
let name = &self.parsed_name(name);
|
||||
self.attrs.borrow().iter().map(|attr| attr.root())
|
||||
.find(|a| a.r().name() == name)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||
fn get_attributes(self, local_name: &Atom, attributes: &mut RootedVec<JS<Attr>>) {
|
||||
pub fn get_attributes(&self, local_name: &Atom, attributes: &mut RootedVec<JS<Attr>>) {
|
||||
for ref attr in self.attrs.borrow().iter() {
|
||||
let attr = attr.root();
|
||||
if attr.r().local_name() == local_name {
|
||||
|
@ -928,7 +852,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_attribute_from_parser(self,
|
||||
pub fn set_attribute_from_parser(&self,
|
||||
qname: QualName,
|
||||
value: DOMString,
|
||||
prefix: Option<Atom>) {
|
||||
|
@ -949,7 +873,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
self.do_set_attribute(qname.local, value, name, qname.ns, prefix, |_| false)
|
||||
}
|
||||
|
||||
fn set_attribute(self, name: &Atom, value: AttrValue) {
|
||||
pub fn set_attribute(&self, name: &Atom, value: AttrValue) {
|
||||
assert!(&**name == name.to_ascii_lowercase());
|
||||
assert!(!name.contains(":"));
|
||||
|
||||
|
@ -958,7 +882,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#attr-data-*
|
||||
fn set_custom_attribute(self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||
pub fn set_custom_attribute(&self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||
// Step 1.
|
||||
match xml_name_type(&name) {
|
||||
InvalidXMLName => return Err(InvalidCharacter),
|
||||
|
@ -974,7 +898,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn do_set_attribute<F>(self,
|
||||
pub fn do_set_attribute<F>(&self,
|
||||
local_name: Atom,
|
||||
value: AttrValue,
|
||||
name: Atom,
|
||||
|
@ -1000,7 +924,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
(*self.attrs.borrow())[idx].root().r().set_value(set_type, value, self);
|
||||
}
|
||||
|
||||
fn parse_attribute(self, namespace: &Namespace, local_name: &Atom,
|
||||
pub fn parse_attribute(&self, namespace: &Namespace, local_name: &Atom,
|
||||
value: DOMString) -> AttrValue {
|
||||
if *namespace == ns!("") {
|
||||
vtable_for(&NodeCast::from_ref(self))
|
||||
|
@ -1010,18 +934,18 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
fn remove_attribute(self, namespace: &Namespace, local_name: &Atom)
|
||||
pub fn remove_attribute(&self, namespace: &Namespace, local_name: &Atom)
|
||||
-> Option<Root<Attr>> {
|
||||
self.do_remove_attribute(|attr| {
|
||||
attr.namespace() == namespace && attr.local_name() == local_name
|
||||
})
|
||||
}
|
||||
|
||||
fn remove_attribute_by_name(self, name: &Atom) -> Option<Root<Attr>> {
|
||||
pub fn remove_attribute_by_name(&self, name: &Atom) -> Option<Root<Attr>> {
|
||||
self.do_remove_attribute(|attr| attr.name() == name)
|
||||
}
|
||||
|
||||
fn do_remove_attribute<F>(self, find: F) -> Option<Root<Attr>>
|
||||
pub fn do_remove_attribute<F>(&self, find: F) -> Option<Root<Attr>>
|
||||
where F: Fn(&Attr) -> bool
|
||||
{
|
||||
let idx = self.attrs.borrow().iter()
|
||||
|
@ -1054,7 +978,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
})
|
||||
}
|
||||
|
||||
fn has_class(self, name: &Atom) -> bool {
|
||||
pub fn has_class(&self, name: &Atom) -> bool {
|
||||
let quirks_mode = {
|
||||
let node = NodeCast::from_ref(self);
|
||||
let owner_doc = node.owner_doc();
|
||||
|
@ -1071,20 +995,20 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
}).unwrap_or(false)
|
||||
}
|
||||
|
||||
fn set_atomic_attribute(self, local_name: &Atom, value: DOMString) {
|
||||
pub fn set_atomic_attribute(&self, local_name: &Atom, value: DOMString) {
|
||||
assert!(&**local_name == local_name.to_ascii_lowercase());
|
||||
let value = AttrValue::from_atomic(value);
|
||||
self.set_attribute(local_name, value);
|
||||
}
|
||||
|
||||
fn has_attribute(self, local_name: &Atom) -> bool {
|
||||
pub fn has_attribute(&self, local_name: &Atom) -> bool {
|
||||
assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b));
|
||||
self.attrs.borrow().iter().map(|attr| attr.root()).any(|attr| {
|
||||
attr.r().local_name() == local_name && attr.r().namespace() == &ns!("")
|
||||
})
|
||||
}
|
||||
|
||||
fn set_bool_attribute(self, local_name: &Atom, value: bool) {
|
||||
pub fn set_bool_attribute(&self, local_name: &Atom, value: bool) {
|
||||
if self.has_attribute(local_name) == value { return; }
|
||||
if value {
|
||||
self.set_string_attribute(local_name, String::new());
|
||||
|
@ -1093,7 +1017,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_url_attribute(self, local_name: &Atom) -> DOMString {
|
||||
pub fn get_url_attribute(&self, local_name: &Atom) -> DOMString {
|
||||
assert!(&**local_name == local_name.to_ascii_lowercase());
|
||||
if !self.has_attribute(local_name) {
|
||||
return "".to_owned();
|
||||
|
@ -1108,22 +1032,22 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
Err(_) => "".to_owned()
|
||||
}
|
||||
}
|
||||
fn set_url_attribute(self, local_name: &Atom, value: DOMString) {
|
||||
pub fn set_url_attribute(&self, local_name: &Atom, value: DOMString) {
|
||||
self.set_string_attribute(local_name, value);
|
||||
}
|
||||
|
||||
fn get_string_attribute(self, local_name: &Atom) -> DOMString {
|
||||
pub fn get_string_attribute(&self, local_name: &Atom) -> DOMString {
|
||||
match self.get_attribute(&ns!(""), local_name) {
|
||||
Some(x) => x.r().Value(),
|
||||
None => "".to_owned()
|
||||
}
|
||||
}
|
||||
fn set_string_attribute(self, local_name: &Atom, value: DOMString) {
|
||||
pub fn set_string_attribute(&self, local_name: &Atom, value: DOMString) {
|
||||
assert!(&**local_name == local_name.to_ascii_lowercase());
|
||||
self.set_attribute(local_name, AttrValue::String(value));
|
||||
}
|
||||
|
||||
fn get_tokenlist_attribute(self, local_name: &Atom) -> Vec<Atom> {
|
||||
pub fn get_tokenlist_attribute(&self, local_name: &Atom) -> Vec<Atom> {
|
||||
self.get_attribute(&ns!(""), local_name).map(|attr| {
|
||||
attr.r()
|
||||
.value()
|
||||
|
@ -1133,17 +1057,17 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
}).unwrap_or(vec!())
|
||||
}
|
||||
|
||||
fn set_tokenlist_attribute(self, local_name: &Atom, value: DOMString) {
|
||||
pub fn set_tokenlist_attribute(&self, local_name: &Atom, value: DOMString) {
|
||||
assert!(&**local_name == local_name.to_ascii_lowercase());
|
||||
self.set_attribute(local_name, AttrValue::from_serialized_tokenlist(value));
|
||||
}
|
||||
|
||||
fn set_atomic_tokenlist_attribute(self, local_name: &Atom, tokens: Vec<Atom>) {
|
||||
pub fn set_atomic_tokenlist_attribute(&self, local_name: &Atom, tokens: Vec<Atom>) {
|
||||
assert!(&**local_name == local_name.to_ascii_lowercase());
|
||||
self.set_attribute(local_name, AttrValue::from_atomic_tokens(tokens));
|
||||
}
|
||||
|
||||
fn get_uint_attribute(self, local_name: &Atom, default: u32) -> u32 {
|
||||
pub fn get_uint_attribute(&self, local_name: &Atom, default: u32) -> u32 {
|
||||
assert!(local_name.chars().all(|ch| {
|
||||
!ch.is_ascii() || ch.to_ascii_lowercase() == ch
|
||||
}));
|
||||
|
@ -1159,7 +1083,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
None => default,
|
||||
}
|
||||
}
|
||||
fn set_uint_attribute(self, local_name: &Atom, value: u32) {
|
||||
pub fn set_uint_attribute(&self, local_name: &Atom, value: u32) {
|
||||
assert!(&**local_name == local_name.to_ascii_lowercase());
|
||||
self.set_attribute(local_name, AttrValue::UInt(value.to_string(), value));
|
||||
}
|
||||
|
@ -1744,7 +1668,7 @@ impl<'a> ::selectors::Element for Root<Element> {
|
|||
}
|
||||
|
||||
fn get_local_name<'b>(&'b self) -> &'b Atom {
|
||||
ElementHelpers::local_name(&**self)
|
||||
self.local_name()
|
||||
}
|
||||
fn get_namespace<'b>(&'b self) -> &'b Namespace {
|
||||
self.namespace()
|
||||
|
@ -1795,7 +1719,7 @@ impl<'a> ::selectors::Element for Root<Element> {
|
|||
}
|
||||
}
|
||||
fn has_class(&self, name: &Atom) -> bool {
|
||||
AttributeHandlers::has_class(&**self, name)
|
||||
Element::has_class(&**self, name)
|
||||
}
|
||||
fn each_class<F>(&self, mut callback: F)
|
||||
where F: FnMut(&Atom)
|
||||
|
@ -1856,16 +1780,9 @@ impl<'a> ::selectors::Element for Root<Element> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait ActivationElementHelpers<'a> {
|
||||
fn as_maybe_activatable(self) -> Option<&'a (Activatable + 'a)>;
|
||||
fn click_in_progress(self) -> bool;
|
||||
fn set_click_in_progress(self, click: bool);
|
||||
fn nearest_activable_element(self) -> Option<Root<Element>>;
|
||||
fn authentic_click_activation<'b>(self, event: &'b Event);
|
||||
}
|
||||
|
||||
impl<'a> ActivationElementHelpers<'a> for &'a Element {
|
||||
fn as_maybe_activatable(self) -> Option<&'a (Activatable + 'a)> {
|
||||
impl Element {
|
||||
pub fn as_maybe_activatable<'a>(&'a self) -> Option<&'a (Activatable + 'a)> {
|
||||
let node = NodeCast::from_ref(self);
|
||||
let element = match node.type_id() {
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
|
||||
|
@ -1889,18 +1806,18 @@ impl<'a> ActivationElementHelpers<'a> for &'a Element {
|
|||
})
|
||||
}
|
||||
|
||||
fn click_in_progress(self) -> bool {
|
||||
pub fn click_in_progress(&self) -> bool {
|
||||
let node = NodeCast::from_ref(self);
|
||||
node.get_flag(CLICK_IN_PROGRESS)
|
||||
}
|
||||
|
||||
fn set_click_in_progress(self, click: bool) {
|
||||
pub fn set_click_in_progress(&self, click: bool) {
|
||||
let node = NodeCast::from_ref(self);
|
||||
node.set_flag(CLICK_IN_PROGRESS, click)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#nearest-activatable-element
|
||||
fn nearest_activable_element(self) -> Option<Root<Element>> {
|
||||
pub fn nearest_activable_element(&self) -> Option<Root<Element>> {
|
||||
match self.as_maybe_activatable() {
|
||||
Some(el) => Some(Root::from_ref(el.as_element())),
|
||||
None => {
|
||||
|
@ -1923,7 +1840,7 @@ impl<'a> ActivationElementHelpers<'a> for &'a Element {
|
|||
///
|
||||
/// Use an element's synthetic click activation (or handle_event) for any script-triggered clicks.
|
||||
/// If the spec says otherwise, check with Manishearth first
|
||||
fn authentic_click_activation<'b>(self, event: &'b Event) {
|
||||
pub fn authentic_click_activation<'b>(&self, event: &'b Event) {
|
||||
// Not explicitly part of the spec, however this helps enforce the invariants
|
||||
// required to save state between pre-activation and post-activation
|
||||
// since we cannot nest authentic clicks (unlike synthetic click activation, where
|
||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::error::Fallible;
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::uievent::{UIEventTypeId};
|
||||
use util::str::DOMString;
|
||||
|
||||
|
@ -257,18 +257,14 @@ impl<'a> EventMethods for &'a Event {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait EventHelpers {
|
||||
fn set_trusted(self, trusted: bool);
|
||||
fn fire(self, target: &EventTarget) -> bool;
|
||||
}
|
||||
|
||||
impl<'a> EventHelpers for &'a Event {
|
||||
fn set_trusted(self, trusted: bool) {
|
||||
impl Event {
|
||||
pub fn set_trusted(&self, trusted: bool) {
|
||||
self.trusted.set(trusted);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#fire-a-simple-event
|
||||
fn fire(self, target: &EventTarget) -> bool {
|
||||
pub fn fire(&self, target: &EventTarget) -> bool {
|
||||
self.set_trusted(true);
|
||||
target.dispatch_event(self)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::js::JS;
|
|||
use dom::bindings::trace::RootedVec;
|
||||
use dom::event::{Event, EventPhase};
|
||||
use dom::eventtarget::{EventTarget, ListenerPhase};
|
||||
use dom::node::{Node, NodeHelpers};
|
||||
use dom::node::Node;
|
||||
use dom::virtualmethods::vtable_for;
|
||||
|
||||
// See https://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
|||
use dom::bindings::error::Error::InvalidState;
|
||||
use dom::bindings::error::{Fallible, report_pending_exception};
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::event::{Event, EventHelpers};
|
||||
use dom::event::Event;
|
||||
use dom::eventdispatcher::dispatch_event;
|
||||
use dom::node::NodeTypeId;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
@ -165,40 +165,19 @@ impl EventTarget {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait EventTargetHelpers {
|
||||
fn dispatch_event_with_target(self,
|
||||
target: &EventTarget,
|
||||
event: &Event) -> bool;
|
||||
fn dispatch_event(self, event: &Event) -> bool;
|
||||
fn set_inline_event_listener(self,
|
||||
ty: DOMString,
|
||||
listener: Option<Rc<EventHandler>>);
|
||||
fn get_inline_event_listener(self, ty: DOMString) -> Option<Rc<EventHandler>>;
|
||||
fn set_event_handler_uncompiled(self,
|
||||
cx: *mut JSContext,
|
||||
url: Url,
|
||||
scope: HandleObject,
|
||||
ty: &str,
|
||||
source: DOMString);
|
||||
fn set_event_handler_common<T: CallbackContainer>(self, ty: &str,
|
||||
listener: Option<Rc<T>>);
|
||||
fn get_event_handler_common<T: CallbackContainer>(self, ty: &str) -> Option<Rc<T>>;
|
||||
|
||||
fn has_handlers(self) -> bool;
|
||||
}
|
||||
|
||||
impl<'a> EventTargetHelpers for &'a EventTarget {
|
||||
fn dispatch_event_with_target(self,
|
||||
impl EventTarget {
|
||||
pub fn dispatch_event_with_target(&self,
|
||||
target: &EventTarget,
|
||||
event: &Event) -> bool {
|
||||
dispatch_event(self, Some(target), event)
|
||||
}
|
||||
|
||||
fn dispatch_event(self, event: &Event) -> bool {
|
||||
pub fn dispatch_event(&self, event: &Event) -> bool {
|
||||
dispatch_event(self, None, event)
|
||||
}
|
||||
|
||||
fn set_inline_event_listener(self,
|
||||
pub fn set_inline_event_listener(&self,
|
||||
ty: DOMString,
|
||||
listener: Option<Rc<EventHandler>>) {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
|
@ -234,7 +213,7 @@ impl<'a> EventTargetHelpers for &'a EventTarget {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_inline_event_listener(self, ty: DOMString) -> Option<Rc<EventHandler>> {
|
||||
pub fn get_inline_event_listener(&self, ty: DOMString) -> Option<Rc<EventHandler>> {
|
||||
let handlers = self.handlers.borrow();
|
||||
let entries = handlers.get(&ty);
|
||||
entries.and_then(|entries| entries.iter().filter_map(|entry| {
|
||||
|
@ -246,7 +225,7 @@ impl<'a> EventTargetHelpers for &'a EventTarget {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn set_event_handler_uncompiled(self,
|
||||
pub fn set_event_handler_uncompiled(&self,
|
||||
cx: *mut JSContext,
|
||||
url: Url,
|
||||
scope: HandleObject,
|
||||
|
@ -287,20 +266,20 @@ impl<'a> EventTargetHelpers for &'a EventTarget {
|
|||
self.set_event_handler_common(ty, Some(EventHandlerNonNull::new(funobj)));
|
||||
}
|
||||
|
||||
fn set_event_handler_common<T: CallbackContainer>(
|
||||
self, ty: &str, listener: Option<Rc<T>>)
|
||||
pub fn set_event_handler_common<T: CallbackContainer>(
|
||||
&self, ty: &str, listener: Option<Rc<T>>)
|
||||
{
|
||||
let event_listener = listener.map(|listener|
|
||||
EventHandlerNonNull::new(listener.callback()));
|
||||
self.set_inline_event_listener(ty.to_owned(), event_listener);
|
||||
}
|
||||
|
||||
fn get_event_handler_common<T: CallbackContainer>(self, ty: &str) -> Option<Rc<T>> {
|
||||
pub fn get_event_handler_common<T: CallbackContainer>(&self, ty: &str) -> Option<Rc<T>> {
|
||||
let listener = self.get_inline_event_listener(ty.to_owned());
|
||||
listener.map(|listener| CallbackContainer::new(listener.parent.callback()))
|
||||
}
|
||||
|
||||
fn has_handlers(self) -> bool {
|
||||
pub fn has_handlers(&self) -> bool {
|
||||
!self.handlers.borrow().is_empty()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ use dom::bindings::global::{GlobalRef, GlobalField};
|
|||
use dom::bindings::js::{Root, JS, MutNullableHeap};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::utils::{reflect_dom_object, Reflectable};
|
||||
use dom::blob::{Blob, BlobHelpers};
|
||||
use dom::blob::Blob;
|
||||
use dom::domexception::{DOMException, DOMErrorName};
|
||||
use dom::event::{EventHelpers, EventCancelable, EventBubbles};
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::event::{EventCancelable, EventBubbles};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::progressevent::ProgressEvent;
|
||||
use encoding::all::UTF_8;
|
||||
use encoding::label::encoding_from_whatwg_label;
|
||||
|
@ -305,15 +305,9 @@ impl<'a> FileReaderMethods for &'a FileReader {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateFileReaderHelpers {
|
||||
fn dispatch_progress_event(self, type_: DOMString, loaded: u64, total: Option<u64>);
|
||||
fn terminate_ongoing_reading(self);
|
||||
fn read(self, function: FileReaderFunction, blob: &Blob, label: Option<DOMString>) -> ErrorResult;
|
||||
fn change_ready_state(self, state: FileReaderReadyState);
|
||||
}
|
||||
|
||||
impl<'a> PrivateFileReaderHelpers for &'a FileReader {
|
||||
fn dispatch_progress_event(self, type_: DOMString, loaded: u64, total: Option<u64>) {
|
||||
impl FileReader {
|
||||
fn dispatch_progress_event(&self, type_: DOMString, loaded: u64, total: Option<u64>) {
|
||||
|
||||
let global = self.global.root();
|
||||
let progressevent = ProgressEvent::new(global.r(),
|
||||
|
@ -325,12 +319,12 @@ impl<'a> PrivateFileReaderHelpers for &'a FileReader {
|
|||
event.fire(target);
|
||||
}
|
||||
|
||||
fn terminate_ongoing_reading(self) {
|
||||
fn terminate_ongoing_reading(&self) {
|
||||
let GenerationId(prev_id) = self.generation_id.get();
|
||||
self.generation_id.set(GenerationId(prev_id + 1));
|
||||
}
|
||||
|
||||
fn read(self, function: FileReaderFunction, blob: &Blob, label: Option<DOMString>) -> ErrorResult {
|
||||
fn read(&self, function: FileReaderFunction, blob: &Blob, label: Option<DOMString>) -> ErrorResult {
|
||||
let root = self.global.root();
|
||||
let global = root.r();
|
||||
// Step 1
|
||||
|
@ -368,7 +362,7 @@ impl<'a> PrivateFileReaderHelpers for &'a FileReader {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn change_ready_state(self, state: FileReaderReadyState) {
|
||||
fn change_ready_state(&self, state: FileReaderReadyState) {
|
||||
self.ready_state.set(state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,12 +120,9 @@ impl<'a> FormDataMethods for &'a FormData {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateFormDataHelpers {
|
||||
fn get_file_from_blob(self, value: &Blob, filename: Option<DOMString>) -> Root<File>;
|
||||
}
|
||||
|
||||
impl<'a> PrivateFormDataHelpers for &'a FormData {
|
||||
fn get_file_from_blob(self, value: &Blob, filename: Option<DOMString>) -> Root<File> {
|
||||
impl FormData {
|
||||
fn get_file_from_blob(&self, value: &Blob, filename: Option<DOMString>) -> Root<File> {
|
||||
let global = self.global.root();
|
||||
let f: Option<&File> = FileCast::to_ref(value);
|
||||
let name = filename.unwrap_or(f.map(|inner| inner.name().clone()).unwrap_or("blob".to_owned()));
|
||||
|
|
|
@ -14,15 +14,14 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
|
|||
use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementDerived, HTMLImageElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{MouseEventCast, NodeCast};
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::domtokenlist::DOMTokenList;
|
||||
use dom::element::{Element, AttributeHandlers, ElementTypeId};
|
||||
use dom::element::{Element, ElementTypeId};
|
||||
use dom::event::Event;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::node::{Node, NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::WindowHelpers;
|
||||
|
||||
use util::str::DOMString;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::InheritTypes::HTMLAppletElementDerived;
|
|||
use dom::bindings::codegen::InheritTypes::HTMLElementCast;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::{AttributeHandlers, ElementTypeId};
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
|
|
|
@ -14,7 +14,7 @@ use dom::domtokenlist::DOMTokenList;
|
|||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
use std::default::Default;
|
||||
|
|
|
@ -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::attr::{Attr, AttrHelpers};
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::codegen::Bindings::HTMLBaseElementBinding;
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::bindings::codegen::InheritTypes::HTMLBaseElementDerived;
|
||||
use dom::bindings::codegen::InheritTypes::HTMLElementCast;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::{ElementTypeId, AttributeHandlers};
|
||||
use dom::document::Document;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeTypeId, document_from_node};
|
||||
|
|
|
@ -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, AttrHelpers};
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{self, HTMLBodyElementMethods};
|
||||
|
@ -11,13 +11,12 @@ use dom::bindings::codegen::InheritTypes::{EventTargetCast};
|
|||
use dom::bindings::codegen::InheritTypes::{HTMLBodyElementDerived, HTMLElementCast};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::utils::Reflectable;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId, EventTargetHelpers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeTypeId, window_from_node, document_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::WindowHelpers;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
|
||||
|
@ -87,18 +86,14 @@ impl<'a> HTMLBodyElementMethods for &'a HTMLBodyElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLBodyElementHelpers {
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
fn get_background(self) -> Option<Url>;
|
||||
}
|
||||
|
||||
impl<'a> HTMLBodyElementHelpers for &'a HTMLBodyElement {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
impl HTMLBodyElement {
|
||||
pub fn get_background_color(&self) -> Option<RGBA> {
|
||||
self.background_color.get()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_background(self) -> Option<Url> {
|
||||
pub fn get_background(&self) -> Option<Url> {
|
||||
unsafe {
|
||||
self.background.borrow_for_layout().clone()
|
||||
}
|
||||
|
|
|
@ -4,21 +4,19 @@
|
|||
|
||||
use dom::activation::Activatable;
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLButtonElementCast, NodeCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLButtonElementDerived, HTMLFieldSetElementDerived};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::ActivationElementHelpers;
|
||||
use dom::element::{AttributeHandlers, Element, ElementTypeId};
|
||||
use dom::element::{Element, ElementTypeId};
|
||||
use dom::event::Event;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::htmlformelement::{FormSubmitter, FormControl, HTMLFormElementHelpers};
|
||||
use dom::htmlformelement::{FormSubmitter, FormControl};
|
||||
use dom::htmlformelement::{SubmittedFrom};
|
||||
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::node::{Node, NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::validitystate::ValidityState;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::HTMLCanvasElementMethods;
|
||||
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes;
|
||||
|
@ -15,7 +14,6 @@ use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, HeapGCValue, Root};
|
|||
use dom::bindings::utils::{Reflectable};
|
||||
use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::element::AttributeHandlers;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
|
@ -153,17 +151,9 @@ impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLCanvasElementHelpers {
|
||||
fn get_or_init_2d_context(self) -> Option<Root<CanvasRenderingContext2D>>;
|
||||
fn get_or_init_webgl_context(self,
|
||||
cx: *mut JSContext,
|
||||
attrs: Option<HandleValue>) -> Option<Root<WebGLRenderingContext>>;
|
||||
|
||||
fn is_valid(self) -> bool;
|
||||
}
|
||||
|
||||
impl<'a> HTMLCanvasElementHelpers for &'a HTMLCanvasElement {
|
||||
fn get_or_init_2d_context(self) -> Option<Root<CanvasRenderingContext2D>> {
|
||||
impl HTMLCanvasElement {
|
||||
pub fn get_or_init_2d_context(&self) -> Option<Root<CanvasRenderingContext2D>> {
|
||||
if self.context.get().is_none() {
|
||||
let window = window_from_node(self);
|
||||
let size = self.get_size();
|
||||
|
@ -177,7 +167,7 @@ impl<'a> HTMLCanvasElementHelpers for &'a HTMLCanvasElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_or_init_webgl_context(self,
|
||||
pub fn get_or_init_webgl_context(&self,
|
||||
cx: *mut JSContext,
|
||||
attrs: Option<HandleValue>) -> Option<Root<WebGLRenderingContext>> {
|
||||
if self.context.get().is_none() {
|
||||
|
@ -210,7 +200,7 @@ impl<'a> HTMLCanvasElementHelpers for &'a HTMLCanvasElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_valid(self) -> bool {
|
||||
pub fn is_valid(&self) -> bool {
|
||||
self.height.get() != 0 && self.width.get() != 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::bindings::utils::{namespace_from_domstring, Reflector, reflect_dom_object};
|
||||
use dom::element::{Element, AttributeHandlers, ElementHelpers};
|
||||
use dom::node::{Node, NodeHelpers, TreeIterator};
|
||||
use dom::element::Element;
|
||||
use dom::node::{Node, TreeIterator};
|
||||
use dom::window::Window;
|
||||
use util::str::{DOMString, split_html_space_chars};
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::attr::AttrValue;
|
||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::HTMLElementBinding;
|
||||
|
@ -18,16 +17,15 @@ use dom::bindings::error::ErrorResult;
|
|||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::bindings::utils::Reflectable;
|
||||
use dom::cssstyledeclaration::{CSSStyleDeclaration, CSSModificationAccess};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::domstringmap::DOMStringMap;
|
||||
use dom::element::{Element, ElementTypeId, ActivationElementHelpers, AttributeHandlers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::element::{Element, ElementTypeId};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlinputelement::HTMLInputElement;
|
||||
use dom::htmlmediaelement::HTMLMediaElementTypeId;
|
||||
use dom::htmltablecellelement::HTMLTableCellElementTypeId;
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node, SEQUENTIALLY_FOCUSABLE};
|
||||
use dom::node::{Node, NodeTypeId, document_from_node, window_from_node, SEQUENTIALLY_FOCUSABLE};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::WindowHelpers;
|
||||
|
||||
use msg::constellation_msg::FocusType;
|
||||
use util::str::DOMString;
|
||||
|
@ -81,18 +79,14 @@ impl HTMLElement {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateHTMLElementHelpers {
|
||||
fn is_body_or_frameset(self) -> bool;
|
||||
fn update_sequentially_focusable_status(self);
|
||||
}
|
||||
|
||||
impl<'a> PrivateHTMLElementHelpers for &'a HTMLElement {
|
||||
fn is_body_or_frameset(self) -> bool {
|
||||
impl HTMLElement {
|
||||
fn is_body_or_frameset(&self) -> bool {
|
||||
let eventtarget = EventTargetCast::from_ref(self);
|
||||
eventtarget.is_htmlbodyelement() || eventtarget.is_htmlframesetelement()
|
||||
}
|
||||
|
||||
fn update_sequentially_focusable_status(self) {
|
||||
fn update_sequentially_focusable_status(&self) {
|
||||
let element = ElementCast::from_ref(self);
|
||||
let node = NodeCast::from_ref(self);
|
||||
if element.has_attribute(&atom!("tabindex")) {
|
||||
|
@ -276,11 +270,6 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#attr-data-*
|
||||
pub trait HTMLElementCustomAttributeHelpers {
|
||||
fn set_custom_attr(self, name: DOMString, value: DOMString) -> ErrorResult;
|
||||
fn get_custom_attr(self, name: DOMString) -> Option<DOMString>;
|
||||
fn delete_custom_attr(self, name: DOMString);
|
||||
}
|
||||
|
||||
fn to_snake_case(name: DOMString) -> DOMString {
|
||||
let mut attr_name = "data-".to_owned();
|
||||
|
@ -295,8 +284,8 @@ fn to_snake_case(name: DOMString) -> DOMString {
|
|||
attr_name
|
||||
}
|
||||
|
||||
impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
|
||||
fn set_custom_attr(self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||
impl HTMLElement {
|
||||
pub fn set_custom_attr(&self, name: DOMString, value: DOMString) -> ErrorResult {
|
||||
if name.chars()
|
||||
.skip_while(|&ch| ch != '\u{2d}')
|
||||
.nth(1).map_or(false, |ch| ch >= 'a' && ch <= 'z') {
|
||||
|
@ -306,7 +295,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
|
|||
element.set_custom_attribute(to_snake_case(name), value)
|
||||
}
|
||||
|
||||
fn get_custom_attr(self, local_name: DOMString) -> Option<DOMString> {
|
||||
pub fn get_custom_attr(&self, local_name: DOMString) -> Option<DOMString> {
|
||||
let element = ElementCast::from_ref(self);
|
||||
let local_name = Atom::from_slice(&to_snake_case(local_name));
|
||||
element.get_attribute(&ns!(""), &local_name).map(|attr| {
|
||||
|
@ -314,7 +303,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
|
|||
})
|
||||
}
|
||||
|
||||
fn delete_custom_attr(self, local_name: DOMString) {
|
||||
pub fn delete_custom_attr(&self, local_name: DOMString) {
|
||||
let element = ElementCast::from_ref(self);
|
||||
let local_name = Atom::from_slice(&to_snake_case(local_name));
|
||||
element.remove_attribute(&ns!(""), &local_name);
|
||||
|
|
|
@ -3,19 +3,17 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLLegendElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLFieldSetElementDerived, NodeCast};
|
||||
use dom::bindings::js::{Root, RootedReference};
|
||||
use dom::document::Document;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{AttributeHandlers, Element, ElementHelpers};
|
||||
use dom::element::{Element, ElementTypeId};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlcollection::{HTMLCollection, CollectionFilter};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, NodeTypeId, window_from_node};
|
||||
use dom::node::{Node, NodeTypeId, window_from_node};
|
||||
use dom::validitystate::ValidityState;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
|
|
|
@ -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, AttrHelpers};
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::codegen::Bindings::HTMLFontElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLFontElementDerived};
|
||||
|
@ -85,12 +85,9 @@ impl VirtualMethods for HTMLFontElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLFontElementHelpers {
|
||||
fn get_color(&self) -> Option<RGBA>;
|
||||
}
|
||||
|
||||
impl HTMLFontElementHelpers for HTMLFontElement {
|
||||
fn get_color(&self) -> Option<RGBA> {
|
||||
impl HTMLFontElement {
|
||||
pub fn get_color(&self) -> Option<RGBA> {
|
||||
self.color.get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,16 +18,14 @@ use dom::bindings::codegen::InheritTypes::HTMLInputElementCast;
|
|||
use dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementCast, NodeCast};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{Root};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::event::{Event, EventHelpers, EventBubbles, EventCancelable};
|
||||
use dom::document::Document;
|
||||
use dom::element::{Element, ElementTypeId};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlbuttonelement::{HTMLButtonElement};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::htmlinputelement::{HTMLInputElement, HTMLInputElementHelpers};
|
||||
use dom::htmltextareaelement::HTMLTextAreaElementHelpers;
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::htmlinputelement::HTMLInputElement;
|
||||
use dom::node::{Node, NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use hyper::header::ContentType;
|
||||
use hyper::method::Method;
|
||||
|
@ -161,17 +159,9 @@ pub enum ResetFrom {
|
|||
NotFromFormResetMethod
|
||||
}
|
||||
|
||||
pub trait HTMLFormElementHelpers {
|
||||
// https://html.spec.whatwg.org/multipage/#concept-form-submit
|
||||
fn submit(self, submit_method_flag: SubmittedFrom, submitter: FormSubmitter);
|
||||
// https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set
|
||||
fn get_form_dataset(self, submitter: Option<FormSubmitter>) -> Vec<FormDatum>;
|
||||
// https://html.spec.whatwg.org/multipage/#dom-form-reset
|
||||
fn reset(self, submit_method_flag: ResetFrom);
|
||||
}
|
||||
|
||||
impl<'a> HTMLFormElementHelpers for &'a HTMLFormElement {
|
||||
fn submit(self, _submit_method_flag: SubmittedFrom, submitter: FormSubmitter) {
|
||||
impl HTMLFormElement {
|
||||
pub fn submit(&self, _submit_method_flag: SubmittedFrom, submitter: FormSubmitter) {
|
||||
// Step 1
|
||||
let doc = document_from_node(self);
|
||||
let win = window_from_node(self);
|
||||
|
@ -235,7 +225,7 @@ impl<'a> HTMLFormElementHelpers for &'a HTMLFormElement {
|
|||
win.r().pipeline(), load_data)).unwrap();
|
||||
}
|
||||
|
||||
fn get_form_dataset<'b>(self, submitter: Option<FormSubmitter<'b>>) -> Vec<FormDatum> {
|
||||
pub fn get_form_dataset<'b>(&self, submitter: Option<FormSubmitter<'b>>) -> Vec<FormDatum> {
|
||||
fn clean_crlf(s: &str) -> DOMString {
|
||||
// https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set
|
||||
// Step 4
|
||||
|
@ -362,7 +352,7 @@ impl<'a> HTMLFormElementHelpers for &'a HTMLFormElement {
|
|||
ret
|
||||
}
|
||||
|
||||
fn reset(self, _reset_method_flag: ResetFrom) {
|
||||
pub fn reset(&self, _reset_method_flag: ResetFrom) {
|
||||
// https://html.spec.whatwg.org/multipage/#locked-for-reset
|
||||
if self.marked_for_reset.get() {
|
||||
return;
|
||||
|
|
|
@ -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, AttrHelpers, AttrHelpersForLayout, AttrValue};
|
||||
use dom::attr::{Attr, AttrHelpersForLayout, AttrValue};
|
||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
|
@ -17,15 +17,13 @@ use dom::bindings::js::{Root};
|
|||
use dom::bindings::utils::Reflectable;
|
||||
use dom::customevent::CustomEvent;
|
||||
use dom::document::Document;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{self, AttributeHandlers};
|
||||
use dom::event::EventHelpers;
|
||||
use dom::element::{ElementTypeId, self};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
||||
use dom::node::{Node, NodeTypeId, window_from_node};
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::{Window, WindowHelpers};
|
||||
use dom::window::Window;
|
||||
use page::IterablePage;
|
||||
|
||||
use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
|
||||
|
@ -70,28 +68,14 @@ impl HTMLIFrameElementDerived for EventTarget {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLIFrameElementHelpers {
|
||||
fn is_sandboxed(self) -> bool;
|
||||
fn get_url(self) -> Option<Url>;
|
||||
/// https://www.whatwg.org/html/#process-the-iframe-attributes
|
||||
fn process_the_iframe_attributes(self);
|
||||
fn generate_new_subpage_id(self) -> (SubpageId, Option<SubpageId>);
|
||||
fn navigate_child_browsing_context(self, url: Url);
|
||||
fn dispatch_mozbrowser_event(self, event: MozBrowserEvent);
|
||||
fn update_subpage_id(self, new_subpage_id: SubpageId);
|
||||
}
|
||||
|
||||
pub trait RawHTMLIFrameElementHelpers {
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl<'a> HTMLIFrameElementHelpers for &'a HTMLIFrameElement {
|
||||
fn is_sandboxed(self) -> bool {
|
||||
impl HTMLIFrameElement {
|
||||
pub fn is_sandboxed(&self) -> bool {
|
||||
self.sandbox.get().is_some()
|
||||
}
|
||||
|
||||
fn get_url(self) -> Option<Url> {
|
||||
pub fn get_url(&self) -> Option<Url> {
|
||||
let element = ElementCast::from_ref(self);
|
||||
element.get_attribute(&ns!(""), &atom!("src")).and_then(|src| {
|
||||
let url = src.r().value();
|
||||
|
@ -105,7 +89,7 @@ impl<'a> HTMLIFrameElementHelpers for &'a HTMLIFrameElement {
|
|||
})
|
||||
}
|
||||
|
||||
fn generate_new_subpage_id(self) -> (SubpageId, Option<SubpageId>) {
|
||||
pub fn generate_new_subpage_id(&self) -> (SubpageId, Option<SubpageId>) {
|
||||
let old_subpage_id = self.subpage_id.get();
|
||||
let win = window_from_node(self);
|
||||
let subpage_id = win.r().get_next_subpage_id();
|
||||
|
@ -113,7 +97,7 @@ impl<'a> HTMLIFrameElementHelpers for &'a HTMLIFrameElement {
|
|||
(subpage_id, old_subpage_id)
|
||||
}
|
||||
|
||||
fn navigate_child_browsing_context(self, url: Url) {
|
||||
pub fn navigate_child_browsing_context(&self, url: Url) {
|
||||
let sandboxed = if self.is_sandboxed() {
|
||||
IFrameSandboxed
|
||||
} else {
|
||||
|
@ -139,7 +123,7 @@ impl<'a> HTMLIFrameElementHelpers for &'a HTMLIFrameElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn process_the_iframe_attributes(self) {
|
||||
pub fn process_the_iframe_attributes(&self) {
|
||||
let url = match self.get_url() {
|
||||
Some(url) => url.clone(),
|
||||
None => Url::parse("about:blank").unwrap(),
|
||||
|
@ -148,7 +132,7 @@ impl<'a> HTMLIFrameElementHelpers for &'a HTMLIFrameElement {
|
|||
self.navigate_child_browsing_context(url);
|
||||
}
|
||||
|
||||
fn dispatch_mozbrowser_event(self, event: MozBrowserEvent) {
|
||||
pub fn dispatch_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||
// 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.
|
||||
|
@ -172,14 +156,14 @@ impl<'a> HTMLIFrameElementHelpers for &'a HTMLIFrameElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn update_subpage_id(self, new_subpage_id: SubpageId) {
|
||||
pub fn update_subpage_id(&self, new_subpage_id: SubpageId) {
|
||||
self.subpage_id.set(Some(new_subpage_id));
|
||||
}
|
||||
}
|
||||
|
||||
impl RawHTMLIFrameElementHelpers for HTMLIFrameElement {
|
||||
impl HTMLIFrameElement {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
pub fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
element::get_attr_for_layout(ElementCast::from_ref(&*self),
|
||||
&ns!(""),
|
||||
|
@ -190,7 +174,7 @@ impl RawHTMLIFrameElementHelpers for HTMLIFrameElement {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto {
|
||||
pub fn get_height(&self) -> LengthOrPercentageOrAuto {
|
||||
unsafe {
|
||||
element::get_attr_for_layout(ElementCast::from_ref(&*self),
|
||||
&ns!(""),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::{AttrHelpers, AttrValue};
|
||||
use dom::attr::AttrValue;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
|
||||
|
@ -14,15 +14,13 @@ use dom::bindings::error::Fallible;
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{LayoutJS, Root};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::AttributeHandlers;
|
||||
use dom::document::Document;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable, EventHelpers};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{document_from_node, Node, NodeTypeId, NodeHelpers, NodeDamage, window_from_node};
|
||||
use dom::node::{document_from_node, Node, NodeTypeId, NodeDamage, window_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::WindowHelpers;
|
||||
use script_task::{Runnable, ScriptChan, CommonScriptMsg};
|
||||
use string_cache::Atom;
|
||||
use util::str::DOMString;
|
||||
|
@ -51,19 +49,13 @@ impl HTMLImageElementDerived for EventTarget {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLImageElementHelpers {
|
||||
fn get_url(&self) -> Option<Url>;
|
||||
}
|
||||
|
||||
impl<'a> HTMLImageElementHelpers for &'a HTMLImageElement {
|
||||
fn get_url(&self) -> Option<Url>{
|
||||
impl HTMLImageElement {
|
||||
pub fn get_url(&self) -> Option<Url>{
|
||||
self.url.borrow().clone()
|
||||
}
|
||||
}
|
||||
|
||||
trait PrivateHTMLImageElementHelpers {
|
||||
fn update_image(self, value: Option<(DOMString, &Url)>);
|
||||
}
|
||||
|
||||
struct ImageResponseHandlerRunnable {
|
||||
element: Trusted<HTMLImageElement>,
|
||||
|
@ -112,10 +104,10 @@ impl Runnable for ImageResponseHandlerRunnable {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> PrivateHTMLImageElementHelpers for &'a HTMLImageElement {
|
||||
impl HTMLImageElement {
|
||||
/// Makes the local `image` member match the status of the `src` attribute and starts
|
||||
/// prefetching the image. This method must be called after `src` is changed.
|
||||
fn update_image(self, value: Option<(DOMString, &Url)>) {
|
||||
fn update_image(&self, value: Option<(DOMString, &Url)>) {
|
||||
let node = NodeCast::from_ref(self);
|
||||
let document = node.owner_doc();
|
||||
let window = document.r().window();
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::activation::Activatable;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||
|
@ -16,20 +15,17 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLInp
|
|||
use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLFieldSetElementDerived, EventTargetCast};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, LayoutJS, Root, RootedReference};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{AttributeHandlers, Element};
|
||||
use dom::element::{RawLayoutElementHelpers, ActivationElementHelpers};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable, EventHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::element::{Element, ElementTypeId, RawLayoutElementHelpers};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::htmlformelement::{FormSubmitter, FormControl, HTMLFormElement, HTMLFormElementHelpers};
|
||||
use dom::htmlformelement::{FormSubmitter, FormControl, HTMLFormElement};
|
||||
use dom::htmlformelement::{SubmittedFrom, ResetFrom};
|
||||
use dom::keyboardevent::KeyboardEvent;
|
||||
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, NodeDamage, NodeTypeId};
|
||||
use dom::node::{Node, NodeDamage, NodeTypeId};
|
||||
use dom::node::{document_from_node, window_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::WindowHelpers;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use textinput::KeyReaction::{TriggerDefaultAction, DispatchInput, Nothing};
|
||||
use textinput::Lines::Single;
|
||||
|
@ -331,16 +327,6 @@ impl<'a> HTMLInputElementMethods for &'a HTMLInputElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLInputElementHelpers {
|
||||
fn force_relayout(self);
|
||||
fn radio_group_updated(self, group: Option<&str>);
|
||||
fn get_radio_group_name(self) -> Option<String>;
|
||||
fn update_checked_state(self, checked: bool, dirty: bool);
|
||||
fn get_size(self) -> u32;
|
||||
fn get_indeterminate_state(self) -> bool;
|
||||
fn mutable(self) -> bool;
|
||||
fn reset(self);
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&str>) {
|
||||
|
@ -384,27 +370,27 @@ fn in_same_group<'a,'b>(other: &'a HTMLInputElement,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> HTMLInputElementHelpers for &'a HTMLInputElement {
|
||||
fn force_relayout(self) {
|
||||
impl HTMLInputElement {
|
||||
pub fn force_relayout(&self) {
|
||||
let doc = document_from_node(self);
|
||||
let node = NodeCast::from_ref(self);
|
||||
doc.r().content_changed(node, NodeDamage::OtherNodeDamage)
|
||||
}
|
||||
|
||||
fn radio_group_updated(self, group: Option<&str>) {
|
||||
pub fn radio_group_updated(&self, group: Option<&str>) {
|
||||
if self.Checked() {
|
||||
broadcast_radio_checked(self, group);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_radio_group_name(self) -> Option<String> {
|
||||
pub fn get_radio_group_name(&self) -> Option<String> {
|
||||
//TODO: determine form owner
|
||||
let elem = ElementCast::from_ref(self);
|
||||
elem.get_attribute(&ns!(""), &atom!("name"))
|
||||
.map(|name| name.r().Value())
|
||||
}
|
||||
|
||||
fn update_checked_state(self, checked: bool, dirty: bool) {
|
||||
pub fn update_checked_state(&self, checked: bool, dirty: bool) {
|
||||
self.checked.set(checked);
|
||||
|
||||
if dirty {
|
||||
|
@ -422,16 +408,16 @@ impl<'a> HTMLInputElementHelpers for &'a HTMLInputElement {
|
|||
//TODO: dispatch change event
|
||||
}
|
||||
|
||||
fn get_size(self) -> u32 {
|
||||
pub fn get_size(&self) -> u32 {
|
||||
self.size.get()
|
||||
}
|
||||
|
||||
fn get_indeterminate_state(self) -> bool {
|
||||
pub fn get_indeterminate_state(&self) -> bool {
|
||||
self.indeterminate.get()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#concept-fe-mutable
|
||||
fn mutable(self) -> bool {
|
||||
pub fn mutable(&self) -> bool {
|
||||
// https://html.spec.whatwg.org/multipage/#the-input-element:concept-fe-mutable
|
||||
// https://html.spec.whatwg.org/multipage/#the-readonly-attribute:concept-fe-mutable
|
||||
let node = NodeCast::from_ref(self);
|
||||
|
@ -439,7 +425,7 @@ impl<'a> HTMLInputElementHelpers for &'a HTMLInputElement {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-input-element:concept-form-reset-control
|
||||
fn reset(self) {
|
||||
pub fn reset(&self) {
|
||||
match self.input_type.get() {
|
||||
InputType::InputRadio | InputType::InputCheckbox => {
|
||||
self.update_checked_state(self.DefaultChecked(), false);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use cssparser::Parser as CssParser;
|
||||
use document_loader::LoadType;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods;
|
||||
|
@ -15,16 +14,14 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::bindings::js::{RootedReference};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::domtokenlist::DOMTokenList;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{AttributeHandlers, Element};
|
||||
use dom::event::{EventBubbles, EventCancelable, Event, EventHelpers};
|
||||
use dom::element::{Element, ElementTypeId};
|
||||
use dom::event::{EventBubbles, EventCancelable, Event};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId, window_from_node};
|
||||
use dom::node::{Node, NodeTypeId, window_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::WindowHelpers;
|
||||
use layout_interface::{LayoutChan, Msg};
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
|
@ -167,13 +164,9 @@ impl VirtualMethods for HTMLLinkElement {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateHTMLLinkElementHelpers {
|
||||
fn handle_stylesheet_url(self, href: &str);
|
||||
fn handle_favicon_url(self, href: &str);
|
||||
}
|
||||
|
||||
impl<'a> PrivateHTMLLinkElementHelpers for &'a HTMLLinkElement {
|
||||
fn handle_stylesheet_url(self, href: &str) {
|
||||
impl HTMLLinkElement {
|
||||
fn handle_stylesheet_url(&self, href: &str) {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
match UrlParser::new().base_url(&window.get_url()).parse(href) {
|
||||
|
@ -201,7 +194,7 @@ impl<'a> PrivateHTMLLinkElementHelpers for &'a HTMLLinkElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_favicon_url(self, href: &str) {
|
||||
fn handle_favicon_url(&self, href: &str) {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
match UrlParser::new().base_url(&window.get_url()).parse(href) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLObjectElementBinding;
|
||||
|
@ -12,11 +11,10 @@ use dom::bindings::codegen::InheritTypes::HTMLObjectElementDerived;
|
|||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::AttributeHandlers;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeTypeId, NodeHelpers, window_from_node};
|
||||
use dom::node::{Node, NodeTypeId, window_from_node};
|
||||
use dom::validitystate::ValidityState;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
|
|
|
@ -3,18 +3,16 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding::HTMLOptGroupElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLOptGroupElementDerived, HTMLOptionElementDerived};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::AttributeHandlers;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
use util::str::DOMString;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
|
||||
|
@ -14,10 +13,9 @@ use dom::bindings::codegen::InheritTypes::{HTMLScriptElementDerived};
|
|||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{AttributeHandlers, ElementHelpers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
use util::str::{DOMString, split_html_space_chars};
|
||||
|
|
|
@ -6,7 +6,6 @@ use std::ascii::AsciiExt;
|
|||
|
||||
use document_loader::LoadType;
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
|
@ -21,17 +20,15 @@ use dom::bindings::js::RootedReference;
|
|||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{AttributeHandlers, ElementCreator};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable, EventHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::element::{ElementCreator, ElementTypeId};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node, NodeHelpers};
|
||||
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node};
|
||||
use dom::node::{NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::servohtmlparser::ServoHTMLParserHelpers;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::{WindowHelpers, ScriptHelpers};
|
||||
use dom::window::ScriptHelpers;
|
||||
use js::jsapi::RootedValue;
|
||||
use js::jsval::UndefinedValue;
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
|
@ -110,35 +107,6 @@ impl HTMLScriptElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLScriptElementHelpers {
|
||||
/// Prepare a script (<https://www.whatwg.org/html/#prepare-a-script>)
|
||||
fn prepare(self) -> NextParserState;
|
||||
|
||||
/// [Execute a script block]
|
||||
/// (https://html.spec.whatwg.org/multipage/#execute-the-script-block)
|
||||
fn execute(self, load: ScriptOrigin);
|
||||
|
||||
/// Prepare a script, steps 6 and 7.
|
||||
fn is_javascript(self) -> bool;
|
||||
|
||||
/// Set the "already started" flag (<https://whatwg.org/html/#already-started>)
|
||||
fn mark_already_started(self);
|
||||
|
||||
// Queues error event
|
||||
fn queue_error_event(self);
|
||||
|
||||
/// Dispatch beforescriptexecute event.
|
||||
fn dispatch_before_script_execute_event(self) -> bool;
|
||||
|
||||
/// Dispatch afterscriptexecute event.
|
||||
fn dispatch_after_script_execute_event(self);
|
||||
|
||||
/// Dispatch load event.
|
||||
fn dispatch_load_event(self);
|
||||
|
||||
/// Dispatch error event.
|
||||
fn dispatch_error_event(self);
|
||||
}
|
||||
|
||||
/// Supported script types as defined by
|
||||
/// <https://whatwg.org/html/#support-the-scripting-language>.
|
||||
|
@ -212,8 +180,8 @@ impl AsyncResponseListener for ScriptContext {
|
|||
|
||||
impl PreInvoke for ScriptContext {}
|
||||
|
||||
impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
|
||||
fn prepare(self) -> NextParserState {
|
||||
impl HTMLScriptElement {
|
||||
pub fn prepare(&self) -> NextParserState {
|
||||
// https://html.spec.whatwg.org/multipage/#prepare-a-script
|
||||
// Step 1.
|
||||
if self.already_started.get() {
|
||||
|
@ -365,7 +333,7 @@ impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
|
|||
NextParserState::Continue
|
||||
}
|
||||
|
||||
fn execute(self, load: ScriptOrigin) {
|
||||
pub fn execute(&self, load: ScriptOrigin) {
|
||||
// Step 1.
|
||||
// TODO: If the element is flagged as "parser-inserted", but the
|
||||
// element's node document is not the Document of the parser that
|
||||
|
@ -462,7 +430,7 @@ impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn queue_error_event(self) {
|
||||
pub fn queue_error_event(&self) {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let chan = window.script_chan();
|
||||
|
@ -474,31 +442,31 @@ impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
|
|||
chan.send(CommonScriptMsg::RunnableMsg(dispatcher)).unwrap();
|
||||
}
|
||||
|
||||
fn dispatch_before_script_execute_event(self) -> bool {
|
||||
pub fn dispatch_before_script_execute_event(&self) -> bool {
|
||||
self.dispatch_event("beforescriptexecute".to_owned(),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::Cancelable)
|
||||
}
|
||||
|
||||
fn dispatch_after_script_execute_event(self) {
|
||||
pub fn dispatch_after_script_execute_event(&self) {
|
||||
self.dispatch_event("afterscriptexecute".to_owned(),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable);
|
||||
}
|
||||
|
||||
fn dispatch_load_event(self) {
|
||||
pub fn dispatch_load_event(&self) {
|
||||
self.dispatch_event("load".to_owned(),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable);
|
||||
}
|
||||
|
||||
fn dispatch_error_event(self) {
|
||||
pub fn dispatch_error_event(&self) {
|
||||
self.dispatch_event("error".to_owned(),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable);
|
||||
}
|
||||
|
||||
fn is_javascript(self) -> bool {
|
||||
pub fn is_javascript(&self) -> bool {
|
||||
let element = ElementCast::from_ref(self);
|
||||
match element.get_attribute(&ns!(""), &atom!("type")).map(|s| s.r().Value()) {
|
||||
Some(ref s) if s.is_empty() => {
|
||||
|
@ -531,20 +499,14 @@ impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn mark_already_started(self) {
|
||||
pub fn mark_already_started(&self) {
|
||||
self.already_started.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
trait PrivateHTMLScriptElementHelpers {
|
||||
fn dispatch_event(self,
|
||||
type_: DOMString,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> bool;
|
||||
}
|
||||
|
||||
impl<'a> PrivateHTMLScriptElementHelpers for &'a HTMLScriptElement {
|
||||
fn dispatch_event(self,
|
||||
impl HTMLScriptElement {
|
||||
fn dispatch_event(&self,
|
||||
type_: DOMString,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> bool {
|
||||
|
|
|
@ -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, AttrHelpers, AttrValue};
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
||||
|
@ -11,11 +11,10 @@ use dom::bindings::codegen::UnionTypes::HTMLElementOrLong;
|
|||
use dom::bindings::codegen::UnionTypes::HTMLOptionElementOrHTMLOptGroupElement;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::AttributeHandlers;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, NodeTypeId, window_from_node};
|
||||
use dom::node::{Node, NodeTypeId, window_from_node};
|
||||
use dom::validitystate::ValidityState;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
|
|
|
@ -3,19 +3,17 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::Parser as CssParser;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::codegen::Bindings::HTMLStyleElementBinding;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLStyleElementDerived, NodeCast};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::{ElementTypeId, AttributeHandlers};
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::window_from_node;
|
||||
use dom::node::{ChildrenMutation, Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{ChildrenMutation, Node, NodeTypeId};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::WindowHelpers;
|
||||
use layout_interface::{LayoutChan, Msg};
|
||||
use style::media_queries::parse_media_query_list;
|
||||
use style::stylesheets::{Origin, Stylesheet};
|
||||
|
@ -52,12 +50,9 @@ impl HTMLStyleElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait StyleElementHelpers {
|
||||
fn parse_own_css(self);
|
||||
}
|
||||
|
||||
impl<'a> StyleElementHelpers for &'a HTMLStyleElement {
|
||||
fn parse_own_css(self) {
|
||||
impl HTMLStyleElement {
|
||||
pub fn parse_own_css(&self) {
|
||||
let node = NodeCast::from_ref(self);
|
||||
let element = ElementCast::from_ref(self);
|
||||
assert!(node.is_in_doc());
|
||||
|
|
|
@ -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, AttrHelpers, AttrValue};
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableCellElementDerived};
|
||||
use dom::document::Document;
|
||||
|
@ -80,22 +80,17 @@ impl<'a> HTMLTableCellElementMethods for &'a HTMLTableCellElement {
|
|||
make_uint_setter!(SetColSpan, "colspan");
|
||||
}
|
||||
|
||||
pub trait HTMLTableCellElementHelpers {
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
fn get_colspan(self) -> Option<u32>;
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl<'a> HTMLTableCellElementHelpers for &'a HTMLTableCellElement {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
impl HTMLTableCellElement {
|
||||
pub fn get_background_color(&self) -> Option<RGBA> {
|
||||
self.background_color.get()
|
||||
}
|
||||
|
||||
fn get_colspan(self) -> Option<u32> {
|
||||
pub fn get_colspan(&self) -> Option<u32> {
|
||||
self.colspan.get()
|
||||
}
|
||||
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
pub fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
self.width.get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, AttrHelpers, AttrValue};
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::codegen::Bindings::HTMLTableElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
|
@ -11,12 +11,12 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLTab
|
|||
use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, NodeCast};
|
||||
use dom::bindings::js::{Root, RootedReference};
|
||||
use dom::document::Document;
|
||||
use dom::element::{ElementHelpers, ElementTypeId};
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
|
||||
use dom::htmltablesectionelement::HTMLTableSectionElement;
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node};
|
||||
use dom::node::{Node, NodeTypeId, document_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
use util::str::{self, DOMString, LengthOrPercentageOrAuto};
|
||||
|
@ -132,27 +132,21 @@ impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLTableElementHelpers {
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
fn get_border(self) -> Option<u32>;
|
||||
fn get_cellspacing(self) -> Option<u32>;
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
||||
impl<'a> HTMLTableElementHelpers for &'a HTMLTableElement {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
impl HTMLTableElement {
|
||||
pub fn get_background_color(&self) -> Option<RGBA> {
|
||||
self.background_color.get()
|
||||
}
|
||||
|
||||
fn get_border(self) -> Option<u32> {
|
||||
pub fn get_border(&self) -> Option<u32> {
|
||||
self.border.get()
|
||||
}
|
||||
|
||||
fn get_cellspacing(self) -> Option<u32> {
|
||||
pub fn get_cellspacing(&self) -> Option<u32> {
|
||||
self.cellspacing.get()
|
||||
}
|
||||
|
||||
fn get_width(self) -> LengthOrPercentageOrAuto {
|
||||
pub fn get_width(&self) -> LengthOrPercentageOrAuto {
|
||||
self.width.get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, AttrHelpers};
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::codegen::Bindings::HTMLTableRowElementBinding;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableRowElementDerived};
|
||||
use dom::bindings::js::Root;
|
||||
|
@ -53,12 +53,9 @@ impl HTMLTableRowElement {
|
|||
}
|
||||
|
||||
|
||||
pub trait HTMLTableRowElementHelpers {
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
}
|
||||
|
||||
impl<'a> HTMLTableRowElementHelpers for &'a HTMLTableRowElement {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
impl HTMLTableRowElement {
|
||||
pub fn get_background_color(&self) -> Option<RGBA> {
|
||||
self.background_color.get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, AttrHelpers};
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding;
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableSectionElementDerived};
|
||||
use dom::bindings::js::Root;
|
||||
|
@ -51,12 +51,9 @@ impl HTMLTableSectionElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLTableSectionElementHelpers {
|
||||
fn get_background_color(self) -> Option<RGBA>;
|
||||
}
|
||||
|
||||
impl<'a> HTMLTableSectionElementHelpers for &'a HTMLTableSectionElement {
|
||||
fn get_background_color(self) -> Option<RGBA> {
|
||||
impl HTMLTableSectionElement {
|
||||
pub fn get_background_color(&self) -> Option<RGBA> {
|
||||
self.background_color.get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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::AttrHelpers;
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||
|
@ -15,18 +14,16 @@ use dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementDerived, HTMLField
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{LayoutJS, Root};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::document::Document;
|
||||
use dom::element::{Element, ElementTypeId};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::htmlformelement::FormControl;
|
||||
use dom::keyboardevent::KeyboardEvent;
|
||||
use dom::node::{ChildrenMutation, DisabledStateHelpers, Node, NodeDamage};
|
||||
use dom::node::{NodeHelpers, NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::node::{ChildrenMutation, Node, NodeDamage};
|
||||
use dom::node::{NodeTypeId, document_from_node, window_from_node};
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom::window::WindowHelpers;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use script_task::{Runnable, CommonScriptMsg};
|
||||
use textinput::{TextInput, Lines, KeyReaction};
|
||||
|
@ -203,37 +200,29 @@ impl<'a> HTMLTextAreaElementMethods for &'a HTMLTextAreaElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLTextAreaElementHelpers {
|
||||
fn mutable(self) -> bool;
|
||||
fn reset(self);
|
||||
}
|
||||
|
||||
impl<'a> HTMLTextAreaElementHelpers for &'a HTMLTextAreaElement {
|
||||
impl HTMLTextAreaElement {
|
||||
// https://html.spec.whatwg.org/multipage/#concept-fe-mutable
|
||||
fn mutable(self) -> bool {
|
||||
pub fn mutable(&self) -> bool {
|
||||
// https://html.spec.whatwg.org/multipage/#the-textarea-element:concept-fe-mutable
|
||||
!(self.Disabled() || self.ReadOnly())
|
||||
}
|
||||
fn reset(self) {
|
||||
pub fn reset(&self) {
|
||||
// https://html.spec.whatwg.org/multipage/#the-textarea-element:concept-form-reset-control
|
||||
self.SetValue(self.DefaultValue());
|
||||
self.value_changed.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
trait PrivateHTMLTextAreaElementHelpers {
|
||||
fn force_relayout(self);
|
||||
fn dispatch_change_event(self);
|
||||
}
|
||||
|
||||
impl<'a> PrivateHTMLTextAreaElementHelpers for &'a HTMLTextAreaElement {
|
||||
fn force_relayout(self) {
|
||||
impl HTMLTextAreaElement {
|
||||
fn force_relayout(&self) {
|
||||
let doc = document_from_node(self);
|
||||
let node = NodeCast::from_ref(self);
|
||||
doc.r().content_changed(node, NodeDamage::OtherNodeDamage)
|
||||
}
|
||||
|
||||
fn dispatch_change_event(self) {
|
||||
fn dispatch_change_event(&self) {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let event = Event::new(GlobalRef::Window(window),
|
||||
|
|
|
@ -8,12 +8,11 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
|||
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, TextCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTitleElementDerived, NodeCast};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::characterdata::CharacterDataHelpers;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{ChildrenMutation, Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{ChildrenMutation, Node, NodeTypeId};
|
||||
use dom::text::Text;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use util::str::DOMString;
|
||||
|
|
|
@ -51,14 +51,10 @@ impl ImageData {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait ImageDataHelpers {
|
||||
fn get_data_array(self, global: &GlobalRef) -> Vec<u8>;
|
||||
fn get_size(self) -> Size2D<i32>;
|
||||
}
|
||||
|
||||
impl<'a> ImageDataHelpers for &'a ImageData {
|
||||
impl ImageData {
|
||||
#[allow(unsafe_code)]
|
||||
fn get_data_array(self, global: &GlobalRef) -> Vec<u8> {
|
||||
pub fn get_data_array(&self, global: &GlobalRef) -> Vec<u8> {
|
||||
unsafe {
|
||||
let cx = global.get_cx();
|
||||
let data: *const uint8_t = JS_GetUint8ClampedArrayData(self.Data(cx), ptr::null()) as *const uint8_t;
|
||||
|
@ -67,7 +63,7 @@ impl<'a> ImageDataHelpers for &'a ImageData {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_size(self) -> Size2D<i32> {
|
||||
pub fn get_size(&self) -> Size2D<i32> {
|
||||
Size2D::new(self.Width() as i32, self.Height() as i32)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,17 +135,13 @@ impl KeyboardEvent {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait KeyboardEventHelpers {
|
||||
fn get_key(self) -> Option<Key>;
|
||||
fn get_key_modifiers(self) -> KeyModifiers;
|
||||
}
|
||||
|
||||
impl<'a> KeyboardEventHelpers for &'a KeyboardEvent {
|
||||
fn get_key(self) -> Option<Key> {
|
||||
impl KeyboardEvent {
|
||||
pub fn get_key(&self) -> Option<Key> {
|
||||
self.key.get().clone()
|
||||
}
|
||||
|
||||
fn get_key_modifiers(self) -> KeyModifiers {
|
||||
pub fn get_key_modifiers(&self) -> KeyModifiers {
|
||||
let mut result = KeyModifiers::empty();
|
||||
if self.shift.get() {
|
||||
result = result | constellation_msg::SHIFT;
|
||||
|
|
|
@ -10,7 +10,6 @@ use dom::bindings::str::USVString;
|
|||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use dom::window::Window;
|
||||
use dom::window::WindowHelpers;
|
||||
|
||||
use url::{Url, UrlParser};
|
||||
use util::str::DOMString;
|
||||
|
@ -104,12 +103,9 @@ impl<'a> LocationMethods for &'a Location {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateLocationHelpers {
|
||||
fn get_url(self) -> Url;
|
||||
}
|
||||
|
||||
impl<'a> PrivateLocationHelpers for &'a Location {
|
||||
fn get_url(self) -> Url {
|
||||
impl Location {
|
||||
fn get_url(&self) -> Url {
|
||||
let window = self.window.root();
|
||||
window.r().get_url()
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ macro_rules! make_getter(
|
|||
( $attr:ident, $htmlname:expr ) => (
|
||||
fn $attr(self) -> DOMString {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let element = ElementCast::from_ref(self);
|
||||
element.get_string_attribute(&Atom::from_slice($htmlname))
|
||||
|
@ -23,7 +22,6 @@ macro_rules! make_bool_getter(
|
|||
( $attr:ident, $htmlname:expr ) => (
|
||||
fn $attr(self) -> bool {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let element = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not runtime.
|
||||
|
@ -40,7 +38,6 @@ macro_rules! make_uint_getter(
|
|||
($attr:ident, $htmlname:expr, $default:expr) => (
|
||||
fn $attr(self) -> u32 {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let element = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not runtime.
|
||||
|
@ -60,7 +57,6 @@ macro_rules! make_url_getter(
|
|||
( $attr:ident, $htmlname:expr ) => (
|
||||
fn $attr(self) -> DOMString {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let element = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not runtime.
|
||||
|
@ -78,8 +74,6 @@ macro_rules! make_url_or_base_getter(
|
|||
( $attr:ident, $htmlname:expr ) => (
|
||||
fn $attr(self) -> DOMString {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use dom::window::WindowHelpers;
|
||||
use string_cache::Atom;
|
||||
let element = ElementCast::from_ref(self);
|
||||
let url = element.get_url_attribute(&Atom::from_slice($htmlname));
|
||||
|
@ -101,7 +95,6 @@ macro_rules! make_enumerated_getter(
|
|||
( $attr:ident, $htmlname:expr, $default:expr, $(($choices: pat))|+) => (
|
||||
fn $attr(self) -> DOMString {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use string_cache::Atom;
|
||||
|
@ -127,7 +120,6 @@ macro_rules! make_setter(
|
|||
( $attr:ident, $htmlname:expr ) => (
|
||||
fn $attr(self, value: DOMString) {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let element = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not at runtime.
|
||||
|
@ -141,7 +133,6 @@ macro_rules! make_bool_setter(
|
|||
( $attr:ident, $htmlname:expr ) => (
|
||||
fn $attr(self, value: bool) {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let element = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not at runtime.
|
||||
|
@ -155,7 +146,6 @@ macro_rules! make_uint_setter(
|
|||
($attr:ident, $htmlname:expr, $default:expr) => (
|
||||
fn $attr(self, value: u32) {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let value = if value > 2147483647 {
|
||||
$default
|
||||
|
@ -177,7 +167,6 @@ macro_rules! make_limited_uint_setter(
|
|||
($attr:ident, $htmlname:expr, $default:expr) => (
|
||||
fn $attr(self, value: u32) -> $crate::dom::bindings::error::ErrorResult {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let value = if value == 0 {
|
||||
return Err($crate::dom::bindings::error::Error::IndexSize);
|
||||
|
@ -205,7 +194,6 @@ macro_rules! make_atomic_setter(
|
|||
( $attr:ident, $htmlname:expr ) => (
|
||||
fn $attr(self, value: DOMString) {
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
use dom::element::AttributeHandlers;
|
||||
use string_cache::Atom;
|
||||
let element = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not at runtime.
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::error::Fallible;
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::utils::reflect_dom_object;
|
||||
use dom::event::{Event, EventHelpers, EventTypeId};
|
||||
use dom::event::{Event, EventTypeId};
|
||||
use dom::eventtarget::EventTarget;
|
||||
|
||||
use util::str::DOMString;
|
||||
|
|
|
@ -109,16 +109,10 @@
|
|||
//! Implementing methods for a DOM object
|
||||
//! =====================================
|
||||
//!
|
||||
//! XXX JSRef no longer exists - should we remove the *Helpers traits?
|
||||
//! In order to ensure that DOM objects are rooted when they are called, we
|
||||
//! require that all methods are implemented for `JSRef<'a, Foo>`. This means
|
||||
//! that all methods are defined on traits. Conventionally, those traits are
|
||||
//! called
|
||||
//!
|
||||
//! * `dom::bindings::codegen::Bindings::FooBindings::FooMethods` for methods
|
||||
//! defined through IDL;
|
||||
//! * `FooHelpers` for public methods;
|
||||
//! * `PrivateFooHelpers` for private methods.
|
||||
//! * `&self` public methods for public helpers;
|
||||
//! * `&self` methods for private helpers.
|
||||
//!
|
||||
//! Accessing fields of a DOM object
|
||||
//! ================================
|
||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::error::{Error, Fallible};
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::utils::{namespace_from_domstring, Reflector, reflect_dom_object};
|
||||
use dom::element::{AttributeHandlers, Element, ElementHelpers};
|
||||
use dom::element::Element;
|
||||
use dom::window::Window;
|
||||
use util::str::DOMString;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use devtools_traits::NodeInfo;
|
||||
use document_loader::DocumentLoader;
|
||||
use dom::attr::{Attr, AttrHelpers};
|
||||
use dom::attr::Attr;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||
|
@ -32,20 +32,19 @@ use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
|
|||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::bindings::trace::RootedVec;
|
||||
use dom::bindings::utils::{namespace_from_domstring, Reflectable, reflect_dom_object};
|
||||
use dom::characterdata::{CharacterData, CharacterDataHelpers, CharacterDataTypeId};
|
||||
use dom::characterdata::{CharacterData, CharacterDataTypeId};
|
||||
use dom::comment::Comment;
|
||||
use dom::document::{Document, DocumentHelpers, IsHTMLDocument, DocumentSource};
|
||||
use dom::document::{Document, IsHTMLDocument, DocumentSource};
|
||||
use dom::documentfragment::DocumentFragment;
|
||||
use dom::documenttype::DocumentType;
|
||||
use dom::element::ElementHelpers;
|
||||
use dom::element::{AttributeHandlers, Element, ElementCreator, ElementTypeId};
|
||||
use dom::element::{Element, ElementCreator, ElementTypeId};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::HTMLElementTypeId;
|
||||
use dom::nodelist::{NodeList, NodeListHelpers};
|
||||
use dom::processinginstruction::{ProcessingInstruction, ProcessingInstructionHelpers};
|
||||
use dom::nodelist::NodeList;
|
||||
use dom::processinginstruction::ProcessingInstruction;
|
||||
use dom::text::Text;
|
||||
use dom::virtualmethods::{VirtualMethods, vtable_for};
|
||||
use dom::window::{Window, WindowHelpers};
|
||||
use dom::window::Window;
|
||||
use euclid::rect::Rect;
|
||||
use layout_interface::{LayoutChan, Msg};
|
||||
use parse::html::parse_html_fragment;
|
||||
|
@ -295,16 +294,12 @@ pub enum NodeTypeId {
|
|||
Element(ElementTypeId),
|
||||
}
|
||||
|
||||
trait PrivateNodeHelpers {
|
||||
fn add_child(self, new_child: &Node, before: Option<&Node>);
|
||||
fn remove_child(self, child: &Node);
|
||||
}
|
||||
|
||||
impl<'a> PrivateNodeHelpers for &'a Node {
|
||||
impl Node {
|
||||
/// Adds a new child to the end of this node's list of children.
|
||||
///
|
||||
/// Fails unless `new_child` is disconnected from the tree.
|
||||
fn add_child(self, new_child: &Node, before: Option<&Node>) {
|
||||
fn add_child(&self, new_child: &Node, before: Option<&Node>) {
|
||||
assert!(new_child.parent_node.get().is_none());
|
||||
assert!(new_child.prev_sibling.get().is_none());
|
||||
assert!(new_child.next_sibling.get().is_none());
|
||||
|
@ -354,7 +349,7 @@ impl<'a> PrivateNodeHelpers for &'a Node {
|
|||
/// Removes the given child from this node's list of children.
|
||||
///
|
||||
/// Fails unless `child` is a child of this node.
|
||||
fn remove_child(self, child: &Node) {
|
||||
fn remove_child(&self, child: &Node) {
|
||||
assert!(child.parent_node.get().map(Root::from_rooted).r() == Some(self));
|
||||
let prev_sibling = child.GetPreviousSibling();
|
||||
match prev_sibling {
|
||||
|
@ -425,117 +420,9 @@ impl<'a> Iterator for QuerySelectorIterator {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait NodeHelpers {
|
||||
fn ancestors(self) -> AncestorIterator;
|
||||
fn inclusive_ancestors(self) -> AncestorIterator;
|
||||
fn children(self) -> NodeSiblingIterator;
|
||||
fn rev_children(self) -> ReverseSiblingIterator;
|
||||
fn child_elements(self) -> ChildElementIterator;
|
||||
fn following_siblings(self) -> NodeSiblingIterator;
|
||||
fn preceding_siblings(self) -> ReverseSiblingIterator;
|
||||
fn following_nodes(self, root: &Node) -> FollowingNodeIterator;
|
||||
fn preceding_nodes(self, root: &Node) -> PrecedingNodeIterator;
|
||||
fn descending_last_children(self) -> LastChildIterator;
|
||||
fn is_in_doc(self) -> bool;
|
||||
fn is_inclusive_ancestor_of(self, parent: &Node) -> bool;
|
||||
fn is_parent_of(self, child: &Node) -> bool;
|
||||
|
||||
fn type_id(self) -> NodeTypeId;
|
||||
fn len(self) -> u32;
|
||||
fn index(self) -> u32;
|
||||
fn children_count(self) -> u32;
|
||||
|
||||
fn owner_doc(self) -> Root<Document>;
|
||||
fn set_owner_doc(self, document: &Document);
|
||||
fn is_in_html_doc(self) -> bool;
|
||||
|
||||
fn is_doctype(self) -> bool;
|
||||
fn is_anchor_element(self) -> bool;
|
||||
|
||||
fn get_flag(self, flag: NodeFlags) -> bool;
|
||||
fn set_flag(self, flag: NodeFlags, value: bool);
|
||||
|
||||
fn get_hover_state(self) -> bool;
|
||||
fn set_hover_state(self, state: bool);
|
||||
|
||||
fn get_focus_state(self) -> bool;
|
||||
fn set_focus_state(self, state: bool);
|
||||
|
||||
fn get_active_state(self) -> bool;
|
||||
fn set_active_state(self, state: bool);
|
||||
|
||||
fn get_disabled_state(self) -> bool;
|
||||
fn set_disabled_state(self, state: bool);
|
||||
|
||||
fn get_enabled_state(self) -> bool;
|
||||
fn set_enabled_state(self, state: bool);
|
||||
|
||||
fn get_has_changed(self) -> bool;
|
||||
fn set_has_changed(self, state: bool);
|
||||
|
||||
fn get_is_dirty(self) -> bool;
|
||||
fn set_is_dirty(self, state: bool);
|
||||
|
||||
fn get_has_dirty_siblings(self) -> bool;
|
||||
fn set_has_dirty_siblings(self, state: bool);
|
||||
|
||||
fn get_has_dirty_descendants(self) -> bool;
|
||||
fn set_has_dirty_descendants(self, state: bool);
|
||||
|
||||
/// Marks the given node as `IS_DIRTY`, its siblings as `HAS_DIRTY_SIBLINGS` (to deal with
|
||||
/// sibling selectors), its ancestors as `HAS_DIRTY_DESCENDANTS`, and its descendants as
|
||||
/// `IS_DIRTY`. If anything more than the node's style was damaged, this method also sets the
|
||||
/// `HAS_CHANGED` flag.
|
||||
fn dirty(self, damage: NodeDamage);
|
||||
|
||||
/// Similar to `dirty`, but will always walk the ancestors to mark them dirty,
|
||||
/// too. This is useful when a node is reparented. The node will frequently
|
||||
/// already be marked as `changed` to skip double-dirties, but the ancestors
|
||||
/// still need to be marked as `HAS_DIRTY_DESCENDANTS`.
|
||||
///
|
||||
/// See #4170
|
||||
fn force_dirty_ancestors(self, damage: NodeDamage);
|
||||
|
||||
fn dirty_impl(self, damage: NodeDamage, force_ancestors: bool);
|
||||
|
||||
fn dump(self);
|
||||
fn dump_indent(self, indent: u32);
|
||||
fn debug_str(self) -> String;
|
||||
|
||||
fn traverse_preorder(self) -> TreeIterator;
|
||||
fn inclusively_following_siblings(self) -> NodeSiblingIterator;
|
||||
fn inclusively_preceding_siblings(self) -> ReverseSiblingIterator;
|
||||
|
||||
fn to_trusted_node_address(self) -> TrustedNodeAddress;
|
||||
|
||||
fn get_bounding_content_box(self) -> Rect<Au>;
|
||||
fn get_content_boxes(self) -> Vec<Rect<Au>>;
|
||||
fn get_client_rect(self) -> Rect<i32>;
|
||||
|
||||
fn before(self, nodes: Vec<NodeOrString>) -> ErrorResult;
|
||||
fn after(self, nodes: Vec<NodeOrString>) -> ErrorResult;
|
||||
fn replace_with(self, nodes: Vec<NodeOrString>) -> ErrorResult;
|
||||
fn prepend(self, nodes: Vec<NodeOrString>) -> ErrorResult;
|
||||
fn append(self, nodes: Vec<NodeOrString>) -> ErrorResult;
|
||||
|
||||
fn query_selector(self, selectors: DOMString) -> Fallible<Option<Root<Element>>>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn query_selector_iter(self, selectors: DOMString) -> Fallible<QuerySelectorIterator>;
|
||||
fn query_selector_all(self, selectors: DOMString) -> Fallible<Root<NodeList>>;
|
||||
|
||||
fn remove_self(self);
|
||||
|
||||
fn get_unique_id(self) -> String;
|
||||
fn summarize(self) -> NodeInfo;
|
||||
|
||||
fn teardown(self);
|
||||
|
||||
fn parse_fragment(self, markup: DOMString) -> Fallible<Root<DocumentFragment>>;
|
||||
|
||||
}
|
||||
|
||||
impl<'a> NodeHelpers for &'a Node {
|
||||
fn teardown(self) {
|
||||
impl Node {
|
||||
pub fn teardown(&self) {
|
||||
self.layout_data.dispose(self);
|
||||
for kid in self.children() {
|
||||
kid.r().teardown();
|
||||
|
@ -543,12 +430,12 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
/// Dumps the subtree rooted at this node, for debugging.
|
||||
fn dump(self) {
|
||||
pub fn dump(&self) {
|
||||
self.dump_indent(0);
|
||||
}
|
||||
|
||||
/// Dumps the node tree, for debugging, with indentation.
|
||||
fn dump_indent(self, indent: u32) {
|
||||
pub fn dump_indent(&self, indent: u32) {
|
||||
let mut s = String::new();
|
||||
for _ in 0..indent {
|
||||
s.push_str(" ");
|
||||
|
@ -564,21 +451,21 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
/// Returns a string that describes this node.
|
||||
fn debug_str(self) -> String {
|
||||
pub fn debug_str(&self) -> String {
|
||||
format!("{:?}", self.type_id)
|
||||
}
|
||||
|
||||
fn is_in_doc(self) -> bool {
|
||||
pub fn is_in_doc(&self) -> bool {
|
||||
self.flags.get().contains(IS_IN_DOC)
|
||||
}
|
||||
|
||||
/// Returns the type ID of this node. Fails if this node is borrowed mutably.
|
||||
fn type_id(self) -> NodeTypeId {
|
||||
pub fn type_id(&self) -> NodeTypeId {
|
||||
self.type_id
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-node-length
|
||||
fn len(self) -> u32 {
|
||||
pub fn len(&self) -> u32 {
|
||||
match self.type_id {
|
||||
NodeTypeId::DocumentType => 0,
|
||||
NodeTypeId::CharacterData(_) => {
|
||||
|
@ -589,29 +476,29 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-tree-index
|
||||
fn index(self) -> u32 {
|
||||
pub fn index(&self) -> u32 {
|
||||
self.preceding_siblings().count() as u32
|
||||
}
|
||||
|
||||
fn children_count(self) -> u32 {
|
||||
pub fn children_count(&self) -> u32 {
|
||||
self.children_count.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_anchor_element(self) -> bool {
|
||||
pub fn is_anchor_element(&self) -> bool {
|
||||
self.type_id == NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_doctype(self) -> bool {
|
||||
pub fn is_doctype(&self) -> bool {
|
||||
self.type_id == NodeTypeId::DocumentType
|
||||
}
|
||||
|
||||
fn get_flag(self, flag: NodeFlags) -> bool {
|
||||
pub fn get_flag(&self, flag: NodeFlags) -> bool {
|
||||
self.flags.get().contains(flag)
|
||||
}
|
||||
|
||||
fn set_flag(self, flag: NodeFlags, value: bool) {
|
||||
pub fn set_flag(&self, flag: NodeFlags, value: bool) {
|
||||
let mut flags = self.flags.get();
|
||||
|
||||
if value {
|
||||
|
@ -623,90 +510,90 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
self.flags.set(flags);
|
||||
}
|
||||
|
||||
fn get_hover_state(self) -> bool {
|
||||
pub fn get_hover_state(&self) -> bool {
|
||||
self.get_flag(IN_HOVER_STATE)
|
||||
}
|
||||
|
||||
fn set_hover_state(self, state: bool) {
|
||||
pub fn set_hover_state(&self, state: bool) {
|
||||
self.set_flag(IN_HOVER_STATE, state);
|
||||
self.dirty(NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
|
||||
fn get_focus_state(self) -> bool {
|
||||
pub fn get_focus_state(&self) -> bool {
|
||||
self.get_flag(IN_FOCUS_STATE)
|
||||
}
|
||||
|
||||
fn set_focus_state(self, state: bool) {
|
||||
pub fn set_focus_state(&self, state: bool) {
|
||||
self.set_flag(IN_FOCUS_STATE, state);
|
||||
self.dirty(NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
|
||||
fn get_active_state(self) -> bool {
|
||||
pub fn get_active_state(&self) -> bool {
|
||||
self.get_flag(IN_ACTIVE_STATE)
|
||||
}
|
||||
|
||||
fn set_active_state(self, state: bool) {
|
||||
pub fn set_active_state(&self, state: bool) {
|
||||
self.set_flag(IN_ACTIVE_STATE, state);
|
||||
self.dirty(NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
|
||||
fn get_disabled_state(self) -> bool {
|
||||
pub fn get_disabled_state(&self) -> bool {
|
||||
self.get_flag(IN_DISABLED_STATE)
|
||||
}
|
||||
|
||||
fn set_disabled_state(self, state: bool) {
|
||||
pub fn set_disabled_state(&self, state: bool) {
|
||||
self.set_flag(IN_DISABLED_STATE, state)
|
||||
}
|
||||
|
||||
fn get_enabled_state(self) -> bool {
|
||||
pub fn get_enabled_state(&self) -> bool {
|
||||
self.get_flag(IN_ENABLED_STATE)
|
||||
}
|
||||
|
||||
fn set_enabled_state(self, state: bool) {
|
||||
pub fn set_enabled_state(&self, state: bool) {
|
||||
self.set_flag(IN_ENABLED_STATE, state)
|
||||
}
|
||||
|
||||
fn get_has_changed(self) -> bool {
|
||||
pub fn get_has_changed(&self) -> bool {
|
||||
self.get_flag(HAS_CHANGED)
|
||||
}
|
||||
|
||||
fn set_has_changed(self, state: bool) {
|
||||
pub fn set_has_changed(&self, state: bool) {
|
||||
self.set_flag(HAS_CHANGED, state)
|
||||
}
|
||||
|
||||
fn get_is_dirty(self) -> bool {
|
||||
pub fn get_is_dirty(&self) -> bool {
|
||||
self.get_flag(IS_DIRTY)
|
||||
}
|
||||
|
||||
fn set_is_dirty(self, state: bool) {
|
||||
pub fn set_is_dirty(&self, state: bool) {
|
||||
self.set_flag(IS_DIRTY, state)
|
||||
}
|
||||
|
||||
fn get_has_dirty_siblings(self) -> bool {
|
||||
pub fn get_has_dirty_siblings(&self) -> bool {
|
||||
self.get_flag(HAS_DIRTY_SIBLINGS)
|
||||
}
|
||||
|
||||
fn set_has_dirty_siblings(self, state: bool) {
|
||||
pub fn set_has_dirty_siblings(&self, state: bool) {
|
||||
self.set_flag(HAS_DIRTY_SIBLINGS, state)
|
||||
}
|
||||
|
||||
fn get_has_dirty_descendants(self) -> bool {
|
||||
pub fn get_has_dirty_descendants(&self) -> bool {
|
||||
self.get_flag(HAS_DIRTY_DESCENDANTS)
|
||||
}
|
||||
|
||||
fn set_has_dirty_descendants(self, state: bool) {
|
||||
pub fn set_has_dirty_descendants(&self, state: bool) {
|
||||
self.set_flag(HAS_DIRTY_DESCENDANTS, state)
|
||||
}
|
||||
|
||||
fn force_dirty_ancestors(self, damage: NodeDamage) {
|
||||
pub fn force_dirty_ancestors(&self, damage: NodeDamage) {
|
||||
self.dirty_impl(damage, true)
|
||||
}
|
||||
|
||||
fn dirty(self, damage: NodeDamage) {
|
||||
pub fn dirty(&self, damage: NodeDamage) {
|
||||
self.dirty_impl(damage, false)
|
||||
}
|
||||
|
||||
fn dirty_impl(self, damage: NodeDamage, force_ancestors: bool) {
|
||||
pub fn dirty_impl(&self, damage: NodeDamage, force_ancestors: bool) {
|
||||
// 1. Dirty self.
|
||||
match damage {
|
||||
NodeDamage::NodeStyleDamaged => {}
|
||||
|
@ -755,83 +642,83 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
/// Iterates over this node and all its descendants, in preorder.
|
||||
fn traverse_preorder(self) -> TreeIterator {
|
||||
pub fn traverse_preorder(&self) -> TreeIterator {
|
||||
TreeIterator::new(self)
|
||||
}
|
||||
|
||||
fn inclusively_following_siblings(self) -> NodeSiblingIterator {
|
||||
pub fn inclusively_following_siblings(&self) -> NodeSiblingIterator {
|
||||
NodeSiblingIterator {
|
||||
current: Some(Root::from_ref(self)),
|
||||
}
|
||||
}
|
||||
|
||||
fn inclusively_preceding_siblings(self) -> ReverseSiblingIterator {
|
||||
pub fn inclusively_preceding_siblings(&self) -> ReverseSiblingIterator {
|
||||
ReverseSiblingIterator {
|
||||
current: Some(Root::from_ref(self)),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_inclusive_ancestor_of(self, parent: &Node) -> bool {
|
||||
pub fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool {
|
||||
self == parent || parent.ancestors().any(|ancestor| ancestor.r() == self)
|
||||
}
|
||||
|
||||
fn following_siblings(self) -> NodeSiblingIterator {
|
||||
pub fn following_siblings(&self) -> NodeSiblingIterator {
|
||||
NodeSiblingIterator {
|
||||
current: self.GetNextSibling(),
|
||||
}
|
||||
}
|
||||
|
||||
fn preceding_siblings(self) -> ReverseSiblingIterator {
|
||||
pub fn preceding_siblings(&self) -> ReverseSiblingIterator {
|
||||
ReverseSiblingIterator {
|
||||
current: self.GetPreviousSibling(),
|
||||
}
|
||||
}
|
||||
|
||||
fn following_nodes(self, root: &Node) -> FollowingNodeIterator {
|
||||
pub fn following_nodes(&self, root: &Node) -> FollowingNodeIterator {
|
||||
FollowingNodeIterator {
|
||||
current: Some(Root::from_ref(self)),
|
||||
root: Root::from_ref(root),
|
||||
}
|
||||
}
|
||||
|
||||
fn preceding_nodes(self, root: &Node) -> PrecedingNodeIterator {
|
||||
pub fn preceding_nodes(&self, root: &Node) -> PrecedingNodeIterator {
|
||||
PrecedingNodeIterator {
|
||||
current: Some(Root::from_ref(self)),
|
||||
root: Root::from_ref(root),
|
||||
}
|
||||
}
|
||||
|
||||
fn descending_last_children(self) -> LastChildIterator {
|
||||
pub fn descending_last_children(&self) -> LastChildIterator {
|
||||
LastChildIterator {
|
||||
current: self.GetLastChild(),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_parent_of(self, child: &Node) -> bool {
|
||||
pub fn is_parent_of(&self, child: &Node) -> bool {
|
||||
match child.parent_node.get() {
|
||||
Some(ref parent) => parent.root().r() == self,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_trusted_node_address(self) -> TrustedNodeAddress {
|
||||
pub fn to_trusted_node_address(&self) -> TrustedNodeAddress {
|
||||
TrustedNodeAddress(&*self as *const Node as *const libc::c_void)
|
||||
}
|
||||
|
||||
fn get_bounding_content_box(self) -> Rect<Au> {
|
||||
pub fn get_bounding_content_box(&self) -> Rect<Au> {
|
||||
window_from_node(self).r().content_box_query(self.to_trusted_node_address())
|
||||
}
|
||||
|
||||
fn get_content_boxes(self) -> Vec<Rect<Au>> {
|
||||
pub fn get_content_boxes(&self) -> Vec<Rect<Au>> {
|
||||
window_from_node(self).r().content_boxes_query(self.to_trusted_node_address())
|
||||
}
|
||||
|
||||
fn get_client_rect(self) -> Rect<i32> {
|
||||
pub fn get_client_rect(&self) -> Rect<i32> {
|
||||
window_from_node(self).r().client_rect_query(self.to_trusted_node_address())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-childnode-before
|
||||
fn before(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
pub fn before(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
// Step 1.
|
||||
let parent = &self.parent_node;
|
||||
|
||||
|
@ -860,7 +747,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-childnode-after
|
||||
fn after(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
pub fn after(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
// Step 1.
|
||||
let parent = &self.parent_node;
|
||||
|
||||
|
@ -883,7 +770,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-childnode-replacewith
|
||||
fn replace_with(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
pub fn replace_with(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
match self.parent_node.get() {
|
||||
None => {
|
||||
// Step 1.
|
||||
|
@ -900,7 +787,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-prepend
|
||||
fn prepend(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
pub fn prepend(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
// Step 1.
|
||||
let doc = self.owner_doc();
|
||||
let node = try!(doc.r().node_from_nodes_and_strings(nodes));
|
||||
|
@ -910,7 +797,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-append
|
||||
fn append(self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
pub fn append(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
|
||||
// Step 1.
|
||||
let doc = self.owner_doc();
|
||||
let node = try!(doc.r().node_from_nodes_and_strings(nodes));
|
||||
|
@ -919,7 +806,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||
fn query_selector(self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
||||
pub fn query_selector(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> {
|
||||
// Step 1.
|
||||
match parse_author_origin_selector_list_from_str(&selectors) {
|
||||
// Step 2.
|
||||
|
@ -939,7 +826,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
/// Be careful not to do anything which may manipulate the DOM tree whilst iterating, otherwise
|
||||
/// the iterator may be invalidated
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn query_selector_iter(self, selectors: DOMString)
|
||||
pub unsafe fn query_selector_iter(&self, selectors: DOMString)
|
||||
-> Fallible<QuerySelectorIterator> {
|
||||
// Step 1.
|
||||
match parse_author_origin_selector_list_from_str(&selectors) {
|
||||
|
@ -956,49 +843,49 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||
#[allow(unsafe_code)]
|
||||
fn query_selector_all(self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
||||
pub fn query_selector_all(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
|
||||
let window = window_from_node(self);
|
||||
let iter = try!(unsafe { self.query_selector_iter(selectors) });
|
||||
Ok(NodeList::new_simple_list(window.r(), iter))
|
||||
}
|
||||
|
||||
fn ancestors(self) -> AncestorIterator {
|
||||
pub fn ancestors(&self) -> AncestorIterator {
|
||||
AncestorIterator {
|
||||
current: self.GetParentNode()
|
||||
}
|
||||
}
|
||||
|
||||
fn inclusive_ancestors(self) -> AncestorIterator {
|
||||
pub fn inclusive_ancestors(&self) -> AncestorIterator {
|
||||
AncestorIterator {
|
||||
current: Some(Root::from_ref(self))
|
||||
}
|
||||
}
|
||||
|
||||
fn owner_doc(self) -> Root<Document> {
|
||||
pub fn owner_doc(&self) -> Root<Document> {
|
||||
self.owner_doc.get().unwrap().root()
|
||||
}
|
||||
|
||||
fn set_owner_doc(self, document: &Document) {
|
||||
pub fn set_owner_doc(&self, document: &Document) {
|
||||
self.owner_doc.set(Some(JS::from_ref(document)));
|
||||
}
|
||||
|
||||
fn is_in_html_doc(self) -> bool {
|
||||
pub fn is_in_html_doc(&self) -> bool {
|
||||
self.owner_doc().r().is_html_document()
|
||||
}
|
||||
|
||||
fn children(self) -> NodeSiblingIterator {
|
||||
pub fn children(&self) -> NodeSiblingIterator {
|
||||
NodeSiblingIterator {
|
||||
current: self.GetFirstChild(),
|
||||
}
|
||||
}
|
||||
|
||||
fn rev_children(self) -> ReverseSiblingIterator {
|
||||
pub fn rev_children(&self) -> ReverseSiblingIterator {
|
||||
ReverseSiblingIterator {
|
||||
current: self.GetLastChild(),
|
||||
}
|
||||
}
|
||||
|
||||
fn child_elements(self) -> ChildElementIterator {
|
||||
pub fn child_elements(&self) -> ChildElementIterator {
|
||||
fn to_temporary(node: Root<Node>) -> Option<Root<Element>> {
|
||||
ElementCast::to_root(node)
|
||||
}
|
||||
|
@ -1007,13 +894,13 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
.peekable()
|
||||
}
|
||||
|
||||
fn remove_self(self) {
|
||||
pub fn remove_self(&self) {
|
||||
if let Some(ref parent) = self.GetParentNode() {
|
||||
Node::remove(self, parent.r(), SuppressObserver::Unsuppressed);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_unique_id(self) -> String {
|
||||
pub fn get_unique_id(&self) -> String {
|
||||
if self.unique_id.borrow().is_empty() {
|
||||
let mut unique_id = self.unique_id.borrow_mut();
|
||||
*unique_id = uuid::Uuid::new_v4().to_simple_string();
|
||||
|
@ -1021,7 +908,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
self.unique_id.borrow().clone()
|
||||
}
|
||||
|
||||
fn summarize(self) -> NodeInfo {
|
||||
pub fn summarize(&self) -> NodeInfo {
|
||||
NodeInfo {
|
||||
uniqueId: self.get_unique_id(),
|
||||
baseURI: self.BaseURI(),
|
||||
|
@ -1057,7 +944,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#dfn-concept-parse-fragment
|
||||
fn parse_fragment(self, markup: DOMString) -> Fallible<Root<DocumentFragment>> {
|
||||
pub fn parse_fragment(&self, markup: DOMString) -> Fallible<Root<DocumentFragment>> {
|
||||
let context_node: &Node = NodeCast::from_ref(self);
|
||||
let context_document = document_from_node(self);
|
||||
let fragment = DocumentFragment::new(context_document.r());
|
||||
|
@ -2607,14 +2494,9 @@ impl VirtualMethods for Node {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait DisabledStateHelpers {
|
||||
fn check_ancestors_disabled_state_for_form_control(self);
|
||||
fn check_parent_disabled_state_for_option(self);
|
||||
fn check_disabled_attribute(self);
|
||||
}
|
||||
|
||||
impl<'a> DisabledStateHelpers for &'a Node {
|
||||
fn check_ancestors_disabled_state_for_form_control(self) {
|
||||
impl Node {
|
||||
pub fn check_ancestors_disabled_state_for_form_control(&self) {
|
||||
if self.get_disabled_state() { return; }
|
||||
for ancestor in self.ancestors() {
|
||||
let ancestor = ancestor;
|
||||
|
@ -2641,7 +2523,7 @@ impl<'a> DisabledStateHelpers for &'a Node {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_parent_disabled_state_for_option(self) {
|
||||
pub fn check_parent_disabled_state_for_option(&self) {
|
||||
if self.get_disabled_state() { return; }
|
||||
if let Some(ref parent) = self.GetParentNode() {
|
||||
if parent.r().is_htmloptgroupelement() && parent.r().get_disabled_state() {
|
||||
|
@ -2651,7 +2533,7 @@ impl<'a> DisabledStateHelpers for &'a Node {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_disabled_attribute(self) {
|
||||
pub fn check_disabled_attribute(&self) {
|
||||
let elem = ElementCast::to_ref(self).unwrap();
|
||||
let has_disabled_attrib = elem.has_attribute(&atom!("disabled"));
|
||||
self.set_disabled_state(has_disabled_attrib);
|
||||
|
|
|
@ -12,8 +12,8 @@ use dom::bindings::error::Fallible;
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::node::{Node, NodeHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::node::Node;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
@ -191,14 +191,10 @@ impl<'a> NodeIteratorMethods for &'a NodeIterator {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateNodeIteratorHelpers {
|
||||
fn accept_node(self, node: &Node) -> Fallible<u16>;
|
||||
fn is_root_node(self, node: &Node) -> bool;
|
||||
}
|
||||
|
||||
impl<'a> PrivateNodeIteratorHelpers for &'a NodeIterator {
|
||||
impl NodeIterator {
|
||||
// https://dom.spec.whatwg.org/#concept-node-filter
|
||||
fn accept_node(self, node: &Node) -> Fallible<u16> {
|
||||
fn accept_node(&self, node: &Node) -> Fallible<u16> {
|
||||
// Step 1.
|
||||
let n = node.NodeType() - 1;
|
||||
// Step 2.
|
||||
|
@ -212,10 +208,6 @@ impl<'a> PrivateNodeIteratorHelpers for &'a NodeIterator {
|
|||
Filter::Callback(ref callback) => callback.AcceptNode_(self, node, Rethrow)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_root_node(self, node: &Node) -> bool {
|
||||
JS::from_ref(node) == self.root_node
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods;
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::node::{ChildrenMutation, Node, NodeHelpers};
|
||||
use dom::node::{ChildrenMutation, Node};
|
||||
use dom::window::Window;
|
||||
|
||||
use std::cell::Cell;
|
||||
|
@ -79,12 +79,9 @@ impl<'a> NodeListMethods for &'a NodeList {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait NodeListHelpers<'a> {
|
||||
fn as_children_list(self) -> &'a ChildrenList;
|
||||
}
|
||||
|
||||
impl<'a> NodeListHelpers<'a> for &'a NodeList {
|
||||
fn as_children_list(self) -> &'a ChildrenList {
|
||||
impl NodeList {
|
||||
pub fn as_children_list(&self) -> &ChildrenList {
|
||||
if let NodeListType::Children(ref list) = self.list_type {
|
||||
list
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::num::Finite;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::performancetiming::{PerformanceTiming, PerformanceTimingHelpers};
|
||||
use dom::performancetiming::PerformanceTiming;
|
||||
use dom::window::Window;
|
||||
use time;
|
||||
|
||||
|
|
|
@ -46,12 +46,9 @@ impl<'a> PerformanceTimingMethods for &'a PerformanceTiming {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait PerformanceTimingHelpers {
|
||||
fn NavigationStartPrecise(self) -> f64;
|
||||
}
|
||||
|
||||
impl<'a> PerformanceTimingHelpers for &'a PerformanceTiming {
|
||||
fn NavigationStartPrecise(self) -> f64 {
|
||||
impl PerformanceTiming {
|
||||
pub fn NavigationStartPrecise(&self) -> f64 {
|
||||
self.navigationStartPrecise
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,12 +40,9 @@ impl ProcessingInstruction {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait ProcessingInstructionHelpers<'a> {
|
||||
fn target(self) -> &'a DOMString;
|
||||
}
|
||||
|
||||
impl<'a> ProcessingInstructionHelpers<'a> for &'a ProcessingInstruction {
|
||||
fn target(self) -> &'a DOMString {
|
||||
impl ProcessingInstruction {
|
||||
pub fn target(&self) -> &DOMString {
|
||||
&self.target
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::{JS, Root, RootedReference};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::characterdata::CharacterDataTypeId;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::documentfragment::DocumentFragment;
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::{Ord, Ordering, PartialEq, PartialOrd};
|
||||
|
@ -125,12 +125,9 @@ impl Range {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait RangeHelpers<'a> {
|
||||
fn inner(self) -> &'a Rc<RefCell<RangeInner>>;
|
||||
}
|
||||
|
||||
impl<'a> RangeHelpers<'a> for &'a Range {
|
||||
fn inner(self) -> &'a Rc<RefCell<RangeInner>> {
|
||||
impl Range {
|
||||
pub fn inner(&self) -> &Rc<RefCell<RangeInner>> {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,15 @@
|
|||
use document_loader::LoadType;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::ServoHTMLParserBinding;
|
||||
use dom::bindings::codegen::InheritTypes::NodeCast;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::node::{window_from_node, Node};
|
||||
use dom::text::Text;
|
||||
use dom::window::Window;
|
||||
use network_listener::PreInvoke;
|
||||
use parse::Parser;
|
||||
|
@ -27,7 +29,7 @@ use encoding::all::UTF_8;
|
|||
use encoding::types::{Encoding, DecoderTrap};
|
||||
use html5ever::tokenizer;
|
||||
use html5ever::tree_builder;
|
||||
use html5ever::tree_builder::{TreeBuilder, TreeBuilderOpts};
|
||||
use html5ever::tree_builder::{NodeOrText, TreeBuilder, TreeBuilderOpts};
|
||||
use hyper::header::ContentType;
|
||||
use hyper::mime::{Mime, TopLevel, SubLevel};
|
||||
use js::jsapi::JSTracer;
|
||||
|
@ -42,6 +44,19 @@ pub struct Sink {
|
|||
pub document: JS<Document>,
|
||||
}
|
||||
|
||||
impl Sink {
|
||||
pub fn get_or_create(&self, child: NodeOrText<JS<Node>>) -> Root<Node> {
|
||||
match child {
|
||||
NodeOrText::AppendNode(n) => n.root(),
|
||||
NodeOrText::AppendText(t) => {
|
||||
let doc = self.document.root();
|
||||
let text = Text::new(t.into(), &doc);
|
||||
NodeCast::from_root(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// FragmentContext is used only to pass this group of related values
|
||||
/// into functions.
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -272,16 +287,9 @@ impl ServoHTMLParser {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateServoHTMLParserHelpers {
|
||||
/// Synchronously run the tokenizer parse loop until explicitly suspended or
|
||||
/// the tokenizer runs out of input.
|
||||
fn parse_sync(self);
|
||||
/// Retrieve the window object associated with this parser.
|
||||
fn window(self) -> Root<Window>;
|
||||
}
|
||||
|
||||
impl<'a> PrivateServoHTMLParserHelpers for &'a ServoHTMLParser {
|
||||
fn parse_sync(self) {
|
||||
impl ServoHTMLParser {
|
||||
fn parse_sync(&self) {
|
||||
let mut first = true;
|
||||
|
||||
// This parser will continue to parse while there is either pending input or
|
||||
|
@ -314,28 +322,20 @@ impl<'a> PrivateServoHTMLParserHelpers for &'a ServoHTMLParser {
|
|||
}
|
||||
}
|
||||
|
||||
fn window(self) -> Root<Window> {
|
||||
fn window(&self) -> Root<Window> {
|
||||
let doc = self.document.root();
|
||||
window_from_node(doc.r())
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ServoHTMLParserHelpers {
|
||||
/// Cause the parser to interrupt next time the tokenizer reaches a quiescent state.
|
||||
/// No further parsing will occur after that point until the `resume` method is called.
|
||||
/// Panics if the parser is already suspended.
|
||||
fn suspend(self);
|
||||
/// Immediately resume a suspended parser. Panics if the parser is not suspended.
|
||||
fn resume(self);
|
||||
}
|
||||
|
||||
impl<'a> ServoHTMLParserHelpers for &'a ServoHTMLParser {
|
||||
fn suspend(self) {
|
||||
impl ServoHTMLParser {
|
||||
pub fn suspend(&self) {
|
||||
assert!(!self.suspended.get());
|
||||
self.suspended.set(true);
|
||||
}
|
||||
|
||||
fn resume(self) {
|
||||
pub fn resume(&self) {
|
||||
assert!(self.suspended.get());
|
||||
self.suspended.set(false);
|
||||
self.parse_sync();
|
||||
|
|
|
@ -9,10 +9,9 @@ use dom::bindings::global::{GlobalRef, GlobalField};
|
|||
use dom::bindings::js::{Root, RootedReference};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::event::{EventHelpers, EventBubbles, EventCancelable};
|
||||
use dom::event::{EventBubbles, EventCancelable};
|
||||
use dom::storageevent::StorageEvent;
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use dom::window::WindowHelpers;
|
||||
use ipc_channel::ipc;
|
||||
use net_traits::storage_task::{StorageTask, StorageTaskMsg, StorageType};
|
||||
use page::IterablePage;
|
||||
|
@ -140,14 +139,10 @@ impl<'a> StorageMethods for &'a Storage {
|
|||
}
|
||||
}
|
||||
|
||||
trait PrivateStorageHelpers {
|
||||
fn broadcast_change_notification(self, key: Option<DOMString>, old_value: Option<DOMString>,
|
||||
new_value: Option<DOMString>);
|
||||
}
|
||||
|
||||
impl<'a> PrivateStorageHelpers for &'a Storage {
|
||||
impl Storage {
|
||||
/// https://html.spec.whatwg.org/multipage/#send-a-storage-notification
|
||||
fn broadcast_change_notification(self, key: Option<DOMString>, old_value: Option<DOMString>,
|
||||
fn broadcast_change_notification(&self, key: Option<DOMString>, old_value: Option<DOMString>,
|
||||
new_value: Option<DOMString>) {
|
||||
let global_root = self.global.root();
|
||||
let global_ref = global_root.r();
|
||||
|
|
|
@ -13,10 +13,10 @@ use dom::bindings::error::{Error, Fallible};
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::js::{RootedReference};
|
||||
use dom::characterdata::{CharacterData, CharacterDataHelpers, CharacterDataTypeId};
|
||||
use dom::characterdata::{CharacterData, CharacterDataTypeId};
|
||||
use dom::document::Document;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
use util::str::DOMString;
|
||||
|
||||
/// An HTML text node.
|
||||
|
|
|
@ -13,7 +13,7 @@ use dom::bindings::global::GlobalRef;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::js::{JS, MutHeap};
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::node::Node;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -255,29 +255,10 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker {
|
|||
|
||||
type NodeAdvancer<'a> = Fn(&Node) -> Option<Root<Node>> + 'a;
|
||||
|
||||
trait PrivateTreeWalkerHelpers {
|
||||
fn traverse_children<F, G>(self,
|
||||
next_child: F,
|
||||
next_sibling: G)
|
||||
-> Fallible<Option<Root<Node>>>
|
||||
where F: Fn(&Node) -> Option<Root<Node>>,
|
||||
G: Fn(&Node) -> Option<Root<Node>>;
|
||||
fn traverse_siblings<F, G>(self,
|
||||
next_child: F,
|
||||
next_sibling: G)
|
||||
-> Fallible<Option<Root<Node>>>
|
||||
where F: Fn(&Node) -> Option<Root<Node>>,
|
||||
G: Fn(&Node) -> Option<Root<Node>>;
|
||||
fn is_root_node(self, node: &Node) -> bool;
|
||||
fn is_current_node(self, node: &Node) -> bool;
|
||||
fn first_following_node_not_following_root(self, node: &Node)
|
||||
-> Option<Root<Node>>;
|
||||
fn accept_node(self, node: &Node) -> Fallible<u16>;
|
||||
}
|
||||
|
||||
impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker {
|
||||
impl TreeWalker {
|
||||
// https://dom.spec.whatwg.org/#concept-traverse-children
|
||||
fn traverse_children<F, G>(self,
|
||||
fn traverse_children<F, G>(&self,
|
||||
next_child: F,
|
||||
next_sibling: G)
|
||||
-> Fallible<Option<Root<Node>>>
|
||||
|
@ -352,7 +333,7 @@ impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-traverse-siblings
|
||||
fn traverse_siblings<F, G>(self,
|
||||
fn traverse_siblings<F, G>(&self,
|
||||
next_child: F,
|
||||
next_sibling: G)
|
||||
-> Fallible<Option<Root<Node>>>
|
||||
|
@ -414,7 +395,7 @@ impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-tree-following
|
||||
fn first_following_node_not_following_root(self, node: &Node)
|
||||
fn first_following_node_not_following_root(&self, node: &Node)
|
||||
-> Option<Root<Node>> {
|
||||
// "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."
|
||||
|
@ -441,7 +422,7 @@ impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-node-filter
|
||||
fn accept_node(self, node: &Node) -> Fallible<u16> {
|
||||
fn accept_node(&self, node: &Node) -> Fallible<u16> {
|
||||
// "To filter node run these steps:"
|
||||
// "1. Let n be node's nodeType attribute value minus 1."
|
||||
let n = node.NodeType() - 1;
|
||||
|
@ -461,11 +442,11 @@ impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_root_node(self, node: &Node) -> bool {
|
||||
fn is_root_node(&self, node: &Node) -> bool {
|
||||
JS::from_ref(node) == self.root_node
|
||||
}
|
||||
|
||||
fn is_current_node(self, node: &Node) -> bool {
|
||||
fn is_current_node(&self, node: &Node) -> bool {
|
||||
JS::from_ref(node) == self.current_node.get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,25 +123,19 @@ impl<'a> URLSearchParamsMethods for &'a URLSearchParams {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait URLSearchParamsHelpers {
|
||||
fn serialize(self, encoding: Option<EncodingRef>) -> DOMString;
|
||||
}
|
||||
|
||||
impl<'a> URLSearchParamsHelpers for &'a URLSearchParams {
|
||||
impl URLSearchParams {
|
||||
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
|
||||
fn serialize(self, encoding: Option<EncodingRef>) -> DOMString {
|
||||
pub fn serialize(&self, encoding: Option<EncodingRef>) -> DOMString {
|
||||
let list = self.list.borrow();
|
||||
serialize_with_encoding(list.iter(), encoding)
|
||||
}
|
||||
}
|
||||
|
||||
trait PrivateURLSearchParamsHelpers {
|
||||
fn update_steps(self);
|
||||
}
|
||||
|
||||
impl<'a> PrivateURLSearchParamsHelpers for &'a URLSearchParams {
|
||||
impl URLSearchParams {
|
||||
// https://url.spec.whatwg.org/#concept-uq-update
|
||||
fn update_steps(self) {
|
||||
fn update_steps(&self) {
|
||||
// XXXManishearth Implement this when the URL interface is implemented
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
|||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::InheritTypes::NodeCast;
|
||||
use dom::bindings::js::{RootedReference};
|
||||
use dom::element::AttributeHandlers;
|
||||
use dom::htmlheadelement::HTMLHeadElement;
|
||||
use dom::node::NodeHelpers;
|
||||
use std::borrow::ToOwned;
|
||||
use std::fs::read_dir;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
@ -37,7 +37,7 @@ use dom::element::ElementTypeId;
|
|||
use dom::event::Event;
|
||||
use dom::htmlelement::HTMLElementTypeId;
|
||||
use dom::node::NodeTypeId;
|
||||
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node, NodeHelpers};
|
||||
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node};
|
||||
|
||||
use util::str::DOMString;
|
||||
|
||||
|
|
|
@ -49,19 +49,14 @@ impl WebGLBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebGLBufferHelpers {
|
||||
fn id(self) -> u32;
|
||||
fn bind(self, target: u32) -> WebGLResult<()>;
|
||||
fn delete(self);
|
||||
}
|
||||
|
||||
impl<'a> WebGLBufferHelpers for &'a WebGLBuffer {
|
||||
fn id(self) -> u32 {
|
||||
impl WebGLBuffer {
|
||||
pub fn id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
// NB: Only valid buffer targets come here
|
||||
fn bind(self, target: u32) -> WebGLResult<()> {
|
||||
pub fn bind(&self, target: u32) -> WebGLResult<()> {
|
||||
if let Some(previous_target) = self.target.get() {
|
||||
if target != previous_target {
|
||||
return Err(WebGLError::InvalidOperation);
|
||||
|
@ -74,7 +69,7 @@ impl<'a> WebGLBufferHelpers for &'a WebGLBuffer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn delete(self) {
|
||||
pub fn delete(&self) {
|
||||
if !self.is_deleted.get() {
|
||||
self.is_deleted.set(true);
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteBuffer(self.id))).unwrap();
|
||||
|
|
|
@ -47,23 +47,18 @@ impl WebGLFramebuffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebGLFramebufferHelpers {
|
||||
fn id(self) -> u32;
|
||||
fn bind(self, target: u32);
|
||||
fn delete(self);
|
||||
}
|
||||
|
||||
impl<'a> WebGLFramebufferHelpers for &'a WebGLFramebuffer {
|
||||
fn id(self) -> u32 {
|
||||
impl WebGLFramebuffer {
|
||||
pub fn id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn bind(self, target: u32) {
|
||||
pub fn bind(&self, target: u32) {
|
||||
let cmd = CanvasWebGLMsg::BindFramebuffer(target, WebGLFramebufferBindingRequest::Explicit(self.id));
|
||||
self.renderer.send(CanvasMsg::WebGL(cmd)).unwrap();
|
||||
}
|
||||
|
||||
fn delete(self) {
|
||||
pub fn delete(&self) {
|
||||
if !self.is_deleted.get() {
|
||||
self.is_deleted.set(true);
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteFramebuffer(self.id))).unwrap();
|
||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::js::{JS, MutNullableHeap, Root};
|
|||
use dom::bindings::utils::reflect_dom_object;
|
||||
use dom::webglobject::WebGLObject;
|
||||
use dom::webglrenderingcontext::MAX_UNIFORM_AND_ATTRIBUTE_LEN;
|
||||
use dom::webglshader::{WebGLShader, WebGLShaderHelpers};
|
||||
use dom::webglshader::WebGLShader;
|
||||
|
||||
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
|
||||
|
||||
|
@ -54,18 +54,10 @@ impl WebGLProgram {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebGLProgramHelpers {
|
||||
fn delete(self);
|
||||
fn link(self);
|
||||
fn use_program(self);
|
||||
fn attach_shader(self, shader: &WebGLShader) -> WebGLResult<()>;
|
||||
fn get_attrib_location(self, name: String) -> WebGLResult<Option<i32>>;
|
||||
fn get_uniform_location(self, name: String) -> WebGLResult<Option<i32>>;
|
||||
}
|
||||
|
||||
impl<'a> WebGLProgramHelpers for &'a WebGLProgram {
|
||||
impl WebGLProgram {
|
||||
/// glDeleteProgram
|
||||
fn delete(self) {
|
||||
pub fn delete(&self) {
|
||||
if !self.is_deleted.get() {
|
||||
self.is_deleted.set(true);
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteProgram(self.id))).unwrap();
|
||||
|
@ -73,17 +65,17 @@ impl<'a> WebGLProgramHelpers for &'a WebGLProgram {
|
|||
}
|
||||
|
||||
/// glLinkProgram
|
||||
fn link(self) {
|
||||
pub fn link(&self) {
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::LinkProgram(self.id))).unwrap();
|
||||
}
|
||||
|
||||
/// glUseProgram
|
||||
fn use_program(self) {
|
||||
pub fn use_program(&self) {
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::UseProgram(self.id))).unwrap();
|
||||
}
|
||||
|
||||
/// glAttachShader
|
||||
fn attach_shader(self, shader: &WebGLShader) -> WebGLResult<()> {
|
||||
pub fn attach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> {
|
||||
let shader_slot = match shader.gl_type() {
|
||||
constants::FRAGMENT_SHADER => &self.fragment_shader,
|
||||
constants::VERTEX_SHADER => &self.vertex_shader,
|
||||
|
@ -104,7 +96,7 @@ impl<'a> WebGLProgramHelpers for &'a WebGLProgram {
|
|||
}
|
||||
|
||||
/// glGetAttribLocation
|
||||
fn get_attrib_location(self, name: String) -> WebGLResult<Option<i32>> {
|
||||
pub fn get_attrib_location(&self, name: String) -> WebGLResult<Option<i32>> {
|
||||
if name.len() > MAX_UNIFORM_AND_ATTRIBUTE_LEN {
|
||||
return Err(WebGLError::InvalidValue);
|
||||
}
|
||||
|
@ -120,7 +112,7 @@ impl<'a> WebGLProgramHelpers for &'a WebGLProgram {
|
|||
}
|
||||
|
||||
/// glGetUniformLocation
|
||||
fn get_uniform_location(self, name: String) -> WebGLResult<Option<i32>> {
|
||||
pub fn get_uniform_location(&self, name: String) -> WebGLResult<Option<i32>> {
|
||||
if name.len() > MAX_UNIFORM_AND_ATTRIBUTE_LEN {
|
||||
return Err(WebGLError::InvalidValue);
|
||||
}
|
||||
|
|
|
@ -47,22 +47,17 @@ impl WebGLRenderbuffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebGLRenderbufferHelpers {
|
||||
fn id(self) -> u32;
|
||||
fn bind(self, target: u32);
|
||||
fn delete(self);
|
||||
}
|
||||
|
||||
impl<'a> WebGLRenderbufferHelpers for &'a WebGLRenderbuffer {
|
||||
fn id(self) -> u32 {
|
||||
impl WebGLRenderbuffer {
|
||||
pub fn id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn bind(self, target: u32) {
|
||||
pub fn bind(&self, target: u32) {
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::BindRenderbuffer(target, self.id))).unwrap();
|
||||
}
|
||||
|
||||
fn delete(self) {
|
||||
pub fn delete(&self) {
|
||||
if !self.is_deleted.get() {
|
||||
self.is_deleted.set(true);
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteRenderbuffer(self.id))).unwrap();
|
||||
|
|
|
@ -17,16 +17,14 @@ use dom::bindings::js::{JS, LayoutJS, Root};
|
|||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::htmlcanvaselement::HTMLCanvasElement;
|
||||
use dom::htmlcanvaselement::utils as canvas_utils;
|
||||
use dom::htmlimageelement::HTMLImageElementHelpers;
|
||||
use dom::imagedata::ImageDataHelpers;
|
||||
use dom::node::{window_from_node, NodeHelpers, NodeDamage};
|
||||
use dom::webglbuffer::{WebGLBuffer, WebGLBufferHelpers};
|
||||
use dom::webglframebuffer::{WebGLFramebuffer, WebGLFramebufferHelpers};
|
||||
use dom::webglprogram::{WebGLProgram, WebGLProgramHelpers};
|
||||
use dom::webglrenderbuffer::{WebGLRenderbuffer, WebGLRenderbufferHelpers};
|
||||
use dom::webglshader::{WebGLShader, WebGLShaderHelpers};
|
||||
use dom::webgltexture::{TexParameterValue, WebGLTexture, WebGLTextureHelpers};
|
||||
use dom::webgluniformlocation::{WebGLUniformLocation, WebGLUniformLocationHelpers};
|
||||
use dom::node::{window_from_node, NodeDamage};
|
||||
use dom::webglbuffer::WebGLBuffer;
|
||||
use dom::webglframebuffer::WebGLFramebuffer;
|
||||
use dom::webglprogram::WebGLProgram;
|
||||
use dom::webglrenderbuffer::WebGLRenderbuffer;
|
||||
use dom::webglshader::WebGLShader;
|
||||
use dom::webgltexture::{TexParameterValue, WebGLTexture};
|
||||
use dom::webgluniformlocation::WebGLUniformLocation;
|
||||
use euclid::size::Size2D;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::jsapi::{JSContext, JSObject, RootedValue};
|
||||
|
@ -906,13 +904,9 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebGLRenderingContextHelpers {
|
||||
fn webgl_error(&self, err: WebGLError);
|
||||
fn bound_texture_for(&self, target: u32) -> Option<JS<WebGLTexture>>;
|
||||
}
|
||||
|
||||
impl<'a> WebGLRenderingContextHelpers for &'a WebGLRenderingContext {
|
||||
fn webgl_error(&self, err: WebGLError) {
|
||||
impl WebGLRenderingContext {
|
||||
pub fn webgl_error(&self, err: WebGLError) {
|
||||
// If an error has been detected no further errors must be
|
||||
// recorded until `getError` has been called
|
||||
if self.last_error.get().is_none() {
|
||||
|
@ -920,7 +914,7 @@ impl<'a> WebGLRenderingContextHelpers for &'a WebGLRenderingContext {
|
|||
}
|
||||
}
|
||||
|
||||
fn bound_texture_for(&self, target: u32) -> Option<JS<WebGLTexture>> {
|
||||
pub fn bound_texture_for(&self, target: u32) -> Option<JS<WebGLTexture>> {
|
||||
match target {
|
||||
constants::TEXTURE_2D => self.bound_texture_2d.get(),
|
||||
constants::TEXTURE_CUBE_MAP => self.bound_texture_cube_map.get(),
|
||||
|
|
|
@ -59,35 +59,25 @@ impl WebGLShader {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebGLShaderHelpers {
|
||||
fn id(self) -> u32;
|
||||
fn gl_type(self) -> u32;
|
||||
fn compile(self);
|
||||
fn delete(self);
|
||||
fn info_log(self) -> Option<String>;
|
||||
fn parameter(self, param_id: u32) -> WebGLResult<WebGLShaderParameter>;
|
||||
fn source(self) -> Option<String>;
|
||||
fn set_source(self, src: String);
|
||||
}
|
||||
|
||||
impl<'a> WebGLShaderHelpers for &'a WebGLShader {
|
||||
fn id(self) -> u32 {
|
||||
impl WebGLShader {
|
||||
pub fn id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn gl_type(self) -> u32 {
|
||||
pub fn gl_type(&self) -> u32 {
|
||||
self.gl_type
|
||||
}
|
||||
|
||||
// TODO(ecoal95): Validate shaders to be conforming to the WebGL spec
|
||||
/// glCompileShader
|
||||
fn compile(self) {
|
||||
pub fn compile(&self) {
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CompileShader(self.id))).unwrap()
|
||||
}
|
||||
|
||||
/// Mark this shader as deleted (if it wasn't previously)
|
||||
/// and delete it as if calling glDeleteShader.
|
||||
fn delete(self) {
|
||||
pub fn delete(&self) {
|
||||
if !self.is_deleted.get() {
|
||||
self.is_deleted.set(true);
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteShader(self.id))).unwrap()
|
||||
|
@ -95,14 +85,14 @@ impl<'a> WebGLShaderHelpers for &'a WebGLShader {
|
|||
}
|
||||
|
||||
/// glGetShaderInfoLog
|
||||
fn info_log(self) -> Option<String> {
|
||||
pub fn info_log(&self) -> Option<String> {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::GetShaderInfoLog(self.id, sender))).unwrap();
|
||||
receiver.recv().unwrap()
|
||||
}
|
||||
|
||||
/// glGetShaderParameter
|
||||
fn parameter(self, param_id: u32) -> WebGLResult<WebGLShaderParameter> {
|
||||
pub fn parameter(&self, param_id: u32) -> WebGLResult<WebGLShaderParameter> {
|
||||
match param_id {
|
||||
constants::SHADER_TYPE | constants::DELETE_STATUS | constants::COMPILE_STATUS => {},
|
||||
_ => return Err(WebGLError::InvalidEnum),
|
||||
|
@ -114,12 +104,12 @@ impl<'a> WebGLShaderHelpers for &'a WebGLShader {
|
|||
}
|
||||
|
||||
/// Get the shader source
|
||||
fn source(self) -> Option<String> {
|
||||
pub fn source(&self) -> Option<String> {
|
||||
self.source.borrow().clone()
|
||||
}
|
||||
|
||||
/// glShaderSource
|
||||
fn set_source(self, source: String) {
|
||||
pub fn set_source(&self, source: String) {
|
||||
*self.source.borrow_mut() = Some(source.clone());
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::ShaderSource(self.id, source))).unwrap()
|
||||
}
|
||||
|
|
|
@ -55,23 +55,14 @@ impl WebGLTexture {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebGLTextureHelpers {
|
||||
fn id(self) -> u32;
|
||||
fn bind(self, target: u32) -> WebGLResult<()>;
|
||||
fn delete(self);
|
||||
fn tex_parameter(self,
|
||||
target: u32,
|
||||
name: u32,
|
||||
value: TexParameterValue) -> WebGLResult<()>;
|
||||
}
|
||||
|
||||
impl<'a> WebGLTextureHelpers for &'a WebGLTexture {
|
||||
fn id(self) -> u32 {
|
||||
impl WebGLTexture {
|
||||
pub fn id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
// NB: Only valid texture targets come here
|
||||
fn bind(self, target: u32) -> WebGLResult<()> {
|
||||
pub fn bind(&self, target: u32) -> WebGLResult<()> {
|
||||
if let Some(previous_target) = self.target.get() {
|
||||
if target != previous_target {
|
||||
return Err(WebGLError::InvalidOperation);
|
||||
|
@ -85,7 +76,7 @@ impl<'a> WebGLTextureHelpers for &'a WebGLTexture {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn delete(self) {
|
||||
pub fn delete(&self) {
|
||||
if !self.is_deleted.get() {
|
||||
self.is_deleted.set(true);
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteTexture(self.id))).unwrap();
|
||||
|
@ -95,7 +86,7 @@ impl<'a> WebGLTextureHelpers for &'a WebGLTexture {
|
|||
/// We have to follow the conversion rules for GLES 2.0. See:
|
||||
/// https://www.khronos.org/webgl/public-mailing-list/archives/1008/msg00014.html
|
||||
///
|
||||
fn tex_parameter(self,
|
||||
pub fn tex_parameter(&self,
|
||||
target: u32,
|
||||
name: u32,
|
||||
value: TexParameterValue) -> WebGLResult<()> {
|
||||
|
|
|
@ -27,12 +27,9 @@ impl WebGLUniformLocation {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebGLUniformLocationHelpers {
|
||||
fn id(self) -> i32;
|
||||
}
|
||||
|
||||
impl<'a> WebGLUniformLocationHelpers for &'a WebGLUniformLocation {
|
||||
fn id(self) -> i32 {
|
||||
impl WebGLUniformLocation {
|
||||
pub fn id(&self) -> i32 {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ use dom::bindings::trace::JSTraceable;
|
|||
use dom::bindings::utils::{reflect_dom_object, Reflectable};
|
||||
use dom::blob::Blob;
|
||||
use dom::closeevent::CloseEvent;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable, EventHelpers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::messageevent::MessageEvent;
|
||||
use script_task::{Runnable, CommonScriptMsg};
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ use dom::browsercontext::BrowsingContext;
|
|||
use dom::console::Console;
|
||||
use dom::crypto::Crypto;
|
||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::element::Element;
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::location::Location;
|
||||
use dom::navigator::Navigator;
|
||||
use dom::node::{window_from_node, TrustedNodeAddress, NodeHelpers, from_untrusted_node_address};
|
||||
use dom::node::{window_from_node, TrustedNodeAddress, from_untrusted_node_address};
|
||||
use dom::performance::Performance;
|
||||
use dom::screen::Screen;
|
||||
use dom::storage::Storage;
|
||||
|
@ -591,54 +591,6 @@ impl<'a> WindowMethods for &'a Window {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WindowHelpers {
|
||||
fn clear_js_runtime(self);
|
||||
fn init_browsing_context(self, doc: &Document, frame_element: Option<&Element>);
|
||||
fn load_url(self, url: Url);
|
||||
fn handle_fire_timer(self, timer_id: TimerId);
|
||||
fn force_reflow(self, goal: ReflowGoal, query_type: ReflowQueryType, reason: ReflowReason);
|
||||
fn reflow(self, goal: ReflowGoal, query_type: ReflowQueryType, reason: ReflowReason);
|
||||
fn join_layout(self);
|
||||
fn layout(&self) -> &LayoutRPC;
|
||||
fn content_box_query(self, content_box_request: TrustedNodeAddress) -> Rect<Au>;
|
||||
fn content_boxes_query(self, content_boxes_request: TrustedNodeAddress) -> Vec<Rect<Au>>;
|
||||
fn client_rect_query(self, node_geometry_request: TrustedNodeAddress) -> Rect<i32>;
|
||||
fn resolved_style_query(self, element: TrustedNodeAddress,
|
||||
pseudo: Option<PseudoElement>, property: &Atom) -> Option<String>;
|
||||
fn offset_parent_query(self, node: TrustedNodeAddress) -> (Option<Root<Element>>, Rect<Au>);
|
||||
fn handle_reflow_complete_msg(self, reflow_id: u32);
|
||||
fn set_fragment_name(self, fragment: Option<String>);
|
||||
fn steal_fragment_name(self) -> Option<String>;
|
||||
fn set_window_size(self, size: WindowSizeData);
|
||||
fn window_size(self) -> Option<WindowSizeData>;
|
||||
fn get_url(self) -> Url;
|
||||
fn resource_task(self) -> ResourceTask;
|
||||
fn mem_profiler_chan(self) -> mem::ProfilerChan;
|
||||
fn devtools_chan(self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>>;
|
||||
fn layout_chan(self) -> LayoutChan;
|
||||
fn constellation_chan(self) -> ConstellationChan;
|
||||
fn windowproxy_handler(self) -> WindowProxyHandler;
|
||||
fn get_next_subpage_id(self) -> SubpageId;
|
||||
fn layout_is_idle(self) -> bool;
|
||||
fn get_pending_reflow_count(self) -> u32;
|
||||
fn add_pending_reflow(self);
|
||||
fn set_resize_event(self, event: WindowSizeData);
|
||||
fn steal_resize_event(self) -> Option<WindowSizeData>;
|
||||
fn set_page_clip_rect_with_new_viewport(self, viewport: Rect<f32>) -> bool;
|
||||
fn set_devtools_wants_updates(self, value: bool);
|
||||
fn IndexedGetter(self, _index: u32, _found: &mut bool) -> Option<Root<Window>>;
|
||||
fn thaw(self);
|
||||
fn freeze(self);
|
||||
fn need_emit_timeline_marker(self, timeline_type: TimelineMarkerType) -> bool;
|
||||
fn emit_timeline_marker(self, marker: TimelineMarker);
|
||||
fn set_devtools_timeline_marker(self,
|
||||
marker: TimelineMarkerType,
|
||||
reply: IpcSender<TimelineMarker>);
|
||||
fn drop_devtools_timeline_markers(self);
|
||||
fn set_webdriver_script_chan(self, chan: Option<IpcSender<WebDriverJSResult>>);
|
||||
fn is_alive(self) -> bool;
|
||||
fn parent(self) -> Option<Root<Window>>;
|
||||
}
|
||||
|
||||
pub trait ScriptHelpers {
|
||||
fn evaluate_js_on_global_with_result(self, code: &str,
|
||||
|
@ -677,8 +629,8 @@ impl<'a, T: Reflectable> ScriptHelpers for &'a T {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> WindowHelpers for &'a Window {
|
||||
fn clear_js_runtime(self) {
|
||||
impl Window {
|
||||
pub fn clear_js_runtime(&self) {
|
||||
let document = self.Document();
|
||||
NodeCast::from_ref(document.r()).teardown();
|
||||
|
||||
|
@ -703,7 +655,7 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
/// and no reflow is performed.
|
||||
///
|
||||
/// TODO(pcwalton): Only wait for style recalc, since we have off-main-thread layout.
|
||||
fn force_reflow(self, goal: ReflowGoal, query_type: ReflowQueryType, reason: ReflowReason) {
|
||||
pub fn force_reflow(&self, goal: ReflowGoal, query_type: ReflowQueryType, reason: ReflowReason) {
|
||||
let document = self.Document();
|
||||
let root = document.r().GetDocumentElement();
|
||||
let root = match root.r() {
|
||||
|
@ -774,7 +726,7 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
/// yet, the page is presumed invisible and no reflow is performed.
|
||||
///
|
||||
/// TODO(pcwalton): Only wait for style recalc, since we have off-main-thread layout.
|
||||
fn reflow(self, goal: ReflowGoal, query_type: ReflowQueryType, reason: ReflowReason) {
|
||||
pub fn reflow(&self, goal: ReflowGoal, query_type: ReflowQueryType, reason: ReflowReason) {
|
||||
let document = self.Document();
|
||||
let root = document.r().GetDocumentElement();
|
||||
let root = match root.r() {
|
||||
|
@ -797,7 +749,7 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
|
||||
/// Sends a ping to layout and waits for the response. The response will arrive when the
|
||||
/// layout task has finished any pending request messages.
|
||||
fn join_layout(self) {
|
||||
pub fn join_layout(&self) {
|
||||
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
||||
if let Some(join_port) = std_mem::replace(&mut *layout_join_port, None) {
|
||||
match join_port.try_recv() {
|
||||
|
@ -815,11 +767,11 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
}
|
||||
}
|
||||
|
||||
fn layout(&self) -> &LayoutRPC {
|
||||
pub fn layout(&self) -> &LayoutRPC {
|
||||
&*self.layout_rpc
|
||||
}
|
||||
|
||||
fn content_box_query(self, content_box_request: TrustedNodeAddress) -> Rect<Au> {
|
||||
pub fn content_box_query(&self, content_box_request: TrustedNodeAddress) -> Rect<Au> {
|
||||
self.reflow(ReflowGoal::ForScriptQuery,
|
||||
ReflowQueryType::ContentBoxQuery(content_box_request),
|
||||
ReflowReason::Query);
|
||||
|
@ -828,7 +780,7 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
rect
|
||||
}
|
||||
|
||||
fn content_boxes_query(self, content_boxes_request: TrustedNodeAddress) -> Vec<Rect<Au>> {
|
||||
pub fn content_boxes_query(&self, content_boxes_request: TrustedNodeAddress) -> Vec<Rect<Au>> {
|
||||
self.reflow(ReflowGoal::ForScriptQuery,
|
||||
ReflowQueryType::ContentBoxesQuery(content_boxes_request),
|
||||
ReflowReason::Query);
|
||||
|
@ -837,14 +789,14 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
rects
|
||||
}
|
||||
|
||||
fn client_rect_query(self, node_geometry_request: TrustedNodeAddress) -> Rect<i32> {
|
||||
pub fn client_rect_query(&self, node_geometry_request: TrustedNodeAddress) -> Rect<i32> {
|
||||
self.reflow(ReflowGoal::ForScriptQuery,
|
||||
ReflowQueryType::NodeGeometryQuery(node_geometry_request),
|
||||
ReflowReason::Query);
|
||||
self.layout_rpc.node_geometry().client_rect
|
||||
}
|
||||
|
||||
fn resolved_style_query(self,
|
||||
pub fn resolved_style_query(&self,
|
||||
element: TrustedNodeAddress,
|
||||
pseudo: Option<PseudoElement>,
|
||||
property: &Atom) -> Option<String> {
|
||||
|
@ -855,7 +807,7 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
resolved
|
||||
}
|
||||
|
||||
fn offset_parent_query(self, node: TrustedNodeAddress) -> (Option<Root<Element>>, Rect<Au>) {
|
||||
pub fn offset_parent_query(&self, node: TrustedNodeAddress) -> (Option<Root<Element>>, Rect<Au>) {
|
||||
self.reflow(ReflowGoal::ForScriptQuery,
|
||||
ReflowQueryType::OffsetParentQuery(node),
|
||||
ReflowReason::Query);
|
||||
|
@ -876,105 +828,105 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
(element, response.rect)
|
||||
}
|
||||
|
||||
fn handle_reflow_complete_msg(self, reflow_id: u32) {
|
||||
pub fn handle_reflow_complete_msg(&self, reflow_id: u32) {
|
||||
let last_reflow_id = self.last_reflow_id.get();
|
||||
if last_reflow_id == reflow_id {
|
||||
*self.layout_join_port.borrow_mut() = None;
|
||||
}
|
||||
}
|
||||
|
||||
fn init_browsing_context(self, doc: &Document, frame_element: Option<&Element>) {
|
||||
pub fn init_browsing_context(&self, doc: &Document, frame_element: Option<&Element>) {
|
||||
let mut browsing_context = self.browsing_context.borrow_mut();
|
||||
*browsing_context = Some(BrowsingContext::new(doc, frame_element));
|
||||
(*browsing_context).as_mut().unwrap().create_window_proxy();
|
||||
}
|
||||
|
||||
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
||||
fn load_url(self, url: Url) {
|
||||
pub fn load_url(&self, url: Url) {
|
||||
self.main_thread_script_chan().send(
|
||||
MainThreadScriptMsg::Navigate(self.id, LoadData::new(url))).unwrap();
|
||||
}
|
||||
|
||||
fn handle_fire_timer(self, timer_id: TimerId) {
|
||||
pub fn handle_fire_timer(&self, timer_id: TimerId) {
|
||||
self.timers.fire_timer(timer_id, self);
|
||||
self.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::Timer);
|
||||
}
|
||||
|
||||
fn set_fragment_name(self, fragment: Option<String>) {
|
||||
pub fn set_fragment_name(&self, fragment: Option<String>) {
|
||||
*self.fragment_name.borrow_mut() = fragment;
|
||||
}
|
||||
|
||||
fn steal_fragment_name(self) -> Option<String> {
|
||||
pub fn steal_fragment_name(&self) -> Option<String> {
|
||||
self.fragment_name.borrow_mut().take()
|
||||
}
|
||||
|
||||
fn set_window_size(self, size: WindowSizeData) {
|
||||
pub fn set_window_size(&self, size: WindowSizeData) {
|
||||
self.window_size.set(Some(size));
|
||||
}
|
||||
|
||||
fn window_size(self) -> Option<WindowSizeData> {
|
||||
pub fn window_size(&self) -> Option<WindowSizeData> {
|
||||
self.window_size.get()
|
||||
}
|
||||
|
||||
fn get_url(self) -> Url {
|
||||
pub fn get_url(&self) -> Url {
|
||||
let doc = self.Document();
|
||||
doc.r().url()
|
||||
}
|
||||
|
||||
fn resource_task(self) -> ResourceTask {
|
||||
pub fn resource_task(&self) -> ResourceTask {
|
||||
(*self.resource_task).clone()
|
||||
}
|
||||
|
||||
fn mem_profiler_chan(self) -> mem::ProfilerChan {
|
||||
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
|
||||
self.mem_profiler_chan.clone()
|
||||
}
|
||||
|
||||
fn devtools_chan(self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
||||
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
||||
self.devtools_chan.clone()
|
||||
}
|
||||
|
||||
fn layout_chan(self) -> LayoutChan {
|
||||
pub fn layout_chan(&self) -> LayoutChan {
|
||||
self.layout_chan.clone()
|
||||
}
|
||||
|
||||
fn constellation_chan(self) -> ConstellationChan {
|
||||
pub fn constellation_chan(&self) -> ConstellationChan {
|
||||
self.constellation_chan.clone()
|
||||
}
|
||||
|
||||
fn windowproxy_handler(self) -> WindowProxyHandler {
|
||||
pub fn windowproxy_handler(&self) -> WindowProxyHandler {
|
||||
WindowProxyHandler(self.dom_static.windowproxy_handler.0)
|
||||
}
|
||||
|
||||
fn get_next_subpage_id(self) -> SubpageId {
|
||||
pub fn get_next_subpage_id(&self) -> SubpageId {
|
||||
let subpage_id = self.next_subpage_id.get();
|
||||
let SubpageId(id_num) = subpage_id;
|
||||
self.next_subpage_id.set(SubpageId(id_num + 1));
|
||||
subpage_id
|
||||
}
|
||||
|
||||
fn layout_is_idle(self) -> bool {
|
||||
pub fn layout_is_idle(&self) -> bool {
|
||||
self.layout_join_port.borrow().is_none()
|
||||
}
|
||||
|
||||
fn get_pending_reflow_count(self) -> u32 {
|
||||
pub fn get_pending_reflow_count(&self) -> u32 {
|
||||
self.pending_reflow_count.get()
|
||||
}
|
||||
|
||||
fn add_pending_reflow(self) {
|
||||
pub fn add_pending_reflow(&self) {
|
||||
self.pending_reflow_count.set(self.pending_reflow_count.get() + 1);
|
||||
}
|
||||
|
||||
fn set_resize_event(self, event: WindowSizeData) {
|
||||
pub fn set_resize_event(&self, event: WindowSizeData) {
|
||||
self.resize_event.set(Some(event));
|
||||
}
|
||||
|
||||
fn steal_resize_event(self) -> Option<WindowSizeData> {
|
||||
pub fn steal_resize_event(&self) -> Option<WindowSizeData> {
|
||||
let event = self.resize_event.get();
|
||||
self.resize_event.set(None);
|
||||
event
|
||||
}
|
||||
|
||||
fn set_page_clip_rect_with_new_viewport(self, viewport: Rect<f32>) -> bool {
|
||||
pub fn set_page_clip_rect_with_new_viewport(&self, viewport: Rect<f32>) -> bool {
|
||||
// We use a clipping rectangle that is five times the size of the of the viewport,
|
||||
// so that we don't collect display list items for areas too far outside the viewport,
|
||||
// but also don't trigger reflows every time the viewport changes.
|
||||
|
@ -999,16 +951,16 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
had_clip_rect
|
||||
}
|
||||
|
||||
fn set_devtools_wants_updates(self, value: bool) {
|
||||
pub fn set_devtools_wants_updates(&self, value: bool) {
|
||||
self.devtools_wants_updates.set(value);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#accessing-other-browsing-contexts
|
||||
fn IndexedGetter(self, _index: u32, _found: &mut bool) -> Option<Root<Window>> {
|
||||
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Root<Window>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn thaw(self) {
|
||||
pub fn thaw(&self) {
|
||||
self.timers.resume();
|
||||
|
||||
// Push the document title to the compositor since we are
|
||||
|
@ -1017,42 +969,42 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
document.r().title_changed();
|
||||
}
|
||||
|
||||
fn freeze(self) {
|
||||
pub fn freeze(&self) {
|
||||
self.timers.suspend();
|
||||
}
|
||||
|
||||
fn need_emit_timeline_marker(self, timeline_type: TimelineMarkerType) -> bool {
|
||||
pub fn need_emit_timeline_marker(&self, timeline_type: TimelineMarkerType) -> bool {
|
||||
let markers = self.devtools_markers.borrow();
|
||||
markers.contains(&timeline_type)
|
||||
}
|
||||
|
||||
fn emit_timeline_marker(self, marker: TimelineMarker) {
|
||||
pub fn emit_timeline_marker(&self, marker: TimelineMarker) {
|
||||
let sender = self.devtools_marker_sender.borrow();
|
||||
let sender = sender.as_ref().expect("There is no marker sender");
|
||||
sender.send(marker).unwrap();
|
||||
}
|
||||
|
||||
fn set_devtools_timeline_marker(self,
|
||||
pub fn set_devtools_timeline_marker(&self,
|
||||
marker: TimelineMarkerType,
|
||||
reply: IpcSender<TimelineMarker>) {
|
||||
*self.devtools_marker_sender.borrow_mut() = Some(reply);
|
||||
self.devtools_markers.borrow_mut().insert(marker);
|
||||
}
|
||||
|
||||
fn drop_devtools_timeline_markers(self) {
|
||||
pub fn drop_devtools_timeline_markers(&self) {
|
||||
self.devtools_markers.borrow_mut().clear();
|
||||
*self.devtools_marker_sender.borrow_mut() = None;
|
||||
}
|
||||
|
||||
fn set_webdriver_script_chan(self, chan: Option<IpcSender<WebDriverJSResult>>) {
|
||||
pub fn set_webdriver_script_chan(&self, chan: Option<IpcSender<WebDriverJSResult>>) {
|
||||
*self.webdriver_script_chan.borrow_mut() = chan;
|
||||
}
|
||||
|
||||
fn is_alive(self) -> bool {
|
||||
pub fn is_alive(&self) -> bool {
|
||||
self.current_state.get() == WindowState::Alive
|
||||
}
|
||||
|
||||
fn parent(self) -> Option<Root<Window>> {
|
||||
pub fn parent(&self) -> Option<Root<Window>> {
|
||||
let browsing_context = self.browsing_context();
|
||||
let browsing_context = browsing_context.as_ref().unwrap();
|
||||
|
||||
|
|
|
@ -16,10 +16,9 @@ use dom::bindings::trace::JSTraceable;
|
|||
use dom::bindings::utils::{Reflectable, reflect_dom_object};
|
||||
use dom::dedicatedworkerglobalscope::{DedicatedWorkerGlobalScope, WorkerScriptMsg};
|
||||
use dom::errorevent::ErrorEvent;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable, EventHelpers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::messageevent::MessageEvent;
|
||||
use dom::window::WindowHelpers;
|
||||
use dom::workerglobalscope::WorkerGlobalScopeInit;
|
||||
|
||||
use devtools_traits::{DevtoolsPageInfo, ScriptToDevtoolsControlMsg};
|
||||
|
|
|
@ -12,7 +12,6 @@ use dom::bindings::js::{JS, Root, MutNullableHeap};
|
|||
use dom::bindings::utils::Reflectable;
|
||||
use dom::console::Console;
|
||||
use dom::crypto::Crypto;
|
||||
use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScopeHelpers;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::window::{base64_atob, base64_btoa};
|
||||
use dom::workerlocation::WorkerLocation;
|
||||
|
@ -284,19 +283,9 @@ impl<'a> WorkerGlobalScopeMethods for &'a WorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WorkerGlobalScopeHelpers {
|
||||
fn execute_script(self, source: DOMString);
|
||||
fn handle_fire_timer(self, timer_id: TimerId);
|
||||
fn script_chan(self) -> Box<ScriptChan + Send>;
|
||||
fn pipeline(self) -> PipelineId;
|
||||
fn new_script_pair(self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>);
|
||||
fn process_event(self, msg: CommonScriptMsg);
|
||||
fn get_cx(self) -> *mut JSContext;
|
||||
fn set_devtools_wants_updates(self, value: bool);
|
||||
}
|
||||
|
||||
impl<'a> WorkerGlobalScopeHelpers for &'a WorkerGlobalScope {
|
||||
fn execute_script(self, source: DOMString) {
|
||||
impl WorkerGlobalScope {
|
||||
pub fn execute_script(&self, source: DOMString) {
|
||||
match self.runtime.evaluate_script(
|
||||
self.reflector().get_jsobject(), source, self.worker_url.serialize(), 1) {
|
||||
Ok(_) => (),
|
||||
|
@ -310,7 +299,7 @@ impl<'a> WorkerGlobalScopeHelpers for &'a WorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
fn script_chan(self) -> Box<ScriptChan + Send> {
|
||||
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
|
||||
let dedicated =
|
||||
DedicatedWorkerGlobalScopeCast::to_ref(self);
|
||||
match dedicated {
|
||||
|
@ -319,7 +308,7 @@ impl<'a> WorkerGlobalScopeHelpers for &'a WorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
fn pipeline(self) -> PipelineId {
|
||||
pub fn pipeline(&self) -> PipelineId {
|
||||
let dedicated =
|
||||
DedicatedWorkerGlobalScopeCast::to_ref(self);
|
||||
match dedicated {
|
||||
|
@ -328,7 +317,7 @@ impl<'a> WorkerGlobalScopeHelpers for &'a WorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
fn new_script_pair(self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
|
||||
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
|
||||
let dedicated =
|
||||
DedicatedWorkerGlobalScopeCast::to_ref(self);
|
||||
match dedicated {
|
||||
|
@ -337,7 +326,7 @@ impl<'a> WorkerGlobalScopeHelpers for &'a WorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
fn process_event(self, msg: CommonScriptMsg) {
|
||||
pub fn process_event(&self, msg: CommonScriptMsg) {
|
||||
let dedicated =
|
||||
DedicatedWorkerGlobalScopeCast::to_ref(self);
|
||||
match dedicated {
|
||||
|
@ -346,15 +335,11 @@ impl<'a> WorkerGlobalScopeHelpers for &'a WorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_fire_timer(self, timer_id: TimerId) {
|
||||
pub fn handle_fire_timer(&self, timer_id: TimerId) {
|
||||
self.timers.fire_timer(timer_id, self);
|
||||
}
|
||||
|
||||
fn get_cx(self) -> *mut JSContext {
|
||||
self.runtime.cx()
|
||||
}
|
||||
|
||||
fn set_devtools_wants_updates(self, value: bool) {
|
||||
pub fn set_devtools_wants_updates(&self, value: bool) {
|
||||
self.devtools_wants_updates.set(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,9 @@ use dom::bindings::refcounted::Trusted;
|
|||
use dom::bindings::str::ByteString;
|
||||
use dom::bindings::utils::{Reflectable, reflect_dom_object};
|
||||
use dom::document::Document;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable, EventHelpers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::progressevent::ProgressEvent;
|
||||
use dom::urlsearchparams::URLSearchParamsHelpers;
|
||||
use dom::xmlhttprequesteventtarget::XMLHttpRequestEventTarget;
|
||||
use dom::xmlhttprequesteventtarget::XMLHttpRequestEventTargetTypeId;
|
||||
use dom::xmlhttprequestupload::XMLHttpRequestUpload;
|
||||
|
@ -747,29 +746,9 @@ impl XMLHttpRequestDerived for EventTarget {
|
|||
|
||||
pub type TrustedXHRAddress = Trusted<XMLHttpRequest>;
|
||||
|
||||
trait PrivateXMLHttpRequestHelpers {
|
||||
fn change_ready_state(self, XMLHttpRequestState);
|
||||
fn process_headers_available(self, cors_request: Option<CORSRequest>,
|
||||
gen_id: GenerationId, metadata: Metadata) -> Result<(), Error>;
|
||||
fn process_data_available(self, gen_id: GenerationId, payload: Vec<u8>);
|
||||
fn process_response_complete(self, gen_id: GenerationId, status: Result<(), String>) -> ErrorResult;
|
||||
fn process_partial_response(self, progress: XHRProgress);
|
||||
fn terminate_ongoing_fetch(self);
|
||||
fn insert_trusted_header(self, name: String, value: String);
|
||||
fn dispatch_progress_event(self, upload: bool, type_: DOMString, loaded: u64, total: Option<u64>);
|
||||
fn dispatch_upload_progress_event(self, type_: DOMString, partial_load: Option<u64>);
|
||||
fn dispatch_response_progress_event(self, type_: DOMString);
|
||||
fn text_response(self) -> DOMString;
|
||||
fn set_timeout(self, timeout: u32);
|
||||
fn cancel_timeout(self);
|
||||
fn filter_response_headers(self) -> Headers;
|
||||
fn discard_subsequent_responses(self);
|
||||
fn fetch(self, load_data: LoadData, cors_request: Result<Option<CORSRequest>,()>,
|
||||
global: GlobalRef) -> ErrorResult;
|
||||
}
|
||||
|
||||
impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
||||
fn change_ready_state(self, rs: XMLHttpRequestState) {
|
||||
impl XMLHttpRequest {
|
||||
fn change_ready_state(&self, rs: XMLHttpRequestState) {
|
||||
assert!(self.ready_state.get() != rs);
|
||||
self.ready_state.set(rs);
|
||||
let global = self.global.root();
|
||||
|
@ -781,7 +760,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
event.r().fire(target);
|
||||
}
|
||||
|
||||
fn process_headers_available(self, cors_request: Option<CORSRequest>,
|
||||
fn process_headers_available(&self, cors_request: Option<CORSRequest>,
|
||||
gen_id: GenerationId, metadata: Metadata) -> Result<(), Error> {
|
||||
|
||||
if let Some(ref req) = cors_request {
|
||||
|
@ -801,11 +780,11 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn process_data_available(self, gen_id: GenerationId, payload: Vec<u8>) {
|
||||
fn process_data_available(&self, gen_id: GenerationId, payload: Vec<u8>) {
|
||||
self.process_partial_response(XHRProgress::Loading(gen_id, ByteString::new(payload)));
|
||||
}
|
||||
|
||||
fn process_response_complete(self, gen_id: GenerationId, status: Result<(), String>)
|
||||
fn process_response_complete(&self, gen_id: GenerationId, status: Result<(), String>)
|
||||
-> ErrorResult {
|
||||
match status {
|
||||
Ok(()) => {
|
||||
|
@ -819,7 +798,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
}
|
||||
}
|
||||
|
||||
fn process_partial_response(self, progress: XHRProgress) {
|
||||
fn process_partial_response(&self, progress: XHRProgress) {
|
||||
let msg_id = progress.generation_id();
|
||||
|
||||
// Aborts processing if abort() or open() was called
|
||||
|
@ -941,20 +920,20 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
}
|
||||
}
|
||||
|
||||
fn terminate_ongoing_fetch(self) {
|
||||
fn terminate_ongoing_fetch(&self) {
|
||||
let GenerationId(prev_id) = self.generation_id.get();
|
||||
self.generation_id.set(GenerationId(prev_id + 1));
|
||||
*self.timeout_target.borrow_mut() = None;
|
||||
self.response_status.set(Ok(()));
|
||||
}
|
||||
|
||||
fn insert_trusted_header(self, name: String, value: String) {
|
||||
fn insert_trusted_header(&self, name: String, value: String) {
|
||||
// Insert a header without checking spec-compliance
|
||||
// Use for hardcoded headers
|
||||
self.request_headers.borrow_mut().set_raw(name, vec![value.into_bytes()]);
|
||||
}
|
||||
|
||||
fn dispatch_progress_event(self, upload: bool, type_: DOMString, loaded: u64, total: Option<u64>) {
|
||||
fn dispatch_progress_event(&self, upload: bool, type_: DOMString, loaded: u64, total: Option<u64>) {
|
||||
let global = self.global.root();
|
||||
let upload_target = self.upload.root();
|
||||
let progressevent = ProgressEvent::new(global.r(),
|
||||
|
@ -970,19 +949,19 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
event.fire(target);
|
||||
}
|
||||
|
||||
fn dispatch_upload_progress_event(self, type_: DOMString, partial_load: Option<u64>) {
|
||||
fn dispatch_upload_progress_event(&self, type_: DOMString, partial_load: Option<u64>) {
|
||||
// If partial_load is None, loading has completed and we can just use the value from the request body
|
||||
|
||||
let total = self.request_body_len.get() as u64;
|
||||
self.dispatch_progress_event(true, type_, partial_load.unwrap_or(total), Some(total));
|
||||
}
|
||||
|
||||
fn dispatch_response_progress_event(self, type_: DOMString) {
|
||||
fn dispatch_response_progress_event(&self, type_: DOMString) {
|
||||
let len = self.response.borrow().len() as u64;
|
||||
let total = self.response_headers.borrow().get::<ContentLength>().map(|x| {**x as u64});
|
||||
self.dispatch_progress_event(false, type_, len, total);
|
||||
}
|
||||
fn set_timeout(self, duration_ms: u32) {
|
||||
fn set_timeout(&self, duration_ms: u32) {
|
||||
struct XHRTimeout {
|
||||
xhr: TrustedXHRAddress,
|
||||
gen_id: GenerationId,
|
||||
|
@ -1025,13 +1004,13 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
);
|
||||
}
|
||||
|
||||
fn cancel_timeout(self) {
|
||||
fn cancel_timeout(&self) {
|
||||
if let Some(cancel_tx) = self.timeout_cancel.borrow_mut().take() {
|
||||
let _ = cancel_tx.send(());
|
||||
}
|
||||
}
|
||||
|
||||
fn text_response(self) -> DOMString {
|
||||
fn text_response(&self) -> DOMString {
|
||||
let mut encoding = UTF_8 as EncodingRef;
|
||||
match self.response_headers.borrow().get() {
|
||||
Some(&ContentType(mime::Mime(_, _, ref params))) => {
|
||||
|
@ -1049,7 +1028,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
// the result should be fine. XXXManishearth have a closer look at this later
|
||||
encoding.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap().to_owned()
|
||||
}
|
||||
fn filter_response_headers(self) -> Headers {
|
||||
fn filter_response_headers(&self) -> Headers {
|
||||
// https://fetch.spec.whatwg.org/#concept-response-header-list
|
||||
use hyper::error::Result;
|
||||
use hyper::header::SetCookie;
|
||||
|
@ -1081,11 +1060,11 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
headers
|
||||
}
|
||||
|
||||
fn discard_subsequent_responses(self) {
|
||||
fn discard_subsequent_responses(&self) {
|
||||
self.response_status.set(Err(()));
|
||||
}
|
||||
|
||||
fn fetch(self,
|
||||
fn fetch(&self,
|
||||
load_data: LoadData,
|
||||
cors_request: Result<Option<CORSRequest>,()>,
|
||||
global: GlobalRef) -> ErrorResult {
|
||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
|||
use dom::bindings::codegen::Bindings::XMLHttpRequestEventTargetBinding::XMLHttpRequestEventTargetMethods;
|
||||
use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
||||
use dom::bindings::codegen::InheritTypes::XMLHttpRequestEventTargetDerived;
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
|
||||
#[derive(JSTraceable, Copy, Clone, PartialEq, HeapSizeOf)]
|
||||
pub enum XMLHttpRequestEventTargetTypeId {
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::node::NodeHelpers;
|
||||
use dom::document::Document;
|
||||
use dom::window::Window;
|
||||
|
||||
use msg::constellation_msg::PipelineId;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#![allow(unsafe_code, unrooted_must_root)]
|
||||
|
||||
use document_loader::DocumentLoader;
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::InheritTypes::ProcessingInstructionCast;
|
||||
|
@ -14,20 +13,17 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLScriptElementCast};
|
|||
use dom::bindings::codegen::InheritTypes::{HTMLFormElementDerived, NodeCast};
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::js::{RootedReference};
|
||||
use dom::characterdata::{CharacterDataHelpers, CharacterDataTypeId};
|
||||
use dom::characterdata::CharacterDataTypeId;
|
||||
use dom::comment::Comment;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::Document;
|
||||
use dom::document::{DocumentSource, IsHTMLDocument};
|
||||
use dom::documenttype::DocumentType;
|
||||
use dom::element::{Element, AttributeHandlers, ElementHelpers, ElementCreator};
|
||||
use dom::element::{Element, ElementCreator};
|
||||
use dom::htmlscriptelement::HTMLScriptElement;
|
||||
use dom::htmlscriptelement::HTMLScriptElementHelpers;
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
use dom::node::{document_from_node, window_from_node};
|
||||
use dom::processinginstruction::ProcessingInstructionHelpers;
|
||||
use dom::servohtmlparser;
|
||||
use dom::servohtmlparser::{ServoHTMLParser, FragmentContext};
|
||||
use dom::text::Text;
|
||||
use parse::Parser;
|
||||
|
||||
use encoding::types::Encoding;
|
||||
|
@ -36,7 +32,7 @@ use html5ever::Attribute;
|
|||
use html5ever::serialize::TraversalScope;
|
||||
use html5ever::serialize::TraversalScope::{IncludeNode, ChildrenOnly};
|
||||
use html5ever::serialize::{Serializable, Serializer, AttrRef};
|
||||
use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText, NextParserState};
|
||||
use html5ever::tree_builder::{NextParserState, NodeOrText, QuirksMode, TreeSink};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use std::borrow::Cow;
|
||||
use std::io::{self, Write};
|
||||
|
@ -45,23 +41,6 @@ use tendril::StrTendril;
|
|||
use url::Url;
|
||||
use util::str::DOMString;
|
||||
|
||||
trait SinkHelpers {
|
||||
fn get_or_create(&self, child: NodeOrText<JS<Node>>) -> Root<Node>;
|
||||
}
|
||||
|
||||
impl SinkHelpers for servohtmlparser::Sink {
|
||||
fn get_or_create(&self, child: NodeOrText<JS<Node>>) -> Root<Node> {
|
||||
match child {
|
||||
AppendNode(n) => n.root(),
|
||||
AppendText(t) => {
|
||||
let doc = self.document.root();
|
||||
let text = Text::new(t.into(), doc.r());
|
||||
NodeCast::from_root(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TreeSink for servohtmlparser::Sink {
|
||||
type Handle = JS<Node>;
|
||||
fn get_document(&mut self) -> JS<Node> {
|
||||
|
|
|
@ -33,15 +33,14 @@ use dom::bindings::js::{RootCollectionPtr, Root, RootedReference};
|
|||
use dom::bindings::refcounted::{LiveDOMReferences, Trusted, TrustedReference, trace_refcounted_objects};
|
||||
use dom::bindings::trace::{JSTraceable, trace_traceables, RootedVec};
|
||||
use dom::bindings::utils::{WRAP_CALLBACKS, DOM_CALLBACKS};
|
||||
use dom::document::{Document, IsHTMLDocument, DocumentHelpers, DocumentProgressHandler};
|
||||
use dom::document::{Document, IsHTMLDocument, DocumentProgressHandler};
|
||||
use dom::document::{DocumentProgressTask, DocumentSource, MouseEventType};
|
||||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::event::{EventHelpers, EventBubbles, EventCancelable};
|
||||
use dom::htmliframeelement::HTMLIFrameElementHelpers;
|
||||
use dom::node::{Node, NodeHelpers, NodeDamage, window_from_node};
|
||||
use dom::element::Element;
|
||||
use dom::event::{EventBubbles, EventCancelable};
|
||||
use dom::node::{Node, NodeDamage, window_from_node};
|
||||
use dom::servohtmlparser::{ServoHTMLParser, ParserContext};
|
||||
use dom::uievent::UIEvent;
|
||||
use dom::window::{Window, WindowHelpers, ScriptHelpers, ReflowReason};
|
||||
use dom::window::{Window, ScriptHelpers, ReflowReason};
|
||||
use dom::worker::TrustedWorkerAddress;
|
||||
use layout_interface::{ReflowQueryType};
|
||||
use layout_interface::{self, NewLayoutTaskInfo, ScriptLayoutChan, LayoutChan, ReflowGoal};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! Common handling of keyboard input and state management for text input controls
|
||||
|
||||
use clipboard_provider::ClipboardProvider;
|
||||
use dom::keyboardevent::{KeyboardEvent, KeyboardEventHelpers, key_value};
|
||||
use dom::keyboardevent::{KeyboardEvent, key_value};
|
||||
use msg::constellation_msg::{Key, KeyModifiers};
|
||||
use msg::constellation_msg::{SHIFT, CONTROL, ALT, SUPER};
|
||||
use util::mem::HeapSizeOf;
|
||||
|
|
|
@ -11,9 +11,8 @@ use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, HTMLIFrameElem
|
|||
use dom::bindings::conversions::FromJSValConvertible;
|
||||
use dom::bindings::conversions::StringificationBehavior;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::DocumentHelpers;
|
||||
use dom::node::{Node, NodeHelpers};
|
||||
use dom::window::{ScriptHelpers, WindowHelpers};
|
||||
use dom::node::Node;
|
||||
use dom::window::ScriptHelpers;
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsapi::{RootedValue, HandleValue};
|
||||
use js::jsval::UndefinedValue;
|
||||
|
|
Загрузка…
Ссылка в новой задаче