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"
18 void PresShell::SetNeedLayoutFlush() {
19 mNeedLayoutFlush
= true;
20 if (dom::Document
* doc
= mDocument
->GetDisplayDocument()) {
21 if (PresShell
* presShell
= doc
->GetPresShell()) {
22 presShell
->mNeedLayoutFlush
= true;
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;
47 mStyleCause
= profiler_capture_backtrace();
51 void PresShell::EnsureStyleFlush() {
53 ObserveStyleFlushes();
56 void PresShell::EnsureLayoutFlush() {
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();
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