summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-01-02 17:15:29 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-01-02 17:15:29 +0100
commitf543892e44771a2798d8ab0afe0d9bae8db06c3f (patch)
tree42b23d0154ca4c6361053b64b1e1586720a5b60a
parentda0d462d65d10bdb74981ecf12e35a160ac77171 (diff)
downloaduxp-f543892e44771a2798d8ab0afe0d9bae8db06c3f.tar.gz
Use getElementBoundingRect and element.ownerGlobal in FormSubmitObserver
-rw-r--r--application/palemoon/modules/FormSubmitObserver.jsm46
1 files changed, 15 insertions, 31 deletions
diff --git a/application/palemoon/modules/FormSubmitObserver.jsm b/application/palemoon/modules/FormSubmitObserver.jsm
index e4d3e765ed..6b2ea3c84b 100644
--- a/application/palemoon/modules/FormSubmitObserver.jsm
+++ b/application/palemoon/modules/FormSubmitObserver.jsm
@@ -42,10 +42,10 @@ FormSubmitObserver.prototype =
{
this._content = aWindow;
this._tab = aTabChildGlobal;
- this._mm =
- this._content.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell)
- .sameTypeRootTreeItem
+ this._mm =
+ this._content.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDocShell)
+ .sameTypeRootTreeItem
.QueryInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
@@ -104,13 +104,13 @@ FormSubmitObserver.prototype =
return;
}
- // Insure that this is the FormSubmitObserver associated with the form
+ // Ensure that this is the FormSubmitObserver associated with the
// element / window this notification is about.
- if (this._content != aFormElement.ownerDocument.defaultView.top.document.defaultView) {
+ let element = aInvalidElements.queryElementAt(0, Ci.nsISupports);
+ if (this._content != element.ownerGlobal.top.document.defaultView) {
return;
}
- let element = aInvalidElements.queryElementAt(0, Ci.nsISupports);
if (!(element instanceof HTMLInputElement ||
element instanceof HTMLTextAreaElement ||
element instanceof HTMLSelectElement ||
@@ -118,6 +118,9 @@ FormSubmitObserver.prototype =
return;
}
+ // Update validation message before showing notification
+ this._validationMessage = element.validationMessage;
+
// Don't connect up to the same element more than once.
if (this._element == element) {
this._showPopup(element);
@@ -127,8 +130,6 @@ FormSubmitObserver.prototype =
element.focus();
- this._validationMessage = element.validationMessage;
-
// Watch for input changes which may change the validation message.
element.addEventListener("input", this, false);
@@ -142,7 +143,7 @@ FormSubmitObserver.prototype =
/*
* Internal
*/
-
+
/*
* Handles input changes on the form element we've associated a popup
* with. Updates the validation message or closes the popup if form data
@@ -189,18 +190,17 @@ FormSubmitObserver.prototype =
// Note, this is relative to the browser and needs to be translated
// in chrome.
- panelData.contentRect = this._msgRect(aElement);
+ panelData.contentRect = BrowserUtils.getElementBoundingRect(aElement);
// We want to show the popup at the middle of checkbox and radio buttons
// and where the content begin for the other elements.
let offset = 0;
- let position = "";
if (aElement.tagName == 'INPUT' &&
(aElement.type == 'radio' || aElement.type == 'checkbox')) {
panelData.position = "bottomcenter topleft";
} else {
- let win = aElement.ownerDocument.defaultView;
+ let win = aElement.ownerGlobal;
let style = win.getComputedStyle(aElement, null);
if (style.direction == 'rtl') {
offset = parseInt(style.paddingRight) + parseInt(style.borderRightWidth);
@@ -218,8 +218,8 @@ FormSubmitObserver.prototype =
this._mm.sendAsyncMessage("FormValidation:HidePopup", {});
},
- _getWindowUtils: function () {
- return this._content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+ _getWindowUtils: function () {
+ return this._content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
},
_isRootDocumentEvent: function (aEvent) {
@@ -231,21 +231,5 @@ FormSubmitObserver.prototype =
(target.ownerDocument && target.ownerDocument == this._content.document));
},
- /*
- * Return a message manager rect for the element's bounding client rect
- * in top level browser coords.
- */
- _msgRect: function (aElement) {
- let domRect = aElement.getBoundingClientRect();
- let zoomFactor = this._getWindowUtils().fullZoom;
- let { offsetX, offsetY } = BrowserUtils.offsetToTopLevelWindow(this._content, aElement);
- return {
- left: (domRect.left + offsetX) * zoomFactor,
- top: (domRect.top + offsetY) * zoomFactor,
- width: domRect.width * zoomFactor,
- height: domRect.height * zoomFactor
- };
- },
-
QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormSubmitObserver])
};