зеркало из https://github.com/mozilla/gecko-dev.git
DOM extension for exposing text areas to XUL
bug 12022, r=rickg, vidur
This commit is contained in:
Родитель
ab8c72f310
Коммит
2c36996496
|
@ -96,6 +96,7 @@ CPPSRCS = \
|
|||
nsHTMLTitleElement.cpp \
|
||||
nsHTMLUListElement.cpp \
|
||||
nsHTMLWBRElement.cpp \
|
||||
nsEditorController.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -94,6 +94,7 @@ CPPSRCS= \
|
|||
nsHTMLTitleElement.cpp \
|
||||
nsHTMLUListElement.cpp \
|
||||
nsHTMLWBRElement.cpp \
|
||||
nsEditorController.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
|
@ -161,6 +162,7 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsHTMLTitleElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLUListElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLWBRElement.obj \
|
||||
.\$(OBJDIR)\nsEditorController.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
@ -338,9 +340,10 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresCo
|
|||
container->QueryInterface(kIWebShellIID, (void**) &webShell);
|
||||
if (nsnull != webShell) {
|
||||
nscoord pixel = NSIntPixelsToTwips(1, p2t);
|
||||
nscoord frameMarginWidth, frameMarginHeight;
|
||||
webShell->GetMarginWidth(frameMarginWidth); // -1 indicates not set
|
||||
webShell->GetMarginHeight(frameMarginHeight);
|
||||
nscoord frameMarginWidth=-1; // default value
|
||||
nscoord frameMarginHeight=-1; // default value
|
||||
webShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
|
||||
webShell->GetMarginHeight(&frameMarginHeight);
|
||||
if ((frameMarginWidth >= 0) && (0 > bodyMarginWidth)) { // set in <frame> & not in <body>
|
||||
if (eCompatibility_NavQuirks == mode) { // allow 0 margins
|
||||
if ((0 > bodyMarginHeight) && (0 > frameMarginHeight)) { // another nav quirk
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMNSHTMLTextAreaElement.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsEditorController.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComponentManager.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIForm.h"
|
||||
|
@ -44,8 +50,10 @@ static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
|
|||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
||||
static NS_DEFINE_IID(kIFocusableContentIID, NS_IFOCUSABLECONTENT_IID);
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
|
||||
class nsHTMLTextAreaElement : public nsIDOMHTMLTextAreaElement,
|
||||
public nsIDOMNSHTMLTextAreaElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent,
|
||||
|
@ -93,6 +101,9 @@ public:
|
|||
NS_IMETHOD Focus();
|
||||
NS_IMETHOD Select();
|
||||
|
||||
// nsIDOMNSHTMLTextAreaElement
|
||||
NS_DECL_IDOMNSHTMLTEXTAREAELEMENT
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
|
@ -117,6 +128,7 @@ public:
|
|||
protected:
|
||||
nsGenericHTMLContainerElement mInner;
|
||||
nsIForm* mForm;
|
||||
nsCOMPtr<nsIControllers> mControllers;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -161,6 +173,11 @@ nsHTMLTextAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsIDOMNSHTMLTextAreaElement::GetIID())) {
|
||||
*aInstancePtr = (void*)(nsIDOMNSHTMLTextAreaElement*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIFormControlIID)) {
|
||||
*aInstancePtr = (void*)(nsIFormControl*) this;
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -523,3 +540,34 @@ nsHTMLTextAreaElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
|||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Controllers Methods
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::GetControllers(nsIControllers** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!mControllers)
|
||||
{
|
||||
NS_ENSURE_SUCCESS (
|
||||
nsComponentManager::CreateInstance(kXULControllersCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIControllers),
|
||||
getter_AddRefs(mControllers)),
|
||||
NS_ERROR_FAILURE);
|
||||
if (!mControllers) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
nsEditorController *controller = new nsEditorController();
|
||||
if (!controller) { return NS_ERROR_NULL_POINTER; }
|
||||
nsCOMPtr<nsIController> iController = do_QueryInterface(controller);
|
||||
if (!iController) { return NS_ERROR_NULL_POINTER; }
|
||||
NS_ADDREF(controller);
|
||||
mControllers->AppendController(iController);
|
||||
controller->SetContent(this);
|
||||
}
|
||||
|
||||
*aResult = mControllers;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIEditor;
|
||||
|
||||
#define NS_IGFXTEXTCONTROLFRAME_IID \
|
||||
{/* d3ea33ea-9e00-11d3-bccc-0060b0fc76bd*/ \
|
||||
0xd3ea33ea, 0x9e00, 0x11d3, \
|
||||
{0xbc, 0xcc, 0x0, 0x60, 0xb0, 0xfc, 0x76, 0xbd} }
|
||||
|
||||
class nsIGfxTextControlFrame : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
};
|
|
@ -96,6 +96,7 @@ CPPSRCS = \
|
|||
nsHTMLTitleElement.cpp \
|
||||
nsHTMLUListElement.cpp \
|
||||
nsHTMLWBRElement.cpp \
|
||||
nsEditorController.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -94,6 +94,7 @@ CPPSRCS= \
|
|||
nsHTMLTitleElement.cpp \
|
||||
nsHTMLUListElement.cpp \
|
||||
nsHTMLWBRElement.cpp \
|
||||
nsEditorController.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
|
@ -161,6 +162,7 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsHTMLTitleElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLUListElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLWBRElement.obj \
|
||||
.\$(OBJDIR)\nsEditorController.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
|
||||
|
|
|
@ -0,0 +1,248 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsEditorController.h"
|
||||
#include "nsIGfxTextControlFrame.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsIDOMSelection.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsEditorController)
|
||||
NS_IMPL_RELEASE(nsEditorController)
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE1(nsEditorController, nsIController)
|
||||
|
||||
nsEditorController::nsEditorController()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mContent = nsnull;
|
||||
mUndoString = "cmd_undo";
|
||||
mRedoString = "cmd_redo";
|
||||
mCutString = "cmd_cut";
|
||||
mCopyString = "cmd_copy";
|
||||
mPasteString = "cmd_paste";
|
||||
mDeleteString = "cmd_delete";
|
||||
mSelectAllString = "cmd_selectAll";
|
||||
}
|
||||
|
||||
nsEditorController::~nsEditorController()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsEditorController::SetContent(nsIHTMLContent *aContent)
|
||||
{
|
||||
// indiscriminately sets mContent, no ref counting here
|
||||
mContent = aContent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* =======================================================================
|
||||
* nsIController
|
||||
* ======================================================================= */
|
||||
|
||||
NS_IMETHODIMP nsEditorController::IsCommandEnabled(const PRUnichar *aCommand, PRBool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
NS_ENSURE_SUCCESS(GetEditor(getter_AddRefs(editor)), NS_ERROR_FAILURE);
|
||||
if (!editor)
|
||||
{ // XXX: what does it mean if there is no editor? It means we've never had focus
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (PR_TRUE==mUndoString.Equals(aCommand))
|
||||
{ // we can undo if the editor says we can undo
|
||||
PRBool isEnabled;
|
||||
NS_ENSURE_SUCCESS(editor->CanUndo(isEnabled, *aResult), NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mRedoString.Equals(aCommand))
|
||||
{ // we can redo if the editor says we can undo
|
||||
PRBool isEnabled;
|
||||
NS_ENSURE_SUCCESS(editor->CanRedo(isEnabled, *aResult), NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mCutString.Equals(aCommand))
|
||||
{ // we can cut if the editor has a non-collapsed selection and is not readonly
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
NS_ENSURE_SUCCESS(editor->GetSelection(getter_AddRefs(selection)), NS_ERROR_FAILURE);
|
||||
if (selection)
|
||||
{
|
||||
PRBool collapsed;
|
||||
NS_ENSURE_SUCCESS(selection->GetIsCollapsed(&collapsed), NS_ERROR_FAILURE);
|
||||
if ((PR_FALSE==collapsed) && (PR_TRUE==IsEnabled())) {
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PR_TRUE==mCopyString.Equals(aCommand))
|
||||
{ // we can copy if the editor has a non-collapsed selection
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
NS_ENSURE_SUCCESS(editor->GetSelection(getter_AddRefs(selection)), NS_ERROR_FAILURE);
|
||||
if (selection)
|
||||
{
|
||||
PRBool collapsed;
|
||||
NS_ENSURE_SUCCESS(selection->GetIsCollapsed(&collapsed), NS_ERROR_FAILURE);
|
||||
if (PR_FALSE==collapsed) {
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PR_TRUE==mPasteString.Equals(aCommand))
|
||||
{ // paste is enabled if there is text on the clipbard and if the editor is not readonly or disabled
|
||||
// XXX: implement me
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
else if (PR_TRUE==mDeleteString.Equals(aCommand))
|
||||
{ // delete is enabled if there is any content and if the editor is not readonly or disabled
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
else if (PR_TRUE==mSelectAllString.Equals(aCommand))
|
||||
{ // selectAll is enabled if there is any content and if the editor is not disabled (readonly is ok)
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsEditorController::SupportsCommand(const PRUnichar *aCommand, PRBool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
// XXX: need to check the readonly and disabled states
|
||||
|
||||
*aResult = PR_FALSE;
|
||||
if ((PR_TRUE==mUndoString.Equals(aCommand)) ||
|
||||
(PR_TRUE==mRedoString.Equals(aCommand)) ||
|
||||
(PR_TRUE==mCutString.Equals(aCommand)) ||
|
||||
(PR_TRUE==mCopyString.Equals(aCommand)) ||
|
||||
(PR_TRUE==mPasteString.Equals(aCommand)) ||
|
||||
(PR_TRUE==mDeleteString.Equals(aCommand)) ||
|
||||
(PR_TRUE==mSelectAllString.Equals(aCommand))
|
||||
)
|
||||
{
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsEditorController::DoCommand(const PRUnichar *aCommand)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
NS_ENSURE_SUCCESS(GetEditor(getter_AddRefs(editor)), NS_ERROR_FAILURE);
|
||||
if (!editor)
|
||||
{ // XXX: what does it mean if there is no editor? It means we've never had focus, so we can't do anything
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (PR_TRUE==mUndoString.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->Undo(1), NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mRedoString.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->Redo(1), NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mCutString.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->Cut(), NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mCopyString.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->Copy(), NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mPasteString.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->Paste(), NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mDeleteString.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->DeleteSelection(nsIEditor::eDeleteNext), NS_ERROR_FAILURE);
|
||||
}
|
||||
else if (PR_TRUE==mSelectAllString.Equals(aCommand))
|
||||
{
|
||||
NS_ENSURE_SUCCESS(editor->SelectAll(), NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsEditorController::OnEvent(const PRUnichar *aEventName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEventName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditorController::GetEditor(nsIEditor ** aEditor)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEditor);
|
||||
|
||||
nsIGfxTextControlFrame *frame;
|
||||
NS_ENSURE_SUCCESS(GetFrame(&frame), NS_ERROR_FAILURE);
|
||||
if (!frame) { return NS_ERROR_FAILURE; }
|
||||
|
||||
NS_ENSURE_SUCCESS(frame->GetEditor(aEditor), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsEditorController::GetFrame(nsIGfxTextControlFrame **aFrame)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFrame);
|
||||
*aFrame = nsnull;
|
||||
NS_ENSURE_STATE(mContent);
|
||||
|
||||
nsIFormControlFrame *frame = nsnull;
|
||||
NS_ENSURE_SUCCESS(
|
||||
nsGenericHTMLElement::GetPrimaryFrame(mContent, frame),
|
||||
NS_ERROR_FAILURE
|
||||
);
|
||||
if (!frame) { return NS_ERROR_FAILURE; }
|
||||
|
||||
NS_ENSURE_SUCCESS(
|
||||
frame->QueryInterface(nsIGfxTextControlFrame::GetIID(), (void**)aFrame),
|
||||
NS_ERROR_FAILURE
|
||||
);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsEditorController::IsEnabled()
|
||||
{
|
||||
return PR_TRUE; // XXX: need to implement this
|
||||
/*
|
||||
PRUint32 flags=0;
|
||||
NS_ENSURE_SUCCESS(mEditor->GetFlags(&flags), NS_ERROR_FAILURE);
|
||||
check eEditorReadonlyBit and eEditorDisabledBit
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#define NS_EDITORCONTROLLERS_CID \
|
||||
{ 0x26fb965c, 0x9de6, 0x11d3, { 0xbc, 0xcc, 0x0, 0x60, 0xb0, 0xfc, 0x76, 0xbd } }
|
||||
|
||||
#include "nsIController.h"
|
||||
|
||||
#include "nsString2.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIHTMLContent;
|
||||
class nsIGfxTextControlFrame;
|
||||
class nsIEditor;
|
||||
|
||||
class nsEditorController : public nsIController
|
||||
{
|
||||
public:
|
||||
nsEditorController();
|
||||
virtual ~nsEditorController();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIController
|
||||
NS_DECL_NSICONTROLLER
|
||||
|
||||
/** set the content for this controller instance */
|
||||
NS_IMETHOD SetContent(nsIHTMLContent *aContent);
|
||||
|
||||
protected:
|
||||
|
||||
/** fetch the primary frame associated with mContent */
|
||||
NS_IMETHOD GetFrame(nsIGfxTextControlFrame **aFrame);
|
||||
|
||||
/** fetch the editor associated with mContent */
|
||||
NS_IMETHOD GetEditor(nsIEditor ** aEditor);
|
||||
|
||||
/** return PR_TRUE if the editor associated with mContent is enabled */
|
||||
PRBool IsEnabled();
|
||||
|
||||
// XXX: should be static
|
||||
nsString mUndoString;
|
||||
nsString mRedoString;
|
||||
nsString mCutString;
|
||||
nsString mCopyString;
|
||||
nsString mPasteString;
|
||||
nsString mDeleteString;
|
||||
nsString mSelectAllString;
|
||||
|
||||
protected:
|
||||
nsIHTMLContent* mContent; // weak reference, the content object owns this object
|
||||
};
|
|
@ -39,6 +39,8 @@
|
|||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIHTMLAttributes.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
@ -338,9 +340,10 @@ BodyRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresCo
|
|||
container->QueryInterface(kIWebShellIID, (void**) &webShell);
|
||||
if (nsnull != webShell) {
|
||||
nscoord pixel = NSIntPixelsToTwips(1, p2t);
|
||||
nscoord frameMarginWidth, frameMarginHeight;
|
||||
webShell->GetMarginWidth(frameMarginWidth); // -1 indicates not set
|
||||
webShell->GetMarginHeight(frameMarginHeight);
|
||||
nscoord frameMarginWidth=-1; // default value
|
||||
nscoord frameMarginHeight=-1; // default value
|
||||
webShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
|
||||
webShell->GetMarginHeight(&frameMarginHeight);
|
||||
if ((frameMarginWidth >= 0) && (0 > bodyMarginWidth)) { // set in <frame> & not in <body>
|
||||
if (eCompatibility_NavQuirks == mode) { // allow 0 margins
|
||||
if ((0 > bodyMarginHeight) && (0 > frameMarginHeight)) { // another nav quirk
|
||||
|
|
|
@ -20,6 +20,12 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMNSHTMLTextAreaElement.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsEditorController.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComponentManager.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIForm.h"
|
||||
|
@ -44,8 +50,10 @@ static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
|
|||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
|
||||
static NS_DEFINE_IID(kIFocusableContentIID, NS_IFOCUSABLECONTENT_IID);
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
|
||||
class nsHTMLTextAreaElement : public nsIDOMHTMLTextAreaElement,
|
||||
public nsIDOMNSHTMLTextAreaElement,
|
||||
public nsIScriptObjectOwner,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIHTMLContent,
|
||||
|
@ -93,6 +101,9 @@ public:
|
|||
NS_IMETHOD Focus();
|
||||
NS_IMETHOD Select();
|
||||
|
||||
// nsIDOMNSHTMLTextAreaElement
|
||||
NS_DECL_IDOMNSHTMLTEXTAREAELEMENT
|
||||
|
||||
// nsIScriptObjectOwner
|
||||
NS_IMPL_ISCRIPTOBJECTOWNER_USING_GENERIC(mInner)
|
||||
|
||||
|
@ -117,6 +128,7 @@ public:
|
|||
protected:
|
||||
nsGenericHTMLContainerElement mInner;
|
||||
nsIForm* mForm;
|
||||
nsCOMPtr<nsIControllers> mControllers;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -161,6 +173,11 @@ nsHTMLTextAreaElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsIDOMNSHTMLTextAreaElement::GetIID())) {
|
||||
*aInstancePtr = (void*)(nsIDOMNSHTMLTextAreaElement*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIFormControlIID)) {
|
||||
*aInstancePtr = (void*)(nsIFormControl*) this;
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -523,3 +540,34 @@ nsHTMLTextAreaElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
|||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Controllers Methods
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::GetControllers(nsIControllers** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!mControllers)
|
||||
{
|
||||
NS_ENSURE_SUCCESS (
|
||||
nsComponentManager::CreateInstance(kXULControllersCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIControllers),
|
||||
getter_AddRefs(mControllers)),
|
||||
NS_ERROR_FAILURE);
|
||||
if (!mControllers) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
nsEditorController *controller = new nsEditorController();
|
||||
if (!controller) { return NS_ERROR_NULL_POINTER; }
|
||||
nsCOMPtr<nsIController> iController = do_QueryInterface(controller);
|
||||
if (!iController) { return NS_ERROR_NULL_POINTER; }
|
||||
NS_ADDREF(controller);
|
||||
mControllers->AppendController(iController);
|
||||
controller->SetContent(this);
|
||||
}
|
||||
|
||||
*aResult = mControllers;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIEditor;
|
||||
|
||||
#define NS_IGFXTEXTCONTROLFRAME_IID \
|
||||
{/* d3ea33ea-9e00-11d3-bccc-0060b0fc76bd*/ \
|
||||
0xd3ea33ea, 0x9e00, 0x11d3, \
|
||||
{0xbc, 0xcc, 0x0, 0x60, 0xb0, 0xfc, 0x76, 0xbd} }
|
||||
|
||||
class nsIGfxTextControlFrame : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
};
|
|
@ -0,0 +1,38 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIEditor;
|
||||
|
||||
#define NS_IGFXTEXTCONTROLFRAME_IID \
|
||||
{/* d3ea33ea-9e00-11d3-bccc-0060b0fc76bd*/ \
|
||||
0xd3ea33ea, 0x9e00, 0x11d3, \
|
||||
{0xbc, 0xcc, 0x0, 0x60, 0xb0, 0xfc, 0x76, 0xbd} }
|
||||
|
||||
class nsIGfxTextControlFrame : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
};
|
Загрузка…
Ссылка в новой задаче