gfx/thebes/gfxScriptItemizer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/thebes/gfxScriptItemizer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,100 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * This file is based on usc_impl.c from ICU 4.2.0.1, slightly adapted
    1.11 + * for use within Mozilla Gecko, separate from a standard ICU build.
    1.12 + *
    1.13 + * The original ICU license of the code follows:
    1.14 + *
    1.15 + * ICU License - ICU 1.8.1 and later
    1.16 + *
    1.17 + * COPYRIGHT AND PERMISSION NOTICE
    1.18 + * 
    1.19 + * Copyright (c) 1995-2009 International Business Machines Corporation and
    1.20 + * others
    1.21 + *
    1.22 + * All rights reserved.
    1.23 + *
    1.24 + * Permission is hereby granted, free of charge, to any person obtaining a
    1.25 + * copy of this software and associated documentation files (the "Software"),
    1.26 + * to deal in the Software without restriction, including without limitation
    1.27 + * the rights to use, copy, modify, merge, publish, distribute, and/or sell
    1.28 + * copies of the Software, and to permit persons to whom the Software is
    1.29 + * furnished to do so, provided that the above copyright notice(s) and this
    1.30 + * permission notice appear in all copies of the Software and that both the
    1.31 + * above copyright notice(s) and this permission notice appear in supporting
    1.32 + * documentation.
    1.33 + *
    1.34 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.35 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.36 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
    1.37 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
    1.38 + * BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
    1.39 + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
    1.40 + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
    1.41 + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
    1.42 + * SOFTWARE.
    1.43 + *
    1.44 + * Except as contained in this notice, the name of a copyright holder shall
    1.45 + * not be used in advertising or otherwise to promote the sale, use or other
    1.46 + * dealings in this Software without prior written authorization of the
    1.47 + * copyright holder.
    1.48 + *
    1.49 + * All trademarks and registered trademarks mentioned herein are the property
    1.50 + * of their respective owners. 
    1.51 + */
    1.52 +
    1.53 +#ifndef GFX_SCRIPTITEMIZER_H
    1.54 +#define GFX_SCRIPTITEMIZER_H
    1.55 +
    1.56 +#include <stdint.h>
    1.57 +#include "nsUnicodeScriptCodes.h"
    1.58 +
    1.59 +#define PAREN_STACK_DEPTH 32
    1.60 +
    1.61 +class gfxScriptItemizer
    1.62 +{
    1.63 +public:
    1.64 +    gfxScriptItemizer(const char16_t *src, uint32_t length);
    1.65 +
    1.66 +    void SetText(const char16_t *src, uint32_t length);
    1.67 +
    1.68 +    bool Next(uint32_t& aRunStart, uint32_t& aRunLimit,
    1.69 +              int32_t& aRunScript);
    1.70 +
    1.71 +protected:
    1.72 +    void reset() {
    1.73 +        scriptStart = 0;
    1.74 +        scriptLimit = 0;
    1.75 +        scriptCode  = MOZ_SCRIPT_INVALID;
    1.76 +        parenSP     = -1;
    1.77 +        pushCount   =  0;
    1.78 +        fixupCount  =  0;
    1.79 +    }
    1.80 +
    1.81 +    void push(uint32_t endPairChar, int32_t scriptCode);
    1.82 +    void pop();
    1.83 +    void fixup(int32_t scriptCode);
    1.84 +
    1.85 +    struct ParenStackEntry {
    1.86 +        uint32_t endPairChar;
    1.87 +        int32_t  scriptCode;
    1.88 +    };
    1.89 +
    1.90 +    const char16_t *textPtr;
    1.91 +    uint32_t textLength;
    1.92 +
    1.93 +    uint32_t scriptStart;
    1.94 +    uint32_t scriptLimit;
    1.95 +    int32_t  scriptCode;
    1.96 +
    1.97 +    struct ParenStackEntry parenStack[PAREN_STACK_DEPTH];
    1.98 +    uint32_t parenSP;
    1.99 +    uint32_t pushCount;
   1.100 +    uint32_t fixupCount;
   1.101 +};
   1.102 +
   1.103 +#endif /* GFX_SCRIPTITEMIZER_H */

mercurial