- Revision
- 90691
- Author
- m...@apple.com
- Date
- 2011-07-10 08:37:30 -0700 (Sun, 10 Jul 2011)
Log Message
<rdar://problem/9750062> REGRESSION: Button text missing in many iTunes Store pages
https://bugs.webkit.org/show_bug.cgi?id=64236
Reviewed by Maciej Stachowiak.
Source/WebCore:
Test: fast/css/empty-display-none.html
When an :empty selector caused an element to not have a renderer, the check for empty style
change when finishing parsing the elemenet did nothing, because it could not check if the
element’s current style was affected by :empty. The fix is to record the fact that the style
was affected by :empty in ElementRareData in the no-renderer case.
* dom/Element.cpp:
(WebCore::Element::recalcStyle): Clear the m_styleAffectedByEmpty flag.
(WebCore::checkForEmptyStyleChange): If the style is null (meaning there is no renderer), check
Element::styleAffectedByEmpty().
(WebCore::Element::setStyleAffectedByEmpty): Added. Sets the flag in rare data.
(WebCore::Element::styleAffectedByEmpty): Added. Checks for the flag in rare data.
* dom/Element.h:
* dom/ElementRareData.h:
(WebCore::ElementRareData::ElementRareData): Added m_styleAffectedByEmpty and initialized it
to false.
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRendererFactory::createRendererAndStyle): If an element doesn’t need a renderer
and its style is affected by :empty, record this fact in the element by calling setStyleAffectedByEmpty().
LayoutTests:
* fast/css/empty-display-none-expected.txt: Added.
* fast/css/empty-display-none.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (90690 => 90691)
--- trunk/LayoutTests/ChangeLog 2011-07-10 12:21:00 UTC (rev 90690)
+++ trunk/LayoutTests/ChangeLog 2011-07-10 15:37:30 UTC (rev 90691)
@@ -1,3 +1,13 @@
+2011-07-10 Dan Bernstein <m...@apple.com>
+
+ <rdar://problem/9750062> REGRESSION: Button text missing in many iTunes Store pages
+ https://bugs.webkit.org/show_bug.cgi?id=64236
+
+ Reviewed by Maciej Stachowiak.
+
+ * fast/css/empty-display-none-expected.txt: Added.
+ * fast/css/empty-display-none.html: Added.
+
2011-07-08 Stephen White <senorbla...@chromium.org>
Unreviewed; new chromium GPU pixel results for overflow-scroll-expected.
Added: trunk/LayoutTests/fast/css/empty-display-none-expected.txt (0 => 90691)
--- trunk/LayoutTests/fast/css/empty-display-none-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/empty-display-none-expected.txt 2011-07-10 15:37:30 UTC (rev 90691)
@@ -0,0 +1,3 @@
+This tests that specifying display: none; for the :empty pseudoclass doesn’t affect non-empty elements.
+
+PASS
Added: trunk/LayoutTests/fast/css/empty-display-none.html (0 => 90691)
--- trunk/LayoutTests/fast/css/empty-display-none.html (rev 0)
+++ trunk/LayoutTests/fast/css/empty-display-none.html 2011-07-10 15:37:30 UTC (rev 90691)
@@ -0,0 +1,18 @@
+<style>
+ div { width: 100px; height: 100px; }
+ #target { margin-top: -100px; background-color: green; }
+ #target:empty { display: none; }
+</style>
+<p>
+ This tests that specifying <tt>display: none;</tt> for the <tt>:empty</tt>
+ pseudoclass doesn’t affect non-empty elements.
+</p>
+<div style="background-color: red;"></div>
+<div id="target"><span></span></div>
+<p id="result"></p>
+<script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ document.getElementById("result").innerText = document.getElementById("target").offsetWidth === 100 ? "PASS" : "FAIL";
+</script>
Modified: trunk/Source/WebCore/ChangeLog (90690 => 90691)
--- trunk/Source/WebCore/ChangeLog 2011-07-10 12:21:00 UTC (rev 90690)
+++ trunk/Source/WebCore/ChangeLog 2011-07-10 15:37:30 UTC (rev 90691)
@@ -1,3 +1,31 @@
+2011-07-10 Dan Bernstein <m...@apple.com>
+
+ <rdar://problem/9750062> REGRESSION: Button text missing in many iTunes Store pages
+ https://bugs.webkit.org/show_bug.cgi?id=64236
+
+ Reviewed by Maciej Stachowiak.
+
+ Test: fast/css/empty-display-none.html
+
+ When an :empty selector caused an element to not have a renderer, the check for empty style
+ change when finishing parsing the elemenet did nothing, because it could not check if the
+ element’s current style was affected by :empty. The fix is to record the fact that the style
+ was affected by :empty in ElementRareData in the no-renderer case.
+
+ * dom/Element.cpp:
+ (WebCore::Element::recalcStyle): Clear the m_styleAffectedByEmpty flag.
+ (WebCore::checkForEmptyStyleChange): If the style is null (meaning there is no renderer), check
+ Element::styleAffectedByEmpty().
+ (WebCore::Element::setStyleAffectedByEmpty): Added. Sets the flag in rare data.
+ (WebCore::Element::styleAffectedByEmpty): Added. Checks for the flag in rare data.
+ * dom/Element.h:
+ * dom/ElementRareData.h:
+ (WebCore::ElementRareData::ElementRareData): Added m_styleAffectedByEmpty and initialized it
+ to false.
+ * dom/NodeRenderingContext.cpp:
+ (WebCore::NodeRendererFactory::createRendererAndStyle): If an element doesn’t need a renderer
+ and its style is affected by :empty, record this fact in the element by calling setStyleAffectedByEmpty().
+
2011-07-10 Mark Rowe <mr...@apple.com>
Fix the build.
Modified: trunk/Source/WebCore/dom/Element.cpp (90690 => 90691)
--- trunk/Source/WebCore/dom/Element.cpp 2011-07-10 12:21:00 UTC (rev 90690)
+++ trunk/Source/WebCore/dom/Element.cpp 2011-07-10 15:37:30 UTC (rev 90691)
@@ -1102,8 +1102,11 @@
bool hasIndirectAdjacentRules = currentStyle && currentStyle->childrenAffectedByForwardPositionalRules();
if ((change > NoChange || needsStyleRecalc())) {
- if (hasRareData())
- rareData()->resetComputedStyle();
+ if (hasRareData()) {
+ ElementRareData* data = ""
+ data->resetComputedStyle();
+ data->m_styleAffectedByEmpty = false;
+ }
}
if (hasParentStyle && (change >= Inherit || needsStyleRecalc())) {
RefPtr<RenderStyle> newStyle = styleForRenderer(NodeRenderingContext(this, 0));
@@ -1301,10 +1304,10 @@
static void checkForEmptyStyleChange(Element* element, RenderStyle* style)
{
- if (!style)
+ if (!style && !element->styleAffectedByEmpty())
return;
- if (style->affectedByEmpty() && (!style->emptyState() || element->hasChildNodes()))
+ if (!style || (style->affectedByEmpty() && (!style->emptyState() || element->hasChildNodes())))
element->setNeedsStyleRecalc();
}
@@ -1750,6 +1753,17 @@
return pseudoElementSpecifier ? data->m_computedStyle->getCachedPseudoStyle(pseudoElementSpecifier) : data->m_computedStyle.get();
}
+void Element::setStyleAffectedByEmpty()
+{
+ ElementRareData* data = ""
+ data->m_styleAffectedByEmpty = true;
+}
+
+bool Element::styleAffectedByEmpty() const
+{
+ return hasRareData() && rareData()->m_styleAffectedByEmpty;
+}
+
AtomicString Element::computeInheritedLanguage() const
{
const Node* n = this;
Modified: trunk/Source/WebCore/dom/Element.h (90690 => 90691)
--- trunk/Source/WebCore/dom/Element.h 2011-07-10 12:21:00 UTC (rev 90690)
+++ trunk/Source/WebCore/dom/Element.h 2011-07-10 15:37:30 UTC (rev 90691)
@@ -240,6 +240,9 @@
RenderStyle* computedStyle(PseudoId = NOPSEUDO);
+ void setStyleAffectedByEmpty();
+ bool styleAffectedByEmpty() const;
+
AtomicString computeInheritedLanguage() const;
void dispatchAttrRemovalEvent(Attribute*);
Modified: trunk/Source/WebCore/dom/ElementRareData.h (90690 => 90691)
--- trunk/Source/WebCore/dom/ElementRareData.h 2011-07-10 12:21:00 UTC (rev 90690)
+++ trunk/Source/WebCore/dom/ElementRareData.h 2011-07-10 15:37:30 UTC (rev 90691)
@@ -50,6 +50,8 @@
OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap;
OwnPtr<ClassList> m_classList;
+ bool m_styleAffectedByEmpty;
+
#if ENABLE(FULLSCREEN_API)
bool m_containsFullScreenElement;
#endif
@@ -63,6 +65,7 @@
inline ElementRareData::ElementRareData()
: m_minimumSizeForResizing(defaultMinimumSizeForResizing())
, m_shadowRoot(0)
+ , m_styleAffectedByEmpty(false)
#if ENABLE(FULLSCREEN_API)
, m_containsFullScreenElement(false)
#endif
Modified: trunk/Source/WebCore/dom/NodeRenderingContext.cpp (90690 => 90691)
--- trunk/Source/WebCore/dom/NodeRenderingContext.cpp 2011-07-10 12:21:00 UTC (rev 90690)
+++ trunk/Source/WebCore/dom/NodeRenderingContext.cpp 2011-07-10 15:37:30 UTC (rev 90691)
@@ -271,8 +271,14 @@
return 0;
m_context.setStyle(node->styleForRenderer(m_context));
- if (!node->rendererIsNeeded(m_context))
+ if (!node->rendererIsNeeded(m_context)) {
+ if (node->isElementNode()) {
+ Element* element = toElement(node);
+ if (m_context.style()->affectedByEmpty())
+ element->setStyleAffectedByEmpty();
+ }
return 0;
+ }
RenderObject* newRenderer = node->createRenderer(document->renderArena(), m_context.style());
if (!newRenderer)