| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 // Notify browser of new location for the selected rectangle. | 386 // Notify browser of new location for the selected rectangle. |
| 387 reportFindInPageSelection( | 387 reportFindInPageSelection( |
| 388 ownerFrame().frameView()->contentsToRootFrame(resultBounds), | 388 ownerFrame().frameView()->contentsToRootFrame(resultBounds), |
| 389 m_activeMatchIndex + 1, identifier); | 389 m_activeMatchIndex + 1, identifier); |
| 390 } | 390 } |
| 391 | 391 |
| 392 ownerFrame().frame()->document()->markers().addTextMatchMarker( | 392 ownerFrame().frame()->document()->markers().addTextMatchMarker( |
| 393 EphemeralRange(resultRange), foundActiveMatch); | 393 EphemeralRange(resultRange), foundActiveMatch); |
| 394 | 394 |
| 395 m_findMatchesCache.append( | 395 m_findMatchesCache.push_back( |
| 396 FindMatch(resultRange, m_lastMatchCount + matchCount)); | 396 FindMatch(resultRange, m_lastMatchCount + matchCount)); |
| 397 | 397 |
| 398 // Set the new start for the search range to be the end of the previous | 398 // Set the new start for the search range to be the end of the previous |
| 399 // result range. There is no need to use a VisiblePosition here, | 399 // result range. There is no need to use a VisiblePosition here, |
| 400 // since findPlainText will use a TextIterator to go over the visible | 400 // since findPlainText will use a TextIterator to go over the visible |
| 401 // text nodes. | 401 // text nodes. |
| 402 searchStart = result.endPosition(); | 402 searchStart = result.endPosition(); |
| 403 | 403 |
| 404 m_resumeScopingFromRange = Range::create( | 404 m_resumeScopingFromRange = Range::create( |
| 405 result.document(), toPositionInDOMTree(result.endPosition()), | 405 result.document(), toPositionInDOMTree(result.endPosition()), |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 ++deadMatches; | 528 ++deadMatches; |
| 529 } | 529 } |
| 530 | 530 |
| 531 // Remove any invalid matches from the cache. | 531 // Remove any invalid matches from the cache. |
| 532 if (deadMatches) { | 532 if (deadMatches) { |
| 533 HeapVector<FindMatch> filteredMatches; | 533 HeapVector<FindMatch> filteredMatches; |
| 534 filteredMatches.reserveCapacity(m_findMatchesCache.size() - deadMatches); | 534 filteredMatches.reserveCapacity(m_findMatchesCache.size() - deadMatches); |
| 535 | 535 |
| 536 for (const FindMatch& match : m_findMatchesCache) { | 536 for (const FindMatch& match : m_findMatchesCache) { |
| 537 if (!match.m_rect.isEmpty()) | 537 if (!match.m_rect.isEmpty()) |
| 538 filteredMatches.append(match); | 538 filteredMatches.push_back(match); |
| 539 } | 539 } |
| 540 | 540 |
| 541 m_findMatchesCache.swap(filteredMatches); | 541 m_findMatchesCache.swap(filteredMatches); |
| 542 } | 542 } |
| 543 | 543 |
| 544 // Invalidate the rects in child frames. Will be updated later during | 544 // Invalidate the rects in child frames. Will be updated later during |
| 545 // traversal. | 545 // traversal. |
| 546 if (!m_findMatchRectsAreValid) | 546 if (!m_findMatchRectsAreValid) |
| 547 for (WebFrame* child = ownerFrame().firstChild(); child; | 547 for (WebFrame* child = ownerFrame().firstChild(); child; |
| 548 child = child->nextSibling()) | 548 child = child->nextSibling()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 559 return WebFloatRect(findInPageRectFromRange(activeMatch())); | 559 return WebFloatRect(findInPageRectFromRange(activeMatch())); |
| 560 } | 560 } |
| 561 | 561 |
| 562 void TextFinder::findMatchRects(WebVector<WebFloatRect>& outputRects) { | 562 void TextFinder::findMatchRects(WebVector<WebFloatRect>& outputRects) { |
| 563 updateFindMatchRects(); | 563 updateFindMatchRects(); |
| 564 | 564 |
| 565 Vector<WebFloatRect> matchRects; | 565 Vector<WebFloatRect> matchRects; |
| 566 matchRects.reserveCapacity(matchRects.size() + m_findMatchesCache.size()); | 566 matchRects.reserveCapacity(matchRects.size() + m_findMatchesCache.size()); |
| 567 for (const FindMatch& match : m_findMatchesCache) { | 567 for (const FindMatch& match : m_findMatchesCache) { |
| 568 DCHECK(!match.m_rect.isEmpty()); | 568 DCHECK(!match.m_rect.isEmpty()); |
| 569 matchRects.append(match.m_rect); | 569 matchRects.push_back(match.m_rect); |
| 570 } | 570 } |
| 571 | 571 |
| 572 outputRects = matchRects; | 572 outputRects = matchRects; |
| 573 } | 573 } |
| 574 | 574 |
| 575 int TextFinder::selectNearestFindMatch(const WebFloatPoint& point, | 575 int TextFinder::selectNearestFindMatch(const WebFloatPoint& point, |
| 576 WebRect* selectionRect) { | 576 WebRect* selectionRect) { |
| 577 int index = nearestFindMatch(point, nullptr); | 577 int index = nearestFindMatch(point, nullptr); |
| 578 if (index != -1) | 578 if (index != -1) |
| 579 return selectFindMatch(static_cast<unsigned>(index), selectionRect); | 579 return selectFindMatch(static_cast<unsigned>(index), selectionRect); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 | 769 |
| 770 DEFINE_TRACE(TextFinder) { | 770 DEFINE_TRACE(TextFinder) { |
| 771 visitor->trace(m_ownerFrame); | 771 visitor->trace(m_ownerFrame); |
| 772 visitor->trace(m_activeMatch); | 772 visitor->trace(m_activeMatch); |
| 773 visitor->trace(m_resumeScopingFromRange); | 773 visitor->trace(m_resumeScopingFromRange); |
| 774 visitor->trace(m_deferredScopingWork); | 774 visitor->trace(m_deferredScopingWork); |
| 775 visitor->trace(m_findMatchesCache); | 775 visitor->trace(m_findMatchesCache); |
| 776 } | 776 } |
| 777 | 777 |
| 778 } // namespace blink | 778 } // namespace blink |
| OLD | NEW |