From 776aae6399989009a99e4cc4735f62ea2c7215af Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 1 Apr 2016 11:20:11 -0700 Subject: [PATCH] Fix incremental reflow of text selection changes Also replace force_relayout methods with direct Node::dirty calls, for clarity. --- components/script/dom/htmlinputelement.rs | 16 ++++------ components/script/dom/htmltextareaelement.rs | 13 ++------ tests/wpt/mozilla/meta/MANIFEST.json | 24 ++++++++++++++ .../css/input_selection_incremental_a.html | 31 +++++++++++++++++++ .../css/input_selection_incremental_ref.html | 19 ++++++++++++ 5 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 tests/wpt/mozilla/tests/css/input_selection_incremental_a.html create mode 100644 tests/wpt/mozilla/tests/css/input_selection_incremental_ref.html diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index e14a91ae9d7..e2434d60759 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -200,6 +200,7 @@ impl HTMLInputElement { text_input.selection_begin = Some(text_input.get_text_point_for_absolute_point(start)); text_input.edit_point = text_input.get_text_point_for_absolute_point(end); self.selection_direction.set(*direction); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); } } @@ -401,7 +402,7 @@ impl HTMLInputElementMethods for HTMLInputElement { } self.value_changed.set(true); - self.force_relayout(); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); Ok(()) } @@ -586,11 +587,6 @@ fn in_same_group(other: &HTMLInputElement, owner: Option<&HTMLFormElement>, } impl HTMLInputElement { - fn force_relayout(&self) { - let doc = document_from_node(self); - doc.content_changed(self.upcast(), NodeDamage::OtherNodeDamage) - } - fn radio_group_updated(&self, group: Option<&Atom>) { if self.Checked() { broadcast_radio_checked(self, group); @@ -654,7 +650,7 @@ impl HTMLInputElement { self.get_radio_group_name().as_ref()); } - self.force_relayout(); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); //TODO: dispatch change event } @@ -684,7 +680,7 @@ impl HTMLInputElement { .expect("Failed to reset input value to default."); self.value_dirty.set(false); self.value_changed.set(false); - self.force_relayout(); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); } } @@ -889,11 +885,11 @@ impl VirtualMethods for HTMLInputElement { ChangeEventRunnable::send(self.upcast::()); } - self.force_relayout(); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); event.PreventDefault(); } RedrawSelection => { - self.force_relayout(); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); event.PreventDefault(); } Nothing => (), diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 0f82919124f..a3279fc6fe3 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -206,7 +206,7 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement { self.textinput.borrow_mut().set_content(value); self.value_changed.set(true); - self.force_relayout(); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); } // https://html.spec.whatwg.org/multipage/#dom-lfe-labels @@ -230,13 +230,6 @@ impl HTMLTextAreaElement { } -impl HTMLTextAreaElement { - fn force_relayout(&self) { - let doc = document_from_node(self); - doc.content_changed(self.upcast(), NodeDamage::OtherNodeDamage) - } -} - impl VirtualMethods for HTMLTextAreaElement { fn super_type(&self) -> Option<&VirtualMethods> { Some(self.upcast::() as &VirtualMethods) @@ -321,11 +314,11 @@ impl VirtualMethods for HTMLTextAreaElement { ChangeEventRunnable::send(self.upcast::()); } - self.force_relayout(); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); event.PreventDefault(); } KeyReaction::RedrawSelection => { - self.force_relayout(); + self.upcast::().dirty(NodeDamage::OtherNodeDamage); event.PreventDefault(); } KeyReaction::Nothing => (), diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 9e552bd9c01..ef666bfb904 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -2603,6 +2603,18 @@ "url": "/_mozilla/css/input_selection_a.html" } ], + "css/input_selection_incremental_a.html": [ + { + "path": "css/input_selection_incremental_a.html", + "references": [ + [ + "/_mozilla/css/input_selection_incremental_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/input_selection_incremental_a.html" + } + ], "css/input_selection_ref.html": [ { "path": "css/input_selection_ref.html", @@ -9025,6 +9037,18 @@ "url": "/_mozilla/css/input_selection_a.html" } ], + "css/input_selection_incremental_a.html": [ + { + "path": "css/input_selection_incremental_a.html", + "references": [ + [ + "/_mozilla/css/input_selection_incremental_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/input_selection_incremental_a.html" + } + ], "css/input_selection_ref.html": [ { "path": "css/input_selection_ref.html", diff --git a/tests/wpt/mozilla/tests/css/input_selection_incremental_a.html b/tests/wpt/mozilla/tests/css/input_selection_incremental_a.html new file mode 100644 index 00000000000..11bc66128a7 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/input_selection_incremental_a.html @@ -0,0 +1,31 @@ + + + + + input selection incremental test + + + + + + + + diff --git a/tests/wpt/mozilla/tests/css/input_selection_incremental_ref.html b/tests/wpt/mozilla/tests/css/input_selection_incremental_ref.html new file mode 100644 index 00000000000..7b9986ce98e --- /dev/null +++ b/tests/wpt/mozilla/tests/css/input_selection_incremental_ref.html @@ -0,0 +1,19 @@ + + + + + input selection incremental reference + + + + Hello + +