LCOV - code coverage report
Current view: top level - layout/style - StyleComplexColor.h (source / functions) Hit Total Coverage
Test: output.info Lines: 14 14 100.0 %
Date: 2017-07-14 16:53:18 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : /* represent a color combines a numeric color and currentcolor */
       8             : 
       9             : #ifndef mozilla_StyleComplexColor_h_
      10             : #define mozilla_StyleComplexColor_h_
      11             : 
      12             : #include "nsColor.h"
      13             : 
      14             : namespace mozilla {
      15             : 
      16             : /**
      17             :  * This struct represents a combined color from a numeric color and
      18             :  * the current foreground color (currentcolor keyword).
      19             :  * Conceptually, the formula is "color * (1 - p) + currentcolor * p"
      20             :  * where p is mForegroundRatio. See mozilla::LinearBlendColors for
      21             :  * the actual algorithm.
      22             :  */
      23             : struct StyleComplexColor
      24             : {
      25             :   nscolor mColor;
      26             :   uint8_t mForegroundRatio;
      27             :   // Whether the complex color represents a computed-value time auto
      28             :   // value. This is only a flag indicating that this value should not
      29             :   // be interpolatable with other colors, while other fields still
      30             :   // represents the actual used color of this value.
      31             :   bool mIsAuto;
      32             : 
      33         592 :   static StyleComplexColor FromColor(nscolor aColor) {
      34         592 :     return {aColor, 0, false};
      35             :   }
      36        1377 :   static StyleComplexColor CurrentColor() {
      37        1377 :     return {NS_RGBA(0, 0, 0, 0), 255, false};
      38             :   }
      39        1677 :   static StyleComplexColor Auto() {
      40        1677 :     return {NS_RGBA(0, 0, 0, 0), 255, true};
      41             :   }
      42             : 
      43        2955 :   bool IsNumericColor() const { return mForegroundRatio == 0; }
      44        3517 :   bool IsCurrentColor() const { return mForegroundRatio == 255; }
      45             : 
      46        3168 :   bool operator==(const StyleComplexColor& aOther) const {
      47        6335 :     return mForegroundRatio == aOther.mForegroundRatio &&
      48        6745 :            (IsCurrentColor() || mColor == aOther.mColor) &&
      49        6333 :            mIsAuto == aOther.mIsAuto;
      50             :   }
      51        3168 :   bool operator!=(const StyleComplexColor& aOther) const {
      52        3168 :     return !(*this == aOther);
      53             :   }
      54             : };
      55             : 
      56             : }
      57             : 
      58             : #endif // mozilla_StyleComplexColor_h_

Generated by: LCOV version 1.13