1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsILineBreaker_h__
6 #define nsILineBreaker_h__
8 #include "nsISupports.h"
12 #define NS_LINEBREAKER_NEED_MORE_TEXT -1
14 // {0x4b0b9e04-6ffb-4647-aa5f-2fa2ebd883e8}
15 #define NS_ILINEBREAKER_IID \
16 {0x4b0b9e04, 0x6ffb, 0x4647, \
17 {0xaa, 0x5f, 0x2f, 0xa2, 0xeb, 0xd8, 0x83, 0xe8}}
19 class nsILineBreaker
: public nsISupports
22 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINEBREAKER_IID
)
25 kWordBreak_Normal
= 0, // default
26 kWordBreak_BreakAll
= 1, // break all
27 kWordBreak_KeepAll
= 2 // always keep
30 virtual int32_t Next( const char16_t
* aText
, uint32_t aLen
,
33 virtual int32_t Prev( const char16_t
* aText
, uint32_t aLen
,
36 // Call this on a word with whitespace at either end. We will apply JISx4051
37 // rules to find breaks inside the word. aBreakBefore is set to the break-
38 // before status of each character; aBreakBefore[0] will always be false
39 // because we never return a break before the first character.
40 // aLength is the length of the aText array and also the length of the aBreakBefore
42 virtual void GetJISx4051Breaks(const char16_t
* aText
, uint32_t aLength
,
44 uint8_t* aBreakBefore
) = 0;
45 virtual void GetJISx4051Breaks(const uint8_t* aText
, uint32_t aLength
,
47 uint8_t* aBreakBefore
) = 0;
50 NS_DEFINE_STATIC_IID_ACCESSOR(nsILineBreaker
, NS_ILINEBREAKER_IID
)
53 NS_IsSpace(char16_t u
)
55 return u
== 0x0020 || // SPACE
56 u
== 0x0009 || // CHARACTER TABULATION
57 u
== 0x000D || // CARRIAGE RETURN
58 u
== 0x1680 || // OGHAM SPACE MARK
59 (0x2000 <= u
&& u
<= 0x2006) || // EN QUAD, EM QUAD, EN SPACE,
60 // EM SPACE, THREE-PER-EM SPACE,
61 // FOUR-PER-SPACE, SIX-PER-EM SPACE,
62 (0x2008 <= u
&& u
<= 0x200B) || // PUNCTUATION SPACE, THIN SPACE,
63 // HAIR SPACE, ZERO WIDTH SPACE
64 u
== 0x205F; // MEDIUM MATHEMATICAL SPACE
68 NS_NeedsPlatformNativeHandling(char16_t aChar
)
70 return (0x0e01 <= aChar
&& aChar
<= 0x0fff) || // Thai, Lao, Tibetan
71 (0x1780 <= aChar
&& aChar
<= 0x17ff); // Khmer
74 #endif /* nsILineBreaker_h__ */