diff --git a/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/layout/html/forms/src/nsGfxTextControlFrame2.cpp index 92fe083cc130..8cf170a302a7 100644 --- a/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -52,6 +52,7 @@ #include "nsIComponentManager.h" #include "nsIElementFactory.h" #include "nsIServiceManager.h" +#include "nsIFrameSelection.h" static NS_DEFINE_IID(kIAnonymousContentCreatorIID, NS_IANONYMOUS_CONTENT_CREATOR_IID); @@ -119,6 +120,47 @@ nsGfxTextControlFrame2::~nsGfxTextControlFrame2() { } + +// XXX: wouldn't it be nice to get this from the style context! +PRBool nsGfxTextControlFrame2::IsSingleLineTextControl() const +{ + PRInt32 type; + GetType(&type); + if ((NS_FORM_INPUT_TEXT==type) || (NS_FORM_INPUT_PASSWORD==type)) { + return PR_TRUE; + } + return PR_FALSE; +} + +// XXX: wouldn't it be nice to get this from the style context! +PRBool nsGfxTextControlFrame2::IsPlainTextControl() const +{ + // need to check HTML attribute of mContent and/or CSS. + return PR_TRUE; +} + +PRBool nsGfxTextControlFrame2::IsPasswordTextControl() const +{ + PRInt32 type; + GetType(&type); + if (NS_FORM_INPUT_PASSWORD==type) { + return PR_TRUE; + } + return PR_FALSE; +} + + +NS_IMETHOD +nsGfxTextControlFrame2::CreateFrameFor(nsIPresContext* aPresContext, + nsIContent * aContent, + nsIFrame** aFrame) +{ + aContent = nsnull; + return NS_ERROR_FAILURE; +} + + + NS_IMETHODIMP nsGfxTextControlFrame2::CreateAnonymousContent(nsIPresContext* aPresContext, nsISupportsArray& aChildList) @@ -162,8 +204,25 @@ nsGfxTextControlFrame2::CreateAnonymousContent(nsIPresContext* aPresContext, rv = aPresContext->GetShell(getter_AddRefs(shell)); if (NS_FAILED(rv) || !shell) return rv?rv:NS_ERROR_FAILURE; +//get the document + nsCOMPtr doc; + rv = shell->GetDocument(getter_AddRefs(doc)); + if (NS_FAILED(rv) || !doc) + return rv?rv:NS_ERROR_FAILURE; + nsCOMPtr domdoc = do_QueryInterface(doc, &rv); + if (NS_FAILED(rv) || !domdoc) + return rv?rv:NS_ERROR_FAILURE; +//get the flags + PRUint32 editorFlags = 0; + if (IsPlainTextControl()) + editorFlags |= nsIHTMLEditor::eEditorPlaintextMask; + if (IsSingleLineTextControl()) + editorFlags |= nsIHTMLEditor::eEditorSingleLineMask; + if (IsPasswordTextControl()) + editorFlags |= nsIHTMLEditor::eEditorPasswordMask; + //initialize the editor - + mEditor->Init(domdoc, shell, mSelCon, 0); } return NS_OK; } diff --git a/layout/html/forms/src/nsGfxTextControlFrame2.h b/layout/html/forms/src/nsGfxTextControlFrame2.h index ad08be8fa53b..985b2773a2b9 100644 --- a/layout/html/forms/src/nsGfxTextControlFrame2.h +++ b/layout/html/forms/src/nsGfxTextControlFrame2.h @@ -28,6 +28,8 @@ #include "nsIDOMMouseListener.h" #include "nsIAnonymousContentCreator.h" #include "nsIStatefulFrame.h" +#include "nsIEditor.h" + class nsIPresState; class nsGfxTextControlFrame; @@ -56,7 +58,7 @@ public: #ifdef NS_DEBUG NS_IMETHOD GetFrameName(nsString& aResult) const { - aResult = "nsGfxControlFrame2"; + aResult.AssignWithConversion("nsGfxControlFrame2"); return NS_OK; } #endif @@ -67,6 +69,15 @@ public: NS_DECL_ISUPPORTS_INHERITED protected: virtual PRIntn GetSkipSides() const; + +//helper methods + virtual PRBool IsSingleLineTextControl() const; + virtual PRBool IsPlainTextControl() const; + virtual PRBool IsPasswordTextControl() const; + + NS_IMETHOD CreateFrameFor(nsIPresContext* aPresContext, + nsIContent * aContent, + nsIFrame** aFrame); private: nsCOMPtr mEditor; nsCOMPtr mSelCon;