2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#ifndef DOM_SMIL_SMILCOMPOSITOR_H_
|
|
|
|
#define DOM_SMIL_SMILCOMPOSITOR_H_
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2020-01-20 19:18:20 +03:00
|
|
|
#include <utility>
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
|
|
|
|
#include "PLDHashTable.h"
|
|
|
|
#include "SMILTargetIdentifier.h"
|
2019-01-01 12:16:21 +03:00
|
|
|
#include "mozilla/SMILAnimationFunction.h"
|
|
|
|
#include "mozilla/SMILCompositorTable.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "nsCSSPropertyID.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
#include "nsString.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsTHashtable.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-01 12:16:21 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2020-11-23 19:21:38 +03:00
|
|
|
class ComputedStyle;
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
//----------------------------------------------------------------------
|
2019-01-01 12:16:21 +03:00
|
|
|
// SMILCompositor
|
2009-01-15 07:38:07 +03:00
|
|
|
//
|
|
|
|
// Performs the composition of the animation sandwich by combining the results
|
|
|
|
// of a series animation functions according to the rules of SMIL composition
|
|
|
|
// including prioritising animations.
|
|
|
|
|
2019-01-01 12:16:21 +03:00
|
|
|
class SMILCompositor : public PLDHashEntryHdr {
|
2009-01-15 07:38:07 +03:00
|
|
|
public:
|
2020-07-15 13:37:55 +03:00
|
|
|
using KeyType = SMILTargetIdentifier;
|
|
|
|
using KeyTypeRef = const KeyType&;
|
|
|
|
using KeyTypePointer = const KeyType*;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2019-01-01 12:16:21 +03:00
|
|
|
explicit SMILCompositor(KeyTypePointer aKey)
|
2011-10-17 18:59:28 +04:00
|
|
|
: mKey(*aKey), mForceCompositing(false) {}
|
2019-04-24 23:39:47 +03:00
|
|
|
SMILCompositor(SMILCompositor&& toMove) noexcept
|
Bug 1415980 - make hash keys movable and not copyable; r=erahm
Everything that goes in a PLDHashtable (and its derivatives, like
nsTHashtable) needs to inherit from PLDHashEntryHdr. But through a lack
of enforcement, copy constructors for these derived classes didn't
explicitly invoke the copy constructor for PLDHashEntryHdr (and the
compiler didn't invoke the copy constructor for us). Instead,
PLDHashTable explicitly copied around the bits that the copy constructor
would have.
The current setup has two problems:
1) Derived classes should be using move construction, not copy
construction, since anything that's shuffling hash table keys/entries
around will be using move construction.
2) Derived classes should take responsibility for transferring bits of
superclass state around, and not rely on something else to handle that.
The second point is not a huge problem for PLDHashTable (PLDHashTable
only has to copy PLDHashEntryHdr's bits in a single place), but future
hash table implementations that might move entries around more
aggressively would have to insert compensation code all over the
place. Additionally, if moving entries is implemented via memcpy (which
is quite common), PLDHashTable copying around bits *again* is
inefficient.
Let's fix all these problems in one go, by:
1) Explicitly declaring the set of constructors that PLDHashEntryHdr
implements (and does not implement). In particular, the copy
constructor is deleted, so any derived classes that attempt to make
themselves copyable will be detected at compile time: the compiler
will complain that the superclass type is not copyable.
This change on its own will result in many compiler errors, so...
2) Change any derived classes to implement move constructors instead of
copy constructors. Note that some of these move constructors are,
strictly speaking, unnecessary, since the relevant classes are moved
via memcpy in nsTHashtable and its derivatives.
2018-09-20 18:20:36 +03:00
|
|
|
: PLDHashEntryHdr(std::move(toMove)),
|
|
|
|
mKey(std::move(toMove.mKey)),
|
2018-05-30 22:15:35 +03:00
|
|
|
mAnimationFunctions(std::move(toMove.mAnimationFunctions)),
|
2011-10-17 18:59:28 +04:00
|
|
|
mForceCompositing(false) {}
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
// PLDHashEntryHdr methods
|
2010-02-21 00:13:11 +03:00
|
|
|
KeyTypeRef GetKey() const { return mKey; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool KeyEquals(KeyTypePointer aKey) const;
|
2010-02-21 00:13:11 +03:00
|
|
|
static KeyTypePointer KeyToPointer(KeyTypeRef aKey) { return &aKey; }
|
2009-01-15 07:38:07 +03:00
|
|
|
static PLDHashNumber HashKey(KeyTypePointer aKey);
|
2011-10-17 18:59:28 +04:00
|
|
|
enum { ALLOW_MEMMOVE = false };
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
// Adds the given animation function to this Compositor's list of functions
|
2019-01-01 12:16:21 +03:00
|
|
|
void AddAnimationFunction(SMILAnimationFunction* aFunc);
|
2009-07-15 22:33:31 +04:00
|
|
|
|
2009-07-14 23:33:29 +04:00
|
|
|
// Composes the attribute's current value with the list of animation
|
|
|
|
// functions, and assigns the resulting value to this compositor's target
|
2016-05-23 04:47:14 +03:00
|
|
|
// attribute. If a change is made that might produce style updates,
|
|
|
|
// aMightHavePendingStyleUpdates is set to true. Otherwise it is not modified.
|
|
|
|
void ComposeAttribute(bool& aMightHavePendingStyleUpdates);
|
2009-07-14 23:33:29 +04:00
|
|
|
|
|
|
|
// Clears animation effects on my target attribute
|
|
|
|
void ClearAnimationEffects();
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
// Cycle-collection support
|
|
|
|
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
|
|
|
|
|
2010-02-21 00:13:11 +03:00
|
|
|
// Toggles a bit that will force us to composite (bypassing early-return
|
|
|
|
// optimizations) when we hit ComposeAttribute.
|
2011-10-17 18:59:28 +04:00
|
|
|
void ToggleForceCompositing() { mForceCompositing = true; }
|
2010-02-21 00:13:11 +03:00
|
|
|
|
2010-02-21 00:13:11 +03:00
|
|
|
// Transfers |aOther|'s mCachedBaseValue to |this|
|
2019-01-01 12:16:21 +03:00
|
|
|
void StealCachedBaseValue(SMILCompositor* aOther) {
|
2018-05-30 22:15:35 +03:00
|
|
|
mCachedBaseValue = std::move(aOther->mCachedBaseValue);
|
2010-02-21 00:13:11 +03:00
|
|
|
}
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
private:
|
2019-01-25 06:24:01 +03:00
|
|
|
// Create a SMILAttr for my target, on the heap.
|
2017-04-03 10:49:10 +03:00
|
|
|
//
|
2018-03-23 16:49:21 +03:00
|
|
|
// @param aBaseComputedStyle An optional ComputedStyle which, if set, will be
|
2017-04-03 10:49:10 +03:00
|
|
|
// used when fetching the base style.
|
2019-01-25 06:24:01 +03:00
|
|
|
UniquePtr<SMILAttr> CreateSMILAttr(ComputedStyle* aBaseComputedStyle);
|
2016-05-23 04:47:14 +03:00
|
|
|
|
2017-03-30 07:10:08 +03:00
|
|
|
// Returns the CSS property this compositor should animate, or
|
|
|
|
// eCSSProperty_UNKNOWN if this compositor does not animate a CSS property.
|
|
|
|
nsCSSPropertyID GetCSSPropertyToAnimate() const;
|
|
|
|
|
2017-04-03 10:49:09 +03:00
|
|
|
// Returns true if we might need to refer to base styles (i.e. we are
|
|
|
|
// targeting a CSS property and have one or more animation functions that
|
|
|
|
// don't just replace the underlying value).
|
|
|
|
//
|
|
|
|
// This might return true in some cases where we don't actually need the base
|
|
|
|
// style since it doesn't build up the animation sandwich to check if the
|
|
|
|
// functions that appear to need the base style are actually replaced by
|
|
|
|
// a function further up the stack.
|
|
|
|
bool MightNeedBaseStyle() const;
|
|
|
|
|
2010-02-21 00:13:11 +03:00
|
|
|
// Finds the index of the first function that will affect our animation
|
|
|
|
// sandwich. Also toggles the 'mForceCompositing' flag if it finds that any
|
|
|
|
// (used) functions have changed.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t GetFirstFuncToAffectSandwich();
|
2010-02-21 00:13:11 +03:00
|
|
|
|
|
|
|
// If the passed-in base value differs from our cached base value, this
|
|
|
|
// method updates the cached value (and toggles the 'mForceCompositing' flag)
|
2019-01-23 16:48:08 +03:00
|
|
|
void UpdateCachedBaseValue(const SMILValue& aBaseValue);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2017-03-30 07:10:06 +03:00
|
|
|
// The hash key (tuple of element and attributeName)
|
2010-02-21 00:13:11 +03:00
|
|
|
KeyType mKey;
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-02-21 00:13:11 +03:00
|
|
|
// Hash Value: List of animation functions that animate the specified attr
|
2019-01-01 12:16:21 +03:00
|
|
|
nsTArray<SMILAnimationFunction*> mAnimationFunctions;
|
2010-02-21 00:13:11 +03:00
|
|
|
|
|
|
|
// Member data for detecting when we need to force-recompose
|
|
|
|
// ---------------------------------------------------------
|
2011-10-17 18:59:28 +04:00
|
|
|
// Flag for tracking whether we need to compose. Initialized to false, but
|
|
|
|
// gets flipped to true if we detect that something has changed.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mForceCompositing;
|
2010-02-21 00:13:11 +03:00
|
|
|
|
|
|
|
// Cached base value, so we can detect & force-recompose when it changes
|
2018-12-28 14:47:58 +03:00
|
|
|
// from one sample to the next. (SMILAnimationController moves this
|
Bug 1353208 - Don't allocate separate heap memory for nsSMILCompositor::mCachedBaseValue; r=dholbert
nsSMILCompositor::mCachedBaseValue is an nsAutoPtr<nsSMILValue> that we allocate
on the heap. It looks like we did that back in bug 533291 presumably because it
makes transferring these cached values between nsSMILCompositor objects cheaper.
One drawback of this, however, is that mCachedBaseValue has two null states:
the mCachedBaseValue pointer can be null, and the pointed-to nsSMILValue can be
a null value (i.e. IsNull() returns true).
Now that we have move ctors and operators defined for nsSMILValue we can
transfer these objects between compositors cheaply without requiring the object
to be allocated as separate heap object. This patch makes mCachedBaseValue just
a regular nsSMILValue class member (i.e. drops the nsAutoPtr).
There's a subtle difference in behavior with regards to the first sample.
Previously we would compare the (initially) null mCachedBaseValue pointer with
the passed-in nsSMILValue and set mForceCompositing to true. With this patch,
however, we will only set mForceCompositing to true if the passed-in
mCachedBaseValue is not null.
I believe this is correct, however, since if we don't call GetBaseValue in
ComposeAttribute we should not be setting mForceCompositing to true (something
else should ensure that gets set to true), and if we do call GetBaseValue the
result should not be a null nsSMILValue (except in some OOM cases where we don't
really care if we miss a sample). This patch adds an assertion to check that
GetBaseValue does, in fact, return a non-null value. (I checked the code and
this appears to be the case. Even in error cases we typically return an empty
nsSMILValue of a non-null type. For example, the early return in
nsSMILCSSProperty::GetBaseValue() does this.)
MozReview-Commit-ID: BRJFa4xMdxz
--HG--
extra : rebase_source : f3e3ca1e01e73610523bde7583e2a002d2473184
2017-03-30 07:10:07 +03:00
|
|
|
// forward from the previous sample's compositor by calling
|
|
|
|
// StealCachedBaseValue.)
|
2019-01-23 16:48:08 +03:00
|
|
|
SMILValue mCachedBaseValue;
|
2009-01-15 07:38:07 +03:00
|
|
|
};
|
|
|
|
|
2019-01-01 12:16:21 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-07-15 02:40:05 +03:00
|
|
|
#endif // DOM_SMIL_SMILCOMPOSITOR_H_
|