Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upstylo: Use atoms as the pseudo-element back-end. #12815
Conversation
highfive
commented
Aug 11, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Aug 11, 2016
| } | ||
|
|
||
| #[inline] | ||
| pub unsafe fn from_static(ptr: *mut nsIAtom) -> Self { |
This comment has been minimized.
This comment has been minimized.
| else: | ||
| print("OK") | ||
|
|
||
| return 0 |
This comment has been minimized.
This comment has been minimized.
| CLASS = "nsGKAtoms" | ||
| TYPE = "nsICSSAnonBoxPseudo" | ||
|
|
||
| @staticmethod |
This comment has been minimized.
This comment has been minimized.
| @@ -214,7 +223,7 @@ impl fmt::Debug for Atom { | |||
|
|
|||
| impl fmt::Display for Atom { | |||
| fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { | |||
| for c in char::decode_utf16(self.as_slice().iter().cloned()) { | |||
| for c in self.chars() { | |||
This comment has been minimized.
This comment has been minimized.
bholley
Aug 12, 2016
Contributor
I actually wanted @SimonSapin to remove this in #12571, because it makes it too easy to accidentally trigger a slow stringification. Can you revert this line and remove |pub fn chars|? I'd also be ok with chars() being non-public with a comment indicating that it's slow and shouldn't be exposed.
This comment has been minimized.
This comment has been minimized.
SimonSapin
Aug 13, 2016
Member
I’ve removed PartialEq<str> for Atom because, I agree, it’s easy to accidentally use it instead of fast atom comparison.
But consuming Atom::chars is O(n) like str::chars, and calling it has to be explicit, so I don’t see what the problem is. When possible, it’s better than using with_str which allocates.
| MozSVGForeignContent, | ||
| MozSVGText, | ||
| // TODO: automatize this list from | ||
| // http://searchfox.org/mozilla-central/source/layout/style/nsCSSPseudoElements.h and |
This comment has been minimized.
This comment has been minimized.
| match Self::from_atom(&*atom, true) { | ||
| Some(pseudo) => { | ||
| assert_eq!(pseudo.is_anon_box(), is_anon_box); | ||
| return pseudo; |
This comment has been minimized.
This comment has been minimized.
| #[derive(Clone)] | ||
| struct Utf16toASCIIIter<'a>(Iter<'a, u16>); | ||
|
|
||
| impl<'a> Iterator for Utf16toASCIIIter<'a> { |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 13, 2016
Contributor
I don't understand why we need to do all this junk, though it looks like it goes away in subsequent patches? In the mean time, wouldn't we get the same effect by just comparing against atom!(":before") like from_bytes_iter does? Seems preferable to all that nasty unicode munging (which I didn't really look at because it goes away).
This comment has been minimized.
This comment has been minimized.
bholley
Aug 13, 2016
Contributor
(Would still prefer to not introduce the nasty stuff at all though, even for a temporary patch)
| } | ||
|
|
||
| parse!("before", atom!(":before")); | ||
| parse!("after", atom!(":after")); |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 13, 2016
Contributor
Do I understand correctly that this temporarily regresses our support for anon boxes during this patch? I don't see us passing |true| to parse! anywhere. I guess I'm ok with that, though generally would prefer to review less intermediate code...
| in_ua_stylesheet: bool, | ||
| byte_len: usize) -> Option<Self> { | ||
| use std::ascii::AsciiExt; | ||
| macro_rules! parse { |
This comment has been minimized.
This comment has been minimized.
8dd76af
to
01f981a
| self.value = value | ||
| self.cpp_class = source.CLASS | ||
| # FIXME(emilio): This is crap, and we really could/should just store a | ||
| # reference to the source, but... |
This comment has been minimized.
This comment has been minimized.
| * Expected usage is as follows: | ||
| * | ||
| * Also, it guarantees the property that normal pseudo-elements are processed | ||
| * before anonymous boxes. |
This comment has been minimized.
This comment has been minimized.
| return ptr::null_mut(); | ||
| } | ||
| }; | ||
| let atom = unsafe { Atom::from_static(pseudo_tag) }; |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 13, 2016
Contributor
This is a nice optimization, but a bit scary, since it would lead to an unpaired Release() if we ever got it wrong (this only works because ReleaseAtom() is a no-op for static atoms).
Can we make the gecko Atom struct carry an extra bit that indicates whether the atom was created with from_static, and skip the ReleaseAtom() call in that case? That would reduce the risk here, and also save an FFI call.
This comment has been minimized.
This comment has been minimized.
emilio
Aug 13, 2016
Author
Member
It's probably better if we generate accessors for the atom bitfield, with the extra benefit that gives us the length (which means in some cases we don't need to make an ffi call to make some comparisons).
This comment has been minimized.
This comment has been minimized.
emilio
Aug 13, 2016
Author
Member
Oh, also, note that from_atom_unchecked still checks the atom in debug builds.
| Gecko_AtomEqualsUTF8IgnoreCase(self.as_ptr(), s.as_ptr() as *const _, s.len() as u32) | ||
| Gecko_AtomEqualsUTF8IgnoreCase(self.as_ptr(), | ||
| bytes.as_ptr() as *const _, | ||
| bytes.len() as u32) |
This comment has been minimized.
This comment has been minimized.
bholley
Aug 13, 2016
Contributor
yikes. @Manishearth, any ideas on tooling to prevent us from making errors like this in the future?
This comment has been minimized.
This comment has been minimized.
SimonSapin
Aug 13, 2016
Member
I think this change is a no-op: str::len returns a number of UTF-8 bytes, not of code points.
This comment has been minimized.
This comment has been minimized.
emilio
Aug 13, 2016
Author
Member
That's true, I removed it. I'll also fill follow-ups to remove the FFI
functions for string comparison and a few other things.
On 08/13/2016 09:47 AM, Simon Sapin wrote:
In ports/geckolib/string_cache/lib.rs
#12815 (comment):unsafe {
Gecko_AtomEqualsUTF8IgnoreCase(self.as_ptr(), s.as_ptr() as *const _, s.len() as u32)Gecko_AtomEqualsUTF8IgnoreCase(self.as_ptr(),bytes.as_ptr() as *const _,bytes.len() as u32)I think this change is a no-op: |str::len| returns a number of UTF-8
bytes, not of code points.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/servo/servo/pull/12815/files/93e6fb1a6569a2b6934cb28c8d4889122d0b2897..22a7892934b829e32c75a8e408b5569535f13414#r74689195,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABQwurP0WCuwUHsCBBfOmvp2EkqOgZ76ks5qffUtgaJpZM4Jh0-a.
| @@ -1339,6 +1339,80 @@ fn static_assert() { | |||
| ${impl_coord_copy('column_width', 'mColumnWidth')} | |||
| </%self:impl_trait> | |||
|
|
|||
| <%self:impl_trait style_struct_name="Counters" | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bholley
Aug 13, 2016
Contributor
Actually, could you split this commit out into a separate PR? I've got to run pretty soon and may not have time to review the whole thing, and it's pretty separate from the atom stuff (and also presumably needs some gecko-side changes).
|
r=me with comments addressed on everything but the |content| patch, which I'd like to see in a separate PR. @bors-servo delegate+ |
|
|
dd159cc
to
8a92235
|
|
||
| AnonBox(AnonBoxPseudoElement), | ||
| } | ||
| pub struct PseudoElement(Atom, bool); |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Aug 13, 2016
Member
Maybe use struct syntax with named fields? I particular to say what this bool is.
This comment has been minimized.
This comment has been minimized.
emilio
Aug 13, 2016
Author
Member
It's documented above (though the diff makes it difficult to find), but
yeah, it's fair, I'll do it.
On 08/13/2016 08:04 AM, Simon Sapin wrote:
In components/style/gecko_selector_impl.rs
#12815 (comment):
- MozNumberWrapper,
- MozNumberText,
- MozNumberSpinBox,
- MozNumberSpinUp,
- MozNumberSpinDown,
- MozProgressBar,
- MozRangeTrack,
- MozRangeProgress,
- MozRangeThumb,
- MozMeterBar,
- MozPlaceholder,
- MozColorSwatch,
- AnonBox(AnonBoxPseudoElement),
-}
+pub struct PseudoElement(Atom, bool);Maybe use struct syntax with named fields? I particular to say what this
|bool| is.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/servo/servo/pull/12815/files/8a92235c7c372b7d884a6928608a7477e2af7c70#r74687932,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABQwull1-KtkBA4749IbfIn2nU6g_1AUks5qfd0PgaJpZM4Jh0-a.
2a71630
to
15f8390
|
|
||
|
|
||
| def msvc32_symbolify(source, ident): | ||
| return "?" + ident + "@" + source.CLASS + "@@2PAV" + source.TYPE + "@@A" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
upsuper
Aug 17, 2016
•
Member
TBH, I have no idea about msvc manglings. Their mangling rule looks complicated, so I disassembled the object file and copied the pattern to here directly.
If the type is just pointers, I guess reusing this is probably fine, but I'm unconfident about that anyway.
|
Left just the atom patches, will submit the content patches after this lands. @bors-servo: r=bholley |
|
|
stylo: Use atoms as the pseudo-element back-end. <!-- Please describe your changes on the following line: --> A bit of work left, and we can uber-optimize this (left comments, will fill follow-ups), but this is a decent refactor so I thought I'd rather get some feedback on it. r? @bholley (not formally yet, maybe, but some feedback is appreciated). --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] These changes do not require tests because geckolib only... <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12815) <!-- Reviewable:end -->
|
|
highfive
commented
Aug 16, 2016
|
|
@bors-servo: retry #9087 |
|
|
|
|
highfive
commented
Aug 16, 2016
|
|
@bors-servo: retry
|
stylo: Use atoms as the pseudo-element back-end. <!-- Please describe your changes on the following line: --> A bit of work left, and we can uber-optimize this (left comments, will fill follow-ups), but this is a decent refactor so I thought I'd rather get some feedback on it. r? @bholley (not formally yet, maybe, but some feedback is appreciated). --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] These changes do not require tests because geckolib only... <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12815) <!-- Reviewable:end -->
|
|
|
Looks like it works fine with MSVC. |
emilio commentedAug 11, 2016
•
edited by larsbergstrom
A bit of work left, and we can uber-optimize this (left comments, will fill follow-ups), but this is a decent refactor so I thought I'd rather get some feedback on it.
r? @bholley (not formally yet, maybe, but some feedback is appreciated).
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is