2012-11-05 16:58:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementations of DOM Core's nsIDOMComment node.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2013-01-04 17:02:14 +00:00
|
|
|
#include "mozilla/dom/Comment.h"
|
|
|
|
#include "mozilla/dom/CommentBinding.h"
|
2014-03-27 20:38:33 +00:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2012-11-05 16:58:04 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace dom;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
Comment::~Comment()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(Comment, nsGenericDOMDataNode, nsIDOMNode,
|
|
|
|
nsIDOMCharacterData, nsIDOMComment)
|
2012-11-05 16:58:04 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
Comment::IsNodeOfType(uint32_t aFlags) const
|
|
|
|
{
|
|
|
|
return !(aFlags & ~(eCONTENT | eCOMMENT | eDATA_NODE));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericDOMDataNode*
|
2014-06-20 02:01:40 +00:00
|
|
|
Comment::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
2012-11-05 16:58:04 +00:00
|
|
|
{
|
2014-06-20 02:01:40 +00:00
|
|
|
nsRefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
2012-11-05 16:58:04 +00:00
|
|
|
Comment *it = new Comment(ni.forget());
|
|
|
|
if (it && aCloneText) {
|
|
|
|
it->mText = mText;
|
|
|
|
}
|
|
|
|
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
Comment::List(FILE* out, int32_t aIndent) const
|
|
|
|
{
|
|
|
|
int32_t indx;
|
|
|
|
for (indx = aIndent; --indx >= 0; ) fputs(" ", out);
|
|
|
|
|
2014-03-27 20:38:33 +00:00
|
|
|
fprintf(out, "Comment@%p refcount=%" PRIuPTR "<!--", (void*)this, mRefCnt.get());
|
2012-11-05 16:58:04 +00:00
|
|
|
|
|
|
|
nsAutoString tmp;
|
|
|
|
ToCString(tmp, 0, mText.GetLength());
|
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
|
|
|
|
|
|
|
fputs("-->\n", out);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-05-13 13:22:30 +00:00
|
|
|
/* static */ already_AddRefed<Comment>
|
2013-08-23 05:17:08 +00:00
|
|
|
Comment::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aData, ErrorResult& aRv)
|
2013-05-13 13:22:30 +00:00
|
|
|
{
|
2013-08-23 05:17:08 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
2013-05-13 13:22:30 +00:00
|
|
|
if (!window || !window->GetDoc()) {
|
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return window->GetDoc()->CreateComment(aData);
|
|
|
|
}
|
|
|
|
|
2013-01-04 17:02:14 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:17 +00:00
|
|
|
Comment::WrapNode(JSContext *aCx)
|
2013-01-04 17:02:14 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return CommentBinding::Wrap(aCx, this);
|
2013-01-04 17:02:14 +00:00
|
|
|
}
|
|
|
|
|
2012-11-05 16:58:04 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|