1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_SELF_ALIGNMENT_DATA_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_SELF_ALIGNMENT_DATA_H_ 7 8 #include "third_party/blink/renderer/core/style/computed_style_constants.h" 9 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" 10 11 namespace blink { 12 13 class StyleSelfAlignmentData { 14 DISALLOW_NEW(); 15 16 public: 17 // Style data for Self-Aligment and Default-Alignment properties: align-{self, 18 // items}, justify-{self, items}. 19 // [ <self-position> && <overflow-position>? ] | [ legacy && [ left | right | 20 // center ] ] 21 StyleSelfAlignmentData( 22 ItemPosition position, 23 OverflowAlignment overflow, 24 ItemPositionType position_type = ItemPositionType::kNonLegacy) position_(static_cast<unsigned> (position))25 : position_(static_cast<unsigned>(position)), 26 position_type_(static_cast<unsigned>(position_type)), 27 overflow_(static_cast<unsigned>(overflow)) {} 28 SetPosition(ItemPosition position)29 void SetPosition(ItemPosition position) { 30 position_ = static_cast<unsigned>(position); 31 } SetPositionType(ItemPositionType position_type)32 void SetPositionType(ItemPositionType position_type) { 33 position_type_ = static_cast<unsigned>(position_type); 34 } SetOverflow(OverflowAlignment overflow)35 void SetOverflow(OverflowAlignment overflow) { 36 overflow_ = static_cast<unsigned>(overflow); 37 } 38 GetPosition()39 ItemPosition GetPosition() const { 40 return static_cast<ItemPosition>(position_); 41 } PositionType()42 ItemPositionType PositionType() const { 43 return static_cast<ItemPositionType>(position_type_); 44 } Overflow()45 OverflowAlignment Overflow() const { 46 return static_cast<OverflowAlignment>(overflow_); 47 } 48 49 bool operator==(const StyleSelfAlignmentData& o) const { 50 return position_ == o.position_ && position_type_ == o.position_type_ && 51 overflow_ == o.overflow_; 52 } 53 54 bool operator!=(const StyleSelfAlignmentData& o) const { 55 return !(*this == o); 56 } 57 58 private: 59 unsigned position_ : 4; // ItemPosition 60 unsigned position_type_ : 1; // Whether or not alignment uses the 'legacy' 61 // keyword. 62 unsigned overflow_ : 2; // OverflowAlignment 63 }; 64 65 } // namespace blink 66 67 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_SELF_ALIGNMENT_DATA_H_ 68