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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 delete this._searchResults; | 454 delete this._searchResults; |
| 455 | 455 |
| 456 SDK.DOMModel.cancelSearch(); | 456 SDK.DOMModel.cancelSearch(); |
| 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 * @param {boolean=} reset | |
| 464 */ | 465 */ |
| 465 performSearch(searchConfig, shouldJump, jumpBackwards) { | 466 performSearch(searchConfig, shouldJump, jumpBackwards, reset) { |
| 466 var query = searchConfig.query; | 467 var query = searchConfig.query; |
| 467 // Call searchCanceled since it will reset everything we need before doing a new search. | 468 if (reset) |
| 468 this.searchCanceled(); | 469 // Call searchCanceled since it will reset everything we need before doing a new search. |
| 470 this.searchCanceled(); | |
| 471 else | |
| 472 this._hideSearchHighlights(); | |
| 469 | 473 |
| 470 const whitespaceTrimmedQuery = query.trim(); | 474 const whitespaceTrimmedQuery = query.trim(); |
| 471 if (!whitespaceTrimmedQuery.length) | 475 if (!whitespaceTrimmedQuery.length) |
| 472 return; | 476 return; |
| 473 | 477 |
| 474 this._searchQuery = query; | 478 this._searchQuery = query; |
| 475 | 479 |
| 476 var promises = []; | 480 var promises = []; |
| 477 var domModels = SDK.DOMModel.instances(); | 481 var domModels = SDK.DOMModel.instances(); |
| 478 for (var domModel of domModels) { | 482 for (var domModel of domModels) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 491 */ | 495 */ |
| 492 this._searchResults = []; | 496 this._searchResults = []; |
| 493 for (var i = 0; i < resultCounts.length; ++i) { | 497 for (var i = 0; i < resultCounts.length; ++i) { |
| 494 var resultCount = resultCounts[i]; | 498 var resultCount = resultCounts[i]; |
| 495 for (var j = 0; j < resultCount; ++j) | 499 for (var j = 0; j < resultCount; ++j) |
| 496 this._searchResults.push({domModel: domModels[i], index: j, node: unde fined}); | 500 this._searchResults.push({domModel: domModels[i], index: j, node: unde fined}); |
| 497 } | 501 } |
| 498 this._searchableView.updateSearchMatchesCount(this._searchResults.length); | 502 this._searchableView.updateSearchMatchesCount(this._searchResults.length); |
| 499 if (!this._searchResults.length) | 503 if (!this._searchResults.length) |
| 500 return; | 504 return; |
| 501 this._currentSearchResultIndex = -1; | 505 if (reset || typeof this._currentSearchResultIndex === 'undefined') |
| 506 this._currentSearchResultIndex = -1; | |
| 502 | 507 |
| 503 if (shouldJump) | 508 var index = this._currentSearchResultIndex; |
| 504 this._jumpToSearchResult(jumpBackwards ? -1 : 0); | 509 |
| 510 if (shouldJump) { | |
| 511 if (index === -1) | |
| 512 index = jumpBackwards ? -1 : 0; | |
| 513 else | |
| 514 index = jumpBackwards ? index - 1 : index + 1; | |
| 515 this._jumpToSearchResult(index); | |
| 516 } | |
| 505 } | 517 } |
| 506 } | 518 } |
| 507 | 519 |
| 508 _domWordWrapSettingChanged(event) { | 520 _domWordWrapSettingChanged(event) { |
| 509 // FIXME: crbug.com/425984 | 521 // FIXME: crbug.com/425984 |
| 510 this._contentElement.classList.toggle('elements-wrap', event.data); | 522 this._contentElement.classList.toggle('elements-wrap', event.data); |
| 511 for (var i = 0; i < this._treeOutlines.length; ++i) | 523 for (var i = 0; i < this._treeOutlines.length; ++i) |
| 512 this._treeOutlines[i].setWordWrap(/** @type {boolean} */ (event.data)); | 524 this._treeOutlines[i].setWordWrap(/** @type {boolean} */ (event.data)); |
| 513 } | 525 } |
| 514 | 526 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 function showPopover(contents) { | 559 function showPopover(contents) { |
| 548 if (!contents) | 560 if (!contents) |
| 549 return; | 561 return; |
| 550 popover.setCanShrink(false); | 562 popover.setCanShrink(false); |
| 551 popover.showForAnchor(contents, link); | 563 popover.showForAnchor(contents, link); |
| 552 } | 564 } |
| 553 } | 565 } |
| 554 | 566 |
| 555 _jumpToSearchResult(index) { | 567 _jumpToSearchResult(index) { |
| 556 this._hideSearchHighlights(); | 568 this._hideSearchHighlights(); |
| 557 this._currentSearchResultIndex = (index + this._searchResults.length) % this ._searchResults.length; | 569 if (index > this._searchResults.length) |
| 570 this._currentSearchResultIndex = 0; | |
| 571 else | |
| 572 this._currentSearchResultIndex = (index + this._searchResults.length) % th is._searchResults.length; | |
| 558 this._highlightCurrentSearchResult(); | 573 this._highlightCurrentSearchResult(); |
| 559 } | 574 } |
| 560 | 575 |
| 561 /** | 576 /** |
| 562 * @override | 577 * @override |
| 563 */ | 578 */ |
| 564 jumpToNextSearchResult() { | 579 jumpToNextSearchResult() { |
| 565 if (!this._searchResults) | 580 if (!this._searchResults) |
|
pfeldman
2017/02/06 19:24:53
Can we instead just call performSearch(sameConfig,
Oleksii Kadurin
2017/02/07 20:20:24
If you are talking about resetting this._currentSe
| |
| 566 return; | 581 return; |
| 567 this._jumpToSearchResult(this._currentSearchResultIndex + 1); | 582 this._jumpToSearchResult(this._currentSearchResultIndex + 1); |
| 568 } | 583 } |
| 569 | 584 |
| 570 /** | 585 /** |
| 571 * @override | 586 * @override |
| 572 */ | 587 */ |
| 573 jumpToPreviousSearchResult() { | 588 jumpToPreviousSearchResult() { |
| 574 if (!this._searchResults) | 589 if (!this._searchResults) |
|
pfeldman
2017/02/06 19:24:53
performSearch(sameConfig, true, true)
| |
| 575 return; | 590 return; |
| 576 this._jumpToSearchResult(this._currentSearchResultIndex - 1); | 591 this._jumpToSearchResult(this._currentSearchResultIndex - 1); |
| 577 } | 592 } |
| 578 | 593 |
| 579 /** | 594 /** |
| 580 * @override | 595 * @override |
| 581 * @return {boolean} | 596 * @return {boolean} |
| 582 */ | 597 */ |
| 583 supportsCaseSensitiveSearch() { | 598 supportsCaseSensitiveSearch() { |
| 584 return false; | 599 return false; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 if (treeElement) { | 638 if (treeElement) { |
| 624 treeElement.highlightSearchResults(this._searchQuery); | 639 treeElement.highlightSearchResults(this._searchQuery); |
| 625 treeElement.reveal(); | 640 treeElement.reveal(); |
| 626 var matches = treeElement.listItemElement.getElementsByClassName(UI.highli ghtedSearchResultClassName); | 641 var matches = treeElement.listItemElement.getElementsByClassName(UI.highli ghtedSearchResultClassName); |
| 627 if (matches.length) | 642 if (matches.length) |
| 628 matches[0].scrollIntoViewIfNeeded(false); | 643 matches[0].scrollIntoViewIfNeeded(false); |
| 629 } | 644 } |
| 630 } | 645 } |
| 631 | 646 |
| 632 _hideSearchHighlights() { | 647 _hideSearchHighlights() { |
| 633 if (!this._searchResults || !this._searchResults.length || this._currentSear chResultIndex < 0) | 648 if (!this._searchResults || !this._searchResults.length || this._currentSear chResultIndex < 0 || |
| 649 this._currentSearchResultIndex > this._searchResults.length - 1) | |
| 634 return; | 650 return; |
| 635 var searchResult = this._searchResults[this._currentSearchResultIndex]; | 651 var searchResult = this._searchResults[this._currentSearchResultIndex]; |
| 636 if (!searchResult.node) | 652 if (!searchResult.node) |
| 637 return; | 653 return; |
| 638 var treeOutline = Elements.ElementsTreeOutline.forDOMModel(searchResult.node .domModel()); | 654 var treeOutline = Elements.ElementsTreeOutline.forDOMModel(searchResult.node .domModel()); |
| 639 var treeElement = treeOutline.findTreeElement(searchResult.node); | 655 var treeElement = treeOutline.findTreeElement(searchResult.node); |
| 640 if (treeElement) | 656 if (treeElement) |
| 641 treeElement.hideSearchHighlights(); | 657 treeElement.hideSearchHighlights(); |
| 642 } | 658 } |
| 643 | 659 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 * @param {!SDK.DOMNode} node | 1075 * @param {!SDK.DOMNode} node |
| 1060 * @return {?{title: string, color: string}} | 1076 * @return {?{title: string, color: string}} |
| 1061 */ | 1077 */ |
| 1062 decorate(node) { | 1078 decorate(node) { |
| 1063 return { | 1079 return { |
| 1064 color: 'orange', | 1080 color: 'orange', |
| 1065 title: Common.UIString('Element state: %s', ':' + SDK.CSSModel.fromNode(no de).pseudoState(node).join(', :')) | 1081 title: Common.UIString('Element state: %s', ':' + SDK.CSSModel.fromNode(no de).pseudoState(node).join(', :')) |
| 1066 }; | 1082 }; |
| 1067 } | 1083 } |
| 1068 }; | 1084 }; |
| OLD | NEW |