gfx/skia/trunk/src/views/animated/SkBorderView.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.

     2 /*
     3  * Copyright 2011 Google Inc.
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
     8 #include "SkBorderView.h"
     9 #include "SkAnimator.h"
    10 #include "SkWidgetViews.h"
    11 #include "SkSystemEventTypes.h"
    12 #include "SkTime.h"
    13 #include "SkStackViewLayout.h"
    15 SkBorderView::SkBorderView() : fLeft(SkIntToScalar(0)),
    16                                fRight(SkIntToScalar(0)),
    17                                fTop(SkIntToScalar(0)),
    18                                fBottom(SkIntToScalar(0))
    19 {
    20     fAnim.setHostEventSink(this);
    21     init_skin_anim(kBorder_SkinEnum, &fAnim);
    22 }
    24 SkBorderView::~SkBorderView()
    25 {
    27 }
    29 void SkBorderView::setSkin(const char skin[])
    30 {
    31     init_skin_anim(skin, &fAnim);
    32 }
    34 /* virtual */ void SkBorderView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
    35 {
    36     this->INHERITED::onInflate(dom, node);
    37 }
    39 /*virtual*/ void SkBorderView::onSizeChange()
    40 {
    41     this->INHERITED::onSizeChange();
    42     SkEvent evt("user");
    43     evt.setString("id", "setDim");
    44     evt.setScalar("dimX", this->width());
    45     evt.setScalar("dimY", this->height());
    46     fAnim.doUserEvent(evt);
    47 }
    49 /*virtual*/ void SkBorderView::onDraw(SkCanvas* canvas)
    50 {
    51     SkPaint                        paint;
    52     SkAnimator::DifferenceType    diff = fAnim.draw(canvas, &paint, SkTime::GetMSecs());
    54     if (diff == SkAnimator::kDifferent)
    55         this->inval(NULL);
    56     else if (diff == SkAnimator::kPartiallyDifferent)
    57     {
    58         SkRect    bounds;
    59         fAnim.getInvalBounds(&bounds);
    60         this->inval(&bounds);
    61     }
    62 }
    64 /*virtual*/ bool SkBorderView::onEvent(const SkEvent& evt)
    65 {
    66     if (evt.isType(SK_EventType_Inval))
    67     {
    68         this->inval(NULL);
    69         return true;
    70     }
    71     if (evt.isType("recommendDim"))
    72     {
    73         evt.findScalar("leftMargin", &fLeft);
    74         evt.findScalar("rightMargin", &fRight);
    75         evt.findScalar("topMargin", &fTop);
    76         evt.findScalar("bottomMargin", &fBottom);
    78         //setup_views.cpp uses SkView::Layout instead of SkStackViewLayout
    79         //but that gives me an error
    80         SkStackViewLayout* layout;
    81         fMargin.set(fLeft, fTop, fRight, fBottom);
    82         if (this->getLayout())
    83         {
    84             layout = (SkStackViewLayout*)this->getLayout();
    85             layout->setMargin(fMargin);
    86         }
    87         else
    88         {
    89             layout = new SkStackViewLayout;
    90             layout->setMargin(fMargin);
    91             this->setLayout(layout)->unref();
    92         }
    93         this->invokeLayout();
    94     }
    95     return this->INHERITED::onEvent(evt);
    96 }

mercurial