gfx/skia/trunk/src/utils/SkTLogic.h

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.

     1 /*
     2  * Copyright 2013 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  *
     7  *
     8  * This header provides some of the helpers (std::integral_constant) and
     9  * type transformations (std::conditional) which will become available with
    10  * C++11 in the type_traits header.
    11  *
    12  * Because we lack constexpr, we cannot mimic
    13  * std::integral_constant::'constexpr operator T()'.
    14  * As a result we introduce SkTBool and SkTIf similar to Boost in order to
    15  * minimize the visual noise of many uses of '::value'.
    16  */
    18 #ifndef SkTLogic_DEFINED
    19 #define SkTLogic_DEFINED
    21 /** Represents a templated integer constant.
    22  *  Pre-C++11 version of std::integral_constant.
    23  */
    24 template <typename T, T v> struct SkTIntegralConstant {
    25     static const T value = v;
    26     typedef T value_type;
    27     typedef SkTIntegralConstant<T, v> type;
    28 };
    30 /** Convenience specialization of SkTIntegralConstant. */
    31 template <bool b> struct SkTBool : SkTIntegralConstant<bool, b> { };
    33 /** Pre-C++11 version of std::true_type. */
    34 typedef SkTBool<true> SkTrue;
    36 /** Pre-C++11 version of std::false_type. */
    37 typedef SkTBool<false> SkFalse;
    39 /** SkTIf_c::type = (condition) ? T : F;
    40  *  Pre-C++11 version of std::conditional.
    41  */
    42 template <bool condition, typename T, typename F> struct SkTIf_c {
    43     typedef F type;
    44 };
    45 template <typename T, typename F> struct SkTIf_c<true, T, F> {
    46     typedef T type;
    47 };
    49 /** SkTIf::type = (Condition::value) ? T : F; */
    50 template <typename Condition, typename T, typename F> struct SkTIf {
    51     typedef typename SkTIf_c<static_cast<bool>(Condition::value), T, F>::type type;
    52 };
    54 /** SkTMux::type = (a && b) ? Both : (a) ? A : (b) ? B : Neither; */
    55 template <typename a, typename b, typename Both, typename A, typename B, typename Neither>
    56 struct SkTMux {
    57     typedef typename SkTIf<a, typename SkTIf<b, Both, A>::type,
    58                               typename SkTIf<b, B, Neither>::type>::type type;
    59 };
    61 #endif

mercurial