2015-05-03 15:32:37 -04: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: */
|
2012-05-21 12:12:37 +01: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/. */
|
2006-03-30 08:03:04 +00:00
|
|
|
|
|
|
|
/*
|
2018-01-21 12:07:31 -05:00
|
|
|
* Implementation of DOM Core's Attr node.
|
2006-03-30 08:03:04 +00:00
|
|
|
*/
|
|
|
|
|
2013-04-09 17:29:44 +02:00
|
|
|
#ifndef mozilla_dom_Attr_h
|
|
|
|
#define mozilla_dom_Attr_h
|
1999-01-12 08:45:23 +00:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2019-06-17 04:36:02 +00:00
|
|
|
#include "nsDOMAttributeMap.h"
|
2018-07-12 15:51:52 -07:00
|
|
|
#include "nsINode.h"
|
1999-01-12 08:45:23 +00:00
|
|
|
#include "nsString.h"
|
2000-06-23 00:21:32 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2007-01-04 22:31:26 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-05-27 15:10:33 -04:00
|
|
|
#include "nsStubMutationObserver.h"
|
2014-08-18 17:44:50 +03:00
|
|
|
|
2013-04-09 17:29:44 +02:00
|
|
|
namespace mozilla {
|
2014-03-18 13:48:19 +09:00
|
|
|
class EventChainPreVisitor;
|
2013-04-09 17:29:44 +02:00
|
|
|
namespace dom {
|
|
|
|
|
2019-01-02 14:05:23 +01:00
|
|
|
class Document;
|
|
|
|
|
1999-01-12 08:45:23 +00:00
|
|
|
// Attribute helper class used to wrap up an attribute with a dom
|
2018-01-21 12:07:31 -05:00
|
|
|
// object that implements the DOM Attr interface.
|
2018-07-12 15:51:52 -07:00
|
|
|
class Attr final : public nsINode {
|
2014-06-24 22:09:15 -04:00
|
|
|
virtual ~Attr() {}
|
|
|
|
|
1999-01-12 08:45:23 +00:00
|
|
|
public:
|
2018-08-08 23:58:44 +00:00
|
|
|
Attr(nsDOMAttributeMap* aAttrMap, already_AddRefed<dom::NodeInfo>&& aNodeInfo,
|
2016-01-11 13:01:31 -05:00
|
|
|
const nsAString& aValue);
|
1999-01-12 08:45:23 +00:00
|
|
|
|
2007-01-04 22:31:26 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2005-12-03 07:42:40 +00:00
|
|
|
|
2018-04-15 15:12:02 +02:00
|
|
|
NS_IMPL_FROMNODE_HELPER(Attr, IsAttr())
|
|
|
|
|
2018-01-29 23:10:52 -05:00
|
|
|
// nsINode interface
|
2014-08-05 06:10:00 -04:00
|
|
|
virtual void GetTextContentInternal(nsAString& aTextContent,
|
2017-01-17 23:52:29 -05:00
|
|
|
OOMReporter& aError) override;
|
2012-10-09 14:31:24 +02:00
|
|
|
virtual void SetTextContentInternal(const nsAString& aTextContent,
|
2017-11-07 14:01:21 -08:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2015-03-21 12:28:04 -04:00
|
|
|
ErrorResult& aError) override;
|
|
|
|
virtual void GetNodeValueInternal(nsAString& aNodeValue) override;
|
2012-10-09 14:31:24 +02:00
|
|
|
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
|
2015-03-21 12:28:04 -04:00
|
|
|
ErrorResult& aError) override;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 16:46:42 +00:00
|
|
|
|
2018-04-05 13:42:41 -04:00
|
|
|
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
|
2011-06-23 19:17:58 -07:00
|
|
|
|
2018-07-06 16:52:42 -07:00
|
|
|
void ConstructUbiNode(void* storage) override;
|
|
|
|
|
2018-07-12 15:51:52 -07:00
|
|
|
nsDOMAttributeMap* GetMap() { return mAttrMap; }
|
|
|
|
|
|
|
|
void SetMap(nsDOMAttributeMap* aMap);
|
|
|
|
|
2014-04-10 19:09:50 +03:00
|
|
|
Element* GetElement() const;
|
2018-07-12 15:51:52 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when our ownerElement is moved into a new document.
|
|
|
|
* Updates the nodeinfo of this node.
|
|
|
|
*/
|
2019-01-02 14:05:23 +01:00
|
|
|
nsresult SetOwnerDocument(Document* aDocument);
|
2005-06-06 08:51:40 +00:00
|
|
|
|
2006-01-25 20:49:56 +00:00
|
|
|
// nsINode interface
|
2015-03-21 12:28:04 -04:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
2018-08-08 23:58:44 +00:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2019-07-15 17:22:30 +00:00
|
|
|
nsIURI* GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
|
2006-09-05 10:22:54 +00:00
|
|
|
|
2005-08-19 23:40:42 +00:00
|
|
|
static void Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2018-07-12 15:51:52 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(Attr)
|
2007-01-04 22:31:26 +00:00
|
|
|
|
2013-04-09 17:29:47 +02:00
|
|
|
// WebIDL
|
2015-03-21 12:28:04 -04:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2013-04-09 17:29:47 +02:00
|
|
|
|
2018-01-21 12:07:31 -05:00
|
|
|
void GetName(nsAString& aName);
|
|
|
|
void GetValue(nsAString& aValue);
|
2017-10-09 14:33:38 -07:00
|
|
|
|
|
|
|
void SetValue(const nsAString& aValue, nsIPrincipal* aTriggeringPrincipal,
|
|
|
|
ErrorResult& aRv);
|
2018-01-21 12:07:31 -05:00
|
|
|
void SetValue(const nsAString& aValue, ErrorResult& aRv);
|
2013-04-09 17:29:47 +02:00
|
|
|
|
|
|
|
bool Specified() const;
|
|
|
|
|
|
|
|
// XPCOM GetNamespaceURI() is OK
|
|
|
|
// XPCOM GetPrefix() is OK
|
|
|
|
// XPCOM GetLocalName() is OK
|
|
|
|
|
2014-03-21 16:04:09 -04:00
|
|
|
Element* GetOwnerElement(ErrorResult& aRv);
|
|
|
|
|
2005-08-19 23:40:42 +00:00
|
|
|
protected:
|
2015-03-21 12:28:04 -04:00
|
|
|
virtual Element* GetNameSpaceElement() override { return GetElement(); }
|
2010-04-19 17:40:16 +02:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool sInitialized;
|
1999-01-12 08:45:23 +00:00
|
|
|
|
|
|
|
private:
|
2018-07-12 15:51:52 -07:00
|
|
|
RefPtr<nsDOMAttributeMap> mAttrMap;
|
2012-04-03 09:25:39 +02:00
|
|
|
nsString mValue;
|
1999-01-12 08:45:23 +00:00
|
|
|
};
|
|
|
|
|
2013-04-09 17:29:44 +02:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
1999-01-12 08:45:23 +00:00
|
|
|
|
2013-04-09 17:29:44 +02:00
|
|
|
#endif /* mozilla_dom_Attr_h */
|