Only emit finalUpdate found-in-page events

Since Chrome 53 all meaningful results of found-in-page are finalUpdate.
This commit is contained in:
Cheng Zhao 2016-09-09 19:50:43 +09:00
parent 5ccd0a24e9
commit fbac635687
4 changed files with 11 additions and 12 deletions

View file

@ -528,15 +528,17 @@ void WebContents::FindReply(content::WebContents* web_contents,
const gfx::Rect& selection_rect, const gfx::Rect& selection_rect,
int active_match_ordinal, int active_match_ordinal,
bool final_update) { bool final_update) {
if (!final_update)
return;
v8::Locker locker(isolate()); v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate()); mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate());
result.Set("requestId", request_id); result.Set("requestId", request_id);
result.Set("matches", number_of_matches); result.Set("matches", number_of_matches);
result.Set("finalUpdate", final_update);
result.Set("selectionArea", selection_rect); result.Set("selectionArea", selection_rect);
result.Set("activeMatchOrdinal", active_match_ordinal); result.Set("activeMatchOrdinal", active_match_ordinal);
result.Set("finalUpdate", final_update); // Deprecate after 2.0
Emit("found-in-page", result); Emit("found-in-page", result);
} }

View file

@ -302,10 +302,9 @@ Returns:
* `event` Event * `event` Event
* `result` Object * `result` Object
* `requestId` Integer * `requestId` Integer
* `finalUpdate` Boolean - Indicates if more responses are to follow. * `activeMatchOrdinal` Integer - Position of the active match.
* `activeMatchOrdinal` Integer (optional) - Position of the active match. * `matches` Integer - Number of Matches.
* `matches` Integer (optional) - Number of Matches. * `selectionArea` Object - Coordinates of first match region.
* `selectionArea` Object (optional) - Coordinates of first match region.
Emitted when a result is available for Emitted when a result is available for
[`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request. [`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request.

View file

@ -646,10 +646,9 @@ Returns:
* `result` Object * `result` Object
* `requestId` Integer * `requestId` Integer
* `finalUpdate` Boolean - Indicates if more responses are to follow. * `activeMatchOrdinal` Integer - Position of the active match.
* `activeMatchOrdinal` Integer (optional) - Position of the active match. * `matches` Integer - Number of Matches.
* `matches` Integer (optional) - Number of Matches. * `selectionArea` Object - Coordinates of first match region.
* `selectionArea` Object (optional) - Coordinates of first match region.
Fired when a result is available for Fired when a result is available for
[`webview.findInPage`](web-view-tag.md#webviewtagfindinpage) request. [`webview.findInPage`](web-view-tag.md#webviewtagfindinpage) request.
@ -657,7 +656,7 @@ Fired when a result is available for
```javascript ```javascript
const webview = document.getElementById('foo') const webview = document.getElementById('foo')
webview.addEventListener('found-in-page', (e) => { webview.addEventListener('found-in-page', (e) => {
if (e.result.finalUpdate) webview.stopFindInPage('keepSelection') webview.stopFindInPage('keepSelection')
}) })
const requestId = webview.findInPage('test') const requestId = webview.findInPage('test')

View file

@ -783,7 +783,6 @@ describe('<webview> tag', function () {
let requestId = null let requestId = null
let activeMatchOrdinal = [] let activeMatchOrdinal = []
const listener = function (e) { const listener = function (e) {
if (!e.result.finalUpdate) return
assert.equal(e.result.requestId, requestId) assert.equal(e.result.requestId, requestId)
assert.equal(e.result.matches, 3) assert.equal(e.result.matches, 3)
activeMatchOrdinal.push(e.result.activeMatchOrdinal) activeMatchOrdinal.push(e.result.activeMatchOrdinal)