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-02-01 16:28:36 +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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_XMLStylesheetProcessingInstruction_h
|
|
|
|
#define mozilla_dom_XMLStylesheetProcessingInstruction_h
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2018-04-24 13:50:35 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2020-05-21 06:07:16 +03:00
|
|
|
#include "mozilla/dom/LinkStyle.h"
|
2013-02-01 16:28:36 +04:00
|
|
|
#include "mozilla/dom/ProcessingInstruction.h"
|
2014-03-17 10:56:53 +04:00
|
|
|
#include "nsIURI.h"
|
2013-02-01 16:28:36 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2020-05-21 06:07:16 +03:00
|
|
|
class XMLStylesheetProcessingInstruction final : public ProcessingInstruction,
|
|
|
|
public LinkStyle {
|
2013-02-01 16:28:36 +04:00
|
|
|
public:
|
2014-06-20 06:01:40 +04:00
|
|
|
XMLStylesheetProcessingInstruction(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-02-01 16:28:36 +04:00
|
|
|
const nsAString& aData)
|
2018-05-30 22:15:35 +03:00
|
|
|
: ProcessingInstruction(std::move(aNodeInfo), aData) {}
|
2013-04-04 16:01:11 +04:00
|
|
|
|
|
|
|
XMLStylesheetProcessingInstruction(nsNodeInfoManager* aNodeInfoManager,
|
|
|
|
const nsAString& aData)
|
|
|
|
: ProcessingInstruction(
|
|
|
|
aNodeInfoManager->GetNodeInfo(
|
|
|
|
nsGkAtoms::processingInstructionTagName, nullptr,
|
2018-01-30 07:10:53 +03:00
|
|
|
kNameSpaceID_None, PROCESSING_INSTRUCTION_NODE,
|
2013-04-04 16:01:11 +04:00
|
|
|
nsGkAtoms::xml_stylesheet),
|
|
|
|
aData) {}
|
|
|
|
|
2013-02-01 16:28:36 +04:00
|
|
|
// CC
|
2020-05-21 06:07:16 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-02-01 16:28:36 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLStylesheetProcessingInstruction,
|
|
|
|
ProcessingInstruction)
|
|
|
|
|
2018-05-30 05:58:49 +03:00
|
|
|
// nsINode
|
2013-02-01 16:28:36 +04:00
|
|
|
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
mozilla::ErrorResult& aError) override;
|
2013-02-01 16:28:36 +04:00
|
|
|
|
|
|
|
// nsIContent
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
2019-05-29 01:47:08 +03:00
|
|
|
virtual void UnbindFromTree(bool aNullParent = true) override;
|
2013-02-01 16:28:36 +04:00
|
|
|
|
2020-05-21 03:40:31 +03:00
|
|
|
/**
|
|
|
|
* 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);
|
2013-02-01 16:28:36 +04:00
|
|
|
|
2020-05-21 06:07:16 +03:00
|
|
|
// LinkStyle
|
2018-02-02 16:21:32 +03:00
|
|
|
void GetCharset(nsAString& aCharset) override;
|
2013-02-01 16:28:36 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetData(const nsAString& aData,
|
|
|
|
mozilla::ErrorResult& rv) override {
|
2018-03-19 22:18:06 +03:00
|
|
|
CharacterData::SetData(aData, rv);
|
2013-07-17 18:09:04 +04:00
|
|
|
if (rv.Failed()) {
|
|
|
|
return;
|
|
|
|
}
|
2018-04-24 13:50:35 +03:00
|
|
|
Unused << UpdateStyleSheetInternal(nullptr, nullptr, ForceUpdate::Yes);
|
2013-07-17 18:09:04 +04:00
|
|
|
}
|
|
|
|
|
2013-02-01 16:28:36 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~XMLStylesheetProcessingInstruction();
|
|
|
|
|
2013-02-01 16:28:36 +04:00
|
|
|
nsCOMPtr<nsIURI> mOverriddenBaseURI;
|
|
|
|
|
2020-05-21 06:07:16 +03:00
|
|
|
nsIContent& AsContent() final { return *this; }
|
|
|
|
const LinkStyle* AsLinkStyle() const final { return this; }
|
2018-05-08 07:11:56 +03:00
|
|
|
Maybe<SheetInfo> GetStyleSheetInfo() final;
|
2018-05-06 14:20:03 +03:00
|
|
|
|
2018-03-19 22:50:16 +03:00
|
|
|
already_AddRefed<CharacterData> CloneDataNode(
|
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const final;
|
2013-02-01 16:28:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_XMLStylesheetProcessingInstruction_h
|