| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 Timer<DeferredScopeStringMatches> m_timer; | 107 Timer<DeferredScopeStringMatches> m_timer; |
| 108 Member<TextFinder> m_textFinder; | 108 Member<TextFinder> m_textFinder; |
| 109 const int m_identifier; | 109 const int m_identifier; |
| 110 const WebString m_searchText; | 110 const WebString m_searchText; |
| 111 const WebFindOptions m_options; | 111 const WebFindOptions m_options; |
| 112 const bool m_reset; | 112 const bool m_reset; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 bool TextFinder::find(int identifier, const WebString& searchText, const WebFind
Options& options, bool wrapWithinFrame, WebRect* selectionRect, bool* activeNow) | 115 bool TextFinder::find(int identifier, const WebString& searchText, const WebFind
Options& options, bool wrapWithinFrame, WebRect* selectionRect, bool* activeNow) |
| 116 { | 116 { |
| 117 if (!ownerFrame().frame() || !ownerFrame().frame()->page()) | |
| 118 return false; | |
| 119 | |
| 120 if (!options.findNext) | 117 if (!options.findNext) |
| 121 unmarkAllTextMatches(); | 118 unmarkAllTextMatches(); |
| 122 else | 119 else |
| 123 setMarkerActive(m_activeMatch.get(), false); | 120 setMarkerActive(m_activeMatch.get(), false); |
| 124 | 121 |
| 125 if (m_activeMatch && &m_activeMatch->ownerDocument() != ownerFrame().frame()
->document()) | 122 if (m_activeMatch && &m_activeMatch->ownerDocument() != ownerFrame().frame()
->document()) |
| 126 m_activeMatch = nullptr; | 123 m_activeMatch = nullptr; |
| 127 | 124 |
| 128 // If the user has selected something since the last Find operation we want | 125 // If the user has selected something since the last Find operation we want |
| 129 // to start from there. Otherwise, we start searching from where the last Fi
nd | 126 // to start from there. Otherwise, we start searching from where the last Fi
nd |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if (ownerFrame().client()) { | 242 if (ownerFrame().client()) { |
| 246 ownerFrame().client()->handleAccessibilityFindInPageResult( | 243 ownerFrame().client()->handleAccessibilityFindInPageResult( |
| 247 identifier, m_activeMatchIndex + 1, | 244 identifier, m_activeMatchIndex + 1, |
| 248 WebAXObject(startObject), m_activeMatch->startOffset(), | 245 WebAXObject(startObject), m_activeMatch->startOffset(), |
| 249 WebAXObject(endObject), m_activeMatch->endOffset()); | 246 WebAXObject(endObject), m_activeMatch->endOffset()); |
| 250 } | 247 } |
| 251 } | 248 } |
| 252 | 249 |
| 253 void TextFinder::scopeStringMatches(int identifier, const WebString& searchText,
const WebFindOptions& options, bool reset) | 250 void TextFinder::scopeStringMatches(int identifier, const WebString& searchText,
const WebFindOptions& options, bool reset) |
| 254 { | 251 { |
| 252 // TODO(dglazkov): The reset/continue cases need to be untangled into two se
parate functions. This collation of logic |
| 253 // is unnecessary and adds to overall complexity of the code. |
| 255 if (reset) { | 254 if (reset) { |
| 256 // This is a brand new search, so we need to reset everything. | 255 // This is a brand new search, so we need to reset everything. |
| 257 // Scoping is just about to begin. | 256 // Scoping is just about to begin. |
| 258 m_scopingInProgress = true; | 257 m_scopingInProgress = true; |
| 259 | 258 |
| 260 // Need to keep the current identifier locally in order to finish the | 259 // Need to keep the current identifier locally in order to finish the |
| 261 // request in case the frame is detached during the process. | 260 // request in case the frame is detached during the process. |
| 262 m_findRequestIdentifier = identifier; | 261 m_findRequestIdentifier = identifier; |
| 263 | 262 |
| 264 // Clear highlighting for this frame. | 263 // Clear highlighting for this frame. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 293 | 292 |
| 294 if (m_resumeScopingFromRange) { | 293 if (m_resumeScopingFromRange) { |
| 295 // This is a continuation of a scoping operation that timed out and didn
't | 294 // This is a continuation of a scoping operation that timed out and didn
't |
| 296 // complete last time around, so we should start from where we left off. | 295 // complete last time around, so we should start from where we left off. |
| 297 DCHECK(m_resumeScopingFromRange->collapsed()); | 296 DCHECK(m_resumeScopingFromRange->collapsed()); |
| 298 searchStart = fromPositionInDOMTree<EditingInFlatTreeStrategy>(m_resumeS
copingFromRange->endPosition()); | 297 searchStart = fromPositionInDOMTree<EditingInFlatTreeStrategy>(m_resumeS
copingFromRange->endPosition()); |
| 299 if (searchStart.document() != searchEnd.document()) | 298 if (searchStart.document() != searchEnd.document()) |
| 300 return; | 299 return; |
| 301 } | 300 } |
| 302 | 301 |
| 302 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n
eeds to be audited. |
| 303 // see http://crbug.com/590369 for more details. |
| 304 searchStart.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 305 |
| 303 // This timeout controls how long we scope before releasing control. This | 306 // This timeout controls how long we scope before releasing control. This |
| 304 // value does not prevent us from running for longer than this, but it is | 307 // value does not prevent us from running for longer than this, but it is |
| 305 // periodically checked to see if we have exceeded our allocated time. | 308 // periodically checked to see if we have exceeded our allocated time. |
| 306 const double maxScopingDuration = 0.1; // seconds | 309 const double maxScopingDuration = 0.1; // seconds |
| 307 | 310 |
| 308 int matchCount = 0; | 311 int matchCount = 0; |
| 309 bool timedOut = false; | 312 bool timedOut = false; |
| 310 double startTime = currentTime(); | 313 double startTime = currentTime(); |
| 311 do { | 314 do { |
| 312 // Find next occurrence of the search string. | 315 // Find next occurrence of the search string. |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 DEFINE_TRACE(TextFinder) | 745 DEFINE_TRACE(TextFinder) |
| 743 { | 746 { |
| 744 visitor->trace(m_ownerFrame); | 747 visitor->trace(m_ownerFrame); |
| 745 visitor->trace(m_activeMatch); | 748 visitor->trace(m_activeMatch); |
| 746 visitor->trace(m_resumeScopingFromRange); | 749 visitor->trace(m_resumeScopingFromRange); |
| 747 visitor->trace(m_deferredScopingWork); | 750 visitor->trace(m_deferredScopingWork); |
| 748 visitor->trace(m_findMatchesCache); | 751 visitor->trace(m_findMatchesCache); |
| 749 } | 752 } |
| 750 | 753 |
| 751 } // namespace blink | 754 } // namespace blink |
| OLD | NEW |