Files
palemoon27/docshell/base/timeline/ObservedDocShell.cpp
T
roytam1 f468c29a62 import changes from `dev' branch of rmottola/Arctic-Fox:
- hState() in iframe fails when reloading with CTRL+F5, r=bz (2afcd259da)
- Bug 1207137 - Add an error code for weak crypto override. r=bz (27b270707b)
- Bug 1170488 - Add browser_multiple_pushState.js regression test. r=smaug (157672edb9)
- Bug 1206879 - fire onlocationchange from pushState in frames when the URI changes, r=smaug (deb2b21372)
- Bug 1200119 - Add a way to create usable markers from different threads, r=tromey (530f3a5eba)
- fix include (4c9ffeff29)
- Bug 1202657 - Add markers for workers' message passing and serialization/deserialization, r=smaug, jsantell, tromey, ejpbruel (4b911a9422)
- Bug 1160307 - capture async stack frames on Javascript timeline markers. r=fitzgen, r=smaug r=Paolo (04a700e4d1)
- fix linux toolbar icons (ffd49a4dff)
- partial revert or Mac won't package (cbdaa8382d)
- fix most icons on Mac except download (07c700aa76)
- Bug 718637 - Notify that the document is loaded. r=MarcoZ (7b35f20bef)
- Bug 1177640 - [Mac] Do not expose HTML table semantics for "layout" tables. r=surkov (8c898e78a3)
- Bug 1210023 - Fix accessibilityAttributeValue for NSAccessibilityIndexAttribute. r=surkov (6aac88d16f)
- Bug 1178272 - Move table semantics to a separate mozTableAccessible.mm file. r=surkov (0ee62ef8e8)
- cleanup trailing spaces (9f53855fbd)
- bug 1213402 - separate value change events into text value changes and numeric value changes r=davidb (c94cc113ad)
- bug 1213402 - Fire numeric value change events for proxies r=davidb (cb58d2b126)
- Bug 1213382 - proxy more accessible selection methods, r=tbsaunde (68f9f6ef57)
- bug 1170049 - check if document tree is correct before cleaning it upr=lsocks (d92ae58a5c)
- bug 1185550 - Make sure to correctly handle invalid RecvBindChildDoc and PDocAccessibleConstructor messages from the child process r=lsocks (f70e1b0d1a)
- bug 1185726 - avoid killing the child process when it sends the parent events with bad IDs r=lsocks (9447b7c6d7)
- bug 1185726 - follow up to deal with -Wunused warning r=me landing on a CLOSED TREE (3cd4bbb768)
- bug 1188415 - add document tree consistancy checks to more message handlers r=davidb (1bc9c578ee)
- bug 1194853 - pass the correct interfaces to Proxycreated when creating documents r=davidb (f1748d0892)
- bug 1188415 - make CheckDocTree return if the document tree is in a sane state (9a2b452392)
- bug 1221551 - unbind child documents before rebinding them r=davidb (06737cdb16)
- bug 1204070 - add a little more checking to proxy subtree removal r=davidb (24aca334a6)
- bug 1164976 - Make DocAccessibleParent::GetAccessible return itself when appropriate r=davidb (9e88a4fa99)
- bug 1207862 - make it possible to traverse down the tree of proxied documents r=davidb (41a684a249)
- bug 1209147 - make proxying of Accessible::TakeFocus() async r=davidb (96b8ba4f45)
- bug 1186536 - make SerializeTree() use IsOuterDoc() to check if an accessible is an outer doc r=davidb (b661e115f3)
- bug 1162543 - IDs not mapping to accessibles shouldn't cause ipc calls to fail r=davidb (7f9ba71016)
- bug 1170595 - always use IdToAccessible to convert ids to accessibles r=lsocks (c21659779b)
- Bug 1207311 - No need for \!nsAccUtils::MustPrune(acc) in DocAccessibleChild::RecvExtents, r=tbsaunde (69f7ebc23d)
- Bug 1100602 - Kill child if accessibility ID is re-used (r=trevor) (9955223c4e)
- bug 1213606 - assert that we don't destroy a document's proxy until we destroy all of its children r=davidb (f7ab023489)
- bug 1191433 - use ProxyAccessible::AsDoc() in ProxyAccessible::Shutdown() r=lsocks (e6204e7847)
- bug 1210447 - fix ProxyAccessible::EmbeddedChildAt() on proxies of outerDocs r=davidb (d5acdc0507)
- Bug 1212904 P0 Do not abuse fetch response tainting to create opaqueredirect responses. r=ehsan (36f1f393b6)
- Bug 1212904 P3 Make FetchDriver look for the channel Tainting value. r=ehsan (037227c5a8)
- Bug 1212904 P4 Set channel tainting in FetchEvent.respondWith(). r=ehsan (8fcd1f64d6)
- Bug 1212904 P5 Make XHR respect channel tainting. r=ehsan r=sicking (ea03564fde)
- Bug 1204596 - Part 1: Avoid overriding the channel final URI when it gets intercepted; r=nsm,bkelly (da18cfd294)
- Bug 1204596 - Part 2: Update the schema of the DOM Cache database to remove the response_redirected and response_redirected_url columns; r=bkelly (eabaae5330)
- Bug 1204596 - Part 3: Store the responses with manual redirect in the tests added for bug 1164397; r=bkelly (8996f84c1c)
- Bug 1204596 - Part 4: Disable test_fetch_cors.html on b2g; r=bkelly (eb0a61aae1)
- Bug 1212904 P6 Check for CORS response type in fetch mochitests. r=sicking (157b516434)
- Bug 1212904 P7 Verify xhr respects service worker CORS tainting. r=ehsan (e6f347d6d3)
- Bug 1217501 P1 Expose Accept and Accept-Language to service worker FetchEvent.request. r=mcmanus (07722f151e)
- Bug 1217501 P2 Send */* for fetch() default Accept header. r=ehsan (2bc362d107)
- Bug 1130803 - Use non-blocking input for Fetch synthetization pipe, r=bkelly,ehsan (f926b74fed)
2022-11-08 14:20:19 +08:00

161 lines
6.2 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ObservedDocShell.h"
#include "AbstractTimelineMarker.h"
#include "LayerTimelineMarker.h"
#include "MainThreadUtils.h"
#include "mozilla/Move.h"
namespace mozilla {
ObservedDocShell::ObservedDocShell(nsIDocShell* aDocShell)
: MarkersStorage("ObservedDocShellMutex")
, mDocShell(aDocShell)
{
MOZ_ASSERT(NS_IsMainThread());
}
void
ObservedDocShell::AddMarker(UniquePtr<AbstractTimelineMarker>&& aMarker)
{
// Only allow main thread markers to go into this list. No need to lock
// here since `mTimelineMarkers` will only be accessed or modified on the
// main thread only.
MOZ_ASSERT(NS_IsMainThread());
mTimelineMarkers.AppendElement(Move(aMarker));
}
void
ObservedDocShell::AddOTMTMarker(UniquePtr<AbstractTimelineMarker>&& aMarker)
{
// Only allow off the main thread markers to go into this list. Since most
// of our markers come from the main thread, be a little more efficient and
// avoid dealing with multithreading scenarios until all the markers are
// actually cleared or popped in `ClearMarkers` or `PopMarkers`.
MOZ_ASSERT(!NS_IsMainThread());
MutexAutoLock lock(GetLock()); // for `mOffTheMainThreadTimelineMarkers`.
mOffTheMainThreadTimelineMarkers.AppendElement(Move(aMarker));
}
void
ObservedDocShell::ClearMarkers()
{
MutexAutoLock lock(GetLock()); // for `mOffTheMainThreadTimelineMarkers`.
mTimelineMarkers.Clear();
mOffTheMainThreadTimelineMarkers.Clear();
}
void
ObservedDocShell::PopMarkers(JSContext* aCx,
nsTArray<dom::ProfileTimelineMarker>& aStore)
{
MOZ_ASSERT(NS_IsMainThread());
MutexAutoLock lock(GetLock()); // for `mOffTheMainThreadTimelineMarkers`.
// First, move all of our markers into a single array. We'll chose
// the `mTimelineMarkers` store because that's where we expect most of
// our markers to be.
mTimelineMarkers.AppendElements(Move(mOffTheMainThreadTimelineMarkers));
// If we see an unpaired START, we keep it around for the next call
// to ObservedDocShell::PopMarkers. We store the kept START objects here.
nsTArray<UniquePtr<AbstractTimelineMarker>> keptStartMarkers;
for (uint32_t i = 0; i < mTimelineMarkers.Length(); ++i) {
UniquePtr<AbstractTimelineMarker>& startPayload = mTimelineMarkers.ElementAt(i);
// If this is a TIMESTAMP marker, there's no corresponding END,
// as it's a single unit of time, not a duration.
if (startPayload->GetTracingType() == MarkerTracingType::TIMESTAMP) {
dom::ProfileTimelineMarker* marker = aStore.AppendElement();
marker->mName = NS_ConvertUTF8toUTF16(startPayload->GetName());
marker->mStart = startPayload->GetTime();
marker->mEnd = startPayload->GetTime();
marker->mStack = startPayload->GetStack();
startPayload->AddDetails(aCx, *marker);
continue;
}
// Whenever a START marker is found, look for the corresponding END
// and build a {name,start,end} JS object.
if (startPayload->GetTracingType() == MarkerTracingType::START) {
bool hasSeenEnd = false;
// "Paint" markers are different because painting is handled at root
// docshell level. The information that a paint was done is stored at
// sub-docshell level, but we can only be sure that a paint did actually
// happen in if a "Layer" marker was recorded too.
bool startIsPaintType = strcmp(startPayload->GetName(), "Paint") == 0;
bool hasSeenLayerType = false;
// If we are processing a "Paint" marker, we append information from
// all the embedded "Layer" markers to this array.
dom::Sequence<dom::ProfileTimelineLayerRect> layerRectangles;
// DOM events can be nested, so we must take care when searching
// for the matching end. It doesn't hurt to apply this logic to
// all event types.
uint32_t markerDepth = 0;
// The assumption is that the devtools timeline flushes markers frequently
// enough for the amount of markers to always be small enough that the
// nested for loop isn't going to be a performance problem.
for (uint32_t j = i + 1; j < mTimelineMarkers.Length(); ++j) {
UniquePtr<AbstractTimelineMarker>& endPayload = mTimelineMarkers.ElementAt(j);
bool endIsLayerType = strcmp(endPayload->GetName(), "Layer") == 0;
// Look for "Layer" markers to stream out "Paint" markers.
if (startIsPaintType && endIsLayerType) {
AbstractTimelineMarker* raw = endPayload.get();
LayerTimelineMarker* layerPayload = static_cast<LayerTimelineMarker*>(raw);
layerPayload->AddLayerRectangles(layerRectangles);
hasSeenLayerType = true;
}
if (!startPayload->Equals(*endPayload)) {
continue;
}
if (endPayload->GetTracingType() == MarkerTracingType::START) {
++markerDepth;
continue;
}
if (endPayload->GetTracingType() == MarkerTracingType::END) {
if (markerDepth > 0) {
--markerDepth;
continue;
}
if (!startIsPaintType || (startIsPaintType && hasSeenLayerType)) {
dom::ProfileTimelineMarker* marker = aStore.AppendElement();
marker->mName = NS_ConvertUTF8toUTF16(startPayload->GetName());
marker->mStart = startPayload->GetTime();
marker->mEnd = endPayload->GetTime();
marker->mStack = startPayload->GetStack();
if (hasSeenLayerType) {
marker->mRectangles.Construct(layerRectangles);
}
startPayload->AddDetails(aCx, *marker);
endPayload->AddDetails(aCx, *marker);
}
hasSeenEnd = true;
break;
}
}
// If we did not see the corresponding END, keep the START.
if (!hasSeenEnd) {
keptStartMarkers.AppendElement(Move(mTimelineMarkers.ElementAt(i)));
mTimelineMarkers.RemoveElementAt(i);
--i;
}
}
}
mTimelineMarkers.SwapElements(keptStartMarkers);
}
} // namespace mozilla