1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/nsHTMLEditor.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,961 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsHTMLEditor_h__ 1.10 +#define nsHTMLEditor_h__ 1.11 + 1.12 +#include "nsCOMPtr.h" 1.13 +#include "nsCOMArray.h" 1.14 +#include "nsPlaintextEditor.h" 1.15 +#include "nsIEditor.h" 1.16 +#include "nsIHTMLEditor.h" 1.17 +#include "nsITableEditor.h" 1.18 +#include "nsIEditorMailSupport.h" 1.19 +#include "nsIEditorStyleSheets.h" 1.20 + 1.21 +#include "nsEditor.h" 1.22 +#include "nsIDOMElement.h" 1.23 +#include "nsIDOMEventListener.h" 1.24 +#include "nsICSSLoaderObserver.h" 1.25 + 1.26 +#include "nsEditRules.h" 1.27 + 1.28 +#include "nsEditProperty.h" 1.29 +#include "nsHTMLCSSUtils.h" 1.30 + 1.31 +#include "nsHTMLObjectResizer.h" 1.32 +#include "nsIHTMLAbsPosEditor.h" 1.33 +#include "nsIHTMLInlineTableEditor.h" 1.34 +#include "nsIHTMLObjectResizeListener.h" 1.35 +#include "nsIHTMLObjectResizer.h" 1.36 + 1.37 +#include "nsIDocumentObserver.h" 1.38 + 1.39 +#include "nsPoint.h" 1.40 +#include "nsTArray.h" 1.41 +#include "nsAutoPtr.h" 1.42 +#include "nsAttrName.h" 1.43 +#include "nsStubMutationObserver.h" 1.44 + 1.45 +#include "mozilla/Attributes.h" 1.46 +#include "mozilla/dom/Element.h" 1.47 + 1.48 +class nsIDOMKeyEvent; 1.49 +class nsITransferable; 1.50 +class nsIDocumentEncoder; 1.51 +class nsIClipboard; 1.52 +class TypeInState; 1.53 +class nsIContentFilter; 1.54 +class nsIURL; 1.55 +class nsILinkHandler; 1.56 +class nsTableOuterFrame; 1.57 +struct PropItem; 1.58 + 1.59 +namespace mozilla { 1.60 +namespace widget { 1.61 +struct IMEState; 1.62 +} // namespace widget 1.63 +} // namespace mozilla 1.64 + 1.65 +/** 1.66 + * The HTML editor implementation.<br> 1.67 + * Use to edit HTML document represented as a DOM tree. 1.68 + */ 1.69 +class nsHTMLEditor : public nsPlaintextEditor, 1.70 + public nsIHTMLEditor, 1.71 + public nsIHTMLObjectResizer, 1.72 + public nsIHTMLAbsPosEditor, 1.73 + public nsITableEditor, 1.74 + public nsIHTMLInlineTableEditor, 1.75 + public nsIEditorStyleSheets, 1.76 + public nsICSSLoaderObserver, 1.77 + public nsStubMutationObserver 1.78 +{ 1.79 + typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType; 1.80 + 1.81 +public: 1.82 + 1.83 + enum ResizingRequestID 1.84 + { 1.85 + kX = 0, 1.86 + kY = 1, 1.87 + kWidth = 2, 1.88 + kHeight = 3 1.89 + }; 1.90 + 1.91 + // see nsIHTMLEditor for documentation 1.92 + 1.93 +//Interfaces for addref and release and queryinterface 1.94 +//NOTE macro used is for classes that inherit from 1.95 +// another class. Only the base class should use NS_DECL_ISUPPORTS 1.96 + NS_DECL_ISUPPORTS_INHERITED 1.97 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLEditor, nsPlaintextEditor) 1.98 + 1.99 + 1.100 + nsHTMLEditor(); 1.101 + virtual ~nsHTMLEditor(); 1.102 + 1.103 + bool GetReturnInParagraphCreatesNewParagraph(); 1.104 + 1.105 + /* ------------ nsPlaintextEditor overrides -------------- */ 1.106 + NS_IMETHOD GetIsDocumentEditable(bool *aIsDocumentEditable); 1.107 + NS_IMETHOD BeginningOfDocument(); 1.108 + virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent); 1.109 + virtual already_AddRefed<nsIContent> GetFocusedContent(); 1.110 + virtual already_AddRefed<nsIContent> GetFocusedContentForIME(); 1.111 + virtual bool IsActiveInDOMWindow(); 1.112 + virtual already_AddRefed<mozilla::dom::EventTarget> GetDOMEventTarget(); 1.113 + virtual mozilla::dom::Element* GetEditorRoot() MOZ_OVERRIDE; 1.114 + virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode *aNode); 1.115 + virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent); 1.116 + virtual already_AddRefed<nsIContent> GetInputEventTargetContent(); 1.117 + virtual bool IsEditable(nsIContent *aNode); 1.118 + using nsEditor::IsEditable; 1.119 + 1.120 + /* ------------ nsStubMutationObserver overrides --------- */ 1.121 + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED 1.122 + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED 1.123 + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED 1.124 + 1.125 + /* ------------ nsIEditorIMESupport overrides ------------ */ 1.126 + NS_IMETHOD GetPreferredIMEState(mozilla::widget::IMEState *aState); 1.127 + 1.128 + /* ------------ nsIHTMLEditor methods -------------- */ 1.129 + 1.130 + NS_DECL_NSIHTMLEDITOR 1.131 + 1.132 + /* ------------ nsIHTMLObjectResizer methods -------------- */ 1.133 + /* -------- Implemented in nsHTMLObjectResizer.cpp -------- */ 1.134 + NS_DECL_NSIHTMLOBJECTRESIZER 1.135 + 1.136 + /* ------------ nsIHTMLAbsPosEditor methods -------------- */ 1.137 + /* -------- Implemented in nsHTMLAbsPosition.cpp --------- */ 1.138 + NS_DECL_NSIHTMLABSPOSEDITOR 1.139 + 1.140 + /* ------------ nsIHTMLInlineTableEditor methods -------------- */ 1.141 + /* ------- Implemented in nsHTMLInlineTableEditor.cpp --------- */ 1.142 + NS_DECL_NSIHTMLINLINETABLEEDITOR 1.143 + 1.144 + /* ------------ nsIHTMLEditor methods -------------- */ 1.145 + NS_IMETHOD CopyLastEditableChildStyles(nsIDOMNode *aPreviousBlock, nsIDOMNode *aNewBlock, 1.146 + nsIDOMNode **aOutBrNode); 1.147 + 1.148 + NS_IMETHOD LoadHTML(const nsAString &aInputString); 1.149 + 1.150 + nsresult GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, 1.151 + bool aBlockLevel); 1.152 + NS_IMETHOD GetHTMLBackgroundColorState(bool *aMixed, nsAString &outColor); 1.153 + 1.154 + /* ------------ nsIEditorStyleSheets methods -------------- */ 1.155 + 1.156 + NS_IMETHOD AddStyleSheet(const nsAString & aURL); 1.157 + NS_IMETHOD ReplaceStyleSheet(const nsAString& aURL); 1.158 + NS_IMETHOD RemoveStyleSheet(const nsAString &aURL); 1.159 + 1.160 + NS_IMETHOD AddOverrideStyleSheet(const nsAString & aURL); 1.161 + NS_IMETHOD ReplaceOverrideStyleSheet(const nsAString& aURL); 1.162 + NS_IMETHOD RemoveOverrideStyleSheet(const nsAString &aURL); 1.163 + 1.164 + NS_IMETHOD EnableStyleSheet(const nsAString& aURL, bool aEnable); 1.165 + 1.166 + /* ------------ nsIEditorMailSupport methods -------------- */ 1.167 + 1.168 + NS_DECL_NSIEDITORMAILSUPPORT 1.169 + 1.170 + /* ------------ nsITableEditor methods -------------- */ 1.171 + 1.172 + NS_IMETHOD InsertTableCell(int32_t aNumber, bool aAfter); 1.173 + NS_IMETHOD InsertTableColumn(int32_t aNumber, bool aAfter); 1.174 + NS_IMETHOD InsertTableRow(int32_t aNumber, bool aAfter); 1.175 + NS_IMETHOD DeleteTable(); 1.176 + NS_IMETHOD DeleteTableCell(int32_t aNumber); 1.177 + NS_IMETHOD DeleteTableCellContents(); 1.178 + NS_IMETHOD DeleteTableColumn(int32_t aNumber); 1.179 + NS_IMETHOD DeleteTableRow(int32_t aNumber); 1.180 + NS_IMETHOD SelectTableCell(); 1.181 + NS_IMETHOD SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndCell); 1.182 + NS_IMETHOD SelectTableRow(); 1.183 + NS_IMETHOD SelectTableColumn(); 1.184 + NS_IMETHOD SelectTable(); 1.185 + NS_IMETHOD SelectAllTableCells(); 1.186 + NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell); 1.187 + NS_IMETHOD JoinTableCells(bool aMergeNonContiguousContents); 1.188 + NS_IMETHOD SplitTableCell(); 1.189 + NS_IMETHOD NormalizeTable(nsIDOMElement *aTable); 1.190 + NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, 1.191 + int32_t* aRowIndex, int32_t* aColIndex); 1.192 + NS_IMETHOD GetTableSize(nsIDOMElement *aTable, 1.193 + int32_t* aRowCount, int32_t* aColCount); 1.194 + NS_IMETHOD GetCellAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex, nsIDOMElement **aCell); 1.195 + NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, 1.196 + int32_t aRowIndex, int32_t aColIndex, 1.197 + nsIDOMElement **aCell, 1.198 + int32_t* aStartRowIndex, int32_t* aStartColIndex, 1.199 + int32_t* aRowSpan, int32_t* aColSpan, 1.200 + int32_t* aActualRowSpan, int32_t* aActualColSpan, 1.201 + bool* aIsSelected); 1.202 + NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement, nsIDOMNode** aRowNode); 1.203 + NS_IMETHOD GetNextRow(nsIDOMNode* aCurrentRowNode, nsIDOMNode** aRowNode); 1.204 + NS_IMETHOD GetLastCellInRow(nsIDOMNode* aRowNode, nsIDOMNode** aCellNode); 1.205 + 1.206 + NS_IMETHOD SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, int32_t aCol, 1.207 + int32_t aDirection, bool aSelected); 1.208 + NS_IMETHOD GetSelectedOrParentTableElement(nsAString& aTagName, 1.209 + int32_t *aSelectedCount, 1.210 + nsIDOMElement** aTableElement); 1.211 + NS_IMETHOD GetSelectedCellsType(nsIDOMElement *aElement, uint32_t *aSelectionType); 1.212 + 1.213 + nsresult GetCellFromRange(nsIDOMRange *aRange, nsIDOMElement **aCell); 1.214 + 1.215 + // Finds the first selected cell in first range of selection 1.216 + // This is in the *order of selection*, not order in the table 1.217 + // (i.e., each cell added to selection is added in another range 1.218 + // in the selection's rangelist, independent of location in table) 1.219 + // aRange is optional: returns the range around the cell 1.220 + NS_IMETHOD GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell); 1.221 + // Get next cell until no more are found. Always use GetFirstSelected cell first 1.222 + // aRange is optional: returns the range around the cell 1.223 + NS_IMETHOD GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell); 1.224 + 1.225 + // Upper-left-most selected cell in table 1.226 + NS_IMETHOD GetFirstSelectedCellInTable(int32_t *aRowIndex, int32_t *aColIndex, nsIDOMElement **aCell); 1.227 + 1.228 + /* miscellaneous */ 1.229 + // This sets background on the appropriate container element (table, cell,) 1.230 + // or calls into nsTextEditor to set the page background 1.231 + NS_IMETHOD SetCSSBackgroundColor(const nsAString& aColor); 1.232 + NS_IMETHOD SetHTMLBackgroundColor(const nsAString& aColor); 1.233 + 1.234 + /* ------------ Block methods moved from nsEditor -------------- */ 1.235 + static already_AddRefed<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode); 1.236 + 1.237 + void IsNextCharInNodeWhitespace(nsIContent* aContent, 1.238 + int32_t aOffset, 1.239 + bool* outIsSpace, 1.240 + bool* outIsNBSP, 1.241 + nsIContent** outNode = nullptr, 1.242 + int32_t* outOffset = 0); 1.243 + void IsPrevCharInNodeWhitespace(nsIContent* aContent, 1.244 + int32_t aOffset, 1.245 + bool* outIsSpace, 1.246 + bool* outIsNBSP, 1.247 + nsIContent** outNode = nullptr, 1.248 + int32_t* outOffset = 0); 1.249 + 1.250 + /* ------------ Overrides of nsEditor interface methods -------------- */ 1.251 + 1.252 + nsresult EndUpdateViewBatch(); 1.253 + 1.254 + /** prepare the editor for use */ 1.255 + NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIContent *aRoot, 1.256 + nsISelectionController *aSelCon, uint32_t aFlags, 1.257 + const nsAString& aValue); 1.258 + NS_IMETHOD PreDestroy(bool aDestroyingFrames); 1.259 + 1.260 + /** Internal, static version */ 1.261 + // aElement must not be null. 1.262 + static bool NodeIsBlockStatic(const mozilla::dom::Element* aElement); 1.263 + static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, bool *aIsBlock); 1.264 +protected: 1.265 + using nsEditor::IsBlockNode; 1.266 + virtual bool IsBlockNode(nsINode *aNode); 1.267 + 1.268 +public: 1.269 + NS_IMETHOD SetFlags(uint32_t aFlags); 1.270 + 1.271 + NS_IMETHOD Paste(int32_t aSelectionType); 1.272 + NS_IMETHOD CanPaste(int32_t aSelectionType, bool *aCanPaste); 1.273 + 1.274 + NS_IMETHOD PasteTransferable(nsITransferable *aTransferable); 1.275 + NS_IMETHOD CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste); 1.276 + 1.277 + NS_IMETHOD DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed); 1.278 + 1.279 + /** All editor operations which alter the doc should be prefaced 1.280 + * with a call to StartOperation, naming the action and direction */ 1.281 + NS_IMETHOD StartOperation(EditAction opID, 1.282 + nsIEditor::EDirection aDirection); 1.283 + 1.284 + /** All editor operations which alter the doc should be followed 1.285 + * with a call to EndOperation */ 1.286 + NS_IMETHOD EndOperation(); 1.287 + 1.288 + /** returns true if aParentTag can contain a child of type aChildTag */ 1.289 + virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag); 1.290 + 1.291 + /** returns true if aNode is a container */ 1.292 + virtual bool IsContainer(nsIDOMNode *aNode); 1.293 + 1.294 + /** make the given selection span the entire document */ 1.295 + NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); 1.296 + 1.297 + NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement, 1.298 + const nsAString & aAttribute, 1.299 + const nsAString & aValue, 1.300 + bool aSuppressTransaction); 1.301 + NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement, 1.302 + const nsAString & aAttribute, 1.303 + bool aSuppressTransaction); 1.304 + 1.305 + /** join together any adjacent editable text nodes in the range */ 1.306 + NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange); 1.307 + 1.308 + virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2) 1.309 + MOZ_OVERRIDE; 1.310 + 1.311 + NS_IMETHOD DeleteSelectionImpl(EDirection aAction, 1.312 + EStripWrappers aStripWrappers); 1.313 + nsresult DeleteNode(nsINode* aNode); 1.314 + NS_IMETHODIMP DeleteNode(nsIDOMNode * aNode); 1.315 + NS_IMETHODIMP DeleteText(nsIDOMCharacterData *aTextNode, 1.316 + uint32_t aOffset, 1.317 + uint32_t aLength); 1.318 + NS_IMETHOD InsertTextImpl(const nsAString& aStringToInsert, 1.319 + nsCOMPtr<nsIDOMNode> *aInOutNode, 1.320 + int32_t *aInOutOffset, 1.321 + nsIDOMDocument *aDoc); 1.322 + NS_IMETHOD_(bool) IsModifiableNode(nsIDOMNode *aNode); 1.323 + virtual bool IsModifiableNode(nsINode *aNode); 1.324 + 1.325 + NS_IMETHOD GetIsSelectionEditable(bool* aIsSelectionEditable); 1.326 + 1.327 + NS_IMETHOD SelectAll(); 1.328 + 1.329 + NS_IMETHOD GetRootElement(nsIDOMElement **aRootElement); 1.330 + 1.331 + /* ------------ nsICSSLoaderObserver -------------- */ 1.332 + NS_IMETHOD StyleSheetLoaded(nsCSSStyleSheet*aSheet, bool aWasAlternate, 1.333 + nsresult aStatus); 1.334 + 1.335 + /* ------------ Utility Routines, not part of public API -------------- */ 1.336 + NS_IMETHOD TypedText(const nsAString& aString, ETypingAction aAction); 1.337 + nsresult InsertNodeAtPoint( nsIDOMNode *aNode, 1.338 + nsCOMPtr<nsIDOMNode> *ioParent, 1.339 + int32_t *ioOffset, 1.340 + bool aNoEmptyNodes); 1.341 + 1.342 + // Use this to assure that selection is set after attribute nodes when 1.343 + // trying to collapse selection at begining of a block node 1.344 + // e.g., when setting at beginning of a table cell 1.345 + // This will stop at a table, however, since we don't want to 1.346 + // "drill down" into nested tables. 1.347 + // aSelection is optional -- if null, we get current seletion 1.348 + nsresult CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode); 1.349 + 1.350 + /** 1.351 + * aNode must be a non-null text node. 1.352 + * outIsEmptyNode must be non-null. 1.353 + */ 1.354 + nsresult IsVisTextNode(nsIContent* aNode, 1.355 + bool* outIsEmptyNode, 1.356 + bool aSafeToAskFrames); 1.357 + nsresult IsEmptyNode(nsIDOMNode *aNode, bool *outIsEmptyBlock, 1.358 + bool aMozBRDoesntCount = false, 1.359 + bool aListOrCellNotEmpty = false, 1.360 + bool aSafeToAskFrames = false); 1.361 + nsresult IsEmptyNode(nsINode* aNode, bool* outIsEmptyBlock, 1.362 + bool aMozBRDoesntCount = false, 1.363 + bool aListOrCellNotEmpty = false, 1.364 + bool aSafeToAskFrames = false); 1.365 + nsresult IsEmptyNodeImpl(nsINode* aNode, 1.366 + bool *outIsEmptyBlock, 1.367 + bool aMozBRDoesntCount, 1.368 + bool aListOrCellNotEmpty, 1.369 + bool aSafeToAskFrames, 1.370 + bool *aSeenBR); 1.371 + 1.372 + // Returns TRUE if sheet was loaded, false if it wasn't 1.373 + bool EnableExistingStyleSheet(const nsAString& aURL); 1.374 + 1.375 + // Dealing with the internal style sheet lists: 1.376 + NS_IMETHOD GetStyleSheetForURL(const nsAString &aURL, 1.377 + nsCSSStyleSheet **_retval); 1.378 + NS_IMETHOD GetURLForStyleSheet(nsCSSStyleSheet *aStyleSheet, nsAString &aURL); 1.379 + 1.380 + // Add a url + known style sheet to the internal lists: 1.381 + nsresult AddNewStyleSheetToList(const nsAString &aURL, 1.382 + nsCSSStyleSheet *aStyleSheet); 1.383 + 1.384 + nsresult RemoveStyleSheetFromList(const nsAString &aURL); 1.385 + 1.386 + bool IsCSSEnabled() 1.387 + { 1.388 + // TODO: removal of mCSSAware and use only the presence of mHTMLCSSUtils 1.389 + return mCSSAware && mHTMLCSSUtils && mHTMLCSSUtils->IsCSSPrefChecked(); 1.390 + } 1.391 + 1.392 + static bool HasAttributes(mozilla::dom::Element* aElement) 1.393 + { 1.394 + MOZ_ASSERT(aElement); 1.395 + uint32_t attrCount = aElement->GetAttrCount(); 1.396 + return attrCount > 1 || 1.397 + (1 == attrCount && !aElement->GetAttrNameAt(0)->Equals(nsGkAtoms::mozdirty)); 1.398 + } 1.399 + 1.400 +protected: 1.401 + 1.402 + NS_IMETHOD InitRules(); 1.403 + 1.404 + // Create the event listeners for the editor to install 1.405 + virtual void CreateEventListeners(); 1.406 + 1.407 + virtual nsresult InstallEventListeners(); 1.408 + virtual void RemoveEventListeners(); 1.409 + 1.410 + bool ShouldReplaceRootElement(); 1.411 + void ResetRootElementAndEventTarget(); 1.412 + nsresult GetBodyElement(nsIDOMHTMLElement** aBody); 1.413 + // Get the focused node of this editor. 1.414 + // @return If the editor has focus, this returns the focused node. 1.415 + // Otherwise, returns null. 1.416 + already_AddRefed<nsINode> GetFocusedNode(); 1.417 + 1.418 + // Return TRUE if aElement is a table-related elemet and caret was set 1.419 + bool SetCaretInTableCell(nsIDOMElement* aElement); 1.420 + 1.421 + // key event helpers 1.422 + NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled); 1.423 + NS_IMETHOD CreateBR(nsIDOMNode *aNode, int32_t aOffset, 1.424 + nsCOMPtr<nsIDOMNode> *outBRNode, nsIEditor::EDirection aSelect = nsIEditor::eNone); 1.425 + 1.426 +// Table Editing (implemented in nsTableEditor.cpp) 1.427 + 1.428 + // Table utilities 1.429 + 1.430 + // Insert a new cell after or before supplied aCell. 1.431 + // Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course) 1.432 + // This doesn't change or use the current selection 1.433 + NS_IMETHOD InsertCell(nsIDOMElement *aCell, int32_t aRowSpan, int32_t aColSpan, 1.434 + bool aAfter, bool aIsHeader, nsIDOMElement **aNewCell); 1.435 + 1.436 + // Helpers that don't touch the selection or do batch transactions 1.437 + NS_IMETHOD DeleteRow(nsIDOMElement *aTable, int32_t aRowIndex); 1.438 + NS_IMETHOD DeleteColumn(nsIDOMElement *aTable, int32_t aColIndex); 1.439 + NS_IMETHOD DeleteCellContents(nsIDOMElement *aCell); 1.440 + 1.441 + // Move all contents from aCellToMerge into aTargetCell (append at end) 1.442 + NS_IMETHOD MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell, nsCOMPtr<nsIDOMElement> aCellToMerge, bool aDeleteCellToMerge); 1.443 + 1.444 + NS_IMETHOD DeleteTable2(nsIDOMElement *aTable, nsISelection *aSelection); 1.445 + NS_IMETHOD SetColSpan(nsIDOMElement *aCell, int32_t aColSpan); 1.446 + NS_IMETHOD SetRowSpan(nsIDOMElement *aCell, int32_t aRowSpan); 1.447 + 1.448 + // Helper used to get nsTableOuterFrame for a table. 1.449 + nsTableOuterFrame* GetTableFrame(nsIDOMElement* aTable); 1.450 + // Needed to do appropriate deleting when last cell or row is about to be deleted 1.451 + // This doesn't count cells that don't start in the given row (are spanning from row above) 1.452 + int32_t GetNumberOfCellsInRow(nsIDOMElement* aTable, int32_t rowIndex); 1.453 + // Test if all cells in row or column at given index are selected 1.454 + bool AllCellsInRowSelected(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aNumberOfColumns); 1.455 + bool AllCellsInColumnSelected(nsIDOMElement *aTable, int32_t aColIndex, int32_t aNumberOfRows); 1.456 + 1.457 + bool IsEmptyCell(mozilla::dom::Element* aCell); 1.458 + 1.459 + // Most insert methods need to get the same basic context data 1.460 + // Any of the pointers may be null if you don't need that datum (for more efficiency) 1.461 + // Input: *aCell is a known cell, 1.462 + // if null, cell is obtained from the anchor node of the selection 1.463 + // Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is null 1.464 + NS_IMETHOD GetCellContext(nsISelection **aSelection, 1.465 + nsIDOMElement **aTable, 1.466 + nsIDOMElement **aCell, 1.467 + nsIDOMNode **aCellParent, int32_t *aCellOffset, 1.468 + int32_t *aRowIndex, int32_t *aColIndex); 1.469 + 1.470 + NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex, 1.471 + int32_t& aActualRowSpan, int32_t& aActualColSpan); 1.472 + 1.473 + NS_IMETHOD SplitCellIntoColumns(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex, 1.474 + int32_t aColSpanLeft, int32_t aColSpanRight, nsIDOMElement **aNewCell); 1.475 + 1.476 + NS_IMETHOD SplitCellIntoRows(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex, 1.477 + int32_t aRowSpanAbove, int32_t aRowSpanBelow, nsIDOMElement **aNewCell); 1.478 + 1.479 + nsresult CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *sourceCell); 1.480 + 1.481 + // Reduce rowspan/colspan when cells span into nonexistent rows/columns 1.482 + NS_IMETHOD FixBadRowSpan(nsIDOMElement *aTable, int32_t aRowIndex, int32_t& aNewRowCount); 1.483 + NS_IMETHOD FixBadColSpan(nsIDOMElement *aTable, int32_t aColIndex, int32_t& aNewColCount); 1.484 + 1.485 + // Fallback method: Call this after using ClearSelection() and you 1.486 + // failed to set selection to some other content in the document 1.487 + NS_IMETHOD SetSelectionAtDocumentStart(nsISelection *aSelection); 1.488 + 1.489 +// End of Table Editing utilities 1.490 + 1.491 + static nsCOMPtr<nsIDOMNode> GetEnclosingTable(nsIDOMNode *aNode); 1.492 + 1.493 + /** content-based query returns true if <aProperty aAttribute=aValue> effects aNode 1.494 + * If <aProperty aAttribute=aValue> contains aNode, 1.495 + * but <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is 1.496 + * more deeply nested than the first, then the first does not effect aNode. 1.497 + * 1.498 + * @param aNode The target of the query 1.499 + * @param aProperty The property that we are querying for 1.500 + * @param aAttribute The attribute of aProperty, example: color in <FONT color="blue"> 1.501 + * May be null. 1.502 + * @param aValue The value of aAttribute, example: blue in <FONT color="blue"> 1.503 + * May be null. Ignored if aAttribute is null. 1.504 + * @param aIsSet [OUT] true if <aProperty aAttribute=aValue> effects aNode. 1.505 + * @param outValue [OUT] the value of the attribute, if aIsSet is true 1.506 + * 1.507 + * The nsIContent variant returns aIsSet instead of using an out parameter. 1.508 + */ 1.509 + bool IsTextPropertySetByContent(nsIContent* aContent, 1.510 + nsIAtom* aProperty, 1.511 + const nsAString* aAttribute, 1.512 + const nsAString* aValue, 1.513 + nsAString* outValue = nullptr); 1.514 + 1.515 + void IsTextPropertySetByContent(nsIDOMNode* aNode, 1.516 + nsIAtom* aProperty, 1.517 + const nsAString* aAttribute, 1.518 + const nsAString* aValue, 1.519 + bool& aIsSet, 1.520 + nsAString* outValue = nullptr); 1.521 + 1.522 + // Methods for handling plaintext quotations 1.523 + NS_IMETHOD PasteAsPlaintextQuotation(int32_t aSelectionType); 1.524 + 1.525 + /** Insert a string as quoted text, 1.526 + * replacing the selected text (if any). 1.527 + * @param aQuotedText The string to insert. 1.528 + * @param aAddCites Whether to prepend extra ">" to each line 1.529 + * (usually true, unless those characters 1.530 + * have already been added.) 1.531 + * @return aNodeInserted The node spanning the insertion, if applicable. 1.532 + * If aAddCites is false, this will be null. 1.533 + */ 1.534 + NS_IMETHOD InsertAsPlaintextQuotation(const nsAString & aQuotedText, 1.535 + bool aAddCites, 1.536 + nsIDOMNode **aNodeInserted); 1.537 + 1.538 + nsresult InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe, 1.539 + nsIDOMDocument *aSourceDoc, 1.540 + nsIDOMNode *aDestinationNode, 1.541 + int32_t aDestOffset, 1.542 + bool aDoDeleteSelection); 1.543 + 1.544 + // factored methods for handling insertion of data from transferables (drag&drop or clipboard) 1.545 + NS_IMETHOD PrepareTransferable(nsITransferable **transferable); 1.546 + NS_IMETHOD PrepareHTMLTransferable(nsITransferable **transferable, bool havePrivFlavor); 1.547 + NS_IMETHOD InsertFromTransferable(nsITransferable *transferable, 1.548 + nsIDOMDocument *aSourceDoc, 1.549 + const nsAString & aContextStr, 1.550 + const nsAString & aInfoStr, 1.551 + nsIDOMNode *aDestinationNode, 1.552 + int32_t aDestinationOffset, 1.553 + bool aDoDeleteSelection); 1.554 + nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer, 1.555 + int32_t aIndex, 1.556 + nsIDOMDocument *aSourceDoc, 1.557 + nsIDOMNode *aDestinationNode, 1.558 + int32_t aDestOffset, 1.559 + bool aDoDeleteSelection); 1.560 + bool HavePrivateHTMLFlavor( nsIClipboard *clipboard ); 1.561 + nsresult ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_t **aCfcontext); 1.562 + nsresult DoContentFilterCallback(const nsAString &aFlavor, 1.563 + nsIDOMDocument *aSourceDoc, 1.564 + bool aWillDeleteSelection, 1.565 + nsIDOMNode **aFragmentAsNode, 1.566 + nsIDOMNode **aFragStartNode, 1.567 + int32_t *aFragStartOffset, 1.568 + nsIDOMNode **aFragEndNode, 1.569 + int32_t *aFragEndOffset, 1.570 + nsIDOMNode **aTargetNode, 1.571 + int32_t *aTargetOffset, 1.572 + bool *aDoContinue); 1.573 + 1.574 + bool IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink = nullptr); 1.575 + nsresult StripFormattingNodes(nsIDOMNode *aNode, bool aOnlyList = false); 1.576 + nsresult CreateDOMFragmentFromPaste(const nsAString & aInputString, 1.577 + const nsAString & aContextStr, 1.578 + const nsAString & aInfoStr, 1.579 + nsCOMPtr<nsIDOMNode> *outFragNode, 1.580 + nsCOMPtr<nsIDOMNode> *outStartNode, 1.581 + nsCOMPtr<nsIDOMNode> *outEndNode, 1.582 + int32_t *outStartOffset, 1.583 + int32_t *outEndOffset, 1.584 + bool aTrustedInput); 1.585 + nsresult ParseFragment(const nsAString & aStr, nsIAtom* aContextLocalName, 1.586 + nsIDocument* aTargetDoc, 1.587 + nsCOMPtr<nsIDOMNode> *outNode, 1.588 + bool aTrustedInput); 1.589 + nsresult CreateListOfNodesToPaste(nsIDOMNode *aFragmentAsNode, 1.590 + nsCOMArray<nsIDOMNode>& outNodeList, 1.591 + nsIDOMNode *aStartNode, 1.592 + int32_t aStartOffset, 1.593 + nsIDOMNode *aEndNode, 1.594 + int32_t aEndOffset); 1.595 + nsresult CreateTagStack(nsTArray<nsString> &aTagStack, 1.596 + nsIDOMNode *aNode); 1.597 + nsresult GetListAndTableParents( bool aEnd, 1.598 + nsCOMArray<nsIDOMNode>& aListOfNodes, 1.599 + nsCOMArray<nsIDOMNode>& outArray); 1.600 + nsresult DiscoverPartialListsAndTables(nsCOMArray<nsIDOMNode>& aPasteNodes, 1.601 + nsCOMArray<nsIDOMNode>& aListsAndTables, 1.602 + int32_t *outHighWaterMark); 1.603 + nsresult ScanForListAndTableStructure(bool aEnd, 1.604 + nsCOMArray<nsIDOMNode>& aNodes, 1.605 + nsIDOMNode *aListOrTable, 1.606 + nsCOMPtr<nsIDOMNode> *outReplaceNode); 1.607 + nsresult ReplaceOrphanedStructure( bool aEnd, 1.608 + nsCOMArray<nsIDOMNode>& aNodeArray, 1.609 + nsCOMArray<nsIDOMNode>& aListAndTableArray, 1.610 + int32_t aHighWaterMark); 1.611 + nsIDOMNode* GetArrayEndpoint(bool aEnd, nsCOMArray<nsIDOMNode>& aNodeArray); 1.612 + 1.613 + /* small utility routine to test if a break node is visible to user */ 1.614 + bool IsVisBreak(nsIDOMNode *aNode); 1.615 + 1.616 + /* utility routine to possibly adjust the insertion position when 1.617 + inserting a block level element */ 1.618 + void NormalizeEOLInsertPosition(nsIDOMNode *firstNodeToInsert, 1.619 + nsCOMPtr<nsIDOMNode> *insertParentNode, 1.620 + int32_t *insertOffset); 1.621 + 1.622 + /* small utility routine to test the eEditorReadonly bit */ 1.623 + bool IsModifiable(); 1.624 + 1.625 + /* helpers for block transformations */ 1.626 + nsresult MakeDefinitionItem(const nsAString & aItemType); 1.627 + nsresult InsertBasicBlock(const nsAString & aBlockType); 1.628 + 1.629 + /* increase/decrease the font size of selection */ 1.630 + nsresult RelativeFontChange( int32_t aSizeChange); 1.631 + 1.632 + /* helper routines for font size changing */ 1.633 + nsresult RelativeFontChangeOnTextNode( int32_t aSizeChange, 1.634 + nsIDOMCharacterData *aTextNode, 1.635 + int32_t aStartOffset, 1.636 + int32_t aEndOffset); 1.637 + nsresult RelativeFontChangeOnNode(int32_t aSizeChange, nsINode* aNode); 1.638 + nsresult RelativeFontChangeHelper(int32_t aSizeChange, nsINode* aNode); 1.639 + 1.640 + /* helper routines for inline style */ 1.641 + nsresult SetInlinePropertyOnTextNode( nsIDOMCharacterData *aTextNode, 1.642 + int32_t aStartOffset, 1.643 + int32_t aEndOffset, 1.644 + nsIAtom *aProperty, 1.645 + const nsAString *aAttribute, 1.646 + const nsAString *aValue); 1.647 + nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode, 1.648 + nsIAtom *aProperty, 1.649 + const nsAString *aAttribute, 1.650 + const nsAString *aValue); 1.651 + nsresult SetInlinePropertyOnNode(nsIContent* aNode, 1.652 + nsIAtom* aProperty, 1.653 + const nsAString* aAttribute, 1.654 + const nsAString* aValue); 1.655 + 1.656 + nsresult PromoteInlineRange(nsIDOMRange *inRange); 1.657 + nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRange); 1.658 + nsresult SplitStyleAboveRange(nsIDOMRange *aRange, 1.659 + nsIAtom *aProperty, 1.660 + const nsAString *aAttribute); 1.661 + nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode, 1.662 + int32_t *aOffset, 1.663 + nsIAtom *aProperty, 1.664 + const nsAString *aAttribute, 1.665 + nsCOMPtr<nsIDOMNode> *outLeftNode = nullptr, 1.666 + nsCOMPtr<nsIDOMNode> *outRightNode = nullptr); 1.667 + nsresult ApplyDefaultProperties(); 1.668 + nsresult RemoveStyleInside(nsIDOMNode *aNode, 1.669 + nsIAtom *aProperty, 1.670 + const nsAString *aAttribute, 1.671 + const bool aChildrenOnly = false); 1.672 + nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAString *aAttribute); 1.673 + 1.674 + bool NodeIsProperty(nsIDOMNode *aNode); 1.675 + bool HasAttr(nsIDOMNode *aNode, const nsAString *aAttribute); 1.676 + bool IsAtFrontOfNode(nsIDOMNode *aNode, int32_t aOffset); 1.677 + bool IsAtEndOfNode(nsIDOMNode *aNode, int32_t aOffset); 1.678 + bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute); 1.679 + bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute); 1.680 + 1.681 + nsresult RemoveBlockContainer(nsIDOMNode *inNode); 1.682 + 1.683 + nsIContent* GetPriorHTMLSibling(nsINode* aNode); 1.684 + nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode); 1.685 + nsIContent* GetPriorHTMLSibling(nsINode* aParent, int32_t aOffset); 1.686 + nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode); 1.687 + 1.688 + nsIContent* GetNextHTMLSibling(nsINode* aNode); 1.689 + nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode); 1.690 + nsIContent* GetNextHTMLSibling(nsINode* aParent, int32_t aOffset); 1.691 + nsresult GetNextHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode); 1.692 + 1.693 + nsIContent* GetPriorHTMLNode(nsINode* aNode, bool aNoBlockCrossing = false); 1.694 + nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false); 1.695 + nsIContent* GetPriorHTMLNode(nsINode* aParent, int32_t aOffset, 1.696 + bool aNoBlockCrossing = false); 1.697 + nsresult GetPriorHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false); 1.698 + 1.699 + nsIContent* GetNextHTMLNode(nsINode* aNode, bool aNoBlockCrossing = false); 1.700 + nsresult GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false); 1.701 + nsIContent* GetNextHTMLNode(nsINode* aParent, int32_t aOffset, 1.702 + bool aNoBlockCrossing = false); 1.703 + nsresult GetNextHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false); 1.704 + 1.705 + nsresult IsFirstEditableChild( nsIDOMNode *aNode, bool *aOutIsFirst); 1.706 + nsresult IsLastEditableChild( nsIDOMNode *aNode, bool *aOutIsLast); 1.707 + nsresult GetFirstEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstChild); 1.708 + nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastChild); 1.709 + 1.710 + nsresult GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstLeaf); 1.711 + nsresult GetLastEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastLeaf); 1.712 + 1.713 + nsresult GetInlinePropertyBase(nsIAtom *aProperty, 1.714 + const nsAString *aAttribute, 1.715 + const nsAString *aValue, 1.716 + bool *aFirst, 1.717 + bool *aAny, 1.718 + bool *aAll, 1.719 + nsAString *outValue, 1.720 + bool aCheckDefaults = true); 1.721 + bool HasStyleOrIdOrClass(mozilla::dom::Element* aElement); 1.722 + nsresult RemoveElementIfNoStyleOrIdOrClass(nsIDOMNode* aElement); 1.723 + 1.724 + // Whether the outer window of the DOM event target has focus or not. 1.725 + bool OurWindowHasFocus(); 1.726 + 1.727 + // This function is used to insert a string of HTML input optionally with some 1.728 + // context information into the editable field. The HTML input either comes 1.729 + // from a transferable object created as part of a drop/paste operation, or from 1.730 + // the InsertHTML method. We may want the HTML input to be sanitized (for example, 1.731 + // if it's coming from a transferable object), in which case aTrustedInput should 1.732 + // be set to false, otherwise, the caller should set it to true, which means that 1.733 + // the HTML will be inserted in the DOM verbatim. 1.734 + // 1.735 + // aClearStyle should be set to false if you want the paste to be affected by 1.736 + // local style (e.g., for the insertHTML command). 1.737 + nsresult DoInsertHTMLWithContext(const nsAString& aInputString, 1.738 + const nsAString& aContextStr, 1.739 + const nsAString& aInfoStr, 1.740 + const nsAString& aFlavor, 1.741 + nsIDOMDocument* aSourceDoc, 1.742 + nsIDOMNode* aDestNode, 1.743 + int32_t aDestOffset, 1.744 + bool aDeleteSelection, 1.745 + bool aTrustedInput, 1.746 + bool aClearStyle = true); 1.747 + 1.748 + nsresult ClearStyle(nsCOMPtr<nsIDOMNode>* aNode, int32_t* aOffset, 1.749 + nsIAtom* aProperty, const nsAString* aAttribute); 1.750 + 1.751 +// Data members 1.752 +protected: 1.753 + 1.754 + nsCOMArray<nsIContentFilter> mContentFilters; 1.755 + 1.756 + nsRefPtr<TypeInState> mTypeInState; 1.757 + 1.758 + bool mCRInParagraphCreatesParagraph; 1.759 + 1.760 + bool mCSSAware; 1.761 + nsAutoPtr<nsHTMLCSSUtils> mHTMLCSSUtils; 1.762 + 1.763 + // Used by GetFirstSelectedCell and GetNextSelectedCell 1.764 + int32_t mSelectedCellIndex; 1.765 + 1.766 + nsString mLastStyleSheetURL; 1.767 + nsString mLastOverrideStyleSheetURL; 1.768 + 1.769 + // Maintain a list of associated style sheets and their urls. 1.770 + nsTArray<nsString> mStyleSheetURLs; 1.771 + nsTArray<nsRefPtr<nsCSSStyleSheet> > mStyleSheets; 1.772 + 1.773 + // an array for holding default style settings 1.774 + nsTArray<PropItem*> mDefaultStyles; 1.775 + 1.776 +protected: 1.777 + 1.778 + /* ANONYMOUS UTILS */ 1.779 + void RemoveListenerAndDeleteRef(const nsAString& aEvent, 1.780 + nsIDOMEventListener* aListener, 1.781 + bool aUseCapture, 1.782 + nsIDOMElement* aElement, 1.783 + nsIContent* aParentContent, 1.784 + nsIPresShell* aShell); 1.785 + void DeleteRefToAnonymousNode(nsIDOMElement* aElement, 1.786 + nsIContent * aParentContent, 1.787 + nsIPresShell* aShell); 1.788 + 1.789 + nsresult ShowResizersInner(nsIDOMElement *aResizedElement); 1.790 + 1.791 + // Returns the offset of an element's frame to its absolute containing block. 1.792 + nsresult GetElementOrigin(nsIDOMElement * aElement, int32_t & aX, int32_t & aY); 1.793 + nsresult GetPositionAndDimensions(nsIDOMElement * aElement, 1.794 + int32_t & aX, int32_t & aY, 1.795 + int32_t & aW, int32_t & aH, 1.796 + int32_t & aBorderLeft, 1.797 + int32_t & aBorderTop, 1.798 + int32_t & aMarginLeft, 1.799 + int32_t & aMarginTop); 1.800 + 1.801 + /* PACKED BOOLEANS FOR RESIZING, ABSOLUTE POSITIONING AND */ 1.802 + /* INLINE TABLE EDITING */ 1.803 + 1.804 + // resizing 1.805 + bool mIsObjectResizingEnabled; 1.806 + bool mIsResizing; 1.807 + bool mPreserveRatio; 1.808 + bool mResizedObjectIsAnImage; 1.809 + 1.810 + // absolute positioning 1.811 + bool mIsAbsolutelyPositioningEnabled; 1.812 + bool mResizedObjectIsAbsolutelyPositioned; 1.813 + 1.814 + bool mGrabberClicked; 1.815 + bool mIsMoving; 1.816 + 1.817 + bool mSnapToGridEnabled; 1.818 + 1.819 + // inline table editing 1.820 + bool mIsInlineTableEditingEnabled; 1.821 + 1.822 + /* RESIZING */ 1.823 + 1.824 + nsCOMPtr<nsIDOMElement> mTopLeftHandle; 1.825 + nsCOMPtr<nsIDOMElement> mTopHandle; 1.826 + nsCOMPtr<nsIDOMElement> mTopRightHandle; 1.827 + nsCOMPtr<nsIDOMElement> mLeftHandle; 1.828 + nsCOMPtr<nsIDOMElement> mRightHandle; 1.829 + nsCOMPtr<nsIDOMElement> mBottomLeftHandle; 1.830 + nsCOMPtr<nsIDOMElement> mBottomHandle; 1.831 + nsCOMPtr<nsIDOMElement> mBottomRightHandle; 1.832 + 1.833 + nsCOMPtr<nsIDOMElement> mActivatedHandle; 1.834 + 1.835 + nsCOMPtr<nsIDOMElement> mResizingShadow; 1.836 + nsCOMPtr<nsIDOMElement> mResizingInfo; 1.837 + 1.838 + nsCOMPtr<nsIDOMElement> mResizedObject; 1.839 + 1.840 + nsCOMPtr<nsIDOMEventListener> mMouseMotionListenerP; 1.841 + nsCOMPtr<nsISelectionListener> mSelectionListenerP; 1.842 + nsCOMPtr<nsIDOMEventListener> mResizeEventListenerP; 1.843 + 1.844 + nsCOMArray<nsIHTMLObjectResizeListener> objectResizeEventListeners; 1.845 + 1.846 + int32_t mOriginalX; 1.847 + int32_t mOriginalY; 1.848 + 1.849 + int32_t mResizedObjectX; 1.850 + int32_t mResizedObjectY; 1.851 + int32_t mResizedObjectWidth; 1.852 + int32_t mResizedObjectHeight; 1.853 + 1.854 + int32_t mResizedObjectMarginLeft; 1.855 + int32_t mResizedObjectMarginTop; 1.856 + int32_t mResizedObjectBorderLeft; 1.857 + int32_t mResizedObjectBorderTop; 1.858 + 1.859 + int32_t mXIncrementFactor; 1.860 + int32_t mYIncrementFactor; 1.861 + int32_t mWidthIncrementFactor; 1.862 + int32_t mHeightIncrementFactor; 1.863 + 1.864 + int8_t mInfoXIncrement; 1.865 + int8_t mInfoYIncrement; 1.866 + 1.867 + nsresult SetAllResizersPosition(); 1.868 + 1.869 + nsresult CreateResizer(nsIDOMElement ** aReturn, int16_t aLocation, nsIDOMNode * aParentNode); 1.870 + void SetAnonymousElementPosition(int32_t aX, int32_t aY, nsIDOMElement *aResizer); 1.871 + 1.872 + nsresult CreateShadow(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode, 1.873 + nsIDOMElement * aOriginalObject); 1.874 + nsresult SetShadowPosition(nsIDOMElement * aShadow, 1.875 + nsIDOMElement * aOriginalObject, 1.876 + int32_t aOriginalObjectX, 1.877 + int32_t aOriginalObjectY); 1.878 + 1.879 + nsresult CreateResizingInfo(nsIDOMElement ** aReturn, nsIDOMNode * aParentNode); 1.880 + nsresult SetResizingInfoPosition(int32_t aX, int32_t aY, 1.881 + int32_t aW, int32_t aH); 1.882 + 1.883 + int32_t GetNewResizingIncrement(int32_t aX, int32_t aY, int32_t aID); 1.884 + nsresult StartResizing(nsIDOMElement * aHandle); 1.885 + int32_t GetNewResizingX(int32_t aX, int32_t aY); 1.886 + int32_t GetNewResizingY(int32_t aX, int32_t aY); 1.887 + int32_t GetNewResizingWidth(int32_t aX, int32_t aY); 1.888 + int32_t GetNewResizingHeight(int32_t aX, int32_t aY); 1.889 + void HideShadowAndInfo(); 1.890 + void SetFinalSize(int32_t aX, int32_t aY); 1.891 + void DeleteRefToAnonymousNode(nsIDOMNode * aNode); 1.892 + void SetResizeIncrements(int32_t aX, int32_t aY, int32_t aW, int32_t aH, bool aPreserveRatio); 1.893 + void HideAnonymousEditingUIs(); 1.894 + 1.895 + /* ABSOLUTE POSITIONING */ 1.896 + 1.897 + int32_t mPositionedObjectX; 1.898 + int32_t mPositionedObjectY; 1.899 + int32_t mPositionedObjectWidth; 1.900 + int32_t mPositionedObjectHeight; 1.901 + 1.902 + int32_t mPositionedObjectMarginLeft; 1.903 + int32_t mPositionedObjectMarginTop; 1.904 + int32_t mPositionedObjectBorderLeft; 1.905 + int32_t mPositionedObjectBorderTop; 1.906 + 1.907 + nsCOMPtr<nsIDOMElement> mAbsolutelyPositionedObject; 1.908 + nsCOMPtr<nsIDOMElement> mGrabber; 1.909 + nsCOMPtr<nsIDOMElement> mPositioningShadow; 1.910 + 1.911 + int32_t mGridSize; 1.912 + 1.913 + nsresult CreateGrabber(nsIDOMNode * aParentNode, nsIDOMElement ** aReturn); 1.914 + nsresult StartMoving(nsIDOMElement * aHandle); 1.915 + nsresult SetFinalPosition(int32_t aX, int32_t aY); 1.916 + void AddPositioningOffset(int32_t & aX, int32_t & aY); 1.917 + void SnapToGrid(int32_t & newX, int32_t & newY); 1.918 + nsresult GrabberClicked(); 1.919 + nsresult EndMoving(); 1.920 + nsresult CheckPositionedElementBGandFG(nsIDOMElement * aElement, 1.921 + nsAString & aReturn); 1.922 + 1.923 + /* INLINE TABLE EDITING */ 1.924 + 1.925 + nsCOMPtr<nsIDOMElement> mInlineEditedCell; 1.926 + 1.927 + nsCOMPtr<nsIDOMElement> mAddColumnBeforeButton; 1.928 + nsCOMPtr<nsIDOMElement> mRemoveColumnButton; 1.929 + nsCOMPtr<nsIDOMElement> mAddColumnAfterButton; 1.930 + 1.931 + nsCOMPtr<nsIDOMElement> mAddRowBeforeButton; 1.932 + nsCOMPtr<nsIDOMElement> mRemoveRowButton; 1.933 + nsCOMPtr<nsIDOMElement> mAddRowAfterButton; 1.934 + 1.935 + void AddMouseClickListener(nsIDOMElement * aElement); 1.936 + void RemoveMouseClickListener(nsIDOMElement * aElement); 1.937 + 1.938 + nsCOMPtr<nsILinkHandler> mLinkHandler; 1.939 + 1.940 +public: 1.941 + 1.942 +// friends 1.943 +friend class nsHTMLEditRules; 1.944 +friend class nsTextEditRules; 1.945 +friend class nsWSRunObject; 1.946 +friend class nsHTMLEditorEventListener; 1.947 + 1.948 +private: 1.949 + // Helpers 1.950 + bool IsSimpleModifiableNode(nsIContent* aContent, 1.951 + nsIAtom* aProperty, 1.952 + const nsAString* aAttribute, 1.953 + const nsAString* aValue); 1.954 + nsresult SetInlinePropertyOnNodeImpl(nsIContent* aNode, 1.955 + nsIAtom* aProperty, 1.956 + const nsAString* aAttribute, 1.957 + const nsAString* aValue); 1.958 + typedef enum { eInserted, eAppended } InsertedOrAppended; 1.959 + void DoContentInserted(nsIDocument* aDocument, nsIContent* aContainer, 1.960 + nsIContent* aChild, int32_t aIndexInContainer, 1.961 + InsertedOrAppended aInsertedOrAppended); 1.962 +}; 1.963 +#endif //nsHTMLEditor_h__ 1.964 +