gfx/skia/trunk/src/views/animated/SkProgressBarView.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 "SkProgressBarView.h"
michael@0 9 #include "SkAnimator.h"
michael@0 10 #include "SkWidgetViews.h"
michael@0 11 #include "SkTime.h"
michael@0 12 #include "SkSystemEventTypes.h"
michael@0 13
michael@0 14 SkProgressBarView::SkProgressBarView()
michael@0 15 {
michael@0 16 init_skin_anim(kProgress_SkinEnum, &fAnim);
michael@0 17 fAnim.setHostEventSink(this);
michael@0 18 fProgress = 0;
michael@0 19 fMax = 100;
michael@0 20
michael@0 21 }
michael@0 22
michael@0 23 void SkProgressBarView::changeProgress(int diff)
michael@0 24 {
michael@0 25 int newProg = fProgress + diff;
michael@0 26 if (newProg > 0 && newProg < fMax)
michael@0 27 this->setProgress(newProg);
michael@0 28 //otherwise i'll just leave it as it is
michael@0 29 //this implies that if a new max and progress are set, max must be set first
michael@0 30 }
michael@0 31
michael@0 32 /*virtual*/ void SkProgressBarView::onDraw(SkCanvas* canvas)
michael@0 33 {
michael@0 34 SkPaint paint;
michael@0 35 SkAnimator::DifferenceType diff = fAnim.draw(canvas, &paint, SkTime::GetMSecs());
michael@0 36
michael@0 37 if (diff == SkAnimator::kDifferent)
michael@0 38 this->inval(NULL);
michael@0 39 else if (diff == SkAnimator::kPartiallyDifferent)
michael@0 40 {
michael@0 41 SkRect bounds;
michael@0 42 fAnim.getInvalBounds(&bounds);
michael@0 43 this->inval(&bounds);
michael@0 44 }
michael@0 45 }
michael@0 46
michael@0 47 /*virtual*/ bool SkProgressBarView::onEvent(const SkEvent& evt)
michael@0 48 {
michael@0 49 if (evt.isType(SK_EventType_Inval))
michael@0 50 {
michael@0 51 this->inval(NULL);
michael@0 52 return true;
michael@0 53 }
michael@0 54 if (evt.isType("recommendDim"))
michael@0 55 {
michael@0 56 SkScalar height;
michael@0 57
michael@0 58 if (evt.findScalar("y", &height))
michael@0 59 this->setHeight(height);
michael@0 60 return true;
michael@0 61 }
michael@0 62 return this->INHERITED::onEvent(evt);
michael@0 63 }
michael@0 64
michael@0 65 /*virtual*/ void SkProgressBarView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
michael@0 66 {
michael@0 67 this->INHERITED::onInflate(dom, node);
michael@0 68 int32_t temp;
michael@0 69 if (dom.findS32(node, "max", &temp))
michael@0 70 this->setMax(temp);
michael@0 71 if (dom.findS32(node, "progress", &temp))
michael@0 72 this->setProgress(temp);
michael@0 73 }
michael@0 74
michael@0 75 /*virtual*/ void SkProgressBarView::onSizeChange()
michael@0 76 {
michael@0 77 this->INHERITED::onSizeChange();
michael@0 78 SkEvent evt("user");
michael@0 79 evt.setString("id", "setDim");
michael@0 80 evt.setScalar("dimX", this->width());
michael@0 81 evt.setScalar("dimY", this->height());
michael@0 82 fAnim.doUserEvent(evt);
michael@0 83 }
michael@0 84
michael@0 85 void SkProgressBarView::reset()
michael@0 86 {
michael@0 87 fProgress = 0;
michael@0 88 SkEvent e("user");
michael@0 89 e.setString("id", "reset");
michael@0 90 fAnim.doUserEvent(e);
michael@0 91 }
michael@0 92
michael@0 93 void SkProgressBarView::setMax(int max)
michael@0 94 {
michael@0 95 fMax = max;
michael@0 96 SkEvent e("user");
michael@0 97 e.setString("id", "setMax");
michael@0 98 e.setS32("newMax", max);
michael@0 99 fAnim.doUserEvent(e);
michael@0 100 }
michael@0 101
michael@0 102 void SkProgressBarView::setProgress(int progress)
michael@0 103 {
michael@0 104 fProgress = progress;
michael@0 105 SkEvent e("user");
michael@0 106 e.setString("id", "setProgress");
michael@0 107 e.setS32("newProgress", progress);
michael@0 108 fAnim.doUserEvent(e);
michael@0 109 }

mercurial