diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/bindings/conversions.rs | 42 | ||||
-rw-r--r-- | components/script/dom/node.rs | 5 | ||||
-rw-r--r-- | components/script/lib.rs | 3 | ||||
-rw-r--r-- | components/script/script_task.rs | 12 | ||||
-rw-r--r-- | components/script/webdriver_handlers.rs | 17 |
5 files changed, 27 insertions, 52 deletions
diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 4afbe9aa29b..b887fd27d76 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -56,48 +56,6 @@ use std::{ptr, slice}; use util::str::DOMString; pub use util::str::{StringificationBehavior, jsstring_to_str}; - -trait As<O>: Copy { - fn cast(self) -> O; -} - -macro_rules! impl_as { - ($I:ty, $O:ty) => ( - impl As<$O> for $I { - fn cast(self) -> $O { - self as $O - } - } - ) -} - -impl_as!(f64, u8); -impl_as!(f64, u16); -impl_as!(f64, u32); -impl_as!(f64, u64); -impl_as!(f64, i8); -impl_as!(f64, i16); -impl_as!(f64, i32); -impl_as!(f64, i64); - -impl_as!(u8, f64); -impl_as!(u16, f64); -impl_as!(u32, f64); -impl_as!(u64, f64); -impl_as!(i8, f64); -impl_as!(i16, f64); -impl_as!(i32, f64); -impl_as!(i64, f64); - -impl_as!(i32, i8); -impl_as!(i32, u8); -impl_as!(i32, i16); -impl_as!(u16, u16); -impl_as!(i32, i32); -impl_as!(u32, u32); -impl_as!(i64, i64); -impl_as!(u64, u64); - /// A trait to check whether a given `JSObject` implements an IDL interface. pub trait IDLInterface { /// Returns whether the given DOM class derives that interface. diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index f7b694300af..d6907ae7cac 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -435,11 +435,6 @@ impl Node { } #[inline] - pub fn is_anchor_element(&self) -> bool { - self.type_id() == NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) - } - - #[inline] pub fn is_doctype(&self) -> bool { self.type_id() == NodeTypeId::DocumentType } diff --git a/components/script/lib.rs b/components/script/lib.rs index 3ef9edff9ff..cd2a0720ce2 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -99,6 +99,8 @@ mod unpremultiplytable; mod webdriver_handlers; use dom::bindings::codegen::RegisterBindings; +use js::jsapi::SetDOMProxyInformation; +use std::ptr; #[cfg(target_os = "linux")] #[allow(unsafe_code)] @@ -145,6 +147,7 @@ fn perform_platform_specific_initialization() {} pub fn init() { unsafe { assert_eq!(js::jsapi::JS_Init(), true); + SetDOMProxyInformation(ptr::null(), 0, Some(script_task::shadow_check_callback)); } // Create the global vtables used by the (generated) DOM diff --git a/components/script/script_task.rs b/components/script/script_task.rs index dd1cf1a546c..95e1c7f356f 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -35,6 +35,7 @@ use dom::document::{Document, DocumentProgressHandler, IsHTMLDocument}; use dom::document::{DocumentSource, MouseEventType}; use dom::element::Element; use dom::event::{Event, EventBubbles, EventCancelable}; +use dom::htmlanchorelement::HTMLAnchorElement; use dom::node::{Node, NodeDamage, window_from_node}; use dom::servohtmlparser::{ParserContext, ServoHTMLParser}; use dom::uievent::UIEvent; @@ -49,7 +50,7 @@ use hyper::mime::{Mime, SubLevel, TopLevel}; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use js::glue::CollectServoSizes; -use js::jsapi::{DOMProxyShadowsResult, HandleId, HandleObject, RootedValue, SetDOMProxyInformation}; +use js::jsapi::{DOMProxyShadowsResult, HandleId, HandleObject, RootedValue}; use js::jsapi::{DisableIncrementalGC, JS_AddExtraGCRootsTracer, JS_SetWrapObjectCallbacks}; use js::jsapi::{GCDescription, GCProgress, JSGCInvocationKind, SetGCSliceCallback}; use js::jsapi::{JSAutoRequest, JSGCStatus, JS_GetRuntime, JS_SetGCCallback, SetDOMCallbacks}; @@ -588,7 +589,7 @@ unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, } } -unsafe extern "C" fn shadow_check_callback(_cx: *mut JSContext, +pub unsafe extern "C" fn shadow_check_callback(_cx: *mut JSContext, _object: HandleObject, _id: HandleId) -> DOMProxyShadowsResult { // XXX implement me DOMProxyShadowsResult::ShadowCheckFailed @@ -704,7 +705,6 @@ impl ScriptTask { unsafe { unsafe extern "C" fn empty_wrapper_callback(_: *mut JSContext, _: *mut JSObject) -> bool { true } - SetDOMProxyInformation(ptr::null(), 0, Some(shadow_check_callback)); SetDOMCallbacks(runtime.rt(), &DOM_CALLBACKS); SetPreserveWrapperCallback(runtime.rt(), Some(empty_wrapper_callback)); // Pre barriers aren't working correctly at the moment @@ -1108,6 +1108,8 @@ impl ScriptTask { webdriver_handlers::handle_get_name(&page, pipeline_id, node_id, reply), WebDriverScriptCommand::GetElementAttribute(node_id, name, reply) => webdriver_handlers::handle_get_attribute(&page, pipeline_id, node_id, name, reply), + WebDriverScriptCommand::GetElementCSS(node_id, name, reply) => + webdriver_handlers::handle_get_css(&page, pipeline_id, node_id, name, reply), WebDriverScriptCommand::GetElementText(node_id, reply) => webdriver_handlers::handle_get_text(&page, pipeline_id, node_id, reply), WebDriverScriptCommand::GetFrameId(frame_id, reply) => @@ -1796,7 +1798,7 @@ impl ScriptTask { // Notify Constellation about anchors that are no longer mouse over targets. for target in &*prev_mouse_over_targets { if !mouse_over_targets.contains(target) { - if target.upcast::<Node>().is_anchor_element() { + if target.is::<HTMLAnchorElement>() { let event = ConstellationMsg::NodeStatus(None); let ConstellationChan(ref chan) = self.constellation_chan; chan.send(event).unwrap(); @@ -1807,7 +1809,7 @@ impl ScriptTask { // Notify Constellation about the topmost anchor mouse over target. for target in &*mouse_over_targets { - if target.upcast::<Node>().is_anchor_element() { + if target.is::<HTMLAnchorElement>() { let status = target.get_attribute(&ns!(""), &atom!("href")) .and_then(|href| { let value = href.value(); diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 0bf2ede1aeb..818ad20abf9 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -2,12 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods; use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; +use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::conversions::{FromJSValConvertible, StringificationBehavior}; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; @@ -217,6 +219,21 @@ pub fn handle_get_attribute(page: &Rc<Page>, }).unwrap(); } +pub fn handle_get_css(page: &Rc<Page>, + pipeline: PipelineId, + node_id: String, + name: String, + reply: IpcSender<Result<String, ()>>) { + reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) { + Some(node) => { + let window = page.window(); + let elem = node.downcast::<Element>().unwrap(); + Ok(String::from( + window.GetComputedStyle(&elem, None).GetPropertyValue(DOMString::from(name)))) + }, + None => Err(()) + }).unwrap(); +} pub fn handle_get_url(page: &Rc<Page>, _pipeline: PipelineId, |