Backout bug 862693 (Stop the :-moz-focusring pseudo-class from matching if an element is themed and the theme will display a visual indication of focus for the element. r=roc)

This commit is contained in:
Jonathan Watt 2013-04-21 11:30:11 +01:00
parent 7c1ae1ff7c
commit c63ee27f69
4 changed files with 3 additions and 26 deletions

View File

@ -1018,23 +1018,6 @@ nsFocusManager::FocusPlugin(nsIContent* aContent)
return NS_OK;
}
/* static */ bool
nsFocusManager::ThemeDisplaysFocusForContent(nsIContent* aContent)
{
// We don't want to draw the focusring if the element is themed and
// the theme displays an indication of focus for the element.
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame) {
nsPresContext *presContext = frame->PresContext();
const nsStyleDisplay *disp = frame->StyleDisplay();
if (frame->IsThemed(disp) &&
presContext->GetTheme()->ThemeDrawsFocusForWidget(presContext, frame, disp->mAppearance)) {
return true;
}
}
return false;
}
/* static */
void
nsFocusManager::NotifyFocusStateChange(nsIContent* aContent,
@ -1045,9 +1028,7 @@ nsFocusManager::NotifyFocusStateChange(nsIContent* aContent,
return;
}
nsEventStates eventState = NS_EVENT_STATE_FOCUS;
if (!aGettingFocus ||
(aWindowShouldShowFocusRing &&
!ThemeDisplaysFocusForContent(aContent))) {
if (aWindowShouldShowFocusRing) {
eventState |= NS_EVENT_STATE_FOCUSRING;
}
if (aGettingFocus) {

View File

@ -116,8 +116,6 @@ public:
static bool sMouseFocusesFormControl;
static bool ThemeDisplaysFocusForContent(nsIContent* aContent);
protected:
nsFocusManager();

View File

@ -8417,8 +8417,7 @@ nsGlobalWindow::SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
oldShouldShowFocusRing != newShouldShowFocusRing &&
mFocusedNode->IsElement()) {
// Update mFocusedNode's state.
if (newShouldShowFocusRing &&
!nsFocusManager::ThemeDisplaysFocusForContent(mFocusedNode.get())) {
if (newShouldShowFocusRing) {
mFocusedNode->AsElement()->AddStates(NS_EVENT_STATE_FOCUSRING);
} else {
mFocusedNode->AsElement()->RemoveStates(NS_EVENT_STATE_FOCUSRING);

View File

@ -49,7 +49,6 @@ function runTest()
var isMac = (navigator.platform.indexOf("Mac") >= 0);
var isWin = (navigator.platform.indexOf("Win") >= 0);
var isLinux = (navigator.platform.indexOf("Linux") >= 0);
function checkFocus(element, visible, testid)
{
@ -101,7 +100,7 @@ function runTest()
checkFocus($("l2"), true, "appearance on list after mouse focus with :focus");
synthesizeMouse($("b1"), 4, 4, { });
checkFocus($("b1"), !isMac && !isLinux && expectedVisible, "appearance on button after mouse focus with :moz-focusring");
checkFocus($("b1"), !isMac && expectedVisible, "appearance on button after mouse focus with :moz-focusring");
if (navigator.platform.indexOf("Mac") >= 0) {
ok(compareSnapshots(snapShot($("b1")), snapShot($("b2")), false)[0], "focus after mouse shows no ring");
}