Closed
Bug 1404897
Opened 7 years ago
Closed 7 years ago
stylo: Use stylo for Element::Matches.
Categories
(Core :: CSS Parsing and Computation, enhancement, P4)
Core
CSS Parsing and Computation
Tracking
()
RESOLVED
FIXED
mozilla58
People
(Reporter: emilio, Assigned: emilio)
References
Details
Attachments
(4 files)
This one is the easiest so far, so let's do it.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 5•7 years ago
|
||
Updated•7 years ago
|
Priority: -- → P4
![]() |
||
Comment 6•7 years ago
|
||
mozreview-review |
Comment on attachment 8914382 [details]
Bug 1404897: Some fixes to allow storing non-copyable types in nsDataHashtable.
https://reviewboard.mozilla.org/r/185658/#review190776
Discussion about naming below welcome.
::: xpcom/ds/nsBaseHashtable.h:160
(Diff revision 1)
> /**
> + * Put a new value for the associated key
> + * @param aKey the key to put
> + * @param aData the new data
> + */
> + void Put(KeyType aKey, UserDataType&& aData)
Thanks for adding this.
::: xpcom/ds/nsDataHashtable.h:40
(Diff revision 1)
> + * Retrieve a reference to the value for a key.
> + *
> + * @param aKey the key to retrieve.
> + * @return a reference to the found value, or nullptr if no entry was found
> + * with the given key.
> + */
> + DataType* GetRef(KeyType aKey)
It is, uh, a little weird to have a `GetRef` method returning pointers. I guess we're doing this to avoid conflicts with `nsBaseHashtable::Get` with virtually the same signature?
That being said, I'm not sure what a better name is...`GetValuePtr`? Or maybe just `GetValue`?
Attachment #8914382 -
Flags: review?(nfroyd) → review+
Comment 7•7 years ago
|
||
mozreview-review |
Comment on attachment 8914381 [details]
Bug 1404897: Add bindings to Servo selector lists.
https://reviewboard.mozilla.org/r/185656/#review190868
::: servo/ports/geckolib/glue.rs:4100
(Diff revision 1)
> + debug_assert!(!selector_list.is_null());
> + use style::selector_parser::SelectorParser;
Small nit: the "use" probably is better before the debug_assert.
Attachment #8914381 -
Flags: review?(cam) → review+
Comment 8•7 years ago
|
||
mozreview-review |
Comment on attachment 8914382 [details]
Bug 1404897: Some fixes to allow storing non-copyable types in nsDataHashtable.
https://reviewboard.mozilla.org/r/185658/#review190874
::: commit-message-ce15a:1
(Diff revision 1)
> +Bug 1404897: Some fixes to allow storing non-copyable types in nsDataHashTable. r?froydnj
Nit: lowercase "t" in nsDataHashtable. And no, I have no idea why it's spelled like that. :-)
Comment 9•7 years ago
|
||
mozreview-review |
Comment on attachment 8914383 [details]
Bug 1404897: Allow storing Servo selector lists in the document's selector cache.
https://reviewboard.mozilla.org/r/185660/#review190876
::: dom/base/nsIDocument.h:1161
(Diff revision 1)
> + : mIsServo(false)
> + , mGecko(nullptr)
> + {}
> +
> + SelectorList(SelectorList&& aOther)
> + : mIsServo(aOther.mIsServo)
The operator= will do this.
::: dom/base/nsIDocument.h:1166
(Diff revision 1)
> + SelectorList& operator=(SelectorList&& aOther)
> + {
> + mIsServo = aOther.mIsServo;
> + if (mIsServo) {
> + mServo = aOther.mServo;
> + aOther.mServo = nullptr;
> + } else {
> + mGecko = aOther.mGecko;
> + aOther.mGecko = nullptr;
> + }
> + return *this;
> + }
I think we need to call Servo_SelectorList_Drop/delete on the old ServoSelectorList/nsCSSSelectorList in here.
::: dom/base/nsIDocument.h:1196
(Diff revision 1)
> + ~SelectorList();
> +
> + bool IsServo() const { return mIsServo; }
> + bool IsGecko() const { return !IsServo(); }
> +
> + explicit operator bool() const {
Nit: "{" on new line (and for the next two functions).
::: dom/base/nsIDocument.h:1211
(Diff revision 1)
> + bool mIsServo;
> +
> + union {
> + nsCSSSelectorList* mGecko;
> + RawServoSelectorList* mServo;
> + };
I think we should consider replacing this with Variant<UniquePtr<nsCSSSelectorList>, UniquePtr<RawServoSelectorList>>, and use DEFINE_BOXED_TYPE to define a DefaultDeleter for RawServoSelectorList. Then we wouldn't have to worry about manually deleting the objects. WDYT?
::: dom/base/nsIDocument.h:1232
(Diff revision 1)
> // If we have an entry and *aList is null, that indicates that aSelector
> // has already been parsed and is not a syntactically valid selector.
Please update the comment now that we no longer have an aList.
Comment 10•7 years ago
|
||
mozreview-review |
Comment on attachment 8914384 [details]
Bug 1404897: Implement Element.matches using stylo.
https://reviewboard.mozilla.org/r/185662/#review190884
::: dom/base/Element.cpp:3510
(Diff revision 1)
> - // Either we failed (and aError already has the exception), or this
> + // Either we failed (and aError already has the exception), or this
> - // is a pseudo-element-only selector that matches nothing.
> + // is a pseudo-element-only selector that matches nothing.
Since this comment applies to both Gecko and Servo, maybe move it up the top of the function, or just make WithSelectorList handle this case?
::: dom/base/nsINode.h:2077
(Diff revision 1)
> mozilla::ErrorResult& aRv);
>
> + /**
> + * Parse the given selector string into a servo SelectorList.
> + *
> + * Never returns null if aRv is failing.
s/Never/Always/ ?
While you're here can you document that the return value (and ParseSelectorList) is owned by the SelectorCache? (And maybe that the caller should be aware that the object could be evicted from the cache and deleted at some later time?)
::: dom/base/nsINode.cpp:2700
(Diff revision 1)
> +
> + if (list->IsServo()) {
Duplicate your FIXME(emilio) from nsINode::ParseSelectorList below?
::: dom/base/nsINode.cpp:2706
(Diff revision 1)
> + if (list->IsServo()) {
> + return list->AsServo();
> + }
> + }
> +
> + nsAutoCString selectorString = NS_ConvertUTF16toUTF8(aSelectorString);
No need to use nsAutoCString, since we'll never use the stack storage. We should always share the nsStringBuffer that the NS_ConvertUTF16toUTF8 creates.
::: servo/ports/geckolib/glue.rs:1541
(Diff revision 1)
> + );
> +
> + selectors::matching::matches_selector_list(selectors, &element, &mut context)
> +}
> +
> +
Nit: No need for this extra blank line.
Attachment #8914384 -
Flags: review?(cam) → review+
Assignee | ||
Comment 11•7 years ago
|
||
(In reply to Cameron McCormack (:heycam) (away 4 Oct) from comment #9)
> ::: dom/base/nsIDocument.h:1166
> (Diff revision 1)
> > + SelectorList& operator=(SelectorList&& aOther)
> > + {
> > + mIsServo = aOther.mIsServo;
> > + if (mIsServo) {
> > + mServo = aOther.mServo;
> > + aOther.mServo = nullptr;
> > + } else {
> > + mGecko = aOther.mGecko;
> > + aOther.mGecko = nullptr;
> > + }
> > + return *this;
> > + }
>
> I think we need to call Servo_SelectorList_Drop/delete on the old
> ServoSelectorList/nsCSSSelectorList in here.
nice catch
> ::: dom/base/nsIDocument.h:1211
> (Diff revision 1)
> > + bool mIsServo;
> > +
> > + union {
> > + nsCSSSelectorList* mGecko;
> > + RawServoSelectorList* mServo;
> > + };
>
> I think we should consider replacing this with
> Variant<UniquePtr<nsCSSSelectorList>, UniquePtr<RawServoSelectorList>>, and
> use DEFINE_BOXED_TYPE to define a DefaultDeleter for RawServoSelectorList.
> Then we wouldn't have to worry about manually deleting the objects. WDYT?
I tried that first, but that required RawServoSelectorList to be complete, which required me to pull ServoTypes, and that ended up making me include a bunch of other stuff, and also errored in nsBaseHashTable, because it doesn't have move-assignment operator... So I think I'll avoid this for now.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 16•7 years ago
|
||
mozreview-review-reply |
Comment on attachment 8914382 [details]
Bug 1404897: Some fixes to allow storing non-copyable types in nsDataHashtable.
https://reviewboard.mozilla.org/r/185658/#review190776
> It is, uh, a little weird to have a `GetRef` method returning pointers. I guess we're doing this to avoid conflicts with `nsBaseHashtable::Get` with virtually the same signature?
>
> That being said, I'm not sure what a better name is...`GetValuePtr`? Or maybe just `GetValue`?
I went with GetValue, but happy to rename to whatever you prefer.
Assignee | ||
Comment 17•7 years ago
|
||
mozreview-review-reply |
Comment on attachment 8914384 [details]
Bug 1404897: Implement Element.matches using stylo.
https://reviewboard.mozilla.org/r/185662/#review190884
> Since this comment applies to both Gecko and Servo, maybe move it up the top of the function, or just make WithSelectorList handle this case?
Not quite, the pseudo-element selector case is handled differently in Servo (we try to actually go and match against it, and we just fail).
> s/Never/Always/ ?
>
> While you're here can you document that the return value (and ParseSelectorList) is owned by the SelectorCache? (And maybe that the caller should be aware that the object could be evicted from the cache and deleted at some later time?)
Done
> Duplicate your FIXME(emilio) from nsINode::ParseSelectorList below?
Done
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 21•7 years ago
|
||
Err, I thought the 3rd patch also got an r+.
Servo bits landed in https://hg.mozilla.org/integration/autoland/rev/687f71098b9ab04e4d824df365c160c35e077104.
Comment 22•7 years ago
|
||
mozreview-review |
Comment on attachment 8914383 [details]
Bug 1404897: Allow storing Servo selector lists in the document's selector cache.
https://reviewboard.mozilla.org/r/185660/#review191290
::: commit-message-72022:4
(Diff revisions 1 - 3)
> Bug 1404897: Allow storing Servo selector lists in the document's selector cache. r?heycam
>
> MozReview-Commit-ID: GtIWGN2zEGT
> +Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
No need for this.
Attachment #8914383 -
Flags: review?(cam) → review+
Assignee | ||
Comment 23•7 years ago
|
||
(In reply to Cameron McCormack (:heycam) (away 4 Oct) from comment #22)
> Comment on attachment 8914383 [details]
> Bug 1404897: Allow storing Servo selector lists in the document's selector
> cache.
>
> https://reviewboard.mozilla.org/r/185660/#review191290
>
> ::: commit-message-72022:4
> (Diff revisions 1 - 3)
> > Bug 1404897: Allow storing Servo selector lists in the document's selector cache. r?heycam
> >
> > MozReview-Commit-ID: GtIWGN2zEGT
> > +Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
>
> No need for this.
Yeah, this is an artifact of the default git settings I have to export patches, and the fact that I have multiple gecko clones, of which only one is properly configured to avoid this...
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 28•7 years ago
|
||
Pushed by ecoal95@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/fda0d9bc93f0
Add bindings to Servo selector lists. r=heycam
https://hg.mozilla.org/integration/autoland/rev/9389dd982590
Some fixes to allow storing non-copyable types in nsDataHashtable. r=froydnj
https://hg.mozilla.org/integration/autoland/rev/2a7dd15c8206
Allow storing Servo selector lists in the document's selector cache. r=heycam
https://hg.mozilla.org/integration/autoland/rev/3833f3700021
Implement Element.matches using stylo. r=heycam
![]() |
||
Comment 29•7 years ago
|
||
Backed out for build bustage at nsIDocument.h:1181: bad implicit conversion constructor for 'SelectorList':
https://hg.mozilla.org/integration/autoland/rev/40be5522a0166b90cdd3d23b09e7e4d12e7770bf
https://hg.mozilla.org/integration/autoland/rev/084da44465b0fa68d08e09fe99fb91dbdccfe248
https://hg.mozilla.org/integration/autoland/rev/e63b7088a1a5365af741c0787f89e5a1320cb126
https://hg.mozilla.org/integration/autoland/rev/ecaeee74172394694d028d60fa365a153101ee7b
Push with bustage: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=3833f3700021543ae4a0b5efda704f4b59803b7d&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-resultStatus=usercancel&filter-resultStatus=runnable
Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=134851730&repo=autoland
[task 2017-10-04T09:13:27.763Z] 09:13:27 INFO - In file included from /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/BindingUtils.h:32:
[task 2017-10-04T09:13:27.763Z] 09:13:27 INFO - /builds/worker/workspace/build/src/obj-firefox/dist/include/nsIDocument.h:1181:9: error: bad implicit conversion constructor for 'SelectorList'
[task 2017-10-04T09:13:27.763Z] 09:13:27 INFO - SelectorList(mozilla::UniquePtr<RawServoSelectorList>&& aList)
[task 2017-10-04T09:13:27.763Z] 09:13:27 INFO - ^
[task 2017-10-04T09:13:27.763Z] 09:13:27 INFO - /builds/worker/workspace/build/src/obj-firefox/dist/include/nsIDocument.h:1181:9: note: consider adding the explicit keyword to the constructor
[task 2017-10-04T09:13:27.763Z] 09:13:27 INFO - /builds/worker/workspace/build/src/obj-firefox/dist/include/nsIDocument.h:1186:9: error: bad implicit conversion constructor for 'SelectorList'
[task 2017-10-04T09:13:27.763Z] 09:13:27 INFO - SelectorList(mozilla::UniquePtr<nsCSSSelectorList>&& aList)
[task 2017-10-04T09:13:27.763Z] 09:13:27 INFO - ^
[task 2017-10-04T09:13:27.764Z] 09:13:27 INFO - /builds/worker/workspace/build/src/obj-firefox/dist/include/nsIDocument.h:1186:9: note: consider adding the explicit keyword to the constructor
[task 2017-10-04T09:13:27.766Z] 09:13:27 INFO - 2 errors generated.
Flags: needinfo?(emilio)
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Updated•7 years ago
|
Flags: needinfo?(emilio)
Comment 34•7 years ago
|
||
Pushed by ecoal95@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/1f1ff129684f
Add bindings to Servo selector lists. r=heycam
https://hg.mozilla.org/integration/autoland/rev/e3352dc9d701
Some fixes to allow storing non-copyable types in nsDataHashtable. r=froydnj
https://hg.mozilla.org/integration/autoland/rev/9a8f77f3dfe7
Allow storing Servo selector lists in the document's selector cache. r=heycam
https://hg.mozilla.org/integration/autoland/rev/cfc393773f0d
Implement Element.matches using stylo. r=heycam
Comment 35•7 years ago
|
||
Backout by archaeopteryx@coole-files.de:
https://hg.mozilla.org/integration/autoland/rev/371714dd45e3
Backed out changeset cfc393773f0d
https://hg.mozilla.org/integration/autoland/rev/02d567e758c9
Backed out changeset 9a8f77f3dfe7
https://hg.mozilla.org/integration/autoland/rev/f3a3e42c3108
Backed out changeset e3352dc9d701
https://hg.mozilla.org/integration/autoland/rev/15f48ea175a8
Backed out changeset 1f1ff129684f for Android bustage at nsDocument.cpp:1414: undefined reference to 'Servo_SelectorList_Drop'. r=backout
Assignee | ||
Comment 36•7 years ago
|
||
Our bindings stuff is a footgun :((
Comment 37•7 years ago
|
||
mozreview-review noise |
Comment on attachment 8914383 [details]
Bug 1404897: Allow storing Servo selector lists in the document's selector cache.
https://reviewboard.mozilla.org/r/185660/#review191358
C/C++ static analysis didn't find any defects in this patch. Hooray!
Comment 38•7 years ago
|
||
mozreview-review noise |
Comment on attachment 8914384 [details]
Bug 1404897: Implement Element.matches using stylo.
https://reviewboard.mozilla.org/r/185662/#review191360
C/C++ static analysis didn't find any defects in this patch. Hooray!
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 43•7 years ago
|
||
mozreview-review noise |
Comment on attachment 8914383 [details]
Bug 1404897: Allow storing Servo selector lists in the document's selector cache.
https://reviewboard.mozilla.org/r/185660/#review191372
C/C++ static analysis didn't find any defects in this patch. Hooray!
Assignee | ||
Comment 44•7 years ago
|
||
Comment 45•7 years ago
|
||
Pushed by ecoal95@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/8b73c2cd90b6
Add bindings to Servo selector lists. r=heycam
https://hg.mozilla.org/integration/autoland/rev/01b7ff077694
Some fixes to allow storing non-copyable types in nsDataHashtable. r=froydnj
https://hg.mozilla.org/integration/autoland/rev/61df17121aa0
Allow storing Servo selector lists in the document's selector cache. r=heycam
https://hg.mozilla.org/integration/autoland/rev/c2c0d2ea67d1
Implement Element.matches using stylo. r=heycam
Comment 46•7 years ago
|
||
mozreview-review noise |
Comment on attachment 8914384 [details]
Bug 1404897: Implement Element.matches using stylo.
https://reviewboard.mozilla.org/r/185662/#review191374
C/C++ static analysis didn't find any defects in this patch. Hooray!
Comment 47•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8b73c2cd90b6
https://hg.mozilla.org/mozilla-central/rev/01b7ff077694
https://hg.mozilla.org/mozilla-central/rev/61df17121aa0
https://hg.mozilla.org/mozilla-central/rev/c2c0d2ea67d1
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox58:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
Comment 48•7 years ago
|
||
Pushed by ecoal95@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3cdd76784502
followup: Fixup documentation of nsINode::WithSelectorList. r=me
![]() |
||
Comment 50•7 years ago
|
||
bugherder |
Updated•7 years ago
|
status-firefox57:
--- → wontfix
You need to log in
before you can comment on or make changes to this bug.
Description
•