From c500711e7e247fdce34b07163987700eded4e880 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Wed, 20 Nov 2013 09:32:45 +0000 Subject: [PATCH] Bug 940698 - Add an "ownerNumberControl" property to HTMLInputElement. r=smaug --- content/html/content/src/HTMLInputElement.cpp | 15 +++++++++++++++ content/html/content/src/HTMLInputElement.h | 2 ++ dom/webidl/HTMLInputElement.webidl | 12 ++++++++++++ 3 files changed, 29 insertions(+) diff --git a/content/html/content/src/HTMLInputElement.cpp b/content/html/content/src/HTMLInputElement.cpp index 485a48c513f..cabbf2d0107 100644 --- a/content/html/content/src/HTMLInputElement.cpp +++ b/content/html/content/src/HTMLInputElement.cpp @@ -2244,6 +2244,21 @@ HTMLInputElement::MozIsTextField(bool aExcludePassword) return IsSingleLineTextControl(aExcludePassword); } +HTMLInputElement* +HTMLInputElement::GetOwnerNumberControl() +{ + if (IsInNativeAnonymousSubtree() && + mType == NS_FORM_INPUT_TEXT && + GetParent() && GetParent()->GetParent()) { + HTMLInputElement* grandparent = + HTMLInputElement::FromContentOrNull(GetParent()->GetParent()); + if (grandparent && grandparent->mType == NS_FORM_INPUT_NUMBER) { + return grandparent; + } + } + return nullptr; +} + NS_IMETHODIMP HTMLInputElement::MozIsTextField(bool aExcludePassword, bool* aResult) { diff --git a/content/html/content/src/HTMLInputElement.h b/content/html/content/src/HTMLInputElement.h index bf2241d6424..ff6f9ce1d62 100644 --- a/content/html/content/src/HTMLInputElement.h +++ b/content/html/content/src/HTMLInputElement.h @@ -668,6 +668,8 @@ public: void MozSetFileNameArray(const Sequence< nsString >& aFileNames); + HTMLInputElement* GetOwnerNumberControl(); + bool MozIsTextField(bool aExcludePassword); nsIEditor* GetEditor(); diff --git a/dom/webidl/HTMLInputElement.webidl b/dom/webidl/HTMLInputElement.webidl index ba1bb610f2e..3c6f9c8c04d 100644 --- a/dom/webidl/HTMLInputElement.webidl +++ b/dom/webidl/HTMLInputElement.webidl @@ -154,6 +154,18 @@ partial interface HTMLInputElement { [ChromeOnly] void mozSetFileNameArray(sequence fileNames); + // Number controls () have an anonymous text control + // () in the anonymous shadow tree that they contain. On + // such an anonymous text control this property provides access to the + // number control that owns the text control. This is useful, for example, + // in code that looks at the currently focused element to make decisions + // about which IME to bring up. Such code needs to be able to check for any + // owning number control since it probably wants to bring up a number pad + // instead of the standard keyboard, even when the anonymous text control has + // focus. + [ChromeOnly] + readonly attribute HTMLInputElement? ownerNumberControl; + boolean mozIsTextField(boolean aExcludePassword); };