Commit graph

67 commits

Author SHA1 Message Date
Martin Robinson
b5c8164e99
layout: Simplify and generalize the usage of pseudo-elements (#36202)
- Remove the last remaining Servo-specific PseudoElement enum from
  layout. This was made to select `::before` and `::after` (both eager
  pseudo-elements), but now `traverse_pseudo_element` is called
  `traverse_eager_pseudo_element` and should work on any eager pseudo
  element.
- Expose a single way of getting psuedo-element variants of
  ThreadSafeLayoutElement in the Layout DOM, which returns `None` when
  the pseudo-element doesn't apply (not defined for eager
  pseudo-elements or when trying to get `<details>` related
  pseudo-elements on elements that they don't apply to).
- Ensure that NodeAndStyleInfo always refers to a node. This is done by
  making sure that anonymous boxes are all associated with their
  originating node.

These changes are prepatory work for implementation of the `::marker`
pseudo-element as well as ensuring that all anonymous boxes can be
cached into the box tree eventually.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-03-29 12:41:04 +00:00
batu_hoang
11d47558b3
Fix UA style value for textarea (#35574)
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-03-19 16:01:39 +00:00
DK Liao
ce4ba30992
feat: display file chosen for input file (#35789)
Signed-off-by: DK Liao <dklassic@gmail.com>
2025-03-10 03:55:38 +00:00
Simon Wülker
1990f04e38
Implement the <progress> element (#35531)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-02-26 10:14:20 +00:00
Simon Wülker
754b117011
Allow the <details> element to be opened and closed (#35261)
* Implement the <summary> element

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement UA shadow root for <details>

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Invalidate style when display is opened or closed

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix /_mozilla/mozilla/duplicated_scroll_ids.html

This test previously assumed that <details> elements would
not be rendered.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement implicit summary elements

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Remove test for duplicated scroll IDs

See https://github.com/servo/servo/pull/35261#discussion_r1969328725 for
reasoning.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Use Iterator::find to find implicit summary element

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-02-25 11:56:36 +00:00
Simon Wülker
085cd981aa
Support the <meter> element (#35524)
* Allow attaching UA shadow roots to any element

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement a UA shadow tree for the <meter> element

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Add UA styles for the meter element

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Include spec text when computing meter state

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-02-21 16:28:12 +00:00
batu_hoang
8c46749740
Implement overflow:clip (#35103)
* Implement overflow clip

Signed-off-by: longvatrong111 <longvatrong111@gmail.com>

* Modify test ini for overflow clip

Signed-off-by: longvatrong111 <longvatrong111@gmail.com>

* Update overflow_clip_rect calculation

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Update overflow-clip-margin border-radius according to shadow box

Signed-off-by: longvatrong111 <longvatrong111@gmail.com>

---------

Signed-off-by: longvatrong111 <longvatrong111@gmail.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: batu_hoang <55729155+longvatrong111@users.noreply.github.com>
2025-02-12 07:02:06 +00:00
Oriol Brufau
27c40fcd29
layout: Don't let table grid boxes inherit display: inline-table (#35264)
The outer display type of a table element applies to the table wrapper
box. The table grid box needs to be block-level as defined in
https://drafts.csswg.org/css-tables/#table-grid-box

Therefore this sets `display: table` on table grid boxes, and then when
painting collapsed table borders we can use the usual logic to compute
the StackingContextSection.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-02-03 17:11:49 +00:00
Martin Robinson
0eda2de19f
style: Add support for is() and where() selectors (#34066)
Additionally, changes now need to be made to `servo.css` in order to
ensure that `<button>` text is centered the same way that it is for
`<input type=button>`. In the past the rule for centering text for the
latter was ignored because it used `:is()`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-11-19 14:05:46 +00:00
Martin Robinson
56280c6242
layout: Add initial support for bidirectional text (BiDi) (#33148)
This adds supports for right-to-left text assigning bidi levels to all
line items when necessary. This includes support for the `dir` attribute
as well as corresponding CSS properties like `unicode-bidi`. It only
implements right-to-left rendering for inline layout at the moment and
doesn't include support for `dir=auto`. Because of missing features,
this causes quite a few tests to start failing, as references become
incorrect due to right-to-left rendering being active in some cases,
but not others (before it didn't exist at all).

Analysis of most of the new failures:

```
- /css/css-flexbox/gap-001-rtl.html
  /css/css-flexbox/gap-004-rtl.html
 - Require implementing BiDi in Flexbox, because the start and
   end inline margins are opposite the order of items.

- /css/CSS2/bidi-text/direction-applies-to-*.xht
  /css/CSS2/bidi-text/direction-applies-to-002.xht
  /css/CSS2/bidi-text/direction-applies-to-003.xht
  /css/CSS2/bidi-text/direction-applies-to-004.xht
  - Broken due to a bug in tables, not allocating the
    right amount of width for a column.

- /css/css-lists/inline-list.html
  - This fails because we wrongly insert a soft wrap opportunity between the
    start of an inline box and its first content.

- /css/css-text/bidi/bidi-lines-001.html
  /css/css-text/bidi/bidi-lines-002.html
  /css/CSS2/text/bidi-flag-emoji.html
  - We do not fully support unicode-bidi: plaintext

- /css/css-text/text-align/text-align-end-010.html
  /css/css-text/text-align/text-align-justify-006.html
  /css/css-text/text-align/text-align-start-010.html
  /html/dom/elements/global-attributes/*
  - We do not support dir=auto yet.

- /css/css-text/white-space/tab-bidi-001.html
  - Servo doesn't support tab stops

- /css/CSS2/positioning/abspos-block-level-001.html
  /css/css-text/word-break/word-break-normal-ar-000.html
  - Do not yet support RTL layout in block

- /css/css-text/white-space/pre-wrap-018.html
  - Even in RTL contexts, spaces at the end of the line must hang and
    not be reordered

- /css/css-text/white-space/trailing-space-and-text-alignment-rtl-002.html
  - We are letting spaces hang with white-space: pre, but they shouldn't
    hang.
```

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
2024-08-21 14:28:54 +00:00
Martin Robinson
569fd5d8b5
Upgrade stylo to 2024-07-16 (#32812)
* Upgrade stylo to 2024-07-16

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

* Use the new `dom` crate from stylo

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-07-24 14:37:08 +00:00
Martin Robinson
959ffad99a
layout: Add support for table captions (#32657)
This adds initial support for table captions. To do this, the idea of
the table wrapper becomes a bit more concrete. Even so, the wrapper is
still reponsible for allocating space for the grid's border and padding,
as those properties are specified on the wrapper and not grid in CSS.

In order to account for this weirdness of HTML/CSS captions and grid are
now laid out and placed with a negative offset in the table wrapper
content rect.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-07-03 18:24:19 +00:00
Martin Robinson
44064b1439
layout: Add very basic support for showing text in input boxes (#32365)
This only paints text in input fields. Selection and cursor are still
not painted.

In addition to adding this feature, the change also updates the
user-agent.css with the latest from the HTML specification. Extra
padding and extraneous settings (such as a bogus line-height and
min-height) are also removed from servo.css. This leads to some new
passes.

There are some new passes, this introduces failures as inserting text
reveals issues that were hidden before. Notably:

- failures in `/html/editing/editing-0/spelling-and-grammar-checking/`:
  We do not support spell-checking.
- Most of the rest of the new failures are missing features of input
  boxes that are also missing in legacy layout.
2024-06-20 10:13:50 +00:00
Oriol Brufau
b30b79a93a
Cleanup UA styles for anonymous table rows and cells (#31661)
These properties were being set to their initial value, this wasn't
needed because they are non-inherited properties and there isn't
anything else setting them.
2024-03-14 11:53:27 +00:00
Martin Robinson
49ae9bb442
layout: Fix the pseudo for anonymous tables (#31578)
Anonymous tables should not use legacy pseudos, as the legacy layout
engine had them inherit lots of random properites that lead to bad
layout in the new layout engine.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2024-03-08 10:32:51 +00:00
Martin Robinson
81f5157522
Add support for table fixups (#30868)
This adds support for fixing up tables so that internal table elements
that are not properly parented in the DOM have the correct box tree
structure according to the CSS Table specification [1]. Note that this
only comes into play when building the DOM via script, as HTML 5 has its
own table fixups that mean that the box tree construction fixups here
are not necessary.

There are no tests for this change. In general, it's hard to write tests
against the shape of the box tree, because it depends on the DOM. We
plan to test this via WPT tests once layout is complete.

1. https://drafts.csswg.org/css-tables/#table-internal-element

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2023-12-22 12:11:58 +00:00
Martin Robinson
fd31da9102
Anonymous boxes that wrap inlines should not inherit overflow (#30579)
In legacy layout, anonymous text wrappers were inheriting the `overflow`
and `text-overflow` properties. This results in the creation of extra
clipping for these anonymous wrappers which could clip away floats. We
will likely implement `text-overflow` differently in non-legacy layout.

This change marks all legacy layout pseudo elements as "legacy" and also
adds a new pseudo element for non-legacy layout that does not inherit
`overflow`.

Fixes #30562.

Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2023-10-19 13:43:55 +00:00
Josh Matthews
6a6662195e net: Add option to temporarily accept certs that failed the handshake. 2020-06-09 15:03:18 -04:00
Emilio Cobos Álvarez
5a2ba9661b
style: Re-enable the rule that was accidentally disabled by a typo in the CSS parser.
In #21946 I commented out this rule because before that patch we were
accidentally ignoring it because of a typo in the CSS parser, since that PR
didn't intend to change behavior.

This PR does though, and re-enables the rule.
2018-10-19 01:23:35 +02:00
Emilio Cobos Álvarez
6d7d1e5691
style: Remove useless declarations in servo.css.
Margin is a reset property, there's no point in setting it to zero since it's
zero by default.
2018-10-15 02:17:03 +02:00
Emilio Cobos Álvarez
7ed3995725
style: Stop using PseudoElement::inherits_all.
This was done that way just because Servo didn't support the `all` property at
the time.

We should do it this way and optimize it if it's slow. Though I suspect that
most of stuff doesn't actually need to be inherited, my patch at bug 1498943
should make it much faster than what it would otherwise be.
2018-10-15 02:17:03 +02:00
Martin Robinson
5937f62352 Wait as late as possible to assign ClipIds
This will allow Servo to create ClipScrollNodes later during display
list construction, which will be necessary once rounded rectangles
are removed from the LocalClip structure. Instead of keeping track
of the ClipId of each ClipScrollNode, we keep track of its index in an
array of ClipScrollNodes. This will allow us to access them without a
hash lookup.
2017-10-24 16:28:07 +02:00
Pu Xingyu
95ce2ac878 Inherit 'text-overflow' and 'overflow' in text fragment
This is an implementation detail that is necessary for 'text-overflow'
to work properly.
2017-04-05 11:04:30 +08:00
Pu Xingyu
951c050690 Use empty pseudo to cascade only inheritable properties for text
Since for nested inline elements non-inheritable properties are
properly stored in the inline context of an inline fragment, so get
rid of them on the style.
2017-04-01 14:05:11 +08:00
Pu Xingyu
1677d479f6 Use Servo-specific pseudo element for InlineAbsolute fragment 2017-03-31 02:45:09 +08:00
Pu Xingyu
836e554c30 Use Servo-specific pseudo element for InlineBlock fragment 2017-03-31 02:45:09 +08:00
Patrick Walton
1ab56c0ccd resources: Style anonymous blocks and anonymous table flows
appropriately in the UA stylesheet.
2016-10-26 14:14:02 -07:00
Patrick Walton
1996045343 resources: Remove the vertical-align: middle rule for buttons from
Servo's style sheet.

This doesn't vertically center the contents of buttons as it's intended
to and breaks layouts once `vertical-align: middle` is implemented.
2016-10-11 12:36:19 -07:00
Patrick Walton
2d31546eba resources: Give button elements white-space: normal again.
Fixes Twitter.

Originally regressed in 0a86543e6d.
2016-09-26 16:31:09 -07:00
Jonathan Schuster
8500f3c8b8 Style input-text pseudo with user-agent CSS 2016-09-21 21:21:32 -04:00
bors-servo
a3e8199c97 Auto merge of #12388 - kilobtye:textarea2, r=pcwalton
Let textarea wrap lines

<!-- Please describe your changes on the following line: -->
1. Change textarea's style from white-space: pre to white-space: pre-wrap.
2. Display insertion point when a line is wrapped.

---
<!-- 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 #10053 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/12388)
<!-- Reviewable:end -->
2016-07-26 08:31:49 -05:00
kilobtye
0a86543e6d Let textarea wrap lines 2016-07-26 20:38:11 +08:00
kilobtye
b9f8df1776 Make textarea scrollable 2016-07-16 12:56:35 +08:00
Connor Brewster
50096c21b0 Use proper comment syntax in servo.css 2016-06-30 11:12:01 -06:00
Zhen Zhang
6a5a4f2de5 add button for file-type input element 2016-06-26 10:22:07 +08:00
Tara
526e795f1c Change the font-size property for input and textarea
Change the `font-size` property for `input` and `textarea` from 0.7em
to 0.8333em.
2016-06-01 04:09:54 -05:00
Per Lundberg
d2469f0cde Reformatted servo.css
As discussed in #10553, we should consider splitting the long lines in this file onto separate lines (one per css attribute), to make it more readable and maintainable in general.

I also added blank lines where I felt it was applicable.
2016-05-15 00:27:49 +03:00
Zaggy1024
f3f1504003 Changed cursor for labels to "default" so their text doesn't use the text cursor. 2016-05-08 02:29:19 -05:00
bors-servo
e65009f317 Auto merge of #10809 - perlun:sendoushi-master, r=jdm
Fixed line-height for input and textarea + use correct font

Fixes #10532.

Replaces #10553 since @Sendoushi had problems getting a proper rebase locally, so helping him out to get this merged.

(Credits to Sendoushi who did the actual changes; I'm just helping out to getting things into a mergeable state.)

<!-- 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/10809)
<!-- Reviewable:end -->
2016-05-01 16:22:17 -07:00
Per Lundberg
220722e321 Fixed test failures. 2016-05-01 22:37:40 +03:00
Emilio Cobos Álvarez
cf5c090576
layout: Don't force to overwrite display for pseudo-elements. 2016-04-29 22:54:49 +02:00
Emilio Cobos Álvarez
2a499d5a0b
layout: Stop storing PrecomputedStyleData in LayoutNode
Use the SharedStyleContext instead.
2016-04-29 22:54:48 +02:00
Emilio Cobos Álvarez
3563ecb770
style: Use precomputation for the -servo-details-content pseudo-element 2016-04-29 22:54:45 +02:00
Joel Santos
adf68626bd Fixed line-height for input and textarea + use correct font
* [fix] Input line height and styling
* [new] Input line height ref test
* [fix] Test for input in manifest
* Updated CSS tests with new expected failures.
2016-04-29 23:25:26 +03:00
Arpad Borsos
606b11c0ec do not render svg children, fixes #10646 2016-04-25 14:28:43 +02:00
bors-servo
0397e2a24d Auto merge of #10299 - mbrubeck:selection-style, r=jdm
Set a default ::selection style

Since we no longer have a hard-coded default after #10252.

<!-- 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/10299)
<!-- Reviewable:end -->
2016-04-01 20:15:32 +05:30
Matt Brubeck
53250b3827 Set a default ::selection style 2016-03-30 18:05:34 -07:00
Nazım Can Altınova
c13ea8a253 Make input elements not inherit parent containers alignment
Added a reftest for input element's alignment

Added float: left beacause text-align: center centers the input's itself.

Removed 'rtl' alignment
2016-03-31 01:35:36 +03:00
Michael Howell
9d9c5398a8 Get the fundamentals of the HTMLDetailsElement rendering stuff working.
Still need to implement the style invalidation.

Part of #9395
2016-03-19 16:02:11 -07:00
Simon Sapin
79656278f2 Hide overflow of <input>, fix #9477 2016-03-04 19:48:19 +01:00