/src/mozilla-central/gfx/thebes/gfxScriptItemizer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
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 | | |
6 | | /* |
7 | | * This file is based on usc_impl.c from ICU 4.2.0.1, slightly adapted |
8 | | * for use within Mozilla Gecko, separate from a standard ICU build. |
9 | | * |
10 | | * The original ICU license of the code follows: |
11 | | * |
12 | | * ICU License - ICU 1.8.1 and later |
13 | | * |
14 | | * COPYRIGHT AND PERMISSION NOTICE |
15 | | * |
16 | | * Copyright (c) 1995-2009 International Business Machines Corporation and |
17 | | * others |
18 | | * |
19 | | * All rights reserved. |
20 | | * |
21 | | * Permission is hereby granted, free of charge, to any person obtaining a |
22 | | * copy of this software and associated documentation files (the "Software"), |
23 | | * to deal in the Software without restriction, including without limitation |
24 | | * the rights to use, copy, modify, merge, publish, distribute, and/or sell |
25 | | * copies of the Software, and to permit persons to whom the Software is |
26 | | * furnished to do so, provided that the above copyright notice(s) and this |
27 | | * permission notice appear in all copies of the Software and that both the |
28 | | * above copyright notice(s) and this permission notice appear in supporting |
29 | | * documentation. |
30 | | * |
31 | | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
32 | | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
33 | | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
34 | | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE |
35 | | * BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, |
36 | | * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
37 | | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
38 | | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
39 | | * SOFTWARE. |
40 | | * |
41 | | * Except as contained in this notice, the name of a copyright holder shall |
42 | | * not be used in advertising or otherwise to promote the sale, use or other |
43 | | * dealings in this Software without prior written authorization of the |
44 | | * copyright holder. |
45 | | * |
46 | | * All trademarks and registered trademarks mentioned herein are the property |
47 | | * of their respective owners. |
48 | | */ |
49 | | |
50 | | #ifndef GFX_SCRIPTITEMIZER_H |
51 | | #define GFX_SCRIPTITEMIZER_H |
52 | | |
53 | | #include <stdint.h> |
54 | | #include "nsUnicodeScriptCodes.h" |
55 | | |
56 | 0 | #define PAREN_STACK_DEPTH 32 |
57 | | |
58 | | class gfxScriptItemizer |
59 | | { |
60 | | public: |
61 | | typedef mozilla::unicode::Script Script; |
62 | | |
63 | | gfxScriptItemizer(const char16_t *src, uint32_t length); |
64 | | |
65 | | void SetText(const char16_t *src, uint32_t length); |
66 | | |
67 | | bool Next(uint32_t& aRunStart, uint32_t& aRunLimit, |
68 | | Script& aRunScript); |
69 | | |
70 | | protected: |
71 | 0 | void reset() { |
72 | 0 | scriptStart = 0; |
73 | 0 | scriptLimit = 0; |
74 | 0 | scriptCode = Script::INVALID; |
75 | 0 | parenSP = -1; |
76 | 0 | pushCount = 0; |
77 | 0 | fixupCount = 0; |
78 | 0 | } |
79 | | |
80 | | void push(uint32_t endPairChar, Script newScriptCode); |
81 | | void pop(); |
82 | | void fixup(Script newScriptCode); |
83 | | |
84 | | struct ParenStackEntry { |
85 | | uint32_t endPairChar; |
86 | | Script scriptCode; |
87 | | }; |
88 | | |
89 | | const char16_t *textPtr; |
90 | | uint32_t textLength; |
91 | | |
92 | | uint32_t scriptStart; |
93 | | uint32_t scriptLimit; |
94 | | Script scriptCode; |
95 | | |
96 | | struct ParenStackEntry parenStack[PAREN_STACK_DEPTH]; |
97 | | uint32_t parenSP; |
98 | | uint32_t pushCount; |
99 | | uint32_t fixupCount; |
100 | | }; |
101 | | |
102 | | #endif /* GFX_SCRIPTITEMIZER_H */ |