Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: third_party/WebKit/Source/core/editing/spellcheck/TextCheckingHelper.h

Issue 2251753002: Merge TextCheckingHelper into SpellChecker Part 5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CleanupIncludesInTCH
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef TextCheckingHelper_h
22 #define TextCheckingHelper_h
23
24 #include "core/editing/EphemeralRange.h"
25 #include "core/editing/Position.h"
26 #include "wtf/text/WTFString.h"
27
28 namespace blink {
29
30 class Range;
31
32 class TextCheckingParagraph {
33 STACK_ALLOCATED();
34 public:
35 explicit TextCheckingParagraph(const EphemeralRange& checkingRange);
36 TextCheckingParagraph(const EphemeralRange& checkingRange, const EphemeralRa nge& paragraphRange);
37 TextCheckingParagraph(Range* checkingRange, Range* paragraphRange);
38 ~TextCheckingParagraph();
39
40 int rangeLength() const;
41 EphemeralRange subrange(int characterOffset, int characterCount) const;
42 int offsetTo(const Position&) const;
43 void expandRangeToNextEnd();
44
45 const String& text() const;
46 // Why not let clients call these functions on text() themselves?
47 String textSubstring(unsigned pos, unsigned len = INT_MAX) const { return te xt().substring(pos, len); }
48 UChar textCharAt(int index) const { return text()[static_cast<unsigned>(inde x)]; }
49
50 bool isEmpty() const;
51
52 int checkingStart() const;
53 int checkingEnd() const;
54 int checkingLength() const;
55
56 bool checkingRangeCovers(int location, int length) const { return location < checkingEnd() && location + length > checkingStart(); }
57 EphemeralRange paragraphRange() const;
58 void setParagraphRange(const EphemeralRange&);
59
60 EphemeralRange checkingRange() const { return m_checkingRange; }
61
62 private:
63 void invalidateParagraphRangeValues();
64 EphemeralRange offsetAsRange() const;
65
66 bool isTextEmpty() const { return text().isEmpty(); }
67 bool isRangeEmpty() const { return checkingStart() >= checkingEnd(); }
68
69 EphemeralRange m_checkingRange;
70 mutable EphemeralRange m_paragraphRange;
71 mutable EphemeralRange m_offsetAsRange;
72 mutable String m_text;
73 mutable int m_checkingStart;
74 mutable int m_checkingEnd;
75 mutable int m_checkingLength;
76 };
77
78 } // namespace blink
79
80 #endif // TextCheckingHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698