Bug 1260680 - Filter out unwanted data in getProperties to reduce protocol traffic; r=miker

MozReview-Commit-ID: 9Gybp724gja

--HG--
extra : rebase_source : 98076280c8bc3d3ce7ff642f6ab2dba03c3bb716
This commit is contained in:
Patrick Brosset 2016-03-30 12:12:36 +02:00
Родитель 13873d680d
Коммит 1dbefe5a91
4 изменённых файлов: 13 добавлений и 17 удалений

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

@ -80,14 +80,12 @@ AnimationDetails.prototype = {
*/
if (this.serverTraits.hasGetProperties) {
let properties = yield this.animation.getProperties();
for (let propertyObject of properties) {
let name = propertyObject.property;
for (let {name, values} of properties) {
if (!tracks[name]) {
tracks[name] = [];
}
for (let {value, offset} of propertyObject.values) {
for (let {value, offset} of values) {
tracks[name].push({value, offset});
}
}

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

@ -60,15 +60,12 @@ function* getExpectedKeyframesData(animation) {
for (let expectedProperty of EXPECTED_PROPERTIES) {
data[expectedProperty] = [];
for (let propertyObject of properties) {
if (propertyObject.property !== expectedProperty) {
for (let {name, values} of properties) {
if (name !== expectedProperty) {
continue;
}
for (let valueObject of propertyObject.values) {
data[expectedProperty].push({
offset: valueObject.offset,
value: valueObject.value
});
for (let {offset, value} of values) {
data[expectedProperty].push({offset, value});
}
}
}

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

@ -444,15 +444,17 @@ var AnimationPlayerActor = ActorClass({
/**
* Get data about the animated properties of this animation player.
* @return {Object} Returns a list of animated properties.
* @return {Array} Returns a list of animated properties.
* Each property contains a list of values and their offsets
*/
getProperties: method(function() {
return this.player.effect.getProperties();
return this.player.effect.getProperties().map(property => {
return {name: property.property, values: property.values};
});
}, {
request: {},
response: {
frames: RetVal("json")
properties: RetVal("array:json")
}
})
});

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

@ -10,8 +10,7 @@
const URL = MAIN_DOMAIN + "animation.html";
add_task(function*() {
let {client, walker, animations} =
yield initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
let {client, walker, animations} = yield initAnimationsFrontForUrl(URL);
info("Get the test node and its animation front");
let node = yield walker.querySelector(walker.rootNode, ".simple-animation");
@ -23,7 +22,7 @@ add_task(function*() {
is(properties.length, 1, "The correct number of properties was retrieved");
let propertyObject = properties[0];
is(propertyObject.property, "transform", "Property 0 is transform");
is(propertyObject.name, "transform", "Property 0 is transform");
is(propertyObject.values.length, 2,
"The correct number of property values was retrieved");