Bug 1440384 - Generate combined transform just once. r=boris

Differential Revision: https://phabricator.services.mozilla.com/D18567
This commit is contained in:
Emilio Cobos Álvarez 2019-02-04 16:57:12 +01:00
parent 042d371291
commit 38e4d112d2
6 changed files with 18 additions and 10 deletions

View File

@ -1761,6 +1761,10 @@ nsCSSValueSharedList* Gecko_NewNoneTransform() {
return list.forget().take();
}
void Gecko_StyleDisplay_GenerateCombinedTransform(nsStyleDisplay* aDisplay) {
aDisplay->GenerateCombinedIndividualTransform();
}
void Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut aCSSValue, float aNumber) {
aCSSValue->SetFloatValue(aNumber, eCSSUnit_Number);
}

View File

@ -587,6 +587,7 @@ NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray);
nsCSSValueSharedList* Gecko_NewCSSValueSharedList(uint32_t len);
nsCSSValueSharedList* Gecko_NewNoneTransform();
void Gecko_StyleDisplay_GenerateCombinedTransform(nsStyleDisplay*);
// Getter for nsCSSValue
nsCSSValueBorrowedMut Gecko_CSSValue_GetArrayItem(

View File

@ -3066,7 +3066,9 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
mSpecifiedRotate(aSource.mSpecifiedRotate),
mSpecifiedTranslate(aSource.mSpecifiedTranslate),
mSpecifiedScale(aSource.mSpecifiedScale),
mIndividualTransform(aSource.mIndividualTransform),
// We intentionally leave mIndividualTransform as null, is the caller's
// responsibility to call GenerateCombinedIndividualTransform when
// appropriate.
mMotion(aSource.mMotion ? MakeUnique<StyleMotion>(*aSource.mMotion)
: nullptr),
mTransformOrigin{aSource.mTransformOrigin[0], aSource.mTransformOrigin[1],
@ -3138,7 +3140,6 @@ void nsStyleDisplay::FinishStyle(Document& aDocument,
mShapeOutside.FinishStyle(aDocument,
aOldStyle ? &aOldStyle->mShapeOutside : nullptr);
GenerateCombinedIndividualTransform();
}
static inline bool TransformListChanged(
@ -3431,11 +3432,7 @@ bool nsStyleDisplay::TransformChanged(const nsStyleDisplay& aNewData) const {
}
void nsStyleDisplay::GenerateCombinedIndividualTransform() {
// FIXME(emilio): This should probably be called from somewhere like what we
// do for image layers, instead of FinishStyle.
//
// This does and undoes the work a ton of times in Stylo.
mIndividualTransform = nullptr;
MOZ_ASSERT(!mIndividualTransform);
// Follow the order defined in the spec to append transform functions.
// https://drafts.csswg.org/css-transforms-2/#ctm

View File

@ -2306,9 +2306,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
return mIndividualTransform ? do_AddRef(mIndividualTransform) : nullptr;
}
private:
// Helpers for above functions, which do some but not all of the tests
// for them (since transform must be tested separately for each).
void GenerateCombinedIndividualTransform();
};

View File

@ -629,6 +629,10 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
#[cfg(feature = "gecko")]
{
if let Some(display) = builder.get_box_if_mutated() {
display.generate_combined_transform();
}
if let Some(bg) = builder.get_background_if_mutated() {
bg.fill_arrays();
}

View File

@ -3023,6 +3023,11 @@ fn static_assert() {
will-change shape-outside contain touch-action
translate scale""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
#[inline]
pub fn generate_combined_transform(&mut self) {
unsafe { bindings::Gecko_StyleDisplay_GenerateCombinedTransform(&mut self.gecko) };
}
#[inline]
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
self.gecko.mDisplay = v;