/src/mozilla-central/docshell/base/timeline/AutoRestyleTimelineMarker.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "AutoRestyleTimelineMarker.h" |
8 | | |
9 | | #include "TimelineConsumers.h" |
10 | | #include "MainThreadUtils.h" |
11 | | #include "RestyleTimelineMarker.h" |
12 | | |
13 | | namespace mozilla { |
14 | | |
15 | | AutoRestyleTimelineMarker::AutoRestyleTimelineMarker( |
16 | | nsIDocShell* aDocShell, |
17 | | bool aIsAnimationOnly |
18 | | MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL) |
19 | | : mDocShell(nullptr) |
20 | | , mIsAnimationOnly(aIsAnimationOnly) |
21 | 0 | { |
22 | 0 | MOZ_GUARD_OBJECT_NOTIFIER_INIT; |
23 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
24 | 0 |
|
25 | 0 | if (!aDocShell) { |
26 | 0 | return; |
27 | 0 | } |
28 | 0 | |
29 | 0 | RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get(); |
30 | 0 | if (!timelines || !timelines->HasConsumer(aDocShell)) { |
31 | 0 | return; |
32 | 0 | } |
33 | 0 | |
34 | 0 | mDocShell = aDocShell; |
35 | 0 | timelines->AddMarkerForDocShell(mDocShell, |
36 | 0 | MakeUnique<RestyleTimelineMarker>( |
37 | 0 | mIsAnimationOnly, |
38 | 0 | MarkerTracingType::START)); |
39 | 0 | } |
40 | | |
41 | | AutoRestyleTimelineMarker::~AutoRestyleTimelineMarker() |
42 | 0 | { |
43 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
44 | 0 |
|
45 | 0 | if (!mDocShell) { |
46 | 0 | return; |
47 | 0 | } |
48 | 0 | |
49 | 0 | RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get(); |
50 | 0 | if (!timelines || !timelines->HasConsumer(mDocShell)) { |
51 | 0 | return; |
52 | 0 | } |
53 | 0 | |
54 | 0 | timelines->AddMarkerForDocShell(mDocShell, |
55 | 0 | MakeUnique<RestyleTimelineMarker>( |
56 | 0 | mIsAnimationOnly, |
57 | 0 | MarkerTracingType::END)); |
58 | 0 | } |
59 | | |
60 | | } // namespace mozilla |