| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/ng/ng_fragment_base.h" | 5 #include "core/layout/ng/ng_fragment_base.h" |
| 6 #include "core/layout/ng/ng_fragment.h" | 6 |
| 7 #include "core/layout/ng/ng_text_fragment.h" | 7 #include "core/layout/ng/ng_physical_fragment_base.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 NGFragmentBase::NGFragmentBase(NGLogicalSize size, | 11 LayoutUnit NGFragmentBase::InlineSize() const { |
| 12 NGLogicalSize overflow, | 12 return writing_mode_ == HorizontalTopBottom ? physical_fragment_->Width() |
| 13 NGWritingMode writing_mode, | 13 : physical_fragment_->Height(); |
| 14 NGDirection direction, | 14 } |
| 15 NGFragmentType type) | |
| 16 : size_(size), | |
| 17 overflow_(overflow), | |
| 18 type_(type), | |
| 19 writing_mode_(writing_mode), | |
| 20 direction_(direction), | |
| 21 has_been_placed_(false) {} | |
| 22 | 15 |
| 23 void NGFragmentBase::SetOffset(LayoutUnit inline_offset, | 16 LayoutUnit NGFragmentBase::BlockSize() const { |
| 24 LayoutUnit block_offset) { | 17 return writing_mode_ == HorizontalTopBottom ? physical_fragment_->Height() |
| 25 // setOffset should only be called once. | 18 : physical_fragment_->Width(); |
| 26 DCHECK(!has_been_placed_); | 19 } |
| 27 offset_.inline_offset = inline_offset; | 20 |
| 28 offset_.block_offset = block_offset; | 21 LayoutUnit NGFragmentBase::InlineOverflow() const { |
| 29 has_been_placed_ = true; | 22 return writing_mode_ == HorizontalTopBottom |
| 23 ? physical_fragment_->WidthOverflow() |
| 24 : physical_fragment_->HeightOverflow(); |
| 25 } |
| 26 |
| 27 LayoutUnit NGFragmentBase::BlockOverflow() const { |
| 28 return writing_mode_ == HorizontalTopBottom |
| 29 ? physical_fragment_->HeightOverflow() |
| 30 : physical_fragment_->WidthOverflow(); |
| 31 } |
| 32 |
| 33 LayoutUnit NGFragmentBase::InlineOffset() const { |
| 34 return writing_mode_ == HorizontalTopBottom ? physical_fragment_->LeftOffset() |
| 35 : physical_fragment_->TopOffset(); |
| 36 } |
| 37 |
| 38 LayoutUnit NGFragmentBase::BlockOffset() const { |
| 39 return writing_mode_ == HorizontalTopBottom |
| 40 ? physical_fragment_->TopOffset() |
| 41 : physical_fragment_->LeftOffset(); |
| 30 } | 42 } |
| 31 | 43 |
| 32 DEFINE_TRACE(NGFragmentBase) { | 44 DEFINE_TRACE(NGFragmentBase) { |
| 33 if (Type() == FragmentText) | 45 visitor->trace(physical_fragment_); |
| 34 static_cast<NGTextFragment*>(this)->traceAfterDispatch(visitor); | |
| 35 else | |
| 36 static_cast<NGFragment*>(this)->traceAfterDispatch(visitor); | |
| 37 } | 46 } |
| 38 | 47 |
| 39 } // namespace blink | 48 } // namespace blink |
| OLD | NEW |