| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project 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 "use strict"; | 5 "use strict"; |
| 6 | 6 |
| 7 class TextView extends View { | 7 class TextView extends View { |
| 8 constructor(id, broker, patterns, allowSpanSelection) { | 8 constructor(id, broker, patterns, allowSpanSelection) { |
| 9 super(id, broker); | 9 super(id, broker); |
| 10 let view = this; | 10 let view = this; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 function(a,b) { return a - b; }); | 161 function(a,b) { return a - b; }); |
| 162 this.positionNodeMap.sort(function(a,b) { | 162 this.positionNodeMap.sort(function(a,b) { |
| 163 let result = view.nodePositionMap[a] - view.nodePositionMap[b]; | 163 let result = view.nodePositionMap[a] - view.nodePositionMap[b]; |
| 164 if (result != 0) return result; | 164 if (result != 0) return result; |
| 165 return a - b; | 165 return a - b; |
| 166 }); | 166 }); |
| 167 } | 167 } |
| 168 | 168 |
| 169 selectLocations(locations, selected, makeVisible) { | 169 selectLocations(locations, selected, makeVisible) { |
| 170 let view = this; | 170 let view = this; |
| 171 let s = new Set(); |
| 171 for (let l of locations) { | 172 for (let l of locations) { |
| 172 for (let i = 0; i < view.textListNode.children.length; ++i) { | 173 for (let i = 0; i < view.textListNode.children.length; ++i) { |
| 173 let child = view.textListNode.children[i]; | 174 let child = view.textListNode.children[i]; |
| 174 if (child.location != undefined && view.sameLocation(l, child.location))
{ | 175 if (child.location != undefined && view.sameLocation(l, child.location))
{ |
| 175 view.selectCommon(child, selected, makeVisible); | 176 s.add(child); |
| 176 } | 177 } |
| 177 } | 178 } |
| 178 } | 179 } |
| 180 view.selectCommon(s, selected, makeVisible); |
| 179 } | 181 } |
| 180 | 182 |
| 181 getRanges(items) { | 183 getRanges(items) { |
| 182 let result = []; | 184 let result = []; |
| 183 let lastObject = null; | 185 let lastObject = null; |
| 184 for (let i of items) { | 186 for (let i of items) { |
| 185 if (i.location) { | 187 if (i.location) { |
| 186 let location = i.location; | 188 let location = i.location; |
| 187 let start = -1; | 189 let start = -1; |
| 188 let end = -1; | 190 let end = -1; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 for (let i = 0; i < view.textListNode.children.length; ++i) { | 296 for (let i = 0; i < view.textListNode.children.length; ++i) { |
| 295 let child = view.textListNode.children[i]; | 297 let child = view.textListNode.children[i]; |
| 296 if (child.location && s(child.location)) { | 298 if (child.location && s(child.location)) { |
| 297 if (firstSelect) { | 299 if (firstSelect) { |
| 298 makeContainerPosVisible(view.parentNode, child.offsetTop); | 300 makeContainerPosVisible(view.parentNode, child.offsetTop); |
| 299 firstSelect = false; | 301 firstSelect = false; |
| 300 } | 302 } |
| 301 view.selection.select(child, selected); | 303 view.selection.select(child, selected); |
| 302 } | 304 } |
| 303 } | 305 } |
| 304 } else if (s.length) { | 306 } else if (typeof s[Symbol.iterator] === 'function') { |
| 305 for (let i of s) { | 307 for (let i of s) { |
| 306 if (firstSelect) { | 308 if (firstSelect) { |
| 307 makeContainerPosVisible(view.parentNode, i.offsetTop); | 309 makeContainerPosVisible(view.parentNode, i.offsetTop); |
| 308 firstSelect = false; | 310 firstSelect = false; |
| 309 } | 311 } |
| 310 view.selection.select(i, selected); | 312 view.selection.select(i, selected); |
| 311 } | 313 } |
| 312 } else { | 314 } else { |
| 313 if (firstSelect) { | 315 if (firstSelect) { |
| 314 makeContainerPosVisible(view.parentNode, s.offsetTop); | 316 makeContainerPosVisible(view.parentNode, s.offsetTop); |
| 315 firstSelect = false; | |
| 316 } | 317 } |
| 317 view.selection.select(s, selected); | 318 view.selection.select(s, selected); |
| 318 } | 319 } |
| 319 } | 320 } |
| 320 | 321 |
| 321 mouseDownLine(li, e) { | 322 mouseDownLine(li, e) { |
| 322 let view = this; | 323 let view = this; |
| 323 e.stopPropagation(); | 324 e.stopPropagation(); |
| 324 if (!e.shiftKey) { | 325 if (!e.shiftKey) { |
| 325 view.selection.clear(); | 326 view.selection.clear(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 let lineLocation = view.lineLocation(li); | 362 let lineLocation = view.lineLocation(li); |
| 362 if (lineLocation != undefined) { | 363 if (lineLocation != undefined) { |
| 363 li.location = lineLocation; | 364 li.location = lineLocation; |
| 364 } | 365 } |
| 365 view.textListNode.appendChild(li); | 366 view.textListNode.appendChild(li); |
| 366 } | 367 } |
| 367 } | 368 } |
| 368 | 369 |
| 369 initializeContent(data, rememberedSelection) { | 370 initializeContent(data, rememberedSelection) { |
| 370 let view = this; | 371 let view = this; |
| 372 view.selection.clear(); |
| 371 view.clearText(); | 373 view.clearText(); |
| 372 view.processText(data); | 374 view.processText(data); |
| 373 var fillerSize = document.documentElement.clientHeight - | 375 var fillerSize = document.documentElement.clientHeight - |
| 374 view.textListNode.clientHeight; | 376 view.textListNode.clientHeight; |
| 375 if (fillerSize < 0) { | 377 if (fillerSize < 0) { |
| 376 fillerSize = 0; | 378 fillerSize = 0; |
| 377 } | 379 } |
| 378 view.fillerSvgElement.attr("height", fillerSize); | 380 view.fillerSvgElement.attr("height", fillerSize); |
| 379 } | 381 } |
| 380 | 382 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 392 lineLocation(li) { | 394 lineLocation(li) { |
| 393 let view = this; | 395 let view = this; |
| 394 for (let i = 0; i < li.children.length; ++i) { | 396 for (let i = 0; i < li.children.length; ++i) { |
| 395 let fragment = li.children[i]; | 397 let fragment = li.children[i]; |
| 396 if (fragment.location != undefined && !view.allowSpanSelection) { | 398 if (fragment.location != undefined && !view.allowSpanSelection) { |
| 397 return fragment.location; | 399 return fragment.location; |
| 398 } | 400 } |
| 399 } | 401 } |
| 400 } | 402 } |
| 401 } | 403 } |
| OLD | NEW |