зеркало из https://github.com/mozilla/pjs.git
Bug 549208 - Dragging a text in an input/textarea element doesn't make the placeholder disappear; r=bzbarsky
--HG-- extra : rebase_source : 13dc342d24bef26815bda5ef9958cfcb11a68a10
This commit is contained in:
Родитель
01fbe1bb3f
Коммит
e9e4a9e303
|
@ -268,14 +268,9 @@ NS_INTERFACE_MAP_END
|
|||
static PRBool
|
||||
IsFocusedContent(nsIContent* aContent)
|
||||
{
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (!fm)
|
||||
return PR_FALSE;
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
|
||||
nsCOMPtr<nsIDOMElement> focusedElement;
|
||||
fm->GetFocusedElement(getter_AddRefs(focusedElement));
|
||||
nsCOMPtr<nsIContent> focusedContent = do_QueryInterface(focusedElement);
|
||||
return (focusedContent == aContent);
|
||||
return fm && fm->GetFocusedContent() == aContent;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1541,6 +1536,12 @@ nsTextControlFrame::InitEditor()
|
|||
// Now restore the original editor flags.
|
||||
rv = mEditor->SetFlags(editorFlags);
|
||||
|
||||
// By default the placeholder is shown,
|
||||
// we should hide it if the default value is not empty.
|
||||
nsWeakFrame weakFrame(this);
|
||||
HidePlaceholder();
|
||||
NS_ENSURE_STATE(weakFrame.IsAlive());
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
@ -2751,15 +2752,6 @@ nsTextControlFrame::SetValue(const nsAString& aValue)
|
|||
editor->SetFlags(savedFlags);
|
||||
if (selPriv)
|
||||
selPriv->EndBatchChanges();
|
||||
|
||||
if (newValue.IsEmpty())
|
||||
{
|
||||
if (!IsFocusedContent(mContent))
|
||||
ShowPlaceholder();
|
||||
// else it's already hidden
|
||||
}
|
||||
else
|
||||
HidePlaceholder();
|
||||
}
|
||||
|
||||
NS_ENSURE_STATE(weakFrame.IsAlive());
|
||||
|
@ -2837,6 +2829,18 @@ nsTextControlFrame::IsScrollable() const
|
|||
void
|
||||
nsTextControlFrame::SetValueChanged(PRBool aValueChanged)
|
||||
{
|
||||
// placeholder management
|
||||
if (!IsFocusedContent(mContent)) {
|
||||
// If the content is focused, we don't care about the changes because
|
||||
// the placeholder is going to be hide/show on blur.
|
||||
nsAutoString valueString;
|
||||
GetValue(valueString, PR_TRUE);
|
||||
if (valueString.IsEmpty())
|
||||
ShowPlaceholder();
|
||||
else
|
||||
HidePlaceholder();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITextControlElement> elem = do_QueryInterface(mContent);
|
||||
if (elem) {
|
||||
elem->SetValueChanged(aValueChanged);
|
||||
|
|
Загрузка…
Ссылка в новой задаче