summaryrefslogtreecommitdiffstats
path: root/dom/base
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 05:07:41 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 05:07:41 -0400
commit5f297c5f57583b0f9d27d714beb285919f42d655 (patch)
treef67fd1bafe4c449fc6527e172deb59411bfbf85f /dom/base
parentf07f8aecb8a03d33d0b90d685d85960a29543c75 (diff)
downloadUXP-5f297c5f57583b0f9d27d714beb285919f42d655.tar
UXP-5f297c5f57583b0f9d27d714beb285919f42d655.tar.gz
UXP-5f297c5f57583b0f9d27d714beb285919f42d655.tar.lz
UXP-5f297c5f57583b0f9d27d714beb285919f42d655.tar.xz
UXP-5f297c5f57583b0f9d27d714beb285919f42d655.zip
Issue #1375 - Include content rules from HTMLTableCellElement::WalkContentStyleRules and move to the mapped attr functionality
* Bugs 1341647 and 1341648
Diffstat (limited to 'dom/base')
-rw-r--r--dom/base/nsAttrAndChildArray.cpp13
-rw-r--r--dom/base/nsAttrAndChildArray.h6
-rw-r--r--dom/base/nsFrameLoader.cpp3
-rw-r--r--dom/base/nsMappedAttributes.cpp12
4 files changed, 28 insertions, 6 deletions
diff --git a/dom/base/nsAttrAndChildArray.cpp b/dom/base/nsAttrAndChildArray.cpp
index 9fd27262b..4daac498b 100644
--- a/dom/base/nsAttrAndChildArray.cpp
+++ b/dom/base/nsAttrAndChildArray.cpp
@@ -714,10 +714,19 @@ nsAttrAndChildArray::MappedAttrCount() const
return mImpl && mImpl->mMappedAttrs ? (uint32_t)mImpl->mMappedAttrs->Count() : 0;
}
+nsresult
+nsAttrAndChildArray::ForceMapped(nsMappedAttributeElement* aContent, nsIDocument* aDocument)
+{
+ nsHTMLStyleSheet* sheet = aDocument->GetAttributeStyleSheet();
+ RefPtr<nsMappedAttributes> mapped = GetModifiableMapped(aContent, sheet, false, 0);
+ return MakeMappedUnique(mapped);
+}
+
nsMappedAttributes*
nsAttrAndChildArray::GetModifiableMapped(nsMappedAttributeElement* aContent,
nsHTMLStyleSheet* aSheet,
- bool aWillAddAttr)
+ bool aWillAddAttr,
+ int32_t aAttrCount)
{
if (mImpl && mImpl->mMappedAttrs) {
return mImpl->mMappedAttrs->Clone(aWillAddAttr);
@@ -727,7 +736,7 @@ nsAttrAndChildArray::GetModifiableMapped(nsMappedAttributeElement* aContent,
nsMapRuleToAttributesFunc mapRuleFunc =
aContent->GetAttributeMappingFunction();
- return new nsMappedAttributes(aSheet, mapRuleFunc);
+ return new (aAttrCount) nsMappedAttributes(aSheet, mapRuleFunc);
}
nsresult
diff --git a/dom/base/nsAttrAndChildArray.h b/dom/base/nsAttrAndChildArray.h
index f34370c43..ffbad196c 100644
--- a/dom/base/nsAttrAndChildArray.h
+++ b/dom/base/nsAttrAndChildArray.h
@@ -135,6 +135,9 @@ public:
return MappedAttrCount();
}
+ // Force this to have mapped attributes, even if those attributes are empty.
+ nsresult ForceMapped(nsMappedAttributeElement* aContent, nsIDocument* aDocument);
+
private:
nsAttrAndChildArray(const nsAttrAndChildArray& aOther) = delete;
nsAttrAndChildArray& operator=(const nsAttrAndChildArray& aOther) = delete;
@@ -148,7 +151,8 @@ private:
nsMappedAttributes*
GetModifiableMapped(nsMappedAttributeElement* aContent,
nsHTMLStyleSheet* aSheet,
- bool aWillAddAttr);
+ bool aWillAddAttr,
+ int32_t aAttrCount = 1);
nsresult MakeMappedUnique(nsMappedAttributes* aAttributes);
uint32_t AttrSlotsSize() const
diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp
index 2804f2d4c..942a84102 100644
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -57,6 +57,7 @@
#include "nsGlobalWindow.h"
#include "nsPIWindowRoot.h"
#include "nsLayoutUtils.h"
+#include "nsMappedAttributes.h"
#include "nsView.h"
#include "GroupedSHistory.h"
#include "PartialSHistory.h"
@@ -936,6 +937,8 @@ nsFrameLoader::MarginsChanged(uint32_t aMarginWidth,
RefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
if (presContext)
+ // rebuild, because now the same nsMappedAttributes* will produce
+ // a different style
presContext->RebuildAllStyleData(nsChangeHint(0), eRestyle_Subtree);
}
diff --git a/dom/base/nsMappedAttributes.cpp b/dom/base/nsMappedAttributes.cpp
index a3accd2a7..9e80c94df 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;