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

Unified Diff: third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js

Issue 2455883003: Convert editing/spelling/spelling-huge-text.html with spellcheck_test (Closed)
Patch Set: Optimize spellcheck_test's handleCharacterData Created 4 years, 1 month 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/LayoutTests/editing/spelling/spelling-huge-text.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js
diff --git a/third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js b/third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js
index 4993dbbda509f6ee64a94abf7c818ff9173ed11d..617d7a390b69daf133e967d0e70876dd5d803cf7 100644
--- a/third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js
+++ b/third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js
@@ -113,20 +113,21 @@ class MarkerSerializer {
/**
* @private
- * @param {!Node} node
+ * @param {!CharacterData} node
* @param {number} offset
+ * @return {number} The next offset at which a current active marker ends or
+ * a new marker starts. Returns node.data.length if there is
+ * no more markers.
*/
advancedTo(node, offset) {
+ var nextCheckPoint = node.data.length;
for (let type in this.markerTypes_) {
// Handle the ending of the current active marker.
- if (isAtRangeEnd(this.activeMarkerRanges_[type], node, offset)) {
- this.activeMarkerRanges_[type] = null;
+ if (isAtRangeEnd(this.activeMarkerRanges_[type], node, offset))
this.emit(this.markerTypes_[type]);
- }
- // Handle the starting of the next active marker.
- if (this.activeMarkerRanges_[type])
- return;
+ // Recompute the current active marker and the next check point
+ this.activeMarkerRanges_[type] = null;
/** @type {number} */
const markerCount = window.internals.markerCountForNode(node, type);
for (let i = 0; i < markerCount; ++i) {
@@ -137,15 +138,20 @@ class MarkerSerializer {
assert_equals(
marker.endContainer, node,
'Internal error: marker range not ending in the annotated node.');
- if (marker.startOffset === offset) {
- assert_greater_than(marker.endOffset, offset,
- 'Internal error: marker range is collapsed.');
+ assert_greater_than(marker.endOffset, marker.startOffset,
+ 'Internal error: marker range is collapsed.');
+ if (marker.startOffset <= offset && offset < marker.endOffset) {
this.activeMarkerRanges_[type] = marker;
- this.emit(this.markerTypes_[type]);
- break;
+ nextCheckPoint = Math.min(nextCheckPoint, marker.endOffset);
+ // Handle the starting of the current active marker.
+ if (offset === marker.startOffset)
+ this.emit(this.markerTypes_[type]);
+ } else if (marker.startOffset > offset) {
+ nextCheckPoint = Math.min(nextCheckPoint, marker.startOffset);
}
}
}
+ return nextCheckPoint;
}
/**
@@ -157,9 +163,10 @@ class MarkerSerializer {
const text = node.nodeValue;
/** @type {number} */
const length = text.length;
- for (let offset = 0; offset < length; ++offset) {
- this.advancedTo(node, offset);
- this.emit(text[offset]);
+ for (let offset = 0; offset < length;) {
+ const nextCheckPoint = this.advancedTo(node, offset);
+ this.emit(text.substring(offset, nextCheckPoint));
+ offset = nextCheckPoint;
}
this.advancedTo(node, length);
}
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/spelling/spelling-huge-text.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698