diff --git a/.eslintignore b/.eslintignore index 55af1ec43437..301ba35194e3 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,7 +5,6 @@ obj*/** # Temporarily ignore HTML files that still need to be fixed. -browser/extensions/loop/**/*.html devtools/**/*.html # We ignore all these directories by default, until we get them enabled. @@ -89,40 +88,8 @@ browser/extensions/shumway/** browser/fuel/** browser/locales/** -# Loop specific exclusions - -# This file currently uses a non-standard (and not on a standards track) -# if statement within catch. -browser/extensions/loop/content/modules/MozLoopWorker.js -# This file currently uses es7 features eslint issue: -# https://github.com/eslint/espree/issues/125 -browser/extensions/loop/content/modules/MozLoopAPI.jsm -# Need to fix the configuration for this. -browser/extensions/loop/bootstrap.js -# Need to drop the preprocessing (bug 1212428) -browser/extensions/loop/content/preferences/prefs.js -# Libs we don't need to check -browser/extensions/loop/content/panels/vendor -browser/extensions/loop/content/shared/vendor -browser/extensions/loop/standalone/content/vendor -# Libs we don't need to check -browser/extensions/loop/test/shared/vendor -# Coverage files -browser/extensions/loop/test/coverage -# These are generated react files that we don't need to check -browser/extensions/loop/content/panels/js/conversation.js -browser/extensions/loop/content/panels/js/conversationViews.js -browser/extensions/loop/content/panels/js/panel.js -browser/extensions/loop/content/panels/js/roomViews.js -browser/extensions/loop/content/panels/js/feedbackViews.js -browser/extensions/loop/content/shared/js/textChatView.js -browser/extensions/loop/content/shared/js/linkifiedTextView.js -browser/extensions/loop/content/shared/js/views.js -browser/extensions/loop/standalone/content/js/standaloneRoomViews.js -browser/extensions/loop/standalone/content/js/webapp.js -browser/extensions/loop/ui/ui-showcase.js -# Don't need to check the built tree -browser/extensions/loop/standalone/dist +# Ignore all of loop since it is imported from github and checked at source. +browser/extensions/loop/** # devtools/ exclusions # Ignore d3 diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index 7bd4c1eca45a..30e5014edea8 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -34,6 +34,7 @@ #include "nsITreeBoxObject.h" #include "nsITreeColumns.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/HTMLLabelElement.h" using namespace mozilla; @@ -41,6 +42,16 @@ using namespace mozilla; // nsCoreUtils //////////////////////////////////////////////////////////////////////////////// +bool +nsCoreUtils::IsLabelWithControl(nsIContent* aContent) +{ + dom::HTMLLabelElement* label = dom::HTMLLabelElement::FromContent(aContent); + if (label && label->GetControl()) + return true; + + return false; +} + bool nsCoreUtils::HasClickListener(nsIContent *aContent) { diff --git a/accessible/base/nsCoreUtils.h b/accessible/base/nsCoreUtils.h index 2e1593bed60d..5e5710f416b0 100644 --- a/accessible/base/nsCoreUtils.h +++ b/accessible/base/nsCoreUtils.h @@ -28,6 +28,11 @@ class nsIWidget; class nsCoreUtils { public: + /** + * Return true if the given node is a label of a control. + */ + static bool IsLabelWithControl(nsIContent *aContent); + /** * Return true if the given node has registered click, mousedown or mouseup * event listeners. diff --git a/accessible/generic/BaseAccessibles.cpp b/accessible/generic/BaseAccessibles.cpp index 6e79fa8156e0..04c31d39bb5c 100644 --- a/accessible/generic/BaseAccessibles.cpp +++ b/accessible/generic/BaseAccessibles.cpp @@ -115,13 +115,14 @@ LinkableAccessible::Value(nsString& aValue) uint8_t LinkableAccessible::ActionCount() { - bool isLink, isOnclick; - ActionWalk(&isLink, &isOnclick); - return (isLink || isOnclick) ? 1 : 0; + bool isLink, isOnclick, isLabelWithControl; + ActionWalk(&isLink, &isOnclick, &isLabelWithControl); + return (isLink || isOnclick || isLabelWithControl) ? 1 : 0; } Accessible* -LinkableAccessible::ActionWalk(bool* aIsLink, bool* aIsOnclick) +LinkableAccessible::ActionWalk(bool* aIsLink, bool* aIsOnclick, + bool* aIsLabelWithControl) { if (aIsOnclick) { *aIsOnclick = false; @@ -129,6 +130,9 @@ LinkableAccessible::ActionWalk(bool* aIsLink, bool* aIsOnclick) if (aIsLink) { *aIsLink = false; } + if (aIsLabelWithControl) { + *aIsLabelWithControl = false; + } if (nsCoreUtils::HasClickListener(mContent)) { if (aIsOnclick) { @@ -155,6 +159,13 @@ LinkableAccessible::ActionWalk(bool* aIsLink, bool* aIsOnclick) } return walkUpAcc; } + + if (nsCoreUtils::IsLabelWithControl(walkUpAcc->GetContent())) { + if (aIsLabelWithControl) { + *aIsLabelWithControl = true; + } + return walkUpAcc; + } } return nullptr; } @@ -166,11 +177,11 @@ LinkableAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName) // Action 0 (default action): Jump to link if (aIndex == eAction_Jump) { - bool isOnclick, isLink; - ActionWalk(&isLink, &isOnclick); + bool isOnclick, isLink, isLabelWithControl; + ActionWalk(&isLink, &isOnclick, &isLabelWithControl); if (isLink) { aName.AssignLiteral("jump"); - } else if (isOnclick) { + } else if (isOnclick || isLabelWithControl) { aName.AssignLiteral("click"); } } diff --git a/accessible/generic/BaseAccessibles.h b/accessible/generic/BaseAccessibles.h index 5e3c20e34604..71e932949b47 100644 --- a/accessible/generic/BaseAccessibles.h +++ b/accessible/generic/BaseAccessibles.h @@ -76,7 +76,8 @@ public: // ActionAccessible helpers Accessible* ActionWalk(bool* aIsLink = nullptr, - bool* aIsOnclick = nullptr); + bool* aIsOnclick = nullptr, + bool* aIsLabelWithControl = nullptr); // HyperLinkAccessible virtual already_AddRefed AnchorURIAt(uint32_t aAnchorIndex) override; diff --git a/accessible/html/HTMLElementAccessibles.cpp b/accessible/html/HTMLElementAccessibles.cpp index 02f31017d145..fa2cc4d35063 100644 --- a/accessible/html/HTMLElementAccessibles.cpp +++ b/accessible/html/HTMLElementAccessibles.cpp @@ -75,6 +75,32 @@ HTMLLabelAccessible::RelationByType(RelationType aType) return rel; } +uint8_t +HTMLLabelAccessible::ActionCount() +{ + return nsCoreUtils::IsLabelWithControl(mContent) ? 1 : 0; +} + +void +HTMLLabelAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName) +{ + if (aIndex == 0) { + if (nsCoreUtils::IsLabelWithControl(mContent)) + aName.AssignLiteral("click"); + } +} + +bool +HTMLLabelAccessible::DoAction(uint8_t aIndex) +{ + if (aIndex != 0) + return false; + + DoCommand(); + return true; +} + + //////////////////////////////////////////////////////////////////////////////// // nsHTMLOuputAccessible //////////////////////////////////////////////////////////////////////////////// diff --git a/accessible/html/HTMLElementAccessibles.h b/accessible/html/HTMLElementAccessibles.h index 8dfffd6f72d1..a1a4a8a9c479 100644 --- a/accessible/html/HTMLElementAccessibles.h +++ b/accessible/html/HTMLElementAccessibles.h @@ -62,6 +62,11 @@ public: // Accessible virtual Relation RelationByType(RelationType aType) override; + // ActionAccessible + virtual uint8_t ActionCount() override; + virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; + virtual bool DoAction(uint8_t aIndex) override; + protected: virtual ~HTMLLabelAccessible() {} virtual ENameValueFlag NativeName(nsString& aName) override; diff --git a/accessible/tests/mochitest/actions/test_general.html b/accessible/tests/mochitest/actions/test_general.html index 1d312df30255..5b9a18dab54c 100644 --- a/accessible/tests/mochitest/actions/test_general.html +++ b/accessible/tests/mochitest/actions/test_general.html @@ -39,11 +39,19 @@ ID: "onclick_img", actionName: "click", events: CLICK_EVENTS + }, + { + ID: "label1", + actionName: "click", + events: CLICK_EVENTS } + ]; testActions(actionsArray); + is(getAccessible("label1").firstChild.actionCount, 1, "label text should have 1 action"); + getAccessible("onclick_img").takeFocus(); is(getAccessible("link1").actionCount, 1, "links should have one action"); is(getAccessible("link2").actionCount, 1, "link with onclick handler should have 1 action"); @@ -87,5 +95,13 @@ linkable textleaf accessible
linkable textleaf accessible
+ +
+ + +
+ diff --git a/accessible/tests/mochitest/actions/test_general.xul b/accessible/tests/mochitest/actions/test_general.xul index fac49f1bbb76..bb27767a38c5 100644 --- a/accessible/tests/mochitest/actions/test_general.xul +++ b/accessible/tests/mochitest/actions/test_general.xul @@ -60,6 +60,11 @@ actionName: "press", events: CLICK_EVENTS }, + { + ID: "name_entry_label", + actionName: "click", + events: CLICK_EVENTS + }, { ID: "labelWithPopup", actionName: "click", @@ -72,6 +77,8 @@ }*/ ]; + is(getAccessible("name_entry_label").firstChild.actionCount, 1, "label text should have 1 action"); + testActions(actionsArray); } @@ -125,6 +132,10 @@