Index: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
index a4a1f40ae74a06ee76a801ba677fb99cd0f60cd0..2e8c482cd1e21e5b14199255d1ae8b9b82545263 100644 |
--- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
+++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
@@ -1960,12 +1960,21 @@ void WebLocalFrameImpl::didCallIsSearchProviderInstalled() |
bool WebLocalFrameImpl::find(int identifier, const WebString& searchText, const WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect, bool* activeNow) |
{ |
+ // TODO(dglazkov): This is a bit silly, since isFocused asks the same questions, but we'll keep it here |
+ // to make the next condition less tangled. |
+ if (!frame() || !frame()->page()) |
esprehn
2016/07/22 05:57:10
I wonder how you get a frame without a page? Is th
dglazkov
2016/07/22 16:40:50
I think that check it bogus. The only time you hav
|
+ return false; |
+ |
// Search for an active match only if this frame is focused or if this is a |
// find next request. |
- if (isFocused() || options.findNext) |
- return ensureTextFinder().find(identifier, searchText, options, wrapWithinFrame, selectionRect, activeNow); |
+ if (!isFocused() && !options.findNext) |
+ return false; |
- return false; |
+ // Up-to-date, clean tree is required for finding text in page, since it relies |
+ // on TextIterator to look over the text. |
+ frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
+ |
+ return ensureTextFinder().find(identifier, searchText, options, wrapWithinFrame, selectionRect, activeNow); |
} |
void WebLocalFrameImpl::stopFinding(StopFindAction action) |