зеркало из https://github.com/mozilla/gecko-dev.git
Bug 998590 - Factor out heading accessibility level into HTMLHeadingElement. r=MarcoZ
Differential Revision: https://phabricator.services.mozilla.com/D49407 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2ec3bb2b4f
Коммит
5ffa02e5a8
|
@ -39,6 +39,7 @@
|
|||
#include "mozilla/TextEditor.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLBRElement.h"
|
||||
#include "mozilla/dom/HTMLHeadingElement.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "gfxSkipChars.h"
|
||||
#include <algorithm>
|
||||
|
@ -907,13 +908,9 @@ HyperTextAccessible::DefaultTextAttributes() {
|
|||
}
|
||||
|
||||
int32_t HyperTextAccessible::GetLevelInternal() {
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::h1)) return 1;
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::h2)) return 2;
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::h3)) return 3;
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::h4)) return 4;
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::h5)) return 5;
|
||||
if (mContent->IsHTMLElement(nsGkAtoms::h6)) return 6;
|
||||
|
||||
if (auto* heading = dom::HTMLHeadingElement::FromNode(mContent)) {
|
||||
return heading->AccessibilityLevel();
|
||||
}
|
||||
return AccessibleWrap::GetLevelInternal();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,27 @@ class HTMLHeadingElement final : public nsGenericHTMLElement {
|
|||
return GetHTMLAttr(nsGkAtoms::align, aAlign);
|
||||
}
|
||||
|
||||
int32_t AccessibilityLevel() const {
|
||||
nsAtom* name = NodeInfo()->NameAtom();
|
||||
if (name == nsGkAtoms::h1) {
|
||||
return 1;
|
||||
}
|
||||
if (name == nsGkAtoms::h2) {
|
||||
return 2;
|
||||
}
|
||||
if (name == nsGkAtoms::h3) {
|
||||
return 3;
|
||||
}
|
||||
if (name == nsGkAtoms::h4) {
|
||||
return 4;
|
||||
}
|
||||
if (name == nsGkAtoms::h5) {
|
||||
return 5;
|
||||
}
|
||||
MOZ_ASSERT(name == nsGkAtoms::h6);
|
||||
return 6;
|
||||
}
|
||||
|
||||
NS_IMPL_FROMNODE_HELPER(HTMLHeadingElement, IsHTMLHeadingElement())
|
||||
|
||||
protected:
|
||||
|
|
Загрузка…
Ссылка в новой задаче