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