Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / layout / base / PresShellInlines.h
blob6c58f1db811a1d7e789d344949bd35db4b5276c9
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/. */
7 #ifndef mozilla_PresShellInlines_h
8 #define mozilla_PresShellInlines_h
10 #include "nsDocShell.h"
11 #include "GeckoProfiler.h"
12 #include "mozilla/PresShell.h"
13 #include "mozilla/dom/Document.h"
14 #include "mozilla/dom/Element.h"
16 namespace mozilla {
18 void PresShell::SetNeedLayoutFlush() {
19 mNeedLayoutFlush = true;
20 if (dom::Document* doc = mDocument->GetDisplayDocument()) {
21 if (PresShell* presShell = doc->GetPresShell()) {
22 presShell->mNeedLayoutFlush = true;
26 if (!mReflowCause) {
27 mReflowCause = profiler_capture_backtrace();
31 void PresShell::SetNeedStyleFlush() {
32 mNeedStyleFlush = true;
33 PROFILER_MARKER_UNTYPED(
34 "SetNeedStyleFlush", LAYOUT,
35 MarkerOptions(MarkerStack::Capture(StackCaptureOptions::NonNative),
36 mPresContext ? MarkerInnerWindowIdFromDocShell(
37 mPresContext->GetDocShell())
38 : MarkerInnerWindowId::NoId()));
40 if (dom::Document* doc = mDocument->GetDisplayDocument()) {
41 if (PresShell* presShell = doc->GetPresShell()) {
42 presShell->mNeedStyleFlush = true;
46 if (!mStyleCause) {
47 mStyleCause = profiler_capture_backtrace();
51 void PresShell::EnsureStyleFlush() {
52 SetNeedStyleFlush();
53 ObserveStyleFlushes();
56 void PresShell::EnsureLayoutFlush() {
57 SetNeedLayoutFlush();
58 ObserveStyleFlushes();
61 void PresShell::SetNeedThrottledAnimationFlush() {
62 mNeedThrottledAnimationFlush = true;
63 if (dom::Document* doc = mDocument->GetDisplayDocument()) {
64 if (PresShell* presShell = doc->GetPresShell()) {
65 presShell->mNeedThrottledAnimationFlush = true;
70 ServoStyleSet* PresShell::StyleSet() const {
71 return mDocument->StyleSetForPresShell();
74 /* static */
75 inline void PresShell::EventHandler::OnPresShellDestroy(Document* aDocument) {
76 if (sLastKeyDownEventTargetElement &&
77 sLastKeyDownEventTargetElement->OwnerDoc() == aDocument) {
78 sLastKeyDownEventTargetElement = nullptr;
82 } // namespace mozilla
84 #endif // mozilla_PresShellInlines_h