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

Unified Diff: third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_result.h

Issue 2968803002: EXPERIMENT TextIterator built on Layout NG offset mapping
Patch Set: Mon Jul 17 15:55: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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_builder.cc ('k') | no next file » | 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_offset_mapping_result.h
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_result.h b/third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_result.h
index 12b0becb896cb0e938da6964c3ee1964c694aa1a..a4a3e541bd79c2409890dbdeb6906c38c12d7a09 100644
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_result.h
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_result.h
@@ -47,6 +47,20 @@ struct NGOffsetMappingUnit {
unsigned dom_end = 0;
unsigned text_content_start = 0;
unsigned text_content_end = 0;
+
+ unsigned DOMToTextContentOffset(unsigned dom_offset) const {
+ switch (type) {
+ case NGOffsetMappingUnitType::kIdentity:
+ return dom_offset - dom_start + text_content_start;
+ case NGOffsetMappingUnitType::kCollapsed:
+ return text_content_start;
+ case NGOffsetMappingUnitType::kExpanded:
+ return dom_offset == dom_start ? text_content_start : text_content_end;
+ }
+ // Add |return| in this unreachable patch to make Windows compiler happy.
+ NOTREACHED();
+ return 0;
+ }
};
// An NGOffsetMappingResult stores the units of a LayoutNGBlockFlow in sorted
@@ -56,6 +70,10 @@ struct NGOffsetMappingUnit {
struct NGOffsetMappingResult {
DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
+ // Returns the mapping unit whose owner is the node and dom offset range
+ // contains the given offset. Returns the last one if multiple units qualify.
+ const NGOffsetMappingUnit* GetMappingUnitForDOMOffset(const Node&, unsigned);
+
Vector<NGOffsetMappingUnit> units;
HashMap<const LayoutText*, std::pair<unsigned, unsigned>> ranges;
};
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698