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

Side by Side Diff: Source/core/editing/TextCheckingHelper.h

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use STACK_ALLOCATED() + incorporate ager's overview of macros in this area. Created 6 years, 8 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
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 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 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, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #ifndef TextCheckingHelper_h 21 #ifndef TextCheckingHelper_h
22 #define TextCheckingHelper_h 22 #define TextCheckingHelper_h
23 23
24 #include "platform/heap/Handle.h"
24 #include "platform/text/TextChecking.h" 25 #include "platform/text/TextChecking.h"
25 #include "wtf/text/WTFString.h" 26 #include "wtf/text/WTFString.h"
26 27
27 namespace WebCore { 28 namespace WebCore {
28 29
29 class ExceptionState; 30 class ExceptionState;
30 class LocalFrame; 31 class LocalFrame;
31 class Range; 32 class Range;
32 class Position; 33 class Position;
33 class SpellCheckerClient; 34 class SpellCheckerClient;
34 class TextCheckerClient; 35 class TextCheckerClient;
35 struct TextCheckingResult; 36 struct TextCheckingResult;
36 37
37 class TextCheckingParagraph { 38 class TextCheckingParagraph {
39 STACK_ALLOCATED();
38 public: 40 public:
39 explicit TextCheckingParagraph(PassRefPtr<Range> checkingRange); 41 explicit TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> checkingRange);
40 TextCheckingParagraph(PassRefPtr<Range> checkingRange, PassRefPtr<Range> par agraphRange); 42 TextCheckingParagraph(PassRefPtrWillBeRawPtr<Range> checkingRange, PassRefPt rWillBeRawPtr<Range> paragraphRange);
41 ~TextCheckingParagraph(); 43 ~TextCheckingParagraph();
42 44
43 int rangeLength() const; 45 int rangeLength() const;
44 PassRefPtr<Range> subrange(int characterOffset, int characterCount) const; 46 PassRefPtrWillBeRawPtr<Range> subrange(int characterOffset, int characterCou nt) const;
45 int offsetTo(const Position&, ExceptionState&) const; 47 int offsetTo(const Position&, ExceptionState&) const;
46 void expandRangeToNextEnd(); 48 void expandRangeToNextEnd();
47 49
48 const String& text() const; 50 const String& text() const;
49 // Why not let clients call these functions on text() themselves? 51 // Why not let clients call these functions on text() themselves?
50 String textSubstring(unsigned pos, unsigned len = INT_MAX) const { return te xt().substring(pos, len); } 52 String textSubstring(unsigned pos, unsigned len = INT_MAX) const { return te xt().substring(pos, len); }
51 UChar textCharAt(int index) const { return text()[static_cast<unsigned>(inde x)]; } 53 UChar textCharAt(int index) const { return text()[static_cast<unsigned>(inde x)]; }
52 54
53 bool isEmpty() const; 55 bool isEmpty() const;
54 bool isTextEmpty() const { return text().isEmpty(); } 56 bool isTextEmpty() const { return text().isEmpty(); }
55 bool isRangeEmpty() const { return checkingStart() >= checkingEnd(); } 57 bool isRangeEmpty() const { return checkingStart() >= checkingEnd(); }
56 58
57 int checkingStart() const; 59 int checkingStart() const;
58 int checkingEnd() const; 60 int checkingEnd() const;
59 int checkingLength() const; 61 int checkingLength() const;
60 String checkingSubstring() const { return textSubstring(checkingStart(), che ckingLength()); } 62 String checkingSubstring() const { return textSubstring(checkingStart(), che ckingLength()); }
61 63
62 bool checkingRangeCovers(int location, int length) const { return location < checkingEnd() && location + length > checkingStart(); } 64 bool checkingRangeCovers(int location, int length) const { return location < checkingEnd() && location + length > checkingStart(); }
63 PassRefPtr<Range> paragraphRange() const; 65 PassRefPtrWillBeRawPtr<Range> paragraphRange() const;
64 PassRefPtr<Range> checkingRange() const { return m_checkingRange; } 66 PassRefPtrWillBeRawPtr<Range> checkingRange() const { return m_checkingRange ; }
65 67
66 private: 68 private:
67 void invalidateParagraphRangeValues(); 69 void invalidateParagraphRangeValues();
68 PassRefPtr<Range> offsetAsRange() const; 70 PassRefPtrWillBeRawPtr<Range> offsetAsRange() const;
69 71
70 RefPtr<Range> m_checkingRange; 72 RefPtrWillBeMember<Range> m_checkingRange;
71 mutable RefPtr<Range> m_paragraphRange; 73 mutable RefPtrWillBeMember<Range> m_paragraphRange;
72 mutable RefPtr<Range> m_offsetAsRange; 74 mutable RefPtrWillBeMember<Range> m_offsetAsRange;
73 mutable String m_text; 75 mutable String m_text;
74 mutable int m_checkingStart; 76 mutable int m_checkingStart;
75 mutable int m_checkingEnd; 77 mutable int m_checkingEnd;
76 mutable int m_checkingLength; 78 mutable int m_checkingLength;
77 }; 79 };
78 80
79 class TextCheckingHelper { 81 class TextCheckingHelper {
80 WTF_MAKE_NONCOPYABLE(TextCheckingHelper); 82 WTF_MAKE_NONCOPYABLE(TextCheckingHelper);
83 STACK_ALLOCATED();
81 public: 84 public:
82 TextCheckingHelper(SpellCheckerClient&, PassRefPtr<Range>); 85 TextCheckingHelper(SpellCheckerClient&, PassRefPtrWillBeRawPtr<Range>);
83 ~TextCheckingHelper(); 86 ~TextCheckingHelper();
84 87
85 String findFirstMisspelling(int& firstMisspellingOffset, bool markAll, RefPt r<Range>& firstMisspellingRange); 88 String findFirstMisspelling(int& firstMisspellingOffset, bool markAll, RefPt rWillBeRawPtr<Range>& firstMisspellingRange);
86 String findFirstMisspellingOrBadGrammar(bool checkGrammar, bool& outIsSpelli ng, int& outFirstFoundOffset, GrammarDetail& outGrammarDetail); 89 String findFirstMisspellingOrBadGrammar(bool checkGrammar, bool& outIsSpelli ng, int& outFirstFoundOffset, GrammarDetail& outGrammarDetail);
87 String findFirstBadGrammar(GrammarDetail& outGrammarDetail, int& outGrammarP hraseOffset, bool markAll); 90 String findFirstBadGrammar(GrammarDetail& outGrammarDetail, int& outGrammarP hraseOffset, bool markAll);
88 void markAllMisspellings(RefPtr<Range>& firstMisspellingRange); 91 void markAllMisspellings(RefPtrWillBeRawPtr<Range>& firstMisspellingRange);
89 void markAllBadGrammar(); 92 void markAllBadGrammar();
90 93
91 private: 94 private:
92 SpellCheckerClient* m_client; 95 SpellCheckerClient* m_client;
93 RefPtr<Range> m_range; 96 RefPtrWillBeMember<Range> m_range;
94 97
95 int findFirstGrammarDetail(const Vector<GrammarDetail>& grammarDetails, int badGrammarPhraseLocation, int startOffset, int endOffset, bool markAll) const; 98 int findFirstGrammarDetail(const Vector<GrammarDetail>& grammarDetails, int badGrammarPhraseLocation, int startOffset, int endOffset, bool markAll) const;
96 bool unifiedTextCheckerEnabled() const; 99 bool unifiedTextCheckerEnabled() const;
97 }; 100 };
98 101
99 void checkTextOfParagraph(TextCheckerClient&, const String&, TextCheckingTypeMas k, Vector<TextCheckingResult>&); 102 void checkTextOfParagraph(TextCheckerClient&, const String&, TextCheckingTypeMas k, Vector<TextCheckingResult>&);
100 103
101 bool unifiedTextCheckerEnabled(const LocalFrame*); 104 bool unifiedTextCheckerEnabled(const LocalFrame*);
102 105
103 } // namespace WebCore 106 } // namespace WebCore
104 107
105 #endif // TextCheckingHelper_h 108 #endif // TextCheckingHelper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698