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: */
|
2012-05-21 15:12:37 +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/. */
|
1999-04-01 00:49:25 +04:00
|
|
|
|
2006-03-31 12:41:49 +04:00
|
|
|
/*
|
|
|
|
* Implementation of DOM Core's nsIDOMText node.
|
|
|
|
*/
|
|
|
|
|
2008-10-15 13:40:28 +04:00
|
|
|
#include "nsTextNode.h"
|
2013-01-04 21:02:14 +04:00
|
|
|
#include "mozilla/dom/TextBinding.h"
|
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 20:46:42 +04:00
|
|
|
#include "nsContentUtils.h"
|
2012-11-21 14:13:57 +04:00
|
|
|
#include "mozilla/dom/DirectionalityUtils.h"
|
2004-01-27 07:22:58 +03:00
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIDOMMutationEvent.h"
|
2004-08-10 14:22:36 +04:00
|
|
|
#include "nsIDocument.h"
|
2006-09-20 07:17:11 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2012-09-06 00:49:53 +04:00
|
|
|
#include "nsStubMutationObserver.h"
|
2014-03-28 00:38:33 +04:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2011-12-20 13:15:41 +04:00
|
|
|
#ifdef DEBUG
|
2012-01-10 18:19:54 +04:00
|
|
|
#include "nsRange.h"
|
2011-12-20 13:15:41 +04:00
|
|
|
#endif
|
2004-01-27 07:22:58 +03:00
|
|
|
|
2012-11-21 14:13:57 +04:00
|
|
|
using namespace mozilla;
|
2010-08-24 11:05:56 +04:00
|
|
|
using namespace mozilla::dom;
|
1998-09-06 04:16:36 +04:00
|
|
|
|
2004-01-27 07:22:58 +03:00
|
|
|
/**
|
|
|
|
* class used to implement attr() generated content
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsAttributeTextNode final : public nsTextNode,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsStubMutationObserver
|
2006-09-20 07:17:11 +04:00
|
|
|
{
|
2004-01-27 07:22:58 +03:00
|
|
|
public:
|
2006-09-20 07:17:11 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2004-01-27 07:22:58 +03:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
nsAttributeTextNode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aNameSpaceID,
|
2006-09-20 07:17:11 +04:00
|
|
|
nsIAtom* aAttrName) :
|
|
|
|
nsTextNode(aNodeInfo),
|
2012-07-30 18:20:58 +04:00
|
|
|
mGrandparent(nullptr),
|
2006-09-20 07:17:11 +04:00
|
|
|
mNameSpaceID(aNameSpaceID),
|
|
|
|
mAttrName(aAttrName)
|
2005-09-24 22:43:15 +04:00
|
|
|
{
|
2006-09-20 07:17:11 +04:00
|
|
|
NS_ASSERTION(mNameSpaceID != kNameSpaceID_Unknown, "Must know namespace");
|
|
|
|
NS_ASSERTION(mAttrName, "Must have attr name");
|
2004-08-10 14:22:36 +04:00
|
|
|
}
|
2006-09-20 07:17:11 +04:00
|
|
|
|
2005-04-06 03:54:35 +04:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aCompileEventHandlers) override;
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNullParent = true) override;
|
2004-01-27 07:22:58 +03:00
|
|
|
|
2007-07-13 00:05:45 +04:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
2008-10-08 15:13:26 +04:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
2006-09-20 07:17:11 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
virtual nsGenericDOMDataNode *CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aCloneText) const override
|
2005-09-11 21:15:08 +04:00
|
|
|
{
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo> ni =
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
|
2014-03-15 23:00:17 +04:00
|
|
|
nsAttributeTextNode *it = new nsAttributeTextNode(ni,
|
2006-09-20 07:17:11 +04:00
|
|
|
mNameSpaceID,
|
|
|
|
mAttrName);
|
2005-09-11 21:15:08 +04:00
|
|
|
if (it && aCloneText) {
|
|
|
|
it->mText = mText;
|
|
|
|
}
|
|
|
|
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
2006-09-20 07:17:11 +04:00
|
|
|
// Public method for the event to run
|
|
|
|
void UpdateText() {
|
2011-10-17 18:59:28 +04:00
|
|
|
UpdateText(true);
|
2006-09-20 07:17:11 +04:00
|
|
|
}
|
|
|
|
|
2004-01-27 07:22:58 +03:00
|
|
|
private:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~nsAttributeTextNode() {
|
|
|
|
NS_ASSERTION(!mGrandparent, "We were not unbound!");
|
|
|
|
}
|
|
|
|
|
2006-09-20 07:17:11 +04:00
|
|
|
// Update our text to our parent's current attr value
|
2011-09-29 10:19:26 +04:00
|
|
|
void UpdateText(bool aNotify);
|
2006-09-20 07:17:11 +04:00
|
|
|
|
2008-08-18 05:16:42 +04:00
|
|
|
// This doesn't need to be a strong pointer because it's only non-null
|
|
|
|
// while we're bound to the document tree, and it points to an ancestor
|
|
|
|
// so the ancestor must be bound to the document tree the whole time
|
|
|
|
// and can't be deleted.
|
|
|
|
nsIContent* mGrandparent;
|
2006-09-20 07:17:11 +04:00
|
|
|
// What attribute we're showing
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mNameSpaceID;
|
2006-09-20 07:17:11 +04:00
|
|
|
nsCOMPtr<nsIAtom> mAttrName;
|
2004-01-27 07:22:58 +03:00
|
|
|
};
|
|
|
|
|
1998-09-06 04:16:36 +04:00
|
|
|
nsTextNode::~nsTextNode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(nsTextNode, nsGenericDOMDataNode, nsIDOMNode,
|
|
|
|
nsIDOMText, nsIDOMCharacterData)
|
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 20:46:42 +04:00
|
|
|
|
2013-01-04 21:02:14 +04:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
nsTextNode::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-04 21:02:14 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return TextBinding::Wrap(aCx, this, aGivenProto);
|
2013-01-04 21:02:14 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTextNode::IsNodeOfType(uint32_t aFlags) const
|
2011-06-14 18:25:51 +04:00
|
|
|
{
|
2011-06-14 11:56:48 +04:00
|
|
|
return !(aFlags & ~(eCONTENT | eTEXT | eDATA_NODE));
|
2011-06-14 18:25:51 +04:00
|
|
|
}
|
|
|
|
|
2005-09-11 21:15:08 +04:00
|
|
|
nsGenericDOMDataNode*
|
2014-06-20 06:01:40 +04:00
|
|
|
nsTextNode::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
1999-12-22 04:51:58 +03:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
|
2014-03-15 23:00:17 +04:00
|
|
|
nsTextNode *it = new nsTextNode(ni);
|
|
|
|
if (aCloneText) {
|
2001-12-16 09:59:31 +03:00
|
|
|
it->mText = mText;
|
1999-12-22 04:51:58 +03:00
|
|
|
}
|
2001-12-16 09:59:31 +03:00
|
|
|
|
2004-05-08 00:55:17 +04:00
|
|
|
return it;
|
2001-12-16 09:59:31 +03:00
|
|
|
}
|
|
|
|
|
2011-08-16 04:55:20 +04:00
|
|
|
nsresult
|
2014-01-04 19:02:17 +04:00
|
|
|
nsTextNode::AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNotify, nsIContent* aNextSibling)
|
2011-08-16 04:55:20 +04:00
|
|
|
{
|
|
|
|
CharacterDataChangeInfo::Details details = {
|
|
|
|
CharacterDataChangeInfo::Details::eMerge, aNextSibling
|
|
|
|
};
|
|
|
|
return SetTextInternal(mText.GetLength(), 0, aBuffer, aLength, aNotify, &details);
|
|
|
|
}
|
|
|
|
|
2012-11-21 14:13:57 +04:00
|
|
|
nsresult
|
|
|
|
nsTextNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent, bool aCompileEventHandlers)
|
|
|
|
{
|
|
|
|
nsresult rv = nsGenericDOMDataNode::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
SetDirectionFromNewTextNode(this);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTextNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
|
|
|
{
|
2015-05-08 03:07:16 +03:00
|
|
|
ResetDirectionSetByTextNode(this);
|
2012-11-21 14:13:57 +04:00
|
|
|
|
|
|
|
nsGenericDOMDataNode::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
2004-01-10 02:54:21 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTextNode::List(FILE* out, int32_t aIndent) const
|
1998-09-06 04:16:36 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index;
|
1998-09-06 04:16:36 +04:00
|
|
|
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
2010-01-18 02:11:02 +03:00
|
|
|
fprintf(out, "Text@%p", static_cast<const void*>(this));
|
2010-05-12 04:30:42 +04:00
|
|
|
fprintf(out, " flags=[%08x]", static_cast<unsigned int>(GetFlags()));
|
2011-12-20 13:15:41 +04:00
|
|
|
if (IsCommonAncestorForRangeInSelection()) {
|
2012-01-10 18:19:54 +04:00
|
|
|
typedef nsTHashtable<nsPtrHashKey<nsRange> > RangeHashTable;
|
2011-12-20 13:15:41 +04:00
|
|
|
RangeHashTable* ranges =
|
|
|
|
static_cast<RangeHashTable*>(GetProperty(nsGkAtoms::range));
|
|
|
|
fprintf(out, " ranges:%d", ranges ? ranges->Count() : 0);
|
|
|
|
}
|
2010-05-01 22:42:47 +04:00
|
|
|
fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
|
2014-03-28 00:38:33 +04:00
|
|
|
fprintf(out, " refcount=%" PRIuPTR "<", mRefCnt.get());
|
1998-09-06 04:16:36 +04:00
|
|
|
|
|
|
|
nsAutoString tmp;
|
2001-12-16 09:59:31 +03:00
|
|
|
ToCString(tmp, 0, mText.GetLength());
|
2006-02-03 17:18:39 +03:00
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
1998-09-06 04:16:36 +04:00
|
|
|
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
|
2004-01-10 02:54:21 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTextNode::DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const
|
2000-05-26 23:45:37 +04:00
|
|
|
{
|
|
|
|
if(aDumpAll) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index;
|
2000-05-26 23:45:37 +04:00
|
|
|
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
nsAutoString tmp;
|
2001-12-16 09:59:31 +03:00
|
|
|
ToCString(tmp, 0, mText.GetLength());
|
|
|
|
|
2004-05-23 02:15:22 +04:00
|
|
|
if(!tmp.EqualsLiteral("\\n")) {
|
2006-02-03 17:18:39 +03:00
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
2000-05-26 23:45:37 +04:00
|
|
|
if(aIndent) fputs("\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2004-01-27 07:22:58 +03:00
|
|
|
|
|
|
|
nsresult
|
2005-09-24 22:43:15 +04:00
|
|
|
NS_NewAttributeContent(nsNodeInfoManager *aNodeInfoManager,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aNameSpaceID, nsIAtom* aAttrName,
|
2005-09-24 22:43:15 +04:00
|
|
|
nsIContent** aResult)
|
2004-01-27 07:22:58 +03:00
|
|
|
{
|
2005-09-24 22:43:15 +04:00
|
|
|
NS_PRECONDITION(aNodeInfoManager, "Missing nodeInfoManager");
|
2004-01-27 07:22:58 +03:00
|
|
|
NS_PRECONDITION(aAttrName, "Must have an attr name");
|
|
|
|
NS_PRECONDITION(aNameSpaceID != kNameSpaceID_Unknown, "Must know namespace");
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*aResult = nullptr;
|
2005-09-11 21:15:08 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo> ni = aNodeInfoManager->GetTextNodeInfo();
|
2005-09-24 22:43:15 +04:00
|
|
|
|
2014-03-15 23:00:17 +04:00
|
|
|
nsAttributeTextNode* textNode = new nsAttributeTextNode(ni,
|
2010-07-23 13:49:57 +04:00
|
|
|
aNameSpaceID,
|
2006-09-20 07:17:11 +04:00
|
|
|
aAttrName);
|
2005-04-06 03:54:35 +04:00
|
|
|
NS_ADDREF(*aResult = textNode);
|
2005-09-24 22:43:15 +04:00
|
|
|
|
2005-04-06 03:54:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-01-27 07:22:58 +03:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(nsAttributeTextNode, nsTextNode,
|
|
|
|
nsIMutationObserver)
|
2006-09-20 07:17:11 +04:00
|
|
|
|
2005-04-06 03:54:35 +04:00
|
|
|
nsresult
|
|
|
|
nsAttributeTextNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCompileEventHandlers)
|
2005-04-06 03:54:35 +04:00
|
|
|
{
|
2008-08-18 05:16:42 +04:00
|
|
|
NS_PRECONDITION(aParent && aParent->GetParent(),
|
|
|
|
"This node can't be a child of the document or of the document root");
|
2004-01-27 07:22:58 +03:00
|
|
|
|
2005-04-06 03:54:35 +04:00
|
|
|
nsresult rv = nsTextNode::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent, aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2008-08-18 05:16:42 +04:00
|
|
|
NS_ASSERTION(!mGrandparent, "We were already bound!");
|
|
|
|
mGrandparent = aParent->GetParent();
|
|
|
|
mGrandparent->AddMutationObserver(this);
|
2006-09-20 07:17:11 +04:00
|
|
|
|
|
|
|
// Note that there is no need to notify here, since we have no
|
|
|
|
// frame yet at this point.
|
2011-10-17 18:59:28 +04:00
|
|
|
UpdateText(false);
|
2004-01-27 07:22:58 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-04-06 03:54:35 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsAttributeTextNode::UnbindFromTree(bool aDeep, bool aNullParent)
|
2005-04-06 03:54:35 +04:00
|
|
|
{
|
2008-08-18 05:16:42 +04:00
|
|
|
// UnbindFromTree can be called anytime so we have to be safe.
|
|
|
|
if (mGrandparent) {
|
|
|
|
// aNullParent might not be true here, but we want to remove the
|
|
|
|
// mutation observer anyway since we only need it while we're
|
|
|
|
// in the document.
|
|
|
|
mGrandparent->RemoveMutationObserver(this);
|
2012-07-30 18:20:58 +04:00
|
|
|
mGrandparent = nullptr;
|
2005-04-06 03:54:35 +04:00
|
|
|
}
|
|
|
|
nsTextNode::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
2004-01-27 07:22:58 +03:00
|
|
|
void
|
2006-09-20 07:17:11 +04:00
|
|
|
nsAttributeTextNode::AttributeChanged(nsIDocument* aDocument,
|
2010-08-24 11:05:56 +04:00
|
|
|
Element* aElement,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aNameSpaceID,
|
2006-09-20 07:17:11 +04:00
|
|
|
nsIAtom* aAttribute,
|
2015-07-25 09:01:19 +03:00
|
|
|
int32_t aModType,
|
|
|
|
const nsAttrValue* aOldValue)
|
2004-01-27 07:22:58 +03:00
|
|
|
{
|
2006-09-20 07:17:11 +04:00
|
|
|
if (aNameSpaceID == mNameSpaceID && aAttribute == mAttrName &&
|
2010-08-24 11:05:56 +04:00
|
|
|
aElement == mGrandparent) {
|
2010-07-21 19:33:32 +04:00
|
|
|
// Since UpdateText notifies, do it when it's safe to run script. Note
|
|
|
|
// that if we get unbound while the event is up that's ok -- we'll just
|
|
|
|
// have no grandparent when it fires, and will do nothing.
|
2010-04-21 03:21:35 +04:00
|
|
|
void (nsAttributeTextNode::*update)() = &nsAttributeTextNode::UpdateText;
|
2016-05-05 11:45:00 +03:00
|
|
|
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update));
|
2006-09-20 07:17:11 +04:00
|
|
|
}
|
|
|
|
}
|
2004-01-27 07:22:58 +03:00
|
|
|
|
2008-10-08 15:13:26 +04:00
|
|
|
void
|
|
|
|
nsAttributeTextNode::NodeWillBeDestroyed(const nsINode* aNode)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aNode == static_cast<nsINode*>(mGrandparent), "Wrong node!");
|
2012-07-30 18:20:58 +04:00
|
|
|
mGrandparent = nullptr;
|
2008-10-08 15:13:26 +04:00
|
|
|
}
|
|
|
|
|
2006-09-20 07:17:11 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsAttributeTextNode::UpdateText(bool aNotify)
|
2006-09-20 07:17:11 +04:00
|
|
|
{
|
2008-08-18 05:16:42 +04:00
|
|
|
if (mGrandparent) {
|
2006-09-20 07:17:11 +04:00
|
|
|
nsAutoString attrValue;
|
2008-08-18 05:16:42 +04:00
|
|
|
mGrandparent->GetAttr(mNameSpaceID, mAttrName, attrValue);
|
2006-09-20 07:17:11 +04:00
|
|
|
SetText(attrValue, aNotify);
|
|
|
|
}
|
|
|
|
}
|
2013-01-04 21:02:14 +04:00
|
|
|
|