| 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 #include "core/layout/ng/ng_fragment.h" |
| 7 #include "core/layout/ng/ng_text.h" | 7 #include "core/layout/ng/ng_text.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 NGFragmentBase::NGFragmentBase(LayoutUnit inlineSize, | 11 NGFragmentBase::NGFragmentBase(LayoutUnit inlineSize, |
| 12 LayoutUnit blockSize, | 12 LayoutUnit blockSize, |
| 13 LayoutUnit inlineOverflow, | 13 LayoutUnit inlineOverflow, |
| 14 LayoutUnit blockOverflow) | 14 LayoutUnit blockOverflow, |
| 15 NGWritingMode writingMode, |
| 16 NGDirection direction, |
| 17 NGFragmentType type) |
| 15 : m_inlineSize(inlineSize), | 18 : m_inlineSize(inlineSize), |
| 16 m_blockSize(blockSize), | 19 m_blockSize(blockSize), |
| 17 m_inlineOverflow(inlineOverflow), | 20 m_inlineOverflow(inlineOverflow), |
| 18 m_blockOverflow(blockOverflow) {} | 21 m_blockOverflow(blockOverflow), |
| 22 m_type(type), |
| 23 m_writingMode(writingMode), |
| 24 m_direction(direction), |
| 25 m_hasBeenPlaced(false) {} |
| 19 | 26 |
| 20 void NGFragmentBase::setOffset(LayoutUnit inlineOffset, | 27 void NGFragmentBase::setOffset(LayoutUnit inlineOffset, |
| 21 LayoutUnit blockOffset) { | 28 LayoutUnit blockOffset) { |
| 29 // setOffset should only be called once. |
| 30 DCHECK(!m_hasBeenPlaced); |
| 22 m_inlineOffset = inlineOffset; | 31 m_inlineOffset = inlineOffset; |
| 23 m_blockOffset = blockOffset; | 32 m_blockOffset = blockOffset; |
| 33 m_hasBeenPlaced = true; |
| 24 } | 34 } |
| 25 | 35 |
| 26 DEFINE_TRACE(NGFragmentBase) { | 36 DEFINE_TRACE(NGFragmentBase) { |
| 27 if (m_isText) | 37 if (type() == FragmentText) |
| 28 static_cast<NGText*>(this)->traceAfterDispatch(visitor); | 38 static_cast<NGText*>(this)->traceAfterDispatch(visitor); |
| 29 else | 39 else |
| 30 static_cast<NGFragment*>(this)->traceAfterDispatch(visitor); | 40 static_cast<NGFragment*>(this)->traceAfterDispatch(visitor); |
| 31 } | 41 } |
| 32 | 42 |
| 33 } // namespace blink | 43 } // namespace blink |
| OLD | NEW |