]> git.draconx.ca Git - gentoo-fixes.git/blob - www-client/firefox/files/firefox-52.9.0-fix-thebes-templates.patch
app-emulation/wine-vanilla-4.0.4: Adapt mpg123 dependency.
[gentoo-fixes.git] / www-client / firefox / files / firefox-52.9.0-fix-thebes-templates.patch
1 diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp
2 index d0b747fff..9ec629285 100644
3 --- a/gfx/thebes/gfxFont.cpp
4 +++ b/gfx/thebes/gfxFont.cpp
5 @@ -2535,85 +2535,6 @@ IsBoundarySpace(char16_t aChar, char16_t aNextChar)
6      return 0;
7  }
8  
9 -#ifdef __GNUC__
10 -#define GFX_MAYBE_UNUSED __attribute__((unused))
11 -#else
12 -#define GFX_MAYBE_UNUSED
13 -#endif
14 -
15 -template<typename T>
16 -gfxShapedWord*
17 -gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
18 -                       const T    *aText,
19 -                       uint32_t    aLength,
20 -                       uint32_t    aHash,
21 -                       Script      aRunScript,
22 -                       bool        aVertical,
23 -                       int32_t     aAppUnitsPerDevUnit,
24 -                       uint32_t    aFlags,
25 -                       gfxTextPerfMetrics *aTextPerf GFX_MAYBE_UNUSED)
26 -{
27 -    // if the cache is getting too big, flush it and start over
28 -    uint32_t wordCacheMaxEntries =
29 -        gfxPlatform::GetPlatform()->WordCacheMaxEntries();
30 -    if (mWordCache->Count() > wordCacheMaxEntries) {
31 -        NS_WARNING("flushing shaped-word cache");
32 -        ClearCachedWords();
33 -    }
34 -
35 -    // if there's a cached entry for this word, just return it
36 -    CacheHashKey key(aText, aLength, aHash,
37 -                     aRunScript,
38 -                     aAppUnitsPerDevUnit,
39 -                     aFlags);
40 -
41 -    CacheHashEntry *entry = mWordCache->PutEntry(key);
42 -    if (!entry) {
43 -        NS_WARNING("failed to create word cache entry - expect missing text");
44 -        return nullptr;
45 -    }
46 -    gfxShapedWord* sw = entry->mShapedWord.get();
47 -
48 -    bool isContent = !mStyle.systemFont;
49 -
50 -    if (sw) {
51 -        sw->ResetAge();
52 -        Telemetry::Accumulate((isContent ? Telemetry::WORD_CACHE_HITS_CONTENT :
53 -                                   Telemetry::WORD_CACHE_HITS_CHROME),
54 -                              aLength);
55 -#ifndef RELEASE_OR_BETA
56 -        if (aTextPerf) {
57 -            aTextPerf->current.wordCacheHit++;
58 -        }
59 -#endif
60 -        return sw;
61 -    }
62 -
63 -    Telemetry::Accumulate((isContent ? Telemetry::WORD_CACHE_MISSES_CONTENT :
64 -                               Telemetry::WORD_CACHE_MISSES_CHROME),
65 -                          aLength);
66 -#ifndef RELEASE_OR_BETA
67 -    if (aTextPerf) {
68 -        aTextPerf->current.wordCacheMiss++;
69 -    }
70 -#endif
71 -
72 -    sw = gfxShapedWord::Create(aText, aLength, aRunScript, aAppUnitsPerDevUnit,
73 -                               aFlags);
74 -    entry->mShapedWord.reset(sw);
75 -    if (!sw) {
76 -        NS_WARNING("failed to create gfxShapedWord - expect missing text");
77 -        return nullptr;
78 -    }
79 -
80 -    DebugOnly<bool> ok =
81 -        ShapeText(aDrawTarget, aText, 0, aLength, aRunScript, aVertical, sw);
82 -
83 -    NS_WARNING_ASSERTION(ok, "failed to shape word - expect garbled text");
84 -
85 -    return sw;
86 -}
87 -
88  bool
89  gfxFont::CacheHashEntry::KeyEquals(const KeyTypePointer aKey) const
90  {
91 diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h
92 index ead0b7666..c38d06675 100644
93 --- a/gfx/thebes/gfxFont.h
94 +++ b/gfx/thebes/gfxFont.h
95 @@ -2220,4 +2220,88 @@ struct EmphasisMarkDrawParams {
96      bool isVertical;
97  };
98  
99 +#include "mozilla/Telemetry.h"
100 +#include "mozilla/DebugOnly.h"
101 +
102 +#ifdef __GNUC__
103 +#define GFX_MAYBE_UNUSED __attribute__((unused))
104 +#else
105 +#define GFX_MAYBE_UNUSED
106 +#endif
107 +
108 +template<typename T>
109 +gfxShapedWord*
110 +gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
111 +                       const T    *aText,
112 +                       uint32_t    aLength,
113 +                       uint32_t    aHash,
114 +                       Script      aRunScript,
115 +                       bool        aVertical,
116 +                       int32_t     aAppUnitsPerDevUnit,
117 +                       uint32_t    aFlags,
118 +                       gfxTextPerfMetrics *aTextPerf GFX_MAYBE_UNUSED)
119 +{
120 +    using namespace mozilla;
121 +
122 +    // if the cache is getting too big, flush it and start over
123 +    uint32_t wordCacheMaxEntries =
124 +        gfxPlatform::GetPlatform()->WordCacheMaxEntries();
125 +    if (mWordCache->Count() > wordCacheMaxEntries) {
126 +        NS_WARNING("flushing shaped-word cache");
127 +        ClearCachedWords();
128 +    }
129 +
130 +    // if there's a cached entry for this word, just return it
131 +    CacheHashKey key(aText, aLength, aHash,
132 +                     aRunScript,
133 +                     aAppUnitsPerDevUnit,
134 +                     aFlags);
135 +
136 +    CacheHashEntry *entry = mWordCache->PutEntry(key);
137 +    if (!entry) {
138 +        NS_WARNING("failed to create word cache entry - expect missing text");
139 +        return nullptr;
140 +    }
141 +    gfxShapedWord* sw = entry->mShapedWord.get();
142 +
143 +    bool isContent = !mStyle.systemFont;
144 +
145 +    if (sw) {
146 +        sw->ResetAge();
147 +        Telemetry::Accumulate((isContent ? Telemetry::WORD_CACHE_HITS_CONTENT :
148 +                                   Telemetry::WORD_CACHE_HITS_CHROME),
149 +                              aLength);
150 +#ifndef RELEASE_OR_BETA
151 +        if (aTextPerf) {
152 +            aTextPerf->current.wordCacheHit++;
153 +        }
154 +#endif
155 +        return sw;
156 +    }
157 +
158 +    Telemetry::Accumulate((isContent ? Telemetry::WORD_CACHE_MISSES_CONTENT :
159 +                               Telemetry::WORD_CACHE_MISSES_CHROME),
160 +                          aLength);
161 +#ifndef RELEASE_OR_BETA
162 +    if (aTextPerf) {
163 +        aTextPerf->current.wordCacheMiss++;
164 +    }
165 +#endif
166 +
167 +    sw = gfxShapedWord::Create(aText, aLength, aRunScript, aAppUnitsPerDevUnit,
168 +                               aFlags);
169 +    entry->mShapedWord.reset(sw);
170 +    if (!sw) {
171 +        NS_WARNING("failed to create gfxShapedWord - expect missing text");
172 +        return nullptr;
173 +    }
174 +
175 +    DebugOnly<bool> ok =
176 +        ShapeText(aDrawTarget, aText, 0, aLength, aRunScript, aVertical, sw);
177 +
178 +    NS_WARNING_ASSERTION(ok, "failed to shape word - expect garbled text");
179 +
180 +    return sw;
181 +}
182 +
183  #endif