Closed
Bug 1340090
Opened 9 years ago
Closed 9 years ago
make nsStyleSheetService notify PresShells directly instead of using the observer service
Categories
(Core :: CSS Parsing and Computation, defect)
Core
CSS Parsing and Computation
Tracking
()
RESOLVED
FIXED
mozilla54
Tracking | Status | |
---|---|---|
firefox54 | --- | fixed |
People
(Reporter: heycam, Unassigned)
References
Details
Attachments
(2 files)
59 bytes,
text/x-review-board-request
|
bzbarsky
:
review+
|
Details |
860 bytes,
patch
|
Details | Diff | Splinter Review |
In bug 1337258 I'm going to have to change the notifications that are sent by nsStyleSheetService, since we need (at least for now) to be able to load sheets as Gecko CSSStyleSheets and ServoStyleSheets. I think we should move from using the observer service to notify about added and removed sheets to just notifying PresShells directly. It looks like there is only one add-on on DXR that listens for {agent,user,author}-sheet-{added,removed} observer service topics, and it doesn't do anything with them.
Comment hidden (mozreview-request) |
![]() |
||
Comment 2•9 years ago
|
||
mozreview-review |
Comment on attachment 8837990 [details]
Bug 1340090 - Make nsStyleSheetService notify PresShells directly instead of using the observer service.
https://reviewboard.mozilla.org/r/112998/#review114606
r=me with the issues below fixed.
::: layout/base/nsStyleSheetService.cpp:170
(Diff revision 1)
> - // XXXheycam Once the nsStyleSheetService can hold ServoStyleSheets too,
> + // XXXheycam Once the nsStyleSheetService can hold ServoStyleSheets too,
> - // we'll need to include them in the notification.
> + // we'll need to include them in the notification.
> - StyleSheet* sheet = mSheets[aSheetType].LastElement();
> + RefPtr<StyleSheet> sheet = mSheets[aSheetType].LastElement();
> - if (sheet->IsGecko()) {
> + if (sheet->IsGecko()) {
> - CSSStyleSheet* cssSheet = sheet->AsGecko();
> - serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
> + // Hold on to a copy of the registered PresShells.
> + auto toNotify(mPresShells);
Please use the actual type here. Then it will be clear this is copying an array of strong refs...
::: layout/base/nsStyleSheetService.cpp:172
(Diff revision 1)
> - StyleSheet* sheet = mSheets[aSheetType].LastElement();
> + RefPtr<StyleSheet> sheet = mSheets[aSheetType].LastElement();
> - if (sheet->IsGecko()) {
> + if (sheet->IsGecko()) {
> - CSSStyleSheet* cssSheet = sheet->AsGecko();
> - serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
> - message, nullptr);
> + // Hold on to a copy of the registered PresShells.
> + auto toNotify(mPresShells);
> + for (nsIPresShell* presShell : toNotify) {
> + if (presShell->StyleSet() && presShell->StyleSet()->IsGecko()) {
Why do you need this check? Preshell does it already, right?
::: layout/base/nsStyleSheetService.cpp:306
(Diff revision 1)
> - if (serv) {
> - // XXXheycam Once the nsStyleSheetService can hold ServoStyleSheets too,
> + // XXXheycam Once the nsStyleSheetService can hold ServoStyleSheets too,
> - // we'll need to include them in the notification.
> + // we'll need to include them in the notification.
> - if (sheet->IsGecko()) {
> + if (sheet->IsGecko()) {
> - CSSStyleSheet* cssSheet = sheet->AsGecko();
> - serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
> + // Hold on to a copy of the registered PresShells.
> + auto toNotify(mPresShells);
Again, please write out this type.
::: layout/base/nsStyleSheetService.cpp:308
(Diff revision 1)
> - // we'll need to include them in the notification.
> + // we'll need to include them in the notification.
> - if (sheet->IsGecko()) {
> + if (sheet->IsGecko()) {
> - CSSStyleSheet* cssSheet = sheet->AsGecko();
> - serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
> - message, nullptr);
> + // Hold on to a copy of the registered PresShells.
> + auto toNotify(mPresShells);
> + for (nsIPresShell* presShell : toNotify) {
> + if (presShell->StyleSet() && presShell->StyleSet()->IsGecko()) {
Again, no need for this check.
Attachment #8837990 -
Flags: review?(bzbarsky) → review+
Reporter | ||
Comment 3•9 years ago
|
||
(In reply to Boris Zbarsky [:bz] (still a bit busy) from comment #2)
> > + if (presShell->StyleSet() && presShell->StyleSet()->IsGecko()) {
>
> Why do you need this check? Preshell does it already, right?
It does the "do we have a style set" check, but it doesn't do the "is the sheet of the right StyleBackendType" check. (This will change slightly in bug 1337258 where I'll select which sheet to notify the pres shell with based on what kind of sheets it expects.)
Comment hidden (mozreview-request) |
Pushed by cmccormack@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b93bef392948
Make nsStyleSheetService notify PresShells directly instead of using the observer service. r=bz
Reporter | ||
Comment 6•9 years ago
|
||
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/37c9877d0524
Annotate fall through to satisfy static analysis on a CLOSED TREE. r=me a=tomcat+bustage-fix
Comment 8•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/b93bef392948
https://hg.mozilla.org/mozilla-central/rev/37c9877d0524
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox54:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in
before you can comment on or make changes to this bug.
Description
•