michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * This file is based on usc_impl.c from ICU 4.2.0.1, slightly adapted michael@0: * for use within Mozilla Gecko, separate from a standard ICU build. michael@0: * michael@0: * The original ICU license of the code follows: michael@0: * michael@0: * ICU License - ICU 1.8.1 and later michael@0: * michael@0: * COPYRIGHT AND PERMISSION NOTICE michael@0: * michael@0: * Copyright (c) 1995-2009 International Business Machines Corporation and michael@0: * others michael@0: * michael@0: * All rights reserved. michael@0: * michael@0: * Permission is hereby granted, free of charge, to any person obtaining a michael@0: * copy of this software and associated documentation files (the "Software"), michael@0: * to deal in the Software without restriction, including without limitation michael@0: * the rights to use, copy, modify, merge, publish, distribute, and/or sell michael@0: * copies of the Software, and to permit persons to whom the Software is michael@0: * furnished to do so, provided that the above copyright notice(s) and this michael@0: * permission notice appear in all copies of the Software and that both the michael@0: * above copyright notice(s) and this permission notice appear in supporting michael@0: * documentation. michael@0: * michael@0: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. michael@0: * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE michael@0: * BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, michael@0: * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, michael@0: * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, michael@0: * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS michael@0: * SOFTWARE. michael@0: * michael@0: * Except as contained in this notice, the name of a copyright holder shall michael@0: * not be used in advertising or otherwise to promote the sale, use or other michael@0: * dealings in this Software without prior written authorization of the michael@0: * copyright holder. michael@0: * michael@0: * All trademarks and registered trademarks mentioned herein are the property michael@0: * of their respective owners. michael@0: */ michael@0: michael@0: #ifndef GFX_SCRIPTITEMIZER_H michael@0: #define GFX_SCRIPTITEMIZER_H michael@0: michael@0: #include michael@0: #include "nsUnicodeScriptCodes.h" michael@0: michael@0: #define PAREN_STACK_DEPTH 32 michael@0: michael@0: class gfxScriptItemizer michael@0: { michael@0: public: michael@0: gfxScriptItemizer(const char16_t *src, uint32_t length); michael@0: michael@0: void SetText(const char16_t *src, uint32_t length); michael@0: michael@0: bool Next(uint32_t& aRunStart, uint32_t& aRunLimit, michael@0: int32_t& aRunScript); michael@0: michael@0: protected: michael@0: void reset() { michael@0: scriptStart = 0; michael@0: scriptLimit = 0; michael@0: scriptCode = MOZ_SCRIPT_INVALID; michael@0: parenSP = -1; michael@0: pushCount = 0; michael@0: fixupCount = 0; michael@0: } michael@0: michael@0: void push(uint32_t endPairChar, int32_t scriptCode); michael@0: void pop(); michael@0: void fixup(int32_t scriptCode); michael@0: michael@0: struct ParenStackEntry { michael@0: uint32_t endPairChar; michael@0: int32_t scriptCode; michael@0: }; michael@0: michael@0: const char16_t *textPtr; michael@0: uint32_t textLength; michael@0: michael@0: uint32_t scriptStart; michael@0: uint32_t scriptLimit; michael@0: int32_t scriptCode; michael@0: michael@0: struct ParenStackEntry parenStack[PAREN_STACK_DEPTH]; michael@0: uint32_t parenSP; michael@0: uint32_t pushCount; michael@0: uint32_t fixupCount; michael@0: }; michael@0: michael@0: #endif /* GFX_SCRIPTITEMIZER_H */