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
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
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
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
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
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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