#ifndef htmlediting_h
#define htmlediting_h
#include "core/dom/Position.h"
#include "core/editing/EditingBoundary.h"
#include "platform/text/TextDirection.h"
#include "wtf/Forward.h"
#include "wtf/unicode/CharacterNames.h"
namespace WebCore {
class Document;
class Element;
class ExceptionState;
class HTMLElement;
class Node;
class Position;
class Range;
class VisiblePosition;
class VisibleSelection;
Node* highestEditableRoot(const Position&, EditableType = ContentIsEditable);
Node* highestEnclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Node*),
EditingBoundaryCrossingRule = CannotCrossEditingBoundary, Node* stayWithin = 0);
Node* highestNodeToRemoveInPruning(Node*, Node* excludeNode = 0);
Node* lowestEditableAncestor(Node*);
Element* enclosingBlock(Node*, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
Node* enclosingTableCell(const Position&);
Node* enclosingEmptyListItem(const VisiblePosition&);
Element* enclosingAnchorElement(const Position&);
Node* enclosingNodeWithTag(const Position&, const QualifiedName&);
Node* enclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
Node* tabSpanNode(const Node*);
Node* isLastPositionBeforeTable(const VisiblePosition&);
Node* isFirstPositionAfterTable(const VisiblePosition&);
int lastOffsetForEditing(const Node*);
int caretMinOffset(const Node*);
int caretMaxOffset(const Node*);
inline bool editingIgnoresContent(const Node* node)
{
return !node->canContainRangeEndPoint();
}
inline bool canHaveChildrenForEditing(const Node* node)
{
return !node->isTextNode() && node->canContainRangeEndPoint();
}
bool isAtomicNode(const Node*);
bool isBlock(const Node*);
bool isInline(const Node*);
bool isSpecialElement(const Node*);
bool isTabSpanNode(const Node*);
bool isTabSpanTextNode(const Node*);
bool isMailBlockquote(const Node*);
bool isRenderedTable(const Node*);
bool isRenderedTableElement(const Node*);
bool isTableCell(const Node*);
bool isEmptyTableCell(const Node*);
bool isTableStructureNode(const Node*);
bool isListElement(Node*);
bool isListItem(const Node*);
bool isNodeRendered(const Node*);
bool isNodeVisiblyContainedWithin(Node&, const Range&);
bool isRenderedAsNonInlineTableImageOrHR(const Node*);
bool areIdenticalElements(const Node*, const Node*);
bool isNonTableCellHTMLBlockElement(const Node*);
TextDirection directionOfEnclosingBlock(const Position&);
Position nextCandidate(const Position&);
Position previousCandidate(const Position&);
Position nextVisuallyDistinctCandidate(const Position&);
Position previousVisuallyDistinctCandidate(const Position&);
Position positionBeforeContainingSpecialElement(const Position&, Node** containingSpecialElement = 0);
Position positionAfterContainingSpecialElement(const Position&, Node** containingSpecialElement = 0);
inline Position firstPositionInOrBeforeNode(Node* node)
{
if (!node)
return Position();
return editingIgnoresContent(node) ? positionBeforeNode(node) : firstPositionInNode(node);
}
inline Position lastPositionInOrAfterNode(Node* node)
{
if (!node)
return Position();
return editingIgnoresContent(node) ? positionAfterNode(node) : lastPositionInNode(node);
}
int comparePositions(const Position&, const Position&);
int comparePositions(const PositionWithAffinity&, const PositionWithAffinity&);
enum EUpdateStyle { UpdateStyle, DoNotUpdateStyle };
bool isEditablePosition(const Position&, EditableType = ContentIsEditable, EUpdateStyle = UpdateStyle);
bool isRichlyEditablePosition(const Position&, EditableType = ContentIsEditable);
bool lineBreakExistsAtPosition(const Position&);
bool isVisiblyAdjacent(const Position& first, const Position& second);
bool isAtUnsplittableElement(const Position&);
unsigned numEnclosingMailBlockquotes(const Position&);
void updatePositionForNodeRemoval(Position&, Node&);
VisiblePosition firstEditablePositionAfterPositionInRoot(const Position&, Node*);
VisiblePosition lastEditablePositionBeforePositionInRoot(const Position&, Node*);
VisiblePosition visiblePositionBeforeNode(Node&);
VisiblePosition visiblePositionAfterNode(Node&);
bool lineBreakExistsAtVisiblePosition(const VisiblePosition&);
int comparePositions(const VisiblePosition&, const VisiblePosition&);
int indexForVisiblePosition(const VisiblePosition&, RefPtr<ContainerNode>& scope);
VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope);
PassRefPtrWillBeRawPtr<Range> createRange(Document&, const VisiblePosition& start, const VisiblePosition& end, ExceptionState&);
PassRefPtr<HTMLElement> createDefaultParagraphElement(Document&);
PassRefPtr<HTMLElement> createBreakElement(Document&);
PassRefPtr<HTMLElement> createOrderedListElement(Document&);
PassRefPtr<HTMLElement> createUnorderedListElement(Document&);
PassRefPtr<HTMLElement> createListItemElement(Document&);
PassRefPtr<HTMLElement> createHTMLElement(Document&, const QualifiedName&);
PassRefPtr<HTMLElement> createHTMLElement(Document&, const AtomicString&);
HTMLElement* enclosingList(Node*);
HTMLElement* outermostEnclosingList(Node*, Node* rootList = 0);
Node* enclosingListChild(Node*);
PassRefPtr<Element> createTabSpanElement(Document&);
PassRefPtr<Element> createTabSpanElement(Document&, PassRefPtr<Node> tabTextNode);
PassRefPtr<Element> createTabSpanElement(Document&, const String& tabText);
PassRefPtr<Element> createBlockPlaceholderElement(Document&);
Element* editableRootForPosition(const Position&, EditableType = ContentIsEditable);
Element* unsplittableElementForPosition(const Position&);
bool canMergeLists(Element* firstList, Element* secondList);
VisibleSelection selectionForParagraphIteration(const VisibleSelection&);
Position adjustedSelectionStartForStyleComputation(const VisibleSelection&);
inline bool isWhitespace(UChar c)
{
return c == noBreakSpace || c == ' ' || c == '\n' || c == '\t';
}
inline bool isCollapsibleWhitespace(UChar c)
{
return c == ' ' || c == '\n';
}
inline bool isAmbiguousBoundaryCharacter(UChar character)
{
return character == '\'' || character == rightSingleQuotationMark || character == hebrewPunctuationGershayim;
}
String stringWithRebalancedWhitespace(const String&, bool startIsStartOfParagraph, bool endIsEndOfParagraph);
const String& nonBreakingSpaceString();
}
#endif