From fbac6356873a42660fae4b3b7cec9af0811a9f57 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 Sep 2016 19:50:43 +0900 Subject: [PATCH] Only emit finalUpdate found-in-page events Since Chrome 53 all meaningful results of found-in-page are finalUpdate. --- atom/browser/api/atom_api_web_contents.cc | 6 ++++-- docs/api/web-contents.md | 7 +++---- docs/api/web-view-tag.md | 9 ++++----- spec/webview-spec.js | 1 - 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 816fc00b2625..a48e8dd60119 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -528,15 +528,17 @@ void WebContents::FindReply(content::WebContents* web_contents, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) { + if (!final_update) + return; + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); - mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate()); result.Set("requestId", request_id); result.Set("matches", number_of_matches); - result.Set("finalUpdate", final_update); result.Set("selectionArea", selection_rect); result.Set("activeMatchOrdinal", active_match_ordinal); + result.Set("finalUpdate", final_update); // Deprecate after 2.0 Emit("found-in-page", result); } diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 235c044c81e5..47aa43bcddfe 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -302,10 +302,9 @@ Returns: * `event` Event * `result` Object * `requestId` Integer - * `finalUpdate` Boolean - Indicates if more responses are to follow. - * `activeMatchOrdinal` Integer (optional) - Position of the active match. - * `matches` Integer (optional) - Number of Matches. - * `selectionArea` Object (optional) - Coordinates of first match region. + * `activeMatchOrdinal` Integer - Position of the active match. + * `matches` Integer - Number of Matches. + * `selectionArea` Object - Coordinates of first match region. Emitted when a result is available for [`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request. diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 90153d8f2513..bda4858e85f7 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -646,10 +646,9 @@ Returns: * `result` Object * `requestId` Integer - * `finalUpdate` Boolean - Indicates if more responses are to follow. - * `activeMatchOrdinal` Integer (optional) - Position of the active match. - * `matches` Integer (optional) - Number of Matches. - * `selectionArea` Object (optional) - Coordinates of first match region. + * `activeMatchOrdinal` Integer - Position of the active match. + * `matches` Integer - Number of Matches. + * `selectionArea` Object - Coordinates of first match region. Fired when a result is available for [`webview.findInPage`](web-view-tag.md#webviewtagfindinpage) request. @@ -657,7 +656,7 @@ Fired when a result is available for ```javascript const webview = document.getElementById('foo') webview.addEventListener('found-in-page', (e) => { - if (e.result.finalUpdate) webview.stopFindInPage('keepSelection') + webview.stopFindInPage('keepSelection') }) const requestId = webview.findInPage('test') diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 5f251284c4e3..01374baf806a 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -783,7 +783,6 @@ describe(' tag', function () { let requestId = null let activeMatchOrdinal = [] const listener = function (e) { - if (!e.result.finalUpdate) return assert.equal(e.result.requestId, requestId) assert.equal(e.result.matches, 3) activeMatchOrdinal.push(e.result.activeMatchOrdinal)