mirror of
https://github.com/servo/servo.git
synced 2025-07-20 13:53:42 +01:00
Remove fields with parsed attribute values on HTMLTextAreaElement
https://github.com/servo/servo/issues/7863
This commit is contained in:
parent
0d52170f35
commit
3eb585f547
2 changed files with 20 additions and 32 deletions
|
@ -51,7 +51,7 @@ use dom::htmltableelement::{HTMLTableElement, HTMLTableElementLayoutHelpers};
|
||||||
use dom::htmltablerowelement::{HTMLTableRowElement, HTMLTableRowElementLayoutHelpers};
|
use dom::htmltablerowelement::{HTMLTableRowElement, HTMLTableRowElementLayoutHelpers};
|
||||||
use dom::htmltablesectionelement::{HTMLTableSectionElement, HTMLTableSectionElementLayoutHelpers};
|
use dom::htmltablesectionelement::{HTMLTableSectionElement, HTMLTableSectionElementLayoutHelpers};
|
||||||
use dom::htmltemplateelement::HTMLTemplateElement;
|
use dom::htmltemplateelement::HTMLTemplateElement;
|
||||||
use dom::htmltextareaelement::{HTMLTextAreaElement, RawLayoutHTMLTextAreaElementHelpers};
|
use dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers};
|
||||||
use dom::namednodemap::NamedNodeMap;
|
use dom::namednodemap::NamedNodeMap;
|
||||||
use dom::node::{CLICK_IN_PROGRESS, LayoutNodeHelpers, Node};
|
use dom::node::{CLICK_IN_PROGRESS, LayoutNodeHelpers, Node};
|
||||||
use dom::node::{NodeDamage, SEQUENTIALLY_FOCUSABLE, UnbindContext};
|
use dom::node::{NodeDamage, SEQUENTIALLY_FOCUSABLE, UnbindContext};
|
||||||
|
@ -440,7 +440,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
|
|
||||||
|
|
||||||
let cols = if let Some(this) = self.downcast::<HTMLTextAreaElement>() {
|
let cols = if let Some(this) = self.downcast::<HTMLTextAreaElement>() {
|
||||||
match (*this.unsafe_get()).get_cols_for_layout() {
|
match this.get_cols() {
|
||||||
0 => None,
|
0 => None,
|
||||||
c => Some(c as i32),
|
c => Some(c as i32),
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
|
|
||||||
|
|
||||||
let rows = if let Some(this) = self.downcast::<HTMLTextAreaElement>() {
|
let rows = if let Some(this) = self.downcast::<HTMLTextAreaElement>() {
|
||||||
match (*this.unsafe_get()).get_rows_for_layout() {
|
match this.get_rows() {
|
||||||
0 => None,
|
0 => None,
|
||||||
r => Some(r as i32),
|
r => Some(r as i32),
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{LayoutJS, Root};
|
use dom::bindings::js::{LayoutJS, Root};
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
|
use dom::element::RawLayoutElementHelpers;
|
||||||
use dom::element::{AttributeMutation, Element};
|
use dom::element::{AttributeMutation, Element};
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
@ -39,8 +40,6 @@ pub struct HTMLTextAreaElement {
|
||||||
htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
#[ignore_heap_size_of = "#7193"]
|
#[ignore_heap_size_of = "#7193"]
|
||||||
textinput: DOMRefCell<TextInput<ConstellationChan<ConstellationMsg>>>,
|
textinput: DOMRefCell<TextInput<ConstellationChan<ConstellationMsg>>>,
|
||||||
cols: Cell<u32>,
|
|
||||||
rows: Cell<u32>,
|
|
||||||
// https://html.spec.whatwg.org/multipage/#concept-textarea-dirty
|
// https://html.spec.whatwg.org/multipage/#concept-textarea-dirty
|
||||||
value_changed: Cell<bool>,
|
value_changed: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
@ -50,13 +49,10 @@ pub trait LayoutHTMLTextAreaElementHelpers {
|
||||||
unsafe fn get_value_for_layout(self) -> String;
|
unsafe fn get_value_for_layout(self) -> String;
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_absolute_insertion_point_for_layout(self) -> usize;
|
unsafe fn get_absolute_insertion_point_for_layout(self) -> usize;
|
||||||
}
|
|
||||||
|
|
||||||
pub trait RawLayoutHTMLTextAreaElementHelpers {
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_cols_for_layout(self) -> u32;
|
fn get_cols(self) -> u32;
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_rows_for_layout(self) -> u32;
|
fn get_rows(self) -> u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
||||||
|
@ -71,19 +67,25 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
||||||
unsafe fn get_absolute_insertion_point_for_layout(self) -> usize {
|
unsafe fn get_absolute_insertion_point_for_layout(self) -> usize {
|
||||||
(*self.unsafe_get()).textinput.borrow_for_layout().get_absolute_insertion_point()
|
(*self.unsafe_get()).textinput.borrow_for_layout().get_absolute_insertion_point()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> RawLayoutHTMLTextAreaElementHelpers for &'a HTMLTextAreaElement {
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_cols_for_layout(self) -> u32 {
|
fn get_cols(self) -> u32 {
|
||||||
self.cols.get()
|
unsafe {
|
||||||
|
(*self.upcast::<Element>().unsafe_get())
|
||||||
|
.get_attr_for_layout(&ns!(), &atom!("cols"))
|
||||||
|
.map(AttrValue::as_uint)
|
||||||
|
.unwrap_or(DEFAULT_COLS)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_rows_for_layout(self) -> u32 {
|
fn get_rows(self) -> u32 {
|
||||||
self.rows.get()
|
unsafe {
|
||||||
|
(*self.upcast::<Element>().unsafe_get())
|
||||||
|
.get_attr_for_layout(&ns!(), &atom!("rows"))
|
||||||
|
.map(AttrValue::as_uint)
|
||||||
|
.unwrap_or(DEFAULT_ROWS)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +102,6 @@ impl HTMLTextAreaElement {
|
||||||
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
|
||||||
localName, prefix, document),
|
localName, prefix, document),
|
||||||
textinput: DOMRefCell::new(TextInput::new(Lines::Multiple, DOMString::new(), chan, None)),
|
textinput: DOMRefCell::new(TextInput::new(Lines::Multiple, DOMString::new(), chan, None)),
|
||||||
cols: Cell::new(DEFAULT_COLS),
|
|
||||||
rows: Cell::new(DEFAULT_ROWS),
|
|
||||||
value_changed: Cell::new(false),
|
value_changed: Cell::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,18 +268,6 @@ impl VirtualMethods for HTMLTextAreaElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
atom!("cols") => {
|
|
||||||
let cols = mutation.new_value(attr).map(|value| {
|
|
||||||
value.as_uint()
|
|
||||||
});
|
|
||||||
self.cols.set(cols.unwrap_or(DEFAULT_COLS));
|
|
||||||
},
|
|
||||||
atom!("rows") => {
|
|
||||||
let rows = mutation.new_value(attr).map(|value| {
|
|
||||||
value.as_uint()
|
|
||||||
});
|
|
||||||
self.rows.set(rows.unwrap_or(DEFAULT_ROWS));
|
|
||||||
},
|
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue