gfx/thebes/gfxScriptItemizer.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial