Chromium Code Reviews| 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..0617fc3b0d7278955ceae17e19fafaf7f8358b64 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 |
| @@ -8,6 +8,7 @@ |
| #include "core/CoreExport.h" |
| #include "core/layout/ng/inline/ng_inline_node.h" |
| #include "platform/wtf/Allocator.h" |
| +#include "platform/wtf/Optional.h" |
| #include "platform/wtf/Vector.h" |
| #include "platform/wtf/text/StringBuilder.h" |
| #include "platform/wtf/text/WTFString.h" |
| @@ -27,11 +28,19 @@ 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 |removed_indexes| to return |
|
kojii
2017/06/19 05:56:33
How about naming |removed_indexes| as |collapsed_i
Xiaocheng
2017/06/19 17:53:01
Sound good. Done.
|
| +// how spaces are collapsed. For each string appended to NGInlineItemsBuilder, |
| +// a Vector<unsigned> is added to |removed_indexes|, storing the indexes of all |
| +// removed 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), removed_indexes_(nullptr) {} |
| + explicit NGInlineItemsBuilder(Vector<NGInlineItem>* items, |
| + Vector<Vector<unsigned>>* removed_indexes); |
| ~NGInlineItemsBuilder(); |
| String ToString(); |
| @@ -78,6 +87,8 @@ class CORE_EXPORT NGInlineItemsBuilder { |
| private: |
| Vector<NGInlineItem>* items_; |
| + Vector<Vector<unsigned>>* removed_indexes_; |
|
kojii
2017/06/19 05:56:33
ditto.
Xiaocheng
2017/06/19 17:53:01
Done.
|
| + Optional<Vector<unsigned>> input_strings_lengths_; |
|
Xiaocheng
2017/06/17 00:35:06
Appending a string may result in the removal of a
yosin_UTC9
2017/06/19 03:23:11
Since NGInlineItemsBuild allocated on stack, == on
Xiaocheng
2017/06/19 05:15:51
Will do.
yosin_UTC9
2017/06/19 05:55:13
It is functional abstraction of each then-clause a
|
| StringBuilder text_; |
| typedef struct OnExitNode { |
| @@ -104,7 +115,8 @@ class CORE_EXPORT NGInlineItemsBuilder { |
| const ComputedStyle*, |
| LayoutObject*); |
| - void AppendForcedBreak(const ComputedStyle*, LayoutObject*); |
| + // Returns true if a previously appended collapsible space is removed. |
| + bool AppendForcedBreak(const ComputedStyle*, LayoutObject*); |
| // Because newlines may be removed depends on following characters, newlines |
| // at the end of input string is not added to |text_| but instead |
| @@ -112,15 +124,19 @@ class CORE_EXPORT NGInlineItemsBuilder { |
| // This function determines whether to add the newline or ignore. |
| void ProcessPendingNewline(const String&, const ComputedStyle*); |
| - // Removes the collapsible space at the end of |text_| if exists. |
| - void RemoveTrailingCollapsibleSpaceIfExists(unsigned*); |
| + // Removes the collapsible space at the end of |text_| if exists. Returns true |
| + // if such a space is removed. |
| + bool RemoveTrailingCollapsibleSpaceIfExists(unsigned*); |
| void RemoveTrailingCollapsibleSpace(unsigned*); |
| - void RemoveTrailingCollapsibleNewlineIfNeeded(unsigned*, |
| + // Returns true if a collapsible newline at the end of |text_| is removed. |
| + bool RemoveTrailingCollapsibleNewlineIfNeeded(unsigned*, |
| const String&, |
| unsigned, |
| const ComputedStyle*); |
| + void AddLastTrailingSpaceToRemovedIndexes(unsigned); |
| + |
| void Enter(LayoutObject*, UChar); |
| void Exit(LayoutObject*); |
| }; |