Modified: trunk/Source/WebCore/ChangeLog (277721 => 277722)
--- trunk/Source/WebCore/ChangeLog 2021-05-19 15:04:36 UTC (rev 277721)
+++ trunk/Source/WebCore/ChangeLog 2021-05-19 15:47:22 UTC (rev 277722)
@@ -1,3 +1,15 @@
+2021-05-19 Antti Koivisto <an...@apple.com>
+
+ Factor pseudo class invalidation code in Document::updateHoverActiveState into a lambda
+ https://bugs.webkit.org/show_bug.cgi?id=225966
+
+ Reviewed by Sam Weinig.
+
+ Cleanup.
+
+ * dom/Document.cpp:
+ (WebCore::Document::updateHoverActiveState):
+
2021-05-19 Chris Dumez <cdu...@apple.com>
Fix flaky assertion hit under AudioSummingJunction::removeOutput()
Modified: trunk/Source/WebCore/dom/Document.cpp (277721 => 277722)
--- trunk/Source/WebCore/dom/Document.cpp 2021-05-19 15:04:36 UTC (rev 277721)
+++ trunk/Source/WebCore/dom/Document.cpp 2021-05-19 15:47:22 UTC (rev 277722)
@@ -7288,26 +7288,26 @@
elementsToSetHover.append(element);
}
- if (!elementsToClearActive.isEmpty()) {
- Style::PseudoClassChangeInvalidation styleInvalidation(*elementsToClearActive.last(), CSSSelector::PseudoClassActive, Style::InvalidationScope::Descendants);
- for (auto& element : elementsToClearActive)
- element->setActive(false, false, Style::InvalidationScope::SelfChildrenAndSiblings);
- }
- if (!elementsToSetActive.isEmpty()) {
- Style::PseudoClassChangeInvalidation styleInvalidation(*elementsToSetActive.last(), CSSSelector::PseudoClassActive, Style::InvalidationScope::Descendants);
- for (auto& element : elementsToSetActive)
- element->setActive(true, false, Style::InvalidationScope::SelfChildrenAndSiblings);
- }
- if (!elementsToClearHover.isEmpty()) {
- Style::PseudoClassChangeInvalidation styleInvalidation(*elementsToClearHover.last(), CSSSelector::PseudoClassHover, Style::InvalidationScope::Descendants);
- for (auto& element : elementsToClearHover)
- element->setHovered(false, Style::InvalidationScope::SelfChildrenAndSiblings);
- }
- if (!elementsToSetHover.isEmpty()) {
- Style::PseudoClassChangeInvalidation styleInvalidation(*elementsToSetHover.last(), CSSSelector::PseudoClassHover, Style::InvalidationScope::Descendants);
- for (auto& element : elementsToSetHover)
- element->setHovered(true, Style::InvalidationScope::SelfChildrenAndSiblings);
- }
+ auto changeState = [](auto& elements, auto pseudoClassType, auto&& setter) {
+ if (elements.isEmpty())
+ return;
+ Style::PseudoClassChangeInvalidation styleInvalidation { *elements.last(), pseudoClassType, Style::InvalidationScope::Descendants };
+ for (auto& element : elements)
+ setter(*element);
+ };
+
+ changeState(elementsToClearActive, CSSSelector::PseudoClassActive, [](auto& element) {
+ element.setActive(false, false, Style::InvalidationScope::SelfChildrenAndSiblings);
+ });
+ changeState(elementsToSetActive, CSSSelector::PseudoClassActive, [](auto& element) {
+ element.setActive(true, false, Style::InvalidationScope::SelfChildrenAndSiblings);
+ });
+ changeState(elementsToClearHover, CSSSelector::PseudoClassHover, [](auto& element) {
+ element.setHovered(false, Style::InvalidationScope::SelfChildrenAndSiblings);
+ });
+ changeState(elementsToSetHover, CSSSelector::PseudoClassHover, [](auto& element) {
+ element.setHovered(true, Style::InvalidationScope::SelfChildrenAndSiblings);
+ });
}
bool Document::haveStylesheetsLoaded() const