зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1020801 - Add new 'ScrollViewChangeEvent' DOM event. r=fabrice, r=bz
This commit is contained in:
Родитель
4529b1d975
Коммит
d2e238061d
|
@ -332,6 +332,7 @@ var shell = {
|
|||
window.addEventListener('unload', this);
|
||||
this.contentBrowser.addEventListener('mozbrowserloadstart', this, true);
|
||||
this.contentBrowser.addEventListener('mozbrowserselectionchange', this, true);
|
||||
this.contentBrowser.addEventListener('mozbrowserscrollviewchange', this, true);
|
||||
|
||||
CustomEventManager.init();
|
||||
WebappsHelper.init();
|
||||
|
@ -359,6 +360,7 @@ var shell = {
|
|||
window.removeEventListener('sizemodechange', this);
|
||||
this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
|
||||
this.contentBrowser.removeEventListener('mozbrowserselectionchange', this, true);
|
||||
this.contentBrowser.removeEventListener('mozbrowserscrollviewchange', this, true);
|
||||
ppmm.removeMessageListener("content-handler", this);
|
||||
|
||||
UserAgentOverrides.uninit();
|
||||
|
@ -500,7 +502,12 @@ var shell = {
|
|||
|
||||
this.notifyContentStart();
|
||||
break;
|
||||
|
||||
case 'mozbrowserscrollviewchange':
|
||||
this.sendChromeEvent({
|
||||
type: 'scrollviewchange',
|
||||
detail: evt.detail,
|
||||
});
|
||||
break;
|
||||
case 'mozbrowserselectionchange':
|
||||
// The mozbrowserselectionchange event, may have crossed the chrome-content boundary.
|
||||
// This event always dispatch to shell.js. But the offset we got from this event is
|
||||
|
|
|
@ -221,6 +221,11 @@ BrowserElementChild.prototype = {
|
|||
/* useCapture = */ false,
|
||||
/* wantsUntrusted = */ false);
|
||||
|
||||
addEventListener('scrollviewchange',
|
||||
this._ScrollViewChangeHandler.bind(this),
|
||||
/* useCapture = */ false,
|
||||
/* wantsUntrusted = */ false);
|
||||
|
||||
// This listens to unload events from our message manager, but /not/ from
|
||||
// the |content| window. That's because the window's unload event doesn't
|
||||
// bubble, and we're not using a capturing listener. If we'd used
|
||||
|
@ -626,6 +631,16 @@ BrowserElementChild.prototype = {
|
|||
sendAsyncMsg('metachange', meta);
|
||||
},
|
||||
|
||||
_ScrollViewChangeHandler: function(e) {
|
||||
e.stopPropagation();
|
||||
let detail = {
|
||||
state: e.state,
|
||||
scrollX: e.scrollX,
|
||||
scrollY: e.scrollY,
|
||||
};
|
||||
sendAsyncMsg('scrollviewchange', detail);
|
||||
},
|
||||
|
||||
_selectionChangeHandler: function(e) {
|
||||
e.stopPropagation();
|
||||
let boundingClientRect = e.boundingClientRect;
|
||||
|
@ -666,7 +681,7 @@ BrowserElementChild.prototype = {
|
|||
currentWindow = currentWindow.parent;
|
||||
}
|
||||
|
||||
sendAsyncMsg("selectionchange", detail);
|
||||
sendAsyncMsg('selectionchange', detail);
|
||||
},
|
||||
|
||||
_themeColorChangedHandler: function(eventType, target) {
|
||||
|
|
|
@ -255,7 +255,8 @@ BrowserElementParent.prototype = {
|
|||
"got-visible": this._gotDOMRequestResult,
|
||||
"visibilitychange": this._childVisibilityChange,
|
||||
"got-set-input-method-active": this._gotDOMRequestResult,
|
||||
"selectionchange": this._handleSelectionChange
|
||||
"selectionchange": this._handleSelectionChange,
|
||||
"scrollviewchange": this._handleScrollViewChange
|
||||
};
|
||||
|
||||
let mmSecuritySensitiveCalls = {
|
||||
|
@ -496,6 +497,12 @@ BrowserElementParent.prototype = {
|
|||
this._frameElement.dispatchEvent(evt);
|
||||
},
|
||||
|
||||
_handleScrollViewChange: function(data) {
|
||||
let evt = this._createEvent("scrollviewchange", data.json,
|
||||
/* cancelable = */ false);
|
||||
this._frameElement.dispatchEvent(evt);
|
||||
},
|
||||
|
||||
_createEvent: function(evtName, detail, cancelable) {
|
||||
// This will have to change if we ever want to send a CustomEvent with null
|
||||
// detail. For now, it's OK.
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*/
|
||||
|
||||
enum ScrollState {"started", "stopped"};
|
||||
|
||||
dictionary ScrollViewChangeEventInit : EventInit {
|
||||
ScrollState state = "started";
|
||||
float scrollX = 0;
|
||||
float scrollY = 0;
|
||||
};
|
||||
|
||||
[Constructor(DOMString type, optional ScrollViewChangeEventInit eventInit),
|
||||
ChromeOnly]
|
||||
interface ScrollViewChangeEvent : Event {
|
||||
readonly attribute ScrollState state;
|
||||
readonly attribute float scrollX;
|
||||
readonly attribute float scrollY;
|
||||
};
|
|
@ -680,6 +680,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
|
|||
'RTCPeerConnectionIceEvent.webidl',
|
||||
'RTCPeerConnectionIdentityErrorEvent.webidl',
|
||||
'RTCPeerConnectionIdentityEvent.webidl',
|
||||
'ScrollViewChangeEvent.webidl',
|
||||
'SelectionChangeEvent.webidl',
|
||||
'StyleRuleChangeEvent.webidl',
|
||||
'StyleSheetApplicableStateChangeEvent.webidl',
|
||||
|
|
Загрузка…
Ссылка в новой задаче