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

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

Issue 2247003005: Eliminate class TextCheckingHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CleanupUnifiedTextChecker
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 "platform/heap/Handle.h"
27 #include "platform/text/TextChecking.h"
28 #include "wtf/text/WTFString.h"
29
30 namespace blink {
31
32 class LocalFrame;
33 class Range;
34 class SpellCheckerClient;
35 class TextCheckerClient;
36 struct TextCheckingResult;
37
38 class TextCheckingParagraph {
39 STACK_ALLOCATED();
40 public:
41 explicit TextCheckingParagraph(const EphemeralRange& checkingRange);
42 TextCheckingParagraph(const EphemeralRange& checkingRange, const EphemeralRa nge& paragraphRange);
43 TextCheckingParagraph(Range* checkingRange, Range* paragraphRange);
44 ~TextCheckingParagraph();
45
46 int rangeLength() const;
47 EphemeralRange subrange(int characterOffset, int characterCount) const;
48 int offsetTo(const Position&) const;
49 void expandRangeToNextEnd();
50
51 const String& text() const;
52 // Why not let clients call these functions on text() themselves?
53 String textSubstring(unsigned pos, unsigned len = INT_MAX) const { return te xt().substring(pos, len); }
54 UChar textCharAt(int index) const { return text()[static_cast<unsigned>(inde x)]; }
55
56 bool isEmpty() const;
57
58 int checkingStart() const;
59 int checkingEnd() const;
60 int checkingLength() const;
61
62 bool checkingRangeCovers(int location, int length) const { return location < checkingEnd() && location + length > checkingStart(); }
63 EphemeralRange paragraphRange() const;
64 void setParagraphRange(const EphemeralRange&);
65
66 EphemeralRange checkingRange() const { return m_checkingRange; }
67
68 private:
69 void invalidateParagraphRangeValues();
70 EphemeralRange offsetAsRange() const;
71
72 bool isTextEmpty() const { return text().isEmpty(); }
73 bool isRangeEmpty() const { return checkingStart() >= checkingEnd(); }
74
75 EphemeralRange m_checkingRange;
76 mutable EphemeralRange m_paragraphRange;
77 mutable EphemeralRange m_offsetAsRange;
78 mutable String m_text;
79 mutable int m_checkingStart;
80 mutable int m_checkingEnd;
81 mutable int m_checkingLength;
82 };
83
84 class TextCheckingHelper {
85 WTF_MAKE_NONCOPYABLE(TextCheckingHelper);
86 STACK_ALLOCATED();
87 public:
88 TextCheckingHelper(SpellCheckerClient&, const Position& start, const Positio n& end);
89 ~TextCheckingHelper();
90
91 String findFirstMisspellingOrBadGrammar(int& outFirstFoundOffset);
92
93 private:
94 SpellCheckerClient* m_client;
95 Position m_start;
96 Position m_end;
97 };
98
99 } // namespace blink
100
101 #endif // TextCheckingHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698