Bug 1292618: Add Gecko_CopyStyleContentsFrom. r?heycam draft
authorEmilio Cobos Álvarez <ecoal95@gmail.com>
Tue, 16 Aug 2016 12:07:17 -0700
changeset 401338 394f71df5d69fa1744c4fd36b6b87a677450e10e
parent 401337 408a73703e078035d891efce901a397ffd13925b
child 528467 31ac1b7ed7e88931a42a257a3f0ea4dc6bf2c954
push id26436
push userbmo:ealvarez@mozilla.com
push dateTue, 16 Aug 2016 21:55:11 +0000
reviewersheycam
bugs1292618
milestone51.0a1
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
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- 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);