1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef nsFind_h__ 8 #define nsFind_h__ 9 10 #include "nsIFind.h" 11 12 #include "nsCOMPtr.h" 13 #include "nsCycleCollectionParticipant.h" 14 #include "nsINode.h" 15 #include "mozilla/intl/WordBreaker.h" 16 17 class nsIContent; 18 class nsRange; 19 20 #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1" 21 22 #define NS_FIND_CID \ 23 { \ 24 0x471f4944, 0x1dd2, 0x11b2, { \ 25 0x87, 0xac, 0x90, 0xbe, 0x0a, 0x51, 0xd6, 0x09 \ 26 } \ 27 } 28 29 class nsFindContentIterator; 30 31 class nsFind : public nsIFind { 32 public: 33 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 34 NS_DECL_NSIFIND 35 NS_DECL_CYCLE_COLLECTION_CLASS(nsFind) 36 37 nsFind(); 38 39 protected: 40 virtual ~nsFind(); 41 42 // Parameters set from the interface: 43 bool mFindBackward; 44 bool mCaseSensitive; 45 bool mMatchDiacritics; 46 47 // Use "find entire words" mode by setting to a word breaker or null, to 48 // disable "entire words" mode. 49 RefPtr<mozilla::intl::WordBreaker> mWordBreaker; 50 51 struct State; 52 class StateRestorer; 53 54 // Extract a character from a string, handling surrogate pairs and 55 // incrementing the index if a surrogate pair is encountered 56 char32_t DecodeChar(const char16_t* t2b, int32_t* index) const; 57 58 // Determine if a line break can occur between two characters 59 // 60 // This could be improved because some languages require more context than two 61 // characters to determine where line breaks can occur 62 bool BreakInBetween(char32_t x, char32_t y) const; 63 64 // Get the first character from the next node (last if mFindBackward). 65 // 66 // This will mutate the state, but then restore it afterwards. 67 char32_t PeekNextChar(State&) const; 68 }; 69 70 #endif // nsFind_h__ 71