diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index 8f253f1e7da1..ff4dd65a64a9 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -3128,12 +3128,17 @@ nsTextPaintStyle::InitCommonColors() } static nsIContent* -FindElementAncestor(nsINode* aNode) +FindElementAncestorForMozSelection(nsIContent* aContent) { - while (aNode && !aNode->IsNodeOfType(nsINode::eELEMENT)) { - aNode = aNode->GetParent(); + NS_ENSURE_TRUE(aContent, nsnull); + while (aContent && aContent->IsInNativeAnonymousSubtree()) { + aContent = aContent->GetBindingParent(); } - return static_cast(aNode); + NS_ASSERTION(aContent, "aContent isn't in non-anonymous tree?"); + while (aContent && !aContent->IsNodeOfType(nsINode::eELEMENT)) { + aContent = aContent->GetParent(); + } + return aContent; } PRBool @@ -3155,7 +3160,8 @@ nsTextPaintStyle::InitSelectionColors() mInitSelectionColors = PR_TRUE; nsIFrame* nonGeneratedAncestor = nsLayoutUtils::GetNonGeneratedAncestor(mFrame); - nsIContent* selectionContent = FindElementAncestor(nonGeneratedAncestor->GetContent()); + nsIContent* selectionContent = + FindElementAncestorForMozSelection(nonGeneratedAncestor->GetContent()); if (selectionContent && selectionStatus == nsISelectionController::SELECTION_ON) { diff --git a/layout/reftests/selection/pseudo-element-of-native-anonymous-ref.html b/layout/reftests/selection/pseudo-element-of-native-anonymous-ref.html new file mode 100644 index 000000000000..dbcfef7cfcaa --- /dev/null +++ b/layout/reftests/selection/pseudo-element-of-native-anonymous-ref.html @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/layout/reftests/selection/pseudo-element-of-native-anonymous.html b/layout/reftests/selection/pseudo-element-of-native-anonymous.html new file mode 100644 index 000000000000..9193f1c27c20 --- /dev/null +++ b/layout/reftests/selection/pseudo-element-of-native-anonymous.html @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/layout/reftests/selection/reftest.list b/layout/reftests/selection/reftest.list index 4ee3a927ed17..63dca04f2644 100644 --- a/layout/reftests/selection/reftest.list +++ b/layout/reftests/selection/reftest.list @@ -24,3 +24,4 @@ == extend-3i.html extend-3-ref.html == extend-4a.html extend-4-ref.html == extend-4b.html extend-4-ref.html +!= pseudo-element-of-native-anonymous.html pseudo-element-of-native-anonymous-ref.html