mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
37dc78596e
- Bug 1203058 - Set the paint sync id on the top-level window rather than the tab's window, because then it won't get lost during page unload. r=rbarker (977f8909e2)
- Bug 1199283 - nsContentUtils::sIsFrameTimingPrefEnabled should default to false. r=smaug (510c4c4ed1)
- Bug 1237714. Make nsContentUtils::IsCustomElementName faster in the common case of a non-custom-element name. r=smaug (397409f308)
- Bug 1237831 - Use a non-format argument in LogMessageToConsole. r=jst (cc9d2cd390)
- Bug 1208517 - Use the legacy opt-out in CanAccessNativeAnon for now to avoid crashes. r=me (79bd55b387)
- Bug 1230353: P1. Ensure type and subtype of MIME are lowercase. r=bz (09f9a067a6)
- Bug 1230353: P2. Update webref test expected results. r=karlt (4c10a9604c)
- Bug 1227906 - Use unicode flag in pattern attribute. r=jst (d5b4fbae46)
- Bug 1223041 - Emit console warning when document.execCommand('copy'/'cut') is triggered outside of a short-lived user-initiated event, r=bz (b590f3eb86)
- Bug 1235159 - Report pattern compliation failure to web console. r=jst,jorendorff (f4b1ddd863)
- Bug 1000004 - Part a: Remove the unused nsContentUtils::HasPluginWithUncontrolledEventDispatch(nsIDocument*) function; r=jst (d873b1a93e)
- Bug 1000004 - Part b: Inline CheckForWindowedPlugins in its only caller; r=jst (f9a2e5cf64)
- Bug 583170 - Handling IPv6 literal address differently to other browsers r=bz (92abdd56ac)
- Bug 1225829 - Use a temporary string to avoid string type confusion via references. r=jimm (47ae4a8b37)
- Bug 1209841 - Support mouse long tap in SendMouseEvent(). r=smaug (23f308d336)
- Bug 1230563 - Part 1: Cookie permissions should override the CookiesL ifetimePolicy, r=ehsan (d7ecd5e7e0)
- Bug 1230563 - Part 2: Test for corrected cookie permission behavior, r=ehsan (f22ef46565)
- Bug 1241078 - Only treat items as backface hidden if they are 3D-transformed. r=tlee (c52f6804cc)
- Bug 1233098 - Refactor CSP upgrade insecure requests flag within loadInfo (r=sicking) (816d36e5d8)
- remove specific PM hack (a0ed71f7f4)
- Bug 1239397: Send Internal ContentPolicyType to CSP and MixedContent (r=sicking) (7c8da2f1df)
- Bug 1236258 part 1. Remove the unused nsDOMAttributeMap::RemoveAttribute. r=smaug (968d788197)
- Bug 1236258 part 3. Remove the unused aNsAware argument of nsDOMAttributeMap::GetAttribute. r=smaug (224d2e1e91)
- Bug 1236258 part 4. Change nsDOMAttributeMap::SetNamedItemNS to not remove the existing attribute when there is one. r=smaug (f1176918a6)
- Bug 1222079. Fix the behavior of Object.getOwnPropertyNames for nsDOMAttributeMap. r=bzbarsky (3b649bf948)
- Bug 1237580. NamedNodeMap should only claim to support a name if that name has no uppercase ASCII chars, for HTML elements in HTML documents. r=bkelly (216aa3ead6)
- just enable visibilityAPI (3df2d50b5d)
- bits of Bug 1153322 (85ba6268b4)
- Bug 1220160 - part 1: add chromeonly getter for documenturi that returns the original document when on an error page, r=bz (d0c256c29f)
- Bug 1219861 - Remove not-allowed cursor on disabled buttons on in-content pages. r=dao (fa9b2ef2d0)
- Bug 1207146 - Add a link to expert technical information in the cert error page. r=Gijs,keeler (c3292b3fc7)
- Bug 1224433 - Part 3: Compute the invalidation area for preserve-3d layers by accumulating the leaves. r=roc (fffc5a7dfb)
- Bug 1245306: Devirtualize RefreshCompartmentPrincipal. r=smaug (4fa906b7fe)
- Bug 1205298 - Date.parse() should accept a wider range of potential formats; r=jandem (11a0377372)
- Bug 1247807 - Fix Mixed Content UI when using upgrade-insecure-requests (r=bz) (10a0aba8d4)
- Bug 1224694 - Unify and clean up initialization of CSP (r=sicking) (45b6f0a865)
- Bug 1190093 - Stop throttling frame requests for loading pages by checking Hidden(), not isShowing. r=tnikkel (343d2b39fd)
- Bug 1234554 - verify pointer validity and if valid dereference it otherwise use default value. r=jst (8c3265ef33)
- Bug 1240283 - Slim down JSDate instances by not caching cheaply-computed values. r=Waldo (0148f646a2)
- Bug 1217049 - Make Date.prototype.toString.call(<primitive value>) throw a TypeError. r=arai (e8ec69b296)
- Bug 1187233 part 1 - Date constructor should create a copy when called with a Date object. Original patch by Giovanni Sferro. r=jwalden (6a3125c081)
- Bug 1187233 part 2 - Fix test_networkstats_service_proxy.js to not rely on the old behavior. r=jwalden (86461c8aa0)
- Bug 1208023 - Avoid using a bad initial-scale when computing the CSS viewport. r=botond (42e370ce6a)
- Bug 1234025 - Part 1: Move ObjectBox::isModuleBox definition to ParseNode.cpp. (ac4454c20a)
- Bug 1234025 - Part 2: Remove unused functions from ScriptedDirectProxyHandler.cpp. (0ea17c2395)
- Bug 1234025 - Part 3: Remove unused constant from Statistics.cpp (8986c23751)
377 lines
8.5 KiB
C++
377 lines
8.5 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/. */
|
|
|
|
/*
|
|
* Implementation of DOM Core's nsIDOMAttr node.
|
|
*/
|
|
|
|
#include "mozilla/dom/Attr.h"
|
|
#include "mozilla/dom/AttrBinding.h"
|
|
#include "mozilla/dom/Element.h"
|
|
#include "mozilla/EventDispatcher.h"
|
|
#include "mozilla/InternalMutationEvent.h"
|
|
#include "nsContentCreatorFunctions.h"
|
|
#include "nsError.h"
|
|
#include "nsUnicharUtils.h"
|
|
#include "nsDOMString.h"
|
|
#include "nsIContentInlines.h"
|
|
#include "nsIDocument.h"
|
|
#include "nsGkAtoms.h"
|
|
#include "nsCOMArray.h"
|
|
#include "nsNameSpaceManager.h"
|
|
#include "nsNodeUtils.h"
|
|
#include "nsTextNode.h"
|
|
#include "mozAutoDocUpdate.h"
|
|
#include "nsWrapperCacheInlines.h"
|
|
|
|
nsIAttribute::nsIAttribute(nsDOMAttributeMap* aAttrMap,
|
|
already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
|
: nsINode(aNodeInfo), mAttrMap(aAttrMap)
|
|
{
|
|
}
|
|
|
|
nsIAttribute::~nsIAttribute()
|
|
{
|
|
}
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
//----------------------------------------------------------------------
|
|
bool Attr::sInitialized;
|
|
|
|
Attr::Attr(nsDOMAttributeMap *aAttrMap,
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
|
const nsAString &aValue)
|
|
: nsIAttribute(aAttrMap, aNodeInfo), mValue(aValue)
|
|
{
|
|
MOZ_ASSERT(mNodeInfo, "We must get a nodeinfo here!");
|
|
MOZ_ASSERT(mNodeInfo->NodeType() == nsIDOMNode::ATTRIBUTE_NODE,
|
|
"Wrong nodeType");
|
|
|
|
// We don't add a reference to our content. It will tell us
|
|
// to drop our reference when it goes away.
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(Attr)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Attr)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
|
|
if (!nsINode::Traverse(tmp, cb)) {
|
|
return NS_SUCCESS_INTERRUPTED_TRAVERSE;
|
|
}
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAttrMap)
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(Attr)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Attr)
|
|
nsINode::Unlink(tmp);
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAttrMap)
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(Attr)
|
|
Element* ownerElement = tmp->GetElement();
|
|
if (tmp->IsBlack()) {
|
|
if (ownerElement) {
|
|
// The attribute owns the element via attribute map so we can
|
|
// mark it when the attribute is certainly alive.
|
|
mozilla::dom::FragmentOrElement::MarkNodeChildren(ownerElement);
|
|
}
|
|
return true;
|
|
}
|
|
if (ownerElement &&
|
|
mozilla::dom::FragmentOrElement::CanSkip(ownerElement, true)) {
|
|
return true;
|
|
}
|
|
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(Attr)
|
|
return tmp->IsBlackAndDoesNotNeedTracing(static_cast<nsIAttribute*>(tmp));
|
|
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(Attr)
|
|
return tmp->IsBlack();
|
|
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
|
|
|
|
// QueryInterface implementation for Attr
|
|
NS_INTERFACE_TABLE_HEAD(Attr)
|
|
NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
|
|
NS_INTERFACE_TABLE(Attr, nsINode, nsIDOMAttr, nsIAttribute, nsIDOMNode,
|
|
nsIDOMEventTarget, EventTarget)
|
|
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(Attr)
|
|
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
|
|
new nsNodeSupportsWeakRefTearoff(this))
|
|
NS_INTERFACE_MAP_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(Attr)
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(Attr,
|
|
nsNodeUtils::LastRelease(this))
|
|
|
|
void
|
|
Attr::SetMap(nsDOMAttributeMap *aMap)
|
|
{
|
|
if (mAttrMap && !aMap && sInitialized) {
|
|
// We're breaking a relationship with content and not getting a new one,
|
|
// need to locally cache value. GetValue() does that.
|
|
GetValue(mValue);
|
|
}
|
|
|
|
mAttrMap = aMap;
|
|
}
|
|
|
|
Element*
|
|
Attr::GetElement() const
|
|
{
|
|
if (!mAttrMap) {
|
|
return nullptr;
|
|
}
|
|
nsIContent* content = mAttrMap->GetContent();
|
|
return content ? content->AsElement() : nullptr;
|
|
}
|
|
|
|
nsresult
|
|
Attr::SetOwnerDocument(nsIDocument* aDocument)
|
|
{
|
|
NS_ASSERTION(aDocument, "Missing document");
|
|
|
|
nsIDocument *doc = OwnerDoc();
|
|
NS_ASSERTION(doc != aDocument, "bad call to Attr::SetOwnerDocument");
|
|
doc->DeleteAllPropertiesFor(this);
|
|
|
|
RefPtr<mozilla::dom::NodeInfo> newNodeInfo;
|
|
newNodeInfo = aDocument->NodeInfoManager()->
|
|
GetNodeInfo(mNodeInfo->NameAtom(), mNodeInfo->GetPrefixAtom(),
|
|
mNodeInfo->NamespaceID(),
|
|
nsIDOMNode::ATTRIBUTE_NODE);
|
|
NS_ASSERTION(newNodeInfo, "GetNodeInfo lies");
|
|
mNodeInfo.swap(newNodeInfo);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
Attr::GetName(nsAString& aName)
|
|
{
|
|
aName = NodeName();
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
Attr::GetValue(nsAString& aValue)
|
|
{
|
|
Element* element = GetElement();
|
|
if (element) {
|
|
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
|
|
element->GetAttr(mNodeInfo->NamespaceID(), nameAtom, aValue);
|
|
}
|
|
else {
|
|
aValue = mValue;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
Attr::SetValue(const nsAString& aValue, ErrorResult& aRv)
|
|
{
|
|
Element* element = GetElement();
|
|
if (!element) {
|
|
mValue = aValue;
|
|
return;
|
|
}
|
|
|
|
nsCOMPtr<nsIAtom> nameAtom = mNodeInfo->NameAtom();
|
|
aRv = element->SetAttr(mNodeInfo->NamespaceID(),
|
|
nameAtom,
|
|
mNodeInfo->GetPrefixAtom(),
|
|
aValue,
|
|
true);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
Attr::SetValue(const nsAString& aValue)
|
|
{
|
|
ErrorResult rv;
|
|
SetValue(aValue, rv);
|
|
return rv.StealNSResult();
|
|
}
|
|
|
|
bool
|
|
Attr::Specified() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
Attr::GetSpecified(bool* aSpecified)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aSpecified);
|
|
*aSpecified = Specified();
|
|
return NS_OK;
|
|
}
|
|
|
|
Element*
|
|
Attr::GetOwnerElement(ErrorResult& aRv)
|
|
{
|
|
OwnerDoc()->WarnOnceAbout(nsIDocument::eOwnerElement);
|
|
return GetElement();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
Attr::GetOwnerElement(nsIDOMElement** aOwnerElement)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aOwnerElement);
|
|
OwnerDoc()->WarnOnceAbout(nsIDocument::eOwnerElement);
|
|
|
|
Element* element = GetElement();
|
|
if (element) {
|
|
return CallQueryInterface(element, aOwnerElement);
|
|
}
|
|
|
|
*aOwnerElement = nullptr;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
Attr::GetNodeValueInternal(nsAString& aNodeValue)
|
|
{
|
|
OwnerDoc()->WarnOnceAbout(nsIDocument::eNodeValue);
|
|
|
|
GetValue(aNodeValue);
|
|
}
|
|
|
|
void
|
|
Attr::SetNodeValueInternal(const nsAString& aNodeValue, ErrorResult& aError)
|
|
{
|
|
OwnerDoc()->WarnOnceAbout(nsIDocument::eNodeValue);
|
|
|
|
aError = SetValue(aNodeValue);
|
|
}
|
|
|
|
nsresult
|
|
Attr::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
|
|
{
|
|
nsAutoString value;
|
|
const_cast<Attr*>(this)->GetValue(value);
|
|
|
|
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
|
*aResult = new Attr(nullptr, ni.forget(), value);
|
|
if (!*aResult) {
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
already_AddRefed<nsIURI>
|
|
Attr::GetBaseURI(bool aTryUseXHRDocBaseURI) const
|
|
{
|
|
Element* parent = GetElement();
|
|
|
|
return parent ? parent->GetBaseURI(aTryUseXHRDocBaseURI) : nullptr;
|
|
}
|
|
|
|
void
|
|
Attr::GetTextContentInternal(nsAString& aTextContent,
|
|
ErrorResult& aError)
|
|
{
|
|
OwnerDoc()->WarnOnceAbout(nsIDocument::eTextContent);
|
|
|
|
GetValue(aTextContent);
|
|
}
|
|
|
|
void
|
|
Attr::SetTextContentInternal(const nsAString& aTextContent,
|
|
ErrorResult& aError)
|
|
{
|
|
OwnerDoc()->WarnOnceAbout(nsIDocument::eTextContent);
|
|
|
|
SetNodeValueInternal(aTextContent, aError);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
Attr::GetIsId(bool* aReturn)
|
|
{
|
|
*aReturn = mNodeInfo->Equals(nsGkAtoms::id, kNameSpaceID_None);
|
|
return NS_OK;
|
|
}
|
|
|
|
bool
|
|
Attr::IsNodeOfType(uint32_t aFlags) const
|
|
{
|
|
return !(aFlags & ~eATTRIBUTE);
|
|
}
|
|
|
|
uint32_t
|
|
Attr::GetChildCount() const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
nsIContent *
|
|
Attr::GetChildAt(uint32_t aIndex) const
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
nsIContent * const *
|
|
Attr::GetChildArray(uint32_t* aChildCount) const
|
|
{
|
|
*aChildCount = 0;
|
|
return nullptr;
|
|
}
|
|
|
|
int32_t
|
|
Attr::IndexOf(const nsINode* aPossibleChild) const
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
nsresult
|
|
Attr::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
|
bool aNotify)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
void
|
|
Attr::RemoveChildAt(uint32_t aIndex, bool aNotify)
|
|
{
|
|
}
|
|
|
|
nsresult
|
|
Attr::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
|
{
|
|
aVisitor.mCanHandle = true;
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
Attr::Initialize()
|
|
{
|
|
sInitialized = true;
|
|
}
|
|
|
|
void
|
|
Attr::Shutdown()
|
|
{
|
|
sInitialized = false;
|
|
}
|
|
|
|
JSObject*
|
|
Attr::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return AttrBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|