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

Issue 18371008: Add a WebDocument::watchCssSelectors(selectors) (Closed)

Created:
7 years, 5 months ago by Jeffrey Yasskin
Modified:
7 years, 2 months ago
CC:
blink-reviews, jamesr, loislo+blink_chromium.org, eae+blinkwatch, leviw+renderwatch, yurys+blink_chromium.org, dglazkov+blink, apavlov+blink_chromium.org, adamk+blink_chromium.org, jchaffraix+rendering, darktears, Nate Chapin, jeez, gavinp+loader_chromium.org, tony, ojan
Base URL:
https://chromium.googlesource.com/chromium/blink.git@pinned
Visibility:
Public.

Description

Add WebDocument::watchCssSelectors(selectors) which requests callbacks to track whether elements matching |selectors| exist within the document. Blink calls the embedder through WebFrameClient::didMatchCss(frame, newlyMatching, stoppedMatching) to report changes. This patch only watches for the binary set "selector matches anything on the page" vs "selector matches nothing on the page". There are some use cases for getting called back when the number of elements matching the selector changes, but I'm not suggesting an interface for that yet. It might also be useful to publish this to the web through MutationObservers. I'm also not proposing that. :) This continues https://bugs.webkit.org/show_bug.cgi?id=110524. BUG=172011 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=158582

Patch Set 1 : Initial #

Patch Set 2 : Omit split CLs #

Total comments: 37

Patch Set 3 : Fix most comments; TODO benchmark and use Element::recalcStyle #

Total comments: 15

Patch Set 4 : Prevent internalCallback from showing up as a style property #

Patch Set 5 : Sync #

Patch Set 6 : Avoid caching property sets containing callbacks, since applying them has side-effects #

Patch Set 7 : Sync #

Patch Set 8 : Remove wrong-way pointer from StyleRareData by moving selector callbacks to Element #

Patch Set 9 : Add a test for watching dynamic attribute changes #

Patch Set 10 : Sync #

Patch Set 11 : Callback selectors still can't go in the MatchedPropertiedCache #

Patch Set 12 : Sync #

Total comments: 32

Patch Set 13 : Fix Elliott's comments #

Patch Set 14 : Sync #

Patch Set 15 : Sync #

Unified diffs Side-by-side diffs Delta from patch set Stats (+648 lines, -4 lines) Patch
M Source/core/core.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/css/CSSComputedStyleDeclaration.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +3 lines, -0 lines 0 comments Download
M Source/core/css/CSSParser-in.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +5 lines, -0 lines 0 comments Download
M Source/core/css/CSSProperty.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/css/CSSPropertyNames.in View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/css/CSSValueKeywords.in View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/css/DocumentRuleSets.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +2 lines, -1 line 0 comments Download
M Source/core/css/DocumentRuleSets.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +8 lines, -1 line 0 comments Download
M Source/core/css/resolver/MatchedPropertiesCache.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +3 lines, -0 lines 0 comments Download
M Source/core/css/resolver/StyleBuilderCustom.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +10 lines, -0 lines 0 comments Download
M Source/core/css/resolver/StyleResolver.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +3 lines, -1 line 0 comments Download
M Source/core/css/resolver/StyleResolverState.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +6 lines, -0 lines 0 comments Download
M Source/core/css/resolver/StyleResolverState.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -0 lines 0 comments Download
A Source/core/dom/CSSSelectorWatch.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +84 lines, -0 lines 0 comments Download
A Source/core/dom/CSSSelectorWatch.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +175 lines, -0 lines 0 comments Download
M Source/core/dom/Document.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/dom/Element.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +2 lines, -0 lines 0 comments Download
M Source/core/dom/Element.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 chunks +32 lines, -0 lines 0 comments Download
M Source/core/loader/EmptyClients.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/loader/FrameLoaderClient.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +4 lines, -0 lines 0 comments Download
M Source/core/page/RuntimeCSSEnabled.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +3 lines, -0 lines 0 comments Download
M Source/core/page/UseCounter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +2 lines, -1 line 0 comments Download
M Source/core/rendering/style/RenderStyle.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +2 lines, -0 lines 0 comments Download
M Source/core/rendering/style/RenderStyle.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +6 lines, -0 lines 0 comments Download
M Source/core/rendering/style/StyleRareNonInheritedData.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +2 lines, -0 lines 0 comments Download
M Source/core/rendering/style/StyleRareNonInheritedData.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M Source/web/FrameLoaderClientImpl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M Source/web/FrameLoaderClientImpl.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +6 lines, -0 lines 0 comments Download
M Source/web/WebDocument.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +9 lines, -0 lines 0 comments Download
M Source/web/tests/WebFrameTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +264 lines, -0 lines 0 comments Download
M public/web/WebDocument.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +5 lines, -0 lines 0 comments Download
M public/web/WebFrameClient.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 23 (0 generated)
Jeffrey Yasskin
PTAL. Eric points out that we might be able to merge this with a fix ...
7 years, 5 months ago (2013-07-12 22:40:41 UTC) #1
abarth-chromium
You're going to need some CSS experts to look at this CL as well. https://codereview.chromium.org/18371008/diff/10001/Source/WebKit/chromium/tests/WebFrameTest.cpp ...
7 years, 5 months ago (2013-07-12 23:44:10 UTC) #2
abarth-chromium
How many documents will watchCSSSelectors be used on? If I have an extension that watches ...
7 years, 5 months ago (2013-07-12 23:46:30 UTC) #3
esprehn
StyleRareNonInheritedData is huge btw, you're giving extensions a huge memory footgun if they did something ...
7 years, 5 months ago (2013-07-13 01:43:00 UTC) #4
Jeffrey Yasskin
No need to re-review until I get some benchmark results. Elliott, I don't intend the ...
7 years, 5 months ago (2013-07-16 00:38:51 UTC) #5
Jeffrey Yasskin
On 2013/07/12 23:46:30, abarth wrote: > How many documents will watchCSSSelectors be used on? If ...
7 years, 5 months ago (2013-07-17 03:42:13 UTC) #6
abarth-chromium
From a rough number crunch, the change doesn't have an effect without extensions, but if ...
7 years, 5 months ago (2013-07-17 05:41:14 UTC) #7
Jeffrey Yasskin
On Tue, Jul 16, 2013 at 10:41 PM, <abarth@chromium.org> wrote: > From a rough number ...
7 years, 5 months ago (2013-07-17 06:48:00 UTC) #8
esprehn
You're recreating the string and doing hash table lookups for every match this is going ...
7 years, 5 months ago (2013-07-17 07:14:31 UTC) #9
abarth-chromium
I'm curious when you're calling watchCSSSelectors (maybe it should just be called watchSelectors btw---there is ...
7 years, 5 months ago (2013-07-17 17:45:24 UTC) #10
Jeffrey Yasskin
I think not-matching things inside display:none is the right behavior for this API. I'll need ...
7 years, 4 months ago (2013-08-02 01:34:06 UTC) #11
Jeffrey Yasskin
I haven't yet benchmarked this version, but I think this includes all the changes Elliott ...
7 years, 4 months ago (2013-08-13 00:29:28 UTC) #12
esprehn
I need to take some more time to review the whole thing, but what you ...
7 years, 4 months ago (2013-08-13 00:34:54 UTC) #13
Jeffrey Yasskin
On Mon, Aug 12, 2013 at 5:34 PM, <esprehn@chromium.org> wrote: > I need to take ...
7 years, 4 months ago (2013-08-13 00:43:40 UTC) #14
Jeffrey Yasskin
Ok, I've got some benchmarks for the most recent patch. These were run with the ...
7 years, 4 months ago (2013-08-21 23:32:48 UTC) #15
Jeffrey Yasskin
> The memory_top25 measurement still doesn't show a visual memory usage difference > between no-content-script ...
7 years, 4 months ago (2013-08-22 01:23:40 UTC) #16
Jeffrey Yasskin
On 2013/08/21 23:32:48, Jeffrey Yasskin wrote: > Ok, I've got some benchmarks for the most ...
7 years, 3 months ago (2013-08-27 21:37:43 UTC) #17
esprehn
Lots of comments, but architecturally I think this is going in the right direction. The ...
7 years, 3 months ago (2013-09-04 06:08:28 UTC) #18
Jeffrey Yasskin
I think I got all your comments. https://codereview.chromium.org/18371008/diff/78001/Source/core/dom/CSSSelectorWatch.cpp File Source/core/dom/CSSSelectorWatch.cpp (right): https://codereview.chromium.org/18371008/diff/78001/Source/core/dom/CSSSelectorWatch.cpp#newcode85 Source/core/dom/CSSSelectorWatch.cpp:85: Vector<String> addedSelectors, ...
7 years, 3 months ago (2013-09-12 22:09:58 UTC) #19
esprehn
LGTM, awesome.
7 years, 2 months ago (2013-09-30 17:28:07 UTC) #20
abarth-chromium
Given that Elliot is happy, public/web LGTM
7 years, 2 months ago (2013-09-30 19:17:36 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jyasskin@chromium.org/18371008/97001
7 years, 2 months ago (2013-09-30 20:01:01 UTC) #22
commit-bot: I haz the power
7 years, 2 months ago (2013-10-01 03:06:40 UTC) #23
Message was sent while issue was closed.
Change committed as 158582

Powered by Google App Engine
This is Rietveld 408576698