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

Issue 348893004: Rework MediaQueryMatcher to batch up listener notification (Closed)

Created:
6 years, 6 months ago by cbiesinger
Modified:
6 years, 6 months ago
CC:
darktears, apavlov+blink_chromium.org, blink-reviews, blink-reviews-css, blink-reviews-dom_chromium.org, dglazkov+blink, eae+blinkwatch, ed+blinkwatch_opera.com, kenneth.christiansen, rwlbuis, rune+blink, sof
Project:
blink
Visibility:
Public.

Description

Rework MediaQueryMatcher to batch up listener notification MediaQueryMatcher currently runs script synchronously inside layout and recalc style which is bad. Instead we should collect all the listeners that have changed and notify them asynchronously. Incidentally this is what the spec says to do too, and also what Firefox and the polyfills do. This is the first step where we collect all the listeners that changed in a Vector and then notify them as a group. This also fixes our behavior where adding a listener in the middle of notification would get that one called too, which is not what the spec says. This also changes the notification order such that listeners are notified in groups based on the creation time of their MediaQueryList which also matches Firefox (and the polyfill) instead of in the order of global calls to addListener. Based on https://codereview.chromium.org/214383008/ by esprehn@ BUG=356487 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=177038

Patch Set 1 #

Patch Set 2 : fix remaining tests #

Patch Set 3 : add a comment #

Patch Set 4 : some minor changes based on reviewer comments on elliott's change #

Patch Set 5 : ordering test #

Total comments: 3

Patch Set 6 : . #

Patch Set 7 : MediaQueryList constructor needs to call updateMatches to avoid "fake" transitions from "unknown st… #

Total comments: 13

Patch Set 8 : fix review comments #

Patch Set 9 : missed one... #

Total comments: 1

Patch Set 10 : now with it #

Unified diffs Side-by-side diffs Delta from patch set Stats (+162 lines, -121 lines) Patch
A LayoutTests/fast/media/media-query-list-listener-ordering.html View 1 2 3 4 5 6 1 chunk +36 lines, -0 lines 0 comments Download
A + LayoutTests/fast/media/media-query-list-listener-ordering-expected.txt View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/css/MediaQueryList.h View 1 2 3 4 5 6 7 1 chunk +13 lines, -8 lines 0 comments Download
M Source/core/css/MediaQueryList.cpp View 1 2 3 4 5 6 7 8 9 4 chunks +46 lines, -22 lines 0 comments Download
M Source/core/css/MediaQueryListListener.h View 1 1 chunk +8 lines, -2 lines 0 comments Download
M Source/core/css/MediaQueryListListener.cpp View 1 chunk +5 lines, -2 lines 0 comments Download
M Source/core/css/MediaQueryMatcher.h View 1 2 3 4 5 6 7 8 1 chunk +12 lines, -28 lines 0 comments Download
M Source/core/css/MediaQueryMatcher.cpp View 1 2 3 4 5 6 7 4 chunks +37 lines, -54 lines 0 comments Download
M Source/core/dom/Document.cpp View 1 2 3 3 chunks +3 lines, -3 lines 0 comments Download

Messages

Total messages: 16 (0 generated)
cbiesinger
This is now working. And Elliott added a test for this function in https://codereview.chromium.org/347423010/
6 years, 6 months ago (2014-06-26 04:05:31 UTC) #1
cbiesinger
Mads - could you check that this patch handles Oilpan correctly?
6 years, 6 months ago (2014-06-26 04:28:04 UTC) #2
Yoav Weiss
https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp File Source/core/css/MediaQueryMatcher.cpp (right): https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp#newcode80 Source/core/css/MediaQueryMatcher.cpp:80: return evaluator->eval(media); Why aren't you updating m_evaluator here? https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp#newcode124 ...
6 years, 6 months ago (2014-06-26 04:43:19 UTC) #3
cbiesinger
On 2014/06/26 04:43:19, Yoav Weiss wrote: > https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp > File Source/core/css/MediaQueryMatcher.cpp (right): > > https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp#newcode80 ...
6 years, 6 months ago (2014-06-26 04:56:51 UTC) #4
esprehn
https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp File Source/core/css/MediaQueryMatcher.cpp (right): https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp#newcode124 Source/core/css/MediaQueryMatcher.cpp:124: m_evaluator = nullptr; On 2014/06/26 04:43:19, Yoav Weiss wrote: ...
6 years, 6 months ago (2014-06-26 05:01:46 UTC) #5
esprehn
lgtm, lots of random nits but this looks great. https://codereview.chromium.org/348893004/diff/110001/Source/core/css/MediaQueryList.cpp File Source/core/css/MediaQueryList.cpp (right): https://codereview.chromium.org/348893004/diff/110001/Source/core/css/MediaQueryList.cpp#newcode91 Source/core/css/MediaQueryList.cpp:91: ...
6 years, 6 months ago (2014-06-26 05:43:24 UTC) #6
Mads Ager (chromium)
This is pretty close on the oilpan side, thanks! :) https://codereview.chromium.org/348893004/diff/110001/Source/core/css/MediaQueryList.cpp File Source/core/css/MediaQueryList.cpp (right): https://codereview.chromium.org/348893004/diff/110001/Source/core/css/MediaQueryList.cpp#newcode47 ...
6 years, 6 months ago (2014-06-26 06:06:23 UTC) #7
Yoav Weiss
On 2014/06/26 05:01:46, esprehn wrote: > https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp > File Source/core/css/MediaQueryMatcher.cpp (right): > > https://codereview.chromium.org/348893004/diff/80001/Source/core/css/MediaQueryMatcher.cpp#newcode124 > ...
6 years, 6 months ago (2014-06-26 08:36:04 UTC) #8
cbiesinger
Review comments fixed! Thanks for so much for the Oilpan advice. https://codereview.chromium.org/348893004/diff/110001/Source/core/css/MediaQueryList.cpp File Source/core/css/MediaQueryList.cpp (right): ...
6 years, 6 months ago (2014-06-26 20:27:59 UTC) #9
cbiesinger
The CQ bit was checked by cbiesinger@chromium.org
6 years, 6 months ago (2014-06-26 21:32:02 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cbiesinger@chromium.org/348893004/150001
6 years, 6 months ago (2014-06-26 21:33:52 UTC) #11
esprehn
https://codereview.chromium.org/348893004/diff/150001/Source/core/css/MediaQueryList.cpp File Source/core/css/MediaQueryList.cpp (right): https://codereview.chromium.org/348893004/diff/150001/Source/core/css/MediaQueryList.cpp#newcode94 Source/core/css/MediaQueryList.cpp:94: for (ListenerList::const_iterator i = m_listeners.begin(), end = m_listeners.end(); i ...
6 years, 6 months ago (2014-06-26 21:35:54 UTC) #12
cbiesinger
The CQ bit was unchecked by cbiesinger@chromium.org
6 years, 6 months ago (2014-06-26 21:37:04 UTC) #13
cbiesinger
The CQ bit was checked by cbiesinger@chromium.org
6 years, 6 months ago (2014-06-26 23:15:30 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/cbiesinger@chromium.org/348893004/130002
6 years, 6 months ago (2014-06-26 23:17:00 UTC) #15
commit-bot: I haz the power
6 years, 6 months ago (2014-06-27 01:31:32 UTC) #16
Message was sent while issue was closed.
Change committed as 177038

Powered by Google App Engine
This is Rietveld 408576698