LCOV - app.info - editor/libeditor/html/nsHTMLEditor.h

LCOV - code coverage report
| Current view: | directory - editor/libeditor/html - nsHTMLEditor.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 7 | 1 | 14.3 %
| Date: | 2012-07-07 | Functions: | 4 | 1 | 25.0 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is mozilla.org code.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * Netscape Communications Corporation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *   Daniel Glazman <glazman@netscape.com>
          24                 :  *   Kathleen Brade <brade@netscape.com>
          25                 :  *
          26                 :  * Alternatively, the contents of this file may be used under the terms of
          27                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          28                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          30                 :  * of those above. If you wish to allow use of your version of this file only
          31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          32                 :  * use your version of this file under the terms of the MPL, indicate your
          33                 :  * decision by deleting the provisions above and replace them with the notice
          34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          35                 :  * the provisions above, a recipient may use your version of this file under
          36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          37                 :  *
          38                 :  * ***** END LICENSE BLOCK ***** */
          39                 :
          40                 : #ifndef nsHTMLEditor_h__
          41                 : #define nsHTMLEditor_h__
          42                 :
          43                 : #include "nsCOMPtr.h"
          44                 : #include "nsCOMArray.h"
          45                 : #include "nsPlaintextEditor.h"
          46                 : #include "nsIEditor.h"
          47                 : #include "nsIHTMLEditor.h"
          48                 : #include "nsITableEditor.h"
          49                 : #include "nsIEditorMailSupport.h"
          50                 : #include "nsIEditorStyleSheets.h"
          51                 : #include "nsITextServicesDocument.h"
          52                 :
          53                 : #include "nsEditor.h"
          54                 : #include "nsIDOMElement.h"
          55                 : #include "nsIDOMEventListener.h"
          56                 : #include "nsICSSLoaderObserver.h"
          57                 : #include "nsITableLayout.h"
          58                 :
          59                 : #include "nsEditRules.h"
          60                 :
          61                 : #include "nsEditProperty.h"
          62                 : #include "nsHTMLCSSUtils.h"
          63                 :
          64                 : #include "nsHTMLObjectResizer.h"
          65                 : #include "nsIHTMLAbsPosEditor.h"
          66                 : #include "nsIHTMLInlineTableEditor.h"
          67                 : #include "nsIHTMLObjectResizeListener.h"
          68                 :
          69                 : #include "nsIDocumentObserver.h"
          70                 :
          71                 : #include "nsPoint.h"
          72                 : #include "nsTArray.h"
          73                 : #include "nsAutoPtr.h"
          74                 : #include "nsAttrName.h"
          75                 :
          76                 : #include "mozilla/dom/Element.h"
          77                 :
          78                 : class nsIDOMKeyEvent;
          79                 : class nsITransferable;
          80                 : class nsIDocumentEncoder;
          81                 : class nsIClipboard;
          82                 : class TypeInState;
          83                 : class nsIContentFilter;
          84                 : class nsIURL;
          85                 : class nsILinkHandler;
          86                 : struct PropItem;
          87                 :
          88                 : namespace mozilla {
          89                 : namespace widget {
          90                 : struct IMEState;
          91                 : } // namespace widget
          92                 : } // namespace mozilla
          93                 :
          94                 : /**
          95                 :  * The HTML editor implementation.<br>
          96                 :  * Use to edit HTML document represented as a DOM tree.
          97                 :  */
          98                 : class nsHTMLEditor : public nsPlaintextEditor,
          99                 :                      public nsIHTMLEditor,
         100                 :                      public nsIHTMLObjectResizer,
         101                 :                      public nsIHTMLAbsPosEditor,
         102                 :                      public nsITableEditor,
         103                 :                      public nsIHTMLInlineTableEditor,
         104                 :                      public nsIEditorStyleSheets,
         105                 :                      public nsICSSLoaderObserver,
         106                 :                      public nsStubMutationObserver
         107                 : {
         108                 :   typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
         109                 :
         110                 : public:
         111                 :
         112                 :   enum OperationID
         113                 :   {
         114                 :     kOpInsertBreak         = 3000,
         115                 :     kOpMakeList            = 3001,
         116                 :     kOpIndent              = 3002,
         117                 :     kOpOutdent             = 3003,
         118                 :     kOpAlign               = 3004,
         119                 :     kOpMakeBasicBlock      = 3005,
         120                 :     kOpRemoveList          = 3006,
         121                 :     kOpMakeDefListItem     = 3007,
         122                 :     kOpInsertElement       = 3008,
         123                 :     kOpInsertQuotation     = 3009,
         124                 :     kOpSetTextProperty     = 3010,
         125                 :     kOpRemoveTextProperty  = 3011,
         126                 :     kOpHTMLPaste           = 3012,
         127                 :     kOpLoadHTML            = 3013,
         128                 :     kOpResetTextProperties = 3014,
         129                 :     kOpSetAbsolutePosition = 3015,
         130                 :     kOpRemoveAbsolutePosition = 3016,
         131                 :     kOpDecreaseZIndex      = 3017,
         132                 :     kOpIncreaseZIndex      = 3018
         133                 :   };
         134                 :
         135                 :   enum ResizingRequestID
         136                 :   {
         137                 :     kX      = 0,
         138                 :     kY      = 1,
         139                 :     kWidth  = 2,
         140                 :     kHeight = 3
         141                 :   };
         142                 :
         143                 :   // see nsIHTMLEditor for documentation
         144                 :
         145                 : //Interfaces for addref and release and queryinterface
         146                 : //NOTE macro used is for classes that inherit from
         147                 : // another class. Only the base class should use NS_DECL_ISUPPORTS
         148                 :   NS_DECL_ISUPPORTS_INHERITED
         149            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLEditor, nsPlaintextEditor)
         150                 :
         151                 :
         152                 :            nsHTMLEditor();
         153                 :   virtual  ~nsHTMLEditor();
         154                 :
         155                 :   /* ------------ nsPlaintextEditor overrides -------------- */
         156                 :   NS_IMETHOD GetIsDocumentEditable(bool *aIsDocumentEditable);
         157                 :   NS_IMETHOD BeginningOfDocument();
         158                 :   virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent);
         159                 :   virtual already_AddRefed<nsIContent> GetFocusedContent();
         160                 :   virtual bool IsActiveInDOMWindow();
         161                 :   virtual already_AddRefed<nsIDOMEventTarget> GetDOMEventTarget();
         162                 :   virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode *aNode);
         163                 :   virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent);
         164                 :
         165                 :   /* ------------ nsStubMutationObserver overrides --------- */
         166                 :   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
         167                 :   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
         168                 :   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
         169                 :
         170                 :   /* ------------ nsIEditorIMESupport overrides ------------ */
         171                 :   NS_IMETHOD GetPreferredIMEState(mozilla::widget::IMEState *aState);
         172                 :
         173                 :   /* ------------ nsIHTMLEditor methods -------------- */
         174                 :
         175                 :   NS_DECL_NSIHTMLEDITOR
         176                 :
         177                 :   /* ------------ nsIHTMLObjectResizer methods -------------- */
         178                 :   /* -------- Implemented in nsHTMLObjectResizer.cpp -------- */
         179                 :   NS_DECL_NSIHTMLOBJECTRESIZER
         180                 :
         181                 :   /* ------------ nsIHTMLAbsPosEditor methods -------------- */
         182                 :   /* -------- Implemented in nsHTMLAbsPosition.cpp --------- */
         183                 :   NS_DECL_NSIHTMLABSPOSEDITOR
         184                 :
         185                 :   /* ------------ nsIHTMLInlineTableEditor methods -------------- */
         186                 :   /* ------- Implemented in nsHTMLInlineTableEditor.cpp --------- */
         187                 :   NS_DECL_NSIHTMLINLINETABLEEDITOR
         188                 :
         189                 :   /* ------------ nsIHTMLEditor methods -------------- */
         190                 :   NS_IMETHOD CopyLastEditableChildStyles(nsIDOMNode *aPreviousBlock, nsIDOMNode *aNewBlock,
         191                 :                                          nsIDOMNode **aOutBrNode);
         192                 :
         193                 :   NS_IMETHOD LoadHTML(const nsAString &aInputString);
         194                 :
         195                 :   nsresult GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor,
         196                 :                                       bool aBlockLevel);
         197                 :   NS_IMETHOD GetHTMLBackgroundColorState(bool *aMixed, nsAString &outColor);
         198                 :
         199                 :   /* ------------ nsIEditorStyleSheets methods -------------- */
         200                 :
         201                 :   NS_IMETHOD AddStyleSheet(const nsAString & aURL);
         202                 :   NS_IMETHOD ReplaceStyleSheet(const nsAString& aURL);
         203                 :   NS_IMETHOD RemoveStyleSheet(const nsAString &aURL);
         204                 :
         205                 :   NS_IMETHOD AddOverrideStyleSheet(const nsAString & aURL);
         206                 :   NS_IMETHOD ReplaceOverrideStyleSheet(const nsAString& aURL);
         207                 :   NS_IMETHOD RemoveOverrideStyleSheet(const nsAString &aURL);
         208                 :
         209                 :   NS_IMETHOD EnableStyleSheet(const nsAString& aURL, bool aEnable);
         210                 :
         211                 :   /* ------------ nsIEditorMailSupport methods -------------- */
         212                 :
         213                 :   NS_DECL_NSIEDITORMAILSUPPORT
         214                 :
         215                 :   /* ------------ nsITableEditor methods -------------- */
         216                 :
         217                 :   NS_IMETHOD InsertTableCell(PRInt32 aNumber, bool aAfter);
         218                 :   NS_IMETHOD InsertTableColumn(PRInt32 aNumber, bool aAfter);
         219                 :   NS_IMETHOD InsertTableRow(PRInt32 aNumber, bool aAfter);
         220                 :   NS_IMETHOD DeleteTable();
         221                 :   NS_IMETHOD DeleteTableCell(PRInt32 aNumber);
         222                 :   NS_IMETHOD DeleteTableCellContents();
         223                 :   NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
         224                 :   NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
         225                 :   NS_IMETHOD SelectTableCell();
         226                 :   NS_IMETHOD SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndCell);
         227                 :   NS_IMETHOD SelectTableRow();
         228                 :   NS_IMETHOD SelectTableColumn();
         229                 :   NS_IMETHOD SelectTable();
         230                 :   NS_IMETHOD SelectAllTableCells();
         231                 :   NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell);
         232                 :   NS_IMETHOD JoinTableCells(bool aMergeNonContiguousContents);
         233                 :   NS_IMETHOD SplitTableCell();
         234                 :   NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
         235                 :   NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell,
         236                 :                             PRInt32* aRowIndex, PRInt32* aColIndex);
         237                 :   NS_IMETHOD GetTableSize(nsIDOMElement *aTable,
         238                 :                           PRInt32* aRowCount, PRInt32* aColCount);
         239                 :   NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement **aCell);
         240                 :   NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable,
         241                 :                            PRInt32 aRowIndex, PRInt32 aColIndex,
         242                 :                            nsIDOMElement **aCell,
         243                 :                            PRInt32* aStartRowIndex, PRInt32* aStartColIndex,
         244                 :                            PRInt32* aRowSpan, PRInt32* aColSpan,
         245                 :                            PRInt32* aActualRowSpan, PRInt32* aActualColSpan,
         246                 :                            bool* aIsSelected);
         247                 :   NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement, nsIDOMNode** aRowNode);
         248                 :   NS_IMETHOD GetNextRow(nsIDOMNode* aCurrentRowNode, nsIDOMNode** aRowNode);
         249                 :   NS_IMETHOD GetLastCellInRow(nsIDOMNode* aRowNode, nsIDOMNode** aCellNode);
         250                 :
         251                 :   NS_IMETHOD SetSelectionAfterTableEdit(nsIDOMElement* aTable, PRInt32 aRow, PRInt32 aCol,
         252                 :                                         PRInt32 aDirection, bool aSelected);
         253                 :   NS_IMETHOD GetSelectedOrParentTableElement(nsAString& aTagName,
         254                 :                                              PRInt32 *aSelectedCount,
         255                 :                                              nsIDOMElement** aTableElement);
         256                 :   NS_IMETHOD GetSelectedCellsType(nsIDOMElement *aElement, PRUint32 *aSelectionType);
         257                 :
         258                 :   nsresult GetCellFromRange(nsIDOMRange *aRange, nsIDOMElement **aCell);
         259                 :
         260                 :   // Finds the first selected cell in first range of selection
         261                 :   // This is in the *order of selection*, not order in the table
         262                 :   // (i.e., each cell added to selection is added in another range
         263                 :   //  in the selection's rangelist, independent of location in table)
         264                 :   // aRange is optional: returns the range around the cell
         265                 :   NS_IMETHOD GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell);
         266                 :   // Get next cell until no more are found. Always use GetFirstSelected cell first
         267                 :   // aRange is optional: returns the range around the cell
         268                 :   NS_IMETHOD GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell);
         269                 :
         270                 :   // Upper-left-most selected cell in table
         271                 :   NS_IMETHOD GetFirstSelectedCellInTable(PRInt32 *aRowIndex, PRInt32 *aColIndex, nsIDOMElement **aCell);
         272                 :
         273                 :   /* miscellaneous */
         274                 :   // This sets background on the appropriate container element (table, cell,)
         275                 :   //   or calls into nsTextEditor to set the page background
         276                 :   NS_IMETHOD SetCSSBackgroundColor(const nsAString& aColor);
         277                 :   NS_IMETHOD SetHTMLBackgroundColor(const nsAString& aColor);
         278                 :
         279                 :   /* ------------ Block methods moved from nsEditor -------------- */
         280                 :   static already_AddRefed<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
         281                 :
         282                 :   static already_AddRefed<nsIDOMNode> NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir);
         283                 :   nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode,
         284                 :                                 PRInt32 aOffset,
         285                 :                                 bool *outIsSpace,
         286                 :                                 bool *outIsNBSP,
         287                 :                                 nsCOMPtr<nsIDOMNode> *outNode = 0,
         288                 :                                 PRInt32 *outOffset = 0);
         289                 :   nsresult IsPrevCharWhitespace(nsIDOMNode *aParentNode,
         290                 :                                 PRInt32 aOffset,
         291                 :                                 bool *outIsSpace,
         292                 :                                 bool *outIsNBSP,
         293                 :                                 nsCOMPtr<nsIDOMNode> *outNode = 0,
         294                 :                                 PRInt32 *outOffset = 0);
         295                 :
         296                 :   /* ------------ Overrides of nsEditor interface methods -------------- */
         297                 :
         298                 :   nsresult EndUpdateViewBatch();
         299                 :
         300                 :   /** prepare the editor for use */
         301                 :   NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIContent *aRoot, nsISelectionController *aSelCon, PRUint32 aFlags);
         302                 :   NS_IMETHOD PreDestroy(bool aDestroyingFrames);
         303                 :
         304                 :   /** Internal, static version */
         305                 :   static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, bool *aIsBlock);
         306                 :
         307                 :   NS_IMETHOD SetFlags(PRUint32 aFlags);
         308                 :
         309                 :   NS_IMETHOD Paste(PRInt32 aSelectionType);
         310                 :   NS_IMETHOD CanPaste(PRInt32 aSelectionType, bool *aCanPaste);
         311                 :
         312                 :   NS_IMETHOD PasteTransferable(nsITransferable *aTransferable);
         313                 :   NS_IMETHOD CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste);
         314                 :
         315                 :   NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
         316                 :
         317                 :   /** All editor operations which alter the doc should be prefaced
         318                 :    *  with a call to StartOperation, naming the action and direction */
         319                 :   NS_IMETHOD StartOperation(PRInt32 opID, nsIEditor::EDirection aDirection);
         320                 :
         321                 :   /** All editor operations which alter the doc should be followed
         322                 :    *  with a call to EndOperation */
         323                 :   NS_IMETHOD EndOperation();
         324                 :
         325                 :   /** returns true if aParentTag can contain a child of type aChildTag */
         326                 :   virtual bool TagCanContainTag(const nsAString& aParentTag, const nsAString& aChildTag);
         327                 :
         328                 :   /** returns true if aNode is a container */
         329                 :   virtual bool IsContainer(nsINode* aNode);
         330                 :   virtual bool IsContainer(nsIDOMNode *aNode);
         331                 :
         332                 :   /** make the given selection span the entire document */
         333                 :   NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
         334                 :
         335                 :   NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
         336                 :                                       const nsAString & aAttribute,
         337                 :                                       const nsAString & aValue,
         338                 :                                       bool aSuppressTransaction);
         339                 :   NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
         340                 :                                          const nsAString & aAttribute,
         341                 :                                          bool aSuppressTransaction);
         342                 :
         343                 :   /** join together any afjacent editable text nodes in the range */
         344                 :   NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange);
         345                 :
         346                 :   virtual bool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
         347                 :
         348                 :   NS_IMETHODIMP DeleteNode(nsIDOMNode * aNode);
         349                 :   NS_IMETHODIMP DeleteText(nsIDOMCharacterData *aTextNode,
         350                 :                            PRUint32             aOffset,
         351                 :                            PRUint32             aLength);
         352                 :   NS_IMETHOD InsertTextImpl(const nsAString& aStringToInsert,
         353                 :                             nsCOMPtr<nsIDOMNode> *aInOutNode,
         354                 :                             PRInt32 *aInOutOffset,
         355                 :                             nsIDOMDocument *aDoc);
         356                 :   NS_IMETHOD_(bool) IsModifiableNode(nsIDOMNode *aNode);
         357                 :   virtual bool IsModifiableNode(nsINode *aNode);
         358                 :
         359                 :   NS_IMETHOD SelectAll();
         360                 :
         361                 :   NS_IMETHOD GetRootElement(nsIDOMElement **aRootElement);
         362                 :
         363                 :   /* ------------ nsICSSLoaderObserver -------------- */
         364                 :   NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet*aSheet, bool aWasAlternate,
         365                 :                               nsresult aStatus);
         366                 :
         367                 :   /* ------------ Utility Routines, not part of public API -------------- */
         368                 :   NS_IMETHOD TypedText(const nsAString& aString, PRInt32 aAction);
         369                 :   nsresult InsertNodeAtPoint( nsIDOMNode *aNode,
         370                 :                               nsCOMPtr<nsIDOMNode> *ioParent,
         371                 :                               PRInt32 *ioOffset,
         372                 :                               bool aNoEmptyNodes);
         373                 :   virtual already_AddRefed<nsIDOMNode> FindUserSelectAllNode(nsIDOMNode* aNode);
         374                 :
         375                 :   /** returns the absolute position of the end points of aSelection
         376                 :     * in the document as a text stream.
         377                 :     */
         378                 :   nsresult GetTextSelectionOffsets(nsISelection *aSelection,
         379                 :                                    PRInt32 &aStartOffset,
         380                 :                                    PRInt32 &aEndOffset);
         381                 :
         382                 :   // Use this to assure that selection is set after attribute nodes when
         383                 :   //  trying to collapse selection at begining of a block node
         384                 :   //  e.g., when setting at beginning of a table cell
         385                 :   // This will stop at a table, however, since we don't want to
         386                 :   //  "drill down" into nested tables.
         387                 :   // aSelection is optional -- if null, we get current seletion
         388                 :   nsresult CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode);
         389                 :
         390                 :   virtual bool IsTextInDirtyFrameVisible(nsIContent *aNode);
         391                 :
         392                 :   nsresult IsVisTextNode(nsIContent* aNode,
         393                 :                          bool* outIsEmptyNode,
         394                 :                          bool aSafeToAskFrames);
         395                 :   nsresult IsEmptyNode(nsIDOMNode *aNode, bool *outIsEmptyBlock,
         396                 :                        bool aMozBRDoesntCount = false,
         397                 :                        bool aListOrCellNotEmpty = false,
         398                 :                        bool aSafeToAskFrames = false);
         399                 :   nsresult IsEmptyNode(nsINode* aNode, bool* outIsEmptyBlock,
         400                 :                        bool aMozBRDoesntCount = false,
         401                 :                        bool aListOrCellNotEmpty = false,
         402                 :                        bool aSafeToAskFrames = false);
         403                 :   nsresult IsEmptyNodeImpl(nsINode* aNode,
         404                 :                            bool *outIsEmptyBlock,
         405                 :                            bool aMozBRDoesntCount,
         406                 :                            bool aListOrCellNotEmpty,
         407                 :                            bool aSafeToAskFrames,
         408                 :                            bool *aSeenBR);
         409                 :
         410                 :   // Returns TRUE if sheet was loaded, false if it wasn't
         411                 :   bool     EnableExistingStyleSheet(const nsAString& aURL);
         412                 :
         413                 :   // Dealing with the internal style sheet lists:
         414                 :   NS_IMETHOD GetStyleSheetForURL(const nsAString &aURL,
         415                 :                                  nsCSSStyleSheet **_retval);
         416                 :   NS_IMETHOD GetURLForStyleSheet(nsCSSStyleSheet *aStyleSheet, nsAString &aURL);
         417                 :
         418                 :   // Add a url + known style sheet to the internal lists:
         419                 :   nsresult AddNewStyleSheetToList(const nsAString &aURL,
         420                 :                                   nsCSSStyleSheet *aStyleSheet);
         421                 :
         422                 :   nsresult RemoveStyleSheetFromList(const nsAString &aURL);
         423                 :
         424               0 :   bool IsCSSEnabled()
         425                 :   {
         426                 :     // TODO: removal of mCSSAware and use only the presence of mHTMLCSSUtils
         427               0 :     return mCSSAware && mHTMLCSSUtils && mHTMLCSSUtils->IsCSSPrefChecked();
         428                 :   }
         429                 :
         430               0 :   static bool HasAttributes(mozilla::dom::Element* aElement)
         431                 :   {
         432               0 :     MOZ_ASSERT(aElement);
         433               0 :     PRUint32 attrCount = aElement->GetAttrCount();
         434                 :     return attrCount > 1 ||
         435               0 :            (1 == attrCount && !aElement->GetAttrNameAt(0)->Equals(nsGkAtoms::mozdirty));
         436                 :   }
         437                 :
         438                 : protected:
         439                 :
         440                 :   NS_IMETHOD  InitRules();
         441                 :
         442                 :   // Create the event listeners for the editor to install
         443                 :   virtual void CreateEventListeners();
         444                 :
         445                 :   virtual nsresult InstallEventListeners();
         446                 :   virtual void RemoveEventListeners();
         447                 :
         448                 :   bool ShouldReplaceRootElement();
         449                 :   void ResetRootElementAndEventTarget();
         450                 :   nsresult GetBodyElement(nsIDOMHTMLElement** aBody);
         451                 :   // Get the focused node of this editor.
         452                 :   // @return    If the editor has focus, this returns the focused node.
         453                 :   //            Otherwise, returns null.
         454                 :   already_AddRefed<nsINode> GetFocusedNode();
         455                 :
         456                 :   // Return TRUE if aElement is a table-related elemet and caret was set
         457                 :   bool SetCaretInTableCell(nsIDOMElement* aElement);
         458                 :   bool IsNodeInActiveEditor(nsIDOMNode* aNode);
         459                 :   bool IsNodeInActiveEditor(nsINode* aNode);
         460                 :
         461                 :   // key event helpers
         462                 :   NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled);
         463                 :   NS_IMETHOD CreateBR(nsIDOMNode *aNode, PRInt32 aOffset,
         464                 :                       nsCOMPtr<nsIDOMNode> *outBRNode, nsIEditor::EDirection aSelect = nsIEditor::eNone);
         465                 :
         466                 : // Table Editing (implemented in nsTableEditor.cpp)
         467                 :
         468                 :   // Table utilities
         469                 :
         470                 :   // Insert a new cell after or before supplied aCell.
         471                 :   //  Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course)
         472                 :   // This doesn't change or use the current selection
         473                 :   NS_IMETHOD InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpan,
         474                 :                         bool aAfter, bool aIsHeader, nsIDOMElement **aNewCell);
         475                 :
         476                 :   // Helpers that don't touch the selection or do batch transactions
         477                 :   NS_IMETHOD DeleteRow(nsIDOMElement *aTable, PRInt32 aRowIndex);
         478                 :   NS_IMETHOD DeleteColumn(nsIDOMElement *aTable, PRInt32 aColIndex);
         479                 :   NS_IMETHOD DeleteCellContents(nsIDOMElement *aCell);
         480                 :
         481                 :   // Move all contents from aCellToMerge into aTargetCell (append at end)
         482                 :   NS_IMETHOD MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell, nsCOMPtr<nsIDOMElement> aCellToMerge, bool aDeleteCellToMerge);
         483                 :
         484                 :   NS_IMETHOD DeleteTable2(nsIDOMElement *aTable, nsISelection *aSelection);
         485                 :   NS_IMETHOD SetColSpan(nsIDOMElement *aCell, PRInt32 aColSpan);
         486                 :   NS_IMETHOD SetRowSpan(nsIDOMElement *aCell, PRInt32 aRowSpan);
         487                 :
         488                 :   // Helper used to get nsITableLayout interface for methods implemented in nsTableFrame
         489                 :   NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
         490                 :   // Needed to do appropriate deleting when last cell or row is about to be deleted
         491                 :   // This doesn't count cells that don't start in the given row (are spanning from row above)
         492                 :   PRInt32  GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex);
         493                 :   // Test if all cells in row or column at given index are selected
         494                 :   bool AllCellsInRowSelected(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aNumberOfColumns);
         495                 :   bool AllCellsInColumnSelected(nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32 aNumberOfRows);
         496                 :
         497                 :   bool     IsEmptyCell(nsIDOMElement *aCell);
         498                 :
         499                 :   // Most insert methods need to get the same basic context data
         500                 :   // Any of the pointers may be null if you don't need that datum (for more efficiency)
         501                 :   // Input: *aCell is a known cell,
         502                 :   //        if null, cell is obtained from the anchor node of the selection
         503                 :   // Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is null
         504                 :   NS_IMETHOD GetCellContext(nsISelection **aSelection,
         505                 :                             nsIDOMElement   **aTable,
         506                 :                             nsIDOMElement   **aCell,
         507                 :                             nsIDOMNode      **aCellParent, PRInt32 *aCellOffset,
         508                 :                             PRInt32 *aRowIndex, PRInt32 *aColIndex);
         509                 :
         510                 :   NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex,
         511                 :                             PRInt32& aActualRowSpan, PRInt32& aActualColSpan);
         512                 :
         513                 :   NS_IMETHOD SplitCellIntoColumns(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex,
         514                 :                                   PRInt32 aColSpanLeft, PRInt32 aColSpanRight, nsIDOMElement **aNewCell);
         515                 :
         516                 :   NS_IMETHOD SplitCellIntoRows(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32 aColIndex,
         517                 :                                PRInt32 aRowSpanAbove, PRInt32 aRowSpanBelow, nsIDOMElement **aNewCell);
         518                 :
         519                 :   nsresult CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *sourceCell);
         520                 :
         521                 :   // Reduce rowspan/colspan when cells span into nonexistent rows/columns
         522                 :   NS_IMETHOD FixBadRowSpan(nsIDOMElement *aTable, PRInt32 aRowIndex, PRInt32& aNewRowCount);
         523                 :   NS_IMETHOD FixBadColSpan(nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32& aNewColCount);
         524                 :
         525                 :   // Fallback method: Call this after using ClearSelection() and you
         526                 :   //  failed to set selection to some other content in the document
         527                 :   NS_IMETHOD SetSelectionAtDocumentStart(nsISelection *aSelection);
         528                 :
         529                 : // End of Table Editing utilities
         530                 :
         531                 :   virtual bool IsBlockNode(nsIDOMNode *aNode);
         532                 :   virtual bool IsBlockNode(nsINode *aNode);
         533                 :
         534                 :   static nsCOMPtr<nsIDOMNode> GetEnclosingTable(nsIDOMNode *aNode);
         535                 :
         536                 :   /** content-based query returns true if <aProperty aAttribute=aValue> effects aNode
         537                 :     * If <aProperty aAttribute=aValue> contains aNode,
         538                 :     * but <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
         539                 :     * more deeply nested than the first, then the first does not effect aNode.
         540                 :     *
         541                 :     * @param aNode      The target of the query
         542                 :     * @param aProperty  The property that we are querying for
         543                 :     * @param aAttribute The attribute of aProperty, example: color in <FONT color="blue">
         544                 :     *                   May be null.
         545                 :     * @param aValue     The value of aAttribute, example: blue in <FONT color="blue">
         546                 :     *                   May be null.  Ignored if aAttribute is null.
         547                 :     * @param aIsSet     [OUT] true if <aProperty aAttribute=aValue> effects aNode.
         548                 :     * @param aStyleNode [OUT] set to the node representing <aProperty aAttribute=aValue>, if found.
         549                 :     *                   null if aIsSet is returned as false;
         550                 :     */
         551                 :   virtual void IsTextPropertySetByContent(nsIDOMNode        *aNode,
         552                 :                                           nsIAtom           *aProperty,
         553                 :                                           const nsAString   *aAttribute,
         554                 :                                           const nsAString   *aValue,
         555                 :                                           bool              &aIsSet,
         556                 :                                           nsIDOMNode       **aStyleNode,
         557                 :                                           nsAString *outValue = nsnull);
         558                 :
         559                 :   // Methods for handling plaintext quotations
         560                 :   NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
         561                 :
         562                 :   /** Insert a string as quoted text,
         563                 :     * replacing the selected text (if any).
         564                 :     * @param aQuotedText     The string to insert.
         565                 :     * @param aAddCites       Whether to prepend extra ">" to each line
         566                 :     *                        (usually true, unless those characters
         567                 :     *                        have already been added.)
         568                 :     * @return aNodeInserted  The node spanning the insertion, if applicable.
         569                 :     *                        If aAddCites is false, this will be null.
         570                 :     */
         571                 :   NS_IMETHOD InsertAsPlaintextQuotation(const nsAString & aQuotedText,
         572                 :                                         bool aAddCites,
         573                 :                                         nsIDOMNode **aNodeInserted);
         574                 :   // Return true if the data is safe to insert as the source and destination
         575                 :   // principals match, or we are in a editor context where this doesn't matter.
         576                 :   // Otherwise, the data must be sanitized first.
         577                 :   bool IsSafeToInsertData(nsIDOMDocument* aSourceDoc);
         578                 :
         579                 :   nsresult InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe,
         580                 :                         nsIDOMDocument *aSourceDoc,
         581                 :                         nsIDOMNode *aDestinationNode,
         582                 :                         PRInt32 aDestOffset,
         583                 :                         bool aDoDeleteSelection);
         584                 :
         585                 :   // factored methods for handling insertion of data from transferables (drag&drop or clipboard)
         586                 :   NS_IMETHOD PrepareTransferable(nsITransferable **transferable);
         587                 :   NS_IMETHOD PrepareHTMLTransferable(nsITransferable **transferable, bool havePrivFlavor);
         588                 :   NS_IMETHOD InsertFromTransferable(nsITransferable *transferable,
         589                 :                                     nsIDOMDocument *aSourceDoc,
         590                 :                                     const nsAString & aContextStr,
         591                 :                                     const nsAString & aInfoStr,
         592                 :                                     nsIDOMNode *aDestinationNode,
         593                 :                                     PRInt32 aDestinationOffset,
         594                 :                                     bool aDoDeleteSelection);
         595                 :   nsresult InsertFromDataTransfer(nsIDOMDataTransfer *aDataTransfer,
         596                 :                                   PRInt32 aIndex,
         597                 :                                   nsIDOMDocument *aSourceDoc,
         598                 :                                   nsIDOMNode *aDestinationNode,
         599                 :                                   PRInt32 aDestOffset,
         600                 :                                   bool aDoDeleteSelection);
         601                 :   bool HavePrivateHTMLFlavor( nsIClipboard *clipboard );
         602                 :   nsresult   ParseCFHTML(nsCString & aCfhtml, PRUnichar **aStuffToPaste, PRUnichar **aCfcontext);
         603                 :   nsresult   DoContentFilterCallback(const nsAString &aFlavor,
         604                 :                                      nsIDOMDocument *aSourceDoc,
         605                 :                                      bool aWillDeleteSelection,
         606                 :                                      nsIDOMNode **aFragmentAsNode,
         607                 :                                      nsIDOMNode **aFragStartNode,
         608                 :                                      PRInt32 *aFragStartOffset,
         609                 :                                      nsIDOMNode **aFragEndNode,
         610                 :                                      PRInt32 *aFragEndOffset,
         611                 :                                      nsIDOMNode **aTargetNode,
         612                 :                                      PRInt32 *aTargetOffset,
         613                 :                                      bool *aDoContinue);
         614                 :   nsresult   GetAttributeToModifyOnNode(nsIDOMNode *aNode, nsAString &aAttrib);
         615                 :
         616                 :   bool       IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink = nsnull);
         617                 :   nsresult   StripFormattingNodes(nsIDOMNode *aNode, bool aOnlyList = false);
         618                 :   nsresult   CreateDOMFragmentFromPaste(const nsAString & aInputString,
         619                 :                                         const nsAString & aContextStr,
         620                 :                                         const nsAString & aInfoStr,
         621                 :                                         nsCOMPtr<nsIDOMNode> *outFragNode,
         622                 :                                         nsCOMPtr<nsIDOMNode> *outStartNode,
         623                 :                                         nsCOMPtr<nsIDOMNode> *outEndNode,
         624                 :                                         PRInt32 *outStartOffset,
         625                 :                                         PRInt32 *outEndOffset,
         626                 :                                         bool aTrustedInput);
         627                 :   nsresult   ParseFragment(const nsAString & aStr, nsIAtom* aContextLocalName,
         628                 :                            nsIDocument* aTargetDoc,
         629                 :                            nsCOMPtr<nsIDOMNode> *outNode,
         630                 :                            bool aTrustedInput);
         631                 :   nsresult   CreateListOfNodesToPaste(nsIDOMNode  *aFragmentAsNode,
         632                 :                                       nsCOMArray<nsIDOMNode>& outNodeList,
         633                 :                                       nsIDOMNode *aStartNode,
         634                 :                                       PRInt32 aStartOffset,
         635                 :                                       nsIDOMNode *aEndNode,
         636                 :                                       PRInt32 aEndOffset);
         637                 :   nsresult CreateTagStack(nsTArray<nsString> &aTagStack,
         638                 :                           nsIDOMNode *aNode);
         639                 :   nsresult GetListAndTableParents( bool aEnd,
         640                 :                                    nsCOMArray<nsIDOMNode>& aListOfNodes,
         641                 :                                    nsCOMArray<nsIDOMNode>& outArray);
         642                 :   nsresult DiscoverPartialListsAndTables(nsCOMArray<nsIDOMNode>& aPasteNodes,
         643                 :                                          nsCOMArray<nsIDOMNode>& aListsAndTables,
         644                 :                                          PRInt32 *outHighWaterMark);
         645                 :   nsresult ScanForListAndTableStructure(bool aEnd,
         646                 :                                         nsCOMArray<nsIDOMNode>& aNodes,
         647                 :                                         nsIDOMNode *aListOrTable,
         648                 :                                         nsCOMPtr<nsIDOMNode> *outReplaceNode);
         649                 :   nsresult ReplaceOrphanedStructure( bool aEnd,
         650                 :                                      nsCOMArray<nsIDOMNode>& aNodeArray,
         651                 :                                      nsCOMArray<nsIDOMNode>& aListAndTableArray,
         652                 :                                      PRInt32 aHighWaterMark);
         653                 :   nsIDOMNode* GetArrayEndpoint(bool aEnd, nsCOMArray<nsIDOMNode>& aNodeArray);
         654                 :
         655                 :   /* small utility routine to test if a break node is visible to user */
         656                 :   bool     IsVisBreak(nsIDOMNode *aNode);
         657                 :
         658                 :   /* utility routine to possibly adjust the insertion position when
         659                 :      inserting a block level element */
         660                 :   void NormalizeEOLInsertPosition(nsIDOMNode *firstNodeToInsert,
         661                 :                                   nsCOMPtr<nsIDOMNode> *insertParentNode,
         662                 :                                   PRInt32 *insertOffset);
         663                 :
         664                 :   /* small utility routine to test the eEditorReadonly bit */
         665                 :   bool IsModifiable();
         666                 :
         667                 :   /* helpers for block transformations */
         668                 :   nsresult MakeDefinitionItem(const nsAString & aItemType);
         669                 :   nsresult InsertBasicBlock(const nsAString & aBlockType);
         670                 :
         671                 :   /* increase/decrease the font size of selection */
         672                 :   nsresult RelativeFontChange( PRInt32 aSizeChange);
         673                 :
         674                 :   /* helper routines for font size changing */
         675                 :   nsresult RelativeFontChangeOnTextNode( PRInt32 aSizeChange,
         676                 :                                          nsIDOMCharacterData *aTextNode,
         677                 :                                          PRInt32 aStartOffset,
         678                 :                                          PRInt32 aEndOffset);
         679                 :   nsresult RelativeFontChangeOnNode( PRInt32 aSizeChange,
         680                 :                                      nsIDOMNode *aNode);
         681                 :   nsresult RelativeFontChangeHelper( PRInt32 aSizeChange,
         682                 :                                      nsIDOMNode *aNode);
         683                 :
         684                 :   /* helper routines for inline style */
         685                 :   nsresult SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode,
         686                 :                                         PRInt32 aStartOffset,
         687                 :                                         PRInt32 aEndOffset,
         688                 :                                         nsIAtom *aProperty,
         689                 :                                         const nsAString *aAttribute,
         690                 :                                         const nsAString *aValue);
         691                 :   nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode,
         692                 :                                     nsIAtom *aProperty,
         693                 :                                     const nsAString *aAttribute,
         694                 :                                     const nsAString *aValue);
         695                 :
         696                 :   nsresult PromoteInlineRange(nsIDOMRange *inRange);
         697                 :   nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRange);
         698                 :   nsresult SplitStyleAboveRange(nsIDOMRange *aRange,
         699                 :                                 nsIAtom *aProperty,
         700                 :                                 const nsAString *aAttribute);
         701                 :   nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
         702                 :                                 PRInt32 *aOffset,
         703                 :                                 nsIAtom *aProperty,
         704                 :                                 const nsAString *aAttribute,
         705                 :                                 nsCOMPtr<nsIDOMNode> *outLeftNode = nsnull,
         706                 :                                 nsCOMPtr<nsIDOMNode> *outRightNode = nsnull);
         707                 :   nsresult ApplyDefaultProperties();
         708                 :   nsresult RemoveStyleInside(nsIDOMNode *aNode,
         709                 :                              nsIAtom *aProperty,
         710                 :                              const nsAString *aAttribute,
         711                 :                              bool aChildrenOnly = false);
         712                 :   nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAString *aAttribute);
         713                 :
         714                 :   bool NodeIsProperty(nsIDOMNode *aNode);
         715                 :   bool HasAttr(nsIDOMNode *aNode, const nsAString *aAttribute);
         716                 :   bool HasAttrVal(nsIDOMNode *aNode, const nsAString *aAttribute, const nsAString *aValue);
         717                 :   bool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
         718                 :   bool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset);
         719                 :   bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute);
         720                 :
         721                 :   nsresult RemoveBlockContainer(nsIDOMNode *inNode);
         722                 :   nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
         723                 :   nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
         724                 :   nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
         725                 :   nsresult GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
         726                 :   nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
         727                 :   nsresult GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
         728                 :   nsresult GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
         729                 :   nsresult GetNextHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
         730                 :
         731                 :   nsresult IsFirstEditableChild( nsIDOMNode *aNode, bool *aOutIsFirst);
         732                 :   nsresult IsLastEditableChild( nsIDOMNode *aNode, bool *aOutIsLast);
         733                 :   nsresult GetFirstEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstChild);
         734                 :   nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastChild);
         735                 :
         736                 :   nsresult GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstLeaf);
         737                 :   nsresult GetLastEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastLeaf);
         738                 :
         739                 :   nsresult GetInlinePropertyBase(nsIAtom *aProperty,
         740                 :                              const nsAString *aAttribute,
         741                 :                              const nsAString *aValue,
         742                 :                              bool *aFirst,
         743                 :                              bool *aAny,
         744                 :                              bool *aAll,
         745                 :                              nsAString *outValue,
         746                 :                              bool aCheckDefaults = true);
         747                 :   bool HasStyleOrIdOrClass(mozilla::dom::Element* aElement);
         748                 :   nsresult RemoveElementIfNoStyleOrIdOrClass(nsIDOMNode* aElement);
         749                 :
         750                 :   // Whether the outer window of the DOM event target has focus or not.
         751                 :   bool     OurWindowHasFocus();
         752                 :
         753                 :   // This function is used to insert a string of HTML input optionally with some
         754                 :   // context information into the editable field.  The HTML input either comes
         755                 :   // from a transferable object created as part of a drop/paste operation, or from
         756                 :   // the InsertHTML method.  We may want the HTML input to be sanitized (for example,
         757                 :   // if it's coming from a transferable object), in which case aTrustedInput should
         758                 :   // be set to false, otherwise, the caller should set it to true, which means that
         759                 :   // the HTML will be inserted in the DOM verbatim.
         760                 :   nsresult DoInsertHTMLWithContext(const nsAString& aInputString,
         761                 :                                    const nsAString& aContextStr,
         762                 :                                    const nsAString& aInfoStr,
         763                 :                                    const nsAString& aFlavor,
         764                 :                                    nsIDOMDocument* aSourceDoc,
         765                 :                                    nsIDOMNode* aDestNode,
         766                 :                                    PRInt32 aDestOffset,
         767                 :                                    bool aDeleteSelection,
         768                 :                                    bool aTrustedInput);
         769                 :
         770                 : // Data members
         771                 : protected:
         772                 :
         773                 :   nsCOMArray<nsIContentFilter> mContentFilters;
         774                 :
         775                 :   nsRefPtr<TypeInState>        mTypeInState;
         776                 :
         777                 :   bool mCRInParagraphCreatesParagraph;
         778                 :
         779                 :   bool mCSSAware;
         780                 :   nsAutoPtr<nsHTMLCSSUtils> mHTMLCSSUtils;
         781                 :
         782                 :   // Used by GetFirstSelectedCell and GetNextSelectedCell
         783                 :   PRInt32  mSelectedCellIndex;
         784                 :
         785                 :   nsString mLastStyleSheetURL;
         786                 :   nsString mLastOverrideStyleSheetURL;
         787                 :
         788                 :   // Maintain a list of associated style sheets and their urls.
         789                 :   nsTArray<nsString> mStyleSheetURLs;
         790                 :   nsTArray<nsRefPtr<nsCSSStyleSheet> > mStyleSheets;
         791                 :
         792                 :   // an array for holding default style settings
         793                 :   nsTArray<PropItem*> mDefaultStyles;
         794                 :
         795                 :    // for real-time spelling
         796                 :    nsCOMPtr<nsITextServicesDocument> mTextServices;
         797                 :
         798                 : protected:
         799                 :
         800                 :   /* ANONYMOUS UTILS */
         801                 :   void     RemoveListenerAndDeleteRef(const nsAString& aEvent,
         802                 :                                       nsIDOMEventListener* aListener,
         803                 :                                       bool aUseCapture,
         804                 :                                       nsIDOMElement* aElement,
         805                 :                                       nsIContent* aParentContent,
         806                 :                                       nsIPresShell* aShell);
         807                 :   void     DeleteRefToAnonymousNode(nsIDOMElement* aElement,
         808                 :                                     nsIContent * aParentContent,
         809                 :                                     nsIPresShell* aShell);
         810                 :
         811                 :   nsresult ShowResizersInner(nsIDOMElement *aResizedElement);
         812                 :
         813                 :   // Returns the offset of an element's frame to its absolute containing block.
         814                 :   nsresult GetElementOrigin(nsIDOMElement * aElement, PRInt32 & aX, PRInt32 & aY);
         815                 :   nsresult GetPositionAndDimensions(nsIDOMElement * aElement,
         816                 :                                     PRInt32 & aX, PRInt32 & aY,
         817                 :                                     PRInt32 & aW, PRInt32 & aH,
         818                 :                                     PRInt32 & aBorderLeft,
         819                 :                                     PRInt32 & aBorderTop,
         820                 :                                     PRInt32 & aMarginLeft,
         821                 :                                     PRInt32 & aMarginTop);
         822                 :
         823                 :   /* PACKED BOOLEANS FOR RESIZING, ABSOLUTE POSITIONING AND */
         824                 :   /* INLINE TABLE EDITING */
         825                 :
         826                 :   // resizing
         827                 :   bool mIsObjectResizingEnabled;
         828                 :   bool mIsResizing;
         829                 :   bool mPreserveRatio;
         830                 :   bool mResizedObjectIsAnImage;
         831                 :
         832                 :   // absolute positioning
         833                 :   bool mIsAbsolutelyPositioningEnabled;
         834                 :   bool mResizedObjectIsAbsolutelyPositioned;
         835                 :
         836                 :   bool mGrabberClicked;
         837                 :   bool mIsMoving;
         838                 :
         839                 :   bool mSnapToGridEnabled;
         840                 :
         841                 :   // inline table editing
         842                 :   bool mIsInlineTableEditingEnabled;
         843                 :
         844                 :   /* RESIZING */
         845                 :
         846                 :   nsCOMPtr<nsIDOMElement> mTopLeftHandle;
         847                 :   nsCOMPtr<nsIDOMElement> mTopHandle;
         848                 :   nsCOMPtr<nsIDOMElement> mTopRightHandle;
         849                 :   nsCOMPtr<nsIDOMElement> mLeftHandle;
         850                 :   nsCOMPtr<nsIDOMElement> mRightHandle;
         851                 :   nsCOMPtr<nsIDOMElement> mBottomLeftHandle;
         852                 :   nsCOMPtr<nsIDOMElement> mBottomHandle;
         853                 :   nsCOMPtr<nsIDOMElement> mBottomRightHandle;
         854                 :
         855                 :   nsCOMPtr<nsIDOMElement> mActivatedHandle;
         856                 :
         857                 :   nsCOMPtr<nsIDOMElement> mResizingShadow;
         858                 :   nsCOMPtr<nsIDOMElement> mResizingInfo;
         859                 :
         860                 :   nsCOMPtr<nsIDOMElement> mResizedObject;
         861                 :
         862                 :   nsCOMPtr<nsIDOMEventListener>  mMouseMotionListenerP;
         863                 :   nsCOMPtr<nsISelectionListener> mSelectionListenerP;
         864                 :   nsCOMPtr<nsIDOMEventListener>  mResizeEventListenerP;
         865                 :
         866                 :   nsCOMArray<nsIHTMLObjectResizeListener> objectResizeEventListeners;
         867                 :
         868                 :   PRInt32 mOriginalX;
         869                 :   PRInt32 mOriginalY;
         870                 :
         871                 :   PRInt32 mResizedObjectX;
         872                 :   PRInt32 mResizedObjectY;
         873                 :   PRInt32 mResizedObjectWidth;
         874                 :   PRInt32 mResizedObjectHeight;
         875                 :
         876                 :   PRInt32 mResizedObjectMarginLeft;
         877                 :   PRInt32 mResizedObjectMarginTop;
         878                 :   PRInt32 mResizedObjectBorderLeft;
         879                 :   PRInt32 mResizedObjectBorderTop;
         880                 :
         881                 :   PRInt32 mXIncrementFactor;
         882                 :   PRInt32 mYIncrementFactor;
         883                 :   PRInt32 mWidthIncrementFactor;
         884                 :   PRInt32 mHeightIncrementFactor;
         885                 :
         886                 :   PRInt8  mInfoXIncrement;
         887                 :   PRInt8  mInfoYIncrement;
         888                 :
         889                 :   nsresult SetAllResizersPosition();
         890                 :
         891                 :   nsresult CreateResizer(nsIDOMElement ** aReturn, PRInt16 aLocation, nsIDOMNode * aParentNode);
         892                 :   void     SetAnonymousElementPosition(PRInt32 aX, PRInt32 aY, nsIDOMElement *aResizer);
         893                 :
         894                 :   nsresult CreateShadow(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode,
         895                 :                         nsIDOMElement * aOriginalObject);
         896                 :   nsresult SetShadowPosition(nsIDOMElement * aShadow,
         897                 :                              nsIDOMElement * aOriginalObject,
         898                 :                              PRInt32 aOriginalObjectX,
         899                 :                              PRInt32 aOriginalObjectY);
         900                 :
         901                 :   nsresult CreateResizingInfo(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode);
         902                 :   nsresult SetResizingInfoPosition(PRInt32 aX, PRInt32 aY,
         903                 :                                    PRInt32 aW, PRInt32 aH);
         904                 :
         905                 :   PRInt32  GetNewResizingIncrement(PRInt32 aX, PRInt32 aY, PRInt32 aID);
         906                 :   nsresult StartResizing(nsIDOMElement * aHandle);
         907                 :   PRInt32  GetNewResizingX(PRInt32 aX, PRInt32 aY);
         908                 :   PRInt32  GetNewResizingY(PRInt32 aX, PRInt32 aY);
         909                 :   PRInt32  GetNewResizingWidth(PRInt32 aX, PRInt32 aY);
         910                 :   PRInt32  GetNewResizingHeight(PRInt32 aX, PRInt32 aY);
         911                 :   void     HideShadowAndInfo();
         912                 :   void     SetFinalSize(PRInt32 aX, PRInt32 aY);
         913                 :   void     DeleteRefToAnonymousNode(nsIDOMNode * aNode);
         914                 :   void     SetResizeIncrements(PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt32 aH, bool aPreserveRatio);
         915                 :   void     HideAnonymousEditingUIs();
         916                 :
         917                 :   /* ABSOLUTE POSITIONING */
         918                 :
         919                 :   PRInt32 mPositionedObjectX;
         920                 :   PRInt32 mPositionedObjectY;
         921                 :   PRInt32 mPositionedObjectWidth;
         922                 :   PRInt32 mPositionedObjectHeight;
         923                 :
         924                 :   PRInt32 mPositionedObjectMarginLeft;
         925                 :   PRInt32 mPositionedObjectMarginTop;
         926                 :   PRInt32 mPositionedObjectBorderLeft;
         927                 :   PRInt32 mPositionedObjectBorderTop;
         928                 :
         929                 :   nsCOMPtr<nsIDOMElement> mAbsolutelyPositionedObject;
         930                 :   nsCOMPtr<nsIDOMElement> mGrabber;
         931                 :   nsCOMPtr<nsIDOMElement> mPositioningShadow;
         932                 :
         933                 :   PRInt32      mGridSize;
         934                 :
         935                 :   nsresult CreateGrabber(nsIDOMNode * aParentNode, nsIDOMElement ** aReturn);
         936                 :   nsresult StartMoving(nsIDOMElement * aHandle);
         937                 :   nsresult SetFinalPosition(PRInt32 aX, PRInt32 aY);
         938                 :   void     AddPositioningOffset(PRInt32 & aX, PRInt32 & aY);
         939                 :   void     SnapToGrid(PRInt32 & newX, PRInt32 & newY);
         940                 :   nsresult GrabberClicked();
         941                 :   nsresult EndMoving();
         942                 :   nsresult CheckPositionedElementBGandFG(nsIDOMElement * aElement,
         943                 :                                          nsAString & aReturn);
         944                 :
         945                 :   /* INLINE TABLE EDITING */
         946                 :
         947                 :   nsCOMPtr<nsIDOMElement> mInlineEditedCell;
         948                 :
         949                 :   nsCOMPtr<nsIDOMElement> mAddColumnBeforeButton;
         950                 :   nsCOMPtr<nsIDOMElement> mRemoveColumnButton;
         951                 :   nsCOMPtr<nsIDOMElement> mAddColumnAfterButton;
         952                 :
         953                 :   nsCOMPtr<nsIDOMElement> mAddRowBeforeButton;
         954                 :   nsCOMPtr<nsIDOMElement> mRemoveRowButton;
         955                 :   nsCOMPtr<nsIDOMElement> mAddRowAfterButton;
         956                 :
         957                 :   void     AddMouseClickListener(nsIDOMElement * aElement);
         958                 :   void     RemoveMouseClickListener(nsIDOMElement * aElement);
         959                 :
         960                 :   nsCOMPtr<nsILinkHandler> mLinkHandler;
         961                 :
         962                 : public:
         963                 :
         964                 : // friends
         965                 : friend class nsHTMLEditRules;
         966                 : friend class nsTextEditRules;
         967                 : friend class nsWSRunObject;
         968                 :
         969                 : };
         970                 : #endif //nsHTMLEditor_h__
         971                 :

Generated by: LCOV version 1.7