Граф коммитов

94 Коммитов

Автор SHA1 Сообщение Дата
Makoto Kato bef691023f Bug 1848282 - Part 3. a11y's word segmenter should reference layout.word_select preferences. r=morgan
We need to consider `layout.word_select.stop_at_punctuation preference` even if
using new segmenter.

Differential Revision: https://phabricator.services.mozilla.com/D188786
2023-10-03 10:43:18 +00:00
Makoto Kato 9dde11abbe Bug 1848282 - Part 1. Move IsPunctuation to nsUnicharUtils. r=TYLin
Remove duplication code.

Differential Revision: https://phabricator.services.mozilla.com/D188784
2023-10-03 10:43:17 +00:00
Natalia Csoregi a03097876a Backed out 3 changesets (bug 1848282) for causing gv-junit failures. CLOSED TREE
Backed out changeset d1fc71cc3817 (bug 1848282)
Backed out changeset 3446c1367bfd (bug 1848282)
Backed out changeset c800ae9f7943 (bug 1848282)
2023-09-28 08:03:34 +03:00
Makoto Kato 9e1a48232e Bug 1848282 - Part 3. a11y's word segmenter should reference layout.word_select preferences. r=morgan
We need to consider `layout.word_select.stop_at_punctuation preference` even if
using new segmenter.

Differential Revision: https://phabricator.services.mozilla.com/D188786
2023-09-28 04:11:06 +00:00
Makoto Kato 750893b128 Bug 1848282 - Part 1. Move IsPunctuation to nsUnicharUtils. r=TYLin
Remove duplication code.

Differential Revision: https://phabricator.services.mozilla.com/D188784
2023-09-28 04:11:05 +00:00
Makoto Kato ef2a0ed90f Bug 1851105 - Use nsAString as parameter for WordBreaker::FindWord. r=TYLin
It is better to use nsAString rather than using pointer directly.

Differential Revision: https://phabricator.services.mozilla.com/D187256
2023-09-08 04:35:38 +00:00
James Teh 313b0fbdf5 Bug 1743749 part 2: Replace usage of atoms as cache keys with the new CacheKey aliases. r=nlapre
This was done with the following Python script:

```
import re

cacheConsts = open("accessible/base/CacheConstants.h", "rt").read()
aliases = {
  alias: atom
  for atom, alias in
  re.findall(
    r'static constexpr nsStaticAtom\*\s+(.*?)\s+=\s+(nsGkAtoms::.*?);',
    cacheConsts
  )
}

RE_ATOM = re.compile(r'(fields->SetAttribute|(?:mCachedFields|aFields)->(?:GetAttribute|GetAttributeRefPtr|GetMutableAttribute|HasAttribute|Remove|SetAttribute)(?:<.+>)?)(\(\s*)(nsGkAtoms::[a-zA-Z_]+)')

def repl(m):
  # Group 3 is the atom.
  alias = aliases.get(m.group(3))
  if not alias:
    # No alias for this atom. Return input unaltered.
    return m.group(0)
  alias = "CacheKey::" + alias
  # Groups 1 and 2 should be returned unaltered. Group 3 (the atom) is replaced
  # with the alias.
  return m.group(1) + m.group(2) + alias

for fn in (
  # Found with: git grep -l 'ields->'
  "accessible/base/CachedTableAccessible.cpp",
  "accessible/base/nsAccessibilityService.cpp",
  "accessible/base/TextLeafRange.cpp",
  "accessible/generic/LocalAccessible.cpp",
  "accessible/ipc/DocAccessibleParent.cpp",
  "accessible/ipc/RemoteAccessible.cpp",
  "accessible/ipc/RemoteAccessible.h",
  "accessible/windows/sdn/sdnAccessible.cpp",
):
  input = open(fn, "rt").read()
  output = RE_ATOM.sub(repl, input)
  open(fn, "wt").write(output)
```

Differential Revision: https://phabricator.services.mozilla.com/D184791
2023-07-31 23:09:56 +00:00
Nathan LaPre 85a3b00160 Bug 1840732 Part 1: Remove unnecessary includes from accessible/base, r=Jamie
This revision removes unnecessary include directives from cpp files in the
accessible/base directory. These suggestions came from the Include What You Use
tool.

Differential Revision: https://phabricator.services.mozilla.com/D182288
2023-07-07 03:22:07 +00:00
Eitan Isaacson 85a5ad4790 Bug 1834874 - P1: Make text navigation work in UI thread with cached TextLeafPoint API. r=Jamie,geckoview-reviewers,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D181320
2023-06-20 18:15:42 +00:00
Morgan Rae Reschenberg d23af61142 Bug 1832260: Fallback to LocalAccessible::Bounds if we can't find a frame in ComputeBoundsFromFrame. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D178576
2023-05-23 21:19:32 +00:00
James Teh a5344cdc1b Bug 1830466: Mac a11y: Don't try to search forward for a line end boundary on a blank line. r=eeejay
1. CachedTextMarker::LineRange: If the line starts with a line feed, it's a blank line and the end boundary is the same as the start boundary, so just return the start for both.
2. TextLeafRange::FindLineEnd: If the origin is the empty last line of a textarea, we actually do want the line starting at the next character, so don't skip forward a character. Also don't skip back to the line feed after the search, since that would be the end of the previous line.

Differential Revision: https://phabricator.services.mozilla.com/D177366
2023-05-10 06:53:33 +00:00
James Teh 4dec25751e Bug 1829167: Construct an invalid TextLeafPoint if null is supplied to the constructor. r=nlapre
DocAccessibleChildBase::RecvSetTextSelection and RecvScrollTextLeafRangeIntoView constructs TextLeafPoints without null checking the retrieved Accessible.
This can be null if the Accessible was destroyed in the content process but the parent process didn't know about this yet when it sent the request.
TextLeafPoint currently crashes if constructed with a null Accessible.
These DocAccessibleChildBase methods do check the validity of the range, which will be invalid if the TextLeafPoints are invalid.
Therefore, just construct an invalid TextLeafPoint if a null Accessible is given.

Differential Revision: https://phabricator.services.mozilla.com/D176494
2023-04-26 23:08:33 +00:00
Eitan Isaacson d70f1224fa Bug 1826264 - P2: Add range TextLeafRange::ScrollIntoView. r=Jamie
Use it when caching is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D174977
2023-04-13 20:40:19 +00:00
Eitan Isaacson 60909e6894 Bug 1826264 - P1: Implement TextLeafPoint::ToDOMPoint. r=Jamie
Generalized code we already had for getting DOM points for DOM
selection.

Differential Revision: https://phabricator.services.mozilla.com/D174976
2023-04-13 20:40:19 +00:00
Eitan Isaacson 545741bece Bug 1825054 - Don't get stuck in endless loop when getting bounds. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D173864
2023-03-29 22:31:00 +00:00
Eitan Isaacson 385aaab8e0 Bug 1823979 - Remove strict assertion in text selection. r=morgan
I was trying to anticipate all the conditions that would bring us
to a non-text leaf text point in a text selection. But it is hard to
account for other "correct" cases so this assertion should probably just
go away.

Differential Revision: https://phabricator.services.mozilla.com/D173760
2023-03-28 16:24:15 +00:00
James Teh 428e00698c Bug 1823594: TextLeafPoint::CharBounds: Only fail the assertion if the offset is larger than the length. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D173248
2023-03-23 00:36:49 +00:00
James Teh 633f202e6d Bug 1821954: Make HyperTextAccessible::Char/TextBounds use HyperTextAccessibleBase when the cache is enabled. r=morgan
This is consistent with other HyperTextAccessible methods such as TextAtOffset.
It allows us to test the new implementation with LocalAccessible.
This is especially useful because we have better test coverage in our HyperText tests than we do in our TextLeafPoint tests.

In fact, running the tests with this change uncovered some bugs which I had to fix here.

First, TextLeafPoint::ComputeBoundsFromFrame was preferring to stick to the end of the first frame when on a boundary, rather than using the next frame.
For example, if we had the text "a\nb" where "b" is split into a continuation, offset 2 "b" was previously using the primary frame instead of the continuation.
This isn't a problem in HyperTextAccessible::GetBoundsInFrame because it walks to the next continuation if needed, since it is dealing with a range of offsets.
This is fixed by preferring the beginning of the next frame instead.

Second, passing the text length as the offset (i.e. one past the last character) should return a 0 rect.
TextLeafPoint::CharBounds needed to be tweaked accordingly.

Third, if TextLeafPoint returns a 0 rect (e.g. because a RemoteAccessible doesn't have a cache yet), HyperTextAccessibleBase needs to respect that and return it untouched.

Differential Revision: https://phabricator.services.mozilla.com/D172533
2023-03-21 01:23:40 +00:00
James Teh 5ec432103b Bug 1821223: TextLeafPoint: Don't treat an entire table as a paragraph. r=eeejay
Table rows and cells are now treated as paragraph boundaries.
Whether a cell should be a paragraph boundary is debatable, but currently, a cell is treated as a line boundary, so this is consistent; a line shouldn't expand beyond a paragraph.

Differential Revision: https://phabricator.services.mozilla.com/D172079
2023-03-10 03:48:34 +00:00
Morgan Rae Reschenberg 60f92a62cb Bug 1820029: Inline HyperTextAccessible::TextBounds to TextLeafPoint::CharBounds r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D171503
2023-03-09 19:59:00 +00:00
Jan-Niklas Jaeschke ebf3cd6240 Bug 1808565, part 1: Adapt `Selection` to support `StaticRange`s. r=webidl,saschanaz,masayuki,smaug
This change is necessary to support the [CSS Highlight API](https://drafts.csswg.org/css-highlight-api-1/),
which uses `Selection` internally.

To replace `nsRange` with `AbstractRange`, some sections needed to be
adapted since `nsRange`-specific features were used.
Therefore, some methods (such as `GetRangeAt()`) may only be called if
the `Selection` is *not* of type `SelectionType::eHighlight`,
as it (per spec) returns an `nsRange`.
These methods will now `MOZ_ASSERT` if called for a highlight selection.
Additional methods are implemented which return `AbstractRange`
instead and are safe to be called for every selection type.

This commit also improves support of highlight features:
- Invalidation of highlight ranges: adding/removing Ranges in-place instead of
  removing and re-adding the Selection object associated with the highlight.
- Ranges are only associated with the Selection that shares the same Document
- Fixed minor IDL issue

Differential Revision: https://phabricator.services.mozilla.com/D170582
2023-03-03 14:59:47 +00:00
James Teh 958055f388 Bug 1819802 part 1: When getting cached a11y character bounds, return a single rect rather than an array of rects. r=morgan
When hit testing, we retrieve the bounds for every character in a text leaf in a separate call.
Because we need to convert from an array of flat ints to rects, this previously meant we built the entire array for every character.
For a large text leaf, building this rect array is relatively expensive.
We only need a single rect at a time.
Therefore, RemoteAccessibleBase now returns the rect for a single requested character instead of building an array of rects.

Differential Revision: https://phabricator.services.mozilla.com/D171419
2023-03-03 03:26:21 +00:00
Morgan Rae Reschenberg 7a080d4df8 Bug 1778441: Call into HyperTextAccessible::CharBounds when computing char bounds for local-acc TextLeafPoint's r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D171285
2023-03-02 18:08:15 +00:00
Eitan Isaacson 8bf95c7d17 Bug 1814220 - Allow ignoring list item markers in TextLeafPoint::FindBoundary. r=Jamie
Refactor in FindBoundary to allow easier skipping of leaves in the loop.

Differential Revision: https://phabricator.services.mozilla.com/D168445
2023-02-22 04:17:31 +00:00
Eitan Isaacson 4cdf1e6cc0 Bug 1816536 - Fix document edge issues in FindBounary. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D169726
2023-02-21 16:37:24 +00:00
Eitan Isaacson a8c6dc0db1 Bug 1816573 - Use flags in TextLeafPoint::FindBoundary instead of boolean arguments. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D169740
2023-02-21 16:37:23 +00:00
Eitan Isaacson dbdb811bfa Bug 1811092 - P1: Add new async add/set text selection message. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D167201
2023-01-27 20:15:11 +00:00
Eitan Isaacson 9bda15c625 Bug 1769824 - Move text range bounds implementation to TextLeafRange. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D166370
2023-01-09 19:56:20 +00:00
James Teh c579cdfd2e Bug 1793408: Consistently treat OuterDocAccessibles as a single character in TextLeafPoint. r=morgan
1. When constructing a TextLeafPoint and searching for a leaf, do not descend inside an OuterDoc (iframe/browser).
  Otherwise, we end up inside another document.
  Other TextLeafPoint code avoids crossing document boundaries, so the constructor must do this too.
2. When searching for a leaf, include an OuterDoc, but don't walk inside it.
  Previously, we skipped OuterDocs altogether.
  This meant that if you started on an OuterDoc, walking backward and then forward by character would never return you to your origin.
  Also, clients walking the document text shouldn't just skip iframes altogether, so exposing them as a single character makes more sense.

This fixes infinite loops in OffsetAtPoint when querying a container with an iframe at the end.

Differential Revision: https://phabricator.services.mozilla.com/D158740
2022-10-06 23:47:50 +00:00
Eitan Isaacson 96c72183cc Bug 1788116 - Introduce TextLeafRange iterator. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D156003
2022-08-31 20:34:18 +00:00
Eitan Isaacson c039e2a85b Bug 1785930 - Introduce aStopInEditable argument in TextLeafPoint::FindBoundary. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D155030
2022-08-26 16:26:31 +00:00
Eitan Isaacson baa3f51d6b Bug 1776907 - Detect line breaks with inputs correctly. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D150492
2022-08-18 17:10:43 +00:00
Eitan Isaacson d66b7102eb Bug 1782563 - Support END_OF_TEXT offset in TextLeafPoint constructor. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D153386
2022-08-02 16:29:07 +00:00
Eitan Isaacson 92afd6db93 Bug 1782550 - Don't treat list bullets as block items. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D153371
2022-08-02 16:27:31 +00:00
Morgan Rae Reschenberg 644b66ac98 Bug 1775329: Support cached OffsetAtPoint in HyperTextAccessibleBase r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D150049
2022-07-05 19:50:45 +00:00
criss fc6d3e181e Backed out 2 changesets (bug 1775329, bug 1776275) for causing mochitest failures on browser_test_zoom_text.js. CLOSED TREE
Backed out changeset 72519abf87ee (bug 1775329)
Backed out changeset 365e262b3dad (bug 1776275)
2022-06-29 23:39:31 +03:00
Morgan Rae Reschenberg a68d0f55b4 Bug 1775329: Support cached OffsetAtPoint in HyperTextAccessibleBase r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D150049
2022-06-29 19:00:14 +00:00
Eitan Isaacson 32e8c940bd Bug 1773102 - Accomodate xul label[value] in offset conversions and spelling errors. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D148677
2022-06-12 06:59:18 +00:00
Jonathan Kew f117f58e47 Bug 1771609 - patch 3 - Remove nsAutoLineIterator, as it no longer serves any useful purpose since the iterator is owned by the target frame. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D147579
2022-06-03 22:05:36 +00:00
James Teh 7564ed957c Bug 1737919 part 4: Update cached spelling errors when a spelling error is added without the text changing. r=morgan,smaug
We already have an nsISelectionListener, but that only tells us that a change happened somewhere in the selection, not which range changed.
We don't want to push a cache update for all ranges when only one changed.
Therefore, this patch adds an accessibility notification in mozInlineSpellChecker::AddRange.
We don't need this for removed ranges because the text will change for any spelling error corrections and text updates trigger spelling error cache updates.

Differential Revision: https://phabricator.services.mozilla.com/D147244
2022-05-27 10:56:41 +00:00
James Teh 3daa72eb49 Bug 1737919 part 3: Support spelling errors for cached RemoteAccessibles. r=morgan
Even though spelling errors can cross Accessibles and are represented in the DOM as ranges, we cache them for each text leaf.
This is necessary so that we correctly update the offsets when text is inserted or removed from a leaf.
We cache them as an array of offsets, including both the start and end offset for each range.
We use -1 as the start offset to indicate when a spelling error starts in a previous Accessible.
When a spelling error starts in an Accessible but ends in a subsequent one, we simply don't include an end offset in the array.
This structure means we can easily query spelling error points or ranges with a binary search.

Differential Revision: https://phabricator.services.mozilla.com/D147243
2022-05-27 10:56:41 +00:00
James Teh e02ce0a43e Bug 1737919 part 2: Support spelling errors in TextLeafPoint for LocalAccessibles. r=morgan
The implementation searches for spelling errors in each leaf, as this is how we will need to do it for RemoteAccessibles.

Differential Revision: https://phabricator.services.mozilla.com/D147242
2022-05-27 10:56:40 +00:00
James Teh efe397519e Bug 1737919 part 1: TextLeafPoint::FindTextAttrsStart: Don't allow the caller to supply origin attributes. r=morgan
This was done for LocalAccessibles to avoid the need to fetch attributes twice when we're simultaneously fetching boundaries and returning the attributes to a client.
However, GetTextAttributes will soon handle spelling errors, so it will no longer return the same data as GetTextAttributesLocalAcc (which doesn't handle spelling errors).
This breaks the equality checks in FindTextAttrsStart.
Aside from this, this argument was somewhat confusing.

For now, just remove aOriginAttrs, which means there will be some redundant calls to GetTextAttributesLocalAcc.
Parent process documents shouldn't be that large anyway.
If this ends up being a real problem, we can either revert to the local HyperTextAccessible implementation of text attributes or implement a smarter temporary cache.

Differential Revision: https://phabricator.services.mozilla.com/D147241
2022-05-27 10:56:40 +00:00
James Teh 732a2400fe Bug 1771259: Fix crash when calling TextLeafPoint::CharBounds on the insertion point at the end of a text box. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D147397
2022-05-27 03:00:34 +00:00
James Teh 0ea37698e8 Bug 1771060: Make use of the line cursor in IsLocalAccAtLineStart to improve performance. r=jfkthame
For block frames, nsLineIterator doesn't use the line cursor, so switch to nsBlockInFlowLineIterator.
We don't actually care about the line number here anyway.

Differential Revision: https://phabricator.services.mozilla.com/D147237
2022-05-27 01:22:07 +00:00
Morgan Rae Reschenberg c3d3119342 Bug 1768054: Traverse embedded chars when computing text bounds. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D145908
2022-05-23 21:43:12 +00:00
James Teh be0257f0e6 Bug 1767887: Fix TextLeafPoint paragraph boundary search for the second leaf Accessible and beyond after a block. r=morgan
The code checks whether the origin is inside the block, since if not, the block ends before the origin.
However, it previously didn't handle the case where there was a leaf outside the block between the block and the origin.
An additional check has now been added to handle this case.
This required the code to be restructured somewhat, which hopefully also makes it easier to read/debug.

Differential Revision: https://phabricator.services.mozilla.com/D145867
2022-05-09 23:41:02 +00:00
Morgan Reschenberg 4e6096c73d Bug 1735101: Cache char, line coordinate info to support computing TextBounds and CharBounds in the parent process r=Jamie
Depends on D144767

Differential Revision: https://phabricator.services.mozilla.com/D143527
2022-05-09 20:30:27 +00:00
James Teh 4e792c6a29 Bug 1766954: TextLeafRange: Don't call nsIFrame::RenderedText for pre-formatted text. r=eeejay
For pre-formatted text, the content text and rendered text are the same.
Therefore, there's no point calling nsIFrame::RenderedText, which is quite slow for nodes containing a large chunk of text.
This improves performance significantly when caching line start offsets for large plain text files such as logs.

Differential Revision: https://phabricator.services.mozilla.com/D145080
2022-05-04 04:18:11 +00:00
Butkovits Atila c1773abb87 Backed out changeset 4e3e696ff054 (bug 1766954) for causing bustages at nsStyleStruct.h. CLOSED TREE 2022-05-03 03:43:58 +03:00