Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/renderer/resources/extensions/content_watcher.js

Issue 22903023: Simplify ContentWatcher by calling querySelector directly instead of through JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/extensions/content_watcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var contentWatcherNative = requireNative("contentWatcherNative"); 5 var contentWatcherNative = requireNative("contentWatcherNative");
6 6
7 // Returns the indices in |cssSelectors| that match any element on the page.
8 exports.FindMatchingSelectors = function(cssSelectors) {
9 var result = []
10 $Array.forEach(cssSelectors, function(selector, index) {
11 try {
12 if (document.querySelector(selector) != null)
13 $Array.push(result, index);
14 } catch (exception) {
15 throw new Error("query Selector failed on '" + selector + "': " +
16 exception.stack);
17 }
18 });
19 return result;
20 };
21
22 // Watches the page for all changes and calls FrameMutated (a C++ callback) in 7 // Watches the page for all changes and calls FrameMutated (a C++ callback) in
23 // response. 8 // response.
24 var mutation_observer = new MutationObserver(contentWatcherNative.FrameMutated); 9 var mutation_observer = new MutationObserver(contentWatcherNative.FrameMutated);
25 10
26 // This runs once per frame, when the module is 'require'd. 11 // This runs once per frame, when the module is 'require'd.
27 mutation_observer.observe(document, { 12 mutation_observer.observe(document, {
28 childList: true, 13 childList: true,
29 attributes: true, 14 attributes: true,
30 characterData: true, 15 characterData: true,
31 subtree: true}); 16 subtree: true});
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/content_watcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698