2016-03-02 01:38:13 +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: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_StyleSheetInlines_h
|
|
|
|
#define mozilla_StyleSheetInlines_h
|
|
|
|
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2018-04-30 20:47:12 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "nsIGlobalObject.h"
|
2017-03-28 12:05:12 +03:00
|
|
|
#include "nsINode.h"
|
2016-03-02 01:38:13 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2018-04-30 20:47:12 +03:00
|
|
|
void StyleSheet::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI,
|
2016-09-26 15:03:25 +03:00
|
|
|
nsIURI* aBaseURI) {
|
2018-04-30 20:47:12 +03:00
|
|
|
MOZ_ASSERT(aSheetURI && aBaseURI, "null ptr");
|
Bug 1484690 - Move the enabled state to the sheet instead of sharing it. r=heycam
We share the inner object across sheets from the same URL, so what happens here
is that, once the sheet parses and loads, we call SetEnabled() on the first
sheet, which sets the inner bit, then calls ApplicableStateChanged.
That set actually turned the second sheet complete, so when inserting the sheet,
we think that the second sheet is already enabled, and thus in the author data,
and try to insert before it. Of course there's nothing there, so we panic.
We rely on calling SetEnabled() on all the sheets already to insert them in the
styleset / author data, so this makes it clearer and fixes the bug by moving the
state to each individual sheet.
Differential Revision: https://phabricator.services.mozilla.com/D3798
--HG--
extra : moz-landing-system : lando
2018-08-21 11:55:10 +03:00
|
|
|
MOZ_ASSERT(!HasRules() && !IsComplete(),
|
2016-09-26 15:03:25 +03:00
|
|
|
"Can't call SetURIs on sheets that are complete or have rules");
|
Bug 1484690 - Move the enabled state to the sheet instead of sharing it. r=heycam
We share the inner object across sheets from the same URL, so what happens here
is that, once the sheet parses and loads, we call SetEnabled() on the first
sheet, which sets the inner bit, then calls ApplicableStateChanged.
That set actually turned the second sheet complete, so when inserting the sheet,
we think that the second sheet is already enabled, and thus in the author data,
and try to insert before it. Of course there's nothing there, so we panic.
We rely on calling SetEnabled() on all the sheets already to insert them in the
styleset / author data, so this makes it clearer and fixes the bug by moving the
state to each individual sheet.
Differential Revision: https://phabricator.services.mozilla.com/D3798
--HG--
extra : moz-landing-system : lando
2018-08-21 11:55:10 +03:00
|
|
|
StyleSheetInfo& info = Inner();
|
2016-09-26 15:03:25 +03:00
|
|
|
info.mSheetURI = aSheetURI;
|
|
|
|
info.mOriginalSheetURI = aOriginalSheetURI;
|
|
|
|
info.mBaseURI = aBaseURI;
|
|
|
|
}
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
dom::ParentObject StyleSheet::GetParentObject() const {
|
2020-05-01 20:08:54 +03:00
|
|
|
if (mRelevantGlobal) {
|
|
|
|
return dom::ParentObject(mRelevantGlobal);
|
|
|
|
}
|
2020-04-17 00:16:08 +03:00
|
|
|
if (IsConstructed()) {
|
|
|
|
return dom::ParentObject(mConstructorDocument.get());
|
|
|
|
}
|
2016-10-14 14:25:38 +03:00
|
|
|
if (mOwningNode) {
|
|
|
|
return dom::ParentObject(mOwningNode);
|
|
|
|
}
|
2020-04-13 23:49:32 +03:00
|
|
|
return dom::ParentObject(mParentSheet);
|
2016-10-14 14:25:38 +03:00
|
|
|
}
|
|
|
|
|
2016-03-02 01:38:13 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_StyleSheetInlines_h
|