Index: Source/core/rendering/RenderObject.cpp |
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp |
index 9c8086c3227d76a293079398053446b5ce96de1c..08f00df16ccb866b46eacbeb5920a9d35c156bd8 100644 |
--- a/Source/core/rendering/RenderObject.cpp |
+++ b/Source/core/rendering/RenderObject.cpp |
@@ -32,6 +32,7 @@ |
#include "core/accessibility/AXObjectCache.h" |
#include "core/animation/ActiveAnimations.h" |
#include "core/css/resolver/StyleResolver.h" |
+#include "core/dom/ElementTraversal.h" |
#include "core/editing/EditingBoundary.h" |
#include "core/editing/FrameSelection.h" |
#include "core/editing/htmlediting.h" |
@@ -2966,13 +2967,12 @@ PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(const PseudoStyleRe |
parentStyle = style(); |
} |
- // FIXME: This "find nearest element parent" should be a helper function. |
- Node* n = node(); |
- while (n && !n->isElementNode()) |
- n = n->parentNode(); |
- if (!n) |
+ if (!node()) |
+ return nullptr; |
+ |
+ Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); |
+ if (!element) |
return nullptr; |
- Element* element = toElement(n); |
if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) { |
RefPtr<RenderStyle> result = document().ensureStyleResolver().styleForElement(element, parentStyle, DisallowStyleSharing); |