Use cbindgen for text-overflow.
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox69 | --- | fixed |
People
(Reporter: emilio, Assigned: violet.bugreport)
References
Details
Attachments
(2 files)
3.63 KB,
patch
|
Details | Diff | Splinter Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
The way to fix this would be:
- Mark
TextOverflowSide
with#[repr(C, u8)]
, and change theBox<str>
forcrate::OwnedStr
: https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/servo/components/style/values/specified/text.rs#138 - Mark
computed::TextOverflow
with#[repr(C)]
: https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/servo/components/style/values/computed/text.rs#116 - Add
TextOverflow
to the list here: https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/servo/ports/geckolib/cbindgen.toml#49 - ... And a line like
{ gecko = "StyleTextOverflow", servo = "values::computed::TextOverflow" },
here: https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/layout/style/ServoBindings.toml#396 - Then change the style struct to have a
mozilla::StyleTextOverflow
instead ofnsStyleTextOverflow
- Rewrite the code that uses
nsStyleTextOverflow
to usemozilla::StyleTextOverflow
. You could put the helpers thatnsStyleTextOverflow
has in a section like this: https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/servo/ports/geckolib/cbindgen.toml#440, or inline them as static functions in the only file that uses them. - Remove
text-overflow
and the text-overflow-specific code from: https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/servo/components/style/properties/gecko.mako.rs#3414 - Remove
nsStyleTextOverflow
and co. - Profit?
Reporter | ||
Comment 1•7 months ago
|
||
Violet, would you be interested in taking this since you mentioned some interest in it?
This is the one I found that wasn't either too trivial or too complex, and you get to remove a good chunk of code :)
I outlined what has to be done above, but I may have goofed somewhere, definitely let me know if you get stuck or what not.
Thanks!
Assignee | ||
Comment 2•7 months ago
|
||
Thanks, that's very helpful!
Assignee | ||
Comment 3•7 months ago
|
||
I think we'll need to add default c'tor support for union
in cbindgen
first, because this seems to be the first time a non-POD member is inside a union (OwnedStr
in TextOverflowSide
). C++ will delete the default c'tor for union if it has a member with nontrivial default c'tor, the generated code won't compile:
static StyleTextOverflowSide String(const StyleOwnedStr &a0) {
StyleTextOverflowSide result;
::new (&result.string._0) (StyleOwnedStr)(a0);
result.tag = Tag::String;
return result;
}
Assignee | ||
Comment 4•7 months ago
|
||
This patch to cbindgen
should be ok.
Reporter | ||
Comment 5•7 months ago
|
||
No need to, see: https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/servo/ports/geckolib/cbindgen.toml#431
Your patch looks ok, but probably the destructor should be private to avoid footgunning somebody. That's why I've been reluctant to add that functionality to cbindgen.
Reporter | ||
Comment 6•7 months ago
|
||
Err, the constructor, I mean.
Assignee | ||
Comment 7•7 months ago
|
||
Oh, I see. So the patch isn't necessary. Do you think I should submit a PR to cbindgen
?
A probably trivial question: what's the recommended way to modify a third-party rust package and see how it works in gecko locally? My current approach looks quite awkward. I have to modify this line https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/layout/style/RunCbindgen.py#27 to use the path of my local cbindgen
repo in order to test whether it works in gecko.
Reporter | ||
Comment 8•7 months ago
|
||
You can put CBINDGEN=/path/to/cbindgen
in your mozconfig and that should do the trick. If you need to push to try with your changes, you need to also change: https://searchfox.org/mozilla-central/source/taskcluster/scripts/misc/build-cbindgen.sh#6 and point it to your repo as well.
For other third-party rust packages it's a bit easier, since they're not expected to be built before the export phase. For example, if you wanted to modify cssparser
, you could add cssparser = {path = "third_party/rust/cssparser"}
to:
https://searchfox.org/mozilla-central/rev/6c9f60f8cc064a1005cd8141ecd526578ae9da7a/Cargo.toml#59
I think submitting a PR to cbindgen is not really necessary, though if this pattern becomes really frequent we could consider adding it.
Assignee | ||
Comment 9•7 months ago
|
||
Comment 10•7 months ago
|
||
Pushed by violet.bugreport@gmail.com: https://hg.mozilla.org/integration/autoland/rev/3304277f5bde Use cbindgen for text-overflow r=emilio
Comment 11•7 months ago
|
||
Backed out changeset 3304277f5bde (bug 1553252) for build bustages on Windows
Push that started the failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&resultStatus=superseded%2Ctestfailed%2Cbusted%2Cexception%2Crunnable&selectedJob=247974781&revision=3304277f5bde56d355b81d3caa62673f4545b0e3
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=247974781&repo=autoland&lineNumber=24706
Backout: https://hg.mozilla.org/integration/autoland/rev/7db5627ab9bd5c0267d23796e6b3e099091ace7d
Reporter | ||
Comment 12•7 months ago
|
||
Comment 13•7 months ago
|
||
Pushed by violet.bugreport@gmail.com: https://hg.mozilla.org/integration/autoland/rev/378c7b4699e1 Use cbindgen for text-overflow r=emilio
Assignee | ||
Comment 14•7 months ago
|
||
That using namespace
is definitely bad, but it's still strange why the bustage only happened on Windows. This sort of name clashing should've been diagnosed by clang, gcc as well, but they compiled successfully.
Actually, clang/gcc does report error on a minimal example that is essentially the same as the actual case: https://wandbox.org/permlink/jrWo9p2KNhgBlOen. I'm not sure if there is any flag or build system related stuff that silences the error diagnostic.
Comment 15•7 months ago
|
||
bugherder |
Reporter | ||
Comment 16•7 months ago
|
||
(In reply to violet.bugreport from comment #14)
That
using namespace
is definitely bad, but it's still strange why the bustage only happened on Windows. This sort of name clashing should've been diagnosed by clang, gcc as well, but they compiled successfully.Actually, clang/gcc does report error on a minimal example that is essentially the same as the actual case: https://wandbox.org/permlink/jrWo9p2KNhgBlOen. I'm not sure if there is any flag or build system related stuff that silences the error diagnostic.
We use unified builds, so if different cpp files are built, they may change how the final compilation unit looks like. That's probably what's happening.
Description
•