Bug 1821951 part 1: Remove HyperTextAccessible methods that are no longer needed now that the cache is always used. r=morgan,taskgraph-reviewers,bhearsum

Differential Revision: https://phabricator.services.mozilla.com/D177744
This commit is contained in:
James Teh 2023-05-21 10:15:05 +00:00
Родитель b6e4c572a0
Коммит 1786366bc4
5 изменённых файлов: 27 добавлений и 1388 удалений

Просмотреть файл

@ -8,6 +8,7 @@
#include "AccAttributes.h"
#include "nsIAccessibleText.h"
#include "nsIAccessibleTypes.h"
namespace mozilla::a11y {
class Accessible;
@ -75,7 +76,7 @@ class HyperTextAccessibleBase {
/**
* Return character count within the hypertext accessible.
*/
virtual uint32_t CharacterCount() const;
uint32_t CharacterCount() const;
/**
* Get/set caret offset, if no caret then -1.
@ -97,8 +98,8 @@ class HyperTextAccessibleBase {
/**
* Return text between given offsets.
*/
virtual void TextSubstring(int32_t aStartOffset, int32_t aEndOffset,
nsAString& aText) const;
void TextSubstring(int32_t aStartOffset, int32_t aEndOffset,
nsAString& aText) const;
/**
* Get a character at the given offset (don't support magic offsets).
@ -106,7 +107,7 @@ class HyperTextAccessibleBase {
bool CharAt(int32_t aOffset, nsAString& aChar,
int32_t* aStartOffset = nullptr, int32_t* aEndOffset = nullptr);
virtual char16_t CharAt(int32_t aOffset) {
char16_t CharAt(int32_t aOffset) {
nsAutoString charAtOffset;
CharAt(aOffset, charAtOffset);
return charAtOffset.CharAt(0);
@ -116,15 +117,16 @@ class HyperTextAccessibleBase {
* Return a rect (in dev pixels) for character at given offset relative
* given coordinate system.
*/
virtual LayoutDeviceIntRect CharBounds(int32_t aOffset, uint32_t aCoordType);
LayoutDeviceIntRect CharBounds(int32_t aOffset, uint32_t aCoordType);
/**
* Return a rect (in dev pixels) of the given text range relative given
* coordinate system.
*/
virtual LayoutDeviceIntRect TextBounds(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aCoordType);
LayoutDeviceIntRect TextBounds(
int32_t aStartOffset, int32_t aEndOffset,
uint32_t aCoordType =
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE);
/**
* Return the offset of the char that contains the given coordinates.
@ -143,18 +145,15 @@ class HyperTextAccessibleBase {
* Return text before/at/after the given offset corresponding to
* the boundary type.
*/
virtual void TextBeforeOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText);
virtual void TextAtOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText);
virtual void TextAfterOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText);
void TextBeforeOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText);
void TextAtOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText);
void TextAfterOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText);
/**
* Return true if the given offset/range is valid.
@ -188,10 +187,10 @@ class HyperTextAccessibleBase {
/**
* Return text attributes for the given text range.
*/
virtual already_AddRefed<AccAttributes> TextAttributes(bool aIncludeDefAttrs,
int32_t aOffset,
int32_t* aStartOffset,
int32_t* aEndOffset);
already_AddRefed<AccAttributes> TextAttributes(bool aIncludeDefAttrs,
int32_t aOffset,
int32_t* aStartOffset,
int32_t* aEndOffset);
/**
* Return text attributes applied to the accessible.
@ -242,8 +241,9 @@ class HyperTextAccessibleBase {
/**
* Scroll the given text range into view.
*/
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void ScrollSubstringTo(
int32_t aStartOffset, int32_t aEndOffset, uint32_t aScrollType);
MOZ_CAN_RUN_SCRIPT_BOUNDARY void ScrollSubstringTo(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aScrollType);
protected:
virtual const Accessible* Acc() const = 0;

Просмотреть файл

@ -89,17 +89,6 @@ inline void HyperTextAccessible::PasteText(int32_t aPosition) {
}
}
inline uint32_t HyperTextAccessible::AdjustCaretOffset(uint32_t aOffset) const {
// It is the same character offset when the caret is visually at the very
// end of a line or the start of a new line (soft line break). Getting text
// at the line should provide the line with the visual caret, otherwise
// screen readers will announce the wrong line as the user presses up or
// down arrow and land at the end of a line.
if (aOffset > 0 && IsCaretAtEndOfLine()) return aOffset - 1;
return aOffset;
}
inline bool HyperTextAccessible::IsCaretAtEndOfLine() const {
RefPtr<nsFrameSelection> frameSelection = FrameSelection();
return frameSelection && frameSelection->GetHint() == CARET_ASSOCIATE_BEFORE;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -12,8 +12,6 @@
#include "nsIAccessibleTypes.h"
#include "nsIFrame.h" // only for nsSelectionAmount
#include "nsISelectionController.h"
#include "nsDirection.h"
#include "WordMovementType.h"
class nsFrameSelection;
class nsIFrame;
@ -125,37 +123,6 @@ class HyperTextAccessible : public AccessibleWrap,
//////////////////////////////////////////////////////////////////////////////
// TextAccessible
using HyperTextAccessibleBase::CharAt;
/**
* Return true if char at the given offset equals to given char.
*/
bool IsCharAt(int32_t aOffset, char16_t aChar) {
return CharAt(aOffset) == aChar;
}
/**
* Return true if terminal char is at the given offset.
*/
bool IsLineEndCharAt(int32_t aOffset) { return IsCharAt(aOffset, '\n'); }
virtual void TextBeforeOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText) override;
virtual void TextAtOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText) override;
virtual void TextAfterOffset(int32_t aOffset,
AccessibleTextBoundary aBoundaryType,
int32_t* aStartOffset, int32_t* aEndOffset,
nsAString& aText) override;
virtual already_AddRefed<AccAttributes> TextAttributes(
bool aIncludeDefAttrs, int32_t aOffset, int32_t* aStartOffset,
int32_t* aEndOffset) override;
virtual already_AddRefed<AccAttributes> DefaultTextAttributes() override;
// HyperTextAccessibleBase provides an overload which takes an Accessible.
@ -170,13 +137,6 @@ class HyperTextAccessible : public AccessibleWrap,
*/
int32_t OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType) override;
LayoutDeviceIntRect TextBounds(
int32_t aStartOffset, int32_t aEndOffset,
uint32_t aCoordType =
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE) override;
LayoutDeviceIntRect CharBounds(int32_t aOffset, uint32_t aCoordType) override;
/**
* Get/set caret offset, if no caret then -1.
*/
@ -269,75 +229,6 @@ class HyperTextAccessible : public AccessibleWrap,
// HyperTextAccessible
/**
* Adjust an offset the caret stays at to get a text by line boundary.
*/
uint32_t AdjustCaretOffset(uint32_t aOffset) const;
/**
* Return true if the given offset points to terminal empty line if any.
*/
bool IsEmptyLastLineOffset(int32_t aOffset) {
return aOffset == static_cast<int32_t>(CharacterCount()) &&
IsLineEndCharAt(aOffset - 1);
}
/**
* Return an offset of the found word boundary.
*/
uint32_t FindWordBoundary(uint32_t aOffset, nsDirection aDirection,
EWordMovementType aWordMovementType);
/**
* Used to get begin/end of previous/this/next line. Note: end of line
* is an offset right before '\n' character if any, the offset is right after
* '\n' character is begin of line. In case of wrap word breaks these offsets
* are equal.
*/
enum EWhichLineBoundary {
ePrevLineBegin,
ePrevLineEnd,
eThisLineBegin,
eThisLineEnd,
eNextLineBegin,
eNextLineEnd
};
/**
* Return an offset for requested line boundary. See constants above.
*/
uint32_t FindLineBoundary(uint32_t aOffset,
EWhichLineBoundary aWhichLineBoundary);
/**
* Find the start offset for a paragraph , taking into account
* inner block elements and line breaks.
*/
int32_t FindParagraphStartOffset(uint32_t aOffset);
/**
* Find the end offset for a paragraph , taking into account
* inner block elements and line breaks.
*/
int32_t FindParagraphEndOffset(uint32_t aOffset);
/**
* Return an offset corresponding to the given direction and selection amount
* relative the given offset. A helper used to find word or line boundaries.
*/
uint32_t FindOffset(uint32_t aOffset, nsDirection aDirection,
nsSelectionAmount aAmount,
EWordMovementType aWordMovementType = eDefaultBehavior);
/**
* Return the boundaries (in dev pixels) of the substring in case of textual
* frame or frame boundaries in case of non textual frame, offsets are
* ignored.
*/
LayoutDeviceIntRect GetBoundsInFrame(nsIFrame* aFrame,
uint32_t aStartRenderedOffset,
uint32_t aEndRenderedOffset);
// Selection helpers
/**
@ -356,26 +247,6 @@ class HyperTextAccessible : public AccessibleWrap,
int32_t aEndPos);
// Helpers
nsresult GetDOMPointByFrameOffset(nsIFrame* aFrame, int32_t aOffset,
LocalAccessible* aAccessible,
mozilla::a11y::DOMPoint* aPoint);
/**
* Set 'misspelled' text attribute and return range offsets where the
* attibute is stretched. If the text is not misspelled at the given offset
* then we expose only range offsets where text is not misspelled. The method
* is used by TextAttributes() method.
*
* @param aIncludeDefAttrs [in] points whether text attributes having default
* values of attributes should be included
* @param aSourceNode [in] the node we start to traverse from
* @param aStartOffset [in, out] the start offset
* @param aEndOffset [in, out] the end offset
* @param aAttributes [out, optional] result attributes
*/
void GetSpellTextAttr(nsINode* aNode, uint32_t aNodeOffset,
uint32_t* aStartOffset, uint32_t* aEndOffset,
AccAttributes* aAttributes);
/**
* Set xml-roles attributes for MathML elements.

Просмотреть файл

@ -8,6 +8,7 @@
#include "HyperTextAccessible.h"
#include "PlatformExtTypes.h"
#include "WordMovementType.h"
namespace mozilla {
namespace a11y {