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

74 Коммитов

Автор SHA1 Сообщение Дата
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
James Teh 4828f4d449 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-02 22:40:43 +00:00
James Teh 16c792ed33 Bug 1766560: Don't ignore the first line start of a RemoteAccessible when retrieving the next line. r=morgan
The code previously returned failure for array index 0, but it did this for both movement directions.
It should only do this for eDirPrevious, since we decrement index in that case.

Differential Revision: https://phabricator.services.mozilla.com/D144785
2022-04-28 10:42:11 +00:00
Butkovits Atila 19ed218d60 Backed out changeset a901a6c26367 (bug 1766560) for causing failures at browser_caching_text. CLOSED TREE 2022-04-28 05:47:17 +03:00
James Teh ff8c09efee Bug 1766560: Don't ignore the first line start of a RemoteAccessible when retrieving the next line. r=morgan
The code previously returned failure for array index 0, but it did this for both movement directions.
It should only do this for eDirPrevious, since we decrement index in that case.

Differential Revision: https://phabricator.services.mozilla.com/D144785
2022-04-28 02:11:53 +00:00
James Teh 6743bc23ee Bug 1766206: TextLeafPoint: When determining whether an Accessible is at the start of a line, compare with the last continuation of the previous leaf. r=morgan
Previously, we were always comparing with the primary frame of the previous leaf.
If the previous leaf crossed lines, this meant we incorrectly reported that the following leaf started a new line even if it didn't, since the primary frame of the previous leaf was always on a different line.
Now, we use the last continuation (line) of the previous leaf.
This way, if the next leaf continues the final line of the previous leaf, they will have the same line number and so we won't incorrectly report that the next leaf starts a new line.

Differential Revision: https://phabricator.services.mozilla.com/D144781
2022-04-28 02:09:16 +00:00
James Teh d91d6ecdec Bug 1735970 part 2: Add methods to unify querying an Accessible's id and retrieval of an Accessible from a document given an id. r=morgan
There is no base class for local (DocAccessible) and remote (DocAccessibleParent) documents, so this adds nsAccUtils::GetAccessibleByID.

Differential Revision: https://phabricator.services.mozilla.com/D141207
2022-04-01 09:49:56 +00:00
Eitan Isaacson 0de0993d51 Bug 1761200 - Check that parent is hypertext before getting attributes. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D141996
2022-03-25 18:41:12 +00:00
criss 34d3fb88a2 Backed out 18 changesets (bug 1735970) for causing hazard bustages.CLOSED TREE
Backed out changeset e7af2be486ce (bug 1735970)
Backed out changeset 73c93a18f65b (bug 1735970)
Backed out changeset 7e48716784d2 (bug 1735970)
Backed out changeset 30f61cdfd3c0 (bug 1735970)
Backed out changeset 3e4697e57570 (bug 1735970)
Backed out changeset 16ac3bec2412 (bug 1735970)
Backed out changeset 945ef21895ec (bug 1735970)
Backed out changeset 5dbfbf341ff8 (bug 1735970)
Backed out changeset d498d61c8f5a (bug 1735970)
Backed out changeset 50a2ee53b763 (bug 1735970)
Backed out changeset 9e2e11ea1a3d (bug 1735970)
Backed out changeset cf84daf9e40f (bug 1735970)
Backed out changeset 003bbf7f5f24 (bug 1735970)
Backed out changeset 00f1fbedc774 (bug 1735970)
Backed out changeset b17a1182539b (bug 1735970)
Backed out changeset 6d0f4821ddcf (bug 1735970)
Backed out changeset d82660fb5408 (bug 1735970)
Backed out changeset e506a5b04bf4 (bug 1735970)
2022-03-23 10:27:08 +02:00
James Teh d76deafa14 Bug 1735970 part 2: Add methods to unify querying an Accessible's id and retrieval of an Accessible from a document given an id. r=morgan
There is no base class for local (DocAccessible) and remote (DocAccessibleParent) documents, so this adds nsAccUtils::GetAccessibleByID.

Differential Revision: https://phabricator.services.mozilla.com/D141207
2022-03-23 04:00:25 +00:00
James Teh a9fcf6f459 Bug 1756730: Null check atributes in TextLeafPoint::FindTextAttrsStart. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D139453
2022-02-23 21:28:20 +00:00
James Teh e9f99b869e Bug 1730090: Implement support for BOUNDARY_PARAGRAPH in TextLeafPoint and HyperTextAccessibleBase. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D138744
2022-02-18 11:41:41 +00:00
James Teh 4181fc7eb2 Bug 1755604: Add Accessible::IsBefore/IsAncestorOf. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D138743
2022-02-18 09:49:02 +00:00
smolnar a7d4b25671 Backed out 4 changesets (bug 1730090, bug 1755604, bug 1755420) for causing build bustages in accessible/base/TextLeafRange.cpp CLOSED TREE
Backed out changeset f1f8a381f403 (bug 1755420)
Backed out changeset a3cfe47a020c (bug 1755420)
Backed out changeset b3360b57cf38 (bug 1730090)
Backed out changeset 3fb940c71b19 (bug 1755604)
2022-02-18 08:11:20 +02:00
James Teh 3c0d005e1c Bug 1730090: Implement support for BOUNDARY_PARAGRAPH in TextLeafPoint and HyperTextAccessibleBase. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D138744
2022-02-18 02:19:11 +00:00
James Teh e9f8aa87b3 Bug 1755604: Add Accessible::IsBefore/IsAncestorOf. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D138743
2022-02-18 02:19:11 +00:00
James Teh f65b9ea3f5 Bug 1730085 part 4: Implement support for BOUNDARY_WORD_END in TextLeafPoint and HyperTextAccessibleBase. r=eeejay
BOUNDARY_WORD_END is implemented using BOUNDARY_WORD_START and adjusting for spaces, which are word end boundaries.
This is arguably less efficient than it could be, since we will walk over space and then reverse course to compensate.
However, the alternative would mean keeping two slightly different versions of the word boundary check code in sync, plus compensating for the fact that a word often ends before a line start while still supporting words split by line wrapping.
I felt the lower complexity here outweighed the potential slight loss in efficiency.
We can always revisit this if this turns out to be a real problem.

Differential Revision: https://phabricator.services.mozilla.com/D138105
2022-02-11 06:27:03 +00:00
James Teh 08355e27b6 Bug 1730085 part 3: Move GetWordBreakClass out of PrevWordBreakClassWalker, as it will be needed outside of that class soon. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D138104
2022-02-11 06:27:03 +00:00
James Teh a8bd05cd9a Bug 1730085 part 2: Implement support for BOUNDARY_LINE_END in TextLeafPoint and HyperTextAccessibleBase. r=eeejay
BOUNDARY_LINE_END is implemented using BOUNDARY_LINE_START and adjusting for line feed characters, which are line end boundaries where present.

Differential Revision: https://phabricator.services.mozilla.com/D138103
2022-02-11 06:27:03 +00:00
James Teh 7039008a5d Bug 1730085 part 1: Fix some bugs in TextLeafPoint::FindBoundary for BOUNDARY_CHAR. r=eeejay
These bugs cause problems for the upcoming implementation of BOUNDARY_LINE_END.

1. Don't always return no character at the caret. Only do that if the caret is at the end of the line. This was always the intent; this was just a silly mistake.
2. When moving to the next character in an Accessible, don't move past the last character. This was a simple off-by-one error.

Differential Revision: https://phabricator.services.mozilla.com/D138102
2022-02-11 06:27:02 +00:00
smolnar af6e7b57c0 Backed out 4 changesets (bug 1730085) for causing bp-hybrid build bustages. CLOSED TREE
Backed out changeset dd90514bc052 (bug 1730085)
Backed out changeset 750f98502e6d (bug 1730085)
Backed out changeset e15365af4131 (bug 1730085)
Backed out changeset f08f12d82f7f (bug 1730085)
2022-02-11 05:25:29 +02:00