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 | /* |
michael@0 | 3 | * Copyright 2011 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | #include "SkMovie.h" |
michael@0 | 9 | #include "SkCanvas.h" |
michael@0 | 10 | #include "SkPaint.h" |
michael@0 | 11 | |
michael@0 | 12 | // We should never see this in normal operation since our time values are |
michael@0 | 13 | // 0-based. So we use it as a sentinal. |
michael@0 | 14 | #define UNINITIALIZED_MSEC ((SkMSec)-1) |
michael@0 | 15 | |
michael@0 | 16 | SkMovie::SkMovie() |
michael@0 | 17 | { |
michael@0 | 18 | fInfo.fDuration = UNINITIALIZED_MSEC; // uninitialized |
michael@0 | 19 | fCurrTime = UNINITIALIZED_MSEC; // uninitialized |
michael@0 | 20 | fNeedBitmap = true; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | void SkMovie::ensureInfo() |
michael@0 | 24 | { |
michael@0 | 25 | if (fInfo.fDuration == UNINITIALIZED_MSEC && !this->onGetInfo(&fInfo)) |
michael@0 | 26 | memset(&fInfo, 0, sizeof(fInfo)); // failure |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | SkMSec SkMovie::duration() |
michael@0 | 30 | { |
michael@0 | 31 | this->ensureInfo(); |
michael@0 | 32 | return fInfo.fDuration; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | int SkMovie::width() |
michael@0 | 36 | { |
michael@0 | 37 | this->ensureInfo(); |
michael@0 | 38 | return fInfo.fWidth; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | int SkMovie::height() |
michael@0 | 42 | { |
michael@0 | 43 | this->ensureInfo(); |
michael@0 | 44 | return fInfo.fHeight; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | int SkMovie::isOpaque() |
michael@0 | 48 | { |
michael@0 | 49 | this->ensureInfo(); |
michael@0 | 50 | return fInfo.fIsOpaque; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | bool SkMovie::setTime(SkMSec time) |
michael@0 | 54 | { |
michael@0 | 55 | SkMSec dur = this->duration(); |
michael@0 | 56 | if (time > dur) |
michael@0 | 57 | time = dur; |
michael@0 | 58 | |
michael@0 | 59 | bool changed = false; |
michael@0 | 60 | if (time != fCurrTime) |
michael@0 | 61 | { |
michael@0 | 62 | fCurrTime = time; |
michael@0 | 63 | changed = this->onSetTime(time); |
michael@0 | 64 | fNeedBitmap |= changed; |
michael@0 | 65 | } |
michael@0 | 66 | return changed; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | const SkBitmap& SkMovie::bitmap() |
michael@0 | 70 | { |
michael@0 | 71 | if (fCurrTime == UNINITIALIZED_MSEC) // uninitialized |
michael@0 | 72 | this->setTime(0); |
michael@0 | 73 | |
michael@0 | 74 | if (fNeedBitmap) |
michael@0 | 75 | { |
michael@0 | 76 | if (!this->onGetBitmap(&fBitmap)) // failure |
michael@0 | 77 | fBitmap.reset(); |
michael@0 | 78 | fNeedBitmap = false; |
michael@0 | 79 | } |
michael@0 | 80 | return fBitmap; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | //////////////////////////////////////////////////////////////////// |
michael@0 | 84 | |
michael@0 | 85 | #include "SkStream.h" |
michael@0 | 86 | |
michael@0 | 87 | SkMovie* SkMovie::DecodeMemory(const void* data, size_t length) { |
michael@0 | 88 | SkMemoryStream stream(data, length, false); |
michael@0 | 89 | return SkMovie::DecodeStream(&stream); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | SkMovie* SkMovie::DecodeFile(const char path[]) { |
michael@0 | 93 | SkAutoTUnref<SkStreamRewindable> stream(SkStream::NewFromFile(path)); |
michael@0 | 94 | return stream.get() ? SkMovie::DecodeStream(stream) : NULL; |
michael@0 | 95 | } |