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: */
|
2013-02-07 00:08:58 -08: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/. */
|
|
|
|
|
2014-03-16 23:56:54 -07:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2013-02-07 00:08:58 -08:00
|
|
|
#include "mozilla/dom/HTMLMetaElement.h"
|
2013-02-07 00:08:58 -08:00
|
|
|
#include "mozilla/dom/HTMLMetaElementBinding.h"
|
2013-02-07 00:08:58 -08:00
|
|
|
#include "nsContentUtils.h"
|
2014-03-16 23:56:54 -07:00
|
|
|
#include "nsStyleConsts.h"
|
2013-02-07 00:08:58 -08:00
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Meta)
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
HTMLMetaElement::HTMLMetaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-02-07 00:08:58 -08:00
|
|
|
: nsGenericHTMLElement(aNodeInfo)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
HTMLMetaElement::~HTMLMetaElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(HTMLMetaElement, nsGenericHTMLElement,
|
|
|
|
nsIDOMHTMLMetaElement)
|
2013-02-07 00:08:58 -08:00
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLMetaElement)
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLMetaElement, Content, content)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLMetaElement, HttpEquiv, httpEquiv)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLMetaElement, Name, name)
|
|
|
|
NS_IMPL_STRING_ATTR(HTMLMetaElement, Scheme, scheme)
|
|
|
|
|
|
|
|
void
|
2015-02-12 17:27:39 -08:00
|
|
|
HTMLMetaElement::GetItemValueText(DOMString& aValue)
|
2013-02-07 00:08:58 -08:00
|
|
|
{
|
|
|
|
GetContent(aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLMetaElement::SetItemValueText(const nsAString& aValue)
|
|
|
|
{
|
|
|
|
SetContent(aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-12 04:28:48 -07:00
|
|
|
nsresult
|
|
|
|
HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue, bool aNotify)
|
|
|
|
{
|
|
|
|
if (aNameSpaceID == kNameSpaceID_None) {
|
|
|
|
if (aName == nsGkAtoms::content) {
|
2014-10-02 12:07:24 -07:00
|
|
|
nsIDocument *document = GetUncomposedDoc();
|
2014-07-12 04:28:48 -07:00
|
|
|
CreateAndDispatchEvent(document, NS_LITERAL_STRING("DOMMetaChanged"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
|
|
|
|
aNotify);
|
|
|
|
}
|
|
|
|
|
2013-02-07 00:08:58 -08:00
|
|
|
nsresult
|
|
|
|
HTMLMetaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (aDocument &&
|
|
|
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::viewport, eIgnoreCase)) {
|
|
|
|
nsAutoString content;
|
|
|
|
rv = GetContent(content);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2014-11-18 05:46:29 -08:00
|
|
|
nsContentUtils::ProcessViewportInfo(aDocument, content);
|
|
|
|
}
|
|
|
|
if (aDocument &&
|
|
|
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::referrer, eIgnoreCase)) {
|
|
|
|
nsAutoString content;
|
|
|
|
rv = GetContent(content);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Referrer Policy spec requires a <meta name="referrer" tag to be in the
|
|
|
|
// <head> element.
|
|
|
|
Element* headElt = aDocument->GetHeadElement();
|
|
|
|
if (headElt && nsContentUtils::ContentIsDescendantOf(this, headElt)) {
|
|
|
|
content = nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(content);
|
|
|
|
aDocument->SetHeaderData(nsGkAtoms::referrer, content);
|
|
|
|
}
|
2013-02-07 00:08:58 -08:00
|
|
|
}
|
|
|
|
CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMMetaAdded"));
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLMetaElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
|
|
|
{
|
2014-10-02 12:07:24 -07:00
|
|
|
nsCOMPtr<nsIDocument> oldDoc = GetUncomposedDoc();
|
2013-02-07 00:08:58 -08:00
|
|
|
CreateAndDispatchEvent(oldDoc, NS_LITERAL_STRING("DOMMetaRemoved"));
|
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HTMLMetaElement::CreateAndDispatchEvent(nsIDocument* aDoc,
|
|
|
|
const nsAString& aEventName)
|
|
|
|
{
|
|
|
|
if (!aDoc)
|
|
|
|
return;
|
|
|
|
|
2014-03-16 23:56:54 -07:00
|
|
|
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
|
|
|
|
new AsyncEventDispatcher(this, aEventName, true, true);
|
|
|
|
asyncDispatcher->PostDOMEvent();
|
2013-02-07 00:08:58 -08:00
|
|
|
}
|
|
|
|
|
2013-02-07 00:08:58 -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
|
|
|
HTMLMetaElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-02-07 00:08:58 -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 HTMLMetaElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-07 00:08:58 -08:00
|
|
|
}
|
|
|
|
|
2013-02-07 00:08:58 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|