Merge mozilla-central to autoland. a=merge CLOSED TREE
[gecko.git] / layout / base / PresShellInlines.h
blobc04c3b54a94a7935451231fc88ad452b5c66cb14
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();
30 mLayoutTelemetry.IncReqsPerFlush(FlushType::Layout);
33 void PresShell::SetNeedStyleFlush() {
34 mNeedStyleFlush = true;
35 PROFILER_MARKER_UNTYPED(
36 "SetNeedStyleFlush", LAYOUT,
37 MarkerOptions(MarkerStack::Capture(StackCaptureOptions::NonNative),
38 mPresContext ? MarkerInnerWindowIdFromDocShell(
39 mPresContext->GetDocShell())
40 : MarkerInnerWindowId::NoId()));
42 if (dom::Document* doc = mDocument->GetDisplayDocument()) {
43 if (PresShell* presShell = doc->GetPresShell()) {
44 presShell->mNeedStyleFlush = true;
48 if (!mStyleCause) {
49 mStyleCause = profiler_capture_backtrace();
52 mLayoutTelemetry.IncReqsPerFlush(FlushType::Layout);
55 void PresShell::EnsureStyleFlush() {
56 SetNeedStyleFlush();
57 ObserveStyleFlushes();
60 void PresShell::SetNeedThrottledAnimationFlush() {
61 mNeedThrottledAnimationFlush = true;
62 if (dom::Document* doc = mDocument->GetDisplayDocument()) {
63 if (PresShell* presShell = doc->GetPresShell()) {
64 presShell->mNeedThrottledAnimationFlush = true;
69 ServoStyleSet* PresShell::StyleSet() const {
70 return mDocument->StyleSetForPresShell();
73 /* static */
74 inline void PresShell::EventHandler::OnPresShellDestroy(Document* aDocument) {
75 if (sLastKeyDownEventTargetElement &&
76 sLastKeyDownEventTargetElement->OwnerDoc() == aDocument) {
77 sLastKeyDownEventTargetElement = nullptr;
81 } // namespace mozilla
83 #endif // mozilla_PresShellInlines_h