зеркало из https://github.com/mozilla/gecko-dev.git
Bug 807613 - Add a pref to make the placeholder disappear when a text field is focused. r=bz
This commit is contained in:
Родитель
225ba431b5
Коммит
ae737c8efe
|
@ -38,6 +38,7 @@
|
||||||
#include "mozilla/Selection.h"
|
#include "mozilla/Selection.h"
|
||||||
#include "nsEventListenerManager.h"
|
#include "nsEventListenerManager.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
@ -2002,6 +2003,12 @@ nsTextEditorState::UpdatePlaceholderVisibility(bool aNotify)
|
||||||
|
|
||||||
mPlaceholderVisibility = value.IsEmpty();
|
mPlaceholderVisibility = value.IsEmpty();
|
||||||
|
|
||||||
|
if (mPlaceholderVisibility &&
|
||||||
|
!Preferences::GetBool("dom.placeholder.show_on_focus", true)) {
|
||||||
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
|
||||||
|
mPlaceholderVisibility = !nsContentUtils::IsFocusedContent(content);
|
||||||
|
}
|
||||||
|
|
||||||
if (mBoundFrame && aNotify) {
|
if (mBoundFrame && aNotify) {
|
||||||
mBoundFrame->InvalidateFrame();
|
mBoundFrame->InvalidateFrame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -648,6 +648,12 @@ void nsTextControlFrame::SetFocus(bool aOn, bool aRepaint)
|
||||||
// Revoke the previous scroll event if one exists
|
// Revoke the previous scroll event if one exists
|
||||||
mScrollEvent.Revoke();
|
mScrollEvent.Revoke();
|
||||||
|
|
||||||
|
// If 'dom.placeholeder.show_on_focus' preference is 'false', focusing or
|
||||||
|
// blurring the frame can have an impact on the placeholder visibility.
|
||||||
|
if (mUsePlaceholder) {
|
||||||
|
txtCtrl->UpdatePlaceholderVisibility(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!aOn) {
|
if (!aOn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<link rel='stylesheet' type='text/css' href='placeholder-style.css'>
|
||||||
|
<!-- Test: when focused, element should not placeholder when
|
||||||
|
'dom.placeholder.show_on_focus' pref is false. -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
function focusPlaceholder()
|
||||||
|
{
|
||||||
|
document.getElementById('p1').focus();
|
||||||
|
}
|
||||||
|
function disableReftestWait()
|
||||||
|
{
|
||||||
|
document.documentElement.className = '';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<body onload="focusPlaceholder();">
|
||||||
|
<input type="text" id="p1" value="" placeholder="my placeholder" onfocus="disableReftestWait();">
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -32,3 +32,4 @@ random-if(winWidget) == placeholder-19.xul placeholder-overridden-ref.xul
|
||||||
needs-focus == placeholder-21.html placeholder-blank-ref.html
|
needs-focus == placeholder-21.html placeholder-blank-ref.html
|
||||||
needs-focus == placeholder-22.html placeholder-blank-ref.html
|
needs-focus == placeholder-22.html placeholder-blank-ref.html
|
||||||
== placeholder-rtl.html placeholder-rtl-ref.html
|
== placeholder-rtl.html placeholder-rtl-ref.html
|
||||||
|
pref(dom.placeholder.show_on_focus,false) needs-focus == placeholder-focus-pref.html placeholder-blank-ref.html
|
|
@ -3834,3 +3834,6 @@ pref("jsloader.reuseGlobal", false);
|
||||||
// When we're asked to take a screenshot, don't wait more than 2000ms for the
|
// When we're asked to take a screenshot, don't wait more than 2000ms for the
|
||||||
// event loop to become idle before actually taking the screenshot.
|
// event loop to become idle before actually taking the screenshot.
|
||||||
pref("dom.browserElement.maxScreenshotDelayMS", 2000);
|
pref("dom.browserElement.maxScreenshotDelayMS", 2000);
|
||||||
|
|
||||||
|
// Whether we should show the placeholder when the element is focused but empty.
|
||||||
|
pref("dom.placeholder.show_on_focus", true);
|
Загрузка…
Ссылка в новой задаче