Bug 1479173 - Add a static constexpr function returns an nsCSSPropertyIDSet being consist of CSS properties set can be run on the compositor. r=heycam,birtles

Also add a script to generate the CSS properties set by looking at
CanAnimateOnCompositor flag in servo's property definitions.

Differential Revision: https://phabricator.services.mozilla.com/D10687

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2018-11-06 09:38:57 +00:00
Родитель ca2bc06dff
Коммит 6ce612423f
3 изменённых файлов: 59 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,23 @@
# 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/.
import runpy
def generate(output, dataFile):
output.write("""/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */
#ifndef COMPOSITOR_ANIMATABLE_PROPERTY_LIST
#define COMPOSITOR_ANIMATABLE_PROPERTY_LIST { \\
""")
def can_animate_on_compositor(p):
return "CanAnimateOnCompositor" in p.flags
properties = runpy.run_path(dataFile)["data"]
properties = filter(can_animate_on_compositor, properties)
for p in properties:
output.write(" eCSSProperty_{}, \\\n".format(p.id))
output.write("}\n")
output.write("#endif /* COMPOSITOR_ANIMATABLE_PROPERTY_LIST */\n")

Просмотреть файл

@ -291,15 +291,23 @@ servo_props.inputs = [
if CONFIG['COMPILE_ENVIRONMENT']:
GENERATED_FILES += [
'CompositorAnimatableProperties.h',
'nsComputedDOMStyleGenerated.cpp',
'nsCSSPropsGenerated.inc',
'ServoStyleConsts.h',
]
EXPORTS.mozilla += [
'!CompositorAnimatableProperties.h',
'!ServoStyleConsts.h',
]
compositor = GENERATED_FILES['CompositorAnimatableProperties.h']
compositor.script = 'GenerateCompositorAnimatableProperties.py:generate'
compositor.inputs = [
'!ServoCSSPropList.py',
]
computed = GENERATED_FILES['nsComputedDOMStyleGenerated.cpp']
computed.script = 'GenerateComputedDOMStyleGenerated.py:generate'
computed.inputs = [

Просмотреть файл

@ -11,6 +11,10 @@
#include "nsCSSPropertyID.h"
#include <limits.h> // for CHAR_BIT
#include <initializer_list>
// For COMPOSITOR_ANIMATABLE_PROPERTY_LIST
#include "mozilla/CompositorAnimatableProperties.h"
/**
* nsCSSPropertyIDSet maintains a set of non-shorthand CSS properties. In
@ -22,6 +26,17 @@ public:
nsCSSPropertyIDSet() { Empty(); }
// auto-generated copy-constructor OK
explicit constexpr nsCSSPropertyIDSet(
std::initializer_list<nsCSSPropertyID> aProperties)
: mProperties{0}
{
for (auto property : aProperties) {
size_t p = property;
mProperties[p / kBitsInChunk] |=
property_set_type(1) << (p % kBitsInChunk);
}
}
void AssertInSetRange(nsCSSPropertyID aProperty) const {
NS_ASSERTION(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands,
@ -52,6 +67,19 @@ public:
(property_set_type(1) << (p % kBitsInChunk))) != 0;
}
// Returns an nsCSSPropertyIDSet including all properties that can be run
// on the compositor.
static constexpr nsCSSPropertyIDSet CompositorAnimatables()
{
return nsCSSPropertyIDSet(COMPOSITOR_ANIMATABLE_PROPERTY_LIST);
}
static constexpr size_t CompositorAnimatableCount()
{
auto list = COMPOSITOR_ANIMATABLE_PROPERTY_LIST;
return list.size();
}
void Empty() {
memset(mProperties, 0, sizeof(mProperties));
}