SlideShare a Scribd company logo
1 of 18
Download to read offline
CSS highlight pseudos
Delan Azabani (she/her)
November 2021
1
Hi, I’m Delan!
Building on the web since ~2004
Building the web since 2017
Joined Igalia in December last year
+
Special thanks to Rego ( ), who was responsible for much of the
work discussed here, and has been a huge help throughout this project.
*
azabani.com @dazabani
@regocas
2
Background
Spec overview, current status, next steps
Igalia’s work is primarily funded by our customers
This project was sponsored by 
Original patch allows recoloring spelling and grammar errors
Original task was to upstream the patch, but in practice…
3
Spec overview
“Real” elements are known as originating elements
Four built-in pseudo-elements
::selection (widely implemented)
::target-text (shipped in Blink)
#:~:text=keyword → keyword
::spelling-error
::grammar-error
Custom highlights with ::highlight(…)
Conceptually unlike other pseudo-elements
Inheritance-based style propagation
Tricky “overlay” painting behaviour
4
Not like other pseudos
All other pseudos interact with the box tree in some way
Highlight pseudos do not generate new boxes
they are singletons, but omnipresent within every box
styles vary depending on location in tree (“innermost”)
5
Highlight styles are inherited
<style>aside::selection { background: yellow; }</style>

<p>The quick brown fox jumps over the lazy dog.

<aside>The fox is <b>brown</b>.</aside>
6
Highlights “lift” text and decorations
(press z/x to animate)
fox
qui own
kc br
7
Highlights can add their own shadows
(press z/x to animate)
quick brown fox
qui fox
ck brown
8
Current status
::{spelling,grammar}-error (CSSSpellingGrammarErrors)
supported in style like any other highlight pseudo
paint support is limited to text-decoration-color
Highlight inheritance (HighlightInheritance)
supported for the four built-in highlight pseudos
needs optimisation for legacy content (*::selection)
Custom highlights (HighlightAPI)
Highlight painting is improving…
…but mostly only for ::selection
9
Highlight painting is improving…
(press z/x to animate)
qui own fox
brown
kc br
10
…but mostly only for ::selection
11
Next steps
12
Inheritance
Make ::highlight() use inheritance too →
Iron out edge cases, invalidation, and
color:currentColor
Improve perf of global ::selection rules
Investigate compat risks for ::selection →
Expose inherited styles to devtools, e.g.
<div>Tex<span>t sele</span>​
cted</div>
CL:3237158
csswg-drafts#6774
13
::selection rework
Design doc:
Merge the ::selection painter with the paint code for
other markers, including all of the ::selection-only
features
Replace k{Back,Fore}ground with phases for each
highlight, skipping over text in higher overlays
Help wanted with data structures: can the selection
“simply” become DocumentMarkers? What happens if
you Select All?
https://go.daz.cat/iri4b
14
Spec issues
— ensuring contrast of highlight colors (needs discussion)
— highlight text decoration painting ( work in progress)
— highlights and custom properties ( pending review)
— clarify paired-cascading behaviour ( pending review)
— compat risk with mixed highlight colors (needs discussion)
— highlight UA defaults and inheritance (needs discussion)
Testability issues
Need a way to reliably create spelling and grammar errors ( )
Need a way to allow UA highlight “tweaks” without breaking reftests
#6150
#6022 #6666
#6264 #6663
#6386 #6665
#6774
#6779
wpt#30863
15
More next steps
Minimal text-decoration painting impl for highlights other than ::selection?
Look into reconciling squiggly lines with wavy/dotted decorations (
)
Fix ::selection text-shadow clipping to take offsets into account (part of
)
Vertical scripts complicate this; we need to migrate away from

DrawLooper ( ) and clean up our coordinate handling
1257553
1147859
671438
16
Further reading
These slides (interactive):
Index of demos/patches/issues:
Blog post in May:
Second blog post coming soon ( )
on Slack
https://go.daz.cat/ufuce
https://go.daz.cat/giige
https://go.daz.cat/d65vn
@dazabani
#css-highlight-pseudos
17
18

More Related Content

Similar to CSS highlight pseudos

Display Suite: A Themers Perspective
Display Suite: A Themers PerspectiveDisplay Suite: A Themers Perspective
Display Suite: A Themers Perspective
Mediacurrent
 
Domain Driven Design Mat Holroyd
Domain Driven Design   Mat HolroydDomain Driven Design   Mat Holroyd
Domain Driven Design Mat Holroyd
melbournepatterns
 
The Language of the Web - HTML and CSS
The Language of the Web - HTML and CSSThe Language of the Web - HTML and CSS
The Language of the Web - HTML and CSS
kcasavale
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
Zohar Arad
 

Similar to CSS highlight pseudos (20)

Display Suite: A Themers Perspective
Display Suite: A Themers PerspectiveDisplay Suite: A Themers Perspective
Display Suite: A Themers Perspective
 
Style based
Style basedStyle based
Style based
 
Style based
Style basedStyle based
Style based
 
The Fast And The Fabulous
The Fast And The FabulousThe Fast And The Fabulous
The Fast And The Fabulous
 
Class[3][5th jun] [three js]
Class[3][5th jun] [three js]Class[3][5th jun] [three js]
Class[3][5th jun] [three js]
 
SAD14 - The Nuts and Bolts
SAD14 - The Nuts and BoltsSAD14 - The Nuts and Bolts
SAD14 - The Nuts and Bolts
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
 
The Road to Starling 2
The Road to Starling 2The Road to Starling 2
The Road to Starling 2
 
Building DSLs with Scala
Building DSLs with ScalaBuilding DSLs with Scala
Building DSLs with Scala
 
Domain Driven Design Mat Holroyd
Domain Driven Design   Mat HolroydDomain Driven Design   Mat Holroyd
Domain Driven Design Mat Holroyd
 
Panels rocks!
Panels rocks!Panels rocks!
Panels rocks!
 
Evaluating Base Themes
Evaluating Base ThemesEvaluating Base Themes
Evaluating Base Themes
 
Object Oriented Views / Aki Salmi
Object Oriented Views / Aki SalmiObject Oriented Views / Aki Salmi
Object Oriented Views / Aki Salmi
 
The Language of the Web - HTML and CSS
The Language of the Web - HTML and CSSThe Language of the Web - HTML and CSS
The Language of the Web - HTML and CSS
 
Code as Data workshop: Using source{d} Engine to extract insights from git re...
Code as Data workshop: Using source{d} Engine to extract insights from git re...Code as Data workshop: Using source{d} Engine to extract insights from git re...
Code as Data workshop: Using source{d} Engine to extract insights from git re...
 
"Dude, where’s my boilerplate? ", Oleksii Makodzeba
"Dude, where’s my boilerplate? ", Oleksii Makodzeba"Dude, where’s my boilerplate? ", Oleksii Makodzeba
"Dude, where’s my boilerplate? ", Oleksii Makodzeba
 
Non Relational Databases
Non Relational DatabasesNon Relational Databases
Non Relational Databases
 
Advanced CSS Troubleshooting
Advanced CSS TroubleshootingAdvanced CSS Troubleshooting
Advanced CSS Troubleshooting
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
DSL explained _
DSL explained _DSL explained _
DSL explained _
 

More from Igalia

Building End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPEBuilding End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPE
Igalia
 
Automated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded DevicesAutomated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded Devices
Igalia
 
Running JS via WASM faster with JIT
Running JS via WASM      faster with JITRunning JS via WASM      faster with JIT
Running JS via WASM faster with JIT
Igalia
 
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por IgaliaIntroducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Igalia
 

More from Igalia (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Building End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPEBuilding End-user Applications on Embedded Devices with WPE
Building End-user Applications on Embedded Devices with WPE
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded DevicesAutomated Testing for Web-based Systems on Embedded Devices
Automated Testing for Web-based Systems on Embedded Devices
 
Embedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to MaintenanceEmbedding WPE WebKit - from Bring-up to Maintenance
Embedding WPE WebKit - from Bring-up to Maintenance
 
Optimizing Scheduler for Linux Gaming.pdf
Optimizing Scheduler for Linux Gaming.pdfOptimizing Scheduler for Linux Gaming.pdf
Optimizing Scheduler for Linux Gaming.pdf
 
Running JS via WASM faster with JIT
Running JS via WASM      faster with JITRunning JS via WASM      faster with JIT
Running JS via WASM faster with JIT
 
To crash or not to crash: if you do, at least recover fast!
To crash or not to crash: if you do, at least recover fast!To crash or not to crash: if you do, at least recover fast!
To crash or not to crash: if you do, at least recover fast!
 
Implementing a Vulkan Video Encoder From Mesa to GStreamer
Implementing a Vulkan Video Encoder From Mesa to GStreamerImplementing a Vulkan Video Encoder From Mesa to GStreamer
Implementing a Vulkan Video Encoder From Mesa to GStreamer
 
8 Years of Open Drivers, including the State of Vulkan in Mesa
8 Years of Open Drivers, including the State of Vulkan in Mesa8 Years of Open Drivers, including the State of Vulkan in Mesa
8 Years of Open Drivers, including the State of Vulkan in Mesa
 
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por IgaliaIntroducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
Introducción a Mesa. Caso específico dos dispositivos Raspberry Pi por Igalia
 
2023 in Chimera Linux
2023 in Chimera                    Linux2023 in Chimera                    Linux
2023 in Chimera Linux
 
Building a Linux distro with LLVM
Building a Linux distro        with LLVMBuilding a Linux distro        with LLVM
Building a Linux distro with LLVM
 
turnip: Update on Open Source Vulkan Driver for Adreno GPUs
turnip: Update on Open Source Vulkan Driver for Adreno GPUsturnip: Update on Open Source Vulkan Driver for Adreno GPUs
turnip: Update on Open Source Vulkan Driver for Adreno GPUs
 
Graphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devicesGraphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devices
 
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOSDelegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
 
MessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the webMessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the web
 
Replacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shadersReplacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shaders
 
I'm not an AMD expert, but...
I'm not an AMD expert, but...I'm not an AMD expert, but...
I'm not an AMD expert, but...
 
Status of Vulkan on Raspberry
Status of Vulkan on RaspberryStatus of Vulkan on Raspberry
Status of Vulkan on Raspberry
 

Recently uploaded

audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
lolsDocherty
 
Production 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptxProduction 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptx
ChloeMeadows1
 

Recently uploaded (17)

Development Lifecycle.pptx for the secure development of apps
Development Lifecycle.pptx for the secure development of appsDevelopment Lifecycle.pptx for the secure development of apps
Development Lifecycle.pptx for the secure development of apps
 
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
 
Cyber Security Services Unveiled: Strategies to Secure Your Digital Presence
Cyber Security Services Unveiled: Strategies to Secure Your Digital PresenceCyber Security Services Unveiled: Strategies to Secure Your Digital Presence
Cyber Security Services Unveiled: Strategies to Secure Your Digital Presence
 
Thank You Luv I’ll Never Walk Alone Again T shirts
Thank You Luv I’ll Never Walk Alone Again T shirtsThank You Luv I’ll Never Walk Alone Again T shirts
Thank You Luv I’ll Never Walk Alone Again T shirts
 
Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdf
 
How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?
 
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
TORTOGEL TELAH MENJADI SALAH SATU PLATFORM PERMAINAN PALING FAVORIT.
 
Bug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's GuideBug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's Guide
 
iThome_CYBERSEC2024_Drive_Into_the_DarkWeb
iThome_CYBERSEC2024_Drive_Into_the_DarkWebiThome_CYBERSEC2024_Drive_Into_the_DarkWeb
iThome_CYBERSEC2024_Drive_Into_the_DarkWeb
 
Reggie miller choke t shirtsReggie miller choke t shirts
Reggie miller choke t shirtsReggie miller choke t shirtsReggie miller choke t shirtsReggie miller choke t shirts
Reggie miller choke t shirtsReggie miller choke t shirts
 
Free scottie t shirts Free scottie t shirts
Free scottie t shirts Free scottie t shirtsFree scottie t shirts Free scottie t shirts
Free scottie t shirts Free scottie t shirts
 
Statistical Analysis of DNS Latencies.pdf
Statistical Analysis of DNS Latencies.pdfStatistical Analysis of DNS Latencies.pdf
Statistical Analysis of DNS Latencies.pdf
 
Production 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptxProduction 2024 sunderland culture final - Copy.pptx
Production 2024 sunderland culture final - Copy.pptx
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case Study
 
I’ll See Y’All Motherfuckers In Game 7 Shirt
I’ll See Y’All Motherfuckers In Game 7 ShirtI’ll See Y’All Motherfuckers In Game 7 Shirt
I’ll See Y’All Motherfuckers In Game 7 Shirt
 
GOOGLE Io 2024 At takes center stage.pdf
GOOGLE Io 2024 At takes center stage.pdfGOOGLE Io 2024 At takes center stage.pdf
GOOGLE Io 2024 At takes center stage.pdf
 
Premier Mobile App Development Agency in USA.pdf
Premier Mobile App Development Agency in USA.pdfPremier Mobile App Development Agency in USA.pdf
Premier Mobile App Development Agency in USA.pdf
 

CSS highlight pseudos

  • 1. CSS highlight pseudos Delan Azabani (she/her) November 2021 1
  • 2. Hi, I’m Delan! Building on the web since ~2004 Building the web since 2017 Joined Igalia in December last year + Special thanks to Rego ( ), who was responsible for much of the work discussed here, and has been a huge help throughout this project. * azabani.com @dazabani @regocas 2
  • 3. Background Spec overview, current status, next steps Igalia’s work is primarily funded by our customers This project was sponsored by  Original patch allows recoloring spelling and grammar errors Original task was to upstream the patch, but in practice… 3
  • 4. Spec overview “Real” elements are known as originating elements Four built-in pseudo-elements ::selection (widely implemented) ::target-text (shipped in Blink) #:~:text=keyword → keyword ::spelling-error ::grammar-error Custom highlights with ::highlight(…) Conceptually unlike other pseudo-elements Inheritance-based style propagation Tricky “overlay” painting behaviour 4
  • 5. Not like other pseudos All other pseudos interact with the box tree in some way Highlight pseudos do not generate new boxes they are singletons, but omnipresent within every box styles vary depending on location in tree (“innermost”) 5
  • 6. Highlight styles are inherited <style>aside::selection { background: yellow; }</style> <p>The quick brown fox jumps over the lazy dog. <aside>The fox is <b>brown</b>.</aside> 6
  • 7. Highlights “lift” text and decorations (press z/x to animate) fox qui own kc br 7
  • 8. Highlights can add their own shadows (press z/x to animate) quick brown fox qui fox ck brown 8
  • 9. Current status ::{spelling,grammar}-error (CSSSpellingGrammarErrors) supported in style like any other highlight pseudo paint support is limited to text-decoration-color Highlight inheritance (HighlightInheritance) supported for the four built-in highlight pseudos needs optimisation for legacy content (*::selection) Custom highlights (HighlightAPI) Highlight painting is improving… …but mostly only for ::selection 9
  • 10. Highlight painting is improving… (press z/x to animate) qui own fox brown kc br 10
  • 11. …but mostly only for ::selection 11
  • 13. Inheritance Make ::highlight() use inheritance too → Iron out edge cases, invalidation, and color:currentColor Improve perf of global ::selection rules Investigate compat risks for ::selection → Expose inherited styles to devtools, e.g. <div>Tex<span>t sele</span>​ cted</div> CL:3237158 csswg-drafts#6774 13
  • 14. ::selection rework Design doc: Merge the ::selection painter with the paint code for other markers, including all of the ::selection-only features Replace k{Back,Fore}ground with phases for each highlight, skipping over text in higher overlays Help wanted with data structures: can the selection “simply” become DocumentMarkers? What happens if you Select All? https://go.daz.cat/iri4b 14
  • 15. Spec issues — ensuring contrast of highlight colors (needs discussion) — highlight text decoration painting ( work in progress) — highlights and custom properties ( pending review) — clarify paired-cascading behaviour ( pending review) — compat risk with mixed highlight colors (needs discussion) — highlight UA defaults and inheritance (needs discussion) Testability issues Need a way to reliably create spelling and grammar errors ( ) Need a way to allow UA highlight “tweaks” without breaking reftests #6150 #6022 #6666 #6264 #6663 #6386 #6665 #6774 #6779 wpt#30863 15
  • 16. More next steps Minimal text-decoration painting impl for highlights other than ::selection? Look into reconciling squiggly lines with wavy/dotted decorations ( ) Fix ::selection text-shadow clipping to take offsets into account (part of ) Vertical scripts complicate this; we need to migrate away from DrawLooper ( ) and clean up our coordinate handling 1257553 1147859 671438 16
  • 17. Further reading These slides (interactive): Index of demos/patches/issues: Blog post in May: Second blog post coming soon ( ) on Slack https://go.daz.cat/ufuce https://go.daz.cat/giige https://go.daz.cat/d65vn @dazabani #css-highlight-pseudos 17
  • 18. 18