mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 97811.
Add nsILookAndFeel::GetPasswordCharacter() to allow toolkits to specify their platform password character. Implement this for GTK+ 2 by grabbing the property from GtkEntry. Make editor ask nsILookAndFeel for the platform password character. r+sr=roc
This commit is contained in:
parent
4c82545467
commit
9d1d420c3f
@ -60,11 +60,15 @@
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
// for IBMBIDI
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsFrameSelection.h"
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
#define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
|
||||
if ((mFlags & nsIPlaintextEditor::eEditorReadonlyMask) || (mFlags & nsIPlaintextEditor::eEditorDisabledMask)) \
|
||||
{ \
|
||||
@ -1420,13 +1424,20 @@ nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAString *
|
||||
// manage the password buffer
|
||||
mPasswordText.Insert(*aOutString, aStart);
|
||||
|
||||
// change the output to '*' only
|
||||
// change the output to the platform password character
|
||||
PRUnichar passwordChar = PRUnichar('*');
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel = do_GetService(kLookAndFeelCID);
|
||||
if (lookAndFeel)
|
||||
{
|
||||
passwordChar = lookAndFeel->GetPasswordCharacter();
|
||||
}
|
||||
|
||||
PRInt32 length = aOutString->Length();
|
||||
PRInt32 i;
|
||||
aOutString->Truncate();
|
||||
for (i=0; i<length; i++)
|
||||
{
|
||||
aOutString->Append(PRUnichar('*'));
|
||||
aOutString->Append(passwordChar);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -268,7 +268,11 @@ public:
|
||||
NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor) = 0;
|
||||
NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric) = 0;
|
||||
NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric) = 0;
|
||||
|
||||
virtual PRUnichar GetPasswordCharacter()
|
||||
{
|
||||
return PRUnichar('*');
|
||||
}
|
||||
|
||||
NS_IMETHOD LookAndFeelChanged() = 0;
|
||||
|
||||
|
||||
|
@ -46,17 +46,17 @@
|
||||
#define GDK_COLOR_TO_NS_RGB(c) \
|
||||
((nscolor) NS_RGB(c.red>>8, c.green>>8, c.blue>>8))
|
||||
|
||||
nscolor nsLookAndFeel::sInfoText = 0;
|
||||
nscolor nsLookAndFeel::sInfoBackground = 0;
|
||||
nscolor nsLookAndFeel::sMenuText = 0;
|
||||
nscolor nsLookAndFeel::sMenuHover = 0;
|
||||
nscolor nsLookAndFeel::sMenuHoverText = 0;
|
||||
nscolor nsLookAndFeel::sMenuBackground = 0;
|
||||
nscolor nsLookAndFeel::sButtonBackground = 0;
|
||||
nscolor nsLookAndFeel::sButtonText = 0;
|
||||
nscolor nsLookAndFeel::sButtonOuterLightBorder = 0;
|
||||
nscolor nsLookAndFeel::sButtonInnerDarkBorder = 0;
|
||||
PRBool nsLookAndFeel::sColorsInitialized = PR_FALSE;
|
||||
nscolor nsLookAndFeel::sInfoText = 0;
|
||||
nscolor nsLookAndFeel::sInfoBackground = 0;
|
||||
nscolor nsLookAndFeel::sMenuText = 0;
|
||||
nscolor nsLookAndFeel::sMenuHover = 0;
|
||||
nscolor nsLookAndFeel::sMenuHoverText = 0;
|
||||
nscolor nsLookAndFeel::sMenuBackground = 0;
|
||||
nscolor nsLookAndFeel::sButtonBackground = 0;
|
||||
nscolor nsLookAndFeel::sButtonText = 0;
|
||||
nscolor nsLookAndFeel::sButtonOuterLightBorder = 0;
|
||||
nscolor nsLookAndFeel::sButtonInnerDarkBorder = 0;
|
||||
PRUnichar nsLookAndFeel::sInvisibleCharacter = PRUnichar('*');
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
@ -67,8 +67,12 @@ nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
||||
{
|
||||
InitWidget();
|
||||
|
||||
if (!sColorsInitialized)
|
||||
InitColors();
|
||||
static PRBool sInitialized = PR_FALSE;
|
||||
|
||||
if (!sInitialized) {
|
||||
sInitialized = PR_TRUE;
|
||||
InitLookAndFeel();
|
||||
}
|
||||
}
|
||||
|
||||
nsLookAndFeel::~nsLookAndFeel()
|
||||
@ -582,9 +586,8 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID,
|
||||
}
|
||||
|
||||
void
|
||||
nsLookAndFeel::InitColors()
|
||||
nsLookAndFeel::InitLookAndFeel()
|
||||
{
|
||||
sColorsInitialized = PR_TRUE;
|
||||
GtkStyle *style;
|
||||
|
||||
// tooltip foreground and background
|
||||
@ -649,6 +652,21 @@ nsLookAndFeel::InitColors()
|
||||
GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]);
|
||||
|
||||
gtk_widget_destroy(window);
|
||||
|
||||
// invisible character styles
|
||||
GtkWidget *entry = gtk_entry_new();
|
||||
guint value;
|
||||
g_object_get (entry, "invisible-char", &value, NULL);
|
||||
sInvisibleCharacter = PRUnichar(value);
|
||||
gtk_widget_destroy(entry);
|
||||
|
||||
}
|
||||
|
||||
// virtual
|
||||
PRUnichar
|
||||
nsLookAndFeel::GetPasswordCharacter()
|
||||
{
|
||||
return sInvisibleCharacter;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -660,7 +678,7 @@ nsLookAndFeel::LookAndFeelChanged()
|
||||
gtk_widget_unref(mWidget);
|
||||
|
||||
InitWidget();
|
||||
InitColors();
|
||||
InitLookAndFeel();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric);
|
||||
NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric);
|
||||
NS_IMETHOD LookAndFeelChanged();
|
||||
virtual PRUnichar GetPasswordCharacter();
|
||||
|
||||
protected:
|
||||
GtkStyle *mStyle;
|
||||
@ -59,7 +60,7 @@ protected:
|
||||
|
||||
// Cached colors, we have to create a dummy widget to actually
|
||||
// get the style
|
||||
static PRBool sColorsInitialized;
|
||||
|
||||
static nscolor sInfoBackground;
|
||||
static nscolor sInfoText;
|
||||
static nscolor sMenuBackground;
|
||||
@ -70,8 +71,9 @@ protected:
|
||||
static nscolor sButtonText;
|
||||
static nscolor sButtonOuterLightBorder;
|
||||
static nscolor sButtonInnerDarkBorder;
|
||||
static PRUnichar sInvisibleCharacter;
|
||||
|
||||
static void InitColors();
|
||||
static void InitLookAndFeel();
|
||||
void InitWidget() {
|
||||
mWidget = gtk_invisible_new();
|
||||
gtk_object_ref(GTK_OBJECT(mWidget));
|
||||
|
Loading…
Reference in New Issue
Block a user