2001-09-26 00:40:45 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-02-09 16:01:48 +00:00
|
|
|
#ifndef nsILineBreaker_h__
|
|
|
|
#define nsILineBreaker_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
|
2005-08-22 03:00:06 +00:00
|
|
|
#define NS_LINEBREAKER_NEED_MORE_TEXT -1
|
|
|
|
|
2012-05-07 19:18:23 +00:00
|
|
|
// {0x4b0b9e04-6ffb-4647-aa5f-2fa2ebd883e8}
|
1999-02-09 16:01:48 +00:00
|
|
|
#define NS_ILINEBREAKER_IID \
|
2012-05-07 19:18:23 +00:00
|
|
|
{0x4b0b9e04, 0x6ffb, 0x4647, \
|
|
|
|
{0xaa, 0x5f, 0x2f, 0xa2, 0xeb, 0xd8, 0x83, 0xe8}}
|
1999-02-09 16:01:48 +00:00
|
|
|
|
|
|
|
class nsILineBreaker : public nsISupports
|
|
|
|
{
|
1999-02-16 18:11:14 +00:00
|
|
|
public:
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINEBREAKER_IID)
|
2012-05-07 19:18:23 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
kWordBreak_Normal = 0, // default
|
|
|
|
kWordBreak_BreakAll = 1, // break all
|
|
|
|
kWordBreak_KeepAll = 2 // always keep
|
|
|
|
};
|
|
|
|
|
2014-01-04 15:02:17 +00:00
|
|
|
virtual int32_t Next( const char16_t* aText, uint32_t aLen,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aPos) = 0;
|
1999-02-23 16:20:39 +00:00
|
|
|
|
2014-01-04 15:02:17 +00:00
|
|
|
virtual int32_t Prev( const char16_t* aText, uint32_t aLen,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aPos) = 0;
|
1999-02-16 18:11:14 +00:00
|
|
|
|
2013-02-27 07:04:38 +00:00
|
|
|
// Call this on a word with whitespace at either end. We will apply JISx4051
|
2007-01-17 02:14:10 +00:00
|
|
|
// rules to find breaks inside the word. aBreakBefore is set to the break-
|
|
|
|
// before status of each character; aBreakBefore[0] will always be false
|
|
|
|
// because we never return a break before the first character.
|
|
|
|
// aLength is the length of the aText array and also the length of the aBreakBefore
|
|
|
|
// output array.
|
2014-01-04 15:02:17 +00:00
|
|
|
virtual void GetJISx4051Breaks(const char16_t* aText, uint32_t aLength,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aWordBreak,
|
|
|
|
uint8_t* aBreakBefore) = 0;
|
|
|
|
virtual void GetJISx4051Breaks(const uint8_t* aText, uint32_t aLength,
|
|
|
|
uint8_t aWordBreak,
|
|
|
|
uint8_t* aBreakBefore) = 0;
|
1999-02-09 16:01:48 +00:00
|
|
|
};
|
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsILineBreaker, NS_ILINEBREAKER_IID)
|
1999-02-09 16:01:48 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static inline bool
|
2014-01-04 15:02:17 +00:00
|
|
|
NS_IsSpace(char16_t u)
|
2007-09-19 06:34:24 +00:00
|
|
|
{
|
|
|
|
return u == 0x0020 || // SPACE
|
|
|
|
u == 0x0009 || // CHARACTER TABULATION
|
|
|
|
u == 0x000D || // CARRIAGE RETURN
|
2012-12-12 07:00:23 +00:00
|
|
|
u == 0x1680 || // OGHAM SPACE MARK
|
2007-09-19 06:34:24 +00:00
|
|
|
(0x2000 <= u && u <= 0x2006) || // EN QUAD, EM QUAD, EN SPACE,
|
|
|
|
// EM SPACE, THREE-PER-EM SPACE,
|
|
|
|
// FOUR-PER-SPACE, SIX-PER-EM SPACE,
|
2012-12-12 07:00:23 +00:00
|
|
|
(0x2008 <= u && u <= 0x200B) || // PUNCTUATION SPACE, THIN SPACE,
|
2007-09-19 06:34:24 +00:00
|
|
|
// HAIR SPACE, ZERO WIDTH SPACE
|
2012-12-12 07:00:23 +00:00
|
|
|
u == 0x205F; // MEDIUM MATHEMATICAL SPACE
|
2007-09-19 06:34:24 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static inline bool
|
2014-01-04 15:02:17 +00:00
|
|
|
NS_NeedsPlatformNativeHandling(char16_t aChar)
|
2007-09-30 20:30:31 +00:00
|
|
|
{
|
2013-03-04 10:17:03 +00:00
|
|
|
return (0x0e01 <= aChar && aChar <= 0x0fff) || // Thai, Lao, Tibetan
|
|
|
|
(0x1780 <= aChar && aChar <= 0x17ff); // Khmer
|
2007-09-30 20:30:31 +00:00
|
|
|
}
|
|
|
|
|
1999-02-09 16:01:48 +00:00
|
|
|
#endif /* nsILineBreaker_h__ */
|