2010-06-19 18:44:43 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2010-06-19 18:44:43 +00:00
|
|
|
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-11-22 11:09:57 +00:00
|
|
|
#include "mozilla/dom/HTMLElementBinding.h"
|
2012-12-21 14:06:50 +00:00
|
|
|
#include "nsContentUtils.h"
|
2011-08-11 13:29:50 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-06-19 18:44:43 +00:00
|
|
|
|
2013-08-07 20:23:08 +00:00
|
|
|
class HTMLElement MOZ_FINAL : public nsGenericHTMLElement
|
2010-06-19 18:44:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2012-12-21 14:06:50 +00:00
|
|
|
virtual ~HTMLElement();
|
2010-06-19 18:44:43 +00:00
|
|
|
|
2013-10-08 19:25:01 +00:00
|
|
|
NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) MOZ_OVERRIDE;
|
2010-07-17 14:00:27 +00:00
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo,
|
2012-12-21 14:06:50 +00:00
|
|
|
nsINode** aResult) const MOZ_OVERRIDE;
|
2010-07-23 09:49:57 +00:00
|
|
|
|
2012-11-22 11:09:57 +00:00
|
|
|
protected:
|
2014-04-08 22:27:17 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;
|
2010-06-19 18:44:43 +00:00
|
|
|
};
|
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
HTMLElement::HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2010-06-19 18:44:43 +00:00
|
|
|
: nsGenericHTMLElement(aNodeInfo)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLElement::~HTMLElement()
|
2010-06-19 18:44:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLElement)
|
2010-06-19 18:44:43 +00:00
|
|
|
|
2013-10-08 19:25:01 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLElement::GetInnerHTML(nsAString& aInnerHTML)
|
2010-07-17 14:00:27 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* nsGenericHTMLElement::GetInnerHTML escapes < and > characters (at least).
|
|
|
|
* .innerHTML should return the HTML code for xmp and plaintext element.
|
|
|
|
*
|
|
|
|
* This code is a workaround until we implement a HTML5 Serializer
|
|
|
|
* with this behavior.
|
|
|
|
*/
|
|
|
|
if (mNodeInfo->Equals(nsGkAtoms::xmp) ||
|
|
|
|
mNodeInfo->Equals(nsGkAtoms::plaintext)) {
|
2014-03-19 17:05:03 +00:00
|
|
|
if (!nsContentUtils::GetNodeTextContent(this, false, aInnerHTML)) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2013-10-08 19:25:01 +00:00
|
|
|
return NS_OK;
|
2010-07-17 14:00:27 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 19:25:01 +00:00
|
|
|
return nsGenericHTMLElement::GetInnerHTML(aInnerHTML);
|
2010-07-17 14:00:27 +00:00
|
|
|
}
|
|
|
|
|
2012-11-22 11:09:57 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:17 +00:00
|
|
|
HTMLElement::WrapNode(JSContext *aCx)
|
2012-11-22 11:09:57 +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 dom::HTMLElementBinding::Wrap(aCx, this);
|
2012-11-22 11:09:57 +00:00
|
|
|
}
|
2012-12-21 14:06:50 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
// Here, we expand 'NS_IMPL_NS_NEW_HTML_ELEMENT()' by hand.
|
|
|
|
// (Calling the macro directly (with no args) produces compiler warnings.)
|
|
|
|
nsGenericHTMLElement*
|
2014-06-20 02:01:40 +00:00
|
|
|
NS_NewHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2012-12-21 14:06:50 +00:00
|
|
|
mozilla::dom::FromParser aFromParser)
|
|
|
|
{
|
|
|
|
return new mozilla::dom::HTMLElement(aNodeInfo);
|
|
|
|
}
|