Commit Graph
111 Commits
Author SHA1 Message Date
James Teh ec58d075ba Bug 2042240 part 1: Tighten accessibility checks for print documents. r=eeejay
Previously, we used the IsPrinting flag on the BrowsingContext in some cases to check whether a document was a print document.
While IsPrinting will always be true on a print document, it might also be true for the original document (as opposed to the static clone) while it is being printed.
This caused us to use the PDF cache domains in some cases when we shouldn't and might have caused other problems down the line.
To fix this, check whether the document is a static clone instead.
Accessibility should only ever see a static clone if it's a print document, but we assert IsPrinting to be sure.

Differential Revision: https://phabricator.services.mozilla.com/D303299
2026-06-01 00:38:26 +00:00
James Teh 6c156cccb6 Bug 2021820 part 10: Remove the ePdfOutput accessibility consumer when the last print doc is gone. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D299962
2026-05-21 01:59:35 +00:00
James Teh 18da8376c7 Bug 2021820 part 9: Make DocManager::NotifyOfPrintDocument bootstrap the a11y service. r=eeejay,layout-reviewers,emilio
Previously, tagged PDF generation required that something else had already created the accessibility service.
If the accessibility service wasn't running, we simply didn't create a tagged PDF.
Now that the accessibility service can be created in a stripped-down mode for PDF output, make DocManager::NotifyOfPrintDocument into a static method which creates the accessibility service appropriately.

Differential Revision: https://phabricator.services.mozilla.com/D299961
2026-05-21 01:59:32 +00:00
James Teh 9c8258974f Bug 2021820 part 5: Don't create DocAccessibles for any document except a printing document when the service is only being used for PDF output. r=eeejay
This includes RootAccessibles, so we must also allow printing documents to have no parent even though they aren't RootAccessibles.

Differential Revision: https://phabricator.services.mozilla.com/D299957
2026-05-21 01:59:21 +00:00
Daniel Holbert b4e4f5d2f5 Bug 2038733: Use MakeRefPtr to do allocation for local RefPtr variables, in accessible/. r=accessibility-platform-reviewers,Jamie
Differential Revision: https://phabricator.services.mozilla.com/D299763
2026-05-12 07:20:02 +00:00
James Teh 5f370ab11b Bug 2029753: When generating a tagged PDF, ensure we only request the DocAccessible once for each OOP iframe. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D296277
2026-04-28 00:19:23 +00:00
Ryan VanderMeulen d63c510f15 Bug 1979253 - Skip DocAccessible for the transient about:blank in printing BCs. r=accessibility-platform-reviewers,eeejay,dom-core,Jamie,jjaschke
BrowsingContext::CreateDetached receives isForPrinting=true for print
preview BCs but never sets the IsPrinting synced field. The
SetIsPrinting(true) call in nsGlobalWindowOuter::Print() happens after
OpenInternal() returns, by which time the transient about:blank has
already triggered DocAccessible creation and
SendPDocAccessibleConstructor to the parent process, causing a kNoID
collision in SessionAccessibility::RegisterAccessible on Android.

Fix by setting IsPrinting during CreateDetached when isForPrinting is
true, and adding an early return in CreateDocOrRootAccessible for the
uncommitted initial about:blank in a printing BrowsingContext.

Differential Revision: https://phabricator.services.mozilla.com/D294444
2026-04-21 17:04:45 +00:00
James Teh 34025870b2 Bug 1657973 part 3: Accessibility engine changes required for PdfStructTreeBuilder. r=eeejay
1. Allow DocAccessibles to be created for static documents when explicitly requested, since print documents are static clones.
2. Changes in a couple places to support static documents correctly.
3. To generate a tagged PDF, we need the accessibility tree to be built for the document and any iframes, and we need to initialize PdfStructTreeBuilder. Add DocManager::NotifyOfPrintDocument to trigger this.
4. PDF generation happens in the parent process, so if the document is remote, we send the content via IPDl and use the RemoteAccessible tree. Add a PDocAccessible message to notify the parent process that this document is being printed.
5. We need to request the accessibility trees for OOP iframes as well. Add a PBrowser message to facilitate this.

Differential Revision: https://phabricator.services.mozilla.com/D285959
2026-03-20 07:00:38 +00:00
Atila Butkovits 18fc13f54e Revert "Bug 1657973 part 6: Add tests for tagged PDF generation. r=eeejay" for causing bustages in SkPDF.
This reverts commit 864e3ed1ca.

Revert "Bug 1657973 part 5: Hook up PdfStructTreeBuilder to the layout and gfx code. r=emilio,lsalzman,layout-reviewers"

This reverts commit 50abf9d6c3.

Revert "Bug 1657973 part 4: Hook up PdfStructTreeBuilder to the printing and PDF code. r=layout-reviewers,dshin"

This reverts commit f600fda75a.

Revert "Bug 1657973 part 3: Accessibility engine changes required for PdfStructTreeBuilder. r=eeejay"

This reverts commit 5a036cc26e.

Revert "Bug 1657973 part 2: Add PdfStructTreeBuilder. r=eeejay"

This reverts commit 8d98b7bed1.

Revert "Bug 1657973 part 1: Plumb BrowsingContext id to PrintTargetSkPDF::BeginPrinting and make it available to nsDeviceContext::End/AbortDocument. r=emilio,geckoview-reviewers,win-reviewers,layout-reviewers,gstoll,m_kato"

This reverts commit cc79f1945a.
2026-03-19 05:08:17 +00:00
James Teh 5a036cc26e Bug 1657973 part 3: Accessibility engine changes required for PdfStructTreeBuilder. r=eeejay
1. Allow DocAccessibles to be created for static documents when explicitly requested, since print documents are static clones.
2. Changes in a couple places to support static documents correctly.
3. To generate a tagged PDF, we need the accessibility tree to be built for the document and any iframes, and we need to initialize PdfStructTreeBuilder. Add DocManager::NotifyOfPrintDocument to trigger this.
4. PDF generation happens in the parent process, so if the document is remote, we send the content via IPDl and use the RemoteAccessible tree. Add a PDocAccessible message to notify the parent process that this document is being printed.
5. We need to request the accessibility trees for OOP iframes as well. Add a PBrowser message to facilitate this.

Differential Revision: https://phabricator.services.mozilla.com/D285959
2026-03-19 04:09:16 +00:00
Sylvestre Ledru eafe8b152d Bug 2023419 - Remove Emacs/Vim modelines from accessible/ r=emilio
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287834
2026-03-18 10:29:47 +00:00
Serban Stanca 5a709d4a9a Revert "Bug 2023419 - Remove Emacs/Vim modelines from accessible/ r=emilio" for causing mochitests failures in browser_action.js.
This reverts commit 2fa4815c8d.
2026-03-17 15:34:26 +00:00
Sylvestre Ledru 2fa4815c8d Bug 2023419 - Remove Emacs/Vim modelines from accessible/ r=emilio
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287834
2026-03-17 09:21:51 +00:00
Eitan Isaacson e175a9d464 Bug 2016312 - Don't construct docs for children of remote XUL elements. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D283374
2026-03-05 04:40:49 +00:00
Emilio Cobos Álvarez b7e0462f57 Bug 1994964 - Make accessible ignoring of hidden widgets work on not-yet-initialized pres shells. 2025-10-17 16:06:29 +00:00
James Teh a40b16b3b2 Bug 1700546: Fire a reorder event when a top level remote document is added. r=morgan
When a local document is added, we fire a reorder event in DocAccessible::DoInitialUpdate.
This doesn't work for top level documents in remote content processes because the embedder (OuterDocAccessible) is in a different process.
We already handled this for out-of-process iframe documents in DocAccessibleChild::AddChildDoc.
However, there was no code to do this for a top level remote document.
This wasn't a problem for users for normal browser tabs, since clients only interact with the document when it gets focus.
It was problematic for <browser> elements embedded in a parent process content document, since some clients need the event in order to pick up the embedded content.
Therefore, we now fire this event in DocManager::RemoteDocAdded.

This patch re-enables browser_test_docload.js, which is intended to test this.
This test was ported in bug 1376857 before we shipped e10s.
It didn't work with e10s at the time, so it was disabled there, but this was never fixed.
That meant that once e10s shipped, this test was disabled completely.

I had to change the test's expectations slightly, since we do fire document load complete and state change events for remote iframe documents, but the test asserted that we don't.
Although we originally didn't fire these events many years ago, this has been broken for a long time now and it doesn't really make sense to reinstate that behaviour; see bug 1700362.

Differential Revision: https://phabricator.services.mozilla.com/D244687
2025-04-10 00:53:14 +00:00
James Teh e6e199ac31 Bug 1888298: If shutdown of the accessibility service is triggered by a document shutting down, shut down the service asynchronously. r=nlapre
When DocAccessibles shut down, they shut down their child documents.
However, shutting down a document can result in shutting down the accessibility service if XPCOM is the only consumer and there are no more cached XPCOM documents.
If this is triggered by a child document, the service will shut down while the parent document is still shutting down, resulting in reentry and a crash.
In bug 1690456, code was added to prevent shutting down the service for a document with a parent.
However, this doesn't address "hanging child documents"; i.e. documents which currently have no parent because their OuterDocAccessible is being destroyed/recreated.

Rather than trying to avoid this specific case and given that we've hit reentry problems here twice before now (bug 1330765 and bug 1690456), I've taken a completely different approach.
Whenever shutdown of the service is triggered by a document shutdown, we now shut down the service asynchronously by dispatching a runnable.
This ensures that the service can't be shut down while shutting down a document.
We do this for both local and remote documents, since although we've never seen this for remote documents, I think this is safer.

In addition:

1. DocAccessible::Shutdown now has a diagnostic assert to hopefully detect such reentry should it occur again in future, making it much easier to debug.
2. Functions related to this have been refactored slightly for readability and consistency.

Differential Revision: https://phabricator.services.mozilla.com/D238143
2025-02-19 03:23:42 +00:00
James Teh db0a8fce0d Bug 1888649: Tweak the assertion when we can't get the parent DocAccessible in CreateDocOrRootAccessible to allow background extension pages. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D207497
2024-04-17 22:53:27 +00:00
Nathan LaPre 22e4c96a2b 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
Emilio Cobos Álvarez e3921efc1e Bug 1811834 - Clean up nsWidgetInitData. r=cmartin,geckoview-reviewers,calu
Move it to the mozilla::widget namespace.

Use enum classes for transparency, popup type, popup level, etc.

Mostly automated with sed, but there were a few manual changes required
as well in windows code because they relied on Atomic<TransparencyMode>
working (which now doesn't because TransparencyMode is 1 byte instead of
4 bytes).

Differential Revision: https://phabricator.services.mozilla.com/D167537
2023-01-23 23:58:41 +00:00
James Teh 75f1e43275 Bug 1757257: Don't assert for a null frame in TextAttrsMgr::GetAttributes. r=morgan
There are several valid reasons for a HyperTextAccessible to have no frame.
As well as removing the assertion, document the (known) cases where GetFrame() might return null.
Also, document why we create a DocAccessible and call DoInitialUpdate despite a null root frame on its PresShell.

Differential Revision: https://phabricator.services.mozilla.com/D139908
2022-03-01 21:16:43 +00:00
Olli Pettay 5bd897c216 Bug 1730541, remove nsCoreUtils::IsContentDocument, r=nika
Differential Revision: https://phabricator.services.mozilla.com/D125462
2021-09-13 21:01:23 +00:00
Emilio Cobos Álvarez 3e3101a57b Bug 1703289 - Make mixed content blocker use a session-persistent permission rather than ad-hoc code. r=ckerschb,smaug
This is more fission-compatible, and a lot simpler.

Differential Revision: https://phabricator.services.mozilla.com/D111480
2021-04-12 18:04:12 +00:00
Simon Giesecke 9e995a79e8 Bug 1184468 - Use nsBaseHashtable::Values. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D108587
2021-03-24 17:56:49 +00:00
Eitan Isaacson bf186aced9 Bug 1700166 - Clean up obsolete remote iface enum and add iface test. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D109384
2021-03-22 20:39:54 +00:00
Simon Giesecke 9a99ab6d93 Bug 1695162 - Migrate from custom hashtable iteration to range-based for in accessible, dom/animation, dom/base, dom/localstorage, gfx/thebes. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D106895
2021-03-12 16:14:58 +00:00
Alexandru Michis bd8c44a2c8 Backed out changeset fd03162e726d (bug 1695162) for causing bustages in Document.cpp
CLOSED TREE
2021-03-12 17:10:02 +02:00
Simon Giesecke d9738bc253 Bug 1695162 - Migrate from custom hashtable iteration to range-based for in accessible, dom/animation, dom/base, dom/localstorage, gfx/thebes. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D106895
2021-03-12 14:54:08 +00:00
Simon Giesecke 12162c0fba Bug 1634281 - Use nsBaseHashtable::GetOrInsertNew where possible. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D106491
2021-03-03 08:58:52 +00:00
Eitan Isaacson caa90c0bd0 Bug 1694203 - P9: Have RemoteAccessible inherit from Accessible. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D104915
2021-03-02 16:32:24 +00:00
Simon Giesecke f8c168cdd0 Bug 1693541 - Improve uses of nsBaseHashtable and descendants and avoid multiple subsequent lookups in accessible. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D106093
2021-03-01 09:59:30 +00:00
Simon Giesecke 95c38cc6b8 Bug 1691913 - Rename nsBaseHashtable::Put to InsertOrUpdate. r=xpcom-reviewers,necko-reviewers,jgilbert,dragana,nika
This makes the naming more consistent with other functions called
Insert and/or Update. Also, it removes the ambiguity whether
Put expects that an entry already exists or not, in particular because
it differed from nsTHashtable::PutEntry in that regard.

Differential Revision: https://phabricator.services.mozilla.com/D105473
2021-02-26 09:11:46 +00:00
Eitan Isaacson c1ef28b8c2 Bug 1693597 - P1: Rename Accessible to LocalAccessible. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D105670
2021-02-19 23:14:32 +00:00
Eitan Isaacson dd2f95aa73 Bug 1693607 - [Linux] Add braces around statements. r=morgan
This is a collaboration between clang-tidy and clang-format.

clang-tidy uses compiled code paths, so this patch is linux specific.

Differential Revision: https://phabricator.services.mozilla.com/D105669
2021-02-19 23:14:32 +00:00
James Teh 1fc63b00a7 Bug 1646486: Move dom::Document::IsVisibleConsideringAncestors to a11y::nsCoreUtils::IsDocumentVisibleConsideringInProcessAncestors. r=emilio
Renaming the function makes it clear that it only deals with in-process ancestors, which is an important distinction for Fission.
A11y is the only consumer of this and it only cares about in-process ancestors in this case (OOP stuff is handled elsewhere), so the functionality doesn't need to change.
Since a11y is the only consumer, move this into the a11y code.

Differential Revision: https://phabricator.services.mozilla.com/D104341
2021-02-09 00:44:21 +00:00
James Teh 1552add35c Bug 1690456: Don't allow nsAccessibilityService to be shut down while a parent document is still shutting down. r=yzen
DocAccessible::Shutdown calls DocManager::NotifyOfDocumentShutdown, which can shut down nsAccessibilityService if there are no more consumers.
Previously, this could happen even when shutting down child documents.
Since shutting down the service shuts down all documents, this resulted in shutting down the parent document within an outer call to shut down that same document.
Even if that reentry were prevented, the service would have been gone when returning to the outer Shutdown call, which still needs the service to complete its cleanup.

To fix this, DocManager::NotifyOfDocumentShutdown takes an argument specifying whether to allow service shutdown.
This is set to false when shutting down child documents.
The service is thus allowed to shut down when returning to the parent document Shutdown.

In addition, mPresShell is cleared before shutting down child documents to prevent reentry like this.
While this should no longer happen, this should safeguard against similar pain in future.

Differential Revision: https://phabricator.services.mozilla.com/D103966
2021-02-04 01:10:52 +00:00
Simon Giesecke 7ec2cfd4b4 Bug 1676356 - Avoid including PresShell.h from header files. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D96534

Depends on D95184
2020-11-23 16:08:23 +00:00
Simon Giesecke eae3689379 Bug 1673931 - Avoid including Document.h from header files. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D95046

Depends on D95045
2020-11-23 16:07:43 +00:00
Simon Giesecke a69d79b6db Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
James Teh 526fcfb5bc Bug 1630208 part 3: Clean up the remote XPC document accessible cache on shutdown. r=yzen
The cache should already be empty by this point unless there's a bug, but we should still clean up regardless.
Also, the hashtable itself was previously never cleaned up even if it was empty.

Differential Revision: https://phabricator.services.mozilla.com/D79781
2020-06-17 18:42:30 +00:00
James Teh 0b50ea5db4 Bug 1630208 part 1: Assert that we don't add a shut down DocAccessibleParent to the remote XPC cache in DocManager::GetXPCDocument. r=yzen
We really want to know about this because the document will never be removed from the cache, since NotifyOfRemoteDocShutdown (which would normally remove it from the XPC cache) won't get called.

Differential Revision: https://phabricator.services.mozilla.com/D79779
2020-06-17 18:37:58 +00:00
Jonathan Watt 9dfbddb0c2 Bug 1634217. Make accessible/ buildable outside of unified-build environment. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D73176
2020-05-01 04:28:35 +00:00
Simon Giesecke 9e7322117c Bug 1617628 - Hide nsBaseHashtable Put overloads in nsRefPtrHashtable subclass. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D63899
2020-02-25 17:03:36 +00:00
Gabriele Svelto eeb9bfc398 Bug 1600545 - Remove useless inclusions of header files generated from IDL files in accessible/, browser/, caps/, chrome/, devtools/, docshell/, editor/, extensions/, gfx/, hal/, image/, intl/, ipc/, js/, layout/, and media/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.

find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
    interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
    if [ -n "$interfaces" ]; then
        if [[ "$interfaces" == *$'\n'* ]]; then
          regexp="\("
          for i in $interfaces; do regexp="$regexp$i\|"; done
          regexp="${regexp%%\\\|}\)"
        else
          regexp="$interfaces"
        fi
        interface=$(basename "$path")
        rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
            hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
            if [ $hits -eq 0 ]; then
                echo "Removing ${interface} from ${path2}"
                grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
                mv -f "$path2".tmp "$path2"
            fi
        done
    fi
done

Differential Revision: https://phabricator.services.mozilla.com/D55443
2019-12-06 09:16:44 +00:00
Kannan Vijayan c690c1925f Bug 1559414 - Rename unaudited pre-fission methods with SameProcess for future audit burndown. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D39378
2019-07-26 16:48:31 +00:00
Ryan Hunt 7144ca54c8 Bug 1534395 - Rename TabChild to BrowserChild. r=nika
This commit renames TabChild to BrowserChild.

Differential Revision: https://phabricator.services.mozilla.com/D28135
2019-04-09 17:39:01 -05:00
Masayuki Nakano e56c690088 Bug 1540015 - part 3: Rename Document::GetShell() to Document::GetPresShell() and make it return PresShell* rather than nsIPresShell* r=smaug,emilio
This makes `Document::GetShell()` return `PresShell*` instead of `nsIPresShell`.

Additonally, "shell" is unclear ("docshell" vs. "presshell").  Therefore, this
also renames `Document::GetShell()` to `Document::GetPresShell()`.

Similarly, some other method names of `Document` are also renamed from
`*Shell*` to `*PresShell*`.

Differential Revision: https://phabricator.services.mozilla.com/D25338
2019-03-29 15:12:47 +00:00
Dorel Luca 6cd4166b18 Backed out 3 changesets (bug 1540015) for build bustage. CLOSED TREE
Backed out changeset 7b71c9da0214 (bug 1540015)
Backed out changeset 5723ddbc5c44 (bug 1540015)
Backed out changeset 9561d2c36fa5 (bug 1540015)
2019-03-29 16:14:26 +02:00
Masayuki Nakano 12ec0ad7f4 Bug 1540015 - part 3: Rename Document::GetShell() to Document::GetPresShell() and make it return PresShell* rather than nsIPresShell* r=smaug,emilio
This makes `Document::GetShell()` return `PresShell*` instead of `nsIPresShell`.

Additonally, "shell" is unclear ("docshell" vs. "presshell").  Therefore, this
also renames `Document::GetShell()` to `Document::GetPresShell()`.

Similarly, some other method names of `Document` are also renamed from
`*Shell*` to `*PresShell*`.

Differential Revision: https://phabricator.services.mozilla.com/D25338
2019-03-29 13:09:26 +00:00
Kris Maglione 8ccab89886 Bug 1478124: Part 8b - Update DocShell module to use a static component manifest. r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D15040
2018-12-16 17:27:58 -08:00