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

     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/. */
     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  */
    50 #ifndef GFX_SCRIPTITEMIZER_H
    51 #define GFX_SCRIPTITEMIZER_H
    53 #include <stdint.h>
    54 #include "nsUnicodeScriptCodes.h"
    56 #define PAREN_STACK_DEPTH 32
    58 class gfxScriptItemizer
    59 {
    60 public:
    61     gfxScriptItemizer(const char16_t *src, uint32_t length);
    63     void SetText(const char16_t *src, uint32_t length);
    65     bool Next(uint32_t& aRunStart, uint32_t& aRunLimit,
    66               int32_t& aRunScript);
    68 protected:
    69     void reset() {
    70         scriptStart = 0;
    71         scriptLimit = 0;
    72         scriptCode  = MOZ_SCRIPT_INVALID;
    73         parenSP     = -1;
    74         pushCount   =  0;
    75         fixupCount  =  0;
    76     }
    78     void push(uint32_t endPairChar, int32_t scriptCode);
    79     void pop();
    80     void fixup(int32_t scriptCode);
    82     struct ParenStackEntry {
    83         uint32_t endPairChar;
    84         int32_t  scriptCode;
    85     };
    87     const char16_t *textPtr;
    88     uint32_t textLength;
    90     uint32_t scriptStart;
    91     uint32_t scriptLimit;
    92     int32_t  scriptCode;
    94     struct ParenStackEntry parenStack[PAREN_STACK_DEPTH];
    95     uint32_t parenSP;
    96     uint32_t pushCount;
    97     uint32_t fixupCount;
    98 };
   100 #endif /* GFX_SCRIPTITEMIZER_H */

mercurial