editor/libeditor/html/nsHTMLEditor.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial