visible_units.h 4.86 KB
Newer Older
kocienda's avatar
kocienda committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

darin's avatar
darin committed
26 27
#ifndef visible_units_h
#define visible_units_h
kocienda's avatar
kocienda committed
28

29
#include "EditingBoundary.h"
30
#include "TextDirection.h"
kocienda's avatar
kocienda committed
31

darin's avatar
darin committed
32
namespace WebCore {
kocienda's avatar
kocienda committed
33

34
class Node;
darin's avatar
darin committed
35
class VisiblePosition;
darin's avatar
darin committed
36 37 38 39

enum EWordSide { RightWordIfOnBoundary = false, LeftWordIfOnBoundary = true };

// words
darin's avatar
darin committed
40 41 42 43
VisiblePosition startOfWord(const VisiblePosition &, EWordSide = RightWordIfOnBoundary);
VisiblePosition endOfWord(const VisiblePosition &, EWordSide = RightWordIfOnBoundary);
VisiblePosition previousWordPosition(const VisiblePosition &);
VisiblePosition nextWordPosition(const VisiblePosition &);
44 45
VisiblePosition rightWordPosition(const VisiblePosition&);
VisiblePosition leftWordPosition(const VisiblePosition&);
46
bool isStartOfWord(const VisiblePosition&);
darin's avatar
darin committed
47

harrison's avatar
harrison committed
48 49 50 51 52 53
// sentences
VisiblePosition startOfSentence(const VisiblePosition &);
VisiblePosition endOfSentence(const VisiblePosition &);
VisiblePosition previousSentencePosition(const VisiblePosition &);
VisiblePosition nextSentencePosition(const VisiblePosition &);

darin's avatar
darin committed
54
// lines
harrison's avatar
harrison committed
55
VisiblePosition startOfLine(const VisiblePosition &);
56
VisiblePosition endOfLine(const VisiblePosition &);
harrison's avatar
harrison committed
57 58 59
VisiblePosition previousLinePosition(const VisiblePosition &, int x);
VisiblePosition nextLinePosition(const VisiblePosition &, int x);
bool inSameLine(const VisiblePosition &, const VisiblePosition &);
mitz@apple.com's avatar
mitz@apple.com committed
60
bool inSameLogicalLine(const VisiblePosition &, const VisiblePosition &);
harrison's avatar
harrison committed
61 62
bool isStartOfLine(const VisiblePosition &);
bool isEndOfLine(const VisiblePosition &);
mitz@apple.com's avatar
mitz@apple.com committed
63 64
VisiblePosition logicalStartOfLine(const VisiblePosition &);
VisiblePosition logicalEndOfLine(const VisiblePosition &);
65 66
VisiblePosition leftBoundaryOfLine(const VisiblePosition&, TextDirection);
VisiblePosition rightBoundaryOfLine(const VisiblePosition&, TextDirection);
darin's avatar
darin committed
67

darin's avatar
darin committed
68
// paragraphs (perhaps a misnomer, can be divided by line break elements)
69 70
VisiblePosition startOfParagraph(const VisiblePosition&, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
VisiblePosition endOfParagraph(const VisiblePosition&, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
justin.garcia@apple.com's avatar
justin.garcia@apple.com committed
71
VisiblePosition startOfNextParagraph(const VisiblePosition&);
harrison's avatar
harrison committed
72 73
VisiblePosition previousParagraphPosition(const VisiblePosition &, int x);
VisiblePosition nextParagraphPosition(const VisiblePosition &, int x);
74 75
bool isStartOfParagraph(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
bool isEndOfParagraph(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
76
bool inSameParagraph(const VisiblePosition &, const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
darin's avatar
darin committed
77

darin's avatar
darin committed
78
// blocks (true paragraphs; line break elements don't break blocks)
79 80
VisiblePosition startOfBlock(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
VisiblePosition endOfBlock(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
darin's avatar
darin committed
81 82 83 84 85
bool inSameBlock(const VisiblePosition &, const VisiblePosition &);
bool isStartOfBlock(const VisiblePosition &);
bool isEndOfBlock(const VisiblePosition &);

// document
harrison's avatar
harrison committed
86 87
VisiblePosition startOfDocument(const Node*);
VisiblePosition endOfDocument(const Node*);
darin's avatar
darin committed
88 89 90 91 92 93
VisiblePosition startOfDocument(const VisiblePosition &);
VisiblePosition endOfDocument(const VisiblePosition &);
bool inSameDocument(const VisiblePosition &, const VisiblePosition &);
bool isStartOfDocument(const VisiblePosition &);
bool isEndOfDocument(const VisiblePosition &);

harrison's avatar
harrison committed
94
// editable content
justing's avatar
justing committed
95 96
VisiblePosition startOfEditableContent(const VisiblePosition&);
VisiblePosition endOfEditableContent(const VisiblePosition&);
harrison's avatar
harrison committed
97

darin's avatar
darin committed
98
} // namespace WebCore
kocienda's avatar
kocienda committed
99

darin's avatar
darin committed
100
#endif // VisiblePosition_h