Bug 910978 part.3 Implement nsScrollPortEvent::AssignScrollPortEventData() r=smaug

This commit is contained in:
Masayuki Nakano 2013-09-03 20:45:28 +09:00
parent 843d62f529
commit 655a3b24fe
3 changed files with 34 additions and 4 deletions

View File

@ -649,8 +649,7 @@ nsDOMEvent::DuplicatePrivateData()
static_cast<nsScrollPortEvent*>(mEvent); static_cast<nsScrollPortEvent*>(mEvent);
nsScrollPortEvent* scrollPortEvent = nsScrollPortEvent* scrollPortEvent =
new nsScrollPortEvent(false, msg, nullptr); new nsScrollPortEvent(false, msg, nullptr);
scrollPortEvent->AssignGUIEventData(*oldScrollPortEvent, true); scrollPortEvent->AssignScrollPortEventData(*oldScrollPortEvent, true);
scrollPortEvent->orient = oldScrollPortEvent->orient;
newEvent = scrollPortEvent; newEvent = scrollPortEvent;
break; break;
} }

View File

@ -799,6 +799,14 @@ public:
} }
orientType orient; orientType orient;
void AssignScrollPortEventData(const nsScrollPortEvent& aEvent,
bool aCopyTargets)
{
AssignGUIEventData(aEvent, aCopyTargets);
orient = aEvent.orient;
}
}; };
class nsScrollAreaEvent : public nsGUIEvent class nsScrollAreaEvent : public nsGUIEvent

View File

@ -12,6 +12,7 @@
<div id="display"> <div id="display">
<input id="input-text"> <input id="input-text">
<button id="button">button</button> <button id="button">button</button>
<div id="scrollable-div" style="overflow: auto; width: 30px; height: 30px;"><div id="scrolled-div" style="width: 10px; height: 10px;"></div></div>
</div> </div>
<div id="content" style="display: none"> <div id="content" style="display: none">
</div> </div>
@ -28,6 +29,7 @@ const kIsWin = (navigator.platform.indexOf("Win") == 0);
var gEvent = null; var gEvent = null;
var gCopiedEvent = []; var gCopiedEvent = [];
var gCallback = null;
function onEvent(aEvent) function onEvent(aEvent)
{ {
@ -39,6 +41,7 @@ function onEvent(aEvent)
gCopiedEvent.push({ name: attr, value: aEvent[attr]}); gCopiedEvent.push({ name: attr, value: aEvent[attr]});
} }
} }
setTimeout(gCallback, 0);
} }
const WIN_KL_US = 0x409; const WIN_KL_US = 0x409;
@ -60,6 +63,26 @@ const kTests = [
}, },
todoMismatch: [], todoMismatch: [],
}, },
{ description: "nsScrollPortEvent (overflow, vertical)",
targetID: "scrollable-div", eventType: "overflow",
dispatchEvent: function () {
document.getElementById("scrolled-div").style.height = "500px";
},
canRun: function () {
return true;
},
todoMismatch: [],
},
{ description: "nsScrollPortEvent (overflow, horizontal)",
targetID: "scrollable-div", eventType: "overflow",
dispatchEvent: function () {
document.getElementById("scrolled-div").style.width = "500px";
},
canRun: function () {
return true;
},
todoMismatch: [],
},
{ description: "nsKeyEvent (keydown of 'a' key without modifiers)", { description: "nsKeyEvent (keydown of 'a' key without modifiers)",
targetID: "input-text", eventType: "keydown", targetID: "input-text", eventType: "keydown",
dispatchEvent: function () { dispatchEvent: function () {
@ -174,7 +197,7 @@ function doTest(aTest)
gCopiedEvent = []; gCopiedEvent = [];
var target = document.getElementById(aTest.targetID); var target = document.getElementById(aTest.targetID);
target.addEventListener(aTest.eventType, onEvent, true); target.addEventListener(aTest.eventType, onEvent, true);
setTimeout(function () { gCallback = function () {
target.removeEventListener(aTest.eventType, onEvent, true); target.removeEventListener(aTest.eventType, onEvent, true);
ok(gEvent !== null, aTest.description + ": failed to get duplicated event"); ok(gEvent !== null, aTest.description + ": failed to get duplicated event");
ok(gCopiedEvent.length > 0, aTest.description + ": count of attribute of the event must be larger than 0"); ok(gCopiedEvent.length > 0, aTest.description + ": count of attribute of the event must be larger than 0");
@ -193,7 +216,7 @@ function doTest(aTest)
} }
} }
runNextTest(); runNextTest();
}, 0); };
aTest.dispatchEvent(); aTest.dispatchEvent();
} }