Backed out 4 changesets (bug 1639392) for build bustages on nsCOMPtr.h. CLOSED TREE

Backed out changeset 379e2c6c0491 (bug 1639392)
Backed out changeset ce2500faad38 (bug 1639392)
Backed out changeset cee5116fbef3 (bug 1639392)
Backed out changeset 7c5823c53db8 (bug 1639392)
This commit is contained in:
Razvan Maries 2020-05-20 19:36:00 +03:00
Родитель 02e0a1d9a4
Коммит 958490b3c1
10 изменённых файлов: 75 добавлений и 34 удалений

Просмотреть файл

@ -127,6 +127,21 @@ class nsIStyleSheetLinkingElement : public nsISupports {
*/
virtual void SetStyleSheet(mozilla::StyleSheet* aStyleSheet) = 0;
/**
* Used to obtain the style sheet linked in by this element.
*
* @return the style sheet associated with this element.
*/
virtual mozilla::StyleSheet* GetStyleSheet() = 0;
/**
* Initialize the stylesheet linking element. If aDontLoadStyle is
* true the element will ignore the first modification to the
* element that would cause a stylesheet to be loaded. Subsequent
* modifications to the element will not be ignored.
*/
virtual void InitStyleLinkElement(bool aDontLoadStyle) = 0;
/**
* Tells this element to update the stylesheet.
*
@ -153,6 +168,15 @@ class nsIStyleSheetLinkingElement : public nsISupports {
*/
virtual void GetCharset(nsAString& aCharset) = 0;
/**
* Tells this element to use a different base URI. This is used for
* proper loading of xml-stylesheet processing instructions in XUL overlays
* and is only currently used by nsXMLStylesheetPI.
*
* @param aNewBaseURI the new base URI, nullptr to use the default base URI.
*/
virtual void OverrideBaseURI(nsIURI* aNewBaseURI) = 0;
// This doesn't entirely belong here since they only make sense for
// some types of linking elements, but it's a better place than
// anywhere else.

Просмотреть файл

@ -65,7 +65,8 @@ nsStyleLinkElement::SheetInfo::SheetInfo(
nsStyleLinkElement::SheetInfo::~SheetInfo() = default;
nsStyleLinkElement::nsStyleLinkElement()
: mUpdatesEnabled(true),
: mDontLoadStyle(false),
mUpdatesEnabled(true),
mLineNumber(1),
mColumnNumber(1) {}
@ -130,6 +131,12 @@ void nsStyleLinkElement::SetStyleSheet(StyleSheet* aStyleSheet) {
}
}
StyleSheet* nsStyleLinkElement::GetStyleSheet() { return mStyleSheet; }
void nsStyleLinkElement::InitStyleLinkElement(bool aDontLoadStyle) {
mDontLoadStyle = aDontLoadStyle;
}
void nsStyleLinkElement::SetEnableUpdates(bool aEnableUpdates) {
mUpdatesEnabled = aEnableUpdates;
}
@ -138,6 +145,13 @@ void nsStyleLinkElement::GetCharset(nsAString& aCharset) {
aCharset.Truncate();
}
/* virtual */
void nsStyleLinkElement::OverrideBaseURI(nsIURI* aNewBaseURI) {
MOZ_ASSERT_UNREACHABLE(
"Base URI can't be overriden in this implementation "
"of nsIStyleSheetLinkingElement.");
}
/* virtual */
void nsStyleLinkElement::SetLineNumber(uint32_t aLineNumber) {
mLineNumber = aLineNumber;
@ -262,7 +276,7 @@ nsStyleLinkElement::DoUpdateStyleSheet(Document* aOldDocument,
}
// When static documents are created, stylesheets are cloned manually.
if (!mUpdatesEnabled || doc->IsStaticDocument()) {
if (mDontLoadStyle || !mUpdatesEnabled || doc->IsStaticDocument()) {
return Update{};
}

Просмотреть файл

@ -32,9 +32,6 @@ class ShadowRoot;
} // namespace mozilla
class nsStyleLinkElement : public nsIStyleSheetLinkingElement {
template <typename V, typename E>
using Result = mozilla::Result<V, E>;
public:
nsStyleLinkElement();
virtual ~nsStyleLinkElement();
@ -44,17 +41,21 @@ class nsStyleLinkElement : public nsIStyleSheetLinkingElement {
mozilla::StyleSheet* GetSheet() const { return mStyleSheet; }
// nsIStyleSheetLinkingElement
void SetStyleSheet(mozilla::StyleSheet* aStyleSheet) final;
void SetStyleSheet(mozilla::StyleSheet* aStyleSheet) override;
mozilla::StyleSheet* GetStyleSheet() override;
void InitStyleLinkElement(bool aDontLoadStyle) override;
Result<Update, nsresult> UpdateStyleSheet(nsICSSLoaderObserver*) final;
mozilla::Result<Update, nsresult> UpdateStyleSheet(
nsICSSLoaderObserver*) override;
void SetEnableUpdates(bool aEnableUpdates) final;
void SetEnableUpdates(bool aEnableUpdates) override;
void GetCharset(nsAString& aCharset) override;
void SetLineNumber(uint32_t aLineNumber) final;
uint32_t GetLineNumber() final;
void SetColumnNumber(uint32_t aColumnNumber) final;
uint32_t GetColumnNumber() final;
void OverrideBaseURI(nsIURI* aNewBaseURI) override;
void SetLineNumber(uint32_t aLineNumber) override;
uint32_t GetLineNumber() override;
void SetColumnNumber(uint32_t aColumnNumber) override;
uint32_t GetColumnNumber() override;
enum RelValue {
ePREFETCH = 0x00000001,
@ -87,7 +88,7 @@ class nsStyleLinkElement : public nsIStyleSheetLinkingElement {
*
* TODO(emilio): Should probably pass a single DocumentOrShadowRoot.
*/
Result<Update, nsresult> UpdateStyleSheetInternal(
mozilla::Result<Update, nsresult> UpdateStyleSheetInternal(
mozilla::dom::Document* aOldDocument,
mozilla::dom::ShadowRoot* aOldShadowRoot, ForceUpdate = ForceUpdate::No);
@ -132,6 +133,7 @@ class nsStyleLinkElement : public nsIStyleSheetLinkingElement {
protected:
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
bool mDontLoadStyle;
bool mUpdatesEnabled;
uint32_t mLineNumber;
uint32_t mColumnNumber;

Просмотреть файл

@ -46,7 +46,6 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/ProcessingInstruction.h"
#include "mozilla/dom/XMLStylesheetProcessingInstruction.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/PresShell.h"
@ -344,11 +343,7 @@ nsresult PrototypeDocumentContentSink::CreateAndInsertPI(
nsresult rv;
if (aProtoPI->mTarget.EqualsLiteral("xml-stylesheet")) {
MOZ_ASSERT(
nsCOMPtr<nsIStyleSheetLinkingElement>(do_QueryInterface(node)),
"XML Stylesheet node does not implement nsIStyleSheetLinkingElement!");
auto* pi = static_cast<XMLStylesheetProcessingInstruction*>(node.get());
rv = InsertXMLStylesheetPI(aProtoPI, aParent, aBeforeThis, pi);
rv = InsertXMLStylesheetPI(aProtoPI, aParent, aBeforeThis, node);
} else {
// No special processing, just add the PI to the document.
rv = aParent->InsertChildBefore(
@ -361,25 +356,30 @@ nsresult PrototypeDocumentContentSink::CreateAndInsertPI(
nsresult PrototypeDocumentContentSink::InsertXMLStylesheetPI(
const nsXULPrototypePI* aProtoPI, nsINode* aParent, nsINode* aBeforeThis,
XMLStylesheetProcessingInstruction* aPINode) {
nsIContent* aPINode) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(aPINode));
NS_ASSERTION(ssle,
"passed XML Stylesheet node does not "
"implement nsIStyleSheetLinkingElement!");
nsresult rv;
ssle->InitStyleLinkElement(false);
// We want to be notified when the style sheet finishes loading, so
// disable style sheet loading for now.
aPINode->SetEnableUpdates(false);
aPINode->OverrideBaseURI(mCurrentPrototype->GetURI());
ssle->SetEnableUpdates(false);
ssle->OverrideBaseURI(mCurrentPrototype->GetURI());
rv = aParent->InsertChildBefore(
aPINode->AsContent(), aBeforeThis ? aBeforeThis->AsContent() : nullptr,
false);
if (NS_FAILED(rv)) return rv;
aPINode->SetEnableUpdates(true);
ssle->SetEnableUpdates(true);
// load the stylesheet if necessary, passing ourselves as
// nsICSSObserver
auto result = aPINode->UpdateStyleSheet(this);
auto result = ssle->UpdateStyleSheet(this);
if (result.isErr()) {
// Ignore errors from UpdateStyleSheet; we don't want failure to
// do that to break the XUL document load. But do propagate out

Просмотреть файл

@ -36,7 +36,6 @@ namespace dom {
class Element;
class ScriptLoader;
class Document;
class XMLStylesheetProcessingInstruction;
} // namespace dom
} // namespace mozilla
@ -238,7 +237,7 @@ class PrototypeDocumentContentSink final : public nsIStreamLoaderObserver,
*/
nsresult InsertXMLStylesheetPI(const nsXULPrototypePI* aProtoPI,
nsINode* aParent, nsINode* aBeforeThis,
XMLStylesheetProcessingInstruction* aPINode);
nsIContent* aPINode);
void CloseElement(Element* aElement);
};

Просмотреть файл

@ -72,6 +72,7 @@ void XMLStylesheetProcessingInstruction::GetCharset(nsAString& aCharset) {
}
}
/* virtual */
void XMLStylesheetProcessingInstruction::OverrideBaseURI(nsIURI* aNewBaseURI) {
mOverriddenBaseURI = aNewBaseURI;
}

Просмотреть файл

@ -47,14 +47,8 @@ class XMLStylesheetProcessingInstruction final : public ProcessingInstruction {
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
/**
* Tells this processing instruction to use a different base URI. This is used
* for proper loading of xml-stylesheet processing instructions in XUL
* overlays and is only currently used by nsXMLStylesheetPI.
*
* @param aNewBaseURI the new base URI, nullptr to use the default base URI.
*/
void OverrideBaseURI(nsIURI* aNewBaseURI);
// nsIStyleSheetLinkingElement
virtual void OverrideBaseURI(nsIURI* aNewBaseURI) override;
// nsStyleLinkElement
void GetCharset(nsAString& aCharset) override;

Просмотреть файл

@ -501,6 +501,7 @@ nsresult nsXMLContentSink::CreateElement(
aNodeInfo->Equals(nsGkAtoms::style, kNameSpaceID_SVG)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(content));
if (ssle) {
ssle->InitStyleLinkElement(false);
if (aFromParser) {
ssle->SetEnableUpdates(false);
}
@ -1167,6 +1168,7 @@ nsXMLContentSink::HandleProcessingInstruction(const char16_t* aTarget,
nsCOMPtr<nsIStyleSheetLinkingElement> ssle =
do_QueryInterface(ToSupports(node));
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
mPrettyPrintXML = false;
}

Просмотреть файл

@ -356,6 +356,7 @@ nsresult txMozillaXMLOutput::processingInstruction(const nsString& aTarget,
if (mCreatingNewDocument) {
ssle = do_QueryInterface(pi);
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
}
}
@ -500,6 +501,7 @@ nsresult txMozillaXMLOutput::startElementInternal(nsAtom* aPrefix,
nsCOMPtr<nsIStyleSheetLinkingElement> ssle =
do_QueryInterface(mOpenedElement);
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
}
}

Просмотреть файл

@ -458,6 +458,7 @@ nsIContent* nsHtml5TreeOperation::CreateHTMLElement(
if (MOZ_UNLIKELY(aName == nsGkAtoms::style || aName == nsGkAtoms::link)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
}
}
@ -485,6 +486,7 @@ nsIContent* nsHtml5TreeOperation::CreateHTMLElement(
if (MOZ_UNLIKELY(aName == nsGkAtoms::style || aName == nsGkAtoms::link)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
}
}
@ -533,6 +535,7 @@ nsIContent* nsHtml5TreeOperation::CreateSVGElement(
if (MOZ_UNLIKELY(aName == nsGkAtoms::style)) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
if (ssle) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
}
}