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 upImplement root element backgrounds #19704
Conversation
| return; | ||
| } | ||
| let root_block = root_flow.as_mut_block(); | ||
| let root_style = ServoArc::make_mut(&mut root_block.fragment.style); |
This comment has been minimized.
This comment has been minimized.
emilio
Jan 6, 2018
Member
It looks unfortunate to mutate the style from here... We should at least move the make_mut to where we know we are going to change it.
This comment has been minimized.
This comment has been minimized.
pyfisch
Jan 6, 2018
Author
Contributor
It looks unfortunate to mutate the style from here
Where should it be done instead?
| .resolve_color(kid_block_flow.fragment.style.get_background().background_color) | ||
| .to_gfx_color() | ||
| let kid_mut_block = kid.as_mut_block(); | ||
| let kid_background = ServoArc::make_mut(&mut kid_mut_block.fragment.style).mutate_background(); |
This comment has been minimized.
This comment has been minimized.
emilio
Jan 6, 2018
Member
I'm pretty sure this make_mut is not needed, is it?
Why wouldn't just kid_mut_block.fragment.style.get_background() suffice?
But more importantly:
- What guarantees that the
<body>is a block? - What guarantees that it's the first block?
Not that the code before wasn't wrong, but...
This comment has been minimized.
This comment has been minimized.
pyfisch
Jan 6, 2018
Author
Contributor
I'm pretty sure this make_mut is not needed, is it?
Why wouldn't just kid_mut_block.fragment.style.get_background() suffice?
Well the borrow checker disagrees. In lines 1709 and 1710 kid_background is mutated. This prompts the compiler to tell me cannot borrow immutable borrowed content `*kid_background` as mutable.
What guarantees that the is a block?
Good catch. While the <body> is usually a block with body { display: inline; } it is not. Which other FlowClass besides block and inline can it be?
What guarantees that it's the first block?
The body element is always the first block. (Even if there is no <body> tag in the source code. Or the code is something like <a href="https://mozilla.org">Mozilla</a><body>Main content</body>.)
There must be some specifications that describes this. One part is Optional Tags. Another is HTML parsing The "after head" insertion mode and HTML parsing The "in body" insertion mode. Servo seems to follow all these weird rules as far as I can tell.
This comment has been minimized.
This comment has been minimized.
emilio
Jan 6, 2018
Member
The body element is always the first block. (Even if there is no tag in the source code. Or the code is something like MozillaMain content.)
I'm pretty sure I can do head { display: block }.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
pyfisch
Jan 6, 2018
Author
Contributor
I'm pretty sure I can do head { display: block }.
Yes this breaks my assumption "always first block". And afaik I can't even ask flows if they are a body element.
|
I've pushed an updated version. It works with |
|
I think we should fix this properly. Fragments contain the I also think that just mutating the fragment's style using |
I have done this. For block-like elements I can now check if BTW the correct way to get a document body is described at https://html.spec.whatwg.org/multipage/dom.html#dom-document-body. |
|
I think for inlines you need to iterate all the fragments and find the one corresponding to the body, if any. @mbrubeck can correct me here if I'm wrong. |
|
Unfortunately the I feel that is the wrong place to implement this. Probably it should be done in For testing:
|
pyfisch commentedJan 5, 2018
•
edited by SimonSapin
Note: #19669 is visible with background images (and some gradients).
Note 2: Maybe the root background only needs to be propagated on REPAINT?
Note 3: I am not sure what the complete implications of not sending a background color to webrender are. But setting one gives wrong results with partially transparent background colors.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is