2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsHTMLEditor_h__
|
|
|
|
#define nsHTMLEditor_h__
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsPlaintextEditor.h"
|
|
|
|
#include "nsIEditor.h"
|
|
|
|
#include "nsIHTMLEditor.h"
|
|
|
|
#include "nsITableEditor.h"
|
|
|
|
#include "nsIEditorMailSupport.h"
|
|
|
|
#include "nsIEditorStyleSheets.h"
|
|
|
|
#include "nsITextServicesDocument.h"
|
|
|
|
|
|
|
|
#include "nsEditor.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsICSSLoaderObserver.h"
|
|
|
|
#include "nsITableLayout.h"
|
|
|
|
|
|
|
|
#include "nsEditRules.h"
|
|
|
|
|
|
|
|
#include "nsEditProperty.h"
|
|
|
|
#include "nsHTMLCSSUtils.h"
|
|
|
|
|
|
|
|
#include "nsHTMLObjectResizer.h"
|
|
|
|
#include "nsIHTMLAbsPosEditor.h"
|
|
|
|
#include "nsIHTMLInlineTableEditor.h"
|
|
|
|
#include "nsIHTMLObjectResizeListener.h"
|
|
|
|
|
|
|
|
#include "nsIDocumentObserver.h"
|
|
|
|
|
|
|
|
#include "nsPoint.h"
|
2007-11-12 17:41:40 -08:00
|
|
|
#include "nsTArray.h"
|
2010-05-11 13:41:47 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2012-02-10 02:04:46 -08:00
|
|
|
#include "nsAttrName.h"
|
|
|
|
|
2012-05-18 01:29:38 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-02-10 02:04:46 -08:00
|
|
|
#include "mozilla/dom/Element.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIDOMKeyEvent;
|
|
|
|
class nsITransferable;
|
|
|
|
class nsIDocumentEncoder;
|
|
|
|
class nsIClipboard;
|
|
|
|
class TypeInState;
|
|
|
|
class nsIContentFilter;
|
|
|
|
class nsIURL;
|
|
|
|
class nsILinkHandler;
|
2009-04-22 01:43:15 -07:00
|
|
|
struct PropItem;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-27 03:51:53 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
struct IMEState;
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* The HTML editor implementation.<br>
|
|
|
|
* Use to edit HTML document represented as a DOM tree.
|
|
|
|
*/
|
|
|
|
class nsHTMLEditor : public nsPlaintextEditor,
|
|
|
|
public nsIHTMLEditor,
|
|
|
|
public nsIHTMLObjectResizer,
|
|
|
|
public nsIHTMLAbsPosEditor,
|
|
|
|
public nsITableEditor,
|
|
|
|
public nsIHTMLInlineTableEditor,
|
|
|
|
public nsIEditorStyleSheets,
|
2010-06-16 22:31:15 -07:00
|
|
|
public nsICSSLoaderObserver,
|
|
|
|
public nsStubMutationObserver
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum ResizingRequestID
|
|
|
|
{
|
|
|
|
kX = 0,
|
|
|
|
kY = 1,
|
|
|
|
kWidth = 2,
|
|
|
|
kHeight = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
// see nsIHTMLEditor for documentation
|
|
|
|
|
|
|
|
//Interfaces for addref and release and queryinterface
|
|
|
|
//NOTE macro used is for classes that inherit from
|
|
|
|
// another class. Only the base class should use NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2011-02-16 04:07:47 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLEditor, nsPlaintextEditor)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
nsHTMLEditor();
|
|
|
|
virtual ~nsHTMLEditor();
|
|
|
|
|
|
|
|
/* ------------ nsPlaintextEditor overrides -------------- */
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD GetIsDocumentEditable(bool *aIsDocumentEditable);
|
2010-11-11 13:40:55 -08:00
|
|
|
NS_IMETHOD BeginningOfDocument();
|
2010-06-09 18:16:58 -07:00
|
|
|
virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent);
|
2010-10-29 09:30:52 -07:00
|
|
|
virtual already_AddRefed<nsIContent> GetFocusedContent();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsActiveInDOMWindow();
|
2011-06-23 19:18:01 -07:00
|
|
|
virtual already_AddRefed<nsIDOMEventTarget> GetDOMEventTarget();
|
2012-05-06 00:53:11 -07:00
|
|
|
virtual mozilla::dom::Element* GetEditorRoot() MOZ_OVERRIDE;
|
2010-06-19 03:39:39 -07:00
|
|
|
virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode *aNode);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent);
|
2012-03-26 18:36:44 -07:00
|
|
|
virtual already_AddRefed<nsIContent> GetInputEventTargetContent();
|
2010-11-16 12:45:49 -08:00
|
|
|
virtual bool IsEditable(nsIContent *aNode);
|
|
|
|
using nsEditor::IsEditable;
|
2010-05-04 10:40:39 -07:00
|
|
|
|
2010-06-16 22:31:15 -07:00
|
|
|
/* ------------ nsStubMutationObserver overrides --------- */
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
|
2010-05-04 10:40:39 -07:00
|
|
|
/* ------------ nsIEditorIMESupport overrides ------------ */
|
2011-11-27 03:51:53 -08:00
|
|
|
NS_IMETHOD GetPreferredIMEState(mozilla::widget::IMEState *aState);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* ------------ nsIHTMLEditor methods -------------- */
|
|
|
|
|
|
|
|
NS_DECL_NSIHTMLEDITOR
|
|
|
|
|
|
|
|
/* ------------ nsIHTMLObjectResizer methods -------------- */
|
|
|
|
/* -------- Implemented in nsHTMLObjectResizer.cpp -------- */
|
|
|
|
NS_DECL_NSIHTMLOBJECTRESIZER
|
|
|
|
|
|
|
|
/* ------------ nsIHTMLAbsPosEditor methods -------------- */
|
|
|
|
/* -------- Implemented in nsHTMLAbsPosition.cpp --------- */
|
|
|
|
NS_DECL_NSIHTMLABSPOSEDITOR
|
|
|
|
|
|
|
|
/* ------------ nsIHTMLInlineTableEditor methods -------------- */
|
|
|
|
/* ------- Implemented in nsHTMLInlineTableEditor.cpp --------- */
|
|
|
|
NS_DECL_NSIHTMLINLINETABLEEDITOR
|
|
|
|
|
|
|
|
/* ------------ nsIHTMLEditor methods -------------- */
|
|
|
|
NS_IMETHOD CopyLastEditableChildStyles(nsIDOMNode *aPreviousBlock, nsIDOMNode *aNewBlock,
|
|
|
|
nsIDOMNode **aOutBrNode);
|
|
|
|
|
|
|
|
NS_IMETHOD LoadHTML(const nsAString &aInputString);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor,
|
|
|
|
bool aBlockLevel);
|
|
|
|
NS_IMETHOD GetHTMLBackgroundColorState(bool *aMixed, nsAString &outColor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* ------------ nsIEditorStyleSheets methods -------------- */
|
|
|
|
|
|
|
|
NS_IMETHOD AddStyleSheet(const nsAString & aURL);
|
|
|
|
NS_IMETHOD ReplaceStyleSheet(const nsAString& aURL);
|
|
|
|
NS_IMETHOD RemoveStyleSheet(const nsAString &aURL);
|
|
|
|
|
|
|
|
NS_IMETHOD AddOverrideStyleSheet(const nsAString & aURL);
|
|
|
|
NS_IMETHOD ReplaceOverrideStyleSheet(const nsAString& aURL);
|
|
|
|
NS_IMETHOD RemoveOverrideStyleSheet(const nsAString &aURL);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD EnableStyleSheet(const nsAString& aURL, bool aEnable);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* ------------ nsIEditorMailSupport methods -------------- */
|
|
|
|
|
|
|
|
NS_DECL_NSIEDITORMAILSUPPORT
|
|
|
|
|
|
|
|
/* ------------ nsITableEditor methods -------------- */
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD InsertTableCell(PRInt32 aNumber, bool aAfter);
|
|
|
|
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, bool aAfter);
|
|
|
|
NS_IMETHOD InsertTableRow(PRInt32 aNumber, bool aAfter);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD DeleteTable();
|
|
|
|
NS_IMETHOD DeleteTableCell(PRInt32 aNumber);
|
|
|
|
NS_IMETHOD DeleteTableCellContents();
|
|
|
|
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
|
|
|
|
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
|
|
|
|
NS_IMETHOD SelectTableCell();
|
|
|
|
NS_IMETHOD SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndCell);
|
|
|
|
NS_IMETHOD SelectTableRow();
|
|
|
|
NS_IMETHOD SelectTableColumn();
|
|
|
|
NS_IMETHOD SelectTable();
|
|
|
|
NS_IMETHOD SelectAllTableCells();
|
|
|
|
NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD JoinTableCells(bool aMergeNonContiguousContents);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD SplitTableCell();
|
|
|
|
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
|
|
|
|
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell,
|
|
|
|
PRInt32* aRowIndex, PRInt32* aColIndex);
|
|
|
|
NS_IMETHOD GetTableSize(nsIDOMElement *aTable,
|
|
|
|
PRInt32* aRowCount, PRInt32* aColCount);
|
|
|
|
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement **aCell);
|
|
|
|
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable,
|
|
|
|
PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
nsIDOMElement **aCell,
|
|
|
|
PRInt32* aStartRowIndex, PRInt32* aStartColIndex,
|
|
|
|
PRInt32* aRowSpan, PRInt32* aColSpan,
|
|
|
|
PRInt32* aActualRowSpan, PRInt32* aActualColSpan,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aIsSelected);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement, nsIDOMNode** aRowNode);
|
|
|
|
NS_IMETHOD GetNextRow(nsIDOMNode* aCurrentRowNode, nsIDOMNode** aRowNode);
|
|
|
|
NS_IMETHOD GetLastCellInRow(nsIDOMNode* aRowNode, nsIDOMNode** aCellNode);
|
|
|
|
|
|
|
|
NS_IMETHOD SetSelectionAfterTableEdit(nsIDOMElement* aTable, PRInt32 aRow, PRInt32 aCol,
|
2011-09-28 23:19:26 -07:00
|
|
|
PRInt32 aDirection, bool aSelected);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD GetSelectedOrParentTableElement(nsAString& aTagName,
|
|
|
|
PRInt32 *aSelectedCount,
|
|
|
|
nsIDOMElement** aTableElement);
|
|
|
|
NS_IMETHOD GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 *aSelectionType);
|
|
|
|
|
|
|
|
nsresult GetCellFromRange(nsIDOMRange *aRange, nsIDOMElement **aCell);
|
|
|
|
|
|
|
|
// Finds the first selected cell in first range of selection
|
|
|
|
// This is in the *order of selection*, not order in the table
|
|
|
|
// (i.e., each cell added to selection is added in another range
|
|
|
|
// in the selection's rangelist, independent of location in table)
|
|
|
|
// aRange is optional: returns the range around the cell
|
|
|
|
NS_IMETHOD GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell);
|
|
|
|
// Get next cell until no more are found. Always use GetFirstSelected cell first
|
|
|
|
// aRange is optional: returns the range around the cell
|
|
|
|
NS_IMETHOD GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell);
|
|
|
|
|
|
|
|
// Upper-left-most selected cell in table
|
|
|
|
NS_IMETHOD GetFirstSelectedCellInTable(PRInt32 *aRowIndex, PRInt32 *aColIndex, nsIDOMElement **aCell);
|
|
|
|
|
|
|
|
/* miscellaneous */
|
|
|
|
// This sets background on the appropriate container element (table, cell,)
|
|
|
|
// or calls into nsTextEditor to set the page background
|
|
|
|
NS_IMETHOD SetCSSBackgroundColor(const nsAString& aColor);
|
|
|
|
NS_IMETHOD SetHTMLBackgroundColor(const nsAString& aColor);
|
|
|
|
|
|
|
|
/* ------------ Block methods moved from nsEditor -------------- */
|
2011-08-11 06:29:59 -07:00
|
|
|
static already_AddRefed<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-11 06:29:59 -07:00
|
|
|
static already_AddRefed<nsIDOMNode> NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode,
|
|
|
|
PRInt32 aOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *outIsSpace,
|
|
|
|
bool *outIsNBSP,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> *outNode = 0,
|
|
|
|
PRInt32 *outOffset = 0);
|
|
|
|
nsresult IsPrevCharWhitespace(nsIDOMNode *aParentNode,
|
|
|
|
PRInt32 aOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *outIsSpace,
|
|
|
|
bool *outIsNBSP,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> *outNode = 0,
|
|
|
|
PRInt32 *outOffset = 0);
|
|
|
|
|
|
|
|
/* ------------ Overrides of nsEditor interface methods -------------- */
|
|
|
|
|
|
|
|
nsresult EndUpdateViewBatch();
|
|
|
|
|
|
|
|
/** prepare the editor for use */
|
2011-03-10 21:40:31 -08:00
|
|
|
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD PreDestroy(bool aDestroyingFrames);
|
2010-06-16 22:31:15 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/** Internal, static version */
|
2011-09-28 23:19:26 -07:00
|
|
|
static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, bool *aIsBlock);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD SetFlags(PRUint32 aFlags);
|
|
|
|
|
|
|
|
NS_IMETHOD Paste(PRInt32 aSelectionType);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD CanPaste(PRInt32 aSelectionType, bool *aCanPaste);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-01-10 17:45:45 -08:00
|
|
|
NS_IMETHOD PasteTransferable(nsITransferable *aTransferable);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste);
|
2010-01-10 17:45:45 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
|
|
|
|
|
|
|
/** All editor operations which alter the doc should be prefaced
|
|
|
|
* with a call to StartOperation, naming the action and direction */
|
2012-05-05 11:52:29 -07:00
|
|
|
NS_IMETHOD StartOperation(OperationID opID,
|
|
|
|
nsIEditor::EDirection aDirection);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** All editor operations which alter the doc should be followed
|
|
|
|
* with a call to EndOperation */
|
|
|
|
NS_IMETHOD EndOperation();
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aParentTag can contain a child of type aChildTag */
|
2012-04-30 23:34:52 -07:00
|
|
|
virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aNode is a container */
|
2012-01-24 23:50:05 -08:00
|
|
|
virtual bool IsContainer(nsINode* aNode);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsContainer(nsIDOMNode *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** make the given selection span the entire document */
|
|
|
|
NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
|
|
|
|
|
|
|
|
NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
|
|
|
const nsAString & aAttribute,
|
|
|
|
const nsAString & aValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aSuppressTransaction);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
|
|
|
|
const nsAString & aAttribute,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aSuppressTransaction);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-18 01:29:38 -07:00
|
|
|
/** join together any adjacent editable text nodes in the range */
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange);
|
|
|
|
|
2012-05-18 01:29:38 -07:00
|
|
|
virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2)
|
|
|
|
MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-10 07:54:33 -07:00
|
|
|
NS_IMETHOD DeleteSelectionImpl(EDirection aAction,
|
|
|
|
EStripWrappers aStripWrappers);
|
|
|
|
nsresult DeleteNode(nsINode* aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP DeleteNode(nsIDOMNode * aNode);
|
|
|
|
NS_IMETHODIMP DeleteText(nsIDOMCharacterData *aTextNode,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
PRUint32 aLength);
|
2007-06-27 19:48:16 -07:00
|
|
|
NS_IMETHOD InsertTextImpl(const nsAString& aStringToInsert,
|
|
|
|
nsCOMPtr<nsIDOMNode> *aInOutNode,
|
|
|
|
PRInt32 *aInOutOffset,
|
|
|
|
nsIDOMDocument *aDoc);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD_(bool) IsModifiableNode(nsIDOMNode *aNode);
|
2011-11-28 04:53:29 -08:00
|
|
|
virtual bool IsModifiableNode(nsINode *aNode);
|
2007-06-27 19:48:16 -07:00
|
|
|
|
|
|
|
NS_IMETHOD SelectAll();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-16 22:29:40 -07:00
|
|
|
NS_IMETHOD GetRootElement(nsIDOMElement **aRootElement);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* ------------ nsICSSLoaderObserver -------------- */
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet*aSheet, bool aWasAlternate,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult aStatus);
|
|
|
|
|
|
|
|
/* ------------ Utility Routines, not part of public API -------------- */
|
|
|
|
NS_IMETHOD TypedText(const nsAString& aString, PRInt32 aAction);
|
|
|
|
nsresult InsertNodeAtPoint( nsIDOMNode *aNode,
|
|
|
|
nsCOMPtr<nsIDOMNode> *ioParent,
|
|
|
|
PRInt32 *ioOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNoEmptyNodes);
|
2012-02-17 06:16:59 -08:00
|
|
|
virtual already_AddRefed<nsIDOMNode> FindUserSelectAllNode(nsIDOMNode* aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** returns the absolute position of the end points of aSelection
|
|
|
|
* in the document as a text stream.
|
|
|
|
*/
|
|
|
|
nsresult GetTextSelectionOffsets(nsISelection *aSelection,
|
|
|
|
PRInt32 &aStartOffset,
|
|
|
|
PRInt32 &aEndOffset);
|
|
|
|
|
|
|
|
// Use this to assure that selection is set after attribute nodes when
|
|
|
|
// trying to collapse selection at begining of a block node
|
|
|
|
// e.g., when setting at beginning of a table cell
|
|
|
|
// This will stop at a table, however, since we don't want to
|
|
|
|
// "drill down" into nested tables.
|
|
|
|
// aSelection is optional -- if null, we get current seletion
|
|
|
|
nsresult CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode);
|
|
|
|
|
2012-05-05 02:00:06 -07:00
|
|
|
/**
|
|
|
|
* aNode must be a non-null text node.
|
|
|
|
*/
|
2011-11-28 04:53:29 -08:00
|
|
|
virtual bool IsTextInDirtyFrameVisible(nsIContent *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-05 02:00:06 -07:00
|
|
|
/**
|
|
|
|
* aNode must be a non-null text node.
|
|
|
|
* outIsEmptyNode must be non-null.
|
|
|
|
*/
|
2012-01-24 23:50:05 -08:00
|
|
|
nsresult IsVisTextNode(nsIContent* aNode,
|
|
|
|
bool* outIsEmptyNode,
|
|
|
|
bool aSafeToAskFrames);
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult IsEmptyNode(nsIDOMNode *aNode, bool *outIsEmptyBlock,
|
|
|
|
bool aMozBRDoesntCount = false,
|
|
|
|
bool aListOrCellNotEmpty = false,
|
|
|
|
bool aSafeToAskFrames = false);
|
2012-01-24 23:50:06 -08:00
|
|
|
nsresult IsEmptyNode(nsINode* aNode, bool* outIsEmptyBlock,
|
|
|
|
bool aMozBRDoesntCount = false,
|
|
|
|
bool aListOrCellNotEmpty = false,
|
|
|
|
bool aSafeToAskFrames = false);
|
2012-01-24 23:50:05 -08:00
|
|
|
nsresult IsEmptyNodeImpl(nsINode* aNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *outIsEmptyBlock,
|
|
|
|
bool aMozBRDoesntCount,
|
|
|
|
bool aListOrCellNotEmpty,
|
|
|
|
bool aSafeToAskFrames,
|
|
|
|
bool *aSeenBR);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Returns TRUE if sheet was loaded, false if it wasn't
|
2011-09-28 23:19:26 -07:00
|
|
|
bool EnableExistingStyleSheet(const nsAString& aURL);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Dealing with the internal style sheet lists:
|
|
|
|
NS_IMETHOD GetStyleSheetForURL(const nsAString &aURL,
|
2010-05-11 13:41:47 -07:00
|
|
|
nsCSSStyleSheet **_retval);
|
|
|
|
NS_IMETHOD GetURLForStyleSheet(nsCSSStyleSheet *aStyleSheet, nsAString &aURL);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Add a url + known style sheet to the internal lists:
|
|
|
|
nsresult AddNewStyleSheetToList(const nsAString &aURL,
|
2010-05-11 13:41:47 -07:00
|
|
|
nsCSSStyleSheet *aStyleSheet);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult RemoveStyleSheetFromList(const nsAString &aURL);
|
2012-02-01 02:54:22 -08:00
|
|
|
|
|
|
|
bool IsCSSEnabled()
|
|
|
|
{
|
|
|
|
// TODO: removal of mCSSAware and use only the presence of mHTMLCSSUtils
|
|
|
|
return mCSSAware && mHTMLCSSUtils && mHTMLCSSUtils->IsCSSPrefChecked();
|
|
|
|
}
|
|
|
|
|
2012-02-10 02:04:46 -08:00
|
|
|
static bool HasAttributes(mozilla::dom::Element* aElement)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aElement);
|
|
|
|
PRUint32 attrCount = aElement->GetAttrCount();
|
|
|
|
return attrCount > 1 ||
|
|
|
|
(1 == attrCount && !aElement->GetAttrNameAt(0)->Equals(nsGkAtoms::mozdirty));
|
|
|
|
}
|
2012-02-01 02:54:22 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
NS_IMETHOD InitRules();
|
|
|
|
|
|
|
|
// Create the event listeners for the editor to install
|
2011-07-15 03:18:35 -07:00
|
|
|
virtual void CreateEventListeners();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-19 05:20:42 -07:00
|
|
|
virtual nsresult InstallEventListeners();
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void RemoveEventListeners();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ShouldReplaceRootElement();
|
2010-06-16 22:32:05 -07:00
|
|
|
void ResetRootElementAndEventTarget();
|
2010-06-16 22:29:40 -07:00
|
|
|
nsresult GetBodyElement(nsIDOMHTMLElement** aBody);
|
2010-07-22 09:22:44 -07:00
|
|
|
// Get the focused node of this editor.
|
|
|
|
// @return If the editor has focus, this returns the focused node.
|
|
|
|
// Otherwise, returns null.
|
2010-06-16 22:32:05 -07:00
|
|
|
already_AddRefed<nsINode> GetFocusedNode();
|
2010-06-16 22:29:40 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Return TRUE if aElement is a table-related elemet and caret was set
|
2011-09-28 23:19:26 -07:00
|
|
|
bool SetCaretInTableCell(nsIDOMElement* aElement);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// key event helpers
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD CreateBR(nsIDOMNode *aNode, PRInt32 aOffset,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outBRNode, nsIEditor::EDirection aSelect = nsIEditor::eNone);
|
|
|
|
|
|
|
|
// Table Editing (implemented in nsTableEditor.cpp)
|
|
|
|
|
|
|
|
// Table utilities
|
|
|
|
|
|
|
|
// Insert a new cell after or before supplied aCell.
|
|
|
|
// Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course)
|
|
|
|
// This doesn't change or use the current selection
|
|
|
|
NS_IMETHOD InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpan,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAfter, bool aIsHeader, nsIDOMElement **aNewCell);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Helpers that don't touch the selection or do batch transactions
|
|
|
|
NS_IMETHOD DeleteRow(nsIDOMElement *aTable, PRInt32 aRowIndex);
|
|
|
|
NS_IMETHOD DeleteColumn(nsIDOMElement *aTable, PRInt32 aColIndex);
|
|
|
|
NS_IMETHOD DeleteCellContents(nsIDOMElement *aCell);
|
|
|
|
|
|
|
|
// Move all contents from aCellToMerge into aTargetCell (append at end)
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell, nsCOMPtr<nsIDOMElement> aCellToMerge, bool aDeleteCellToMerge);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD DeleteTable2(nsIDOMElement *aTable, nsISelection *aSelection);
|
|
|
|
NS_IMETHOD SetColSpan(nsIDOMElement *aCell, PRInt32 aColSpan);
|
|
|
|
NS_IMETHOD SetRowSpan(nsIDOMElement *aCell, PRInt32 aRowSpan);
|
|
|
|
|
|
|
|
// Helper used to get nsITableLayout interface for methods implemented in nsTableFrame
|
|
|
|
NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
|
|
|
|
// Needed to do appropriate deleting when last cell or row is about to be deleted
|
|
|
|
// This doesn't count cells that don't start in the given row (are spanning from row above)
|
|
|
|
PRInt32 GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex);
|
|
|
|
// Test if all cells in row or column at given index are selected
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AllCellsInRowSelected(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aNumberOfColumns);
|
|
|
|
bool AllCellsInColumnSelected(nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32 aNumberOfRows);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsEmptyCell(nsIDOMElement *aCell);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Most insert methods need to get the same basic context data
|
|
|
|
// Any of the pointers may be null if you don't need that datum (for more efficiency)
|
|
|
|
// Input: *aCell is a known cell,
|
|
|
|
// if null, cell is obtained from the anchor node of the selection
|
|
|
|
// Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is null
|
|
|
|
NS_IMETHOD GetCellContext(nsISelection **aSelection,
|
|
|
|
nsIDOMElement **aTable,
|
|
|
|
nsIDOMElement **aCell,
|
|
|
|
nsIDOMNode **aCellParent, PRInt32 *aCellOffset,
|
|
|
|
PRInt32 *aRowIndex, PRInt32 *aColIndex);
|
|
|
|
|
|
|
|
NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
PRInt32& aActualRowSpan, PRInt32& aActualColSpan);
|
|
|
|
|
|
|
|
NS_IMETHOD SplitCellIntoColumns(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
PRInt32 aColSpanLeft, PRInt32 aColSpanRight, nsIDOMElement **aNewCell);
|
|
|
|
|
|
|
|
NS_IMETHOD SplitCellIntoRows(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
PRInt32 aRowSpanAbove, PRInt32 aRowSpanBelow, nsIDOMElement **aNewCell);
|
|
|
|
|
|
|
|
nsresult CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *sourceCell);
|
|
|
|
|
2010-05-23 12:26:15 -07:00
|
|
|
// Reduce rowspan/colspan when cells span into nonexistent rows/columns
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD FixBadRowSpan(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32& aNewRowCount);
|
|
|
|
NS_IMETHOD FixBadColSpan(nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32& aNewColCount);
|
|
|
|
|
|
|
|
// Fallback method: Call this after using ClearSelection() and you
|
|
|
|
// failed to set selection to some other content in the document
|
|
|
|
NS_IMETHOD SetSelectionAtDocumentStart(nsISelection *aSelection);
|
|
|
|
|
|
|
|
// End of Table Editing utilities
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsBlockNode(nsIDOMNode *aNode);
|
2011-11-28 04:53:29 -08:00
|
|
|
virtual bool IsBlockNode(nsINode *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static nsCOMPtr<nsIDOMNode> GetEnclosingTable(nsIDOMNode *aNode);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** content-based query returns true if <aProperty aAttribute=aValue> effects aNode
|
2007-03-22 10:30:00 -07:00
|
|
|
* If <aProperty aAttribute=aValue> contains aNode,
|
|
|
|
* but <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
|
|
|
|
* more deeply nested than the first, then the first does not effect aNode.
|
|
|
|
*
|
|
|
|
* @param aNode The target of the query
|
|
|
|
* @param aProperty The property that we are querying for
|
|
|
|
* @param aAttribute The attribute of aProperty, example: color in <FONT color="blue">
|
|
|
|
* May be null.
|
|
|
|
* @param aValue The value of aAttribute, example: blue in <FONT color="blue">
|
|
|
|
* May be null. Ignored if aAttribute is null.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aIsSet [OUT] true if <aProperty aAttribute=aValue> effects aNode.
|
2012-05-03 00:09:44 -07:00
|
|
|
* @param outValue [OUT] the value of the attribute, if aIsSet is true
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-05-03 00:09:44 -07:00
|
|
|
void IsTextPropertySetByContent(nsIDOMNode* aNode,
|
|
|
|
nsIAtom* aProperty,
|
|
|
|
const nsAString* aAttribute,
|
|
|
|
const nsAString* aValue,
|
|
|
|
bool& aIsSet,
|
|
|
|
nsAString* outValue = nsnull);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Methods for handling plaintext quotations
|
|
|
|
NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
|
|
|
|
|
|
|
|
/** Insert a string as quoted text,
|
|
|
|
* replacing the selected text (if any).
|
|
|
|
* @param aQuotedText The string to insert.
|
|
|
|
* @param aAddCites Whether to prepend extra ">" to each line
|
|
|
|
* (usually true, unless those characters
|
|
|
|
* have already been added.)
|
|
|
|
* @return aNodeInserted The node spanning the insertion, if applicable.
|
|
|
|
* If aAddCites is false, this will be null.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD InsertAsPlaintextQuotation(const nsAString & aQuotedText,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAddCites,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDOMNode **aNodeInserted);
|
2012-02-17 06:16:59 -08:00
|
|
|
// Return true if the data is safe to insert as the source and destination
|
|
|
|
// principals match, or we are in a editor context where this doesn't matter.
|
|
|
|
// Otherwise, the data must be sanitized first.
|
|
|
|
bool IsSafeToInsertData(nsIDOMDocument* aSourceDoc);
|
|
|
|
|
|
|
|
nsresult InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe,
|
|
|
|
nsIDOMDocument *aSourceDoc,
|
|
|
|
nsIDOMNode *aDestinationNode,
|
|
|
|
PRInt32 aDestOffset,
|
|
|
|
bool aDoDeleteSelection);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// factored methods for handling insertion of data from transferables (drag&drop or clipboard)
|
|
|
|
NS_IMETHOD PrepareTransferable(nsITransferable **transferable);
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD PrepareHTMLTransferable(nsITransferable **transferable, bool havePrivFlavor);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD InsertFromTransferable(nsITransferable *transferable,
|
|
|
|
nsIDOMDocument *aSourceDoc,
|
|
|
|
const nsAString & aContextStr,
|
|
|
|
const nsAString & aInfoStr,
|
|
|
|
nsIDOMNode *aDestinationNode,
|
|
|
|
PRInt32 aDestinationOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDoDeleteSelection);
|
2012-02-17 06:16:59 -08:00
|
|
|
nsresult InsertFromDataTransfer(nsIDOMDataTransfer *aDataTransfer,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
nsIDOMDocument *aSourceDoc,
|
|
|
|
nsIDOMNode *aDestinationNode,
|
|
|
|
PRInt32 aDestOffset,
|
|
|
|
bool aDoDeleteSelection);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HavePrivateHTMLFlavor( nsIClipboard *clipboard );
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult ParseCFHTML(nsCString & aCfhtml, PRUnichar **aStuffToPaste, PRUnichar **aCfcontext);
|
|
|
|
nsresult DoContentFilterCallback(const nsAString &aFlavor,
|
|
|
|
nsIDOMDocument *aSourceDoc,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aWillDeleteSelection,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDOMNode **aFragmentAsNode,
|
|
|
|
nsIDOMNode **aFragStartNode,
|
|
|
|
PRInt32 *aFragStartOffset,
|
|
|
|
nsIDOMNode **aFragEndNode,
|
|
|
|
PRInt32 *aFragEndOffset,
|
|
|
|
nsIDOMNode **aTargetNode,
|
|
|
|
PRInt32 *aTargetOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *aDoContinue);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetAttributeToModifyOnNode(nsIDOMNode *aNode, nsAString &aAttrib);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink = nsnull);
|
|
|
|
nsresult StripFormattingNodes(nsIDOMNode *aNode, bool aOnlyList = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult CreateDOMFragmentFromPaste(const nsAString & aInputString,
|
|
|
|
const nsAString & aContextStr,
|
|
|
|
const nsAString & aInfoStr,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outFragNode,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outStartNode,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outEndNode,
|
|
|
|
PRInt32 *outStartOffset,
|
2010-09-27 10:21:34 -07:00
|
|
|
PRInt32 *outEndOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aTrustedInput);
|
2011-07-29 04:48:04 -07:00
|
|
|
nsresult ParseFragment(const nsAString & aStr, nsIAtom* aContextLocalName,
|
2009-07-09 23:17:46 -07:00
|
|
|
nsIDocument* aTargetDoc,
|
2010-09-27 10:21:34 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> *outNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aTrustedInput);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult CreateListOfNodesToPaste(nsIDOMNode *aFragmentAsNode,
|
|
|
|
nsCOMArray<nsIDOMNode>& outNodeList,
|
|
|
|
nsIDOMNode *aStartNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode,
|
|
|
|
PRInt32 aEndOffset);
|
2009-07-09 23:17:46 -07:00
|
|
|
nsresult CreateTagStack(nsTArray<nsString> &aTagStack,
|
|
|
|
nsIDOMNode *aNode);
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult GetListAndTableParents( bool aEnd,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMArray<nsIDOMNode>& aListOfNodes,
|
|
|
|
nsCOMArray<nsIDOMNode>& outArray);
|
|
|
|
nsresult DiscoverPartialListsAndTables(nsCOMArray<nsIDOMNode>& aPasteNodes,
|
|
|
|
nsCOMArray<nsIDOMNode>& aListsAndTables,
|
|
|
|
PRInt32 *outHighWaterMark);
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult ScanForListAndTableStructure(bool aEnd,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMArray<nsIDOMNode>& aNodes,
|
|
|
|
nsIDOMNode *aListOrTable,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outReplaceNode);
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult ReplaceOrphanedStructure( bool aEnd,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMArray<nsIDOMNode>& aNodeArray,
|
|
|
|
nsCOMArray<nsIDOMNode>& aListAndTableArray,
|
|
|
|
PRInt32 aHighWaterMark);
|
2011-09-28 23:19:26 -07:00
|
|
|
nsIDOMNode* GetArrayEndpoint(bool aEnd, nsCOMArray<nsIDOMNode>& aNodeArray);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* small utility routine to test if a break node is visible to user */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsVisBreak(nsIDOMNode *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* utility routine to possibly adjust the insertion position when
|
|
|
|
inserting a block level element */
|
|
|
|
void NormalizeEOLInsertPosition(nsIDOMNode *firstNodeToInsert,
|
|
|
|
nsCOMPtr<nsIDOMNode> *insertParentNode,
|
|
|
|
PRInt32 *insertOffset);
|
|
|
|
|
|
|
|
/* small utility routine to test the eEditorReadonly bit */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsModifiable();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* helpers for block transformations */
|
|
|
|
nsresult MakeDefinitionItem(const nsAString & aItemType);
|
|
|
|
nsresult InsertBasicBlock(const nsAString & aBlockType);
|
|
|
|
|
|
|
|
/* increase/decrease the font size of selection */
|
|
|
|
nsresult RelativeFontChange( PRInt32 aSizeChange);
|
|
|
|
|
|
|
|
/* helper routines for font size changing */
|
|
|
|
nsresult RelativeFontChangeOnTextNode( PRInt32 aSizeChange,
|
|
|
|
nsIDOMCharacterData *aTextNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
PRInt32 aEndOffset);
|
2012-05-18 01:29:39 -07:00
|
|
|
nsresult RelativeFontChangeOnNode(PRInt32 aSizeChange, nsINode* aNode);
|
2012-05-18 01:29:39 -07:00
|
|
|
nsresult RelativeFontChangeHelper(PRInt32 aSizeChange, nsINode* aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* helper routines for inline style */
|
|
|
|
nsresult SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIAtom *aProperty,
|
|
|
|
const nsAString *aAttribute,
|
|
|
|
const nsAString *aValue);
|
|
|
|
nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode,
|
|
|
|
nsIAtom *aProperty,
|
|
|
|
const nsAString *aAttribute,
|
|
|
|
const nsAString *aValue);
|
2012-05-05 02:00:06 -07:00
|
|
|
nsresult SetInlinePropertyOnNode(nsIContent* aNode,
|
|
|
|
nsIAtom* aProperty,
|
|
|
|
const nsAString* aAttribute,
|
|
|
|
const nsAString* aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult PromoteInlineRange(nsIDOMRange *inRange);
|
|
|
|
nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRange);
|
|
|
|
nsresult SplitStyleAboveRange(nsIDOMRange *aRange,
|
|
|
|
nsIAtom *aProperty,
|
|
|
|
const nsAString *aAttribute);
|
|
|
|
nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
|
|
|
|
PRInt32 *aOffset,
|
|
|
|
nsIAtom *aProperty,
|
|
|
|
const nsAString *aAttribute,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outLeftNode = nsnull,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outRightNode = nsnull);
|
|
|
|
nsresult ApplyDefaultProperties();
|
|
|
|
nsresult RemoveStyleInside(nsIDOMNode *aNode,
|
|
|
|
nsIAtom *aProperty,
|
|
|
|
const nsAString *aAttribute,
|
2012-04-17 10:50:19 -07:00
|
|
|
const bool aChildrenOnly = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAString *aAttribute);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool NodeIsProperty(nsIDOMNode *aNode);
|
|
|
|
bool HasAttr(nsIDOMNode *aNode, const nsAString *aAttribute);
|
2012-05-05 02:00:06 -07:00
|
|
|
bool HasAttrVal(const nsIContent* aNode, const nsAString* aAttribute,
|
|
|
|
const nsAString& aValue);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
|
|
|
|
bool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
|
|
|
|
bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute);
|
2012-05-05 02:00:06 -07:00
|
|
|
bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult RemoveBlockContainer(nsIDOMNode *inNode);
|
2012-05-05 02:00:06 -07:00
|
|
|
nsIContent* GetPriorHTMLSibling(nsINode* aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
|
2012-05-05 02:00:06 -07:00
|
|
|
nsIContent* GetPriorHTMLSibling(nsINode* aParent, PRInt32 aOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
|
2012-05-05 02:00:06 -07:00
|
|
|
nsIContent* GetNextHTMLSibling(nsINode* aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
|
2012-05-05 02:00:06 -07:00
|
|
|
nsIContent* GetNextHTMLSibling(nsINode* aParent, PRInt32 aOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
|
|
|
|
nsresult GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
|
|
|
|
nsresult GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
|
|
|
|
nsresult GetNextHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult IsFirstEditableChild( nsIDOMNode *aNode, bool *aOutIsFirst);
|
|
|
|
nsresult IsLastEditableChild( nsIDOMNode *aNode, bool *aOutIsLast);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetFirstEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstChild);
|
|
|
|
nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastChild);
|
|
|
|
|
|
|
|
nsresult GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstLeaf);
|
|
|
|
nsresult GetLastEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastLeaf);
|
|
|
|
|
|
|
|
nsresult GetInlinePropertyBase(nsIAtom *aProperty,
|
|
|
|
const nsAString *aAttribute,
|
|
|
|
const nsAString *aValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *aFirst,
|
|
|
|
bool *aAny,
|
|
|
|
bool *aAll,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAString *outValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCheckDefaults = true);
|
2012-02-01 02:54:22 -08:00
|
|
|
bool HasStyleOrIdOrClass(mozilla::dom::Element* aElement);
|
|
|
|
nsresult RemoveElementIfNoStyleOrIdOrClass(nsIDOMNode* aElement);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-04 10:40:39 -07:00
|
|
|
// Whether the outer window of the DOM event target has focus or not.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool OurWindowHasFocus();
|
2010-05-04 10:40:39 -07:00
|
|
|
|
2010-09-27 10:21:34 -07:00
|
|
|
// This function is used to insert a string of HTML input optionally with some
|
|
|
|
// context information into the editable field. The HTML input either comes
|
|
|
|
// from a transferable object created as part of a drop/paste operation, or from
|
|
|
|
// the InsertHTML method. We may want the HTML input to be sanitized (for example,
|
|
|
|
// if it's coming from a transferable object), in which case aTrustedInput should
|
|
|
|
// be set to false, otherwise, the caller should set it to true, which means that
|
|
|
|
// the HTML will be inserted in the DOM verbatim.
|
|
|
|
nsresult DoInsertHTMLWithContext(const nsAString& aInputString,
|
|
|
|
const nsAString& aContextStr,
|
|
|
|
const nsAString& aInfoStr,
|
|
|
|
const nsAString& aFlavor,
|
|
|
|
nsIDOMDocument* aSourceDoc,
|
|
|
|
nsIDOMNode* aDestNode,
|
|
|
|
PRInt32 aDestOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDeleteSelection,
|
|
|
|
bool aTrustedInput);
|
2010-09-27 10:21:34 -07:00
|
|
|
|
2012-05-10 05:00:14 -07:00
|
|
|
nsresult ClearStyle(nsCOMPtr<nsIDOMNode>* aNode, PRInt32* aOffset,
|
|
|
|
nsIAtom* aProperty, const nsAString* aAttribute);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Data members
|
|
|
|
protected:
|
|
|
|
|
|
|
|
nsCOMArray<nsIContentFilter> mContentFilters;
|
|
|
|
|
2010-11-18 13:01:12 -08:00
|
|
|
nsRefPtr<TypeInState> mTypeInState;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mCRInParagraphCreatesParagraph;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mCSSAware;
|
2010-11-18 13:01:12 -08:00
|
|
|
nsAutoPtr<nsHTMLCSSUtils> mHTMLCSSUtils;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Used by GetFirstSelectedCell and GetNextSelectedCell
|
|
|
|
PRInt32 mSelectedCellIndex;
|
|
|
|
|
|
|
|
nsString mLastStyleSheetURL;
|
|
|
|
nsString mLastOverrideStyleSheetURL;
|
|
|
|
|
|
|
|
// Maintain a list of associated style sheets and their urls.
|
2009-01-18 12:14:14 -08:00
|
|
|
nsTArray<nsString> mStyleSheetURLs;
|
2010-05-11 13:41:47 -07:00
|
|
|
nsTArray<nsRefPtr<nsCSSStyleSheet> > mStyleSheets;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// an array for holding default style settings
|
2009-04-22 01:43:15 -07:00
|
|
|
nsTArray<PropItem*> mDefaultStyles;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// for real-time spelling
|
|
|
|
nsCOMPtr<nsITextServicesDocument> mTextServices;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/* ANONYMOUS UTILS */
|
|
|
|
void RemoveListenerAndDeleteRef(const nsAString& aEvent,
|
|
|
|
nsIDOMEventListener* aListener,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUseCapture,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDOMElement* aElement,
|
|
|
|
nsIContent* aParentContent,
|
|
|
|
nsIPresShell* aShell);
|
|
|
|
void DeleteRefToAnonymousNode(nsIDOMElement* aElement,
|
|
|
|
nsIContent * aParentContent,
|
|
|
|
nsIPresShell* aShell);
|
2008-01-21 23:39:06 -08:00
|
|
|
|
2009-04-13 20:05:34 -07:00
|
|
|
nsresult ShowResizersInner(nsIDOMElement *aResizedElement);
|
|
|
|
|
2008-01-21 23:39:06 -08:00
|
|
|
// Returns the offset of an element's frame to its absolute containing block.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult GetElementOrigin(nsIDOMElement * aElement, PRInt32 & aX, PRInt32 & aY);
|
|
|
|
nsresult GetPositionAndDimensions(nsIDOMElement * aElement,
|
|
|
|
PRInt32 & aX, PRInt32 & aY,
|
|
|
|
PRInt32 & aW, PRInt32 & aH,
|
|
|
|
PRInt32 & aBorderLeft,
|
|
|
|
PRInt32 & aBorderTop,
|
|
|
|
PRInt32 & aMarginLeft,
|
|
|
|
PRInt32 & aMarginTop);
|
|
|
|
|
|
|
|
/* PACKED BOOLEANS FOR RESIZING, ABSOLUTE POSITIONING AND */
|
|
|
|
/* INLINE TABLE EDITING */
|
|
|
|
|
|
|
|
// resizing
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsObjectResizingEnabled;
|
|
|
|
bool mIsResizing;
|
|
|
|
bool mPreserveRatio;
|
|
|
|
bool mResizedObjectIsAnImage;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// absolute positioning
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsAbsolutelyPositioningEnabled;
|
|
|
|
bool mResizedObjectIsAbsolutelyPositioned;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mGrabberClicked;
|
|
|
|
bool mIsMoving;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSnapToGridEnabled;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// inline table editing
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsInlineTableEditingEnabled;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* RESIZING */
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> mTopLeftHandle;
|
|
|
|
nsCOMPtr<nsIDOMElement> mTopHandle;
|
|
|
|
nsCOMPtr<nsIDOMElement> mTopRightHandle;
|
|
|
|
nsCOMPtr<nsIDOMElement> mLeftHandle;
|
|
|
|
nsCOMPtr<nsIDOMElement> mRightHandle;
|
|
|
|
nsCOMPtr<nsIDOMElement> mBottomLeftHandle;
|
|
|
|
nsCOMPtr<nsIDOMElement> mBottomHandle;
|
|
|
|
nsCOMPtr<nsIDOMElement> mBottomRightHandle;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> mActivatedHandle;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> mResizingShadow;
|
|
|
|
nsCOMPtr<nsIDOMElement> mResizingInfo;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> mResizedObject;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mMouseMotionListenerP;
|
|
|
|
nsCOMPtr<nsISelectionListener> mSelectionListenerP;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mResizeEventListenerP;
|
|
|
|
|
|
|
|
nsCOMArray<nsIHTMLObjectResizeListener> objectResizeEventListeners;
|
|
|
|
|
|
|
|
PRInt32 mOriginalX;
|
|
|
|
PRInt32 mOriginalY;
|
|
|
|
|
|
|
|
PRInt32 mResizedObjectX;
|
|
|
|
PRInt32 mResizedObjectY;
|
|
|
|
PRInt32 mResizedObjectWidth;
|
|
|
|
PRInt32 mResizedObjectHeight;
|
|
|
|
|
|
|
|
PRInt32 mResizedObjectMarginLeft;
|
|
|
|
PRInt32 mResizedObjectMarginTop;
|
|
|
|
PRInt32 mResizedObjectBorderLeft;
|
|
|
|
PRInt32 mResizedObjectBorderTop;
|
|
|
|
|
|
|
|
PRInt32 mXIncrementFactor;
|
|
|
|
PRInt32 mYIncrementFactor;
|
|
|
|
PRInt32 mWidthIncrementFactor;
|
|
|
|
PRInt32 mHeightIncrementFactor;
|
|
|
|
|
|
|
|
PRInt8 mInfoXIncrement;
|
|
|
|
PRInt8 mInfoYIncrement;
|
|
|
|
|
|
|
|
nsresult SetAllResizersPosition();
|
|
|
|
|
|
|
|
nsresult CreateResizer(nsIDOMElement ** aReturn, PRInt16 aLocation, nsIDOMNode * aParentNode);
|
|
|
|
void SetAnonymousElementPosition(PRInt32 aX, PRInt32 aY, nsIDOMElement *aResizer);
|
|
|
|
|
|
|
|
nsresult CreateShadow(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode,
|
|
|
|
nsIDOMElement * aOriginalObject);
|
|
|
|
nsresult SetShadowPosition(nsIDOMElement * aShadow,
|
|
|
|
nsIDOMElement * aOriginalObject,
|
|
|
|
PRInt32 aOriginalObjectX,
|
|
|
|
PRInt32 aOriginalObjectY);
|
|
|
|
|
|
|
|
nsresult CreateResizingInfo(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode);
|
|
|
|
nsresult SetResizingInfoPosition(PRInt32 aX, PRInt32 aY,
|
|
|
|
PRInt32 aW, PRInt32 aH);
|
|
|
|
|
|
|
|
PRInt32 GetNewResizingIncrement(PRInt32 aX, PRInt32 aY, PRInt32 aID);
|
|
|
|
nsresult StartResizing(nsIDOMElement * aHandle);
|
|
|
|
PRInt32 GetNewResizingX(PRInt32 aX, PRInt32 aY);
|
|
|
|
PRInt32 GetNewResizingY(PRInt32 aX, PRInt32 aY);
|
|
|
|
PRInt32 GetNewResizingWidth(PRInt32 aX, PRInt32 aY);
|
|
|
|
PRInt32 GetNewResizingHeight(PRInt32 aX, PRInt32 aY);
|
|
|
|
void HideShadowAndInfo();
|
|
|
|
void SetFinalSize(PRInt32 aX, PRInt32 aY);
|
|
|
|
void DeleteRefToAnonymousNode(nsIDOMNode * aNode);
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetResizeIncrements(PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt32 aH, bool aPreserveRatio);
|
2011-02-19 21:43:07 -08:00
|
|
|
void HideAnonymousEditingUIs();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* ABSOLUTE POSITIONING */
|
|
|
|
|
|
|
|
PRInt32 mPositionedObjectX;
|
|
|
|
PRInt32 mPositionedObjectY;
|
|
|
|
PRInt32 mPositionedObjectWidth;
|
|
|
|
PRInt32 mPositionedObjectHeight;
|
|
|
|
|
|
|
|
PRInt32 mPositionedObjectMarginLeft;
|
|
|
|
PRInt32 mPositionedObjectMarginTop;
|
|
|
|
PRInt32 mPositionedObjectBorderLeft;
|
|
|
|
PRInt32 mPositionedObjectBorderTop;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> mAbsolutelyPositionedObject;
|
|
|
|
nsCOMPtr<nsIDOMElement> mGrabber;
|
|
|
|
nsCOMPtr<nsIDOMElement> mPositioningShadow;
|
|
|
|
|
|
|
|
PRInt32 mGridSize;
|
|
|
|
|
|
|
|
nsresult CreateGrabber(nsIDOMNode * aParentNode, nsIDOMElement ** aReturn);
|
|
|
|
nsresult StartMoving(nsIDOMElement * aHandle);
|
|
|
|
nsresult SetFinalPosition(PRInt32 aX, PRInt32 aY);
|
2010-05-24 05:20:59 -07:00
|
|
|
void AddPositioningOffset(PRInt32 & aX, PRInt32 & aY);
|
2007-03-22 10:30:00 -07:00
|
|
|
void SnapToGrid(PRInt32 & newX, PRInt32 & newY);
|
|
|
|
nsresult GrabberClicked();
|
|
|
|
nsresult EndMoving();
|
|
|
|
nsresult CheckPositionedElementBGandFG(nsIDOMElement * aElement,
|
|
|
|
nsAString & aReturn);
|
|
|
|
|
|
|
|
/* INLINE TABLE EDITING */
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> mInlineEditedCell;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> mAddColumnBeforeButton;
|
|
|
|
nsCOMPtr<nsIDOMElement> mRemoveColumnButton;
|
|
|
|
nsCOMPtr<nsIDOMElement> mAddColumnAfterButton;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> mAddRowBeforeButton;
|
|
|
|
nsCOMPtr<nsIDOMElement> mRemoveRowButton;
|
|
|
|
nsCOMPtr<nsIDOMElement> mAddRowAfterButton;
|
|
|
|
|
|
|
|
void AddMouseClickListener(nsIDOMElement * aElement);
|
|
|
|
void RemoveMouseClickListener(nsIDOMElement * aElement);
|
|
|
|
|
|
|
|
nsCOMPtr<nsILinkHandler> mLinkHandler;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// friends
|
|
|
|
friend class nsHTMLEditRules;
|
|
|
|
friend class nsTextEditRules;
|
|
|
|
friend class nsWSRunObject;
|
2012-04-13 05:52:12 -07:00
|
|
|
friend class nsHTMLEditorEventListener;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-19 23:33:21 -07:00
|
|
|
private:
|
|
|
|
// Helper
|
2012-05-05 02:00:06 -07:00
|
|
|
nsresult SetInlinePropertyOnNodeImpl(nsIContent* aNode,
|
|
|
|
nsIAtom* aProperty,
|
|
|
|
const nsAString* aAttribute,
|
|
|
|
const nsAString* aValue);
|
2012-04-19 23:33:21 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
#endif //nsHTMLEditor_h__
|
|
|
|
|