PresShellInlines.h (2375B)
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 "GeckoProfiler.h" 11 #include "mozilla/PresShell.h" 12 #include "mozilla/dom/Document.h" 13 #include "mozilla/dom/Element.h" 14 #include "nsDocShell.h" 15 16 namespace mozilla { 17 18 void 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 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())); 39 40 if (dom::Document* doc = mDocument->GetDisplayDocument()) { 41 if (PresShell* presShell = doc->GetPresShell()) { 42 presShell->mNeedStyleFlush = true; 43 } 44 } 45 46 if (!mStyleCause) { 47 mStyleCause = profiler_capture_backtrace(); 48 } 49 } 50 51 void PresShell::EnsureStyleFlush() { 52 SetNeedStyleFlush(); 53 ScheduleFlush(); 54 } 55 56 void PresShell::EnsureLayoutFlush() { 57 SetNeedLayoutFlush(); 58 ScheduleFlush(); 59 } 60 61 void PresShell::SetNeedThrottledAnimationFlush() { 62 mNeedThrottledAnimationFlush = true; 63 if (dom::Document* doc = mDocument->GetDisplayDocument()) { 64 if (PresShell* presShell = doc->GetPresShell()) { 65 presShell->mNeedThrottledAnimationFlush = true; 66 } 67 } 68 } 69 70 ServoStyleSet* PresShell::StyleSet() const { 71 return mDocument->StyleSetForPresShell(); 72 } 73 74 /* static */ 75 inline void PresShell::EventHandler::OnPresShellDestroy(Document* aDocument) { 76 if (sLastKeyDownEventTargetElement && 77 sLastKeyDownEventTargetElement->OwnerDoc() == aDocument) { 78 sLastKeyDownEventTargetElement = nullptr; 79 } 80 } 81 82 } // namespace mozilla 83 84 #endif // mozilla_PresShellInlines_h