diff options
author | Moonchild <mcwerewolf@wolfbeast.com> | 2019-03-13 07:49:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-13 07:49:07 +0100 |
commit | bf0413359245579e9509146d42cd5547e35da695 (patch) | |
tree | 8218d4f60d9eccacbf42df8cb88094a082d401b4 /application/palemoon/modules/FormSubmitObserver.jsm | |
parent | 51b821b3fdc5a7eab2369cb6a6680598a6264b08 (diff) | |
parent | 709bc24e9110eba12f94cfcb8db00a8338ac4098 (diff) | |
download | UXP-bf0413359245579e9509146d42cd5547e35da695.tar UXP-bf0413359245579e9509146d42cd5547e35da695.tar.gz UXP-bf0413359245579e9509146d42cd5547e35da695.tar.lz UXP-bf0413359245579e9509146d42cd5547e35da695.tar.xz UXP-bf0413359245579e9509146d42cd5547e35da695.zip |
Merge pull request #998 from MoonchildProductions/master
Merge master into Sync-weave
Diffstat (limited to 'application/palemoon/modules/FormSubmitObserver.jsm')
-rw-r--r-- | application/palemoon/modules/FormSubmitObserver.jsm | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/application/palemoon/modules/FormSubmitObserver.jsm b/application/palemoon/modules/FormSubmitObserver.jsm index e4d3e765e..6b2ea3c84 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]) }; |