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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/formatter_worker/HTMLFormatter.js

Issue 1835783002: DevTools: simplify WI.FormattedContentBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaseline tests Created 4 years, 8 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @param {!WebInspector.FormattedContentBuilder} builder 7 * @param {!WebInspector.FormattedContentBuilder} builder
8 */ 8 */
9 WebInspector.HTMLFormatter = function(builder) 9 WebInspector.HTMLFormatter = function(builder)
10 { 10 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 * @param {number} tokenStart 42 * @param {number} tokenStart
43 * @param {number} tokenEnd 43 * @param {number} tokenEnd
44 * @return {(!Object|undefined)} 44 * @return {(!Object|undefined)}
45 * @this {WebInspector.HTMLFormatter} 45 * @this {WebInspector.HTMLFormatter}
46 */ 46 */
47 function processToken(tokenValue, type, tokenStart, tokenEnd) 47 function processToken(tokenValue, type, tokenStart, tokenEnd)
48 { 48 {
49 tokenStart += fromOffset; 49 tokenStart += fromOffset;
50 tokenEnd += fromOffset; 50 tokenEnd += fromOffset;
51 lastOffset = tokenEnd; 51 lastOffset = tokenEnd;
52 var startLine = lineEndings.lowerBound(tokenStart); 52 this._builder.addToken(tokenValue, tokenStart);
53 var endLine = lineEndings.lowerBound(tokenEnd);
54 this._builder.addToken(tokenValue, tokenStart, startLine, endLine);
55 53
56 if (!type) 54 if (!type)
57 return; 55 return;
58 var tokenType = type.split(" ").keySet(); 56 var tokenType = type.split(" ").keySet();
59 if (!tokenType["tag"]) 57 if (!tokenType["tag"])
60 return; 58 return;
61 59
62 if (tokenType["bracket"] && (tokenValue === "<" || tokenValue === "< /")) { 60 if (tokenType["bracket"] && (tokenValue === "<" || tokenValue === "< /")) {
63 accumulatedTokenValue = tokenValue; 61 accumulatedTokenValue = tokenValue;
64 return; 62 return;
65 } 63 }
66 64
67 if (tagName && tokenValue === ">") 65 if (tagName && tokenValue === ">")
68 return WebInspector.AbortTokenization; 66 return WebInspector.AbortTokenization;
69 67
70 accumulatedTokenValue = accumulatedTokenValue + tokenValue.toLowerCa se(); 68 accumulatedTokenValue = accumulatedTokenValue + tokenValue.toLowerCa se();
71 if (accumulatedTokenValue === "<script" || accumulatedTokenValue === "<style") 69 if (accumulatedTokenValue === "<script" || accumulatedTokenValue === "<style")
72 tagName = accumulatedTokenValue.substring(1); 70 tagName = accumulatedTokenValue.substring(1);
73 accumulatedTokenValue = ""; 71 accumulatedTokenValue = "";
74 } 72 }
75 var tokenizer = WebInspector.createTokenizer("text/html"); 73 var tokenizer = WebInspector.createTokenizer("text/html");
76 tokenizer(content, processToken.bind(this)); 74 tokenizer(content, processToken.bind(this));
77 return new WebInspector.HTMLFormatter.Result(tagName, lastOffset); 75 return new WebInspector.HTMLFormatter.Result(tagName, lastOffset);
78 }, 76 },
79 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698