2015-05-03 12:32:37 -07: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 04:12:37 -07: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 11:44:43 -07:00
|
|
|
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-11-22 03:09:57 -08:00
|
|
|
#include "mozilla/dom/HTMLElementBinding.h"
|
2012-12-21 06:06:50 -08:00
|
|
|
#include "nsContentUtils.h"
|
2011-08-11 06:29:50 -07:00
|
|
|
|
2012-12-21 06:06:50 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-06-19 11:44:43 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class HTMLElement final : public nsGenericHTMLElement
|
2010-06-19 11:44:43 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2012-12-21 06:06:50 -08:00
|
|
|
virtual ~HTMLElement();
|
2010-06-19 11:44:43 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) override;
|
2010-07-17 07:00:27 -07:00
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsINode** aResult) const override;
|
2010-07-23 02:49:57 -07:00
|
|
|
|
2012-11-22 03:09:57 -08:00
|
|
|
protected:
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2010-06-19 11:44:43 -07:00
|
|
|
};
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
HTMLElement::HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2010-06-19 11:44:43 -07:00
|
|
|
: nsGenericHTMLElement(aNodeInfo)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 06:06:50 -08:00
|
|
|
HTMLElement::~HTMLElement()
|
2010-06-19 11:44:43 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 06:06:50 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLElement)
|
2010-06-19 11:44:43 -07:00
|
|
|
|
2013-10-08 12:25:01 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLElement::GetInnerHTML(nsAString& aInnerHTML)
|
2010-07-17 07:00:27 -07: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 10:05:03 -07:00
|
|
|
if (!nsContentUtils::GetNodeTextContent(this, false, aInnerHTML)) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2013-10-08 12:25:01 -07:00
|
|
|
return NS_OK;
|
2010-07-17 07:00:27 -07:00
|
|
|
}
|
|
|
|
|
2013-10-08 12:25:01 -07:00
|
|
|
return nsGenericHTMLElement::GetInnerHTML(aInnerHTML);
|
2010-07-17 07:00:27 -07:00
|
|
|
}
|
|
|
|
|
2012-11-22 03:09:57 -08: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 07:13:33 -07:00
|
|
|
HTMLElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-11-22 03:09:57 -08: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 07:13:33 -07:00
|
|
|
return dom::HTMLElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-11-22 03:09:57 -08:00
|
|
|
}
|
2012-12-21 06:06:50 -08: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-19 19:01:40 -07:00
|
|
|
NS_NewHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2012-12-21 06:06:50 -08:00
|
|
|
mozilla::dom::FromParser aFromParser)
|
|
|
|
{
|
|
|
|
return new mozilla::dom::HTMLElement(aNodeInfo);
|
|
|
|
}
|