Bug 574778 - Fix win widget's ConstrainPosition so that it supports full screen windo...
[mozilla-central.git] / gfx / thebes / gfxTextRunWordCache.h
blob3d2b8c6eab6e5dca9626a348dc0e393d1d67f90f
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Foundation code.
17 * The Initial Developer of the Original Code is Mozilla Foundation.
18 * Portions created by the Initial Developer are Copyright (C) 2006
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Vladimir Vukicevic <vladimir@pobox.com>
23 * Ehsan Akhgari <ehsan.akhgari@gmail.com>
24 * Jonathan Kew <jfkthame@gmail.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef GFX_TEXT_RUN_WORD_CACHE_H
41 #define GFX_TEXT_RUN_WORD_CACHE_H
43 #include "gfxFont.h"
45 /**
46 * Cache individual "words" (strings delimited by white-space or white-space-like
47 * characters that don't involve kerning or ligatures) in textruns.
49 class THEBES_API gfxTextRunWordCache {
50 public:
51 enum {
52 TEXT_IN_CACHE = 0x10000000,
54 /**
55 * nsTextFrameThebes sets these, but they're defined here rather than in
56 * nsTextFrameUtils.h because the cache also needs to check the _INCOMING flag
58 TEXT_TRAILING_ARABICCHAR = 0x20000000,
59 /**
60 * When set, the previous character for this textrun was an Arabic
61 * character. This is used for the context detection necessary for
62 * bidi.numeral implementation.
64 TEXT_INCOMING_ARABICCHAR = 0x40000000,
66 TEXT_UNUSED_FLAGS = 0x80000000
69 /**
70 * Create a textrun using cached words.
71 * Invalid characters (see gfxFontGroup::IsInvalidChar) will be automatically
72 * treated as invisible missing.
73 * @param aFlags the flag TEXT_IS_ASCII must be set by the caller,
74 * if applicable; TEXT_IN_CACHE is added if we have a reference to
75 * the textrun in the cache and RemoveTextRun must be called when the
76 * textrun dies.
78 static gfxTextRun *MakeTextRun(const PRUnichar *aText, PRUint32 aLength,
79 gfxFontGroup *aFontGroup,
80 const gfxFontGroup::Parameters *aParams,
81 PRUint32 aFlags);
82 /**
83 * Create a textrun using cached words.
84 * Invalid characters (see gfxFontGroup::IsInvalidChar) will be automatically
85 * treated as invisible missing.
86 * @param aFlags the flag TEXT_IS_ASCII must be set by the caller,
87 * if applicable; TEXT_IN_CACHE is added if we have a reference to
88 * the textrun in the cache and RemoveTextRun must be called when the
89 * textrun dies.
91 static gfxTextRun *MakeTextRun(const PRUint8 *aText, PRUint32 aLength,
92 gfxFontGroup *aFontGroup,
93 const gfxFontGroup::Parameters *aParams,
94 PRUint32 aFlags);
96 /**
97 * Remove a textrun from the cache. This must be called before aTextRun
98 * is deleted! The text in the textrun must still be valid.
100 static void RemoveTextRun(gfxTextRun *aTextRun);
103 * Flush the textrun cache. This must be called if a configuration
104 * change that would affect textruns is applied.
106 static void Flush();
108 protected:
109 friend class gfxPlatform;
111 static nsresult Init();
112 static void Shutdown();
115 #endif /* GFX_TEXT_RUN_WORD_CACHE_H */