| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // column where the next hit has been found. Doing this when autosizing is | 163 // column where the next hit has been found. Doing this when autosizing is |
| 164 // not set will result in a zoom reset on small devices. | 164 // not set will result in a zoom reset on small devices. |
| 165 if (OwnerFrame() | 165 if (OwnerFrame() |
| 166 .GetFrame() | 166 .GetFrame() |
| 167 ->GetDocument() | 167 ->GetDocument() |
| 168 ->GetTextAutosizer() | 168 ->GetTextAutosizer() |
| 169 ->PageNeedsAutosizing()) { | 169 ->PageNeedsAutosizing()) { |
| 170 OwnerFrame().ViewImpl()->ZoomToFindInPageRect( | 170 OwnerFrame().ViewImpl()->ZoomToFindInPageRect( |
| 171 OwnerFrame().GetFrameView()->ContentsToRootFrame( | 171 OwnerFrame().GetFrameView()->ContentsToRootFrame( |
| 172 EnclosingIntRect(LayoutObject::AbsoluteBoundingBoxRectForRange( | 172 EnclosingIntRect(LayoutObject::AbsoluteBoundingBoxRectForRange( |
| 173 active_match_.Get())))); | 173 EphemeralRange(active_match_.Get()))))); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool was_active_frame = current_active_match_frame_; | 176 bool was_active_frame = current_active_match_frame_; |
| 177 current_active_match_frame_ = true; | 177 current_active_match_frame_ = true; |
| 178 | 178 |
| 179 bool is_active = SetMarkerActive(active_match_.Get(), true); | 179 bool is_active = SetMarkerActive(active_match_.Get(), true); |
| 180 if (active_now) | 180 if (active_now) |
| 181 *active_now = is_active; | 181 *active_now = is_active; |
| 182 | 182 |
| 183 // Make sure no node is focused. See http://crbug.com/38700. | 183 // Make sure no node is focused. See http://crbug.com/38700. |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 contents_size_for_current_find_match_rects_ = current_contents_size; | 533 contents_size_for_current_find_match_rects_ = current_contents_size; |
| 534 find_match_rects_are_valid_ = false; | 534 find_match_rects_are_valid_ = false; |
| 535 } | 535 } |
| 536 | 536 |
| 537 size_t dead_matches = 0; | 537 size_t dead_matches = 0; |
| 538 for (FindMatch& match : find_matches_cache_) { | 538 for (FindMatch& match : find_matches_cache_) { |
| 539 if (!match.range_->BoundaryPointsValid() || | 539 if (!match.range_->BoundaryPointsValid() || |
| 540 !match.range_->startContainer()->isConnected()) | 540 !match.range_->startContainer()->isConnected()) |
| 541 match.rect_ = FloatRect(); | 541 match.rect_ = FloatRect(); |
| 542 else if (!find_match_rects_are_valid_) | 542 else if (!find_match_rects_are_valid_) |
| 543 match.rect_ = FindInPageRectFromRange(match.range_.Get()); | 543 match.rect_ = FindInPageRectFromRange(EphemeralRange(match.range_.Get())); |
| 544 | 544 |
| 545 if (match.rect_.IsEmpty()) | 545 if (match.rect_.IsEmpty()) |
| 546 ++dead_matches; | 546 ++dead_matches; |
| 547 } | 547 } |
| 548 | 548 |
| 549 // Remove any invalid matches from the cache. | 549 // Remove any invalid matches from the cache. |
| 550 if (dead_matches) { | 550 if (dead_matches) { |
| 551 HeapVector<FindMatch> filtered_matches; | 551 HeapVector<FindMatch> filtered_matches; |
| 552 filtered_matches.ReserveCapacity(find_matches_cache_.size() - dead_matches); | 552 filtered_matches.ReserveCapacity(find_matches_cache_.size() - dead_matches); |
| 553 | 553 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 568 ->EnsureTextFinder() | 568 ->EnsureTextFinder() |
| 569 .find_match_rects_are_valid_ = false; | 569 .find_match_rects_are_valid_ = false; |
| 570 | 570 |
| 571 find_match_rects_are_valid_ = true; | 571 find_match_rects_are_valid_ = true; |
| 572 } | 572 } |
| 573 | 573 |
| 574 WebFloatRect TextFinder::ActiveFindMatchRect() { | 574 WebFloatRect TextFinder::ActiveFindMatchRect() { |
| 575 if (!current_active_match_frame_ || !active_match_) | 575 if (!current_active_match_frame_ || !active_match_) |
| 576 return WebFloatRect(); | 576 return WebFloatRect(); |
| 577 | 577 |
| 578 return WebFloatRect(FindInPageRectFromRange(ActiveMatch())); | 578 return WebFloatRect(FindInPageRectFromRange(EphemeralRange(ActiveMatch()))); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void TextFinder::FindMatchRects(WebVector<WebFloatRect>& output_rects) { | 581 void TextFinder::FindMatchRects(WebVector<WebFloatRect>& output_rects) { |
| 582 UpdateFindMatchRects(); | 582 UpdateFindMatchRects(); |
| 583 | 583 |
| 584 Vector<WebFloatRect> match_rects; | 584 Vector<WebFloatRect> match_rects; |
| 585 match_rects.ReserveCapacity(match_rects.size() + find_matches_cache_.size()); | 585 match_rects.ReserveCapacity(match_rects.size() + find_matches_cache_.size()); |
| 586 for (const FindMatch& match : find_matches_cache_) { | 586 for (const FindMatch& match : find_matches_cache_) { |
| 587 DCHECK(!match.rect_.IsEmpty()); | 587 DCHECK(!match.rect_.IsEmpty()); |
| 588 match_rects.push_back(match.rect_); | 588 match_rects.push_back(match.rect_); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 647 |
| 648 // Clear any user selection, to make sure Find Next continues on from the | 648 // Clear any user selection, to make sure Find Next continues on from the |
| 649 // match we just activated. | 649 // match we just activated. |
| 650 OwnerFrame().GetFrame()->Selection().Clear(); | 650 OwnerFrame().GetFrame()->Selection().Clear(); |
| 651 | 651 |
| 652 // Make sure no node is focused. See http://crbug.com/38700. | 652 // Make sure no node is focused. See http://crbug.com/38700. |
| 653 OwnerFrame().GetFrame()->GetDocument()->ClearFocusedElement(); | 653 OwnerFrame().GetFrame()->GetDocument()->ClearFocusedElement(); |
| 654 } | 654 } |
| 655 | 655 |
| 656 IntRect active_match_rect; | 656 IntRect active_match_rect; |
| 657 IntRect active_match_bounding_box = EnclosingIntRect( | 657 IntRect active_match_bounding_box = |
| 658 LayoutObject::AbsoluteBoundingBoxRectForRange(active_match_.Get())); | 658 EnclosingIntRect(LayoutObject::AbsoluteBoundingBoxRectForRange( |
| 659 EphemeralRange(active_match_.Get()))); |
| 659 | 660 |
| 660 if (!active_match_bounding_box.IsEmpty()) { | 661 if (!active_match_bounding_box.IsEmpty()) { |
| 661 if (active_match_->FirstNode() && | 662 if (active_match_->FirstNode() && |
| 662 active_match_->FirstNode()->GetLayoutObject()) { | 663 active_match_->FirstNode()->GetLayoutObject()) { |
| 663 active_match_->FirstNode()->GetLayoutObject()->ScrollRectToVisible( | 664 active_match_->FirstNode()->GetLayoutObject()->ScrollRectToVisible( |
| 664 LayoutRect(active_match_bounding_box), | 665 LayoutRect(active_match_bounding_box), |
| 665 ScrollAlignment::kAlignCenterIfNeeded, | 666 ScrollAlignment::kAlignCenterIfNeeded, |
| 666 ScrollAlignment::kAlignCenterIfNeeded, kUserScroll); | 667 ScrollAlignment::kAlignCenterIfNeeded, kUserScroll); |
| 667 } | 668 } |
| 668 | 669 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 794 |
| 794 DEFINE_TRACE(TextFinder) { | 795 DEFINE_TRACE(TextFinder) { |
| 795 visitor->Trace(owner_frame_); | 796 visitor->Trace(owner_frame_); |
| 796 visitor->Trace(active_match_); | 797 visitor->Trace(active_match_); |
| 797 visitor->Trace(resume_scoping_from_range_); | 798 visitor->Trace(resume_scoping_from_range_); |
| 798 visitor->Trace(deferred_scoping_work_); | 799 visitor->Trace(deferred_scoping_work_); |
| 799 visitor->Trace(find_matches_cache_); | 800 visitor->Trace(find_matches_cache_); |
| 800 } | 801 } |
| 801 | 802 |
| 802 } // namespace blink | 803 } // namespace blink |
| OLD | NEW |