| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * Copyright (C) 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * | 10 * |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 this._searchNavigationElement = this._searchControlElement.createChild("div"
, "toolbar-search-navigation-controls"); | 87 this._searchNavigationElement = this._searchControlElement.createChild("div"
, "toolbar-search-navigation-controls"); |
| 88 | 88 |
| 89 this._searchNavigationPrevElement = this._searchNavigationElement.createChil
d("div", "toolbar-search-navigation toolbar-search-navigation-prev"); | 89 this._searchNavigationPrevElement = this._searchNavigationElement.createChil
d("div", "toolbar-search-navigation toolbar-search-navigation-prev"); |
| 90 this._searchNavigationPrevElement.addEventListener("click", this._onPrevButt
onSearch.bind(this), false); | 90 this._searchNavigationPrevElement.addEventListener("click", this._onPrevButt
onSearch.bind(this), false); |
| 91 this._searchNavigationPrevElement.title = WebInspector.UIString("Search Prev
ious"); | 91 this._searchNavigationPrevElement.title = WebInspector.UIString("Search Prev
ious"); |
| 92 | 92 |
| 93 this._searchNavigationNextElement = this._searchNavigationElement.createChil
d("div", "toolbar-search-navigation toolbar-search-navigation-next"); | 93 this._searchNavigationNextElement = this._searchNavigationElement.createChil
d("div", "toolbar-search-navigation toolbar-search-navigation-next"); |
| 94 this._searchNavigationNextElement.addEventListener("click", this._onNextButt
onSearch.bind(this), false); | 94 this._searchNavigationNextElement.addEventListener("click", this._onNextButt
onSearch.bind(this), false); |
| 95 this._searchNavigationNextElement.title = WebInspector.UIString("Search Next
"); | 95 this._searchNavigationNextElement.title = WebInspector.UIString("Search Next
"); |
| 96 | 96 |
| 97 this._searchInputElement.addEventListener("mousedown", this._onSearchFieldMa
nualFocus.bind(this), false); // when the search field is manually selected | |
| 98 this._searchInputElement.addEventListener("keydown", this._onSearchKeyDown.b
ind(this), true); | 97 this._searchInputElement.addEventListener("keydown", this._onSearchKeyDown.b
ind(this), true); |
| 99 this._searchInputElement.addEventListener("input", this._onInput.bind(this),
false); | 98 this._searchInputElement.addEventListener("input", this._onInput.bind(this),
false); |
| 100 | 99 |
| 101 this._replaceInputElement = this._secondRowElement.createChild("td").createC
hild("input", "search-replace toolbar-replace-control"); | 100 this._replaceInputElement = this._secondRowElement.createChild("td").createC
hild("input", "search-replace toolbar-replace-control"); |
| 102 this._replaceInputElement.addEventListener("keydown", this._onReplaceKeyDown
.bind(this), true); | 101 this._replaceInputElement.addEventListener("keydown", this._onReplaceKeyDown
.bind(this), true); |
| 103 this._replaceInputElement.placeholder = WebInspector.UIString("Replace"); | 102 this._replaceInputElement.placeholder = WebInspector.UIString("Replace"); |
| 104 | 103 |
| 105 // Column 2 | 104 // Column 2 |
| 106 this._findButtonElement = this._firstRowElement.createChild("td").createChil
d("button", "search-action-button hidden"); | 105 this._findButtonElement = this._firstRowElement.createChild("td").createChil
d("button", "search-action-button hidden"); |
| 107 this._findButtonElement.textContent = WebInspector.UIString("Find"); | 106 this._findButtonElement.textContent = WebInspector.UIString("Find"); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 * @return {boolean} | 242 * @return {boolean} |
| 244 */ | 243 */ |
| 245 isSearchVisible: function() | 244 isSearchVisible: function() |
| 246 { | 245 { |
| 247 return this._searchIsVisible; | 246 return this._searchIsVisible; |
| 248 }, | 247 }, |
| 249 | 248 |
| 250 closeSearch: function() | 249 closeSearch: function() |
| 251 { | 250 { |
| 252 this.cancelSearch(); | 251 this.cancelSearch(); |
| 253 if (WebInspector.currentFocusElement() && WebInspector.currentFocusEleme
nt().isDescendant(this._footerElementContainer)) | 252 if (this._footerElementContainer.hasFocus()) |
| 254 this.focus(); | 253 this.focus(); |
| 255 }, | 254 }, |
| 256 | 255 |
| 257 _toggleSearchBar: function(toggled) | 256 _toggleSearchBar: function(toggled) |
| 258 { | 257 { |
| 259 this._footerElementContainer.classList.toggle("hidden", !toggled); | 258 this._footerElementContainer.classList.toggle("hidden", !toggled); |
| 260 this.doResize(); | 259 this.doResize(); |
| 261 }, | 260 }, |
| 262 | 261 |
| 263 cancelSearch: function() | 262 cancelSearch: function() |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 this._matchesElement.textContent = WebInspector.UIString("%d matches
", matches); | 356 this._matchesElement.textContent = WebInspector.UIString("%d matches
", matches); |
| 358 this._updateSearchNavigationButtonState(matches > 0); | 357 this._updateSearchNavigationButtonState(matches > 0); |
| 359 }, | 358 }, |
| 360 | 359 |
| 361 showSearchField: function() | 360 showSearchField: function() |
| 362 { | 361 { |
| 363 if (this._searchIsVisible) | 362 if (this._searchIsVisible) |
| 364 this.cancelSearch(); | 363 this.cancelSearch(); |
| 365 | 364 |
| 366 var queryCandidate; | 365 var queryCandidate; |
| 367 if (WebInspector.currentFocusElement() !== this._searchInputElement) { | 366 if (!this._searchInputElement.hasFocus()) { |
| 368 var selection = this._searchInputElement.getComponentSelection(); | 367 var selection = this._searchInputElement.getComponentSelection(); |
| 369 if (selection.rangeCount) | 368 if (selection.rangeCount) |
| 370 queryCandidate = selection.toString().replace(/\r?\n.*/, ""); | 369 queryCandidate = selection.toString().replace(/\r?\n.*/, ""); |
| 371 } | 370 } |
| 372 | 371 |
| 373 this._toggleSearchBar(true); | 372 this._toggleSearchBar(true); |
| 374 this._updateReplaceVisibility(); | 373 this._updateReplaceVisibility(); |
| 375 if (queryCandidate) | 374 if (queryCandidate) |
| 376 this._searchInputElement.value = queryCandidate; | 375 this._searchInputElement.value = queryCandidate; |
| 377 this._performSearch(false, false); | 376 this._performSearch(false, false); |
| 378 this._searchInputElement.focus(); | 377 this._searchInputElement.focus(); |
| 379 this._searchInputElement.select(); | 378 this._searchInputElement.select(); |
| 380 this._searchIsVisible = true; | 379 this._searchIsVisible = true; |
| 381 }, | 380 }, |
| 382 | 381 |
| 383 _updateReplaceVisibility: function() | 382 _updateReplaceVisibility: function() |
| 384 { | 383 { |
| 385 this._replaceElement.classList.toggle("hidden", !this._replaceable); | 384 this._replaceElement.classList.toggle("hidden", !this._replaceable); |
| 386 if (!this._replaceable) { | 385 if (!this._replaceable) { |
| 387 this._replaceCheckboxElement.checked = false; | 386 this._replaceCheckboxElement.checked = false; |
| 388 this._updateSecondRowVisibility(); | 387 this._updateSecondRowVisibility(); |
| 389 } | 388 } |
| 390 }, | 389 }, |
| 391 | 390 |
| 392 /** | 391 /** |
| 393 * @param {!Event} event | 392 * @param {!Event} event |
| 394 */ | 393 */ |
| 395 _onSearchFieldManualFocus: function(event) | |
| 396 { | |
| 397 WebInspector.setCurrentFocusElement(/** @type {?Node} */ (event.target))
; | |
| 398 }, | |
| 399 | |
| 400 /** | |
| 401 * @param {!Event} event | |
| 402 */ | |
| 403 _onSearchKeyDown: function(event) | 394 _onSearchKeyDown: function(event) |
| 404 { | 395 { |
| 405 if (isEscKey(event)) { | 396 if (isEscKey(event)) { |
| 406 this.closeSearch(); | 397 this.closeSearch(); |
| 407 event.consume(true); | 398 event.consume(true); |
| 408 return; | 399 return; |
| 409 } | 400 } |
| 410 if (!isEnterKey(event)) | 401 if (!isEnterKey(event)) |
| 411 return; | 402 return; |
| 412 | 403 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 // Silent catch. | 648 // Silent catch. |
| 658 } | 649 } |
| 659 | 650 |
| 660 // Otherwise just do a plain text search. | 651 // Otherwise just do a plain text search. |
| 661 if (!regex) | 652 if (!regex) |
| 662 regex = createPlainTextSearchRegex(query, modifiers); | 653 regex = createPlainTextSearchRegex(query, modifiers); |
| 663 | 654 |
| 664 return regex; | 655 return regex; |
| 665 } | 656 } |
| 666 } | 657 } |
| OLD | NEW |