Skip to content
Permalink
Browse files
[: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:

Canonical link: https://commits.webkit.org/249415@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
nt1m committed Apr 8, 2022
1 parent 4d6ba09 commit 847e069955b0806121579d073a5d319d06594cb4
@@ -1,3 +1,13 @@
2022-04-07 Tim Nguyen <ntim@apple.com>

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

Reviewed by Antti Koivisto.

* 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:

2022-04-07 Matteo Flores <matteo_flores@apple.com>

REGRESSION(r291509): imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-video.html is a constant text failure
@@ -1,6 +1,7 @@
Check me!

PASS :checked & :indeterminate invalidation
PASS :checked & :indeterminate invalidation on <input>
PASS :indeterminate invalidation on <progress>
PASS :disabled invalidation
PASS :read-only invalidation
PASS :valid invalidation
@@ -15,13 +15,15 @@
.ancestor:has(#textinput:valid) { color: lightgreen }
.ancestor:has(#numberinput:out-of-range) { color: darkgreen }
.ancestor:has(#numberinput:required) { color: pink }
.ancestor:has(#progress:indeterminate) { color: orange }
</style>
<div id=subject class=ancestor>
<input type="checkbox" name="my-checkbox" id="checkme">
<label for="checkme">Check me!</label>
<input type="text" id="textinput" required>
<input id="radioinput" checked>
<input id="numberinput" type="number" min="1" max="10" value="5">
<progress id="progress" value="50" max="100"></progress>
</div>
<script>
test(function() {
@@ -47,7 +49,18 @@
checkme.checked = true;
assert_equals(getComputedStyle(subject).color, "rgb(0, 128, 0)",
"ancestor should be green");
}, ":checked & :indeterminate invalidation");
}, ":checked & :indeterminate invalidation on <input>");

test(function() {
this.add_cleanup(() => {
progress.setAttribute("value", "50");
});
assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)",
"ancestor should be black");
progress.removeAttribute("value");
assert_equals(getComputedStyle(subject).color, "rgb(255, 165, 0)",
"ancestor should be orange");
}, ":indeterminate invalidation on <progress>");

test(function() {
this.add_cleanup(() => {
@@ -1,3 +1,21 @@
2022-04-07 Tim Nguyen <ntim@apple.com>

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

Reviewed by Antti Koivisto.

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:

2022-04-07 Nikolas Zimmermann <nzimmermann@igalia.com>

Unify reference box / CTM computation in RenderLayer
@@ -25,6 +25,7 @@
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "ProgressShadowElement.h"
#include "PseudoClassChangeInvalidation.h"
#include "RenderProgress.h"
#include "ShadowRoot.h"
#include <wtf/IsoMallocInlines.h>
@@ -41,6 +42,7 @@ const double HTMLProgressElement::InvalidPosition = -2;
HTMLProgressElement::HTMLProgressElement(const QualifiedName& tagName, Document& document)
: LabelableElement(tagName, document)
, m_value(0)
, m_isDeterminate(false)
{
ASSERT(hasTagName(progressTag));
setHasCustomStyleResolveCallbacks();
@@ -77,18 +79,19 @@ RenderProgress* HTMLProgressElement::renderProgress() const

void HTMLProgressElement::parseAttribute(const QualifiedName& name, const AtomString& value)
{
if (name == valueAttr)
if (name == valueAttr) {
updateDeterminateState();
didElementStateChange();
else if (name == maxAttr)
} else if (name == maxAttr)
didElementStateChange();
else
LabelableElement::parseAttribute(name, value);
}

void HTMLProgressElement::didAttachRenderers()
{
if (RenderProgress* render = renderProgress())
render->updateFromElement();
if (RenderProgress* renderer = renderProgress())
renderer->updateFromElement();
}

double HTMLProgressElement::value() const
@@ -121,20 +124,20 @@ double HTMLProgressElement::position() const
return value() / max();
}

bool HTMLProgressElement::isDeterminate() const
void HTMLProgressElement::updateDeterminateState()
{
return hasAttributeWithoutSynchronization(valueAttr);
bool newIsDeterminate = hasAttributeWithoutSynchronization(valueAttr);
if (m_isDeterminate == newIsDeterminate)
return;
Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassIndeterminate, !newIsDeterminate);
m_isDeterminate = newIsDeterminate;
}

void HTMLProgressElement::didElementStateChange()
{
m_value->setWidthPercentage(position() * 100);
if (RenderProgress* render = renderProgress()) {
bool wasDeterminate = render->isDeterminate();
render->updateFromElement();
if (wasDeterminate != isDeterminate())
invalidateStyleForSubtree();
}
if (RenderProgress* renderer = renderProgress())
renderer->updateFromElement();
}

void HTMLProgressElement::didAddUserAgentShadowRoot(ShadowRoot& root)
@@ -58,13 +58,15 @@ class HTMLProgressElement final : public LabelableElement {

void didAttachRenderers() final;

void updateDeterminateState();
void didElementStateChange();
void didAddUserAgentShadowRoot(ShadowRoot&) final;
bool isDeterminate() const;
bool isDeterminate() const { return m_isDeterminate; };

bool canContainRangeEndPoint() const final { return false; }

ProgressValueElement* m_value;
bool m_isDeterminate { false };
};

} // namespace

0 comments on commit 847e069

Please sign in to comment.