intl/lwbrk/public/nsILineBreaker.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial