Skip to content

Commit

Permalink
Bug 183646 ::-moz-selection does not work in form controls (input[typ…
Browse files Browse the repository at this point in the history
…e=text], input[type=password], textarea) r=dbaron
  • Loading branch information
masayuki-nakano committed Apr 7, 2010
1 parent 9dc08b1 commit ec0f459
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
16 changes: 11 additions & 5 deletions layout/generic/nsTextFrameThebes.cpp
Expand Up @@ -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<nsIContent*>(aNode);
NS_ASSERTION(aContent, "aContent isn't in non-anonymous tree?");
while (aContent && !aContent->IsNodeOfType(nsINode::eELEMENT)) {
aContent = aContent->GetParent();
}
return aContent;
}

PRBool
Expand All @@ -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) {
Expand Down
@@ -0,0 +1,13 @@
<html>
<head>
<style type="text/css">
input {
color: white;
background-color: green;
}
</style>
</head>
<body onload="document.getElementById('i').select();">
<input value="text" id="i">
</body>
</html>
17 changes: 17 additions & 0 deletions layout/reftests/selection/pseudo-element-of-native-anonymous.html
@@ -0,0 +1,17 @@
<html>
<head>
<style type="text/css">
input {
color: white;
background-color: green;
}
input::-moz-selection {
color: red;
background-color: blue;
}
</style>
</head>
<body onload="document.getElementById('i').select();">
<input value="text" id="i">
</body>
</html>
1 change: 1 addition & 0 deletions layout/reftests/selection/reftest.list
Expand Up @@ -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

0 comments on commit ec0f459

Please sign in to comment.