Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 Vector<unsigned> mapping_; | |
|
kojii
2017/06/28 07:45:50
Can add explanation what this holds? "This is a ve
Xiaocheng
2017/06/28 18:21:58
Done.
| |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(NGOffsetMappingBuilder); | |
| 77 }; | |
| 78 | |
| 79 } // namespace blink | |
| 80 | |
| 81 #endif // OffsetMappingBuilder_h | |
| OLD | NEW |