Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp

Issue 2727853002: [css-display] Support display: contents pseudo-elements.
Patch Set: Add missing nullcheck (whoops). Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
index 1dd8cab62c6067a37c7fa34ec11f7027ecefb707..d9c8781cba7678ba0b5ca465a82a8455926be81a 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
@@ -818,15 +818,27 @@ PseudoElement* StyleResolver::createPseudoElement(Element* parent,
PseudoElement* StyleResolver::createPseudoElementIfNeeded(Element& parent,
PseudoId pseudoId) {
+ if (!parent.canHaveGeneratedPseudo(pseudoId))
+ return nullptr;
+
LayoutObject* parentLayoutObject = parent.layoutObject();
+ if (!parentLayoutObject) {
+ DCHECK(parent.hasDisplayContentsStyle());
+ parentLayoutObject = LayoutTreeBuilderTraversal::parentLayoutObject(parent);
+ }
+
if (!parentLayoutObject)
return nullptr;
+ ComputedStyle* parentStyle = parent.mutableComputedStyle();
+ DCHECK(parentStyle);
+
// The first letter pseudo element has to look up the tree and see if any
// of the ancestors are first letter.
if (pseudoId < FirstInternalPseudoId && pseudoId != PseudoIdFirstLetter &&
- !parentLayoutObject->style()->hasPseudoStyle(pseudoId))
+ !parentStyle->hasPseudoStyle(pseudoId)) {
return nullptr;
+ }
if (pseudoId == PseudoIdBackdrop && !parent.isInTopLayer())
return nullptr;
@@ -839,7 +851,6 @@ PseudoElement* StyleResolver::createPseudoElementIfNeeded(Element& parent,
if (!canHaveGeneratedChildren(*parentLayoutObject))
return nullptr;
- ComputedStyle* parentStyle = parentLayoutObject->mutableStyle();
if (ComputedStyle* cachedStyle =
parentStyle->getCachedPseudoStyle(pseudoId)) {
if (!pseudoElementLayoutObjectIsNeeded(cachedStyle))
@@ -847,7 +858,8 @@ PseudoElement* StyleResolver::createPseudoElementIfNeeded(Element& parent,
return createPseudoElement(&parent, pseudoId);
}
- StyleResolverState state(document(), &parent, parentStyle, parentStyle);
+ StyleResolverState state(document(), &parent, parentStyle,
+ parentLayoutObject->style());
if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state))
return nullptr;
RefPtr<ComputedStyle> style = state.takeStyle();

Powered by Google App Engine
This is Rietveld 408576698