Bug 1854550 - pt 10. Allow LOG() with zero extra arguments r=glandium
[gecko.git] / dom / base / DocumentInlines.h
blobc93189763d3f2452824fd0b0ba9081f4631ad109
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 #ifndef mozilla_dom_DocumentInlines_h
7 #define mozilla_dom_DocumentInlines_h
9 #include "mozilla/dom/Document.h"
11 #include "mozilla/PresShell.h"
12 #include "mozilla/dom/HTMLBodyElement.h"
13 #include "nsContentUtils.h"
14 #include "nsPresContext.h"
15 #include "nsStyleSheetService.h"
17 namespace mozilla::dom {
19 inline PresShell* Document::GetObservingPresShell() const {
20 return mPresShell && mPresShell->IsObservingDocument() ? mPresShell : nullptr;
23 inline nsPresContext* Document::GetPresContext() const {
24 PresShell* presShell = GetPresShell();
25 return presShell ? presShell->GetPresContext() : nullptr;
28 inline HTMLBodyElement* Document::GetBodyElement() {
29 return static_cast<HTMLBodyElement*>(GetHtmlChildElement(nsGkAtoms::body));
32 inline void Document::SetServoRestyleRoot(nsINode* aRoot, uint32_t aDirtyBits) {
33 MOZ_ASSERT(aRoot);
35 MOZ_ASSERT(!mServoRestyleRoot || mServoRestyleRoot == aRoot ||
36 nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(
37 mServoRestyleRoot, aRoot));
38 MOZ_ASSERT(aRoot == aRoot->OwnerDocAsNode() || aRoot->IsElement());
39 mServoRestyleRoot = aRoot;
40 SetServoRestyleRootDirtyBits(aDirtyBits);
43 // Note: we break this out of SetServoRestyleRoot so that callers can add
44 // bits without doing a no-op assignment to the restyle root, which would
45 // involve cycle-collected refcount traffic.
46 inline void Document::SetServoRestyleRootDirtyBits(uint32_t aDirtyBits) {
47 MOZ_ASSERT(aDirtyBits);
48 MOZ_ASSERT((aDirtyBits & ~Element::kAllServoDescendantBits) == 0);
49 MOZ_ASSERT((aDirtyBits & mServoRestyleRootDirtyBits) ==
50 mServoRestyleRootDirtyBits);
51 MOZ_ASSERT(mServoRestyleRoot);
52 mServoRestyleRootDirtyBits = aDirtyBits;
55 } // namespace mozilla::dom
57 #endif // mozilla_dom_DocumentInlines_h