Merge pull request #1914 from tschneidereit/master

Bug 1105480 - Make AVM1 MovieClips mouse-transparent as long as they don't have button-related event handlers
This commit is contained in:
Till Schneidereit 2014-12-03 23:20:38 -08:00
Родитель 87d31d53a9 911a5e1be4
Коммит 250d81ad34
9 изменённых файлов: 68 добавлений и 7 удалений

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

@ -64,6 +64,7 @@ module Shumway.AVM1.Lib {
if (!nativeButton._symbol || !nativeButton._symbol.data.buttonActions) {
return;
}
nativeButton.buttonMode = true;
nativeButton.addEventListener('addedToStage', this._addListeners.bind(this));
nativeButton.addEventListener('removedFromStage', this._removeListeners.bind(this));
var requiredListeners = this._requiredListeners = Object.create(null);
@ -422,4 +423,4 @@ module Shumway.AVM1.Lib {
});
}
}
}
}

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

@ -373,6 +373,7 @@ module Shumway.AVM1.Lib {
var handler = clipEventHandler.bind(null, actionsData, instanceAVM1);
var flags = swfEvent.flags;
for (var eventFlag in ClipEventMappings) {
eventFlag |= 0;
if (!(flags & (eventFlag | 0))) {
continue;
}
@ -382,6 +383,15 @@ module Shumway.AVM1.Lib {
// stageListeners.push({eventName: eventName, handler: handler});
// as3Object.stage.addEventListener(eventName, handler);
//} else {
// AVM1 MovieClips are set to button mode if one of the button-related event listeners is
// set. This behaviour is triggered regardless of the actual value they are set to.
switch (eventFlag) {
case AVM1ClipEvents.Release:
case AVM1ClipEvents.ReleaseOutside:
case AVM1ClipEvents.RollOver:
case AVM1ClipEvents.RollOut:
as3Object.buttonMode = true;
}
as3Object.addEventListener(eventName, handler);
//}
}
@ -423,4 +433,4 @@ module Shumway.AVM1.Lib {
ClipEventMappings[AVM1ClipEvents.KeyPress] = {toString: function() {Debug.warning('KeyPress ClipEvent not implemented');}};
ClipEventMappings[AVM1ClipEvents.Construct] = 'construct';
}
}

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

@ -227,10 +227,19 @@ module Shumway.AVM2.Compiler.Backend {
label = new Variable("$L");
variables = [];
constants = [];
lazyConstants = [];
parameters = [];
useConstant(constant: IR.Constant): number {
return pushUnique(this.constants, constant);
var index;
if (isLazyConstant(constant)) {
index = pushUnique(this.lazyConstants, constant);
this.constants[index] = null;
} else {
index = pushUnique(this.constants, constant);
this.lazyConstants[index] = null;
}
return index;
}
useVariable(variable: IR.Variable) {
@ -714,7 +723,8 @@ module Shumway.AVM2.Compiler.Backend {
static id: number = 0;
constructor(public parameters: string [],
public body: string,
public constants: any []) {
public constants: any [],
public lazyConstants: any []) {
// ...
}
@ -726,8 +736,9 @@ module Shumway.AVM2.Compiler.Backend {
public C(index: number) {
var value = this.constants[index];
// TODO: Avoid using |instanceof| here since this can be called quite frequently.
if (value._isLazyInitializer) {
this.constants[index] = value.resolve();
if (value === null) {
value = this.constants[index] = this.lazyConstants[index].resolve();
this.lazyConstants[index] = null;
}
return this.constants[index];
}
@ -777,7 +788,7 @@ module Shumway.AVM2.Compiler.Backend {
return jsGlobal[compilationGlobalPropertyName] = new Compilation (
parameters.map(function (p) { return p.name; }),
source,
cx.constants
cx.constants, cx.lazyConstants
);
}
}

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

@ -769,5 +769,19 @@ module Shumway.AVM2.AS.flash.display {
}
this._gotoFrameAbs(currentScene.offset + currentScene.numFrames + 1);
}
_containsPointImpl(globalX: number, globalY: number, localX: number, localY: number,
testingType: HitTestingType, objects: DisplayObject[],
skipBoundsCheck: boolean): HitTestingResult {
var result = super._containsPointImpl(globalX, globalY, localX, localY, testingType, objects,
true);
// In AVM1 SWFs, MovieClips are transparent to the mouse as long as they don't have a handler
// attached to them for any of the button-related events.
if (result === HitTestingResult.Shape && testingType === HitTestingType.Mouse &&
'_as2Object' in this && !this.buttonMode && objects[0] === this) {
objects.length = 0;
}
return result;
}
}
}

Двоичные данные
test/swfs/avm1/mouse-transparency/mouse-transparency.fla Normal file

Двоичный файл не отображается.

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

@ -0,0 +1,17 @@
// mouse-transparency.swf test script
run_test = function (t, file) {
print ("Testing " + file);
t.reset (file);
var expected = Buffer.load (file + ".trace");
t.advance (50);
t.mouse_press (55, 55);
t.mouse_release (55, 55);
var diff = t.trace.diff (expected);
};
t = new Test ();
for (var i = 0; i < filenames.length; i++) {
run_test (t, filenames[i]);
}

Двоичные данные
test/swfs/avm1/mouse-transparency/mouse-transparency.swf Normal file

Двоичный файл не отображается.

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

@ -0,0 +1 @@
release

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

@ -344,6 +344,13 @@
],
"type": "stas"
},
{ "id": "avm1-mouse-transparency",
"stas": "swfs/avm1/mouse-transparency/mouse-transparency.stas",
"filenames": [
"swfs/avm1/mouse-transparency/mouse-transparency.swf"
],
"type": "stas"
},
{ "id": "avm1-rollover",
"stas": "swfs/avm1/rollover/avm1-rollover.stas",
"filenames": [