Bug 735251 - don't show focusrings on HTML video / audio elements on non-Windows, r?bz
MozReview-Commit-ID: J7vFGY6ylZ8
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -9627,16 +9627,28 @@ nsGlobalWindow::SetChromeEventHandler(Ev
static bool IsLink(nsIContent* aContent)
{
return aContent && (aContent->IsHTMLElement(nsGkAtoms::a) ||
aContent->AttrValueIs(kNameSpaceID_XLink, nsGkAtoms::type,
nsGkAtoms::simple, eCaseMatters));
}
+static bool ShouldShowFocusRingIfFocusedByMouse(nsIContent* aNode)
+{
+ if (aNode) {
+ if (IsLink(aNode) ||
+ aNode->IsHTMLElement(nsGkAtoms::video) ||
+ aNode->IsHTMLElement(nsGkAtoms::audio)) {
+ return false;
+ }
+ }
+ return true;
+}
+
void
nsGlobalWindow::SetFocusedNode(nsIContent* aNode,
uint32_t aFocusMethod,
bool aNeedsFocus)
{
FORWARD_TO_INNER_VOID(SetFocusedNode, (aNode, aFocusMethod, aNeedsFocus));
if (aNode && aNode->GetComposedDoc() != mDoc) {
@@ -9660,19 +9672,20 @@ nsGlobalWindow::SetFocusedNode(nsIConten
// if a node was focused by a keypress, turn on focus rings for the
// window.
if (mFocusMethod & nsIFocusManager::FLAG_BYKEY) {
mFocusByKeyOccurred = true;
} else if (
// otherwise, we set mShowFocusRingForContent, as we don't want this to
// be permanent for the window. On Windows, focus rings are only shown
// when the FLAG_SHOWRING flag is used. On other platforms, focus rings
- // are only hidden for clicks on links.
+ // are only visible on some elements.
#ifndef XP_WIN
- !(mFocusMethod & nsIFocusManager::FLAG_BYMOUSE) || !IsLink(aNode) ||
+ !(mFocusMethod & nsIFocusManager::FLAG_BYMOUSE) ||
+ ShouldShowFocusRingIfFocusedByMouse(aNode) ||
#endif
aFocusMethod & nsIFocusManager::FLAG_SHOWRING) {
mShowFocusRingForContent = true;
}
}
if (aNeedsFocus)
mNeedsFocus = aNeedsFocus;