mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #8983 - Manishearth:cursors, r=jdm
Various textinput fixes - Currently the cursor sticks around if you click elsewhere. Now the text inputs are relayout-ed on blur. - Currently whitespace gets collapsed in text input (https://github.com/servo/servo/issues/8772). Not anymore. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8983) <!-- Reviewable:end -->
This commit is contained in:
commit
099beee85c
9 changed files with 117 additions and 7 deletions
|
@ -1910,7 +1910,9 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn set_focus_state(&self, value: bool) {
|
||||
self.set_state(IN_FOCUS_STATE, value)
|
||||
self.set_state(IN_FOCUS_STATE, value);
|
||||
let doc = document_from_node(self);
|
||||
doc.content_changed(self.upcast(), NodeDamage::OtherNodeDamage);
|
||||
}
|
||||
|
||||
pub fn get_hover_state(&self) -> bool {
|
||||
|
|
|
@ -202,6 +202,9 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
|
|||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_insertion_point_index_for_layout(self) -> Option<isize> {
|
||||
if !(*self.unsafe_get()).upcast::<Element>().get_focus_state() {
|
||||
return None;
|
||||
}
|
||||
match (*self.unsafe_get()).input_type.get() {
|
||||
InputType::InputText => {
|
||||
let raw = self.get_value_for_layout();
|
||||
|
|
|
@ -45,7 +45,7 @@ pub trait LayoutHTMLTextAreaElementHelpers {
|
|||
#[allow(unsafe_code)]
|
||||
unsafe fn get_value_for_layout(self) -> String;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_absolute_insertion_point_for_layout(self) -> usize;
|
||||
unsafe fn get_absolute_insertion_point_for_layout(self) -> Option<usize>;
|
||||
#[allow(unsafe_code)]
|
||||
fn get_cols(self) -> u32;
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -61,8 +61,13 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
|||
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_absolute_insertion_point_for_layout(self) -> usize {
|
||||
(*self.unsafe_get()).textinput.borrow_for_layout().get_absolute_insertion_point()
|
||||
unsafe fn get_absolute_insertion_point_for_layout(self) -> Option<usize> {
|
||||
if (*self.unsafe_get()).upcast::<Element>().get_focus_state() {
|
||||
Some((*self.unsafe_get()).textinput.borrow_for_layout()
|
||||
.get_absolute_insertion_point())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue