Bug 1556061 - Add IsTopContent and IsChrome helpers to BrowsingContext, r=farre

Differential Revision: https://phabricator.services.mozilla.com/D33332

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-06-06 14:57:31 +00:00
parent de01a8cd7e
commit aba7a5f8f3
3 changed files with 6 additions and 3 deletions

View File

@ -164,6 +164,9 @@ class BrowsingContext : public nsWrapperCache, public BrowsingContextBase {
bool NameEquals(const nsAString& aName) { return mName.Equals(aName); }
bool IsContent() const { return mType == Type::Content; }
bool IsChrome() const { return !IsContent(); }
bool IsTopContent() const { return IsContent() && !GetParent(); }
uint64_t Id() const { return mBrowsingContextId; }

View File

@ -6030,7 +6030,7 @@ void Document::SetContainer(nsDocShell* aContainer) {
BrowsingContext* context = aContainer->GetBrowsingContext();
if (context && context->IsContent()) {
if (!context->GetParent()) {
if (context->IsTopContent()) {
SetIsTopLevelContentDocument(true);
}
SetIsContentDocument(true);

View File

@ -1921,8 +1921,8 @@ bool nsGlobalWindowInner::DialogsAreBeingAbused() {
void nsGlobalWindowInner::FireFrameLoadEvent(bool aIsTrusted) {
// If we're not in a content frame, or are at a BrowsingContext tree boundary,
// such as the content-chrome boundary, don't fire the "load" event.
if (!GetBrowsingContext()->GetParent() ||
!GetBrowsingContext()->IsContent()) {
if (GetBrowsingContext()->IsTopContent() ||
GetBrowsingContext()->IsChrome()) {
return;
}