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

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: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b627038dd28d0cb7be09f833ed9883a80e888272 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
@@ -41,6 +41,8 @@ class CORE_EXPORT NGInlineItemsBuilder {
// Returns whether the items contain any Bidi controls.
bool HasBidiControls() const { return has_bidi_controls_; }
+ using AppendResult = std::pair<bool, Vector<unsigned>>;
+
// Append a string.
// When appending, spaces are collapsed according to CSS Text, The white space
// processing rules
@@ -50,7 +52,12 @@ class CORE_EXPORT NGInlineItemsBuilder {
// this.
// @param LayoutObject The LayoutObject for the string.
// If a nullptr, it does not generate BidiRun. Bidi controls use this.
- void Append(const String&, const ComputedStyle*, LayoutObject* = nullptr);
+ // @return A pair, where the boolean denotes if the appending results in the
+ // removal of a preceeding collapsible space, and the vector gives the indexes
+ // of the collapsed spaces in the appended string.
yoichio 2017/06/16 01:47:48 Does this value have enough information to build o
Xiaocheng 2017/06/16 01:59:14 Yes. The returned vector will contain the indexes
+ AppendResult Append(const String&,
+ const ComputedStyle*,
+ LayoutObject* = nullptr);
// Append a character.
// Currently this function is for adding control characters such as
@@ -76,6 +83,9 @@ class CORE_EXPORT NGInlineItemsBuilder {
void EnterInline(LayoutObject*);
void ExitInline(LayoutObject*);
+ // Returns true if the finalization removes a previous collapsible space.
+ bool Finalize();
Xiaocheng 2017/06/16 00:09:44 This function is refactored out from ToString(), s
+
private:
Vector<NGInlineItem>* items_;
StringBuilder text_;
@@ -92,19 +102,20 @@ class CORE_EXPORT NGInlineItemsBuilder {
bool is_svgtext_ = false;
bool has_bidi_controls_ = false;
- void AppendWithWhiteSpaceCollapsing(const String&,
- unsigned start,
- unsigned end,
- const ComputedStyle*,
- LayoutObject*);
- void AppendWithoutWhiteSpaceCollapsing(const String&,
- const ComputedStyle*,
- LayoutObject*);
- void AppendWithPreservingNewlines(const String&,
- const ComputedStyle*,
- LayoutObject*);
-
- void AppendForcedBreak(const ComputedStyle*, LayoutObject*);
+ AppendResult AppendWithWhiteSpaceCollapsing(const String&,
+ unsigned start,
+ unsigned end,
+ const ComputedStyle*,
+ LayoutObject*);
+ AppendResult AppendWithoutWhiteSpaceCollapsing(const String&,
+ const ComputedStyle*,
+ LayoutObject*);
+ AppendResult AppendWithPreservingNewlines(const String&,
+ const ComputedStyle*,
+ LayoutObject*);
+
+ // Returns if a previous 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,11 +123,13 @@ 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
+ // is a collapsible space is removed.
+ bool RemoveTrailingCollapsibleSpaceIfExists(unsigned*);
void RemoveTrailingCollapsibleSpace(unsigned*);
- void RemoveTrailingCollapsibleNewlineIfNeeded(unsigned*,
+ // Returns true if a collapsible newline is removed.
+ bool RemoveTrailingCollapsibleNewlineIfNeeded(unsigned*,
const String&,
unsigned,
const ComputedStyle*);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/inline/ng_inline_items_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698