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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 2774383002: Move getCached/getUncachedPseudoStyle to Element. (Closed)
Patch Set: Move getCached/getUncachedPseudoStyle to Element. 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/PseudoElement.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 354e11b3a7aa04a8e1fa8faea0f727396b1674c7..d1662218e0fd9be3d58c6865f9ad819e200b666e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -3084,30 +3084,23 @@ ComputedStyle* LayoutObject::cachedFirstLineStyle() const {
ComputedStyle* LayoutObject::getCachedPseudoStyle(
PseudoId pseudo,
const ComputedStyle* parentStyle) const {
- if (pseudo < FirstInternalPseudoId && !style()->hasPseudoStyle(pseudo))
+ DCHECK_NE(pseudo, PseudoIdBefore);
+ DCHECK_NE(pseudo, PseudoIdAfter);
+ if (!node())
return nullptr;
- ComputedStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo);
- if (cachedStyle)
- return cachedStyle;
+ Element* element = Traversal<Element>::firstAncestorOrSelf(*node());
+ if (!element)
+ return nullptr;
- RefPtr<ComputedStyle> result =
- getUncachedPseudoStyle(PseudoStyleRequest(pseudo), parentStyle);
- if (result)
- return mutableStyleRef().addCachedPseudoStyle(result.release());
- return nullptr;
+ return element->pseudoStyle(PseudoStyleRequest(pseudo), parentStyle);
}
PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle(
- const PseudoStyleRequest& pseudoStyleRequest,
+ const PseudoStyleRequest& request,
const ComputedStyle* parentStyle) const {
- if (pseudoStyleRequest.pseudoId < FirstInternalPseudoId &&
- !style()->hasPseudoStyle(pseudoStyleRequest.pseudoId))
- return nullptr;
-
- if (!parentStyle)
- parentStyle = style();
-
+ DCHECK_NE(request.pseudoId, PseudoIdBefore);
+ DCHECK_NE(request.pseudoId, PseudoIdAfter);
if (!node())
return nullptr;
@@ -3115,16 +3108,7 @@ PassRefPtr<ComputedStyle> LayoutObject::getUncachedPseudoStyle(
if (!element)
return nullptr;
- if (pseudoStyleRequest.pseudoId == PseudoIdFirstLineInherited) {
- RefPtr<ComputedStyle> result =
- document().ensureStyleResolver().styleForElement(
- element, parentStyle, parentStyle, DisallowStyleSharing);
- result->setStyleType(PseudoIdFirstLineInherited);
- return result.release();
- }
-
- return document().ensureStyleResolver().pseudoStyleForElement(
- element, pseudoStyleRequest, parentStyle, parentStyle);
+ return element->getUncachedPseudoStyle(request, parentStyle);
}
PassRefPtr<ComputedStyle> LayoutObject::getUncachedSelectionStyle() const {
« no previous file with comments | « third_party/WebKit/Source/core/dom/PseudoElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698