no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / gfx / thebes / gfxScriptItemizer.h
blob6deb37e19cbafa0a7d19a19b30c8cbb39776f6e7
1 /* -*- Mode: C++; tab-width: 20; 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/. */
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.
10 * The original ICU license of the code follows:
12 * ICU License - ICU 1.8.1 and later
14 * COPYRIGHT AND PERMISSION NOTICE
16 * Copyright (c) 1995-2009 International Business Machines Corporation and
17 * others
19 * All rights reserved.
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.
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.
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.
46 * All trademarks and registered trademarks mentioned herein are the property
47 * of their respective owners.
50 #ifndef GFX_SCRIPTITEMIZER_H
51 #define GFX_SCRIPTITEMIZER_H
53 #include <stdint.h>
54 #include "mozilla/intl/UnicodeScriptCodes.h"
56 #define PAREN_STACK_DEPTH 32
58 class gfxScriptItemizer {
59 public:
60 typedef mozilla::intl::Script Script;
62 gfxScriptItemizer(const char16_t* src, uint32_t length);
64 void SetText(const char16_t* src, uint32_t length);
66 bool Next(uint32_t& aRunStart, uint32_t& aRunLimit, Script& aRunScript);
68 protected:
69 void reset() {
70 scriptStart = 0;
71 scriptLimit = 0;
72 scriptCode = Script::INVALID;
73 parenSP = -1;
74 pushCount = 0;
75 fixupCount = 0;
78 void push(uint32_t endPairChar, Script newScriptCode);
79 void pop();
80 void fixup(Script newScriptCode);
82 struct ParenStackEntry {
83 uint32_t endPairChar;
84 Script scriptCode;
87 const char16_t* textPtr;
88 uint32_t textLength;
90 uint32_t scriptStart;
91 uint32_t scriptLimit;
92 Script scriptCode;
94 struct ParenStackEntry parenStack[PAREN_STACK_DEPTH];
95 uint32_t parenSP;
96 uint32_t pushCount;
97 uint32_t fixupCount;
100 #endif /* GFX_SCRIPTITEMIZER_H */