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 "SkScrollBarView.h" |
michael@0 | 9 | #include "SkAnimator.h" |
michael@0 | 10 | #include "SkWidgetViews.h" |
michael@0 | 11 | #include "SkSystemEventTypes.h" |
michael@0 | 12 | #include "SkTime.h" |
michael@0 | 13 | |
michael@0 | 14 | //see SkProgressBarView.cpp |
michael@0 | 15 | //#include "SkWidgetViews.cpp" |
michael@0 | 16 | |
michael@0 | 17 | SkScrollBarView::SkScrollBarView() |
michael@0 | 18 | { |
michael@0 | 19 | fAnim.setHostEventSink(this); |
michael@0 | 20 | init_skin_anim(kScroll_SkinEnum, &fAnim); |
michael@0 | 21 | |
michael@0 | 22 | fTotalLength = 0; |
michael@0 | 23 | fStartPoint = 0; |
michael@0 | 24 | fShownLength = 0; |
michael@0 | 25 | |
michael@0 | 26 | this->adjust(); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | void SkScrollBarView::setStart(unsigned start) |
michael@0 | 30 | { |
michael@0 | 31 | if ((int)start < 0) |
michael@0 | 32 | start = 0; |
michael@0 | 33 | |
michael@0 | 34 | if (fStartPoint != start) |
michael@0 | 35 | { |
michael@0 | 36 | fStartPoint = start; |
michael@0 | 37 | this->adjust(); |
michael@0 | 38 | } |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | void SkScrollBarView::setShown(unsigned shown) |
michael@0 | 42 | { |
michael@0 | 43 | if ((int)shown < 0) |
michael@0 | 44 | shown = 0; |
michael@0 | 45 | |
michael@0 | 46 | if (fShownLength != shown) |
michael@0 | 47 | { |
michael@0 | 48 | fShownLength = shown; |
michael@0 | 49 | this->adjust(); |
michael@0 | 50 | } |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | void SkScrollBarView::setTotal(unsigned total) |
michael@0 | 54 | { |
michael@0 | 55 | if ((int)total < 0) |
michael@0 | 56 | total = 0; |
michael@0 | 57 | |
michael@0 | 58 | if (fTotalLength != total) |
michael@0 | 59 | { |
michael@0 | 60 | fTotalLength = total; |
michael@0 | 61 | this->adjust(); |
michael@0 | 62 | } |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | /* virtual */ void SkScrollBarView::onInflate(const SkDOM& dom, const SkDOM::Node* node) |
michael@0 | 66 | { |
michael@0 | 67 | this->INHERITED::onInflate(dom, node); |
michael@0 | 68 | |
michael@0 | 69 | int32_t value; |
michael@0 | 70 | if (dom.findS32(node, "total", &value)) |
michael@0 | 71 | this->setTotal(value); |
michael@0 | 72 | if (dom.findS32(node, "shown", &value)) |
michael@0 | 73 | this->setShown(value); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | /*virtual*/ void SkScrollBarView::onSizeChange() |
michael@0 | 77 | { |
michael@0 | 78 | this->INHERITED::onSizeChange(); |
michael@0 | 79 | SkEvent evt("user"); |
michael@0 | 80 | evt.setString("id", "setDim"); |
michael@0 | 81 | evt.setScalar("dimX", this->width()); |
michael@0 | 82 | evt.setScalar("dimY", this->height()); |
michael@0 | 83 | fAnim.doUserEvent(evt); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | /*virtual*/ void SkScrollBarView::onDraw(SkCanvas* canvas) |
michael@0 | 87 | { |
michael@0 | 88 | SkPaint paint; |
michael@0 | 89 | SkAnimator::DifferenceType diff = fAnim.draw(canvas, &paint, SkTime::GetMSecs()); |
michael@0 | 90 | |
michael@0 | 91 | if (diff == SkAnimator::kDifferent) |
michael@0 | 92 | this->inval(NULL); |
michael@0 | 93 | else if (diff == SkAnimator::kPartiallyDifferent) |
michael@0 | 94 | { |
michael@0 | 95 | SkRect bounds; |
michael@0 | 96 | fAnim.getInvalBounds(&bounds); |
michael@0 | 97 | this->inval(&bounds); |
michael@0 | 98 | } |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | /*virtual*/ bool SkScrollBarView::onEvent(const SkEvent& evt) |
michael@0 | 102 | { |
michael@0 | 103 | if (evt.isType(SK_EventType_Inval)) |
michael@0 | 104 | { |
michael@0 | 105 | this->inval(NULL); |
michael@0 | 106 | return true; |
michael@0 | 107 | } |
michael@0 | 108 | if (evt.isType("recommendDim")) |
michael@0 | 109 | { |
michael@0 | 110 | SkScalar width; |
michael@0 | 111 | |
michael@0 | 112 | if (evt.findScalar("x", &width)) |
michael@0 | 113 | this->setWidth(width); |
michael@0 | 114 | return true; |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | return this->INHERITED::onEvent(evt); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | void SkScrollBarView::adjust() |
michael@0 | 121 | { |
michael@0 | 122 | int total = fTotalLength; |
michael@0 | 123 | int start = fStartPoint; |
michael@0 | 124 | int shown = fShownLength; |
michael@0 | 125 | // int hideBar = 0; |
michael@0 | 126 | |
michael@0 | 127 | if (total <= 0 || shown <= 0 || shown >= total) // no bar to show |
michael@0 | 128 | { |
michael@0 | 129 | total = 1; // avoid divide-by-zero. should be done by skin/script |
michael@0 | 130 | // hideBar = 1; // signal we don't want a thumb |
michael@0 | 131 | } |
michael@0 | 132 | else |
michael@0 | 133 | { |
michael@0 | 134 | if (start + shown > total) |
michael@0 | 135 | start = total - shown; |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | SkEvent e("user"); |
michael@0 | 139 | e.setString("id", "adjustScrollBar"); |
michael@0 | 140 | e.setScalar("_totalLength", SkIntToScalar(total)); |
michael@0 | 141 | e.setScalar("_startPoint", SkIntToScalar(start)); |
michael@0 | 142 | e.setScalar("_shownLength", SkIntToScalar(shown)); |
michael@0 | 143 | // e.setS32("hideBar", hideBar); |
michael@0 | 144 | fAnim.doUserEvent(e); |
michael@0 | 145 | } |