Bug 1442029 - Move XBL accessibility role="xul:colorpicker" and role="xul:colorpickertile" into XULMap.h
- Remove the colorpickertile binding as it's no longer useful.
- Remove nsAccessibilityService::CreateAccessibleByType() as it has nothing to do anymore.
- Remove nsCoreUtils::XBLBindingRole()
MozReview-Commit-ID: E21yljdsSLl
--- a/accessible/base/XULMap.h
+++ b/accessible/base/XULMap.h
@@ -38,37 +38,55 @@ XULMAP_TYPE(toolbarspring, XULToolbarSep
XULMAP_TYPE(treecol, XULColumnItemAccessible)
XULMAP_TYPE(treecolpicker, XULButtonAccessible)
XULMAP_TYPE(treecols, XULTreeColumAccessible)
XULMAP_TYPE(toolbar, XULToolbarAccessible)
XULMAP_TYPE(toolbarbutton, XULToolbarButtonAccessible)
XULMAP_TYPE(tooltip, XULTooltipAccessible)
XULMAP(
+ colorpicker,
+ [](nsIContent* aContent, Accessible* aContext) -> Accessible* {
+ if (aContent->IsElement() &&
+ aContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
+ nsGkAtoms::button, eIgnoreCase)) {
+ return new XULColorPickerAccessible(aContent, aContext->Document());
+ }
+ return nullptr;
+ }
+)
+
+XULMAP(
label,
[](nsIContent* aContent, Accessible* aContext) -> Accessible* {
if (aContent->IsElement() &&
aContent->AsElement()->ClassList()->Contains(NS_LITERAL_STRING("text-link"))) {
return new XULLinkAccessible(aContent, aContext->Document());
}
return new XULLabelAccessible(aContent, aContext->Document());
}
)
XULMAP(
image,
[](nsIContent* aContent, Accessible* aContext) -> Accessible* {
- if (aContent->IsElement() &&
- aContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::onclick)) {
+ if (!aContent->IsElement()) {
+ return nullptr;
+ }
+
+ if (aContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::onclick)) {
return new XULToolbarButtonAccessible(aContent, aContext->Document());
}
+ if (aContent->AsElement()->ClassList()->Contains(NS_LITERAL_STRING("colorpickertile"))) {
+ return new XULColorPickerTileAccessible(aContent, aContext->Document());
+ }
+
// Don't include nameless images in accessible tree.
- if (!aContent->IsElement() ||
- !aContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::tooltiptext)) {
+ if (!aContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::tooltiptext)) {
return nullptr;
}
return new ImageAccessibleWrap(aContent, aContext->Document());
}
)
XULMAP(
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -1240,22 +1240,16 @@ nsAccessibilityService::CreateAccessible
// Prefer to use XUL to decide if and what kind of accessible to create.
const XULMarkupMapInfo* xulMap =
mXULMarkupMap.Get(content->NodeInfo()->NameAtom());
if (xulMap && xulMap->new_func) {
newAcc = xulMap->new_func(content, aContext);
}
#endif
- // XBL bindings may use @role attribute to point the accessible type
- // they belong to.
- if (!newAcc) {
- newAcc = CreateAccessibleByType(content, document);
- }
-
// Any XUL box can be used as tabpanel, make sure we create a proper
// accessible for it.
if (!newAcc && aContext->IsXULTabpanels() &&
content->GetParent() == aContext->GetContent()) {
LayoutFrameType frameType = frame->Type();
if (frameType == LayoutFrameType::Box ||
frameType == LayoutFrameType::Scroll) {
newAcc = new XULTabpanelAccessible(content, document);
@@ -1462,40 +1456,16 @@ nsAccessibilityService::Shutdown()
if (observerService) {
static const char16_t kShutdownIndicator[] = { '0', 0 };
observerService->NotifyObservers(nullptr, "a11y-init-or-shutdown", kShutdownIndicator);
}
}
already_AddRefed<Accessible>
-nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent,
- DocAccessible* aDoc)
-{
- nsAutoString role;
- nsCoreUtils::XBLBindingRole(aContent, role);
- if (role.IsEmpty())
- return nullptr;
-
- RefPtr<Accessible> accessible;
-#ifdef MOZ_XUL
- // XUL controls
- if (role.EqualsLiteral("xul:colorpicker")) {
- accessible = new XULColorPickerAccessible(aContent, aDoc);
-
- } else if (role.EqualsLiteral("xul:colorpickertile")) {
- accessible = new XULColorPickerTileAccessible(aContent, aDoc);
-
- }
-#endif // MOZ_XUL
-
- return accessible.forget();
-}
-
-already_AddRefed<Accessible>
nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
nsIContent* aContent,
Accessible* aContext)
{
DocAccessible* document = aContext->Document();
RefPtr<Accessible> newAcc;
switch (aFrame->AccessibleType()) {
--- a/accessible/base/nsAccessibilityService.h
+++ b/accessible/base/nsAccessibilityService.h
@@ -287,22 +287,16 @@ private:
bool Init();
/**
* Shutdowns accessibility service.
*/
void Shutdown();
/**
- * Create accessible for the element having XBL bindings.
- */
- already_AddRefed<Accessible>
- CreateAccessibleByType(nsIContent* aContent, DocAccessible* aDoc);
-
- /**
* Create an accessible whose type depends on the given frame.
*/
already_AddRefed<Accessible>
CreateAccessibleByFrameType(nsIFrame* aFrame, nsIContent* aContent,
Accessible* aContext);
/**
* Notify observers about change of the accessibility service's consumers.
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -663,20 +663,8 @@ nsCoreUtils::AccEventObserversExist()
void
nsCoreUtils::DispatchAccEvent(RefPtr<nsIAccessibleEvent> event)
{
nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
NS_ENSURE_TRUE_VOID(obsService);
obsService->NotifyObservers(event, NS_ACCESSIBLE_EVENT_TOPIC, nullptr);
}
-
-void
-nsCoreUtils::XBLBindingRole(const nsIContent* aEl, nsAString& aRole)
-{
- for (const nsXBLBinding* binding = aEl->GetXBLBinding(); binding;
- binding = binding->GetBaseBinding()) {
- Element* bindingElm = binding->PrototypeBinding()->GetBindingElement();
- bindingElm->GetAttr(kNameSpaceID_None, nsGkAtoms::role, aRole);
- if (!aRole.IsEmpty())
- break;
- }
-}
--- a/accessible/base/nsCoreUtils.h
+++ b/accessible/base/nsCoreUtils.h
@@ -316,16 +316,11 @@ public:
* Return true if there are any observers of accessible events.
*/
static bool AccEventObserversExist();
/**
* Notify accessible event observers of an event.
*/
static void DispatchAccEvent(RefPtr<nsIAccessibleEvent> aEvent);
-
- /**
- * Return a role attribute on XBL bindings of the element.
- */
- static void XBLBindingRole(const nsIContent* aEl, nsAString& aRole);
};
#endif
--- a/accessible/xul/XULFormControlAccessible.cpp
+++ b/accessible/xul/XULFormControlAccessible.cpp
@@ -3,17 +3,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "XULFormControlAccessible.h"
#include "Accessible-inl.h"
#include "HTMLFormControlAccessible.h"
#include "nsAccUtils.h"
-#include "nsCoreUtils.h"
#include "DocAccessible.h"
#include "nsIAccessibleRelation.h"
#include "Relation.h"
#include "Role.h"
#include "States.h"
#include "TreeWalker.h"
#include "XULMenuAccessible.h"
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -1483,16 +1483,17 @@ GK_ATOM(clip_path, "clip-path")
GK_ATOM(clip_rule, "clip-rule")
GK_ATOM(clipPath, "clipPath")
GK_ATOM(clipPathUnits, "clipPathUnits")
GK_ATOM(cm, "cm")
GK_ATOM(colorBurn, "color-burn")
GK_ATOM(colorDodge, "color-dodge")
GK_ATOM(colorInterpolation, "color-interpolation")
GK_ATOM(colorInterpolationFilters, "color-interpolation-filters")
+GK_ATOM(colorpicker, "colorpicker")
GK_ATOM(colorProfile, "color-profile")
GK_ATOM(cursor, "cursor")
GK_ATOM(cx, "cx")
GK_ATOM(cy, "cy")
GK_ATOM(d, "d")
GK_ATOM(darken, "darken")
GK_ATOM(defs, "defs")
GK_ATOM(deg, "deg")
--- a/toolkit/content/widgets/colorpicker.xml
+++ b/toolkit/content/widgets/colorpicker.xml
@@ -418,17 +418,17 @@
this.removeAttribute("focused");
this.resetHover();
}
]]>
</handler>
</handlers>
</binding>
- <binding id="colorpicker-button" display="xul:menu" role="xul:colorpicker"
+ <binding id="colorpicker-button" display="xul:menu"
extends="chrome://global/content/bindings/general.xml#basecontrol">
<resources>
<stylesheet src="chrome://global/skin/colorpicker.css"/>
</resources>
<content>
<xul:image class="colorpicker-button-colorbox" anonid="colorbox" flex="1" xbl:inherits="disabled"/>
@@ -552,12 +552,9 @@
if ( (event.keyCode == 32 || (event.keyCode > 36 && event.keyCode < 41)) && !this.open)
this.showPopup();
else if ( (event.keyCode == 27) && this.open)
this.hidePopup();
]]></handler>
</handlers>
</binding>
- <binding id="colorpickertile" role="xul:colorpickertile">
- </binding>
-
</bindings>
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -816,20 +816,16 @@ panel[type="autocomplete-richlistbox"] {
colorpicker {
-moz-binding: url("chrome://global/content/bindings/colorpicker.xml#colorpicker");
}
colorpicker[type="button"] {
-moz-binding: url("chrome://global/content/bindings/colorpicker.xml#colorpicker-button");
}
-.colorpickertile {
- -moz-binding: url("chrome://global/content/bindings/colorpicker.xml#colorpickertile");
-}
-
/********** menulist **********/
menulist {
-moz-binding: url("chrome://global/content/bindings/menulist.xml#menulist");
}
menulist[popuponly="true"] {
-moz-binding: url("chrome://global/content/bindings/menulist.xml#menulist-popuponly");