| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 * | 22 * |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #ifndef CollapsedBorderValue_h | 25 #ifndef CollapsedBorderValue_h |
| 26 #define CollapsedBorderValue_h | 26 #define CollapsedBorderValue_h |
| 27 | 27 |
| 28 #include "core/style/BorderValue.h" | 28 #include "core/style/ComputedStyle.h" |
| 29 #include "platform/wtf/Allocator.h" | 29 #include "platform/wtf/Allocator.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 enum EBorderPrecedence { | 33 enum EBorderPrecedence { |
| 34 kBorderPrecedenceOff, | 34 kBorderPrecedenceOff, |
| 35 kBorderPrecedenceTable, | 35 kBorderPrecedenceTable, |
| 36 kBorderPrecedenceColumnGroup, | 36 kBorderPrecedenceColumnGroup, |
| 37 kBorderPrecedenceColumn, | 37 kBorderPrecedenceColumn, |
| 38 kBorderPrecedenceRowGroup, | 38 kBorderPrecedenceRowGroup, |
| 39 kBorderPrecedenceRow, | 39 kBorderPrecedenceRow, |
| 40 kBorderPrecedenceCell | 40 kBorderPrecedenceCell |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 class CollapsedBorderValue { | 43 class CollapsedBorderValue { |
| 44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 45 | 45 |
| 46 public: | 46 public: |
| 47 // Constructs a CollapsedBorderValue for non-existence border. | 47 // Constructs a CollapsedBorderValue for non-existence border. |
| 48 CollapsedBorderValue() | 48 CollapsedBorderValue() |
| 49 : color_(0), | 49 : color_(0), |
| 50 width_(0), | 50 width_(0), |
| 51 style_(static_cast<unsigned>(EBorderStyle::kNone)), | 51 style_(static_cast<unsigned>(EBorderStyle::kNone)), |
| 52 precedence_(kBorderPrecedenceOff) {} | 52 precedence_(kBorderPrecedenceOff) {} |
| 53 | 53 |
| 54 CollapsedBorderValue(const BorderValue& border, | 54 CollapsedBorderValue(const BorderValue& border, |
| 55 const Color& color, | 55 const Color& color, |
| 56 EBorderPrecedence precedence) | 56 EBorderPrecedence precedence) |
| 57 : color_(color), | 57 : color_(color), |
| 58 width_(border.Style() > EBorderStyle::kHidden ? border.Width() : 0), | 58 width_(ComputedStyle::BorderStyleIsVisible(border.Style()) |
| 59 ? border.Width() |
| 60 : 0), |
| 59 style_(static_cast<unsigned>(border.Style())), | 61 style_(static_cast<unsigned>(border.Style())), |
| 60 precedence_(precedence) { | 62 precedence_(precedence) { |
| 61 DCHECK(precedence != kBorderPrecedenceOff); | 63 DCHECK(precedence != kBorderPrecedenceOff); |
| 62 } | 64 } |
| 63 | 65 |
| 64 unsigned Width() const { return width_; } | 66 unsigned Width() const { return width_; } |
| 65 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } | 67 EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } |
| 66 bool Exists() const { return precedence_ != kBorderPrecedenceOff; } | 68 bool Exists() const { return precedence_ != kBorderPrecedenceOff; } |
| 67 Color GetColor() const { return color_; } | 69 Color GetColor() const { return color_; } |
| 68 bool IsTransparent() const { return !color_.Alpha(); } | 70 bool IsTransparent() const { return !color_.Alpha(); } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 92 private: | 94 private: |
| 93 Color color_; | 95 Color color_; |
| 94 unsigned width_ : 25; | 96 unsigned width_ : 25; |
| 95 unsigned style_ : 4; // EBorderStyle | 97 unsigned style_ : 4; // EBorderStyle |
| 96 unsigned precedence_ : 3; // EBorderPrecedence | 98 unsigned precedence_ : 3; // EBorderPrecedence |
| 97 }; | 99 }; |
| 98 | 100 |
| 99 } // namespace blink | 101 } // namespace blink |
| 100 | 102 |
| 101 #endif // CollapsedBorderValue_h | 103 #endif // CollapsedBorderValue_h |
| OLD | NEW |