Changeset 292582 in webkit


Ignore:
Timestamp:
Apr 7, 2022 5:47:15 PM (2 years ago)
Author:
ntim@apple.com
Message:

[:has() pseudo-class] Support invalidation for :indeterminate pseudo class on <progress>
https://bugs.webkit.org/show_bug.cgi?id=238923

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

  • web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt:
  • web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has.html:

Source/WebCore:

Test: imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has.html

  • html/HTMLProgressElement.cpp:

(WebCore::HTMLProgressElement::HTMLProgressElement):
(WebCore::HTMLProgressElement::parseAttribute):
(WebCore::HTMLProgressElement::didAttachRenderers):
(WebCore::HTMLProgressElement::updateDeterminateState):
(WebCore::HTMLProgressElement::didElementStateChange):
(WebCore::HTMLProgressElement::isDeterminate const): Deleted.

  • html/HTMLProgressElement.h:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r292570 r292582  
     12022-04-07  Tim Nguyen  <ntim@apple.com>
     2
     3        [:has() pseudo-class] Support invalidation for :indeterminate pseudo class on <progress>
     4        https://bugs.webkit.org/show_bug.cgi?id=238923
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt:
     9        * web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has.html:
     10
    1112022-04-07  Matteo Flores  <matteo_flores@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt

    r292523 r292582  
    11 Check me!
    22
    3 PASS :checked & :indeterminate invalidation
     3PASS :checked & :indeterminate invalidation on <input>
     4PASS :indeterminate invalidation on <progress>
    45PASS :disabled invalidation
    56PASS :read-only invalidation
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has.html

    r292466 r292582  
    1616  .ancestor:has(#numberinput:out-of-range) { color: darkgreen }
    1717  .ancestor:has(#numberinput:required) { color: pink }
     18  .ancestor:has(#progress:indeterminate) { color: orange }
    1819</style>
    1920<div id=subject class=ancestor>
     
    2324  <input id="radioinput" checked>
    2425  <input id="numberinput" type="number" min="1" max="10" value="5">
     26  <progress id="progress" value="50" max="100"></progress>
    2527</div>
    2628<script>
     
    4850    assert_equals(getComputedStyle(subject).color, "rgb(0, 128, 0)",
    4951                  "ancestor should be green");
    50   }, ":checked & :indeterminate invalidation");
     52  }, ":checked & :indeterminate invalidation on <input>");
     53
     54  test(function() {
     55    this.add_cleanup(() => {
     56      progress.setAttribute("value", "50");
     57    });
     58    assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)",
     59                  "ancestor should be black");
     60    progress.removeAttribute("value");
     61    assert_equals(getComputedStyle(subject).color, "rgb(255, 165, 0)",
     62                  "ancestor should be orange");
     63  }, ":indeterminate invalidation on <progress>");
    5164
    5265  test(function() {
  • trunk/Source/WebCore/ChangeLog

    r292575 r292582  
     12022-04-07  Tim Nguyen  <ntim@apple.com>
     2
     3        [:has() pseudo-class] Support invalidation for :indeterminate pseudo class on <progress>
     4        https://bugs.webkit.org/show_bug.cgi?id=238923
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Test: imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has.html
     9
     10        * html/HTMLProgressElement.cpp:
     11        (WebCore::HTMLProgressElement::HTMLProgressElement):
     12        (WebCore::HTMLProgressElement::parseAttribute):
     13        (WebCore::HTMLProgressElement::didAttachRenderers):
     14        (WebCore::HTMLProgressElement::updateDeterminateState):
     15        (WebCore::HTMLProgressElement::didElementStateChange):
     16        (WebCore::HTMLProgressElement::isDeterminate const): Deleted.
     17        * html/HTMLProgressElement.h:
     18
    1192022-04-07  Nikolas Zimmermann  <nzimmermann@igalia.com>
    220
  • trunk/Source/WebCore/html/HTMLProgressElement.cpp

    r283269 r292582  
    2626#include "HTMLParserIdioms.h"
    2727#include "ProgressShadowElement.h"
     28#include "PseudoClassChangeInvalidation.h"
    2829#include "RenderProgress.h"
    2930#include "ShadowRoot.h"
     
    4243    : LabelableElement(tagName, document)
    4344    , m_value(0)
     45    , m_isDeterminate(false)
    4446{
    4547    ASSERT(hasTagName(progressTag));
     
    7880void HTMLProgressElement::parseAttribute(const QualifiedName& name, const AtomString& value)
    7981{
    80     if (name == valueAttr)
     82    if (name == valueAttr) {
     83        updateDeterminateState();
    8184        didElementStateChange();
    82     else if (name == maxAttr)
     85    } else if (name == maxAttr)
    8386        didElementStateChange();
    8487    else
     
    8891void HTMLProgressElement::didAttachRenderers()
    8992{
    90     if (RenderProgress* render = renderProgress())
    91         render->updateFromElement();
     93    if (RenderProgress* renderer = renderProgress())
     94        renderer->updateFromElement();
    9295}
    9396
     
    122125}
    123126
    124 bool HTMLProgressElement::isDeterminate() const
     127void HTMLProgressElement::updateDeterminateState()
    125128{
    126     return hasAttributeWithoutSynchronization(valueAttr);
     129    bool newIsDeterminate = hasAttributeWithoutSynchronization(valueAttr);
     130    if (m_isDeterminate == newIsDeterminate)
     131        return;
     132    Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassIndeterminate, !newIsDeterminate);
     133    m_isDeterminate = newIsDeterminate;
    127134}
    128    
     135
    129136void HTMLProgressElement::didElementStateChange()
    130137{
    131138    m_value->setWidthPercentage(position() * 100);
    132     if (RenderProgress* render = renderProgress()) {
    133         bool wasDeterminate = render->isDeterminate();
    134         render->updateFromElement();
    135         if (wasDeterminate != isDeterminate())
    136             invalidateStyleForSubtree();
    137     }
     139    if (RenderProgress* renderer = renderProgress())
     140        renderer->updateFromElement();
    138141}
    139142
  • trunk/Source/WebCore/html/HTMLProgressElement.h

    r246490 r292582  
    5959    void didAttachRenderers() final;
    6060
     61    void updateDeterminateState();
    6162    void didElementStateChange();
    6263    void didAddUserAgentShadowRoot(ShadowRoot&) final;
    63     bool isDeterminate() const;
     64    bool isDeterminate() const { return m_isDeterminate; };
    6465
    6566    bool canContainRangeEndPoint() const final { return false; }
    6667
    6768    ProgressValueElement* m_value;
     69    bool m_isDeterminate { false };
    6870};
    6971
Note: See TracChangeset for help on using the changeset viewer.