зеркало из https://github.com/mozilla/pjs.git
DOM extension for exposing text areas to XUL
bug 12022, r=rickg, vidur also made some improvements for future docshell work r=rickg, travis
This commit is contained in:
Родитель
81dcb1e335
Коммит
e9f5bc6870
|
@ -41,7 +41,6 @@
|
|||
#include "nsIFormControl.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFrameManager.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIScrollbar.h"
|
||||
|
@ -53,6 +52,7 @@
|
|||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIPref.h"
|
||||
|
@ -92,7 +92,6 @@ static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
|||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID);
|
||||
|
@ -106,7 +105,7 @@ static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
|
|||
#define EMPTY_DOCUMENT "about:blank"
|
||||
#define PASSWORD_REPLACEMENT_CHAR '*'
|
||||
|
||||
//#define NEW_WEBSHELL_INTERFACES
|
||||
#define NEW_WEBSHELL_INTERFACES
|
||||
|
||||
//#define NOISY
|
||||
const nscoord kSuggestedNotSet = -1;
|
||||
|
@ -131,6 +130,21 @@ NS_NewGfxTextControlFrame(nsIFrame** aNewFrame)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Frames are not refcounted, no need to AddRef
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIGfxTextControlFrame))) {
|
||||
*aInstancePtr = (void*)(nsIGfxTextControlFrame*) this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsTextControlFrame::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame::Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
|
@ -142,6 +156,17 @@ nsGfxTextControlFrame::Init(nsIPresContext& aPresContext,
|
|||
return (nsTextControlFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow));
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame::GetEditor(nsIEditor **aEditor)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEditor);
|
||||
|
||||
*aEditor = mEditor;
|
||||
NS_IF_ADDREF(*aEditor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame::CreateEditor()
|
||||
{
|
||||
|
@ -1087,17 +1112,19 @@ nsGfxTextControlFrame::CreateWebShell(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID,
|
||||
(void**)&mWebShell);
|
||||
if (NS_OK != rv) {
|
||||
NS_ENSURE_SUCCESS(
|
||||
nsComponentManager::CreateInstance(kWebShellCID, nsnull, nsIWebShell::GetIID(),
|
||||
(void**)&mWebShell),
|
||||
NS_ERROR_FAILURE);
|
||||
if (!mWebShell) {
|
||||
NS_ASSERTION(0, "could not create web widget");
|
||||
return rv;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// pass along marginwidth, marginheight, scrolling so sub document can use it
|
||||
|
||||
// pass along marginwidth and marginheight so sub document can use it
|
||||
mWebShell->SetMarginWidth(0);
|
||||
mWebShell->SetMarginHeight(0);
|
||||
|
||||
|
||||
/* our parent must be a webshell. we need to get our prefs from our parent */
|
||||
nsCOMPtr<nsISupports> container;
|
||||
aPresContext.GetContainer(getter_AddRefs(container));
|
||||
|
@ -2132,18 +2159,19 @@ nsGfxTextControlFrame::InstallEditor()
|
|||
|
||||
// initialize the editor
|
||||
result = mEditor->Init(mDoc, presShell, editorFlags);
|
||||
if (NS_FAILED(result)) { return result; }
|
||||
|
||||
// set data from the text control into the editor
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = InitializeTextControl(presShell, mDoc);
|
||||
}
|
||||
result = InitializeTextControl(presShell, mDoc);
|
||||
if (NS_FAILED(result)) { return result; }
|
||||
|
||||
// install our own event handlers before the editor's event handlers
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = InstallEventListeners();
|
||||
}
|
||||
result = InstallEventListeners();
|
||||
if (NS_FAILED(result)) { return result; }
|
||||
|
||||
// finish editor initialization, including event handler installation
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mEditor->PostCreate();
|
||||
}
|
||||
result = mEditor->PostCreate();
|
||||
if (NS_FAILED(result)) { return result; }
|
||||
|
||||
// check to see if mContent has focus, and if so tell the webshell.
|
||||
nsIEventStateManager *manager;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifndef nsGfxTextControlFrame_h___
|
||||
#define nsGfxTextControlFrame_h___
|
||||
|
||||
#include "nsIGfxTextControlFrame.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCWeakReference.h"
|
||||
#include "nsFormControlFrame.h"
|
||||
|
@ -333,7 +334,8 @@ protected:
|
|||
* and attaches an editor to the subdocument.
|
||||
******************************************************************************/
|
||||
|
||||
class nsGfxTextControlFrame : public nsTextControlFrame
|
||||
class nsGfxTextControlFrame : public nsTextControlFrame,
|
||||
public nsIGfxTextControlFrame
|
||||
{
|
||||
private:
|
||||
typedef nsFormControlFrame Inherited;
|
||||
|
@ -345,6 +347,9 @@ public:
|
|||
/** destructor */
|
||||
virtual ~nsGfxTextControlFrame();
|
||||
|
||||
/** needs it's own QI for nsIGfxTextControlFrame */
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
/** nsIFrame override of Init.
|
||||
* all we do here is cache the pres context for later use
|
||||
*/
|
||||
|
@ -453,6 +458,9 @@ public:
|
|||
// nsEnderEventListener::Focus
|
||||
PRBool DidSetFocus() { return mDidSetFocus; }
|
||||
|
||||
/* ============= nsIGfxTextControlFrame ================= */
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor);
|
||||
|
||||
protected:
|
||||
|
||||
/** calculate the inner region of the text control (size - border and padding) in pixels */
|
||||
|
@ -565,6 +573,11 @@ protected:
|
|||
|
||||
PRBool mDidSetFocus; // init false,
|
||||
|
||||
private: // frames are not refcounted
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче