1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Corporation code.
16 : *
17 : * The Initial Developer of the Original Code is Mozilla Corporation.
18 : * Portions created by the Initial Developer are Copyright (C) 2010
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Jonathan Kew <jfkthame@gmail.com>
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either the GNU General Public License Version 2 or later (the "GPL"), or
26 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : *
37 : * This file is based on usc_impl.c from ICU 4.2.0.1, slightly adapted
38 : * for use within Mozilla Gecko, separate from a standard ICU build.
39 : *
40 : * The original ICU license of the code follows:
41 : *
42 : * ICU License - ICU 1.8.1 and later
43 : *
44 : * COPYRIGHT AND PERMISSION NOTICE
45 : *
46 : * Copyright (c) 1995-2009 International Business Machines Corporation and
47 : * others
48 : *
49 : * All rights reserved.
50 : *
51 : * Permission is hereby granted, free of charge, to any person obtaining a
52 : * copy of this software and associated documentation files (the "Software"),
53 : * to deal in the Software without restriction, including without limitation
54 : * the rights to use, copy, modify, merge, publish, distribute, and/or sell
55 : * copies of the Software, and to permit persons to whom the Software is
56 : * furnished to do so, provided that the above copyright notice(s) and this
57 : * permission notice appear in all copies of the Software and that both the
58 : * above copyright notice(s) and this permission notice appear in supporting
59 : * documentation.
60 : *
61 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62 : * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
64 : * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
65 : * BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
66 : * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
67 : * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
68 : * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
69 : * SOFTWARE.
70 : *
71 : * Except as contained in this notice, the name of a copyright holder shall
72 : * not be used in advertising or otherwise to promote the sale, use or other
73 : * dealings in this Software without prior written authorization of the
74 : * copyright holder.
75 : *
76 : * All trademarks and registered trademarks mentioned herein are the property
77 : * of their respective owners.
78 : */
79 :
80 : #ifndef GFX_SCRIPTITEMIZER_H
81 : #define GFX_SCRIPTITEMIZER_H
82 :
83 : #include "mozilla/StandardInteger.h"
84 : #include "prtypes.h"
85 : #include "harfbuzz/hb.h"
86 : #include "nsUnicodeScriptCodes.h"
87 :
88 : #define PAREN_STACK_DEPTH 32
89 :
90 : class gfxScriptItemizer
91 : {
92 : public:
93 : gfxScriptItemizer(const PRUnichar *src, PRUint32 length);
94 :
95 : void SetText(const PRUnichar *src, PRUint32 length);
96 :
97 : bool Next(PRUint32& aRunStart, PRUint32& aRunLimit,
98 : PRInt32& aRunScript);
99 :
100 : protected:
101 0 : void reset() {
102 0 : scriptStart = 0;
103 0 : scriptLimit = 0;
104 0 : scriptCode = MOZ_SCRIPT_INVALID;
105 0 : parenSP = -1;
106 0 : pushCount = 0;
107 0 : fixupCount = 0;
108 0 : }
109 :
110 : void push(PRInt32 pairIndex, PRInt32 scriptCode);
111 : void pop();
112 : void fixup(PRInt32 scriptCode);
113 :
114 : struct ParenStackEntry {
115 : PRInt32 pairIndex;
116 : PRInt32 scriptCode;
117 : };
118 :
119 : const PRUnichar *textPtr;
120 : PRUint32 textLength;
121 :
122 : PRUint32 scriptStart;
123 : PRUint32 scriptLimit;
124 : PRInt32 scriptCode;
125 :
126 : struct ParenStackEntry parenStack[PAREN_STACK_DEPTH];
127 : PRUint32 parenSP;
128 : PRUint32 pushCount;
129 : PRUint32 fixupCount;
130 : };
131 :
132 : #endif /* GFX_SCRIPTITEMIZER_H */
|