Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 } | 457 } |
| 458 | 458 |
| 459 /** | 459 /** |
| 460 * @override | 460 * @override |
| 461 * @param {!UI.SearchableView.SearchConfig} searchConfig | 461 * @param {!UI.SearchableView.SearchConfig} searchConfig |
| 462 * @param {boolean} shouldJump | 462 * @param {boolean} shouldJump |
| 463 * @param {boolean=} jumpBackwards | 463 * @param {boolean=} jumpBackwards |
| 464 */ | 464 */ |
| 465 performSearch(searchConfig, shouldJump, jumpBackwards) { | 465 performSearch(searchConfig, shouldJump, jumpBackwards) { |
| 466 var query = searchConfig.query; | 466 var query = searchConfig.query; |
| 467 // Call searchCanceled since it will reset everything we need before doing a new search. | 467 this._hideSearchHighlights(); |
| 468 this.searchCanceled(); | |
| 469 | 468 |
| 470 const whitespaceTrimmedQuery = query.trim(); | 469 const whitespaceTrimmedQuery = query.trim(); |
| 471 if (!whitespaceTrimmedQuery.length) | 470 if (!whitespaceTrimmedQuery.length) |
| 472 return; | 471 return; |
| 473 | 472 |
| 474 this._searchQuery = query; | 473 this._searchQuery = query; |
| 475 | 474 |
| 476 var promises = []; | 475 var promises = []; |
| 477 var domModels = SDK.DOMModel.instances(); | 476 var domModels = SDK.DOMModel.instances(); |
| 478 for (var domModel of domModels) { | 477 for (var domModel of domModels) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 491 */ | 490 */ |
| 492 this._searchResults = []; | 491 this._searchResults = []; |
| 493 for (var i = 0; i < resultCounts.length; ++i) { | 492 for (var i = 0; i < resultCounts.length; ++i) { |
| 494 var resultCount = resultCounts[i]; | 493 var resultCount = resultCounts[i]; |
| 495 for (var j = 0; j < resultCount; ++j) | 494 for (var j = 0; j < resultCount; ++j) |
| 496 this._searchResults.push({domModel: domModels[i], index: j, node: unde fined}); | 495 this._searchResults.push({domModel: domModels[i], index: j, node: unde fined}); |
| 497 } | 496 } |
| 498 this._searchableView.updateSearchMatchesCount(this._searchResults.length); | 497 this._searchableView.updateSearchMatchesCount(this._searchResults.length); |
| 499 if (!this._searchResults.length) | 498 if (!this._searchResults.length) |
| 500 return; | 499 return; |
| 501 this._currentSearchResultIndex = -1; | 500 if (this._currentSearchResultIndex === undefined || this._currentSearchRes ultIndex > this._searchResults.length) |
| 501 this._currentSearchResultIndex = -1; | |
| 502 | 502 |
| 503 if (shouldJump) | 503 var index = this._currentSearchResultIndex; |
| 504 this._jumpToSearchResult(jumpBackwards ? -1 : 0); | 504 |
| 505 if (shouldJump) { | |
| 506 if (index === -1) | |
| 507 index = jumpBackwards ? -1 : 0; | |
| 508 else | |
| 509 index = jumpBackwards ? index - 1 : index + 1; | |
| 510 this._jumpToSearchResult(index); | |
| 511 } | |
| 505 } | 512 } |
| 506 } | 513 } |
| 507 | 514 |
| 508 _domWordWrapSettingChanged(event) { | 515 _domWordWrapSettingChanged(event) { |
| 509 // FIXME: crbug.com/425984 | 516 // FIXME: crbug.com/425984 |
| 510 this._contentElement.classList.toggle('elements-wrap', event.data); | 517 this._contentElement.classList.toggle('elements-wrap', event.data); |
| 511 for (var i = 0; i < this._treeOutlines.length; ++i) | 518 for (var i = 0; i < this._treeOutlines.length; ++i) |
| 512 this._treeOutlines[i].setWordWrap(/** @type {boolean} */ (event.data)); | 519 this._treeOutlines[i].setWordWrap(/** @type {boolean} */ (event.data)); |
| 513 } | 520 } |
| 514 | 521 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 */ | 553 */ |
| 547 function showPopover(contents) { | 554 function showPopover(contents) { |
| 548 if (!contents) | 555 if (!contents) |
| 549 return; | 556 return; |
| 550 popover.setCanShrink(false); | 557 popover.setCanShrink(false); |
| 551 popover.showForAnchor(contents, link); | 558 popover.showForAnchor(contents, link); |
| 552 } | 559 } |
| 553 } | 560 } |
| 554 | 561 |
| 555 _jumpToSearchResult(index) { | 562 _jumpToSearchResult(index) { |
| 556 this._hideSearchHighlights(); | |
|
Oleksii Kadurin
2017/02/07 23:57:18
Removed this one because from now every request fo
| |
| 557 this._currentSearchResultIndex = (index + this._searchResults.length) % this ._searchResults.length; | 563 this._currentSearchResultIndex = (index + this._searchResults.length) % this ._searchResults.length; |
| 558 this._highlightCurrentSearchResult(); | 564 this._highlightCurrentSearchResult(); |
| 559 } | 565 } |
| 560 | 566 |
| 561 /** | 567 /** |
| 562 * @override | 568 * @override |
| 563 */ | 569 */ |
| 564 jumpToNextSearchResult() { | 570 jumpToNextSearchResult() { |
| 565 if (!this._searchResults) | 571 if (!this._searchResults) |
| 566 return; | 572 return; |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 * @param {!SDK.DOMNode} node | 1065 * @param {!SDK.DOMNode} node |
| 1060 * @return {?{title: string, color: string}} | 1066 * @return {?{title: string, color: string}} |
| 1061 */ | 1067 */ |
| 1062 decorate(node) { | 1068 decorate(node) { |
| 1063 return { | 1069 return { |
| 1064 color: 'orange', | 1070 color: 'orange', |
| 1065 title: Common.UIString('Element state: %s', ':' + SDK.CSSModel.fromNode(no de).pseudoState(node).join(', :')) | 1071 title: Common.UIString('Element state: %s', ':' + SDK.CSSModel.fromNode(no de).pseudoState(node).join(', :')) |
| 1066 }; | 1072 }; |
| 1067 } | 1073 } |
| 1068 }; | 1074 }; |
| OLD | NEW |