Home | History | Annotate | Download | only in style
      1 /*
      2  * Copyright (c) 2013, Opera Software ASA. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Opera Software ASA nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef BorderImageLengthBox_h
     32 #define BorderImageLengthBox_h
     33 
     34 #include "core/rendering/style/BorderImageLength.h"
     35 
     36 namespace blink {
     37 
     38 // Represents a computed border image width or outset.
     39 //
     40 // http://www.w3.org/TR/css3-background/#border-image-width
     41 // http://www.w3.org/TR/css3-background/#border-image-outset
     42 class BorderImageLengthBox {
     43 public:
     44     BorderImageLengthBox(Length length)
     45         : m_left(length)
     46         , m_right(length)
     47         , m_top(length)
     48         , m_bottom(length)
     49     {
     50     }
     51 
     52     BorderImageLengthBox(double number)
     53         : m_left(number)
     54         , m_right(number)
     55         , m_top(number)
     56         , m_bottom(number)
     57     {
     58     }
     59 
     60     BorderImageLengthBox(const BorderImageLength& top, const BorderImageLength& right,
     61         const BorderImageLength& bottom, const BorderImageLength& left)
     62         : m_left(left)
     63         , m_right(right)
     64         , m_top(top)
     65         , m_bottom(bottom)
     66     {
     67     }
     68 
     69     const BorderImageLength& left() const { return m_left; }
     70     const BorderImageLength& right() const { return m_right; }
     71     const BorderImageLength& top() const { return m_top; }
     72     const BorderImageLength& bottom() const { return m_bottom; }
     73 
     74     bool operator==(const BorderImageLengthBox& other) const
     75     {
     76         return m_left == other.m_left && m_right == other.m_right
     77             && m_top == other.m_top && m_bottom == other.m_bottom;
     78     }
     79 
     80     bool operator!=(const BorderImageLengthBox& other) const
     81     {
     82         return !(*this == other);
     83     }
     84 
     85     bool nonZero() const
     86     {
     87         return !(m_left.isZero() && m_right.isZero() && m_top.isZero() && m_bottom.isZero());
     88     }
     89 
     90 private:
     91     BorderImageLength m_left;
     92     BorderImageLength m_right;
     93     BorderImageLength m_top;
     94     BorderImageLength m_bottom;
     95 };
     96 
     97 } // namespace blink
     98 
     99 #endif // BorderImageLengthBox_h
    100