Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement string-valued text-overflow in Servo #13709

Closed
Manishearth opened this issue Oct 12, 2016 · 21 comments
Closed

Implement string-valued text-overflow in Servo #13709

Manishearth opened this issue Oct 12, 2016 · 21 comments

Comments

@Manishearth
Copy link
Member

@Manishearth Manishearth commented Oct 12, 2016

Part of #13702

In #13701, we added support for parsing the full range of values that text-overflow supports. However, this is disabled in Servo mode

While supporting the two-value form of text-overflow (e.g. text-overflow: "..." clip) is cumbersome, it should be pretty straightforward to support the one-value form.

Steps:

Relevant layout code: components/layout/inline.rs , components/layout/fragment.rs

Tests: None, but we will add some when this is done.

@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 12, 2016

@notriddle @jdm does this look like E-easy material? I tried to break it into steps to make it easier to work on.

@jdm
Copy link
Member

@jdm jdm commented Oct 12, 2016

I would call it E-less easy.

@cynicaldevil
Copy link
Contributor

@cynicaldevil cynicaldevil commented Oct 12, 2016

I'll take a look at this one.

@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 12, 2016

Cool! Let us know if you need help!

@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 17, 2016

@cynicaldevil Any updates? I got a ping from you yesterday but you weren't around when I came back online. Feel free to ask any questions here.

@cynicaldevil
Copy link
Contributor

@cynicaldevil cynicaldevil commented Oct 17, 2016

@Manishearth I get a Could not find Side in style::computed_values::text_overflow error for both match arms. I don't know what's wrong, because the text-overflow module does contain a Side enum, according to mako.rs.

@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 18, 2016

style::properties::text_overflow contains it. The computed value module does not.

@cynicaldevil
Copy link
Contributor

@cynicaldevil cynicaldevil commented Oct 18, 2016

Negative on that as well.

@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 18, 2016

Could you put your code somewhere and pastebin the error?

@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 18, 2016

Also, did you remove the conditional as was mentioned in the first point above?

@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 18, 2016

https://github.com/Manishearth/servo/blob/ea765688cbc7a7f5e223cf060f2bf1341dfa0ae5/components/style/properties/longhand/text.mako.rs#L15 should not be there anymore, you need to change it to unconditionally use the helpers:longhand version

@cynicaldevil
Copy link
Contributor

@cynicaldevil cynicaldevil commented Oct 18, 2016

Yes, I'd removed the conditional statement. I'll push my changes onto my fork now.

@cynicaldevil
Copy link
Contributor

@cynicaldevil cynicaldevil commented Oct 18, 2016

https://github.com/cynicaldevil/servo/commit/74c89e61eece0df4d19ba76996de4ce0238e08bc
Error:

error[E0433]: failed to resolve. Could not find `text_overflow` in `style::properties`
   --> /home/nikhil/workspace/mozilla/servo/components/layout/inline.rs:692:13
    |
692 |             properties::text_overflow::Side::Clip => {}
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `text_overflow` in `style::properties`

error[E0433]: failed to resolve. Could not find `text_overflow` in `style::properties`
   --> /home/nikhil/workspace/mozilla/servo/components/layout/inline.rs:693:13
    |
693 |             properties::text_overflow::Side::Ellipsis => {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `text_overflow` in `style::properties`
@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 18, 2016

It's properties::longhands::text_overflow, sorry.

@cynicaldevil
Copy link
Contributor

@cynicaldevil cynicaldevil commented Oct 18, 2016

Copied from IRC:
I tried to do something like this; but the ref string is forcing a borrow of fragment which is not being returned. I don't get why this is happening.

        let passed_str: Option<&str> = match fragment.style().get_text().text_overflow.first {
            longhands::text_overflow::Side::Clip => None,
            longhands::text_overflow::Side::Ellipsis => {
                need_ellipsis = fragment.margin_box_inline_size() > available_inline_size;
                Some("...")
            }
            longhands::text_overflow::Side::String(ref string) => {
                need_ellipsis = fragment.margin_box_inline_size() > available_inline_size;
                Some(string)
            }
        };
@jdm
Copy link
Member

@jdm jdm commented Oct 18, 2016

What's the error message that you get?

@cynicaldevil
Copy link
Contributor

@cynicaldevil cynicaldevil commented Oct 19, 2016

error[E0505]: cannot move out of `fragment` because it is borrowed
    |
691 |         let passed_str: Option<&str> = match fragment.style().get_text().text_overflow.first {
    |                                              -------- borrow of `fragment` occurs here
...
704 |             self.push_fragment_to_line_ignoring_text_overflow(fragment, layout_context);
    |                                                               ^^^^^^^^ move out of `fragment` occurs here

@jdm
Copy link
Member

@jdm jdm commented Oct 19, 2016

Can you scope passed_str so that it is dropped before line 704?

@cynicaldevil
Copy link
Contributor

@cynicaldevil cynicaldevil commented Oct 19, 2016

I can't do that, because I have to pass it to a function call which occurs after line 704.

@jdm
Copy link
Member

@jdm jdm commented Oct 19, 2016

In that case it's not possible to hold on to a pointer derived from fragment after it gets moved.

@Manishearth
Copy link
Member Author

@Manishearth Manishearth commented Oct 19, 2016

There's no need to try and borrow it in this case, just store an Option<String>. The function it gets passed to calls .to_owned() on it anyway.

@cynicaldevil cynicaldevil mentioned this issue Oct 25, 2016
4 of 4 tasks complete
@jdm jdm added the C-has open PR label Nov 4, 2016
bors-servo added a commit that referenced this issue Nov 9, 2016
implemented string-valued text-overflow

<!-- Please describe your changes on the following line: -->
---

<!-- 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
- [X] These changes fix #13709

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

cc @Manishearth
The lorem-ipsum example from MDN works as expected.

<!-- 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/13924)

<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.