Title: [214290] trunk
- Revision
- 214290
- Author
- an...@apple.com
- Date
- 2017-03-22 18:16:07 -0700 (Wed, 22 Mar 2017)
Log Message
Dynamically applied :empty pseudo class with display:none does not get unapplied
https://bugs.webkit.org/show_bug.cgi?id=169907
Reviewed by Ryosuke Niwa.
Source/WebCore:
We improperly reset the styleAffectedByEmpty bit when removing the renderer when :empty starts
applying. We then fail to invalidate the style when the element becomes non-empty again.
Fix by resetting the style relation bits only when computing the style.
Test: fast/css/empty-display-none-invalidation.html
* dom/Element.cpp:
(WebCore::Element::resetStyleRelations):
Expose this separately.
(WebCore::Element::clearStyleDerivedDataBeforeDetachingRenderer):
Don't reset style relation bits when removing renderers.
* dom/Element.h:
* dom/ElementRareData.h:
(WebCore::ElementRareData::resetComputedStyle):
(WebCore::ElementRareData::resetStyleRelations):
Reset all these bits in one function.
(WebCore::ElementRareData::resetDynamicRestyleObservations): Deleted.
* style/StyleTreeResolver.cpp:
(WebCore::Style::resetStyleForNonRenderedDescendants):
(WebCore::Style::TreeResolver::resolveComposedTree):
Call the explicit style relation reset function when recomputing style.
LayoutTests:
* fast/css/empty-display-none-invalidation-expected.html: Added.
* fast/css/empty-display-none-invalidation.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (214289 => 214290)
--- trunk/LayoutTests/ChangeLog 2017-03-23 01:14:06 UTC (rev 214289)
+++ trunk/LayoutTests/ChangeLog 2017-03-23 01:16:07 UTC (rev 214290)
@@ -1,3 +1,13 @@
+2017-03-22 Antti Koivisto <an...@apple.com>
+
+ Dynamically applied :empty pseudo class with display:none does not get unapplied
+ https://bugs.webkit.org/show_bug.cgi?id=169907
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/css/empty-display-none-invalidation-expected.html: Added.
+ * fast/css/empty-display-none-invalidation.html: Added.
+
2017-03-22 Mark Lam <mark....@apple.com>
Add support for Error.stackTraceLimit.
Added: trunk/LayoutTests/fast/css/empty-display-none-invalidation-expected.html (0 => 214290)
--- trunk/LayoutTests/fast/css/empty-display-none-invalidation-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/empty-display-none-invalidation-expected.html 2017-03-23 01:16:07 UTC (rev 214290)
@@ -0,0 +1 @@
+PASS
Added: trunk/LayoutTests/fast/css/empty-display-none-invalidation.html (0 => 214290)
--- trunk/LayoutTests/fast/css/empty-display-none-invalidation.html (rev 0)
+++ trunk/LayoutTests/fast/css/empty-display-none-invalidation.html 2017-03-23 01:16:07 UTC (rev 214290)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+<style>
+div:empty { display: none; }
+</style>
+<div>hello world</div>
+<script>
+const div = document.querySelector('div');
+div.getBoundingClientRect();
+
+div.innerHTML = '';
+div.getBoundingClientRect();
+
+div.innerHTML = 'PASS';
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (214289 => 214290)
--- trunk/Source/WebCore/ChangeLog 2017-03-23 01:14:06 UTC (rev 214289)
+++ trunk/Source/WebCore/ChangeLog 2017-03-23 01:16:07 UTC (rev 214290)
@@ -1,3 +1,40 @@
+2017-03-22 Antti Koivisto <an...@apple.com>
+
+ Dynamically applied :empty pseudo class with display:none does not get unapplied
+ https://bugs.webkit.org/show_bug.cgi?id=169907
+
+ Reviewed by Ryosuke Niwa.
+
+ We improperly reset the styleAffectedByEmpty bit when removing the renderer when :empty starts
+ applying. We then fail to invalidate the style when the element becomes non-empty again.
+
+ Fix by resetting the style relation bits only when computing the style.
+
+ Test: fast/css/empty-display-none-invalidation.html
+
+ * dom/Element.cpp:
+ (WebCore::Element::resetStyleRelations):
+
+ Expose this separately.
+
+ (WebCore::Element::clearStyleDerivedDataBeforeDetachingRenderer):
+
+ Don't reset style relation bits when removing renderers.
+
+ * dom/Element.h:
+ * dom/ElementRareData.h:
+ (WebCore::ElementRareData::resetComputedStyle):
+ (WebCore::ElementRareData::resetStyleRelations):
+
+ Reset all these bits in one function.
+
+ (WebCore::ElementRareData::resetDynamicRestyleObservations): Deleted.
+ * style/StyleTreeResolver.cpp:
+ (WebCore::Style::resetStyleForNonRenderedDescendants):
+ (WebCore::Style::TreeResolver::resolveComposedTree):
+
+ Call the explicit style relation reset function when recomputing style.
+
2017-03-22 Michael Catanzaro <mcatanz...@igalia.com>
[GTK] Honor GTK+ font settings
Modified: trunk/Source/WebCore/dom/Element.cpp (214289 => 214290)
--- trunk/Source/WebCore/dom/Element.cpp 2017-03-23 01:14:06 UTC (rev 214289)
+++ trunk/Source/WebCore/dom/Element.cpp 2017-03-23 01:16:07 UTC (rev 214290)
@@ -3436,6 +3436,13 @@
reset(child);
}
+void Element::resetStyleRelations()
+{
+ if (!hasRareData())
+ return;
+ elementRareData()->resetStyleRelations();
+}
+
void Element::clearStyleDerivedDataBeforeDetachingRenderer()
{
unregisterNamedFlowContentElement();
@@ -3442,11 +3449,6 @@
cancelFocusAppearanceUpdate();
clearBeforePseudoElement();
clearAfterPseudoElement();
- if (!hasRareData())
- return;
- ElementRareData* data = ""
- data->resetComputedStyle();
- data->resetDynamicRestyleObservations();
}
void Element::clearHoverAndActiveStatusBeforeDetachingRenderer()
Modified: trunk/Source/WebCore/dom/Element.h (214289 => 214290)
--- trunk/Source/WebCore/dom/Element.h 2017-03-23 01:14:06 UTC (rev 214289)
+++ trunk/Source/WebCore/dom/Element.h 2017-03-23 01:16:07 UTC (rev 214290)
@@ -514,6 +514,7 @@
void clearBeforePseudoElement();
void clearAfterPseudoElement();
void resetComputedStyle();
+ void resetStyleRelations();
void clearStyleDerivedDataBeforeDetachingRenderer();
void clearHoverAndActiveStatusBeforeDetachingRenderer();
Modified: trunk/Source/WebCore/dom/ElementRareData.h (214289 => 214290)
--- trunk/Source/WebCore/dom/ElementRareData.h 2017-03-23 01:14:06 UTC (rev 214289)
+++ trunk/Source/WebCore/dom/ElementRareData.h 2017-03-23 01:16:07 UTC (rev 214290)
@@ -46,7 +46,7 @@
PseudoElement* afterPseudoElement() const { return m_afterPseudoElement.get(); }
void resetComputedStyle();
- void resetDynamicRestyleObservations();
+ void resetStyleRelations();
int tabIndex() const { return m_tabIndex; }
void setTabIndexExplicitly(int index) { m_tabIndex = index; m_tabIndexWasSetExplicitly = true; }
@@ -215,13 +215,13 @@
{
m_computedStyle = nullptr;
m_hasDisplayContents = false;
+}
+
+inline void ElementRareData::resetStyleRelations()
+{
setStyleAffectedByEmpty(false);
setStyleAffectedByFocusWithin(false);
setChildIndex(0);
-}
-
-inline void ElementRareData::resetDynamicRestyleObservations()
-{
setStyleAffectedByActive(false);
setChildrenAffectedByDrag(false);
setChildrenAffectedByLastChildRules(false);
Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (214289 => 214290)
--- trunk/Source/WebCore/style/StyleTreeResolver.cpp 2017-03-23 01:14:06 UTC (rev 214289)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp 2017-03-23 01:16:07 UTC (rev 214290)
@@ -140,6 +140,7 @@
if (child.needsStyleRecalc() || affectedByPreviousSibling) {
child.resetComputedStyle();
+ child.resetStyleRelations();
child.setHasValidStyle();
}
@@ -413,6 +414,7 @@
bool shouldResolve = shouldResolveElement(element, parent.change) || affectedByPreviousSibling;
if (shouldResolve) {
element.resetComputedStyle();
+ element.resetStyleRelations();
if (element.hasCustomStyleResolveCallbacks())
element.willRecalcStyle(parent.change);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes