Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the amount of dom code used outside the script crate. #11656

Merged
merged 8 commits into from Jun 7, 2016

Move the definition of ServoThreadSafeLayoutNode::image_url to script.

  • Loading branch information
Ms2ger committed Jun 7, 2016
commit ef3c6a7773f31fd8dbdee074893346692adbf8d3
@@ -48,7 +48,6 @@ use script::dom::document::{Document, LayoutDocumentHelpers};
use script::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers};
use script::dom::htmlcanvaselement::{LayoutHTMLCanvasElementHelpers, HTMLCanvasData};
use script::dom::htmliframeelement::HTMLIFrameElement;
use script::dom::htmlimageelement::LayoutHTMLImageElementHelpers;
use script::dom::node::{CAN_BE_FRAGMENTED, HAS_CHANGED, HAS_DIRTY_DESCENDANTS, IS_DIRTY};
use script::dom::node::{LayoutNodeHelpers, Node, OpaqueStyleAndLayoutData};
use script::dom::text::Text;
@@ -1147,11 +1146,8 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> {
}

fn image_url(&self) -> Option<Url> {
unsafe {
self.get_jsmanaged().downcast()
.expect("not an image!")
.image_url()
}
let this = unsafe { self.get_jsmanaged() };
this.image_url()
}

fn canvas_data(&self) -> Option<HTMLCanvasData> {
@@ -40,6 +40,7 @@ use dom::eventtarget::EventTarget;
use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement;
use dom::htmlimageelement::{HTMLImageElement, LayoutHTMLImageElementHelpers};
use dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers};
use dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers};
use dom::nodelist::NodeList;
@@ -71,6 +72,7 @@ use std::mem;
use std::ops::Range;
use string_cache::{Atom, Namespace, QualName};
use style::selector_impl::ServoSelectorImpl;
use url::Url;
use util::thread_state;
use uuid::Uuid;

@@ -962,6 +964,7 @@ pub trait LayoutNodeHelpers {

fn text_content(&self) -> String;
fn selection(&self) -> Option<Range<usize>>;
fn image_url(&self) -> Option<Url>;
}

impl LayoutNodeHelpers for LayoutJS<Node> {
@@ -1082,6 +1085,15 @@ impl LayoutNodeHelpers for LayoutJS<Node> {

None
}

#[allow(unsafe_code)]
fn image_url(&self) -> Option<Url> {
unsafe {
self.downcast::<HTMLImageElement>()
.expect("not an image!")
.image_url()
}
}
}


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.