From 1df47134f9af94887346c364cab83e3525533c6b Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Wed, 18 Mar 2015 05:42:14 +0900 Subject: [PATCH] Bug 1141455 - Do not treat an element with tabindex as an interactive content in label. r=smaug --- dom/base/Element.cpp | 2 +- dom/base/Element.h | 2 +- dom/html/HTMLAnchorElement.h | 2 +- dom/html/HTMLAudioElement.cpp | 2 +- dom/html/HTMLAudioElement.h | 2 +- dom/html/HTMLButtonElement.h | 2 +- dom/html/HTMLIFrameElement.h | 2 +- dom/html/HTMLImageElement.cpp | 2 +- dom/html/HTMLImageElement.h | 2 +- dom/html/HTMLInputElement.cpp | 2 +- dom/html/HTMLInputElement.h | 2 +- dom/html/HTMLLabelElement.cpp | 2 +- dom/html/HTMLLabelElement.h | 2 +- dom/html/HTMLObjectElement.cpp | 2 +- dom/html/HTMLObjectElement.h | 2 +- dom/html/HTMLSelectElement.h | 2 +- dom/html/HTMLTextAreaElement.h | 2 +- dom/html/HTMLVideoElement.cpp | 2 +- dom/html/HTMLVideoElement.h | 2 +- dom/html/nsGenericHTMLElement.cpp | 4 ++-- dom/html/nsGenericHTMLElement.h | 2 +- dom/html/test/forms/test_interactive_content_in_label.html | 4 ++-- 22 files changed, 24 insertions(+), 24 deletions(-) diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index c82f984c641e..426e9baa591e 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1832,7 +1832,7 @@ Element::IsLabelable() const } bool -Element::IsInteractiveHTMLContent() const +Element::IsInteractiveHTMLContent(bool aIgnoreTabindex) const { return false; } diff --git a/dom/base/Element.h b/dom/base/Element.h index ca627fdaa85c..a531f827936c 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -276,7 +276,7 @@ public: /** * Returns if the element is interactive content as per HTML specification. */ - virtual bool IsInteractiveHTMLContent() const; + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const; /** * Is the attribute named stored in the mapped attributes? diff --git a/dom/html/HTMLAnchorElement.h b/dom/html/HTMLAnchorElement.h index fcb50177fb23..203835849eff 100644 --- a/dom/html/HTMLAnchorElement.h +++ b/dom/html/HTMLAnchorElement.h @@ -43,7 +43,7 @@ public: virtual bool Draggable() const MOZ_OVERRIDE; // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE { return true; } diff --git a/dom/html/HTMLAudioElement.cpp b/dom/html/HTMLAudioElement.cpp index 39d1d5df8f60..04d8313103c2 100644 --- a/dom/html/HTMLAudioElement.cpp +++ b/dom/html/HTMLAudioElement.cpp @@ -41,7 +41,7 @@ HTMLAudioElement::~HTMLAudioElement() } bool -HTMLAudioElement::IsInteractiveHTMLContent() const +HTMLAudioElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const { return HasAttr(kNameSpaceID_None, nsGkAtoms::controls); } diff --git a/dom/html/HTMLAudioElement.h b/dom/html/HTMLAudioElement.h index 3b6ef48d3515..f1f050c00d56 100644 --- a/dom/html/HTMLAudioElement.h +++ b/dom/html/HTMLAudioElement.h @@ -24,7 +24,7 @@ public: explicit HTMLAudioElement(already_AddRefed& aNodeInfo); // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE; + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE; // nsIDOMHTMLMediaElement using HTMLMediaElement::GetPaused; diff --git a/dom/html/HTMLButtonElement.h b/dom/html/HTMLButtonElement.h index 776eaf87d420..a2e8cf55a8e7 100644 --- a/dom/html/HTMLButtonElement.h +++ b/dom/html/HTMLButtonElement.h @@ -37,7 +37,7 @@ public: NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLButtonElement, button) // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE { return true; } diff --git a/dom/html/HTMLIFrameElement.h b/dom/html/HTMLIFrameElement.h index 2a6af020961d..550aec691a17 100644 --- a/dom/html/HTMLIFrameElement.h +++ b/dom/html/HTMLIFrameElement.h @@ -27,7 +27,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE { return true; } diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index 7a3133557010..80450b0290f9 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -149,7 +149,7 @@ NS_IMPL_STRING_ATTR(HTMLImageElement, UseMap, usemap) NS_IMPL_INT_ATTR(HTMLImageElement, Vspace, vspace) bool -HTMLImageElement::IsInteractiveHTMLContent() const +HTMLImageElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const { return HasAttr(kNameSpaceID_None, nsGkAtoms::usemap); } diff --git a/dom/html/HTMLImageElement.h b/dom/html/HTMLImageElement.h index 47cf8ae6b7dd..acc4463b5755 100644 --- a/dom/html/HTMLImageElement.h +++ b/dom/html/HTMLImageElement.h @@ -47,7 +47,7 @@ public: virtual bool Draggable() const MOZ_OVERRIDE; // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE; + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE; // nsIDOMHTMLImageElement NS_DECL_NSIDOMHTMLIMAGEELEMENT diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index f2a4d9084b2f..217663f89fc0 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -3222,7 +3222,7 @@ HTMLInputElement::Focus(ErrorResult& aError) } bool -HTMLInputElement::IsInteractiveHTMLContent() const +HTMLInputElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const { return mType != NS_FORM_INPUT_HIDDEN; } diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h index 6a3d06384d6b..0a625beb7293 100644 --- a/dom/html/HTMLInputElement.h +++ b/dom/html/HTMLInputElement.h @@ -120,7 +120,7 @@ public: virtual void Focus(ErrorResult& aError) MOZ_OVERRIDE; // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE; + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE; // nsIDOMHTMLInputElement NS_DECL_NSIDOMHTMLINPUTELEMENT diff --git a/dom/html/HTMLLabelElement.cpp b/dom/html/HTMLLabelElement.cpp index 110a04cf3dd1..5929714dac89 100644 --- a/dom/html/HTMLLabelElement.cpp +++ b/dom/html/HTMLLabelElement.cpp @@ -88,7 +88,7 @@ InInteractiveHTMLContent(nsIContent* aContent, nsIContent* aStop) nsIContent* content = aContent; while (content && content != aStop) { if (content->IsElement() && - content->AsElement()->IsInteractiveHTMLContent()) { + content->AsElement()->IsInteractiveHTMLContent(true)) { return true; } content = content->GetParent(); diff --git a/dom/html/HTMLLabelElement.h b/dom/html/HTMLLabelElement.h index 9f857b569052..5ac54e41a36c 100644 --- a/dom/html/HTMLLabelElement.h +++ b/dom/html/HTMLLabelElement.h @@ -33,7 +33,7 @@ public: NS_DECL_ISUPPORTS_INHERITED // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE { return true; } diff --git a/dom/html/HTMLObjectElement.cpp b/dom/html/HTMLObjectElement.cpp index 9e78159609a6..bb06e2e9f735 100644 --- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -50,7 +50,7 @@ HTMLObjectElement::~HTMLObjectElement() } bool -HTMLObjectElement::IsInteractiveHTMLContent() const +HTMLObjectElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const { return HasAttr(kNameSpaceID_None, nsGkAtoms::usemap); } diff --git a/dom/html/HTMLObjectElement.h b/dom/html/HTMLObjectElement.h index eae048efb7bd..489c135aabb2 100644 --- a/dom/html/HTMLObjectElement.h +++ b/dom/html/HTMLObjectElement.h @@ -37,7 +37,7 @@ public: #endif // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE; + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE; // nsIDOMHTMLObjectElement NS_DECL_NSIDOMHTMLOBJECTELEMENT diff --git a/dom/html/HTMLSelectElement.h b/dom/html/HTMLSelectElement.h index c73799f3c767..8fdab9a5e84c 100644 --- a/dom/html/HTMLSelectElement.h +++ b/dom/html/HTMLSelectElement.h @@ -148,7 +148,7 @@ public: virtual int32_t TabIndexDefault() MOZ_OVERRIDE; // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE { return true; } diff --git a/dom/html/HTMLTextAreaElement.h b/dom/html/HTMLTextAreaElement.h index d7ced597fbc4..055ede1d5ca9 100644 --- a/dom/html/HTMLTextAreaElement.h +++ b/dom/html/HTMLTextAreaElement.h @@ -54,7 +54,7 @@ public: virtual int32_t TabIndexDefault() MOZ_OVERRIDE; // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE { return true; } diff --git a/dom/html/HTMLVideoElement.cpp b/dom/html/HTMLVideoElement.cpp index 8df0bf6024e5..c3be706b83e9 100644 --- a/dom/html/HTMLVideoElement.cpp +++ b/dom/html/HTMLVideoElement.cpp @@ -127,7 +127,7 @@ nsresult HTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel) } bool -HTMLVideoElement::IsInteractiveHTMLContent() const +HTMLVideoElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const { return HasAttr(kNameSpaceID_None, nsGkAtoms::controls); } diff --git a/dom/html/HTMLVideoElement.h b/dom/html/HTMLVideoElement.h index 6359c20629a4..e23d5c69569d 100644 --- a/dom/html/HTMLVideoElement.h +++ b/dom/html/HTMLVideoElement.h @@ -50,7 +50,7 @@ public: virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel) MOZ_OVERRIDE; // Element - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE; + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE; // WebIDL diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 3728f1bb2cab..713aa39802c7 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -1794,11 +1794,11 @@ nsGenericHTMLElement::IsLabelable() const } bool -nsGenericHTMLElement::IsInteractiveHTMLContent() const +nsGenericHTMLElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const { return IsAnyOfHTMLElements(nsGkAtoms::details, nsGkAtoms::embed, nsGkAtoms::keygen) || - HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex); + (!aIgnoreTabindex && HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex)); } already_AddRefed diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index 4cbde8eb612a..de8acc9050b7 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -923,7 +923,7 @@ public: } virtual bool IsLabelable() const MOZ_OVERRIDE; - virtual bool IsInteractiveHTMLContent() const MOZ_OVERRIDE; + virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const MOZ_OVERRIDE; static bool TouchEventsEnabled(JSContext* /* unused */, JSObject* /* unused */); diff --git a/dom/html/test/forms/test_interactive_content_in_label.html b/dom/html/test/forms/test_interactive_content_in_label.html index 86a7860066a1..705864114c53 100644 --- a/dom/html/test/forms/test_interactive_content_in_label.html +++ b/dom/html/test/forms/test_interactive_content_in_label.html @@ -32,13 +32,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=229925 - tabindex object + tabindex