Bug 183646 ::-moz-selection does not work in form controls (input[type=text], input[type=password], textarea) r=dbaron

This commit is contained in:
Masayuki Nakano 2010-04-07 11:10:54 +09:00
parent 9dc08b1cf0
commit ec0f459b5b
4 changed files with 42 additions and 5 deletions

View File

@ -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
@ -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) {

View File

@ -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>

View File

@ -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>

View File

@ -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