Bug 940698 - Add an "ownerNumberControl" property to HTMLInputElement. r=smaug

This commit is contained in:
Jonathan Watt 2013-11-20 09:32:45 +00:00
Родитель f1da82e63e
Коммит fd6a1d69b8
3 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -668,6 +668,8 @@ public:
void MozSetFileNameArray(const Sequence< nsString >& aFileNames);
HTMLInputElement* GetOwnerNumberControl();
bool MozIsTextField(bool aExcludePassword);
nsIEditor* GetEditor();

Просмотреть файл

@ -154,6 +154,18 @@ partial interface HTMLInputElement {
[ChromeOnly]
void mozSetFileNameArray(sequence<DOMString> fileNames);
// Number controls (<input type=number>) have an anonymous text control
// (<input type=text>) 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);
};