This prevents copies and avoids the hack we have to avoid this, which
right now is using nsDependent{C,}String.
Non-virtual actors can still use `nsString` if they need to on the
receiving end.
Differential Revision: https://phabricator.services.mozilla.com/D152519
Add a pref for MouseEvent.region since that wasn't un-exposed. No other
browser supports it so we can probably safely remove it, but just in
case.
Differential Revision: https://phabricator.services.mozilla.com/D152274
Attributes() might do computation that we'll just throw away; e.g. building a CachedTableAccessible.
In a content process, cached data structures like this will never get used by a client, so building them will always be wasteful.
Instead, use nsAccUtils::SetLiveContainerAttributes, which only computes live region stuff.
Differential Revision: https://phabricator.services.mozilla.com/D151799
gfxFontCache acquires and releases its mutex during various operations.
In order to keep the state internally consistent, we should only release
the lock after the full operation is complete. This involves moving the
deletion of gfxFont to outside the lock via a temporary discard array.
The expiration state should not be protected by the gfxFont's mutex
since we don't hold it during most operations. Instead we should hold
gfxFontCache's mutex because then we can guarantee the operation is
atomic, particularly when a worker wants a font, and the main thread is
aging the generations.
When a font is returned from gfxFontCache, we now return it already
removed from the tracker, and with its refcount updated. This avoids any
potential races between the expiration timer and a worker accessing the
font, as well as simplying the callers so they don't need to be aware of
addref-ing manually in case the result is to be discarded (so that it
gets readded to the tracker).
Differential Revision: https://phabricator.services.mozilla.com/D151821
gfxFontCache acquires and releases its mutex during various operations.
In order to keep the state internally consistent, we should only release
the lock after the full operation is complete. This involves moving the
deletion of gfxFont to outside the lock via a temporary discard array.
The expiration state should not be protected by the gfxFont's mutex
since we don't hold it during most operations. Instead we should hold
gfxFontCache's mutex because then we can guarantee the operation is
atomic, particularly when a worker wants a font, and the main thread is
aging the generations.
When a font is returned from gfxFontCache, we now return it already
removed from the tracker, and with its refcount updated. This avoids any
potential races between the expiration timer and a worker accessing the
font, as well as simplying the callers so they don't need to be aware of
addref-ing manually in case the result is to be discarded (so that it
gets readded to the tracker).
Differential Revision: https://phabricator.services.mozilla.com/D151821
1. Move AccessKey to base Accessible.
2. Retrieve AccessKey from the cache for RemoteAccessible.
3. Update XPCOM and platform specific code accordingly.
Differential Revision: https://phabricator.services.mozilla.com/D151202
KeyboardShortcut is only supported for XUL menu items.
XUL menu items can never be remote, so there's no point in querying this via IPDL.
Differential Revision: https://phabricator.services.mozilla.com/D151199
1. Move AccessKey to base Accessible.
2. Retrieve AccessKey from the cache for RemoteAccessible.
3. Update XPCOM and platform specific code accordingly.
Differential Revision: https://phabricator.services.mozilla.com/D151202
KeyboardShortcut is only supported for XUL menu items.
XUL menu items can never be remote, so there's no point in querying this via IPDL.
Differential Revision: https://phabricator.services.mozilla.com/D151199
We don't create Accessibles for all elements.
If an element has a global ARIA attribute when it is shown, we do create an Accessible for it.
However, previously, if we didn't initially create an Accessible for an element (e.g. no global ARIA attributes) and it subsequently gained a global ARIA attribute, we didn't create an Accessible at that point.
We now explicitly handle this case when such an attribute is added.
Differential Revision: https://phabricator.services.mozilla.com/D151348
1. When updating the row/col map, there can be overlapping cells - we even have code to support that - so don't assert that there is no existing cell.
2. When retrieving the caption, the role assertion was accidentally reversed.
Differential Revision: https://phabricator.services.mozilla.com/D151569
Previously, we used CellAt, but this returns the Accessible, discarding the CachedTableCellAccessible.
RowHeaderCells needs both, so it then called AsTableCellBase, which must walk ancestors to get the table.
We already have the table and access to its private data, so use it directly.
This is probably an insignificant performance improvement, but the unnecessary indirection was bothering me.
Differential Revision: https://phabricator.services.mozilla.com/D151571
Some markup elements expose Accessible attributes which must be retrieved from DOM; e.g. the datetime attribute of the datetime element.
We don't cache these yet for RemoteAccessible.
Previously, these were unintentionally exposed from MarkupAttributes with null values.
For now, these should be skipped instead until we have caching code for them.
This fixes crashes whenever a client tries to fetch attributes from such an element.
Differential Revision: https://phabricator.services.mozilla.com/D151659
1. Make ia2AccessibleText::UpdateTextChangeData (and sLastTextChangeAcc) use HyperTextAccessibleBase instead of HyperTextAccessibleWrap.
2. Make ProxyTextChangeEvent call UpdateTextChangeData when the cache is enabled.
3. Don't send sync text change events when the cache is enabled. They don't need to be sync because clients query the cache, not the content process a11y tree. Even if the content process a11y tree mutates, the cache can't update until in-process clients have synchronously handled the event.
Differential Revision: https://phabricator.services.mozilla.com/D139677
As part of this, aria-relevant is now exposed via object attributes.
This is necessary to ensure it is included in the cache.
There's no good reason not to expose it anyway, since we already expose the other live region attributes.
Differential Revision: https://phabricator.services.mozilla.com/D150380
RemoteAccessibleBase::Attributes will soon use the service to query markup attributes.
Thus, the service must not shut down while a client call is being handled on the UI thread.
Differential Revision: https://phabricator.services.mozilla.com/D150722
This will be needed for easier checking of aria-atomic.
It is also more efficient in terms of cache storage, since we previously pushed strings for these values.
This moves the code from GetARIAToken into NormalizeARIAToken, since GetARIAToken isn't used any more and it makes sense to handle normalization in one place.
Differential Revision: https://phabricator.services.mozilla.com/D150379
This makes it possible for it to work for RemoteAccessible.
There is a functional change here in that using the a11y tree means we traverse parents set via aria-owns, where previously we only walked the DOM ancestry.
I doubt this will have any impact in the wild and Chromium already does this anyway.
Differential Revision: https://phabricator.services.mozilla.com/D150378
Previously, these methods took a DOM nsIContent, making it impossible for them to work for RemoteAccessible.
GetMarkupMapInfoForNode has been renamed to GetMarkupMapInfoFor and has overloads for nsIContent and Accessible.
MarkupAttribute is a template which can take either, as we still need the nsIContent version elsewhere.
MarkupAttributes now only takes an Accessible, as it can get the nsIContent from the Accessible if necessary.
Differential Revision: https://phabricator.services.mozilla.com/D150377
QuerySelector can fail if the id is invalid; e.g. if it contains a quote (") character.
ErrorResult treats a failure as an exception, so it asserts.
We explicitly check for and handle failure ourselves, so use IgnoredErrorResult instead.
Differential Revision: https://phabricator.services.mozilla.com/D151564
The associated PresShell of the root doc can be used for retrieving the
SessionAccessibility. If the PresShell is about to go away, we should
unregister all the accessibles.
Differential Revision: https://phabricator.services.mozilla.com/D150661
We'll probably want to do something more accurate in the future with a
custom clang static analysis pass which validates that XPIDL interfaces
have the expected vtable and struct layout, however doing so would be
more involved than the string matching done in this patch.
In addition to checking for extra virtual methods, we'll likely also
want to check for data members on interfaces, and reject them unless the
class is marked as `[builtinclass]` in addition to some other attribute
which we'll need to add to prevent them from being implemented in Rust
(as c++ data members will not be reflected by the rust macro).
There were 2 instances of a comment which contained the word 'virtual'
within a CDATA block. These comments were moved out of the CDATA block
to avoid triggering the error.
Differential Revision: https://phabricator.services.mozilla.com/D151068
Previously, we retrieved the active tab.
However, remote documents might not be within a tab; e.g. extension sidebars.
Instead, we now use BrowserParent::GetFocused to get the focused document.
Differential Revision: https://phabricator.services.mozilla.com/D150706
Extension sidebars are remote documents.
However, they are embedded inside a XUL <window>, which is a sub-document of the root document.
Previously, our accChild code required that the remote document be embedded in the same local document as the Accessible on which accChild was called.
This meant that calling accChild on the root with the id of an Accessible in an extension sidebar failed.
To fix this, allow a remote document to be embedded in a descendant local document.
Differential Revision: https://phabricator.services.mozilla.com/D150716
1. Make ia2AccessibleText::UpdateTextChangeData (and sLastTextChangeAcc) use HyperTextAccessibleBase instead of HyperTextAccessibleWrap.
2. Make ProxyTextChangeEvent call UpdateTextChangeData when the cache is enabled.
3. Don't send sync text change events when the cache is enabled. They don't need to be sync because clients query the cache, not the content process a11y tree. Even if the content process a11y tree mutates, the cache can't update until in-process clients have synchronously handled the event.
Differential Revision: https://phabricator.services.mozilla.com/D139677
As part of this, aria-relevant is now exposed via object attributes.
This is necessary to ensure it is included in the cache.
There's no good reason not to expose it anyway, since we already expose the other live region attributes.
Differential Revision: https://phabricator.services.mozilla.com/D150380
This will be needed for easier checking of aria-atomic.
It is also more efficient in terms of cache storage, since we previously pushed strings for these values.
This moves the code from GetARIAToken into NormalizeARIAToken, since GetARIAToken isn't used any more and it makes sense to handle normalization in one place.
Differential Revision: https://phabricator.services.mozilla.com/D150379
This makes it possible for it to work for RemoteAccessible.
There is a functional change here in that using the a11y tree means we traverse parents set via aria-owns, where previously we only walked the DOM ancestry.
I doubt this will have any impact in the wild and Chromium already does this anyway.
Differential Revision: https://phabricator.services.mozilla.com/D150378
Previously, these methods took a DOM nsIContent, making it impossible for them to work for RemoteAccessible.
GetMarkupMapInfoForNode has been renamed to GetMarkupMapInfoFor and has overloads for nsIContent and Accessible.
MarkupAttribute is a template which can take either, as we still need the nsIContent version elsewhere.
MarkupAttributes now only takes an Accessible, as it can get the nsIContent from the Accessible if necessary.
Differential Revision: https://phabricator.services.mozilla.com/D150377
This also changes LocalAccessible::Attributes to ignore the edge case of an empty role attribute when calculating xml-roles.
This is consistent with how we handle the role attribute elsewhere (see aria::GetRoleMapIndex) and makes it easier to handle this consistently between local and remote.
Differential Revision: https://phabricator.services.mozilla.com/D149594
We were previously looking for a doc (IsDoc), but we'll never get any doc in a viewport cache except for the doc whose viewport we are searching.
Instead, if we encounter an iframe, we'll hit an OuterDoc (IsOuterDoc) which is the Accessible for the iframe element.
In that case, we walk *inside* that OuterDoc to get its embedded document, then recurse from there if appropriate.
Differential Revision: https://phabricator.services.mozilla.com/D149247
Sometimes, the document occurs too early in the viewport cache, perhaps even right at the start.
We weren't benefitting from it being in the cache anyway, since we always skipped it.
We already have a fallback in ChildAtPoint for the case where we didn't find a matching Accessible, so we rely on that to handle returning the document when appropriate.
Differential Revision: https://phabricator.services.mozilla.com/D149493
This was moved to a post refresh observer on the misunderstanding that this would allow us to benefit from retained display lists.
In reality, it doesn't; work would need to be done in layout to benefit from those, and since there are different display lists for hit testing and painting, this may not be feasible anyway.
Furthermore, the post refresh implementation was broken because WillRefresh often removes the post refresh observer, which meant that a viewport cache update was never actually pushed!
We could fix this by adding the post refresh observer only if the viewport cache is dirty, removing the post refresh observer in DidRefresh and also removing the post refresh observer in Shutdown only if the viewport cache is dirty.
However, given that we can't benefit from retained display lists anyway, using a post refresh observer doesn't serve any purpose at this stage.
Among other things, this fixes intermittent problems with image maps, which often get inserted into the tree after the initial tree is built.
Differential Revision: https://phabricator.services.mozilla.com/D149492
While this removes most of the local-specific code, we can't remove ARIARowAccessible::GroupPosition yet because it also calculates row index/count compensating for intervening Accessibles between tables and rows.
Eventually, we should fix that properly in AccGroupInfo, at which point we can remove this.
Differential Revision: https://phabricator.services.mozilla.com/D149225
Previously, AttrIterator always exposed string values.
Soon, we'll be using this for caching, so we don't want to convert token values to strings.
We'll eventually need to expose numeric values as well.
To achieve this, an ExposeAttr method was added which takes an AccAttributes and sets the attribute on it using an appropriately typed value.
In addition, a small optimisation was made so we don't search the ARIA attributes map twice for each attribute we query.
The string version of AttrName was also removed, since it wasn't used.
Unfortunately, AttrValue can't be removed yet because our old UIA implementation depends on it, but that will have to be rewritten at some point in future.
Differential Revision: https://phabricator.services.mozilla.com/D149221
This behaviour doesn't currently work for OOP iframes.
While we could make it work for OOP iframes using the cache, it isn't covered by the spec, nor does any other browser support it.
Differential Revision: https://phabricator.services.mozilla.com/D149220
Our hit testing tests need this.
This adds a base Accessible::BoundsInCSSPixels implementation which relies on BoundsInAppUnits.
BoundsInAppUnits was also moved to Accessible, but it is implemented differently for local and remote, so the base method is abstract.
I also did a drive-by removal of a pointless conditional in xpcAccessible::GetBounds.
Differential Revision: https://phabricator.services.mozilla.com/D149374
When the cache is enabled, this now also fetches the deepest descendant instead of a direct child.
In addition, I removed some unnecessary/misleading comments.
Differential Revision: https://phabricator.services.mozilla.com/D149240
This was wasting memory for the parent process, and when the cache was disabled, all content processes.
QueueCacheUpdate now checks whether we are actually sending cache updates before it queues anything.
Simple calls rely on this check, rather than guarding the call to QueueCacheUpdate themselves.
We still call QueueCacheUpdate conditionally for more complex cases which would have to do work before calling QueueCacheUpdate, since we don't want to pointlessly do that prerequisite work.
Differential Revision: https://phabricator.services.mozilla.com/D149231
This hittesting approach is borrowed from our Android implementation.
We maintain a cache of ID's for accessibles which are visible in the viewport.
This cache is created with a call to `nsLayoutUtils::GetFramesForArea`, which
returns frames in the viewport, in hittesting order.
In the parent process, we walk through the cache, keeping track of accs whose
bounds contain the hittesting point. Depending on if we're searching for the
direct child, or the deepest child, we walk the entire cache or return the
first match.
Each document (in the content process) maintains a dirty bit, which gets set
any time an acc it contains bundles either a text update, or an update that
affects bounds. We check whether this bit is set in `DidRefresh` after getting
a notification from our post-refresh observer. If that bit is set, we
queue a cache update for the `::Viewport` domain on the current document.
Because this cache depends on the viewport being painted, we include the
`IgnorePaintSuppression` flag in our `GetFramesForArea` call. This ensures
the display lists are built before the page finishes loading.
Differential Revision: https://phabricator.services.mozilla.com/D147225
Now that cbindgen and rust support const generics, it seems more simple.
This centralizes all the relevant font constants etc in rust and avoids
conversions when going from rust to C++ and vice versa.
Differential Revision: https://phabricator.services.mozilla.com/D148847
Now that cbindgen and rust support const generics, it seems more simple.
This centralizes all the relevant font constants etc in rust and avoids
conversions when going from rust to C++ and vice versa.
Differential Revision: https://phabricator.services.mozilla.com/D148847
The biggest set of APIs from ns[T]StringObsolete which are still heavily used
are the string searching APIs. It appears the intention was for these to be
replaced by the `FindInReadable` APIs, however that doesn't appear to have
happened.
In addition, the APIs have some quirks around their handling of mixed character
widths. These APIs generally supported both narrow strings and the native
string type, probably because char16_t string literals weren't available until
c++11. Finally they also used easy-to-confuse unlabeled boolean and integer
optional arguments to control behaviour.
These patches do the following major changes to the searching APIs:
1. The ASCII case-insensitive search method was split out as
LowerCaseFindASCII, rather than using a boolean. This should be less
error-prone and more explicit, and allows the method to continue to use
narrow string literals for all string types (as only ASCII is supported).
2. The other [R]Find methods were restricted to only support arguments with
matching character types. I considered adding a FindASCII method which would
use narrow string literals for both wide and narrow strings but it would've
been the same amount of work as changing all of the literals to unicode
literals.
This ends up being the bulk of the changes in the patch.
3. All find methods were re-implemented using std::basic_string_view's find
algorithm or stl algorithms to reduce code complexity, and avoid the need to
carry around the logic from nsStringObsolete.cpp.
4. The implementations were moved to nsTStringRepr.cpp.
5. An overload of Find was added to try to catch callers which previously
called `Find(..., false)` or `Find(..., true)` to set case-sensitivity, due
to booleans normally implicitly coercing to `index_type`. This should
probably be removed at some point, but may be useful during the transition.
Differential Revision: https://phabricator.services.mozilla.com/D148300
This hittesting approach is borrowed from our Android implementation.
We maintain a cache of ID's for accessibles which are visible in the viewport.
This cache is created with a call to `nsLayoutUtils::GetFramesForArea`, which
returns frames in the viewport, in hittesting order.
In the parent process, we walk through the cache, keeping track of accs whose
bounds contain the hittesting point. Depending on if we're searching for the
direct child, or the deepest child, we walk the entire cache or return the
first match.
Each document (in the content process) maintains a dirty bit, which gets set
any time an acc it contains bundles either a text update, or an update that
affects bounds. We check whether this bit is set in `DidRefresh` after getting
a notification from our post-refresh observer. If that bit is set, we
queue a cache update for the `::Viewport` domain on the current document.
Because this cache depends on the viewport being painted, we include the
`IgnorePaintSuppression` flag in our `GetFramesForArea` call. This ensures
the display lists are built before the page finishes loading.
Differential Revision: https://phabricator.services.mozilla.com/D147225
It has a lot of XBL / Shadow DOM v0 cruft that we can remove.
mDefaultChild is unused, and ExplicitChildIterator is just basically a
loop over GetFirstChild() / GetNextSibling() so remove it..
Differential Revision: https://phabricator.services.mozilla.com/D147870
Add a dom/base/rust crate called just "dom" where we can share these.
Most of the changes are automatic:
s/mozilla::EventStates/mozilla::dom::ElementState/
s/EventStates/ElementState/
s/NS_EVENT_STATE_/ElementState::/
s/NS_DOCUMENT_STATE_/DocumentState::/
And so on. This requires a new cbindgen version to avoid ugly casts for
large shifts.
Differential Revision: https://phabricator.services.mozilla.com/D148537
First, move the cached table cleanup code out of LocalAccessible::UnbindFromParent and into Shutdown.
This makes no practical difference - it gets called either way when the document shuts down - but it's a bit clearer what's happening this way.
Second, add an assertion to CachedTableAccessible::GetFrom to ensure it is only ever given a table.
I don't think it would ever be given anything else, but this makes that clearer.
Differential Revision: https://phabricator.services.mozilla.com/D148089
We're seeing crashes in the wild where we're trying to allocate a very large number of array elements.
This suggests that the column index is underflowing.
The only way I can think of that this could happen is if colspan is 0 on the first cell, in which case we'd do 0 + 0 - 1 and underflow.
That shouldn't be possible - layout shouldn't ever give us a row/colspanof 0 - but perhaps it's happening anyway.
If this happens, we'll now gracefully treat it as a span of 1.
I also added an assertion in case this helps us to track this down properly in future.
Differential Revision: https://phabricator.services.mozilla.com/D148087
When a DocAccessibleParent is destroyed, we don't call Shutdown on its RemoteAccessibles to avoid pointless cleanup overhead.
Previously, this meant we weren't cleaning up associated CachedTableAccessibles.
We now explicitly clean these up in DocAccessibleParent::Destroy.
Differential Revision: https://phabricator.services.mozilla.com/D148086
We already handled this for visible aria-labelledby/describedby subtrees based on a11y events.
However, when a subtree is hidden (whether via CSS or aria-hidden), it is completely removed from the a11y tree, so we can't use a11y events.
Instead, when a node is added to the DOM, we walk its ancestors looking for an aria-labelledby/describedby target.
We stop if the node or an ancestor has an Accessible, since that means it will be handled elsewhere.
This also limits the number of ancestors we walk for each inserted node, thus decreasing the performance impact of this change.
This doesn't catch all possible mutations in a hidden subtree (e.g. removals or direct text node changes), but this at least fixes a case in Gmail.
Given performance risks, I think it makes sense to address specific cases as they arise.
Differential Revision: https://phabricator.services.mozilla.com/D147559
Remove assert for doc to be last accessible to be removed because
in a doc shutdown scenario it will be the first to be removed.
Differential Revision: https://phabricator.services.mozilla.com/D148045
We implement setting of the caret using HyperText rather than TextLeafPoint because caret stuff, including events, still uses HyperText internally for now.
This moves the async IPDL method already used on non-Windows into the base classes so Windows can use it.
We keep the COM implementation for Windows RemoteAccessible without the cache.
SetCaretOffset was moved into HyperTextAccessibleBase and platform methods were updated accordingly.
Finally, I did some drive-by cleanup (no user impact) and changed GetCaretOffset in ATK and XPCOM to use HyperTextAccessibleBase.
GetCaretOffset was moved to the base some time ago, but ATK and XPCOM weren't updated at the time.
Differential Revision: https://phabricator.services.mozilla.com/D147852
Layout sends a11y text update notifications during reflow even if the text hasn't changed.
TextUpdater already detects this case, so just move our cache update calls to TextUpdater.
Differential Revision: https://phabricator.services.mozilla.com/D147656
I originally thought we didn't need to be explicitly notified about removals because a correction always triggers a text change and we push a cache update for spelling errors whenever the text changes.
However, it seems that even when a correction is made and the text changes, the spell check ranges aren't yet up to date.
Previously, we were pushing a cache update whenever text was reflowed, which was taking care of this.
Soon, we don't want to push text cache updates if the text doesn't actually change.
We remove the reliance on these redundant text updates by having an explicit notification for spell check removals.
Differential Revision: https://phabricator.services.mozilla.com/D147655
The BrowsingContext already has this information, so we use that instead of redundantly caching it in RemoteAccessible.
This implementation works even when the a11y cache is disabled, so stop using the sync IPDL URL method.
We can't entirely unify the URL method because we don't have a base class for local/remote documents.
However, a method was added in nsAccUtils to unify this as much as possible.
Differential Revision: https://phabricator.services.mozilla.com/D147717
Previously, even for remote in-process iframes, it was only possible to retrieve the top level BrowsingContext for the remote process by getting the managing BrowserParent.
This makes it possible to get the correct BrowsingContext even for in-process iframes.
Differential Revision: https://phabricator.services.mozilla.com/D147716
None of the consumer need to mutate styles, and this saves some ugly
const_casting on the next patch.
Doesn't change behavior.
Differential Revision: https://phabricator.services.mozilla.com/D147555
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
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
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
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
We detect this in the same way that we detect whether we need to push line starts; i.e. a text update or a bounds change.
Since this is tied to the Text and Bounds domains, I removed the separate TextBounds domain.
Differential Revision: https://phabricator.services.mozilla.com/D147396
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
There can be LocalAccessibles which don't die until the final cycle collection during XPCOM shutdown.
MsaaIdGenerator::ReleaseID (called during deletion of a LocalAccessible) uses a timer when the cache is enabled, but timers can't be used after XPCOM shutdown.
This was causing an assertion.
In addition, because MsaaIdGenerator is a static instance, the timer could be deleted after XPCOM shutdown, causing a warning.
To fix this:
1. If accessibility is shut down, just release ids immediately.
2. Clean up any remaining ids and the timer on XPCOM shutdown.
A better solution would be to create and terminate MsaaIdGenerator during a11y startup and shutdown, but this is a bit tricky while we still have the non-cache code paths.
Once we don't need the non-cache code, MsaaIdGenerator will become a lot simpler, so this refactor will be easier then.
Differential Revision: https://phabricator.services.mozilla.com/D146866
This change allows us to remove the `FullZoom` multiplier and fixes text
bounds caclulations in a zoomed page.
Testing: The current browser scroll/bounds tests pass (with the
exception of fission iframes which were already broken).
Differential Revision: https://phabricator.services.mozilla.com/D146507
This patch won't actually build, because a few bits of code are used
for both nsIFactory::createInstance and static components, and static
components are not fixed until the next patch.
The first place is nsLoadGroupConstructor, which uses an nsIFactory
macro to create a static component constructor. (This could be worked
around by expanding the macro to the state before this patch.)
The other issue is that nsAppShellConstructor is used in an nsIFactory
on OSX, but as a static component on all other platforms. This could
be worked around by wrapping nsAppShellConstructor in an adaptor that
passes in the extra null argument to nsAppShellConstructor.
Differential Revision: https://phabricator.services.mozilla.com/D146456
This was causing a performance regression.
We now only do this for text leaf and image Accessibles, which gets us back to where we were before bug 1395181.
This means we can't support "click ancestor" on ATK.
There weren't requests for this on ATK anyway.
In future, we can probably support this using the information in the cache.
Differential Revision: https://phabricator.services.mozilla.com/D146528
This interface should no longer be required due to the changes in part 1
limiting the complexity of IPCStream instances and limiting the number of file
descriptors which a single stream can attach to a message.
Removing this interface is necessary to serialize nsIInputStream instances over
arbitrary toplevel protocols and non-protocol IPC in the future.
Differential Revision: https://phabricator.services.mozilla.com/D141039
We can't use the StringBundle object off the main thread. We need to
pre-load all the strings we may use. This is a small set of roles. We
also need formatted heading levels, so we preload heading level 1 to 6.
Differential Revision: https://phabricator.services.mozilla.com/D146112
We rely on Recv events to be called from child processes and not from
other Recv events. If this happens we risk reentry in regards to the
android monitor lock. So this patch introduces FireEvent for internal
use where secondary events need to be fired like a reorder when a new
sub-document is added.
Differential Revision: https://phabricator.services.mozilla.com/D146134
In Android we need to keep the remote accessible methods thread safe. That means no direct references to local accessibles, or anything DOM or layout.
We have the advantage of always being remote except for a 0 offset browser element, and no support for full page zoom.
Also removed the visual/layout viewport offset in the bounds method since
the top level doc will always have its visual and layout viewport match.
Differential Revision: https://phabricator.services.mozilla.com/D146006
Previously, we invalidated this cache when the reorder event arrived.
Because the mutation and the reorder event happen in separate IPDL calls, it's possible for a client call to arrive between them.
If that client call queried HyperText offsets, this could result in returning incorrect information to the client or even a parent process crash.
Now, we invalidate the cache during the mutation, so there's no possibility of an intervening client call.
It made sense to put this invalidation call in RemoteAccessibleBase, so I also moved the call to invalidate for text leaf updates into RemoteAccessibleBase so that they're both in the same class.
Differential Revision: https://phabricator.services.mozilla.com/D145845
This interface should no longer be required due to the changes in part 1
limiting the complexity of IPCStream instances and limiting the number of file
descriptors which a single stream can attach to a message.
Removing this interface is necessary to serialize nsIInputStream instances over
arbitrary toplevel protocols and non-protocol IPC in the future.
Differential Revision: https://phabricator.services.mozilla.com/D141039
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
It's critical that we fire mutation events first because our RemoteAccessible tree is created thus and we can't fire events on RemoteAccessibles we haven't created yet.
Beyond that, though, focus events are of primary importance.
See the comments in EventQueue::ProcessEventQueue for the reasons.
Differential Revision: https://phabricator.services.mozilla.com/D145319
This interface should no longer be required due to the changes in part 1
limiting the complexity of IPCStream instances and limiting the number of file
descriptors which a single stream can attach to a message.
Removing this interface is necessary to serialize nsIInputStream instances over
arbitrary toplevel protocols and non-protocol IPC in the future.
Differential Revision: https://phabricator.services.mozilla.com/D141039
We already had a similar cache in local HyperTextAccessible.
This improves performance significantly when walking the text attributes of a container with a large number of text leaf children, such as is encountered when using view source.
This patch unifies that cache across local and remote.
For simplicity, the cache invalidation strategy is more naive/aggressive.
Differential Revision: https://phabricator.services.mozilla.com/D145079
We already had a similar cache in local HyperTextAccessible.
This improves performance significantly when walking the text attributes of a container with a large number of text leaf children, such as is encountered when using view source.
This patch unifies that cache across local and remote.
For simplicity, the cache invalidation strategy is more naive/aggressive.
Differential Revision: https://phabricator.services.mozilla.com/D145079
It's critical that we fire mutation events first because our RemoteAccessible tree is created thus and we can't fire events on RemoteAccessibles we haven't created yet.
Beyond that, though, focus events are of primary importance.
See the comments in EventQueue::ProcessEventQueue for the reasons.
Differential Revision: https://phabricator.services.mozilla.com/D145319
We cannot use GeckoBundle anymore because it cannot be constructed in
the UI thread. Instead, have a set of populate methods that take
arguments and set the correct fields in the AccessibilityNodeInfo, or
its optional info objects.
These fields can be called both in the Gecko and UI thread.
Differential Revision: https://phabricator.services.mozilla.com/D144895
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
This interface should no longer be required due to the changes in part 1
limiting the complexity of IPCStream instances and limiting the number of file
descriptors which a single stream can attach to a message.
Removing this interface is necessary to serialize nsIInputStream instances over
arbitrary toplevel protocols and non-protocol IPC in the future.
Differential Revision: https://phabricator.services.mozilla.com/D141039
Unfortunately, while with MSVC one would use the `I` modifier to format
LPARAM/LONG_PTR, it doesn't work with clang-cl on 32-bits, because
LONG_PTR there is long, but `I` expects an int.
Differential Revision: https://phabricator.services.mozilla.com/D144916
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
We already have a similar cache in local HyperTextAccessible.
Unfortunately, we can't use common code here because we don't want to waste memory having a member variable on all RemoteAccessibles, but local HyperTextAccessibles don't have mCachedFields.
This improves performance significantly when walking the text attributes of a container with a large number of text leaf children, such as is encountered when using view source.
Differential Revision: https://phabricator.services.mozilla.com/D145079
In bug 1739560, I moved the processing of queued cache updates before the firing of mutation events.
That means that Accessibles removed from the tree might not be shut down (and thus defunct) yet, since we have this limbo "not in document" state.
Therefore, as well as skipping defunct Accessibles, we must also skip Accessibles that are no longer in the document.
Differential Revision: https://phabricator.services.mozilla.com/D145176
This distinction between void and empty exists in LocalAccessible, so we should be consistent in RemoteAccessible.
This fixes exposure of explicit-name when the name is empty.
To facilitate this, we no longer assume the name flag is not in the cache just because the name string isn't in the cache, since it could be eNoNameOnPurpose.
Differential Revision: https://phabricator.services.mozilla.com/D145179
This interface should no longer be required due to the changes in part 1
limiting the complexity of IPCStream instances and limiting the number of file
descriptors which a single stream can attach to a message.
Removing this interface is necessary to serialize nsIInputStream instances over
arbitrary toplevel protocols and non-protocol IPC in the future.
Differential Revision: https://phabricator.services.mozilla.com/D141039
If text or bounds change, it's very likely that line starts have changed too, so we push an update for them.
However, if a non-rectangular text span changes its line wrapping without changing its text, the bounds might not change.
In that case, we still get a bounds cache update request; we just determine not to push bounds.
This happens a lot, though.
To limit this, we compare against the cached first line start in LocalAccessible and push an update only if it's different.
If text and bounds both change, we don't want to push two separate cache updates.
We use queued cache updates to prevent this.
This necessitated moving where we send queued cache updates so that we do it before firing mutation events, since clients might need the text to be up to date when handling those events.
Differential Revision: https://phabricator.services.mozilla.com/D144949
dom/network/TCPSocket.cpp(973,38): error: comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'nsISocketTransport::(unnamed enum at obj-aarch64-pc-mingw32/dist/include/nsISocketTransport.h:102:3)' [-Werror,-Wsign-compare]
if (static_cast<uint32_t>(aStatus) !=
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
dom/security/ReferrerInfo.cpp(216,26): error: comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'nsIWebProgressListener::(unnamed enum at obj-aarch64-pc-mingw32/dist/include/nsIWebProgressListener.h:41:3)' [-Werror,-Wsign-compare]
rejectedReason !=
~~~~~~~~~~~~~~ ^
toolkit/components/antitracking/StorageAccess.cpp(175,23): error: comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'nsIWebProgressListener::(unnamed enum at obj-aarch64-pc-mingw32/dist/include/nsIWebProgressListener.h:41:3)' [-Werror,-Wsign-compare]
if (aRejectedReason ==
~~~~~~~~~~~~~~~ ^
toolkit/components/antitracking/StorageAccess.cpp(415,26): error: comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'nsIWebProgressListener::(unnamed enum at obj-aarch64-pc-mingw32/dist/include/nsIWebProgressListener.h:41:3)' [-Werror,-Wsign-compare]
aRejectedReason ==
~~~~~~~~~~~~~~~ ^
toolkit/components/antitracking/StorageAccess.cpp(428,26): error: comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'nsIWebProgressListener::(unnamed enum at obj-aarch64-pc-mingw32/dist/include/nsIWebProgressListener.h:41:3)' [-Werror,-Wsign-compare]
return aRejectedReason ==
~~~~~~~~~~~~~~~ ^
Differential Revision: https://phabricator.services.mozilla.com/D144693
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
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
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
This creates a clearer distinction between local pivots and remote
pivots. The former happens in the parent process and the latter happens
in the remote content process.
Differential Revision: https://phabricator.services.mozilla.com/D144482
Since remote accessibles won't share AccessibleWrap as a base class
anymore this can't be an instance method. Move it to
SessionAccessibility, the sole consumer.
Note: ToBundle will hopefully get removed entirely once CTW is fully adopted.
Differential Revision: https://phabricator.services.mozilla.com/D144480
This creates a clearer distinction between local pivots and remote
pivots. The former happens in the parent process and the latter happens
in the remote content process.
Differential Revision: https://phabricator.services.mozilla.com/D144482
Since remote accessibles won't share AccessibleWrap as a base class
anymore this can't be an instance method. Move it to
SessionAccessibility, the sole consumer.
Note: ToBundle will hopefully get removed entirely once CTW is fully adopted.
Differential Revision: https://phabricator.services.mozilla.com/D144480
This means that cached bounds stay the same regardless of scroll offset.
The scroll position gets subtracted later when calculating absolute bounds.
Differential Revision: https://phabricator.services.mozilla.com/D144392
We use two constraints to ensure the bounds fall within 5 px of the expected values in either direction.
However, the function was using || , so only one constraint was being enforced.
In practice, this meant that we wouldn't fail for any value.
Change this to && to enforce both constraints.
Differential Revision: https://phabricator.services.mozilla.com/D144391
The frame might not be transformed yet when MaybeQueueCacheUpdateForStyleChanges is called.
In that case, frame->IsTransformed() will return false.
However, newStyle->StyleDisplay()->HasTransform(frame) returns true, so we can use that.
Differential Revision: https://phabricator.services.mozilla.com/D144429
In addition, don't send DeleteEntry for Transform for an initial cache update, since there's nothing to delete.
These fixes don't change the behaviour for users, but optimise both cache storage and IPC trafic.
Differential Revision: https://phabricator.services.mozilla.com/D144421
Normally, we treat the body as the DOM node for a DocAccessible.
However, a click listener can be added to the root element; e.g. the html element.
We now treat a click listener added to the root element the same as if one were added to the body.
This required a change to nsAccessibilityService to use the DocAccessible when click listeners change for the root element so a cache update is pushed.
This change was made for the body also, since we weren't pushing a cache update for click listener changes on the body either.
Differential Revision: https://phabricator.services.mozilla.com/D144278
Previously, we supported an action on text leaf and image accessibles if an ancestor was a link or was clickable.
However, we didn't support it on any other kind of descendant, nor could clients differentiate between a click handler on the descendant itself vs an action propagated because of an ancestor.
In addition, the click was performed on the ancestor element itself, rather than bubbling up to the ancestor.
This was probably never a real problem given the limited scope, but it meant that the actual event target was lost.
This has been replaced by a "click ancestor" action supported on all descendants of ancestors providing an action.
The click is dispatched to the descendant and bubbles up to the ancestor.
Aside from consistency and the ability to differentiate the action, this allows clients to stop relying on simulating clicks themselves to directly target a descendant.
This avoids problems caused by obscured web elements, obscured browser windows and other weird screen coordinate issues.
It thus fixes several problems reported by NVDA screen reader users.
Differential Revision: https://phabricator.services.mozilla.com/D144252
Previously, we used the obs_documentCreated observer message fired by editor.
However, this is fired when an editor is created anywhere in the document, even if it's for a descendant.
This meant that we were firing an editable state change on the document when a descendant became contentEditable.
In turn, this resulted in the document always having the editable state in the cache if there was a contentEditable descendant.
This message also isn't fired if an editor already exists (e.g. for a contentEditable descendant) and designMode is turned on for the document.
This meant that we wouldn't fire an event in that case, resulting in an incorrect cache.
There is no usable equivalent to detect when designMode is turned off.
While there is obs_documentWillBeDestroyed, that doesn't ever seem to get fired.
This meant that we didn't fire a state change when designMode was turned off, also resulting in an incorrect cache.
To fix all of these issues, we now watch for NS_EVENT_STATE_READWRITE changes on the root element of the document.
Because we use the root element (not the body), this should avoid duplicate state changes for contentEditable changes on the body, which get handled by LocalAccessible::DOMAttributeChanged.
Finally, we previously fired only an editable state change, but changing the editable state of a document also impacts the read-only state.
This too resulted in an incorrect cache.
We now fire a read-only state change as well.
Differential Revision: https://phabricator.services.mozilla.com/D143969
Aside from adding ScrollTo to the Windows PDocAccessible IPDL, This mostly just moves methods into base classes and adapts platform code to use the unified Accessible::ScrollTo.
Differential Revision: https://phabricator.services.mozilla.com/D143655
There's no point cropping ranges when called on the document, but we still want to remove collapsed ranges.
The path to hell is paved with premature optimisation. :(
Differential Revision: https://phabricator.services.mozilla.com/D143579
This enables AccGroupInfo::TotalItemCount to work for CachedTableAccessibles.
This still doesn't yet support aria-row/colcount for cached RemoteAccessibles.
Differential Revision: https://phabricator.services.mozilla.com/D141818
We can use the base classes for both local and cached remote Accessibles.
However, non-cached RemoteAccessibles need to be handled separately still because we can't implement the table interfaces for those.
Differential Revision: https://phabricator.services.mozilla.com/D141219
We can use the base classes for both local and cached remote Accessibles.
However, non-cached RemoteAccessibles need to be handled separately still because we can't implement the table interfaces for those.
Differential Revision: https://phabricator.services.mozilla.com/D141218
This doesn't work for non-cached RemoteAccessibles, but this wasn't previously implemented anyway.
With this patch (and all earlier patches in the stack) applied, all the tests in accessible/tests/mochitest pass with the cache enabled, thus testing CachedTableAccessible.
Differential Revision: https://phabricator.services.mozilla.com/D141216
This just redirects to the local TableAccessible methods.
This allows us to test selection in our mochitests.
As far as I know, real clients don't actually use these methods , so they haven't been implemented for cached RemoteAccessibles yet.
Differential Revision: https://phabricator.services.mozilla.com/D141215
This allows us to test CachedTableAccessible against our mochitest suite.
We'll eventually want to switch LocalAccessible to use this anyway, as it provides advantages beyond support for cached RemoteAccessibles.
This also ensures the experience is consistent between local and remote.
Differential Revision: https://phabricator.services.mozilla.com/D141214
Headers are associated using the headers DOM attribute, which is a list of DOM node ids.
For the cache, we send and store these as Accessible ids.
Differential Revision: https://phabricator.services.mozilla.com/D141212
We need to be able to iterate through explicitly associated headers for both local and remote Accessibles.
AccIterable will serve nicely as a base class, but it needs to support the Accessible base class to do that.
Differential Revision: https://phabricator.services.mozilla.com/D141210
This gets/creates the CachedTableAccessible when AsTableBase/AsTableCellBase is called.
It also invalidates the table cache when mutations occur.
Differential Revision: https://phabricator.services.mozilla.com/D141208
This is a completely new table implementation which can work with the cache.
We lazily create a cache data structure only when table information is requested by a client, looping through the entire table and calculating all the information we need (counts, coordinates, implicit headers, etc.).
Whenever the cache is invalidated due to a mutation of the table structure, we throw away the entire cache, rebuilding it next time the client requests information.
Differential Revision: https://phabricator.services.mozilla.com/D141206