Skip to content

Commit

Permalink
Auto merge of #8294 - Ms2ger:layout-input, r=jdm
Browse files Browse the repository at this point in the history
Remove RawLayoutHTMLInputElementHelpers.



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8294)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Nov 2, 2015
2 parents 3282174 + 0dacd33 commit 5c11c88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
8 changes: 4 additions & 4 deletions components/script/dom/element.rs
Expand Up @@ -42,7 +42,7 @@ use dom::htmlcollection::HTMLCollection;
use dom::htmlfieldsetelement::HTMLFieldSetElement;
use dom::htmlfontelement::HTMLFontElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers};
use dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers};
use dom::htmllabelelement::HTMLLabelElement;
use dom::htmllegendelement::HTMLLegendElement;
use dom::htmloptgroupelement::HTMLOptGroupElement;
Expand Down Expand Up @@ -374,7 +374,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
// a text field
match (*self.unsafe_get()).get_attr_val_for_layout(&ns!(""), &atom!("type")) {
Some("text") | Some("password") => {
match (*this.unsafe_get()).get_size_for_layout() {
match this.get_size_for_layout() {
0 => None,
s => Some(s as i32),
}
Expand Down Expand Up @@ -574,7 +574,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
// TODO option and menuitem can also have a checked state.
match self.downcast::<HTMLInputElement>() {
Some(input) => unsafe {
(*input.unsafe_get()).get_checked_state_for_layout()
input.get_checked_state_for_layout()
},
None => false,
}
Expand All @@ -586,7 +586,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
// TODO progress elements can also be matched with :indeterminate
match self.downcast::<HTMLInputElement>() {
Some(input) => unsafe {
(*input.unsafe_get()).get_indeterminate_state_for_layout()
input.get_indeterminate_state_for_layout()
},
None => false,
}
Expand Down
29 changes: 8 additions & 21 deletions components/script/dom/htmlinputelement.rs
Expand Up @@ -15,7 +15,7 @@ use dom::bindings::conversions::Castable;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, LayoutJS, Root, RootedReference};
use dom::document::Document;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers, LayoutElementHelpers};
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget;
use dom::htmlelement::HTMLElement;
Expand Down Expand Up @@ -136,15 +136,10 @@ pub trait LayoutHTMLInputElementHelpers {
unsafe fn get_size_for_layout(self) -> u32;
#[allow(unsafe_code)]
unsafe fn get_insertion_point_for_layout(self) -> Option<TextPoint>;
}

pub trait RawLayoutHTMLInputElementHelpers {
#[allow(unsafe_code)]
unsafe fn get_checked_state_for_layout(&self) -> bool;
#[allow(unsafe_code)]
unsafe fn get_indeterminate_state_for_layout(&self) -> bool;
unsafe fn get_checked_state_for_layout(self) -> bool;
#[allow(unsafe_code)]
unsafe fn get_size_for_layout(&self) -> u32;
unsafe fn get_indeterminate_state_for_layout(self) -> bool;
}

impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
Expand Down Expand Up @@ -184,7 +179,7 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_size_for_layout(self) -> u32 {
(*self.unsafe_get()).get_size_for_layout()
(*self.unsafe_get()).size.get()
}

#[allow(unrooted_must_root)]
Expand All @@ -196,25 +191,17 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
_ => None
}
}
}

impl RawLayoutHTMLInputElementHelpers for HTMLInputElement {
#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_checked_state_for_layout(&self) -> bool {
self.Checked()
}

#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_indeterminate_state_for_layout(&self) -> bool {
self.Indeterminate()
unsafe fn get_checked_state_for_layout(self) -> bool {
self.upcast::<Element>().get_state_for_layout().contains(IN_CHECKED_STATE)
}

#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_size_for_layout(&self) -> u32 {
self.size.get()
unsafe fn get_indeterminate_state_for_layout(self) -> bool {
self.upcast::<Element>().get_state_for_layout().contains(IN_INDETERMINATE_STATE)
}
}

Expand Down

0 comments on commit 5c11c88

Please sign in to comment.