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

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

Issue 2943573002: Make NGInlineItemsBuilder construct whitespace-collapsed offset mapping (Closed)
Patch Set: Wed Jun 28 11:44:29 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NGOffsetMappingBuilder_h
6 #define NGOffsetMappingBuilder_h
7
8 #include "core/CoreExport.h"
9 #include "platform/wtf/Allocator.h"
10 #include "platform/wtf/Vector.h"
11 #include "platform/wtf/text/WTFString.h"
12
13 namespace blink {
14
15 // This is the helper class for constructing the DOM-to-TextContent offset
16 // mapping. It holds an offset mapping, and provides APIs to modify the mapping
17 // step by step until the construction is finished.
18 // Design doc: https://goo.gl/CJbxky
19 // TODO(xiaochengh): Change the mock implemetation to a real one.
20 class CORE_EXPORT NGOffsetMappingBuilder {
21 STACK_ALLOCATED();
22
23 public:
24 NGOffsetMappingBuilder();
25
26 // TODO(xiaochengh): Add the following API when we implement the construction
27 // of the concatenated offset mapping.
28 // Associate the offset mapping with a simple annotation with the given node
29 // as its value.
30 // void Annotate(const Node&);
31
32 // Append an identity offset mapping of the specified length with null
33 // annotation to the builder.
34 void AppendIdentityMapping(unsigned length);
35
36 // Append a collapsed offset mapping from the specified length with null
37 // annotation to the builder.
38 void AppendCollapsedMapping(unsigned length);
39
40 // TODO(xiaochengh): Add the following API when we start to fix offset mapping
41 // for text-transform.
42 // Append an expanded offset mapping to the specified length with null
43 // annotation to the builder.
44 // void AppendExpandedMapping(unsigned length);
45
46 // This function should only be called by NGInlineItemsBuilder during
47 // whitespace collapsing, and in the case that the target string of the
48 // currently held mapping:
49 // (i) has at least |skip_length + 1| characters,
50 // (ii) has the last |skip_length| characters being non-text extra
51 // characters, and
52 // (iii) has the |skip_length + 1|-st last character being a space.
53 // This function changes the space into collapsed.
54 void CollapseTrailingSpace(unsigned index);
55
56 // TODO(xiaochengh): Add the following API when we implement the construction
57 // of the concatenated offset mapping.
58 // Concatenate the offset mapping held by another builder to this builder.
59 // void Concatenate(const OffsetMappingBuilder&);
60
61 // TODO(xiaochengh): Add the following APIs when we implement the construction
62 // of the DOM-to-TextContent offset mapping.
63
64 // Composite the offset mapping held by another builder to this builder.
65 // void Composite(const OffsetMappingBuilder&);
66
67 // Finalize and return the offset mapping.
68 // OffsetMappingResult Build();
69
70 // Exposed for testing only.
71 Vector<unsigned> DumpOffsetMappingForTesting() const;
72
73 private:
74 // A mock implementation of the offset mapping builder that stores the mapping
75 // value of every offset in the plain way. This is simple but inefficient, and
76 // will be replaced by a real efficient implementation.
77 Vector<unsigned> mapping_;
78
79 DISALLOW_COPY_AND_ASSIGN(NGOffsetMappingBuilder);
80 };
81
82 } // namespace blink
83
84 #endif // OffsetMappingBuilder_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698