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 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 } | 1559 } |
1560 | 1560 |
1561 bool WebFrameImpl::find(int identifier, | 1561 bool WebFrameImpl::find(int identifier, |
1562 const WebString& searchText, | 1562 const WebString& searchText, |
1563 const WebFindOptions& options, | 1563 const WebFindOptions& options, |
1564 bool wrapWithinFrame, | 1564 bool wrapWithinFrame, |
1565 WebRect* selectionRect) | 1565 WebRect* selectionRect) |
1566 { | 1566 { |
1567 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); | 1567 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); |
1568 | 1568 |
1569 if (!options.findNext) { | 1569 if (!options.findNext) |
1570 frame()->page()->unmarkAllTextMatches(); | 1570 frame()->page()->unmarkAllTextMatches(); |
| 1571 else |
| 1572 setMarkerActive(m_activeMatch.get(), false); |
| 1573 |
| 1574 if (m_activeMatch && m_activeMatch->ownerDocument() != frame()->document()) |
1571 m_activeMatch = 0; | 1575 m_activeMatch = 0; |
1572 } else | |
1573 setMarkerActive(m_activeMatch.get(), false); | |
1574 | 1576 |
1575 // If the user has selected something since the last Find operation we want | 1577 // If the user has selected something since the last Find operation we want |
1576 // to start from there. Otherwise, we start searching from where the last Fi
nd | 1578 // to start from there. Otherwise, we start searching from where the last Fi
nd |
1577 // operation left off (either a Find or a FindNext operation). | 1579 // operation left off (either a Find or a FindNext operation). |
1578 VisibleSelection selection(frame()->selection()->selection()); | 1580 VisibleSelection selection(frame()->selection()->selection()); |
1579 bool activeSelection = !selection.isNone(); | 1581 bool activeSelection = !selection.isNone(); |
1580 if (activeSelection) { | 1582 if (activeSelection) { |
1581 m_activeMatch = selection.firstRange().get(); | 1583 m_activeMatch = selection.firstRange().get(); |
1582 frame()->selection()->clear(); | 1584 frame()->selection()->clear(); |
1583 } | 1585 } |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 node = node->traverseNextNode(); | 2180 node = node->traverseNextNode(); |
2179 } | 2181 } |
2180 | 2182 |
2181 // No node related to the active match was focusable, so set the | 2183 // No node related to the active match was focusable, so set the |
2182 // active match as the selection (so that when you end the Find session, | 2184 // active match as the selection (so that when you end the Find session, |
2183 // you'll have the last thing you found highlighted) and make sure that | 2185 // you'll have the last thing you found highlighted) and make sure that |
2184 // we have nothing focused (otherwise you might have text selected but | 2186 // we have nothing focused (otherwise you might have text selected but |
2185 // a link focused, which is weird). | 2187 // a link focused, which is weird). |
2186 frame()->selection()->setSelection(m_activeMatch.get()); | 2188 frame()->selection()->setSelection(m_activeMatch.get()); |
2187 frame()->document()->setFocusedNode(0); | 2189 frame()->document()->setFocusedNode(0); |
| 2190 |
| 2191 // Finally clear the active match, for two reasons: |
| 2192 // We just finished the find 'session' and we don't want future (potenti
ally |
| 2193 // unrelated) find 'sessions' operations to start at the same place. |
| 2194 // The WebFrameImpl could get reused and the m_activeMatch could end up
pointing |
| 2195 // to a document that is no longer valid. Keeping an invalid reference a
round |
| 2196 // is just asking for trouble. |
| 2197 m_activeMatch = 0; |
2188 } | 2198 } |
2189 } | 2199 } |
2190 | 2200 |
2191 void WebFrameImpl::didFail(const ResourceError& error, bool wasProvisional) | 2201 void WebFrameImpl::didFail(const ResourceError& error, bool wasProvisional) |
2192 { | 2202 { |
2193 if (!client()) | 2203 if (!client()) |
2194 return; | 2204 return; |
2195 WebURLError webError = error; | 2205 WebURLError webError = error; |
2196 if (wasProvisional) | 2206 if (wasProvisional) |
2197 client()->didFailProvisionalLoad(this, webError); | 2207 client()->didFailProvisionalLoad(this, webError); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2351 | 2361 |
2352 String scriptResult; | 2362 String scriptResult; |
2353 if (!result.getString(scriptResult)) | 2363 if (!result.getString(scriptResult)) |
2354 return; | 2364 return; |
2355 | 2365 |
2356 if (!m_frame->navigationScheduler()->locationChangePending()) | 2366 if (!m_frame->navigationScheduler()->locationChangePending()) |
2357 m_frame->document()->loader()->writer()->replaceDocument(scriptResult, o
wnerDocument.get()); | 2367 m_frame->document()->loader()->writer()->replaceDocument(scriptResult, o
wnerDocument.get()); |
2358 } | 2368 } |
2359 | 2369 |
2360 } // namespace WebKit | 2370 } // namespace WebKit |
OLD | NEW |