2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-01-13 01:53:01 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2019-01-02 16:05:23 +03:00
|
|
|
#ifndef mozilla_dom_DocumentInlines_h
|
|
|
|
#define mozilla_dom_DocumentInlines_h
|
2013-01-13 01:53:01 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2019-03-29 18:11:04 +03:00
|
|
|
|
2019-04-04 03:19:48 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
2013-01-13 01:53:01 +04:00
|
|
|
#include "mozilla/dom/HTMLBodyElement.h"
|
2019-03-29 18:11:04 +03:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsPresContext.h"
|
2016-04-29 07:01:44 +03:00
|
|
|
#include "nsStyleSheetService.h"
|
2013-01-13 01:53:01 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2019-03-29 18:12:47 +03:00
|
|
|
inline PresShell* Document::GetObservingPresShell() const {
|
2019-03-29 18:11:04 +03:00
|
|
|
return mPresShell && mPresShell->IsObservingDocument() ? mPresShell : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsPresContext* Document::GetPresContext() const {
|
2019-03-29 18:12:47 +03:00
|
|
|
PresShell* presShell = GetPresShell();
|
2019-03-29 18:11:04 +03:00
|
|
|
return presShell ? presShell->GetPresContext() : nullptr;
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
inline HTMLBodyElement* Document::GetBodyElement() {
|
|
|
|
return static_cast<HTMLBodyElement*>(GetHtmlChildElement(nsGkAtoms::body));
|
2013-01-13 01:53:01 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
inline void Document::SetServoRestyleRoot(nsINode* aRoot, uint32_t aDirtyBits) {
|
2017-07-19 04:38:47 +03:00
|
|
|
MOZ_ASSERT(aRoot);
|
|
|
|
|
2017-08-31 10:42:19 +03:00
|
|
|
MOZ_ASSERT(!mServoRestyleRoot || mServoRestyleRoot == aRoot ||
|
|
|
|
nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(
|
|
|
|
mServoRestyleRoot, aRoot));
|
2017-09-28 15:17:41 +03:00
|
|
|
MOZ_ASSERT(aRoot == aRoot->OwnerDocAsNode() || aRoot->IsElement());
|
2017-07-19 04:38:47 +03:00
|
|
|
mServoRestyleRoot = aRoot;
|
2018-01-12 00:34:30 +03:00
|
|
|
SetServoRestyleRootDirtyBits(aDirtyBits);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: we break this out of SetServoRestyleRoot so that callers can add
|
|
|
|
// bits without doing a no-op assignment to the restyle root, which would
|
|
|
|
// involve cycle-collected refcount traffic.
|
2019-01-02 16:05:23 +03:00
|
|
|
inline void Document::SetServoRestyleRootDirtyBits(uint32_t aDirtyBits) {
|
2018-01-12 00:34:30 +03:00
|
|
|
MOZ_ASSERT(aDirtyBits);
|
|
|
|
MOZ_ASSERT((aDirtyBits & ~Element::kAllServoDescendantBits) == 0);
|
|
|
|
MOZ_ASSERT((aDirtyBits & mServoRestyleRootDirtyBits) ==
|
|
|
|
mServoRestyleRootDirtyBits);
|
|
|
|
MOZ_ASSERT(mServoRestyleRoot);
|
2017-07-19 04:38:47 +03:00
|
|
|
mServoRestyleRootDirtyBits = aDirtyBits;
|
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_DocumentInlines_h
|