| 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 #ifndef NGPhysicalTextFragment_h | 5 #ifndef NGPhysicalTextFragment_h |
| 6 #define NGPhysicalTextFragment_h | 6 #define NGPhysicalTextFragment_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/ng/inline/ng_inline_node.h" | 9 #include "core/layout/ng/inline/ng_inline_node.h" |
| 10 #include "core/layout/ng/ng_block_node.h" | 10 #include "core/layout/ng/ng_block_node.h" |
| 11 #include "core/layout/ng/ng_physical_fragment.h" | 11 #include "core/layout/ng/ng_physical_fragment.h" |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class CORE_EXPORT NGPhysicalTextFragment final : public NGPhysicalFragment { | 16 class CORE_EXPORT NGPhysicalTextFragment final : public NGPhysicalFragment { |
| 17 public: | 17 public: |
| 18 NGPhysicalTextFragment(LayoutObject* layout_object, | 18 NGPhysicalTextFragment(LayoutObject* layout_object, |
| 19 const NGInlineNode* node, | 19 const NGInlineNode node, |
| 20 unsigned item_index, | 20 unsigned item_index, |
| 21 unsigned start_offset, | 21 unsigned start_offset, |
| 22 unsigned end_offset, | 22 unsigned end_offset, |
| 23 NGPhysicalSize size) | 23 NGPhysicalSize size) |
| 24 : NGPhysicalFragment(layout_object, size, kFragmentText), | 24 : NGPhysicalFragment(layout_object, size, kFragmentText), |
| 25 node_(node), | 25 node_(node), |
| 26 item_index_(item_index), | 26 item_index_(item_index), |
| 27 start_offset_(start_offset), | 27 start_offset_(start_offset), |
| 28 end_offset_(end_offset) {} | 28 end_offset_(end_offset) {} |
| 29 | 29 |
| 30 const NGInlineNode* Node() const { return node_; } | 30 const NGInlineNode Node() const { return node_; } |
| 31 StringView Text() const { return node_->Text(start_offset_, end_offset_); } | 31 StringView Text() const { return node_.Text(start_offset_, end_offset_); } |
| 32 | 32 |
| 33 // The range of NGLayoutInlineItem. | 33 // The range of NGLayoutInlineItem. |
| 34 unsigned ItemIndex() const { return item_index_; } | 34 unsigned ItemIndex() const { return item_index_; } |
| 35 unsigned StartOffset() const { return start_offset_; } | 35 unsigned StartOffset() const { return start_offset_; } |
| 36 unsigned EndOffset() const { return end_offset_; } | 36 unsigned EndOffset() const { return end_offset_; } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 // TODO(kojii): NGInlineNode is to access text content and NGLayoutInlineItem. | 39 // TODO(kojii): NGInlineNode is to access text content and NGLayoutInlineItem. |
| 40 // Review if it's better to point them. | 40 // Review if it's better to point them. |
| 41 Persistent<const NGInlineNode> node_; | 41 const NGInlineNode node_; |
| 42 unsigned item_index_; | 42 unsigned item_index_; |
| 43 unsigned start_offset_; | 43 unsigned start_offset_; |
| 44 unsigned end_offset_; | 44 unsigned end_offset_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 DEFINE_TYPE_CASTS(NGPhysicalTextFragment, | 47 DEFINE_TYPE_CASTS(NGPhysicalTextFragment, |
| 48 NGPhysicalFragment, | 48 NGPhysicalFragment, |
| 49 fragment, | 49 fragment, |
| 50 fragment->IsText(), | 50 fragment->IsText(), |
| 51 fragment.IsText()); | 51 fragment.IsText()); |
| 52 | 52 |
| 53 } // namespace blink | 53 } // namespace blink |
| 54 | 54 |
| 55 #endif // NGPhysicalTextFragment_h | 55 #endif // NGPhysicalTextFragment_h |
| OLD | NEW |