Only emit finalUpdate found-in-page events
authorCheng Zhao <zcbenz@gmail.com>
Fri, 9 Sep 2016 10:50:43 +0000 (19:50 +0900)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 14 Sep 2016 07:23:01 +0000 (16:23 +0900)
Since Chrome 53 all meaningful results of found-in-page are finalUpdate.

atom/browser/api/atom_api_web_contents.cc
docs/api/web-contents.md
docs/api/web-view-tag.md
spec/webview-spec.js

index 816fc00..a48e8dd 100644 (file)
@@ -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);
 }
 
index 235c044..47aa43b 100644 (file)
@@ -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.
index 90153d8..bda4858 100644 (file)
@@ -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')
index 5f25128..01374ba 100644 (file)
@@ -783,7 +783,6 @@ describe('<webview> 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)