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 upMake text decorations have the same color as the text if no shadows are present #12233
Conversation
highfive
commented
Jul 4, 2016
|
@bors-servo try |
Make text decorations have the same color as the text if no shadows are present <!-- 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 #11870 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because according to @SimonSapin, making reftests against underlines are impossible <!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12233) <!-- Reviewable:end -->
| stacking_relative_content_box.translate(&Point2D::new(shadow.offset_x, shadow.offset_y)) | ||
| } else { | ||
| stacking_relative_content_box.translate(&Point2D::new(Au(0), Au(0))) | ||
| }; |
This comment has been minimized.
This comment has been minimized.
frewsxcv
Jul 4, 2016
•
Member
Alternatively:
let shadow = text_shadow.map(|s| Point2D::new(s.offset_x, s.offset_y))
.unwrap_or_else(Point2D::zero);
let stacking_relative_content_box = stacking_relative_content_box.translate(shadow);| text_decorations.overline = text_decorations.overline.map(|_| color); | ||
| text_decorations.line_through = text_decorations.line_through.map(|_| color); | ||
| } else { | ||
| // Otherwise, paint the decorations the same color as the text color. | ||
| text_decorations.underline = text_decorations.underline.map(|_| text_color); | ||
| text_decorations.overline = text_decorations.overline.map(|_| text_color); | ||
| text_decorations.line_through = text_decorations.line_through.map(|_| text_color); |
This comment has been minimized.
This comment has been minimized.
frewsxcv
Jul 4, 2016
•
Member
Alternatively:
let color = if let Some(shadow) {
// If we're painting a shadow, paint the decorations the same color as the shadow.
self.style().resolve_color(shadow.color)
} else {
// Otherwise, paint the decorations the same color as the text color.
text_color
};
text_decorations.underline = text_decorations.underline.map(|_| color);
text_decorations.overline = text_decorations.overline.map(|_| color);
text_decorations.line_through = text_decorations.line_through.map(|_| color);|
|
highfive
commented
Jul 4, 2016
|
|
Also from test-css:
|
|
@bors-servo try |
Make text decorations have the same color as the text if no shadows are present <!-- 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 #11870 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because according to @SimonSapin, making reftests against underlines are impossible <!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12233) <!-- Reviewable:end -->
|
If a text shadow and underline are both present, then the shadow will have the same color as the text instead of its real color. <!DOCTYPE html>
<span style="text-shadow: 0 0 10px green; color: red; text-decoration: underline">Test text</span>Couldn't |
|
@KiChjang, you fixed it a few seconds before I posted that comment. Don't mind me. |
|
|
|
Review status: 0 of 4 files reviewed at latest revision, 3 unresolved discussions. components/layout/display_list_builder.rs, line 1569 [r2] (raw file):
Can we compute the color just in one place? Something like: let text_color = if let Some(shadow) = text_shadow {
self.style().resolve_color(shadow.color)
} else if fragment.selected() {
...
} else {
...
};Also. a link to the relevant spec fragment or similar would be extremely nice. And a line saying: ( LGTM with that :) Comments from Reviewable |
|
Review status: 1 of 4 files reviewed at latest revision, 4 unresolved discussions. components/layout/display_list_builder.rs, line 1537 [r2] (raw file):
Also, here you could write: let (offset, shadow_blur_radius) = match text_shadow {
Some(shadow) => {...}
None => {..}
};That would avoid using components/layout/display_list_builder.rs, line 1569 [r2] (raw file):
|
9e6fd14
to
2ce6850
…re present
|
I'm not sure where the relevant spec is located, but other than that, I've addressed the comments. |
|
LGTM @bors-servo: r+ -S-awaiting-review +S-awaiting-answer Reviewed 3 of 4 files at r2, 1 of 1 files at r3. Comments from Reviewable |
|
|
Make text decorations have the same color as the text if no shadows are present <!-- 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 #11870 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because according to @SimonSapin, making reftests against underlines are impossible <!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12233) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
|
The test failed with a different panic: |
|
@bors-servo retry |
Make text decorations have the same color as the text if no shadows are present <!-- 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 #11870 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because according to @SimonSapin, making reftests against underlines are impossible <!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12233) <!-- Reviewable:end -->
|
|


KiChjang commentedJul 4, 2016
•
edited by larsbergstrom
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is