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

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

Issue 2943573002: Make NGInlineItemsBuilder construct whitespace-collapsed offset mapping (Closed)
Patch Set: Tue Jun 27 15:22:36 PDT 2017 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/inline/ng_inline_node.h" 9 #include "core/layout/ng/inline/ng_inline_node.h"
10 #include "platform/wtf/Allocator.h" 10 #include "platform/wtf/Allocator.h"
11 #include "platform/wtf/Vector.h" 11 #include "platform/wtf/Vector.h"
12 #include "platform/wtf/text/StringBuilder.h" 12 #include "platform/wtf/text/StringBuilder.h"
13 #include "platform/wtf/text/WTFString.h" 13 #include "platform/wtf/text/WTFString.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class ComputedStyle; 17 class ComputedStyle;
18 class LayoutObject; 18 class LayoutObject;
19 class NGInlineItem; 19 class NGInlineItem;
20 class NGOffsetMappingBuilder;
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
31 //
32 // NGInlineItemsBuilder may optionally take an NGOffsetMappingBuilder parameter
33 // to construct the white-space collapsed offset mapping, which maps offsets in
34 // the concatenation of all appended strings and characters to offsets in
35 // |text_|. See https://goo.gl/CJbxky for more details about offset mapping.
30 class CORE_EXPORT NGInlineItemsBuilder { 36 class CORE_EXPORT NGInlineItemsBuilder {
31 STACK_ALLOCATED(); 37 STACK_ALLOCATED();
32 38
33 public: 39 public:
34 explicit NGInlineItemsBuilder(Vector<NGInlineItem>* items) : items_(items) {} 40 explicit NGInlineItemsBuilder(Vector<NGInlineItem>* items)
41 : items_(items), mapping_builder_(nullptr) {}
42 explicit NGInlineItemsBuilder(Vector<NGInlineItem>* items,
43 NGOffsetMappingBuilder* mapping_builder)
44 : items_(items), mapping_builder_(mapping_builder) {}
35 ~NGInlineItemsBuilder(); 45 ~NGInlineItemsBuilder();
36 46
37 String ToString(); 47 String ToString();
38 48
39 void SetIsSVGText(bool value) { is_svgtext_ = value; } 49 void SetIsSVGText(bool value) { is_svgtext_ = value; }
40 50
41 // Returns whether the items contain any Bidi controls. 51 // Returns whether the items contain any Bidi controls.
42 bool HasBidiControls() const { return has_bidi_controls_; } 52 bool HasBidiControls() const { return has_bidi_controls_; }
43 53
44 // Append a string. 54 // Append a string.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 UChar character; 101 UChar character;
92 } OnExitNode; 102 } OnExitNode;
93 Vector<OnExitNode> exits_; 103 Vector<OnExitNode> exits_;
94 104
95 enum class CollapsibleSpace { kNone, kSpace, kNewline }; 105 enum class CollapsibleSpace { kNone, kSpace, kNewline };
96 106
97 CollapsibleSpace last_collapsible_space_ = CollapsibleSpace::kSpace; 107 CollapsibleSpace last_collapsible_space_ = CollapsibleSpace::kSpace;
98 bool is_svgtext_ = false; 108 bool is_svgtext_ = false;
99 bool has_bidi_controls_ = false; 109 bool has_bidi_controls_ = false;
100 110
111 NGOffsetMappingBuilder* mapping_builder_;
112
101 void AppendWithWhiteSpaceCollapsing(const String&, 113 void AppendWithWhiteSpaceCollapsing(const String&,
102 unsigned start, 114 unsigned start,
103 unsigned end, 115 unsigned end,
104 const ComputedStyle*, 116 const ComputedStyle*,
105 LayoutObject*); 117 LayoutObject*);
106 void AppendWithoutWhiteSpaceCollapsing(const String&, 118 void AppendWithoutWhiteSpaceCollapsing(const String&,
107 const ComputedStyle*, 119 const ComputedStyle*,
108 LayoutObject*); 120 LayoutObject*);
109 void AppendWithPreservingNewlines(const String&, 121 void AppendWithPreservingNewlines(const String&,
110 const ComputedStyle*, 122 const ComputedStyle*,
(...skipping 13 matching lines...) Expand all
124 unsigned, 136 unsigned,
125 const ComputedStyle*); 137 const ComputedStyle*);
126 138
127 void Enter(LayoutObject*, UChar); 139 void Enter(LayoutObject*, UChar);
128 void Exit(LayoutObject*); 140 void Exit(LayoutObject*);
129 }; 141 };
130 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