Commit d1b6fceb authored by Joey Arhar's avatar Joey Arhar Committed by Commit Bot

Don't update text input elements when any attribute is changed

This change removes an unnecessary update to children of
<input type="text"> elements when any attribute is modified on the
element.

A similar patch was made in WebKit here:
https://trac.webkit.org/changeset/208653/webkit

In the WebKit patch, the update still occurs if the attribute is "value"
or "placeholder." We already handle "value" attribute changes in a case
in HTMLInputElement::ParseAttribute, and we already handle "placeholder"
attribute changes in TextControlElement::ParseAttribute. Since we handle
those cases explicitly, we can remove the entire AttributeChanged
function.

Bug: 1012774
Change-Id: Ib75fde9c5b3e1f9eea4232bf5bfa915d573b9c7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865658Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707397}
parent 8640896a
......@@ -861,7 +861,6 @@ void HTMLInputElement::ParseAttribute(
LogUpdateAttributeIfIsolatedWorldAndInDocument("input", params);
TextControlElement::ParseAttribute(params);
}
input_type_view_->AttributeChanged();
}
void HTMLInputElement::ParserDidSetAttributes() {
......
......@@ -144,8 +144,6 @@ void InputTypeView::DidDispatchClick(Event&, const ClickHandlingState&) {}
void InputTypeView::UpdateView() {}
void InputTypeView::AttributeChanged() {}
void InputTypeView::MultipleAttributeChanged() {}
void InputTypeView::DisabledAttributeChanged() {}
......
......@@ -114,7 +114,6 @@ class CORE_EXPORT InputTypeView : public GarbageCollectedMixin {
virtual void AltAttributeChanged();
virtual void SrcAttributeChanged();
virtual void UpdateView();
virtual void AttributeChanged();
virtual void MultipleAttributeChanged();
virtual void DisabledAttributeChanged();
virtual void ReadonlyAttributeChanged();
......
......@@ -374,9 +374,7 @@ void TextFieldInputType::ListAttributeTargetChanged() {
}
}
void TextFieldInputType::AttributeChanged() {
// TODO(crbug.com/1012774): Updating on any attribute update should be
// unnecessary. We should figure out what attributes affect.
void TextFieldInputType::ValueAttributeChanged() {
UpdateView();
}
......
......@@ -56,7 +56,7 @@ class TextFieldInputType : public InputType,
void CreateShadowSubtree() override;
void DestroyShadowSubtree() override;
void AttributeChanged() override;
void ValueAttributeChanged() override;
void DisabledAttributeChanged() override;
void ReadonlyAttributeChanged() override;
bool SupportsReadOnly() const override;
......
......@@ -3,7 +3,7 @@ Setting the incremental attribute on an input type=search
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS [object Internals] is defined.
PASS internals.updateStyleAndReturnAffectedElementCount() is 1
PASS internals.updateStyleAndReturnAffectedElementCount() is 0
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -19,9 +19,6 @@ searchInput.offsetTop;
getComputedStyle(searchInput); // Force recalc.
searchInput.setAttribute("incremental", "");
// Ideally, the expected value below should be "0", but the search control
// button has its opacity changed unconditionally through inline style on
// every attribute change on the input element.
shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1");
shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "0");
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment