зеркало из https://github.com/mozilla/gecko-dev.git
snapshot
This commit is contained in:
Родитель
27661d8656
Коммит
e74c50762c
|
@ -27,16 +27,31 @@
|
|||
#include "nsIHTMLContent.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsITextWidget.h"
|
||||
|
||||
static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID);
|
||||
|
||||
class nsInputPasswordFrame : public nsInputFrame {
|
||||
public:
|
||||
nsInputPasswordFrame(nsIContent* aContent,
|
||||
PRInt32 aIndexInParent,
|
||||
nsIFrame* aParentFrame);
|
||||
|
||||
virtual void PreInitializeWidget(nsIPresContext* aPresContext,
|
||||
nsSize& aBounds);
|
||||
|
||||
virtual void InitializeWidget(nsIView *aView);
|
||||
|
||||
virtual const nsIID GetCID();
|
||||
|
||||
virtual const nsIID GetIID();
|
||||
|
||||
protected:
|
||||
virtual ~nsInputPasswordFrame();
|
||||
nsString mCacheValue;
|
||||
};
|
||||
|
||||
nsInputPasswordFrame::nsInputPasswordFrame(nsIContent* aContent,
|
||||
|
@ -50,12 +65,65 @@ nsInputPasswordFrame::~nsInputPasswordFrame()
|
|||
{
|
||||
}
|
||||
|
||||
const nsIID
|
||||
nsInputPasswordFrame::GetIID()
|
||||
{
|
||||
static NS_DEFINE_IID(kTextIID, NS_ITEXTWIDGET_IID);
|
||||
return kTextIID;
|
||||
}
|
||||
|
||||
const nsIID
|
||||
nsInputPasswordFrame::GetCID()
|
||||
{
|
||||
static NS_DEFINE_IID(kTextCID, NS_TEXTFIELD_CID);
|
||||
return kTextCID;
|
||||
}
|
||||
|
||||
void
|
||||
nsInputPasswordFrame::PreInitializeWidget(nsIPresContext* aPresContext,
|
||||
nsSize& aBounds)
|
||||
{
|
||||
nsInputText* content = (nsInputText *)mContent;
|
||||
|
||||
// get the value of the text
|
||||
if (nsnull != content->mValue) {
|
||||
mCacheValue = *content->mValue;
|
||||
} else {
|
||||
mCacheValue = "";
|
||||
}
|
||||
|
||||
nsIStyleContext* styleContext = mStyleContext;
|
||||
nsStyleFont* styleFont = (nsStyleFont*)styleContext->GetData(kStyleFontSID);
|
||||
nsIFontMetrics* fm = aPresContext->GetMetricsFor(styleFont->mFont);
|
||||
|
||||
float p2t = aPresContext->GetPixelsToTwips();
|
||||
|
||||
#define DEFAULT_SIZE 21
|
||||
PRInt32 size = content->mSize;
|
||||
if (size <= 0) {
|
||||
size = DEFAULT_SIZE;
|
||||
}
|
||||
|
||||
// XXX 6 should come from widget: we tell widget what the font is,
|
||||
// tell it mSize, let it tell us it's width and height
|
||||
|
||||
aBounds.width = size * fm->GetWidth(' ') + nscoord(6 * p2t);
|
||||
aBounds.height = fm->GetHeight() + nscoord(6 * p2t);
|
||||
|
||||
NS_RELEASE(fm);
|
||||
}
|
||||
|
||||
void
|
||||
nsInputPasswordFrame::InitializeWidget(nsIView *aView)
|
||||
{
|
||||
nsITextWidget* text;
|
||||
if (NS_OK == GetWidget(aView, (nsIWidget **)&text)) {
|
||||
text->SetText(mCacheValue);
|
||||
NS_RELEASE(text);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsInputPassword
|
||||
|
||||
nsInputPassword::nsInputPassword(nsIAtom* aTag, nsIFormManager* aManager)
|
||||
|
|
Загрузка…
Ссылка в новой задаче