Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2010 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #include "GrTextContext.h" |
michael@0 | 9 | #include "GrContext.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "SkAutoKern.h" |
michael@0 | 12 | #include "SkGlyphCache.h" |
michael@0 | 13 | #include "SkGr.h" |
michael@0 | 14 | |
michael@0 | 15 | GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& properties) : |
michael@0 | 16 | fContext(context), fDeviceProperties(properties), fDrawTarget(NULL) { |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | void GrTextContext::init(const GrPaint& grPaint, const SkPaint& skPaint) { |
michael@0 | 20 | const GrClipData* clipData = fContext->getClip(); |
michael@0 | 21 | |
michael@0 | 22 | SkRect devConservativeBound; |
michael@0 | 23 | clipData->fClipStack->getConservativeBounds( |
michael@0 | 24 | -clipData->fOrigin.fX, |
michael@0 | 25 | -clipData->fOrigin.fY, |
michael@0 | 26 | fContext->getRenderTarget()->width(), |
michael@0 | 27 | fContext->getRenderTarget()->height(), |
michael@0 | 28 | &devConservativeBound); |
michael@0 | 29 | |
michael@0 | 30 | devConservativeBound.roundOut(&fClipRect); |
michael@0 | 31 | |
michael@0 | 32 | fDrawTarget = fContext->getTextTarget(); |
michael@0 | 33 | |
michael@0 | 34 | fPaint = grPaint; |
michael@0 | 35 | fSkPaint = skPaint; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | //*** change to output positions? |
michael@0 | 39 | void GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
michael@0 | 40 | const char text[], size_t byteLength, SkVector* stopVector) { |
michael@0 | 41 | SkFixed x = 0, y = 0; |
michael@0 | 42 | const char* stop = text + byteLength; |
michael@0 | 43 | |
michael@0 | 44 | SkAutoKern autokern; |
michael@0 | 45 | |
michael@0 | 46 | while (text < stop) { |
michael@0 | 47 | // don't need x, y here, since all subpixel variants will have the |
michael@0 | 48 | // same advance |
michael@0 | 49 | const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
michael@0 | 50 | |
michael@0 | 51 | x += autokern.adjust(glyph) + glyph.fAdvanceX; |
michael@0 | 52 | y += glyph.fAdvanceY; |
michael@0 | 53 | } |
michael@0 | 54 | stopVector->set(SkFixedToScalar(x), SkFixedToScalar(y)); |
michael@0 | 55 | |
michael@0 | 56 | SkASSERT(text == stop); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | static void GlyphCacheAuxProc(void* data) { |
michael@0 | 60 | GrFontScaler* scaler = (GrFontScaler*)data; |
michael@0 | 61 | SkSafeUnref(scaler); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) { |
michael@0 | 65 | void* auxData; |
michael@0 | 66 | GrFontScaler* scaler = NULL; |
michael@0 | 67 | |
michael@0 | 68 | if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { |
michael@0 | 69 | scaler = (GrFontScaler*)auxData; |
michael@0 | 70 | } |
michael@0 | 71 | if (NULL == scaler) { |
michael@0 | 72 | scaler = SkNEW_ARGS(SkGrFontScaler, (cache)); |
michael@0 | 73 | cache->setAuxProc(GlyphCacheAuxProc, scaler); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | return scaler; |
michael@0 | 77 | } |