Commit 81fb8abc authored by rune's avatar rune Committed by Commit bot

Remove extraneous SubtreeStyleChange for min/maxlength changes.

Validation already takes care of :valid/:invalid changes through
invalidation sets. This reduces the number of elements being recalculated
and gets rid of a SubtreeStyleChange which relies on sibling tree recalcs.

R=tkent@chromium.org
BUG=557440

Review URL: https://codereview.chromium.org/1458363003

Cr-Commit-Position: refs/heads/master@{#361123}
parent 774a62a2
...@@ -15,6 +15,12 @@ PASS getComputedStyle(formValid, '').backgroundColor is green ...@@ -15,6 +15,12 @@ PASS getComputedStyle(formValid, '').backgroundColor is green
PASS getComputedStyle(formInvalid, '').backgroundColor is transparent PASS getComputedStyle(formInvalid, '').backgroundColor is transparent
PASS internals.updateStyleAndReturnAffectedElementCount() is 2 PASS internals.updateStyleAndReturnAffectedElementCount() is 2
PASS getComputedStyle(formInvalid, '').backgroundColor is green PASS getComputedStyle(formInvalid, '').backgroundColor is green
PASS getComputedStyle(maxlengthInvalid, '').backgroundColor is transparent
PASS internals.updateStyleAndReturnAffectedElementCount() is 1
PASS getComputedStyle(maxlengthInvalid, '').backgroundColor is green
PASS getComputedStyle(minlengthInvalid, '').backgroundColor is transparent
PASS internals.updateStyleAndReturnAffectedElementCount() is 1
PASS getComputedStyle(minlengthInvalid, '').backgroundColor is green
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
...@@ -23,3 +29,5 @@ TEST COMPLETE ...@@ -23,3 +29,5 @@ TEST COMPLETE
...@@ -5,7 +5,9 @@ input { background-color: transparent } ...@@ -5,7 +5,9 @@ input { background-color: transparent }
#inputValid:valid, #inputValid:valid,
#inputInvalid:invalid, #inputInvalid:invalid,
#formValid:valid, #formValid:valid,
#formInvalid:invalid { #formInvalid:invalid,
#maxlengthInvalid:invalid,
#minlengthInvalid:invalid {
background-color: green background-color: green
} }
...@@ -42,6 +44,16 @@ input + div { ...@@ -42,6 +44,16 @@ input + div {
<div></div> <div></div>
<div></div> <div></div>
</div> </div>
<input id="maxlengthInvalid" type="text"></input>
<div>
<div></div>
<div></div>
</div>
<input id="minlengthInvalid" type="text"></input>
<div>
<div></div>
<div></div>
</div>
<script> <script>
description("Use descendant invalidation sets for :valid and :invalid pseudo classes.") description("Use descendant invalidation sets for :valid and :invalid pseudo classes.")
...@@ -77,4 +89,27 @@ if (window.internals) ...@@ -77,4 +89,27 @@ if (window.internals)
shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2");
shouldBe("getComputedStyle(formInvalid, '').backgroundColor", "green"); shouldBe("getComputedStyle(formInvalid, '').backgroundColor", "green");
// Make sure the value is user input, otherwise setting maxlength/minlength
// won't cause a validation.
if (window.eventSender) {
maxlengthInvalid.focus();
eventSender.keyDown("x");
eventSender.keyDown("x");
minlengthInvalid.focus();
eventSender.keyDown("x");
}
shouldBe("getComputedStyle(maxlengthInvalid, '').backgroundColor", "transparent");
document.body.offsetTop; // Force recalc.
maxlengthInvalid.setAttribute("maxlength", "1");
if (window.internals)
shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1");
shouldBe("getComputedStyle(maxlengthInvalid, '').backgroundColor", "green");
shouldBe("getComputedStyle(minlengthInvalid, '').backgroundColor", "transparent");
document.body.offsetTop; // Force recalc.
minlengthInvalid.setAttribute("minlength", "2");
if (window.internals)
shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1");
shouldBe("getComputedStyle(minlengthInvalid, '').backgroundColor", "green");
</script> </script>
...@@ -1703,7 +1703,6 @@ void HTMLInputElement::parseMaxLengthAttribute(const AtomicString& value) ...@@ -1703,7 +1703,6 @@ void HTMLInputElement::parseMaxLengthAttribute(const AtomicString& value)
m_maxLength = maxLength; m_maxLength = maxLength;
if (oldMaxLength != maxLength) if (oldMaxLength != maxLength)
updateValueIfNeeded(); updateValueIfNeeded();
setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fromAttribute(maxlengthAttr));
setNeedsValidityCheck(); setNeedsValidityCheck();
} }
...@@ -1715,7 +1714,6 @@ void HTMLInputElement::parseMinLengthAttribute(const AtomicString& value) ...@@ -1715,7 +1714,6 @@ void HTMLInputElement::parseMinLengthAttribute(const AtomicString& value)
if (minLength < 0) if (minLength < 0)
minLength = 0; minLength = 0;
m_minLength = minLength; m_minLength = minLength;
setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fromAttribute(minlengthAttr));
setNeedsValidityCheck(); setNeedsValidityCheck();
} }
......
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