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

Unified 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: Mon Jun 19 14:03:52 PDT 2017 Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder.h
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder.h b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder.h
index 9f295706ea0b3e1cdb2b3afe22068a496810b9bc..1bdfa7712e0bbb6c5677b145912ea449224cbe67 100644
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder.h
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder.h
@@ -27,11 +27,21 @@ class NGInlineItem;
// By calling EnterInline/ExitInline, it inserts bidirectional control
// characters as defined in:
// https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-table
+//
+// Optionally, NGInlineItemsBuilder takes parameter |collapsed_indexes| to
+// return how spaces are collapsed. For each string appended to
+// NGInlineItemsBuilder, a Vector<unsigned> will be added to
+// |collapsed_indexes|, storing the indexes of all collapsed spaces in sorted
+// order. See the unit tests for examples.
class CORE_EXPORT NGInlineItemsBuilder {
STACK_ALLOCATED();
public:
- explicit NGInlineItemsBuilder(Vector<NGInlineItem>* items) : items_(items) {}
+ explicit NGInlineItemsBuilder(Vector<NGInlineItem>* items)
+ : items_(items), collapsed_indexes_(nullptr) {}
+ explicit NGInlineItemsBuilder(Vector<NGInlineItem>* items,
+ Vector<Vector<unsigned>>* collapsed_indexes)
+ : items_(items), collapsed_indexes_(collapsed_indexes) {}
~NGInlineItemsBuilder();
String ToString();
@@ -92,6 +102,13 @@ class CORE_EXPORT NGInlineItemsBuilder {
bool is_svgtext_ = false;
bool has_bidi_controls_ = false;
+ // When provided, the indexes of collapsed spaces in each appended string will
+ // be eventually added to |collapsed_indexes_|.
+ Vector<Vector<unsigned>>* collapsed_indexes_;
yosin_UTC9 2017/06/21 04:22:41 Could you introduce OffsetMappingBuilder class to
kojii 2017/06/21 09:47:13 I take this opposite. Since this is tightly couple
Xiaocheng 2017/06/21 18:15:06 I agree with yosin@ that it's a better pattern if
+ // Length of each appended string. Used only for computing the indexes of
+ // collapsed spaces when |collapsed_indexes_| is provided.
+ Vector<unsigned> input_strings_lengths_;
+
void AppendWithWhiteSpaceCollapsing(const String&,
unsigned start,
unsigned end,
@@ -104,7 +121,7 @@ class CORE_EXPORT NGInlineItemsBuilder {
const ComputedStyle*,
LayoutObject*);
- void AppendForcedBreak(const ComputedStyle*, LayoutObject*);
+ void AppendForcedBreak(const ComputedStyle*, LayoutObject*, unsigned);
// Because newlines may be removed depends on following characters, newlines
// at the end of input string is not added to |text_| but instead
@@ -113,14 +130,16 @@ class CORE_EXPORT NGInlineItemsBuilder {
void ProcessPendingNewline(const String&, const ComputedStyle*);
// Removes the collapsible space at the end of |text_| if exists.
- void RemoveTrailingCollapsibleSpaceIfExists(unsigned*);
- void RemoveTrailingCollapsibleSpace(unsigned*);
+ void RemoveTrailingCollapsibleSpaceIfExists(unsigned*, unsigned);
+ void RemoveTrailingCollapsibleSpace(unsigned*, unsigned);
void RemoveTrailingCollapsibleNewlineIfNeeded(unsigned*,
const String&,
unsigned,
const ComputedStyle*);
+ void AddLastTrailingSpaceToRemovedIndexes(unsigned);
+
void Enter(LayoutObject*, UChar);
void Exit(LayoutObject*);
};

Powered by Google App Engine
This is Rietveld 408576698