Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder.h

Issue 2960673004: Templatize NGInlineItemsBuilder to take a OffsetMappingBuilder parameter (Closed)
Patch Set: Fix grammar Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 NGInlineItemsBuilder_h 5 #ifndef NGInlineItemsBuilder_h
6 #define NGInlineItemsBuilder_h 6 #define NGInlineItemsBuilder_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/api/empty_offset_mapping_builder.h"
9 #include "core/layout/ng/inline/ng_inline_node.h" 10 #include "core/layout/ng/inline/ng_inline_node.h"
10 #include "platform/wtf/Allocator.h" 11 #include "platform/wtf/Allocator.h"
11 #include "platform/wtf/Vector.h" 12 #include "platform/wtf/Vector.h"
12 #include "platform/wtf/text/StringBuilder.h" 13 #include "platform/wtf/text/StringBuilder.h"
13 #include "platform/wtf/text/WTFString.h" 14 #include "platform/wtf/text/WTFString.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class ComputedStyle; 18 class ComputedStyle;
18 class LayoutObject; 19 class LayoutObject;
19 class NGInlineItem; 20 class NGInlineItem;
20 21
21 // NGInlineItemsBuilder builds a string and a list of NGInlineItem from inlines. 22 // NGInlineItemsBuilder builds a string and a list of NGInlineItem from inlines.
22 // 23 //
23 // When appending, spaces are collapsed according to CSS Text, The white space 24 // When appending, spaces are collapsed according to CSS Text, The white space
24 // processing rules 25 // processing rules
25 // https://drafts.csswg.org/css-text-3/#white-space-rules 26 // https://drafts.csswg.org/css-text-3/#white-space-rules
26 // 27 //
27 // By calling EnterInline/ExitInline, it inserts bidirectional control 28 // By calling EnterInline/ExitInline, it inserts bidirectional control
28 // characters as defined in: 29 // characters as defined in:
29 // https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-ta ble 30 // https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-ta ble
30 class CORE_EXPORT NGInlineItemsBuilder { 31 // TODO(xiaochengh): Pass in a real offset mapping builder type and use it to
32 // construct the whitespace-collapsed offset mapping.
33 template <typename OffsetMappingBuilder>
34 class CORE_TEMPLATE_CLASS_EXPORT NGInlineItemsBuilderTemplate {
31 STACK_ALLOCATED(); 35 STACK_ALLOCATED();
32 36
33 public: 37 public:
34 explicit NGInlineItemsBuilder(Vector<NGInlineItem>* items) : items_(items) {} 38 explicit NGInlineItemsBuilderTemplate(Vector<NGInlineItem>* items)
35 ~NGInlineItemsBuilder(); 39 : items_(items) {}
40 ~NGInlineItemsBuilderTemplate();
36 41
37 String ToString(); 42 String ToString();
38 43
39 void SetIsSVGText(bool value) { is_svgtext_ = value; } 44 void SetIsSVGText(bool value) { is_svgtext_ = value; }
40 45
41 // Returns whether the items contain any Bidi controls. 46 // Returns whether the items contain any Bidi controls.
42 bool HasBidiControls() const { return has_bidi_controls_; } 47 bool HasBidiControls() const { return has_bidi_controls_; }
43 48
44 // Append a string. 49 // Append a string.
45 // When appending, spaces are collapsed according to CSS Text, The white space 50 // When appending, spaces are collapsed according to CSS Text, The white space
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void AppendBidiControl(const ComputedStyle*, UChar ltr, UChar rtl); 83 void AppendBidiControl(const ComputedStyle*, UChar ltr, UChar rtl);
79 84
80 void EnterBlock(const ComputedStyle*); 85 void EnterBlock(const ComputedStyle*);
81 void ExitBlock(); 86 void ExitBlock();
82 void EnterInline(LayoutObject*); 87 void EnterInline(LayoutObject*);
83 void ExitInline(LayoutObject*); 88 void ExitInline(LayoutObject*);
84 89
85 private: 90 private:
86 Vector<NGInlineItem>* items_; 91 Vector<NGInlineItem>* items_;
87 StringBuilder text_; 92 StringBuilder text_;
93 OffsetMappingBuilder mapping_builder_;
yosin_UTC9 2017/06/28 03:37:11 Could you upload the patch which using |mapping_bu
Xiaocheng 2017/06/28 03:44:42 This is just a preparation patch that templatizes
88 94
89 typedef struct OnExitNode { 95 typedef struct OnExitNode {
90 LayoutObject* node; 96 LayoutObject* node;
91 UChar character; 97 UChar character;
92 } OnExitNode; 98 } OnExitNode;
93 Vector<OnExitNode> exits_; 99 Vector<OnExitNode> exits_;
94 100
95 enum class CollapsibleSpace { kNone, kSpace, kNewline }; 101 enum class CollapsibleSpace { kNone, kSpace, kNewline };
96 102
97 CollapsibleSpace last_collapsible_space_ = CollapsibleSpace::kSpace; 103 CollapsibleSpace last_collapsible_space_ = CollapsibleSpace::kSpace;
(...skipping 23 matching lines...) Expand all
121 void RemoveTrailingCollapsibleSpaceIfExists(); 127 void RemoveTrailingCollapsibleSpaceIfExists();
122 void RemoveTrailingCollapsibleSpace(unsigned); 128 void RemoveTrailingCollapsibleSpace(unsigned);
123 void RemoveTrailingCollapsibleNewlineIfNeeded(const String&, 129 void RemoveTrailingCollapsibleNewlineIfNeeded(const String&,
124 unsigned, 130 unsigned,
125 const ComputedStyle*); 131 const ComputedStyle*);
126 132
127 void Enter(LayoutObject*, UChar); 133 void Enter(LayoutObject*, UChar);
128 void Exit(LayoutObject*); 134 void Exit(LayoutObject*);
129 }; 135 };
130 136
137 extern template class CORE_EXTERN_TEMPLATE_EXPORT
138 NGInlineItemsBuilderTemplate<EmptyOffsetMappingBuilder>;
139
140 using NGInlineItemsBuilder =
141 NGInlineItemsBuilderTemplate<EmptyOffsetMappingBuilder>;
142
131 } // namespace blink 143 } // namespace blink
132 144
133 #endif // NGInlineItemsBuilder_h 145 #endif // NGInlineItemsBuilder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698