зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1748749 - P2: Cache has long desc. r=Jamie
We only need to cache the existance of a longdesc in an image. This increments the action count. Differential Revision: https://phabricator.services.mozilla.com/D135906
This commit is contained in:
Родитель
75a312e6e0
Коммит
a9bc6f0257
|
@ -11,6 +11,7 @@
|
|||
#include "Role.h"
|
||||
#include "AccAttributes.h"
|
||||
#include "AccIterator.h"
|
||||
#include "CacheConstants.h"
|
||||
#include "States.h"
|
||||
|
||||
#include "imgIContainer.h"
|
||||
|
@ -18,6 +19,7 @@
|
|||
#include "nsGenericHTMLElement.h"
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/MutationEventBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
@ -105,6 +107,20 @@ ENameValueFlag ImageAccessible::NativeName(nsString& aName) const {
|
|||
|
||||
role ImageAccessible::NativeRole() const { return roles::GRAPHIC; }
|
||||
|
||||
void ImageAccessible::DOMAttributeChanged(int32_t aNameSpaceID,
|
||||
nsAtom* aAttribute, int32_t aModType,
|
||||
const nsAttrValue* aOldValue,
|
||||
uint64_t aOldState) {
|
||||
LinkableAccessible::DOMAttributeChanged(aNameSpaceID, aAttribute, aModType,
|
||||
aOldValue, aOldState);
|
||||
|
||||
if (aAttribute == nsGkAtoms::longdesc &&
|
||||
(aModType == dom::MutationEvent_Binding::ADDITION ||
|
||||
aModType == dom::MutationEvent_Binding::REMOVAL)) {
|
||||
SendCache(CacheDomain::Actions, CacheUpdateType::Update);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// LocalAccessible
|
||||
|
||||
|
|
|
@ -40,13 +40,6 @@ class ImageAccessible : public LinkableAccessible,
|
|||
LayoutDeviceIntPoint Position(uint32_t aCoordType);
|
||||
LayoutDeviceIntSize Size();
|
||||
|
||||
protected:
|
||||
virtual ~ImageAccessible();
|
||||
|
||||
// LocalAccessible
|
||||
virtual ENameValueFlag NativeName(nsString& aName) const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Return whether the element has a longdesc URI.
|
||||
*/
|
||||
|
@ -55,6 +48,18 @@ class ImageAccessible : public LinkableAccessible,
|
|||
return uri;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~ImageAccessible();
|
||||
|
||||
// LocalAccessible
|
||||
virtual ENameValueFlag NativeName(nsString& aName) const override;
|
||||
|
||||
virtual void DOMAttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue,
|
||||
uint64_t aOldState) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Return an URI for showlongdesc action if any.
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "TableCellAccessible.h"
|
||||
#include "TreeWalker.h"
|
||||
#include "HTMLElementAccessibles.h"
|
||||
#include "ImageAccessible.h"
|
||||
|
||||
#include "nsIDOMXULButtonElement.h"
|
||||
#include "nsIDOMXULSelectCntrlEl.h"
|
||||
|
@ -3282,8 +3283,12 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
|
|||
}
|
||||
|
||||
if (aCacheDomain & CacheDomain::Actions) {
|
||||
if (ActionCount()) {
|
||||
// We only cache the first action.
|
||||
uint8_t actionCount = ActionCount();
|
||||
ImageAccessible* imgAcc = AsImage();
|
||||
bool hasLongDesc = imgAcc && imgAcc->HasLongDesc();
|
||||
|
||||
if (actionCount && !(actionCount == 1 && hasLongDesc)) {
|
||||
// We only cache the first action that is not showlongdesc.
|
||||
nsAutoString actionName;
|
||||
ActionNameAt(0, actionName);
|
||||
RefPtr<nsAtom> actionAtom = NS_Atomize(actionName);
|
||||
|
@ -3291,6 +3296,14 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
|
|||
} else if (aUpdateType == CacheUpdateType::Update) {
|
||||
fields->SetAttribute(nsGkAtoms::action, DeleteEntry());
|
||||
}
|
||||
|
||||
if (imgAcc) {
|
||||
if (hasLongDesc) {
|
||||
fields->SetAttribute(nsGkAtoms::longdesc, true);
|
||||
} else if (aUpdateType == CacheUpdateType::Update) {
|
||||
fields->SetAttribute(nsGkAtoms::longdesc, DeleteEntry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aUpdateType == CacheUpdateType::Initial) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче