Changeset 287445 in webkit
- Timestamp:
- Dec 26, 2021 10:45:32 AM (7 months ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-pseudo-class-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-pseudo-class.html (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLFormControlElement.cpp (modified) (4 diffs)
-
Source/WebCore/html/HTMLOptGroupElement.cpp (modified) (3 diffs)
-
Source/WebCore/html/HTMLOptGroupElement.h (modified) (1 diff)
-
Source/WebCore/html/HTMLOptionElement.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r287434 r287445 1 2021-12-26 Antti Koivisto <antti@apple.com> 2 3 [:has() pseudo-class] Support :disabled and :enabled pseudo-class invalidation 4 https://bugs.webkit.org/show_bug.cgi?id=234636 5 6 Reviewed by Simon Fraser. 7 8 * web-platform-tests/css/selectors/invalidation/has-pseudo-class.html: 9 1 10 2021-12-24 Tim Nguyen <ntim@apple.com> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-pseudo-class-expected.txt
r287363 r287445 1 1 2 2 3 PASS Initial color 4 PASS Set checked on checkbox 5 PASS Unset checked on checkbox 6 PASS Set selected on option 7 PASS Unset selected on option 3 PASS Before set checked on checkbox, testing subject 4 PASS Set checked on checkbox, testing subject 5 PASS Unset checked on checkbox, testing subject 6 PASS Set select on option 7 PASS Reset select 8 PASS Before set disabled on checkbox, testing subject 9 PASS Set disabled on checkbox, testing subject 10 PASS Unset disabled on checkbox, testing subject 11 PASS Before set disabled on checkbox, testing subject3 12 PASS Set disabled on checkbox, testing subject3 13 PASS Unset disabled on checkbox, testing subject3 14 PASS Before set disabled on option, testing subject 15 PASS Set disabled on option, testing subject 16 PASS Unset disabled on option, testing subject 17 PASS Before set disabled on option, testing subject3 18 PASS Set disabled on option, testing subject3 19 PASS Unset disabled on option, testing subject3 20 PASS Before set disabled on optgroup, testing subject 21 PASS Set disabled on optgroup, testing subject 22 PASS Unset disabled on optgroup, testing subject 23 PASS Before set disabled on optgroup, testing subject2 24 PASS Set disabled on optgroup, testing subject2 25 PASS Unset disabled on optgroup, testing subject2 26 PASS Before set disabled on optgroup, testing subject3 27 PASS Set disabled on optgroup, testing subject3 28 PASS Unset disabled on optgroup, testing subject3 29 PASS Before set disabled on optgroup, testing subject4 30 PASS Set disabled on optgroup, testing subject4 31 PASS Unset disabled on optgroup, testing subject4 8 32 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-pseudo-class.html
r287363 r287445 7 7 <link rel="help" href="https://drafts.csswg.org/selectors/#relational"> 8 8 <style> 9 div, main{ color: grey }9 main:has(input) div { color: grey } 10 10 main:has(#checkbox:checked) > #subject { color: red } 11 main:has(#option:checked) > #subject { color: green } 11 main:has(#option:checked) > #subject { color: red } 12 main:has(#checkbox:disabled) > #subject { color: green } 13 main:has(#option:disabled) > :is(#subject, #subject2) { color: green } 14 main:has(#optgroup:disabled) > #subject { color: blue } 15 main:not(:has(#checkbox:enabled)) > #subject3 { color: green } 16 main:not(:has(#option:enabled)) :is(#subject3, #subject4) { color: green } 17 main:not(:has(#optgroup:enabled)) > #subject3 { color: blue } 12 18 </style> 13 19 14 20 <main id=main> 15 21 <input type=checkbox id=checkbox></input> 16 <select ><option>a</option><option id=option>b</option></select>22 <select id=select><optgroup id=optgroup><option>a</option><option id=option>b</option></optgroup></select> 17 23 <div id=subject></div> 24 <div id=subject2></div> 25 <div id=subject3></div> 26 <div id=subject4></div> 18 27 </main> 19 28 … … 27 36 const pink = 'rgb(255, 192, 203)'; 28 37 29 function testColor(test_name, color) {38 function testColor(test_name, subject_element, color) { 30 39 test(function() { 31 assert_equals(getComputedStyle(subject ).color, color);40 assert_equals(getComputedStyle(subject_element).color, color); 32 41 }, test_name); 33 42 } 34 43 35 function testPseudoClassChange(element, property, expectedColor)44 function testPseudoClassChange(element, property, subject_element, expectedColor) 36 45 { 46 testColor(`Before set ${property} on ${element.id}, testing ${subject_element.id}`, subject_element, grey); 47 37 48 element[property] = true; 38 testColor(`Set ${property} on ${element.id}`, expectedColor); 49 testColor(`Set ${property} on ${element.id}, testing ${subject_element.id}`, subject_element, expectedColor); 50 39 51 element[property] = false; 40 testColor(`Unset ${property} on ${element.id} `, grey);52 testColor(`Unset ${property} on ${element.id}, testing ${subject_element.id}`, subject_element, grey); 41 53 } 42 54 43 testColor('Initial color', grey); 55 function testSelectedChange(option, subject_element, expectedColor) 56 { 57 const oldOption = select.selectedOptions[0]; 58 option.selected = true; 59 testColor(`Set select on ${option.id}`, subject_element, expectedColor); 60 oldOption.selected = true; 61 testColor(`Reset select`, subject, grey); 62 } 44 63 45 testPseudoClassChange(checkbox, "checked", red); 46 testPseudoClassChange(option, "selected", green); 64 testPseudoClassChange(checkbox, "checked", subject, red); 65 testSelectedChange(option, subject, red); 66 67 testPseudoClassChange(checkbox, "disabled", subject, green); 68 testPseudoClassChange(checkbox, "disabled", subject3, green); 69 testPseudoClassChange(option, "disabled", subject, green); 70 testPseudoClassChange(option, "disabled", subject3, green); 71 72 testPseudoClassChange(optgroup, "disabled", subject, blue); 73 testPseudoClassChange(optgroup, "disabled", subject2, green); 74 testPseudoClassChange(optgroup, "disabled", subject3, blue); 75 testPseudoClassChange(optgroup, "disabled", subject4, green); 76 47 77 </script> -
trunk/Source/WebCore/ChangeLog
r287444 r287445 1 2021-12-26 Antti Koivisto <antti@apple.com> 2 3 [:has() pseudo-class] Support :disabled and :enabled pseudo-class invalidation 4 https://bugs.webkit.org/show_bug.cgi?id=234636 5 6 Reviewed by Simon Fraser. 7 8 Use Style::PseudoClassChangeInvalidation to support invalidation with :has(:disabled). 9 10 * html/HTMLFormControlElement.cpp: 11 (WebCore::HTMLFormControlElement::setAncestorDisabled): 12 (WebCore::HTMLFormControlElement::parseAttribute): 13 (WebCore::HTMLFormControlElement::disabledStateChanged): 14 * html/HTMLOptGroupElement.cpp: 15 (WebCore::HTMLOptGroupElement::isDisabledFormControl const): 16 17 Use a member bit instead of checking the attribute directly. This allows invalidation to be scoped over the state change. 18 19 (WebCore::HTMLOptGroupElement::parseAttribute): 20 21 Optgroup can flip the disabled status of the associated option elements too so handle that specifically. 22 23 * html/HTMLOptGroupElement.h: 24 * html/HTMLOptionElement.cpp: 25 (WebCore::HTMLOptionElement::parseAttribute): 26 1 27 2021-12-26 Alan Bujtas <zalan@apple.com> 2 28 -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r286855 r287445 41 41 #include "HTMLParserIdioms.h" 42 42 #include "HTMLTextAreaElement.h" 43 #include "PseudoClassChangeInvalidation.h" 43 44 #include "Quirks.h" 44 45 #include "RenderBox.h" … … 144 145 { 145 146 ASSERT(computeIsDisabledByFieldsetAncestor() == isDisabled); 146 bool oldValue = m_disabledByAncestorFieldset; 147 if (m_disabledByAncestorFieldset == isDisabled) 148 return; 149 150 Style::PseudoClassChangeInvalidation disabledInvalidation(*this, CSSSelector::PseudoClassDisabled); 151 Style::PseudoClassChangeInvalidation enabledInvalidation(*this, CSSSelector::PseudoClassEnabled); 152 147 153 m_disabledByAncestorFieldset = isDisabled; 148 if (oldValue != m_disabledByAncestorFieldset) 149 disabledStateChanged(); 154 disabledStateChanged(); 150 155 } 151 156 … … 156 161 else if (name == disabledAttr) { 157 162 if (canBeActuallyDisabled()) { 158 bool oldDisabled = m_disabled; 159 m_disabled = !value.isNull(); 160 if (oldDisabled != m_disabled) 163 bool newDisabled = !value.isNull(); 164 if (m_disabled != newDisabled) { 165 Style::PseudoClassChangeInvalidation disabledInvalidation(*this, CSSSelector::PseudoClassDisabled); 166 Style::PseudoClassChangeInvalidation enabledInvalidation(*this, CSSSelector::PseudoClassEnabled); 167 m_disabled = newDisabled; 161 168 disabledAttributeChanged(); 169 } 162 170 } 163 171 } else if (name == readonlyAttr) { … … 183 191 { 184 192 updateWillValidateAndValidity(); 185 invalidateStyleForSubtree();186 193 if (renderer() && renderer()->style().hasEffectiveAppearance()) 187 194 renderer()->theme().stateChanged(*renderer(), ControlStates::States::Enabled); -
trunk/Source/WebCore/html/HTMLOptGroupElement.cpp
r282799 r287445 28 28 #include "Document.h" 29 29 #include "ElementAncestorIterator.h" 30 #include "ElementIterator.h" 30 31 #include "HTMLNames.h" 32 #include "HTMLOptionElement.h" 31 33 #include "HTMLSelectElement.h" 34 #include "PseudoClassChangeInvalidation.h" 32 35 #include "RenderMenuList.h" 33 36 #include "NodeRenderStyle.h" … … 55 58 bool HTMLOptGroupElement::isDisabledFormControl() const 56 59 { 57 return hasAttributeWithoutSynchronization(disabledAttr);60 return m_isDisabled; 58 61 } 59 62 … … 84 87 recalcSelectOptions(); 85 88 86 if (name == disabledAttr) 87 invalidateStyleForSubtree(); 89 if (name == disabledAttr) { 90 bool newDisabled = !value.isNull(); 91 if (m_isDisabled != newDisabled) { 92 Style::PseudoClassChangeInvalidation disabledInvalidation(*this, CSSSelector::PseudoClassDisabled); 93 Style::PseudoClassChangeInvalidation enabledInvalidation(*this, CSSSelector::PseudoClassEnabled); 94 95 Vector<Style::PseudoClassChangeInvalidation> optionInvalidation; 96 for (auto& descendant : descendantsOfType<HTMLOptionElement>(*this)) { 97 optionInvalidation.append({ descendant, CSSSelector::PseudoClassDisabled }); 98 optionInvalidation.append({ descendant, CSSSelector::PseudoClassEnabled }); 99 } 100 101 m_isDisabled = newDisabled; 102 } 103 } 88 104 } 89 105 -
trunk/Source/WebCore/html/HTMLOptGroupElement.h
r259687 r287445 53 53 54 54 void recalcSelectOptions(); 55 56 bool m_isDisabled { false }; 55 57 }; 56 58 -
trunk/Source/WebCore/html/HTMLOptionElement.cpp
r287363 r287445 177 177 #endif 178 178 if (name == disabledAttr) { 179 bool oldDisabled = m_disabled; 180 m_disabled = !value.isNull(); 181 if (oldDisabled != m_disabled) { 182 invalidateStyleForSubtree(); 179 bool newDisabled = !value.isNull(); 180 if (m_disabled != newDisabled) { 181 Style::PseudoClassChangeInvalidation disabledInvalidation(*this, CSSSelector::PseudoClassDisabled); 182 Style::PseudoClassChangeInvalidation enabledInvalidation(*this, CSSSelector::PseudoClassEnabled); 183 m_disabled = newDisabled; 183 184 if (renderer() && renderer()->style().hasEffectiveAppearance()) 184 185 renderer()->theme().stateChanged(*renderer(), ControlStates::States::Enabled);
Note: See TracChangeset
for help on using the changeset viewer.