Bug 1052246 - Send correct rect information for selectionchange event. r=fabrice

This commit is contained in:
Morris Tseng 2014-08-13 19:29:00 -04:00
parent 8a6be5ba9a
commit 5712807cf4
2 changed files with 6 additions and 6 deletions

View File

@ -522,8 +522,8 @@ var shell = {
// based on tab's coordinate. So get the actual offsets between shell and evt.target.
let elt = evt.target;
let win = elt.ownerDocument.defaultView;
let offsetX = win.mozInnerScreenX;
let offsetY = win.mozInnerScreenY;
let offsetX = win.mozInnerScreenX - window.mozInnerScreenX;
let offsetY = win.mozInnerScreenY - window.mozInnerScreenY;
let rect = elt.getBoundingClientRect();
offsetX += rect.left;

View File

@ -644,15 +644,15 @@ BrowserElementChild.prototype = {
isCollapsed: (e.selectedText.length == 0),
};
// Get correct geometry information if we have nested <iframe mozbrowser>
// Get correct geometry information if we have nested iframe.
let currentWindow = e.target.defaultView;
while (currentWindow.realFrameElement) {
let currentRect = currentWindow.realFrameElement.getBoundingClientRect();
while (currentWindow.top != currentWindow) {
let currentRect = currentWindow.frameElement.getBoundingClientRect();
detail.rect.top += currentRect.top;
detail.rect.bottom += currentRect.top;
detail.rect.left += currentRect.left;
detail.rect.right += currentRect.left;
currentWindow = currentWindow.realFrameElement.ownerDocument.defaultView;
currentWindow = currentWindow.parent;
}
sendAsyncMsg("selectionchange", detail);