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 #ifndef mozilla_PresShellInlines_h 8 #define mozilla_PresShellInlines_h 9 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" 15 16 namespace mozilla { 17 SetNeedLayoutFlush()18void PresShell::SetNeedLayoutFlush() { 19 mNeedLayoutFlush = true; 20 if (dom::Document* doc = mDocument->GetDisplayDocument()) { 21 if (PresShell* presShell = doc->GetPresShell()) { 22 presShell->mNeedLayoutFlush = true; 23 } 24 } 25 26 if (!mReflowCause) { 27 mReflowCause = profiler_capture_backtrace(); 28 } 29 30 mLayoutTelemetry.IncReqsPerFlush(FlushType::Layout); 31 } 32 SetNeedStyleFlush()33void 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())); 41 42 if (dom::Document* doc = mDocument->GetDisplayDocument()) { 43 if (PresShell* presShell = doc->GetPresShell()) { 44 presShell->mNeedStyleFlush = true; 45 } 46 } 47 48 if (!mStyleCause) { 49 mStyleCause = profiler_capture_backtrace(); 50 } 51 52 mLayoutTelemetry.IncReqsPerFlush(FlushType::Layout); 53 } 54 EnsureStyleFlush()55void PresShell::EnsureStyleFlush() { 56 SetNeedStyleFlush(); 57 ObserveStyleFlushes(); 58 } 59 SetNeedThrottledAnimationFlush()60void PresShell::SetNeedThrottledAnimationFlush() { 61 mNeedThrottledAnimationFlush = true; 62 if (dom::Document* doc = mDocument->GetDisplayDocument()) { 63 if (PresShell* presShell = doc->GetPresShell()) { 64 presShell->mNeedThrottledAnimationFlush = true; 65 } 66 } 67 } 68 StyleSet()69ServoStyleSet* PresShell::StyleSet() const { 70 return mDocument->StyleSetForPresShellOrMediaQueryEvaluation(); 71 } 72 73 /* static */ OnPresShellDestroy(Document * aDocument)74inline void PresShell::EventHandler::OnPresShellDestroy(Document* aDocument) { 75 if (sLastKeyDownEventTargetElement && 76 sLastKeyDownEventTargetElement->OwnerDoc() == aDocument) { 77 sLastKeyDownEventTargetElement = nullptr; 78 } 79 } 80 81 } // namespace mozilla 82 83 #endif // mozilla_PresShellInlines_h 84