mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1121227 - Don't harcode the system app origin in touch-events.js r=ochameau
This commit is contained in:
parent
c815fdc069
commit
28774c3a81
@ -11,6 +11,16 @@ let handlerCount = 0;
|
||||
|
||||
let orig_w3c_touch_events = Services.prefs.getIntPref('dom.w3c_touch_events.enabled');
|
||||
|
||||
let systemAppOrigin = (function() {
|
||||
let systemOrigin = "_";
|
||||
try {
|
||||
systemOrigin = Services.io.newURI(
|
||||
Services.prefs.getCharPref('b2g.system_manifest_url'), null, null)
|
||||
.prePath;
|
||||
} catch(e) {}
|
||||
return systemOrigin;
|
||||
})();
|
||||
|
||||
let trackedWindows = new WeakMap();
|
||||
|
||||
// =================== Touch ====================
|
||||
@ -65,7 +75,10 @@ function TouchEventHandler (window) {
|
||||
// a mix of mouse/touch events. So let's not cancel *all* mouse events
|
||||
// if it is the current target.
|
||||
let content = this.getContent(evt.target);
|
||||
let isSystemWindow = content.location.toString().indexOf("system.gaiamobile.org") != -1;
|
||||
if (!content) {
|
||||
return;
|
||||
}
|
||||
let isSystemWindow = content.location.toString().startsWith(systemAppOrigin);
|
||||
|
||||
// App touchstart & touchend should also be dispatched on the system app
|
||||
// to match on-device behavior.
|
||||
@ -233,6 +246,9 @@ function TouchEventHandler (window) {
|
||||
}
|
||||
let document = target.ownerDocument;
|
||||
let content = this.getContent(target);
|
||||
if (!content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let touchEvent = document.createEvent('touchevent');
|
||||
let point = document.createTouch(content, target, 0,
|
||||
@ -250,7 +266,9 @@ function TouchEventHandler (window) {
|
||||
return touchEvent;
|
||||
},
|
||||
getContent: function teh_getContent(target) {
|
||||
let win = target.ownerDocument.defaultView;
|
||||
let win = (target && target.ownerDocument)
|
||||
? target.ownerDocument.defaultView
|
||||
: null;
|
||||
return win;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user