Bug 1292618: Add Gecko_CopyStyleContentsFrom. r?heycam
This allows to copy the `content` property value from one nsStyleContent to
another, in order to implement content: inherit.
MozReview-Commit-ID: 75mQpGRKKba
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -724,16 +724,28 @@ Gecko_ClearPODTArray(void* aArray, size_
void
Gecko_ClearStyleContents(nsStyleContent* aContent)
{
aContent->AllocateContents(0);
}
void
+Gecko_CopyStyleContentsFrom(nsStyleContent* aContent, const nsStyleContent* aOther)
+{
+ uint32_t count = aOther->ContentCount();
+
+ aContent->AllocateContents(count);
+
+ for (uint32_t i = 0; i < count; ++i) {
+ aContent->ContentAt(i) = aOther->ContentAt(i);
+ }
+}
+
+void
Gecko_EnsureImageLayersLength(nsStyleImageLayers* aLayers, size_t aLen)
{
aLayers->mLayers.EnsureLengthAtLeast(aLen);
}
void
Gecko_InitializeImageLayer(nsStyleImageLayers::Layer* aLayer,
nsStyleImageLayers::LayerType aLayerType)
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -209,16 +209,18 @@ void Gecko_EnsureTArrayCapacity(void* ar
// Important note: Only valid for POD types, since destructors won't be run
// otherwise. This is ensured with rust traits for the relevant structs.
void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align);
// Clear the mContents field in nsStyleContent. This is needed to run the
// destructors, otherwise we'd leak the images (though we still don't support
// those), strings, and whatnot.
void Gecko_ClearStyleContents(nsStyleContent* content);
+void Gecko_CopyStyleContentsFrom(nsStyleContent* content, const nsStyleContent* other);
+
void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len);
void Gecko_InitializeImageLayer(nsStyleImageLayers::Layer* layer,
nsStyleImageLayers::LayerType layer_type);
// Clean up pointer-based coordinates
void Gecko_ResetStyleCoord(nsStyleUnit* unit, nsStyleUnion* value);