1 /* 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef htmlediting_h 27 #define htmlediting_h 28 29 #include <wtf/Forward.h> 30 #include "HTMLNames.h" 31 #include "ExceptionCode.h" 32 33 namespace WebCore { 34 35 class Document; 36 class Element; 37 class HTMLElement; 38 class Node; 39 class Position; 40 class Range; 41 class String; 42 class VisiblePosition; 43 class VisibleSelection; 44 45 Position rangeCompliantEquivalent(const Position&); 46 Position rangeCompliantEquivalent(const VisiblePosition&); 47 int lastOffsetForEditing(const Node*); 48 bool isAtomicNode(const Node*); 49 bool editingIgnoresContent(const Node*); 50 bool canHaveChildrenForEditing(const Node*); 51 Node* highestEditableRoot(const Position&); 52 VisiblePosition firstEditablePositionAfterPositionInRoot(const Position&, Node*); 53 VisiblePosition lastEditablePositionBeforePositionInRoot(const Position&, Node*); 54 int comparePositions(const Position&, const Position&); 55 int comparePositions(const VisiblePosition&, const VisiblePosition&); 56 Node* lowestEditableAncestor(Node*); 57 Position nextCandidate(const Position&); 58 Position nextVisuallyDistinctCandidate(const Position&); 59 Position previousCandidate(const Position&); 60 Position previousVisuallyDistinctCandidate(const Position&); 61 bool isEditablePosition(const Position&); 62 bool isRichlyEditablePosition(const Position&); 63 Element* editableRootForPosition(const Position&); 64 Element* unsplittableElementForPosition(const Position&); 65 bool isBlock(const Node*); 66 Node* enclosingBlock(Node*); 67 68 String stringWithRebalancedWhitespace(const String&, bool, bool); 69 const String& nonBreakingSpaceString(); 70 71 //------------------------------------------------------------------------------------------ 72 73 Position positionBeforeNode(const Node*); 74 Position positionAfterNode(const Node*); 75 VisiblePosition visiblePositionBeforeNode(Node*); 76 VisiblePosition visiblePositionAfterNode(Node*); 77 PassRefPtr<Range> createRange(PassRefPtr<Document>, const VisiblePosition& start, const VisiblePosition& end, ExceptionCode&); 78 PassRefPtr<Range> extendRangeToWrappingNodes(PassRefPtr<Range> rangeToExtend, const Range* maximumRange, const Node* rootNode); 79 80 PassRefPtr<Range> avoidIntersectionWithNode(const Range*, Node*); 81 VisibleSelection avoidIntersectionWithNode(const VisibleSelection&, Node*); 82 83 bool isSpecialElement(const Node*); 84 bool validBlockTag(const String&); 85 86 PassRefPtr<HTMLElement> createDefaultParagraphElement(Document*); 87 PassRefPtr<HTMLElement> createBreakElement(Document*); 88 PassRefPtr<HTMLElement> createOrderedListElement(Document*); 89 PassRefPtr<HTMLElement> createUnorderedListElement(Document*); 90 PassRefPtr<HTMLElement> createListItemElement(Document*); 91 PassRefPtr<HTMLElement> createHTMLElement(Document*, const QualifiedName&); 92 PassRefPtr<HTMLElement> createHTMLElement(Document*, const AtomicString&); 93 94 bool isTabSpanNode(const Node*); 95 bool isTabSpanTextNode(const Node*); 96 Node* tabSpanNode(const Node*); 97 Position positionBeforeTabSpan(const Position&); 98 PassRefPtr<Element> createTabSpanElement(Document*); 99 PassRefPtr<Element> createTabSpanElement(Document*, PassRefPtr<Node> tabTextNode); 100 PassRefPtr<Element> createTabSpanElement(Document*, const String& tabText); 101 102 bool isNodeRendered(const Node*); 103 bool isMailBlockquote(const Node*); 104 Node* nearestMailBlockquote(const Node*); 105 unsigned numEnclosingMailBlockquotes(const Position&); 106 int caretMinOffset(const Node*); 107 int caretMaxOffset(const Node*); 108 109 //------------------------------------------------------------------------------------------ 110 111 bool isTableStructureNode(const Node*); 112 PassRefPtr<Element> createBlockPlaceholderElement(Document*); 113 114 bool isFirstVisiblePositionInSpecialElement(const Position&); 115 Position positionBeforeContainingSpecialElement(const Position&, Node** containingSpecialElement=0); 116 bool isLastVisiblePositionInSpecialElement(const Position&); 117 Position positionAfterContainingSpecialElement(const Position&, Node** containingSpecialElement=0); 118 Position positionOutsideContainingSpecialElement(const Position&, Node** containingSpecialElement=0); 119 Node* isLastPositionBeforeTable(const VisiblePosition&); 120 Node* isFirstPositionAfterTable(const VisiblePosition&); 121 122 Node* enclosingNodeWithTag(const Position&, const QualifiedName&); 123 Node* enclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Node*), bool onlyReturnEditableNodes = true); 124 Node* highestEnclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Node*)); 125 Node* enclosingTableCell(const Position&); 126 Node* enclosingEmptyListItem(const VisiblePosition&); 127 Node* enclosingAnchorElement(const Position&); 128 bool isListElement(Node*); 129 HTMLElement* enclosingList(Node*); 130 HTMLElement* outermostEnclosingList(Node*); 131 HTMLElement* enclosingListChild(Node*); 132 bool canMergeLists(Element* firstList, Element* secondList); 133 Node* highestAncestor(Node*); 134 bool isTableElement(Node*); 135 bool isTableCell(const Node*); 136 137 bool lineBreakExistsAtPosition(const Position&); 138 bool lineBreakExistsAtVisiblePosition(const VisiblePosition&); 139 140 VisibleSelection selectionForParagraphIteration(const VisibleSelection&); 141 142 int indexForVisiblePosition(const VisiblePosition&); 143 bool isVisiblyAdjacent(const Position& first, const Position& second); 144 bool isNodeVisiblyContainedWithin(Node*, const Range*); 145 } 146 147 #endif 148