Diff
Modified: trunk/LayoutTests/ChangeLog (251779 => 251780)
--- trunk/LayoutTests/ChangeLog 2019-10-30 17:44:42 UTC (rev 251779)
+++ trunk/LayoutTests/ChangeLog 2019-10-30 17:51:58 UTC (rev 251780)
@@ -1,5 +1,15 @@
2019-10-30 Antti Koivisto <[email protected]>
+ ::before/::after elements not filling their grid cell when container has display: contents
+ https://bugs.webkit.org/show_bug.cgi?id=193567
+
+ Reviewed by Simon Fraser.
+
+ * fast/css/display-contents-before-after-grid-expected.html: Added.
+ * fast/css/display-contents-before-after-grid.html: Added.
+
+2019-10-30 Antti Koivisto <[email protected]>
+
Update css/css-display web platform tests
https://bugs.webkit.org/show_bug.cgi?id=203607
Added: trunk/LayoutTests/fast/css/display-contents-before-after-grid-expected.html (0 => 251780)
--- trunk/LayoutTests/fast/css/display-contents-before-after-grid-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/display-contents-before-after-grid-expected.html 2019-10-30 17:51:58 UTC (rev 251780)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>CSS Grid, display: contents & ::before/::after</title>
+ <style>
+ .grid {
+ display: grid;
+ grid-template-columns: repeat(5, 150px);
+ }
+
+ span {
+ width: 100px;
+ height: 100px;
+ background-color: green;
+ }
+ </style>
+</head>
+<body>
+ <div class="grid">
+ <span>before</span>
+ <span>after</span>
+ <span>span</span>
+ <span>before</span>
+ <span>after</span>
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/display-contents-before-after-grid.html (0 => 251780)
--- trunk/LayoutTests/fast/css/display-contents-before-after-grid.html (rev 0)
+++ trunk/LayoutTests/fast/css/display-contents-before-after-grid.html 2019-10-30 17:51:58 UTC (rev 251780)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>CSS Grid, display: contents & ::before/::after</title>
+ <style>
+ .grid {
+ display: grid;
+ grid-template-columns: repeat(5, 150px);
+ }
+
+ .replaced {
+ display: contents;
+ }
+
+ .replaced::before {
+ content: "before";
+ }
+
+ .replaced::after {
+ content: "after";
+ }
+
+ .replaced-container {
+ display: contents;
+ }
+
+ .replaced::before, .replaced::after, span {
+ width: 100px;
+ height: 100px;
+ background-color: green;
+ }
+ </style>
+</head>
+<body>
+ <div class="grid">
+ <div class="replaced"></div>
+ <span>span</span>
+ <div class="replaced-container">
+ <div class="replaced"></div>
+ </div>
+ </div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (251779 => 251780)
--- trunk/Source/WebCore/ChangeLog 2019-10-30 17:44:42 UTC (rev 251779)
+++ trunk/Source/WebCore/ChangeLog 2019-10-30 17:51:58 UTC (rev 251780)
@@ -1,3 +1,33 @@
+2019-10-30 Antti Koivisto <[email protected]>
+
+ ::before/::after elements not filling their grid cell when container has display: contents
+ https://bugs.webkit.org/show_bug.cgi?id=193567
+
+ Reviewed by Simon Fraser.
+
+ Test: fast/css/display-contents-before-after-grid.html
+
+ We were not providing parent box style when resolving :before/:after pseudo elements. Because of this we
+ failed to blockify the pseudo elements when their host element had 'display:contents' and the parent
+ box was a grid.
+
+ Original test case by Michał Gołębiowski-Owczarek.
+
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::pseudoStyleForElement):
+
+ Pass the parent box style.
+
+ * css/StyleResolver.h:
+ * style/StyleTreeResolver.cpp:
+ (WebCore::Style::TreeResolver::resolvePseudoStyle):
+ (WebCore::Style::TreeResolver::parentBoxStyle const):
+ (WebCore::Style::TreeResolver::parentBoxStyleForPseudo const):
+
+ If the element has 'display:contents', look for style of its ancestors.
+
+ * style/StyleTreeResolver.h:
+
2019-10-30 Dirk Schulze <[email protected]>
[css-masking] Unprefix -webkit-clip-path
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (251779 => 251780)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2019-10-30 17:44:42 UTC (rev 251779)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2019-10-30 17:51:58 UTC (rev 251780)
@@ -499,7 +499,7 @@
}
}
-std::unique_ptr<RenderStyle> StyleResolver::pseudoStyleForElement(const Element& element, const PseudoStyleRequest& pseudoStyleRequest, const RenderStyle& parentStyle, const SelectorFilter* selectorFilter)
+std::unique_ptr<RenderStyle> StyleResolver::pseudoStyleForElement(const Element& element, const PseudoStyleRequest& pseudoStyleRequest, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const SelectorFilter* selectorFilter)
{
m_state = State(element, &parentStyle, m_overrideDocumentElementStyle, selectorFilter);
@@ -537,7 +537,7 @@
applyMatchedProperties(collector.matchResult(), element);
// Clean up our style object's display and text decorations (among other fixups).
- adjustRenderStyle(*state.style(), *m_state.parentStyle(), nullptr, nullptr);
+ adjustRenderStyle(*state.style(), *m_state.parentStyle(), parentBoxStyle, nullptr);
if (state.style()->hasViewportUnits())
document().setHasStyleWithViewportUnits();
Modified: trunk/Source/WebCore/css/StyleResolver.h (251779 => 251780)
--- trunk/Source/WebCore/css/StyleResolver.h 2019-10-30 17:44:42 UTC (rev 251779)
+++ trunk/Source/WebCore/css/StyleResolver.h 2019-10-30 17:51:58 UTC (rev 251780)
@@ -116,7 +116,7 @@
void keyframeStylesForAnimation(const Element&, const RenderStyle*, KeyframeList&);
- std::unique_ptr<RenderStyle> pseudoStyleForElement(const Element&, const PseudoStyleRequest&, const RenderStyle& parentStyle, const SelectorFilter* = nullptr);
+ std::unique_ptr<RenderStyle> pseudoStyleForElement(const Element&, const PseudoStyleRequest&, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle = nullptr, const SelectorFilter* = nullptr);
std::unique_ptr<RenderStyle> styleForPage(int pageIndex);
std::unique_ptr<RenderStyle> defaultStyleForElement();
Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (251779 => 251780)
--- trunk/Source/WebCore/style/StyleTreeResolver.cpp 2019-10-30 17:44:42 UTC (rev 251779)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp 2019-10-30 17:51:58 UTC (rev 251780)
@@ -254,7 +254,7 @@
if (!elementUpdate.style->hasPseudoStyle(pseudoId))
return { };
- auto pseudoStyle = scope().styleResolver.pseudoStyleForElement(element, { pseudoId }, *elementUpdate.style, &scope().selectorFilter);
+ auto pseudoStyle = scope().styleResolver.pseudoStyleForElement(element, { pseudoId }, *elementUpdate.style, parentBoxStyleForPseudo(elementUpdate), &scope().selectorFilter);
if (!pseudoElementRendererIsNeeded(pseudoStyle.get()))
return { };
@@ -274,8 +274,8 @@
const RenderStyle* TreeResolver::parentBoxStyle() const
{
// 'display: contents' doesn't generate boxes.
- for (unsigned i = m_parentStack.size(); i; --i) {
- auto& parent = m_parentStack[i - 1];
+ for (auto i = m_parentStack.size(); i--;) {
+ auto& parent = m_parentStack[i];
if (parent.style.display() == DisplayType::None)
return nullptr;
if (parent.style.display() != DisplayType::Contents)
@@ -285,6 +285,18 @@
return nullptr;
}
+const RenderStyle* TreeResolver::parentBoxStyleForPseudo(const ElementUpdate& elementUpdate) const
+{
+ switch (elementUpdate.style->display()) {
+ case DisplayType::None:
+ return nullptr;
+ case DisplayType::Contents:
+ return parentBoxStyle();
+ default:
+ return elementUpdate.style.get();
+ }
+}
+
ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, Element& element, Change parentChange)
{
auto* oldStyle = element.renderOrDisplayContentsStyle();
Modified: trunk/Source/WebCore/style/StyleTreeResolver.h (251779 => 251780)
--- trunk/Source/WebCore/style/StyleTreeResolver.h 2019-10-30 17:44:42 UTC (rev 251779)
+++ trunk/Source/WebCore/style/StyleTreeResolver.h 2019-10-30 17:51:58 UTC (rev 251780)
@@ -96,6 +96,7 @@
void popParentsToDepth(unsigned depth);
const RenderStyle* parentBoxStyle() const;
+ const RenderStyle* parentBoxStyleForPseudo(const ElementUpdate&) const;
Document& m_document;
std::unique_ptr<RenderStyle> m_documentElementStyle;