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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/SearchableView.js

Issue 2672083004: [DevTools] Search in Elements tab is not working for newly added elements (Closed)
Patch Set: Created 3 years, 10 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 /* 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 if (!this._searchInputElement.hasFocus()) { 345 if (!this._searchInputElement.hasFocus()) {
346 var selection = this._searchInputElement.getComponentSelection(); 346 var selection = this._searchInputElement.getComponentSelection();
347 if (selection.rangeCount) 347 if (selection.rangeCount)
348 queryCandidate = selection.toString().replace(/\r?\n.*/, ''); 348 queryCandidate = selection.toString().replace(/\r?\n.*/, '');
349 } 349 }
350 350
351 this._toggleSearchBar(true); 351 this._toggleSearchBar(true);
352 this._updateReplaceVisibility(); 352 this._updateReplaceVisibility();
353 if (queryCandidate) 353 if (queryCandidate)
354 this._searchInputElement.value = queryCandidate; 354 this._searchInputElement.value = queryCandidate;
355 this._searchProvider.searchCanceled();
Oleksii Kadurin 2017/02/07 20:20:24 Reset search by explicit invocation of .searchCanc
pfeldman 2017/02/07 23:19:36 This might come unexpected to the provider, why do
Oleksii Kadurin 2017/02/07 23:57:18 It was the part of performSearch function (in the
pfeldman 2017/02/08 01:52:41 Right, but you are changing this contract for all
Oleksii Kadurin 2017/02/08 18:49:14 I've got it now. Thanks!
355 this._performSearch(false, false); 356 this._performSearch(false, false);
356 this._searchInputElement.focus(); 357 this._searchInputElement.focus();
357 this._searchInputElement.select(); 358 this._searchInputElement.select();
358 this._searchIsVisible = true; 359 this._searchIsVisible = true;
359 } 360 }
360 361
361 _updateReplaceVisibility() { 362 _updateReplaceVisibility() {
362 this._replaceElement.classList.toggle('hidden', !this._replaceable); 363 this._replaceElement.classList.toggle('hidden', !this._replaceable);
363 if (!this._replaceable) { 364 if (!this._replaceable) {
364 this._replaceCheckboxElement.checked = false; 365 this._replaceCheckboxElement.checked = false;
365 this._updateSecondRowVisibility(); 366 this._updateSecondRowVisibility();
366 } 367 }
367 } 368 }
368 369
369 /** 370 /**
370 * @param {!Event} event 371 * @param {!Event} event
371 */ 372 */
372 _onSearchKeyDown(event) { 373 _onSearchKeyDown(event) {
373 if (isEscKey(event)) { 374 if (isEscKey(event)) {
374 this.closeSearch(); 375 this.closeSearch();
375 event.consume(true); 376 event.consume(true);
376 return; 377 return;
377 } 378 }
378 if (!isEnterKey(event)) 379 if (!isEnterKey(event))
379 return; 380 return;
380 381
381 if (!this._currentQuery) 382 if (!this._currentQuery)
382 this._performSearch(true, true, event.shiftKey); 383 this._clearSearch();
383 else 384 else
384 this._jumpToNextSearchResult(event.shiftKey); 385 this._performSearch(false, true, event.shiftKey);
385 } 386 }
386 387
387 /** 388 /**
388 * @param {!Event} event 389 * @param {!Event} event
389 */ 390 */
390 _onReplaceKeyDown(event) { 391 _onReplaceKeyDown(event) {
391 if (isEnterKey(event)) 392 if (isEnterKey(event))
392 this._replace(); 393 this._replace();
393 } 394 }
394 395
395 /** 396 /**
396 * @param {boolean=} isBackwardSearch 397 * @param {boolean=} isBackwardSearch
397 */ 398 */
398 _jumpToNextSearchResult(isBackwardSearch) { 399 _jumpToNextSearchResult(isBackwardSearch) {
399 if (!this._currentQuery || !this._searchNavigationPrevElement.classList.cont ains('enabled')) 400 if (!this._currentQuery || !this._searchNavigationPrevElement.classList.cont ains('enabled'))
400 return; 401 return;
401 402
402 if (isBackwardSearch) 403 if (isBackwardSearch)
403 this._searchProvider.jumpToPreviousSearchResult(); 404 this._searchProvider.jumpToPreviousSearchResult();
404 else 405 else
405 this._searchProvider.jumpToNextSearchResult(); 406 this._searchProvider.jumpToNextSearchResult();
406 } 407 }
407 408
408 _onNextButtonSearch(event) { 409 _onNextButtonSearch(event) {
409 if (!this._searchNavigationNextElement.classList.contains('enabled')) 410 if (!this._searchNavigationNextElement.classList.contains('enabled'))
410 return; 411 return;
411 this._jumpToNextSearchResult(); 412 this._performSearch(false, true);
412 this._searchInputElement.focus(); 413 this._searchInputElement.focus();
413 } 414 }
414 415
415 _onPrevButtonSearch(event) { 416 _onPrevButtonSearch(event) {
416 if (!this._searchNavigationPrevElement.classList.contains('enabled')) 417 if (!this._searchNavigationPrevElement.classList.contains('enabled'))
417 return; 418 return;
418 this._jumpToNextSearchResult(true); 419 this._performSearch(false, true, true);
419 this._searchInputElement.focus(); 420 this._searchInputElement.focus();
420 } 421 }
421 422
422 _onFindClick(event) { 423 _onFindClick(event) {
423 if (!this._currentQuery) 424 if (!this._currentQuery)
424 this._performSearch(true, true); 425 this._performSearch(true, true);
425 else 426 else
426 this._jumpToNextSearchResult(); 427 this._jumpToNextSearchResult();
427 this._searchInputElement.focus(); 428 this._searchInputElement.focus();
428 } 429 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 if (this._valueChangedTimeoutId) 510 if (this._valueChangedTimeoutId)
510 clearTimeout(this._valueChangedTimeoutId); 511 clearTimeout(this._valueChangedTimeoutId);
511 var timeout = this._searchInputElement.value.length < 3 ? 200 : 0; 512 var timeout = this._searchInputElement.value.length < 3 ? 200 : 0;
512 this._valueChangedTimeoutId = setTimeout(this._onValueChanged.bind(this), ti meout); 513 this._valueChangedTimeoutId = setTimeout(this._onValueChanged.bind(this), ti meout);
513 } 514 }
514 515
515 _onValueChanged() { 516 _onValueChanged() {
516 if (!this._searchIsVisible) 517 if (!this._searchIsVisible)
517 return; 518 return;
518 delete this._valueChangedTimeoutId; 519 delete this._valueChangedTimeoutId;
520 this._searchProvider.searchCanceled();
Oleksii Kadurin 2017/02/07 20:20:24 Reset search by explicit invocation of .searchCanc
pfeldman 2017/02/07 23:19:36 That seems fine.
519 this._performSearch(false, true); 521 this._performSearch(false, true);
520 } 522 }
521 }; 523 };
522 524
523 UI.SearchableView._lastUniqueId = 0; 525 UI.SearchableView._lastUniqueId = 0;
524 526
525 UI.SearchableView._symbol = Symbol('searchableView'); 527 UI.SearchableView._symbol = Symbol('searchableView');
526 528
527 529
528 /** 530 /**
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 // Silent catch. 613 // Silent catch.
612 } 614 }
613 615
614 // Otherwise just do a plain text search. 616 // Otherwise just do a plain text search.
615 if (!regex) 617 if (!regex)
616 regex = createPlainTextSearchRegex(query, modifiers); 618 regex = createPlainTextSearchRegex(query, modifiers);
617 619
618 return regex; 620 return regex;
619 } 621 }
620 }; 622 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698