OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium 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 package org.chromium.chrome.browser.contextualsearch; | 5 package org.chromium.chrome.browser.contextualsearch; |
6 | 6 |
7 import android.os.Handler; | 7 import android.os.Handler; |
8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
9 | 9 |
10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 | 423 |
424 if (selectionStartAdjust == 0 && selectionEndAdjust == 0) return; | 424 if (selectionStartAdjust == 0 && selectionEndAdjust == 0) return; |
425 ContentViewCore basePageContentView = getBaseContentView(); | 425 ContentViewCore basePageContentView = getBaseContentView(); |
426 if (basePageContentView != null && basePageContentView.getWebContents() != null) { | 426 if (basePageContentView != null && basePageContentView.getWebContents() != null) { |
427 mDidExpandSelection = true; | 427 mDidExpandSelection = true; |
428 basePageContentView.getWebContents().adjustSelectionByCharacterOffse t( | 428 basePageContentView.getWebContents().adjustSelectionByCharacterOffse t( |
429 selectionStartAdjust, selectionEndAdjust); | 429 selectionStartAdjust, selectionEndAdjust); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 /** | |
434 * Acknowledges that a selectWordAroundCaret action has completed with the g ive result. | |
435 * @param didSelect Whether a word was actually selected or not. | |
436 * @param startAdjust The adjustment to the selection start offset needed to select the word. | |
437 * This is typically a negative number (expressed in terms of number of characters). | |
438 * @param endAdjust The adjustment to the selection end offset needed to sel ect the word. | |
439 * This is typically a positive number (expressed in terms of number of characters). | |
440 */ | |
441 void selectWordAroundCaretAck(boolean didSelect, int startAdjust, int endAdj ust) { | |
442 // TODO(donnd): use startAdjust and endAdjust in upcoming text-extractio n CL (started). | |
aelias_OOO_until_Jul13
2017/02/22 03:36:00
You're planning to use these offsets to issue anot
Donn Denman
2017/02/22 23:13:01
Actually we plan to just use these to convert some
| |
443 if (!didSelect) mHandler.handleInvalidTap(); | |
aelias_OOO_until_Jul13
2017/02/22 03:36:00
This seems a bit upside down. How about doing not
Donn Denman
2017/02/22 23:13:01
I think this will look much better once the depend
| |
444 } | |
445 | |
433 // ========================================================================= =================== | 446 // ========================================================================= =================== |
434 // Invalid Tap Notification | 447 // Invalid Tap Notification |
435 // ========================================================================= =================== | 448 // ========================================================================= =================== |
436 | 449 |
437 /** | 450 /** |
438 * Schedules a notification to check if the tap was invalid. | 451 * Schedules a notification to check if the tap was invalid. |
439 * When we call selectWordAroundCaret it selects nothing in cases where the tap was invalid. | 452 * When we call selectWordAroundCaret it selects nothing in cases where the tap was invalid. |
440 * We have no way to know other than scheduling a notification to check late r. | 453 * We have no way to know other than scheduling a notification to check late r. |
441 * This allows us to hide the bar when there's no selection. | 454 * This allows us to hide the bar when there's no selection. |
442 */ | 455 */ |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 // Starts are inclusive and ends are non-inclusive for both GSAContext & matcher. | 607 // Starts are inclusive and ends are non-inclusive for both GSAContext & matcher. |
595 while (matcher.find()) { | 608 while (matcher.find()) { |
596 if (startOffset >= matcher.start() && endOffset <= matcher.end()) { | 609 if (startOffset >= matcher.start() && endOffset <= matcher.end()) { |
597 return true; | 610 return true; |
598 } | 611 } |
599 } | 612 } |
600 | 613 |
601 return false; | 614 return false; |
602 } | 615 } |
603 } | 616 } |
OLD | NEW |