summaryrefslogtreecommitdiffstats
path: root/dom/base/nsMappedAttributes.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-04-17 16:02:56 +0200
committerGitHub <noreply@github.com>2020-04-17 16:02:56 +0200
commitd5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf (patch)
tree2bfef192cbb748b675ce8308c242a376798e265d /dom/base/nsMappedAttributes.cpp
parent5caf99795aa81e1fc145b8e937b1ee8197ed2486 (diff)
parentf35aa3e15fedf3cd4ad163d60ab74a9537ca5c82 (diff)
downloadUXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.tar
UXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.tar.gz
UXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.tar.lz
UXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.tar.xz
UXP-d5102d6beafc2a2a0cec3cc3ee5f7ebde31ae7bf.zip
Merge pull request #1518 from MoonchildProductions/shadowdom-merge
Incremental shadowdom-merge
Diffstat (limited to 'dom/base/nsMappedAttributes.cpp')
-rw-r--r--dom/base/nsMappedAttributes.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/dom/base/nsMappedAttributes.cpp b/dom/base/nsMappedAttributes.cpp
index a3accd2a7..05ad42310 100644
--- a/dom/base/nsMappedAttributes.cpp
+++ b/dom/base/nsMappedAttributes.cpp
@@ -62,11 +62,17 @@ nsMappedAttributes::Clone(bool aWillAddAttr)
void* nsMappedAttributes::operator new(size_t aSize, uint32_t aAttrCount) CPP_THROW_NEW
{
- NS_ASSERTION(aAttrCount > 0, "zero-attribute nsMappedAttributes requested");
+ size_t size = aSize + aAttrCount * sizeof(InternalAttr);
// aSize will include the mAttrs buffer so subtract that.
- void* newAttrs = ::operator new(aSize - sizeof(void*[1]) +
- aAttrCount * sizeof(InternalAttr));
+ // We don't want to under-allocate, however, so do not subtract
+ // if we have zero attributes. The zero attribute case only happens
+ // for <body>'s mapped attributes
+ if (aAttrCount != 0) {
+ size -= sizeof(void*[1]);
+ }
+
+ void* newAttrs = ::operator new(size);
#ifdef DEBUG
static_cast<nsMappedAttributes*>(newAttrs)->mBufferSize = aAttrCount;
@@ -79,15 +85,16 @@ NS_IMPL_ISUPPORTS(nsMappedAttributes,
nsIStyleRule)
void
-nsMappedAttributes::SetAndTakeAttr(nsIAtom* aAttrName, nsAttrValue& aValue)
+nsMappedAttributes::SetAndSwapAttr(nsIAtom* aAttrName, nsAttrValue& aValue,
+ bool* aValueWasSet)
{
NS_PRECONDITION(aAttrName, "null name");
-
+ *aValueWasSet = false;
uint32_t i;
for (i = 0; i < mAttrCount && !Attrs()[i].mName.IsSmaller(aAttrName); ++i) {
if (Attrs()[i].mName.Equals(aAttrName)) {
- Attrs()[i].mValue.Reset();
Attrs()[i].mValue.SwapValueWith(aValue);
+ *aValueWasSet = true;
return;
}
}