2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*
  
						 
					
						
							
								
									
										
										
										
											2024-10-04 13:19:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2022 - 2023 ,  Andreas  Kling  < andreas @ ladybird . org > 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-20 12:17:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2022 - 2025 ,  Sam  Atkins  < sam @ ladybird . org > 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2024 - 2025 ,  Aliaksandr  Kalenik  < kalenik . aliaksandr @ gmail . com > 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-15 16:37:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2025 ,  Jelle  Raaijmakers  < jelle @ ladybird . org > 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-19 11:02:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <AK/GenericShorthands.h> 
  
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <AK/TemporaryChange.h> 
  
						 
					
						
							
								
									
										
										
										
											2025-04-19 19:10:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibGfx/Font/Font.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-05-01 22:36:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibUnicode/CharacterTypes.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-23 17:18:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/SystemColor.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Document.h> 
  
						 
					
						
							
								
									
										
											 
										
											
												LibWeb: Separate text control input events handling from contenteditable
This input event handling change is intended to address the following
design issues:
- Having `DOM::Position` is unnecessary complexity when `Selection`
  exists because caret position could be described by the selection
  object with a collapsed state. Before this change, we had to
  synchronize those whenever one of them was modified, and there were
  already bugs caused by that, i.e., caret position was not changed when
  selection offset was modified from the JS side.
- Selection API exposes selection offset within `<textarea>` and
  `<input>`, which is not supposed to happen. These objects should
  manage their selection state by themselves and have selection offset
  even when they are not displayed.
- `EventHandler` looks only at `DOM::Text` owned by `DOM::Position`
  while doing text manipulations. It works fine for `<input>` and
  `<textarea>`, but `contenteditable` needs to consider all text
  descendant text nodes; i.e., if the cursor is moved outside of
  `DOM::Text`, we need to look for an adjacent text node to move the
  cursor there.
With this change, `EventHandler` no longer does direct manipulations on
caret position or text content, but instead delegates them to the active
`InputEventsTarget`, which could be either
`FormAssociatedTextControlElement` (for `<input>` and `<textarea>`) or
`EditingHostManager` (for `contenteditable`). The `Selection` object is
used to manage both selection and caret position for `contenteditable`,
and text control elements manage their own selection state that is not
exposed by Selection API.
This change improves text editing on Discord, as now we don't have to
refocus the `contenteditable` element after character input. The problem
was that selection manipulations from the JS side were not propagated
to `DOM::Position`.
I expect this change to make future correctness improvements for
`contenteditable` (and `designMode`) easier, as now it's decoupled from
`<input>` and `<textarea>` and separated from `EventHandler`, which is
quite a busy file.
											 
										 
										
											2024-10-23 21:26:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Position.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Range.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/HTMLHtmlElement.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/Window.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Layout/BlockContainer.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-10-16 02:38:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Layout/InlineNode.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/BackgroundPainting.h> 
  
						 
					
						
							
								
									
										
										
										
											2025-02-02 15:55:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/DisplayListRecorder.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/PaintableBox.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/SVGPaintable.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/SVGSVGPaintable.h> 
  
						 
					
						
							
								
									
										
										
										
											2025-06-11 09:07:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/ShadowPainting.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-11 00:03:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/StackingContext.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-07-30 13:41:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/TableBordersPainting.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-01-25 19:21:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/TextPaintable.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-19 08:38:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Painting/ViewportPaintable.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-09-17 21:25:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Platform/FontPlugin.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Selection/Selection.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								namespace  Web : : Painting  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 01:09:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC_DEFINE_ALLOCATOR ( PaintableWithLines ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-16 11:22:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  g_paint_viewport_scrollbars  =  true ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ref < PaintableWithLines >  PaintableWithLines : : create ( Layout : : BlockContainer  const &  block_container )  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-11-14 06:13:46 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  block_container . heap ( ) . allocate < PaintableWithLines > ( block_container ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-11 12:51:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ref < PaintableWithLines >  PaintableWithLines : : create ( Layout : : InlineNode  const &  inline_node ,  size_t  line_index )  
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-11-14 06:13:46 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  inline_node . heap ( ) . allocate < PaintableWithLines > ( inline_node ,  line_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ref < PaintableBox >  PaintableBox : : create ( Layout : : Box  const &  layout_box )  
						 
					
						
							
								
									
										
										
										
											2023-01-11 12:51:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-11-14 06:13:46 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  layout_box . heap ( ) . allocate < PaintableBox > ( layout_box ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ref < PaintableBox >  PaintableBox : : create ( Layout : : InlineNode  const &  layout_box )  
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-11-14 06:13:46 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  layout_box . heap ( ) . allocate < PaintableBox > ( layout_box ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								PaintableBox : : PaintableBox ( Layout : : Box  const &  layout_box )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    :  Paintable ( layout_box ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								PaintableBox : : PaintableBox ( Layout : : InlineNode  const &  layout_box )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    :  Paintable ( layout_box ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								PaintableBox : : ~ PaintableBox ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								PaintableWithLines : : PaintableWithLines ( Layout : : BlockContainer  const &  layout_box )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    :  PaintableBox ( layout_box ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								PaintableWithLines : : PaintableWithLines ( Layout : : InlineNode  const &  inline_node ,  size_t  line_index )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    :  PaintableBox ( inline_node ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_line_index ( line_index ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								PaintableWithLines : : ~ PaintableWithLines ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 20:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelPoint  PaintableBox : : scroll_offset ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-06-03 17:53:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_viewport ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  navigable  =  document ( ) . navigable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( navigable ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  navigable - > viewport_scroll_offset ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 20:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  node  =  layout_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 10:11:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  pseudo_element  =  node . generated_for_pseudo_element ( ) ;  pseudo_element . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  node . pseudo_element_generator ( ) - > scroll_offset ( * pseudo_element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 20:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 21:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! ( dom_node ( )  & &  is < DOM : : Element > ( * dom_node ( ) ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 20:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 10:11:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  static_cast < DOM : : Element  const * > ( dom_node ( ) ) - > scroll_offset ( { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 20:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 21:10:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : set_scroll_offset ( CSSPixelPoint  offset )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-02-22 01:27:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollable_overflow_rect  =  this - > scrollable_overflow_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! scrollable_overflow_rect . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-28 13:47:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    document ( ) . set_needs_to_refresh_scroll_state ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 12:08:21 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  padding_rect  =  absolute_padding_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  max_x_offset  =  max ( scrollable_overflow_rect - > width ( )  -  padding_rect . width ( ) ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  max_y_offset  =  max ( scrollable_overflow_rect - > height ( )  -  padding_rect . height ( ) ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 17:18:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-22 01:27:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    offset . set_x ( clamp ( offset . x ( ) ,  0 ,  max_x_offset ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    offset . set_y ( clamp ( offset . y ( ) ,  0 ,  max_y_offset ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 21:10:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: If there is horizontal and vertical scroll ignore only part of the new offset
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( offset . y ( )  <  0  | |  scroll_offset ( )  = =  offset ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  node  =  layout_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 10:11:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  pseudo_element  =  node . generated_for_pseudo_element ( ) ;  pseudo_element . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        node . pseudo_element_generator ( ) - > set_scroll_offset ( * pseudo_element ,  offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 21:10:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( is < DOM : : Element > ( * dom_node ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 10:11:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        static_cast < DOM : : Element * > ( dom_node ( ) ) - > set_scroll_offset ( { } ,  offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 21:10:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-22 18:16:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // https://drafts.csswg.org/cssom-view-1/#scrolling-events
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Whenever an element gets scrolled (whether in response to user interaction or by an API),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // the user agent must run these steps:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 1. Let doc be the element’  
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  document  =  layout_node ( ) . document ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-22 18:16:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 2. If the element is a snap container, run the steps to update snapchanging targets for the element with
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    //           the element’ ’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //           target in the inline axis as newInlineTarget.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ref < DOM : : EventTarget >  const  event_target  =  * dom_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-22 18:16:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 3. If the element is already in doc’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( document . pending_scroll_event_targets ( ) . contains_slow ( event_target ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 4. Append the element to doc’  
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    document . pending_scroll_event_targets ( ) . append ( * layout_node_with_style_and_box_metrics ( ) . dom_node ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-22 18:16:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 16:47:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    set_needs_display ( InvalidateDisplayList : : No ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 21:10:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 20:29:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : scroll_by ( int  delta_x ,  int  delta_y )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-02-22 01:27:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    set_scroll_offset ( scroll_offset ( ) . translated ( delta_x ,  delta_y ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 20:29:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : set_offset ( CSSPixelPoint  offset )  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_offset  =  offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : set_content_size ( CSSPixelSize  size )  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_content_size  =  size ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is < Layout : : Box > ( Paintable : : layout_node ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        static_cast < Layout : : Box & > ( layout_node_with_style_and_box_metrics ( ) ) . did_set_content_size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-15 15:42:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelPoint  PaintableBox : : offset ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-08-15 15:11:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  m_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : compute_absolute_rect ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-03-24 16:06:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-08-15 15:42:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    CSSPixelRect  rect  {  offset ( ) ,  content_size ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 15:30:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const *  block  =  containing_block ( ) ;  block ;  block  =  block - > containing_block ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        rect . translate_by ( block - > offset ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 16:06:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : absolute_rect ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-24 16:06:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! m_absolute_rect . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_absolute_rect  =  compute_absolute_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-12 00:35:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  * m_absolute_rect ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : compute_absolute_paint_rect ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-09-25 15:13:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: This likely incomplete:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  rect  =  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-12 18:59:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( has_scrollable_overflow ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  scrollable_overflow_rect  =  this - > scrollable_overflow_rect ( ) . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( computed_values ( ) . overflow_x ( )  = =  CSS : : Overflow : : Visible ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            rect . unite_horizontally ( scrollable_overflow_rect ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( computed_values ( ) . overflow_y ( )  = =  CSS : : Overflow : : Visible ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            rect . unite_vertically ( scrollable_overflow_rect ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 19:42:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  shadow  :  box_shadow_data ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 15:13:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( shadow . placement  = =  ShadowPlacement : : Inner ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  inflate  =  shadow . spread_distance  +  shadow . blur_radius ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  shadow_rect  =  rect . inflated ( inflate ,  inflate ,  inflate ,  inflate ) . translated ( shadow . offset_x ,  shadow . offset_y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-15 13:51:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        rect . unite ( shadow_rect ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 15:13:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-15 16:37:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : absolute_padding_box_rect ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  absolute_rect  =  this - > absolute_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    CSSPixelRect  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_x ( absolute_rect . x ( )  -  box_model ( ) . padding . left ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_width ( content_width ( )  +  box_model ( ) . padding . left  +  box_model ( ) . padding . right ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_y ( absolute_rect . y ( )  -  box_model ( ) . padding . top ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_height ( content_height ( )  +  box_model ( ) . padding . top  +  box_model ( ) . padding . bottom ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : absolute_border_box_rect ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  padded_rect  =  this - > absolute_padding_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    CSSPixelRect  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  use_collapsing_borders_model  =  override_borders_data ( ) . has_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Implement the collapsing border model https://www.w3.org/TR/CSS22/tables.html#collapsing-borders.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  border_top  =  use_collapsing_borders_model  ?  round ( box_model ( ) . border . top  /  2 )  :  box_model ( ) . border . top ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  border_bottom  =  use_collapsing_borders_model  ?  round ( box_model ( ) . border . bottom  /  2 )  :  box_model ( ) . border . bottom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  border_left  =  use_collapsing_borders_model  ?  round ( box_model ( ) . border . left  /  2 )  :  box_model ( ) . border . left ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  border_right  =  use_collapsing_borders_model  ?  round ( box_model ( ) . border . right  /  2 )  :  box_model ( ) . border . right ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_x ( padded_rect . x ( )  -  border_left ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_width ( padded_rect . width ( )  +  border_left  +  border_right ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_y ( padded_rect . y ( )  -  border_top ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rect . set_height ( padded_rect . height ( )  +  border_top  +  border_bottom ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-03 11:22:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://drafts.csswg.org/css-overflow-4/#overflow-clip-edge
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : overflow_clip_edge_rect ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Apply overflow-clip-margin-* properties
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  absolute_padding_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : absolute_paint_rect ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-09-25 15:13:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! m_absolute_paint_rect . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_absolute_paint_rect  =  compute_absolute_paint_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  * m_absolute_paint_rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-15 16:37:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  Callable >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								static  CSSPixelRect  united_rect_for_continuation_chain ( PaintableBox  const &  start ,  Callable  get_rect )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Combine the absolute rects of all paintable boxes of all nodes in the continuation chain. Without this, we
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // calculate the wrong rect for inline nodes that were split because of block elements.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < CSSPixelRect >  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: instead of walking the continuation chain in the layout tree, also keep track of this chain in the
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //        painting tree so we can skip visiting the layout nodes altogether.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const *  node  =  & start . layout_node_with_style_and_box_metrics ( ) ;  node ;  node  =  node - > continuation_of_node ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  const &  paintable  :  node - > paintables ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! is < PaintableBox > ( paintable ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  paintable_box  =  static_cast < PaintableBox  const & > ( paintable ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  paintable_border_box_rect  =  get_rect ( paintable_box ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! result . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                result  =  paintable_border_box_rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            else  if  ( ! paintable_border_box_rect . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                result - > unite ( paintable_border_box_rect ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  result . value_or ( { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : absolute_united_border_box_rect ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  united_rect_for_continuation_chain ( * this ,  [ ] ( auto  const &  paintable_box )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  paintable_box . absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : absolute_united_content_rect ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  united_rect_for_continuation_chain ( * this ,  [ ] ( auto  const &  paintable_box )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  paintable_box . absolute_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : absolute_united_padding_box_rect ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  united_rect_for_continuation_chain ( * this ,  [ ] ( auto  const &  paintable_box )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  paintable_box . absolute_padding_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-31 17:08:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < CSSPixelRect >  PaintableBox : : get_clip_rect ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  clip  =  computed_values ( ) . clip ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( clip . is_rect ( )  & &  layout_node_with_style_and_box_metrics ( ) . is_absolutely_positioned ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-31 17:08:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  border_box  =  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-31 17:16:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  clip . to_rect ( ) . resolved ( layout_node ( ) ,  border_box ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-31 17:08:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  PaintableBox : : wants_mouse_events ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:15:13 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( compute_scrollbar_data ( ScrollDirection : : Vertical ) . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:15:13 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( compute_scrollbar_data ( ScrollDirection : : Horizontal ) . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:27:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : before_paint ( PaintContext &  context ,  PaintPhase  phase )  const  
						 
					
						
							
								
									
										
										
										
											2023-08-31 17:08:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! is_visible ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:27:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( first_is_one_of ( phase ,  PaintPhase : : Background ,  PaintPhase : : Foreground )  & &  own_clip_frame ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-13 03:55:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        context . display_list_recorder ( ) . push_clip_frame ( own_clip_frame ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:27:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( ! has_css_transform ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-31 22:26:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        apply_clip_overflow_rect ( context ,  phase ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:39:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    apply_scroll_offset ( context ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-31 17:08:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:27:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : after_paint ( PaintContext &  context ,  PaintPhase  phase )  const  
						 
					
						
							
								
									
										
										
										
											2023-08-31 17:08:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! is_visible ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:39:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    reset_scroll_offset ( context ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:27:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( first_is_one_of ( phase ,  PaintPhase : : Background ,  PaintPhase : : Foreground )  & &  own_clip_frame ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-13 03:55:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        context . display_list_recorder ( ) . pop_clip_frame ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:27:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( ! has_css_transform ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-31 22:26:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        clear_clip_overflow_rect ( context ,  phase ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-31 17:08:45 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 15:47:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  PaintableBox : : could_be_scrolled_by_wheel_event ( ScrollDirection  direction )  const  
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  overflow  =  direction  = =  ScrollDirection : : Horizontal  ?  computed_values ( ) . overflow_x ( )  :  computed_values ( ) . overflow_y ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollable_overflow_rect  =  this - > scrollable_overflow_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! scrollable_overflow_rect . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollable_overflow_size  =  direction  = =  ScrollDirection : : Horizontal  ?  scrollable_overflow_rect - > width ( )  :  scrollable_overflow_rect - > height ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollport_size  =  direction  = =  ScrollDirection : : Horizontal  ?  absolute_padding_box_rect ( ) . width ( )  :  absolute_padding_box_rect ( ) . height ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 15:54:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  overflow_value_allows_scrolling  =  overflow  = =  CSS : : Overflow : : Auto  | |  overflow  = =  CSS : : Overflow : : Scroll ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ( is_viewport ( )  & &  overflow  ! =  CSS : : Overflow : : Hidden )  | |  overflow_value_allows_scrolling ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  scrollable_overflow_size  >  scrollport_size ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 15:54:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 15:47:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  PaintableBox : : could_be_scrolled_by_wheel_event ( )  const  
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:20:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-30 15:47:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  could_be_scrolled_by_wheel_event ( ScrollDirection : : Horizontal )  | |  could_be_scrolled_by_wheel_event ( ScrollDirection : : Vertical ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:20:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  constexpr  CSSPixels  SCROLLBAR_THUMB_NORMAL_THICKNESS  =  5 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								static  constexpr  CSSPixels  SCROLLBAR_THUMB_WIDENED_THICKNESS  =  10 ;  
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:15:13 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < PaintableBox : : ScrollbarData >  PaintableBox : : compute_scrollbar_data ( ScrollDirection  direction ,  AdjustThumbRectForScrollOffset  adjust_thumb_rect_for_scroll_offset )  const  
						 
					
						
							
								
									
										
										
										
											2024-08-17 18:56:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-30 15:54:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  is_horizontal  =  direction  = =  ScrollDirection : : Horizontal ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  display_scrollbar  =  could_be_scrolled_by_wheel_event ( direction ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_horizontal )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        display_scrollbar  | =  computed_values ( ) . overflow_x ( )  = =  CSS : : Overflow : : Scroll ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        display_scrollbar  | =  computed_values ( ) . overflow_y ( )  = =  CSS : : Overflow : : Scroll ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! display_scrollbar )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 18:56:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! own_scroll_frame_id ( ) . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  padding_rect  =  absolute_padding_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollable_overflow_rect  =  this - > scrollable_overflow_rect ( ) . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-25 17:37:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scroll_overflow_size  =  is_horizontal  ?  scrollable_overflow_rect . width ( )  :  scrollable_overflow_rect . height ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollport_size  =  is_horizontal  ?  padding_rect . width ( )  :  padding_rect . height ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-17 07:15:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( scroll_overflow_size  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-05 16:28:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  thickness  =  [ & ] ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_horizontal ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  m_draw_enlarged_horizontal_scrollbar  ?  SCROLLBAR_THUMB_WIDENED_THICKNESS  :  SCROLLBAR_THUMB_NORMAL_THICKNESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  m_draw_enlarged_vertical_scrollbar  ?  SCROLLBAR_THUMB_WIDENED_THICKNESS  :  SCROLLBAR_THUMB_NORMAL_THICKNESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollbar_rect_length  =  is_horizontal  ?  scrollport_size  -  thickness  :  scrollport_size ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-25 17:37:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  min_thumb_length  =  min ( scrollbar_rect_length ,  24 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  thumb_length  =  max ( scrollbar_rect_length  *  ( scrollport_size  /  scroll_overflow_size ) ,  min_thumb_length ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-05 16:28:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 09:10:55 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ScrollbarData  scrollbar_data ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( scroll_overflow_size  >  scrollport_size ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 09:10:55 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        scrollbar_data . scroll_length  =  ( scrollbar_rect_length  -  thumb_length )  /  ( scroll_overflow_size  -  scrollport_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_horizontal )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( m_draw_enlarged_horizontal_scrollbar ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            scrollbar_data . gutter_rect  =  {  padding_rect . left ( ) ,  padding_rect . bottom ( )  -  thickness ,  padding_rect . width ( ) ,  thickness  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        scrollbar_data . thumb_rect  =  {  padding_rect . left ( ) ,  padding_rect . bottom ( )  -  thickness ,  thumb_length ,  thickness  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( m_draw_enlarged_vertical_scrollbar ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            scrollbar_data . gutter_rect  =  {  padding_rect . right ( )  -  thickness ,  padding_rect . top ( ) ,  thickness ,  padding_rect . height ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        scrollbar_data . thumb_rect  =  {  padding_rect . right ( )  -  thickness ,  padding_rect . top ( ) ,  thickness ,  thumb_length  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-03 17:53:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:15:13 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( adjust_thumb_rect_for_scroll_offset  = =  AdjustThumbRectForScrollOffset : : Yes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  scroll_offset  =  is_horizontal  ?  - own_scroll_frame_offset ( ) . x ( )  :  - own_scroll_frame_offset ( ) . y ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  thumb_offset  =  scroll_offset  *  scrollbar_data . scroll_length ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_horizontal ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            scrollbar_data . thumb_rect . translate_by ( thumb_offset ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            scrollbar_data . thumb_rect . translate_by ( 0 ,  thumb_offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 09:10:55 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  scrollbar_data ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : paint ( PaintContext &  context ,  PaintPhase  phase )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! is_visible ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:28:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  empty_cells_property_applies  =  [ this ] ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  display ( ) . is_internal_table ( )  & &  computed_values ( ) . empty_cells ( )  = =  CSS : : EmptyCells : : Hide  & &  ! has_children ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( phase  = =  PaintPhase : : Background  & &  ! empty_cells_property_applies ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        paint_backdrop_filter ( context ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_background ( context ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_box_shadow ( context ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-30 13:41:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const  is_table_with_collapsed_borders  =  display ( ) . is_table_inside ( )  & &  computed_values ( ) . border_collapse ( )  = =  CSS : : BorderCollapse : : Collapse ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! display ( ) . is_table_cell ( )  & &  ! is_table_with_collapsed_borders  & &  phase  = =  PaintPhase : : Border )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_border ( context ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-30 13:41:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ( display ( ) . is_table_inside ( )  | |  computed_values ( ) . border_collapse ( )  = =  CSS : : BorderCollapse : : Collapse )  & &  phase  = =  PaintPhase : : TableCollapsedBorder )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_table_borders ( context ,  * this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 17:24:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( phase  = =  PaintPhase : : Outline )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 01:56:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  outline_data  =  this - > outline_data ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( outline_data . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  outline_offset  =  this - > outline_offset ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 17:24:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  border_radius_data  =  normalized_border_radii_data ( ShrinkRadiiForBorders : : No ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 20:09:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  borders_rect  =  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  outline_offset_x  =  outline_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  outline_offset_y  =  outline_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // "Both the height and the width of the outside of the shape drawn by the outline should not
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // become smaller than twice the computed value of the outline-width property to make sure
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // that an outline can be rendered even with large negative values."
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // https://www.w3.org/TR/css-ui-4/#outline-offset
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // So, if the horizontal outline offset is > half the borders_rect's width then we set it to that.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // (And the same for y)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ( borders_rect . width ( )  /  2 )  +  outline_offset_x  <  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                outline_offset_x  =  - borders_rect . width ( )  /  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ( borders_rect . height ( )  /  2 )  +  outline_offset_y  <  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                outline_offset_y  =  - borders_rect . height ( )  /  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-11 01:56:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            border_radius_data . inflate ( outline_data - > top . width  +  outline_offset_y ,  outline_data - > right . width  +  outline_offset_x ,  outline_data - > bottom . width  +  outline_offset_y ,  outline_data - > left . width  +  outline_offset_x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            borders_rect . inflate ( outline_data - > top . width  +  outline_offset_y ,  outline_data - > right . width  +  outline_offset_x ,  outline_data - > bottom . width  +  outline_offset_y ,  outline_data - > left . width  +  outline_offset_x ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 20:09:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-13 03:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            paint_all_borders ( context . display_list_recorder ( ) ,  context . rounded_device_rect ( borders_rect ) ,  border_radius_data . as_corners ( context . device_pixel_converter ( ) ) ,  outline_data - > to_device_pixels ( context ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 17:24:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 09:10:55 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( phase  = =  PaintPhase : : Overlay  & &  ( g_paint_viewport_scrollbars  | |  ! is_viewport ( ) )  & &  computed_values ( ) . scrollbar_width ( )  ! =  CSS : : ScrollbarWidth : : None )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-26 22:36:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  scrollbar_colors  =  computed_values ( ) . scrollbar_color ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 09:10:55 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  scrollbar_data  =  compute_scrollbar_data ( ScrollDirection : : Vertical ) ;  scrollbar_data . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  gutter_rect  =  context . rounded_device_rect ( scrollbar_data - > gutter_rect ) . to_type < int > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  thumb_rect  =  context . rounded_device_rect ( scrollbar_data - > thumb_rect ) . to_type < int > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-26 22:36:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            context . display_list_recorder ( ) . paint_scrollbar ( own_scroll_frame_id ( ) . value ( ) ,  gutter_rect ,  thumb_rect ,  scrollbar_data - > scroll_length ,  scrollbar_colors . thumb_color ,  scrollbar_colors . track_color ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 09:10:55 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  scrollbar_data  =  compute_scrollbar_data ( ScrollDirection : : Horizontal ) ;  scrollbar_data . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  gutter_rect  =  context . rounded_device_rect ( scrollbar_data - > gutter_rect ) . to_type < int > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  thumb_rect  =  context . rounded_device_rect ( scrollbar_data - > thumb_rect ) . to_type < int > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-26 22:36:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            context . display_list_recorder ( ) . paint_scrollbar ( own_scroll_frame_id ( ) . value ( ) ,  gutter_rect ,  thumb_rect ,  scrollbar_data - > scroll_length ,  scrollbar_colors . thumb_color ,  scrollbar_colors . track_color ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-15 21:12:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-21 09:34:02 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( phase  = =  PaintPhase : : Overlay  & &  layout_node ( ) . document ( ) . highlighted_layout_node ( )  = =  & layout_node_with_style_and_box_metrics ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-15 16:37:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  content_rect  =  absolute_united_content_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  margin_rect  =  united_rect_for_continuation_chain ( * this ,  [ ] ( PaintableBox  const &  box )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  margin_box  =  box . box_model ( ) . margin_box ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  CSSPixelRect  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                box . absolute_x ( )  -  margin_box . left , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                box . absolute_y ( )  -  margin_box . top , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                box . content_width ( )  +  margin_box . left  +  margin_box . right , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                box . content_height ( )  +  margin_box . top  +  margin_box . bottom , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  border_rect  =  absolute_united_border_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  padding_rect  =  absolute_united_padding_box_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  paint_inspector_rect  =  [ & ] ( CSSPixelRect  const &  rect ,  Color  color )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  device_rect  =  context . enclosing_device_rect ( rect ) . to_type < int > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 18:40:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            context . display_list_recorder ( ) . fill_rect ( device_rect ,  Color ( color ) . with_alpha ( 100 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            context . display_list_recorder ( ) . draw_rect ( device_rect ,  Color ( color ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_inspector_rect ( margin_rect ,  Color : : Yellow ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_inspector_rect ( padding_rect ,  Color : : Cyan ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_inspector_rect ( border_rect ,  Color : : Green ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_inspector_rect ( content_rect ,  Color : : Magenta ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 03:56:05 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  font  =  Platform : : FontPlugin : : the ( ) . default_font ( 12 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 22:17:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        StringBuilder  builder ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( layout_node_with_style_and_box_metrics ( ) . dom_node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            builder . append ( layout_node_with_style_and_box_metrics ( ) . dom_node ( ) - > debug_description ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            builder . append ( layout_node_with_style_and_box_metrics ( ) . debug_description ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        builder . appendff ( "  {}x{} @ {},{} " ,  border_rect . width ( ) ,  border_rect . height ( ) ,  border_rect . x ( ) ,  border_rect . y ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-27 10:37:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  size_text  =  MUST ( builder . to_string ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  size_text_rect  =  border_rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        size_text_rect . set_y ( border_rect . y ( )  +  border_rect . height ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        size_text_rect . set_top ( size_text_rect . top ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 03:56:05 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        size_text_rect . set_width ( CSSPixels : : nearest_value_for ( font - > width ( size_text ) )  +  4 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        size_text_rect . set_height ( CSSPixels : : nearest_value_for ( font - > pixel_size ( ) )  +  4 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  size_text_device_rect  =  context . enclosing_device_rect ( size_text_rect ) . to_type < int > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 18:40:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        context . display_list_recorder ( ) . fill_rect ( size_text_device_rect ,  context . palette ( ) . color ( Gfx : : ColorRole : : Tooltip ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        context . display_list_recorder ( ) . draw_rect ( size_text_device_rect ,  context . palette ( ) . threed_shadow1 ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 03:56:05 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        context . display_list_recorder ( ) . draw_text ( size_text_device_rect ,  size_text ,  font - > with_size ( font - > point_size ( )  *  context . device_pixels_per_css_pixel ( ) ) ,  Gfx : : TextAlignment : : Center ,  context . palette ( ) . color ( Gfx : : ColorRole : : TooltipText ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-18 16:05:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : set_stacking_context ( NonnullOwnPtr < StackingContext >  stacking_context )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_stacking_context  =  move ( stacking_context ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : invalidate_stacking_context ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_stacking_context  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-12 04:20:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								BordersData  PaintableBox : : remove_element_kind_from_borders_data ( PaintableBox : : BordersDataWithElementKind  borders_data )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . top  =  borders_data . top . border_data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . right  =  borders_data . right . border_data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . bottom  =  borders_data . bottom . border_data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . left  =  borders_data . left . border_data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : paint_border ( PaintContext &  context )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-07-12 04:20:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  borders_data  =  m_override_borders_data . has_value ( )  ?  remove_element_kind_from_borders_data ( m_override_borders_data . value ( ) )  :  BordersData  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 23:05:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        . top  =  box_model ( ) . border . top  = =  0  ?  CSS : : BorderData ( )  :  computed_values ( ) . border_top ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . right  =  box_model ( ) . border . right  = =  0  ?  CSS : : BorderData ( )  :  computed_values ( ) . border_right ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . bottom  =  box_model ( ) . border . bottom  = =  0  ?  CSS : : BorderData ( )  :  computed_values ( ) . border_bottom ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . left  =  box_model ( ) . border . left  = =  0  ?  CSS : : BorderData ( )  :  computed_values ( ) . border_left ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-13 03:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    paint_all_borders ( context . display_list_recorder ( ) ,  context . rounded_device_rect ( absolute_border_box_rect ( ) ) ,  normalized_border_radii_data ( ) . as_corners ( context . device_pixel_converter ( ) ) ,  borders_data . to_device_pixels ( context ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : paint_backdrop_filter ( PaintContext &  context )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-07-29 16:51:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  backdrop_filter  =  computed_values ( ) . backdrop_filter ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-11 12:44:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! backdrop_filter . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 16:51:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  backdrop_region  =  context . rounded_device_rect ( absolute_border_box_rect ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  border_radii_data  =  normalized_border_radii_data ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ScopedCornerRadiusClip  corner_clipper  {  context ,  backdrop_region ,  border_radii_data  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-11 12:44:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    context . display_list_recorder ( ) . apply_backdrop_filter ( backdrop_region . to_type < int > ( ) ,  border_radii_data ,  backdrop_filter . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : paint_background ( PaintContext &  context )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // If the body's background properties were propagated to the root element, do no re-paint the body's background.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( layout_node_with_style_and_box_metrics ( ) . is_body ( )  & &  document ( ) . html_element ( ) - > should_use_body_background_properties ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 22:04:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Painting : : paint_background ( context ,  * this ,  computed_values ( ) . image_rendering ( ) ,  m_resolved_background ,  normalized_border_radii_data ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 15:13:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : paint_box_shadow ( PaintContext &  context )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-12-19 19:42:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  resolved_box_shadow_data  =  box_shadow_data ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 15:13:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( resolved_box_shadow_data . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 02:42:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  borders_data  =  BordersData  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . top  =  computed_values ( ) . border_top ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . right  =  computed_values ( ) . border_right ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . bottom  =  computed_values ( ) . border_bottom ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . left  =  computed_values ( ) . border_left ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Painting : : paint_box_shadow ( context ,  absolute_border_box_rect ( ) ,  absolute_padding_box_rect ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        borders_data ,  normalized_border_radii_data ( ) ,  resolved_box_shadow_data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-26 20:43:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								BorderRadiiData  PaintableBox : : normalized_border_radii_data ( ShrinkRadiiForBorders  shrink )  const  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-12-07 06:16:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  border_radii_data  =  this - > border_radii_data ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-26 20:43:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( shrink  = =  ShrinkRadiiForBorders : : Yes ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-07 06:16:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        border_radii_data . shrink ( computed_values ( ) . border_top ( ) . width ,  computed_values ( ) . border_right ( ) . width ,  computed_values ( ) . border_bottom ( ) . width ,  computed_values ( ) . border_left ( ) . width ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  border_radii_data ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < int >  PaintableBox : : own_scroll_frame_id ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_own_scroll_frame ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  m_own_scroll_frame - > id ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Optional < int >  PaintableBox : : scroll_frame_id ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_enclosing_scroll_frame ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  m_enclosing_scroll_frame - > id ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelPoint  PaintableBox : : cumulative_offset_of_enclosing_scroll_frame ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_enclosing_scroll_frame ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  m_enclosing_scroll_frame - > cumulative_offset ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Optional < CSSPixelRect >  PaintableBox : : clip_rect_for_hit_testing ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_enclosing_clip_frame ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  m_enclosing_clip_frame - > clip_rect_for_hit_testing ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:39:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : apply_scroll_offset ( PaintContext &  context )  const  
						 
					
						
							
								
									
										
										
										
											2023-08-08 15:02:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-02-08 17:30:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( scroll_frame_id ( ) . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-11 15:18:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        context . display_list_recorder ( ) . push_scroll_frame_id ( scroll_frame_id ( ) . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-29 06:10:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-08 15:02:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-07 18:39:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : reset_scroll_offset ( PaintContext &  context )  const  
						 
					
						
							
								
									
										
										
										
											2023-08-08 15:02:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-10-11 15:18:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( scroll_frame_id ( ) . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        context . display_list_recorder ( ) . pop_scroll_frame_id ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-08 15:02:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 04:50:14 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : apply_clip_overflow_rect ( PaintContext &  context ,  PaintPhase  phase )  const  
						 
					
						
							
								
									
										
										
										
											2022-11-12 00:07:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-05-03 11:22:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! enclosing_clip_frame ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-30 13:41:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! AK : : first_is_one_of ( phase ,  PaintPhase : : Background ,  PaintPhase : : Border ,  PaintPhase : : TableCollapsedBorder ,  PaintPhase : : Foreground ,  PaintPhase : : Outline ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-13 20:45:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-13 03:55:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    context . display_list_recorder ( ) . push_clip_frame ( enclosing_clip_frame ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 04:50:14 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : clear_clip_overflow_rect ( PaintContext &  context ,  PaintPhase  phase )  const  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-05-03 11:22:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! enclosing_clip_frame ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-30 13:41:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! AK : : first_is_one_of ( phase ,  PaintPhase : : Background ,  PaintPhase : : Border ,  PaintPhase : : TableCollapsedBorder ,  PaintPhase : : Foreground ,  PaintPhase : : Outline ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-19 11:02:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-13 03:55:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    context . display_list_recorder ( ) . pop_clip_frame ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 10:25:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  paint_cursor_if_needed ( PaintContext &  context ,  TextPaintable  const &  paintable ,  PaintableFragment  const &  fragment )  
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  navigable  =  * paintable . navigable ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-02 07:31:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  document  =  paintable . document ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-26 16:59:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! navigable . is_focused ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-02 07:31:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! document . cursor_blink_state ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												LibWeb: Separate text control input events handling from contenteditable
This input event handling change is intended to address the following
design issues:
- Having `DOM::Position` is unnecessary complexity when `Selection`
  exists because caret position could be described by the selection
  object with a collapsed state. Before this change, we had to
  synchronize those whenever one of them was modified, and there were
  already bugs caused by that, i.e., caret position was not changed when
  selection offset was modified from the JS side.
- Selection API exposes selection offset within `<textarea>` and
  `<input>`, which is not supposed to happen. These objects should
  manage their selection state by themselves and have selection offset
  even when they are not displayed.
- `EventHandler` looks only at `DOM::Text` owned by `DOM::Position`
  while doing text manipulations. It works fine for `<input>` and
  `<textarea>`, but `contenteditable` needs to consider all text
  descendant text nodes; i.e., if the cursor is moved outside of
  `DOM::Text`, we need to look for an adjacent text node to move the
  cursor there.
With this change, `EventHandler` no longer does direct manipulations on
caret position or text content, but instead delegates them to the active
`InputEventsTarget`, which could be either
`FormAssociatedTextControlElement` (for `<input>` and `<textarea>`) or
`EditingHostManager` (for `contenteditable`). The `Selection` object is
used to manage both selection and caret position for `contenteditable`,
and text control elements manage their own selection state that is not
exposed by Selection API.
This change improves text editing on Discord, as now we don't have to
refocus the `contenteditable` element after character input. The problem
was that selection manipulations from the JS side were not propagated
to `DOM::Position`.
I expect this change to make future correctness improvements for
`contenteditable` (and `designMode`) easier, as now it's decoupled from
`<input>` and `<textarea>` and separated from `EventHandler`, which is
quite a busy file.
											 
										 
										
											2024-10-23 21:26:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  cursor_position  =  document . cursor_position ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! cursor_position  | |  ! cursor_position - > node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( cursor_position - > node ( )  ! =  paintable . dom_node ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: This checks if the cursor is before the start or after the end of the fragment. If it is at the end, after all text, it should still be painted.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 13:19:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    size_t  cursor_position_byte_offset  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( cursor_position - > offset ( )  = =  fragment . utf16_view ( ) . length_in_code_units ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        cursor_position_byte_offset  =  fragment . utf8_view ( ) . byte_length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  cursor_position_code_point_offset  =  fragment . utf16_view ( ) . code_point_offset_of ( cursor_position - > offset ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        cursor_position_byte_offset  =  fragment . utf8_view ( ) . byte_offset_of ( cursor_position_code_point_offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 14:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( cursor_position_byte_offset  <  fragment . start_byte_offset ( )  | |  cursor_position_byte_offset  >  ( fragment . start_byte_offset ( )  +  fragment . length_in_bytes ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-06 11:41:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  active_element  =  document . active_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  active_element_is_editable  =  is < HTML : : FormAssociatedTextControlElement > ( active_element ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  dynamic_cast < HTML : : FormAssociatedTextControlElement  const & > ( * active_element ) . is_mutable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  dom_node  =  fragment . layout_node ( ) . dom_node ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! dom_node  | |  ( ! dom_node - > is_editable ( )  & &  ! active_element_is_editable ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-09 13:59:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  caret_color  =  paintable . computed_values ( ) . caret_color ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( caret_color . alpha ( )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  fragment_rect  =  fragment . absolute_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 19:38:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  font  =  fragment . glyph_run ( )  ?  fragment . glyph_run ( ) - > font ( )  :  fragment . layout_node ( ) . first_available_font ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 13:19:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  utf8_text  =  fragment . utf8_view ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 14:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  cursor_offset  =  font . width ( utf8_text . substring_view ( fragment . start_byte_offset ( ) ,  cursor_position_byte_offset  -  fragment . start_byte_offset ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 13:19:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    CSSPixelRect  cursor_rect  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 13:19:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        fragment_rect . x ( )  +  CSSPixels : : nearest_value_for ( cursor_offset ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        fragment_rect . top ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        fragment_rect . height ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  cursor_device_rect  =  context . rounded_device_rect ( cursor_rect ) . to_type < int > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-09 13:59:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    context . display_list_recorder ( ) . draw_rect ( cursor_device_rect ,  caret_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 10:25:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  paint_text_decoration ( PaintContext &  context ,  TextPaintable  const &  paintable ,  PaintableFragment  const &  fragment )  
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-06-23 18:40:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  painter  =  context . display_list_recorder ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-12-09 23:42:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  font  =  fragment . layout_node ( ) . first_available_font ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  fragment_box  =  fragment . absolute_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-26 15:57:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    CSSPixels  glyph_height  =  CSSPixels : : nearest_value_for ( font . pixel_size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-25 18:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  baseline  =  fragment . baseline ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 10:25:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  line_color  =  paintable . computed_values ( ) . text_decoration_color ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 19:51:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  line_style  =  paintable . computed_values ( ) . text_decoration_style ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-16 18:05:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  device_line_thickness  =  context . rounded_device_pixels ( fragment . text_decoration_thickness ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 10:25:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  text_decoration_lines  =  paintable . computed_values ( ) . text_decoration_line ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  line  :  text_decoration_lines )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        DevicePixelPoint  line_start_point  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        DevicePixelPoint  line_end_point  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 19:51:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( line  = =  CSS : : TextDecorationLine : : SpellingError )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // https://drafts.csswg.org/css-text-decor-4/#valdef-text-decoration-line-spelling-error
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // This value indicates the type of text decoration used by the user agent to highlight spelling mistakes.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Its appearance is UA-defined, and may be platform-dependent. It is often rendered as a red wavy underline.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line_color  =  Color : : Red ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            device_line_thickness  =  context . rounded_device_pixels ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line_style  =  CSS : : TextDecorationStyle : : Wavy ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line  =  CSS : : TextDecorationLine : : Underline ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( line  = =  CSS : : TextDecorationLine : : GrammarError )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // https://drafts.csswg.org/css-text-decor-4/#valdef-text-decoration-line-grammar-error
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // This value indicates the type of text decoration used by the user agent to highlight grammar mistakes.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Its appearance is UA defined, and may be platform-dependent. It is often rendered as a green wavy underline.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line_color  =  Color : : DarkGreen ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            device_line_thickness  =  context . rounded_device_pixels ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line_style  =  CSS : : TextDecorationStyle : : Wavy ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line  =  CSS : : TextDecorationLine : : Underline ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( line )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationLine : : None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationLine : : Underline : 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            line_start_point  =  context . rounded_device_point ( fragment_box . top_left ( ) . translated ( 0 ,  baseline  +  2 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-22 00:41:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            line_end_point  =  context . rounded_device_point ( fragment_box . top_right ( ) . translated ( - 1 ,  baseline  +  2 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationLine : : Overline : 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            line_start_point  =  context . rounded_device_point ( fragment_box . top_left ( ) . translated ( 0 ,  baseline  -  glyph_height ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-22 00:41:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            line_end_point  =  context . rounded_device_point ( fragment_box . top_right ( ) . translated ( - 1 ,  baseline  -  glyph_height ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationLine : : LineThrough :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  x_height  =  font . x_height ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-26 15:03:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            line_start_point  =  context . rounded_device_point ( fragment_box . top_left ( ) . translated ( 0 ,  baseline  -  x_height  *  CSSPixels ( 0.5f ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line_end_point  =  context . rounded_device_point ( fragment_box . top_right ( ) . translated ( - 1 ,  baseline  -  x_height  *  CSSPixels ( 0.5f ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationLine : : Blink : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Conforming user agents may simply not blink the text
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 19:51:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationLine : : SpellingError : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationLine : : GrammarError : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Handled above.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 19:51:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( line_style )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationStyle : : Solid : 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 10:25:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            painter . draw_line ( line_start_point . to_type < int > ( ) ,  line_end_point . to_type < int > ( ) ,  line_color ,  device_line_thickness . value ( ) ,  Gfx : : LineStyle : : Solid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationStyle : : Double : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            switch  ( line )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  CSS : : TextDecorationLine : : Underline : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  CSS : : TextDecorationLine : : Overline : 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                line_start_point . translate_by ( 0 ,  - device_line_thickness  -  context . rounded_device_pixels ( 1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_end_point . translate_by ( 0 ,  - device_line_thickness  -  context . rounded_device_pixels ( 1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  CSS : : TextDecorationLine : : LineThrough : 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                line_start_point . translate_by ( 0 ,  - device_line_thickness  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_end_point . translate_by ( 0 ,  - device_line_thickness  /  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            painter . draw_line ( line_start_point . to_type < int > ( ) ,  line_end_point . to_type < int > ( ) ,  line_color ,  device_line_thickness . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            painter . draw_line ( line_start_point . translated ( 0 ,  device_line_thickness  +  1 ) . to_type < int > ( ) ,  line_end_point . translated ( 0 ,  device_line_thickness  +  1 ) . to_type < int > ( ) ,  line_color ,  device_line_thickness . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationStyle : : Dashed : 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 10:25:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            painter . draw_line ( line_start_point . to_type < int > ( ) ,  line_end_point . to_type < int > ( ) ,  line_color ,  device_line_thickness . value ( ) ,  Gfx : : LineStyle : : Dashed ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationStyle : : Dotted : 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 10:25:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            painter . draw_line ( line_start_point . to_type < int > ( ) ,  line_end_point . to_type < int > ( ) ,  line_color ,  device_line_thickness . value ( ) ,  Gfx : : LineStyle : : Dotted ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TextDecorationStyle : : Wavy : 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-27 19:51:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  amplitude  =  device_line_thickness . value ( )  *  3 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            switch  ( line )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  CSS : : TextDecorationLine : : Underline : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_start_point . translate_by ( 0 ,  device_line_thickness  +  context . rounded_device_pixels ( 1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_end_point . translate_by ( 0 ,  device_line_thickness  +  context . rounded_device_pixels ( 1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  CSS : : TextDecorationLine : : Overline : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_start_point . translate_by ( 0 ,  - device_line_thickness  -  context . rounded_device_pixels ( 1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_end_point . translate_by ( 0 ,  - device_line_thickness  -  context . rounded_device_pixels ( 1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  CSS : : TextDecorationLine : : LineThrough : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_start_point . translate_by ( 0 ,  - device_line_thickness  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_end_point . translate_by ( 0 ,  - device_line_thickness  /  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            painter . draw_triangle_wave ( line_start_point . to_type < int > ( ) ,  line_end_point . to_type < int > ( ) ,  line_color ,  amplitude ,  device_line_thickness . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 10:25:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  paint_text_fragment ( PaintContext &  context ,  TextPaintable  const &  paintable ,  PaintableFragment  const &  fragment ,  PaintPhase  phase )  
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-08-24 13:56:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! paintable . is_visible ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 18:40:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  painter  =  context . display_list_recorder ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 16:02:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( phase  = =  PaintPhase : : Foreground )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  fragment_absolute_rect  =  fragment . absolute_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-27 16:30:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  fragment_absolute_device_rect  =  context . enclosing_device_rect ( fragment_absolute_rect ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-21 09:34:02 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( paintable . document ( ) . highlighted_layout_node ( )  = =  & paintable . layout_node ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 18:40:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            context . display_list_recorder ( ) . draw_rect ( fragment_absolute_device_rect . to_type < int > ( ) ,  Color : : Magenta ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 10:25:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  text  =  paintable . text_for_rendering ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-29 17:14:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  glyph_run  =  fragment . glyph_run ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! glyph_run ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 14:14:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  scale  =  context . device_pixels_per_css_pixel ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 10:24:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  baseline_start  =  Gfx : : FloatPoint  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            fragment_absolute_rect . x ( ) . to_float ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            fragment_absolute_rect . y ( ) . to_float ( )  +  fragment . baseline ( ) . to_float ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  *  scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        painter . draw_text_run ( baseline_start ,  * glyph_run ,  paintable . computed_values ( ) . webkit_text_fill_color ( ) ,  fragment_absolute_device_rect . to_type < int > ( ) ,  scale ,  fragment . orientation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:54:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  selection_rect  =  context . enclosing_device_rect ( fragment . selection_rect ( ) ) . to_type < int > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! selection_rect . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 12:59:09 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            painter . fill_rect ( selection_rect ,  CSS : : SystemColor : : highlight ( paintable . computed_values ( ) . color_scheme ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 18:40:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            DisplayListRecorderStateSaver  saver ( painter ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-31 19:46:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            painter . add_clip_rect ( selection_rect ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 12:59:09 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            painter . draw_text_run ( baseline_start ,  * glyph_run ,  CSS : : SystemColor : : highlight_text ( paintable . computed_values ( ) . color_scheme ( ) ) ,  fragment_absolute_device_rect . to_type < int > ( ) ,  scale ,  fragment . orientation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 10:25:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        paint_text_decoration ( context ,  paintable ,  fragment ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        paint_cursor_if_needed ( context ,  paintable ,  fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-16 23:03:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableWithLines : : paint ( PaintContext &  context ,  PaintPhase  phase )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! is_visible ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    PaintableBox : : paint ( context ,  phase ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 15:20:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Text shadows
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // This is yet another loop, but done here because all shadows should appear under all text.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // So, we paint the shadows before painting any text.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Find a smarter way to do this?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( phase  = =  PaintPhase : : Foreground )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 10:24:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto &  fragment  :  fragments ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-13 10:38:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            paint_text_shadow ( context ,  fragment ,  fragment . shadows ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 15:20:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-12 21:25:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  fragment  :  m_fragments )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  fragment_absolute_rect  =  fragment . absolute_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( context . should_show_line_box_borders ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-16 16:55:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  fragment_absolute_device_rect  =  context . enclosing_device_rect ( fragment_absolute_rect ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 18:40:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            context . display_list_recorder ( ) . draw_rect ( fragment_absolute_device_rect . to_type < int > ( ) ,  Color : : Green ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            context . display_list_recorder ( ) . draw_line ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-12 21:25:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                context . rounded_device_point ( fragment_absolute_rect . top_left ( ) . translated ( 0 ,  fragment . baseline ( ) ) ) . to_type < int > ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                context . rounded_device_point ( fragment_absolute_rect . top_right ( ) . translated ( - 1 ,  fragment . baseline ( ) ) ) . to_type < int > ( ) ,  Color : : Red ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-18 10:25:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is < TextPaintable > ( fragment . paintable ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            paint_text_fragment ( context ,  static_cast < TextPaintable  const & > ( fragment . paintable ( ) ) ,  fragment ,  phase ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Paintable : : DispatchEventOfSameName  PaintableBox : : handle_mousedown ( Badge < EventHandler > ,  CSSPixelPoint  position ,  unsigned ,  unsigned )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-05-07 19:06:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    position  =  adjust_position_for_cumulative_scroll_offset ( position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  handle_scrollbar  =  [ & ] ( auto  direction )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  scrollbar_data  =  compute_scrollbar_data ( direction ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! scrollbar_data . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:15:13 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( scrollbar_data - > gutter_rect . contains ( position ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            m_scroll_thumb_dragging_direction  =  direction ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            navigable ( ) - > event_handler ( ) . set_mouse_event_tracking_paintable ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            scroll_to_mouse_position ( position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( handle_scrollbar ( ScrollDirection : : Vertical ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  Paintable : : DispatchEventOfSameName : : No ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( handle_scrollbar ( ScrollDirection : : Horizontal ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  Paintable : : DispatchEventOfSameName : : No ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:15:13 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  Paintable : : DispatchEventOfSameName : : Yes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Paintable : : DispatchEventOfSameName  PaintableBox : : handle_mouseup ( Badge < EventHandler > ,  CSSPixelPoint ,  unsigned ,  unsigned )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_scroll_thumb_grab_position . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_scroll_thumb_grab_position . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        m_scroll_thumb_dragging_direction . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        navigable ( ) - > event_handler ( ) . set_mouse_event_tracking_paintable ( nullptr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  Paintable : : DispatchEventOfSameName : : Yes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Paintable : : DispatchEventOfSameName  PaintableBox : : handle_mousemove ( Badge < EventHandler > ,  CSSPixelPoint  position ,  unsigned ,  unsigned )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-05-07 19:06:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    position  =  adjust_position_for_cumulative_scroll_offset ( position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_scroll_thumb_grab_position . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        scroll_to_mouse_position ( position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  Paintable : : DispatchEventOfSameName : : No ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  previous_draw_enlarged_horizontal_scrollbar  =  m_draw_enlarged_horizontal_scrollbar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_draw_enlarged_horizontal_scrollbar  =  scrollbar_contains_mouse_position ( ScrollDirection : : Horizontal ,  position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( previous_draw_enlarged_horizontal_scrollbar  ! =  m_draw_enlarged_horizontal_scrollbar ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        set_needs_display ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  previous_draw_enlarged_vertical_scrollbar  =  m_draw_enlarged_vertical_scrollbar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_draw_enlarged_vertical_scrollbar  =  scrollbar_contains_mouse_position ( ScrollDirection : : Vertical ,  position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( previous_draw_enlarged_vertical_scrollbar  ! =  m_draw_enlarged_vertical_scrollbar ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        set_needs_display ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_draw_enlarged_horizontal_scrollbar  | |  m_draw_enlarged_vertical_scrollbar ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  Paintable : : DispatchEventOfSameName : : No ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  Paintable : : DispatchEventOfSameName : : Yes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  PaintableBox : : scrollbar_contains_mouse_position ( ScrollDirection  direction ,  CSSPixelPoint  position )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TemporaryChange  force_enlarged_horizontal_scrollbar  {  m_draw_enlarged_horizontal_scrollbar ,  true  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TemporaryChange  force_enlarged_vertical_scrollbar  {  m_draw_enlarged_vertical_scrollbar ,  true  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollbar_data  =  compute_scrollbar_data ( direction ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! scrollbar_data . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-07 19:04:08 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  scrollbar_data - > gutter_rect . contains ( position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : scroll_to_mouse_position ( CSSPixelPoint  position )  
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( m_scroll_thumb_dragging_direction . has_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollbar_data  =  compute_scrollbar_data ( m_scroll_thumb_dragging_direction . value ( ) ,  AdjustThumbRectForScrollOffset : : Yes ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( scrollbar_data . has_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  orientation  =  m_scroll_thumb_dragging_direction  = =  ScrollDirection : : Horizontal  ?  Orientation : : Horizontal  :  Orientation : : Vertical ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  offset_relative_to_gutter  =  ( position  -  scrollbar_data - > gutter_rect . location ( ) ) . primary_offset_for_orientation ( orientation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  gutter_size  =  scrollbar_data - > gutter_rect . primary_size_for_orientation ( orientation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  thumb_size  =  scrollbar_data - > thumb_rect . primary_size_for_orientation ( orientation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Set the thumb grab position, if we haven't got one already.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! m_scroll_thumb_grab_position . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_scroll_thumb_grab_position  =  scrollbar_data - > thumb_rect . contains ( position ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            ?  ( position  -  scrollbar_data - > thumb_rect . location ( ) ) . primary_offset_for_orientation ( orientation ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            :  max ( min ( offset_relative_to_gutter ,  thumb_size  /  2 ) ,  offset_relative_to_gutter  -  gutter_size  +  thumb_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Calculate the relative scroll position (0..1) based on the position of the mouse cursor. We only move the thumb
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // if we are interacting with the grab point on the thumb. E.g. if the thumb is all the way to its minimum position
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // and the position is beyond the grab point, we should do nothing.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  constrained_offset  =  AK : : clamp ( offset_relative_to_gutter  -  m_scroll_thumb_grab_position . value ( ) ,  0 ,  gutter_size  -  thumb_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scroll_position  =  constrained_offset . to_double ( )  /  ( gutter_size  -  thumb_size ) . to_double ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Calculate the scroll offset we need to apply to the viewport or element.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scrollable_overflow_size  =  scrollable_overflow_rect ( ) - > primary_size_for_orientation ( orientation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  padding_size  =  absolute_padding_box_rect ( ) . primary_size_for_orientation ( orientation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  scroll_position_in_pixels  =  CSSPixels : : nearest_value_for ( scroll_position  *  ( scrollable_overflow_size  -  padding_size ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Set the new scroll offset.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  new_scroll_offset  =  is_viewport ( )  ?  document ( ) . navigable ( ) - > viewport_scroll_offset ( )  :  scroll_offset ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    new_scroll_offset . set_primary_offset_for_orientation ( orientation ,  scroll_position_in_pixels ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_viewport ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        document ( ) . navigable ( ) - > perform_scroll_of_viewport ( new_scroll_offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 12:00:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        set_scroll_offset ( new_scroll_offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 10:22:14 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 14:28:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  PaintableBox : : handle_mousewheel ( Badge < EventHandler > ,  CSSPixelPoint ,  unsigned ,  unsigned ,  int  wheel_delta_x ,  int  wheel_delta_y )  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-03-01 18:23:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // if none of the axes we scrolled with can be accepted by this element, don't handle scroll.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ( ! wheel_delta_x  | |  ! could_be_scrolled_by_wheel_event ( ScrollDirection : : Horizontal ) )  & &  ( ! wheel_delta_y  | |  ! could_be_scrolled_by_wheel_event ( ScrollDirection : : Vertical ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-06 00:21:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-07 17:50:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-06 00:21:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-06 20:29:29 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    scroll_by ( wheel_delta_x ,  wheel_delta_y ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Layout : : NodeWithStyleAndBoxModelMetrics  const &  PaintableWithLines : : layout_node_with_style_and_box_metrics ( )  const  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  static_cast < Layout : : NodeWithStyleAndBoxModelMetrics  const & > ( PaintableBox : : layout_node_with_style_and_box_metrics ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Layout : : NodeWithStyleAndBoxModelMetrics &  PaintableWithLines : : layout_node_with_style_and_box_metrics ( )  
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  static_cast < Layout : : NodeWithStyleAndBoxModelMetrics & > ( PaintableBox : : layout_node_with_style_and_box_metrics ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								TraversalDecision  PaintableBox : : hit_test_scrollbars ( CSSPixelPoint  position ,  Function < TraversalDecision ( HitTestResult ) >  const &  callback )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: This const_cast is not great, but this method is invoked from overrides of virtual const methods.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  self  =  const_cast < PaintableBox & > ( * this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( self . scrollbar_contains_mouse_position ( ScrollDirection : : Horizontal ,  position ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  callback ( HitTestResult  {  const_cast < PaintableBox & > ( * this )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_draw_enlarged_horizontal_scrollbar )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        self . m_draw_enlarged_horizontal_scrollbar  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        self . set_needs_display ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( self . scrollbar_contains_mouse_position ( ScrollDirection : : Vertical ,  position ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  callback ( HitTestResult  {  const_cast < PaintableBox & > ( * this )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 08:29:51 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_draw_enlarged_vertical_scrollbar )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        self . m_draw_enlarged_vertical_scrollbar  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        self . set_needs_display ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-07 19:06:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelPoint  PaintableBox : : adjust_position_for_cumulative_scroll_offset ( CSSPixelPoint  position )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  position . translated ( - cumulative_offset_of_enclosing_scroll_frame ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								TraversalDecision  PaintableBox : : hit_test ( CSSPixelPoint  position ,  HitTestType  type ,  Function < TraversalDecision ( HitTestResult ) >  const &  callback )  const  
						 
					
						
							
								
									
										
										
										
											2022-03-11 00:03:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-08-10 14:24:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( clip_rect_for_hit_testing ( ) . has_value ( )  & &  ! clip_rect_for_hit_testing ( ) - > contains ( position ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-30 10:02:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-07 19:06:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  position_adjusted_by_scroll_offset  =  adjust_position_for_cumulative_scroll_offset ( position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-29 06:28:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-06 23:32:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( computed_values ( ) . visibility ( )  ! =  CSS : : Visibility : : Visible ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 15:43:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( hit_test_scrollbars ( position_adjusted_by_scroll_offset ,  callback )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:28:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_viewport ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-30 09:50:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  viewport_paintable  =  const_cast < ViewportPaintable & > ( static_cast < ViewportPaintable  const & > ( * this ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        viewport_paintable . build_stacking_context_tree_if_needed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-08 17:30:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        viewport_paintable . document ( ) . update_paint_and_hit_testing_properties_if_needed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        viewport_paintable . refresh_scroll_state ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  stacking_context ( ) - > hit_test ( position ,  type ,  callback ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 10:56:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-11 00:03:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-04 14:54:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( hit_test_children ( position ,  type ,  callback )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-18 20:28:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-26 00:35:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! visible_for_hit_testing ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-15 16:37:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! absolute_border_box_rect ( ) . contains ( position_adjusted_by_scroll_offset ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-26 00:35:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( hit_test_continuation ( callback )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  callback ( HitTestResult  {  const_cast < PaintableBox & > ( * this )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2023-03-18 20:28:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-26 00:35:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								TraversalDecision  PaintableBox : : hit_test_continuation ( Function < TraversalDecision ( HitTestResult ) >  const &  callback )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // If we're hit testing the "middle" part of a continuation chain, we are dealing with an anonymous box that is
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // linked to a parent inline node. Since our block element children did not match the hit test, but we did, we
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // should walk the continuation chain up to the inline parent and return a hit on that instead.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  continuation_node  =  layout_node_with_style_and_box_metrics ( ) . continuation_of_node ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! continuation_node  | |  ! layout_node ( ) . is_anonymous ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( continuation_node - > continuation_of_node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        continuation_node  =  continuation_node - > continuation_of_node ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  paintable  =  * continuation_node - > first_paintable ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! paintable . visible_for_hit_testing ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  callback ( HitTestResult  {  paintable  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < HitTestResult >  PaintableBox : : hit_test ( CSSPixelPoint  position ,  HitTestType  type )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < HitTestResult >  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ( void ) PaintableBox : : hit_test ( position ,  type ,  [ & ] ( HitTestResult  candidate )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-21 15:24:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! result . has_value ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            | |  candidate . vertical_distance . value_or ( CSSPixels : : max_integer_value )  <  result - > vertical_distance . value_or ( CSSPixels : : max_integer_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            | |  candidate . horizontal_distance . value_or ( CSSPixels : : max_integer_value )  <  result - > horizontal_distance . value_or ( CSSPixels : : max_integer_value ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            result  =  move ( candidate ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( result . has_value ( )  & &  ( type  = =  HitTestType : : Exact  | |  ( result - > vertical_distance  = =  0  & &  result - > horizontal_distance  = =  0 ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  result ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-11 00:03:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-04 14:54:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								TraversalDecision  PaintableBox : : hit_test_children ( CSSPixelPoint  position ,  HitTestType  type ,  Function < TraversalDecision ( HitTestResult ) >  const &  callback )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const *  child  =  last_child ( ) ;  child ;  child  =  child - > previous_sibling ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( child - > layout_node ( ) . is_positioned ( )  & &  child - > computed_values ( ) . z_index ( ) . value_or ( 0 )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( child - > hit_test ( position ,  type ,  callback )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								TraversalDecision  PaintableWithLines : : hit_test ( CSSPixelPoint  position ,  HitTestType  type ,  Function < TraversalDecision ( HitTestResult ) >  const &  callback )  const  
						 
					
						
							
								
									
										
										
										
											2022-03-11 00:03:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-08-10 14:24:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( clip_rect_for_hit_testing ( ) . has_value ( )  & &  ! clip_rect_for_hit_testing ( ) - > contains ( position ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-30 10:02:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-07 19:06:57 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  position_adjusted_by_scroll_offset  =  adjust_position_for_cumulative_scroll_offset ( position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-29 06:28:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 17:40:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // TextCursor hit testing mode should be able to place cursor in contenteditable elements even if they are empty
 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-30 11:17:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_fragments . is_empty ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  ! has_children ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  type  = =  HitTestType : : TextCursor 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-04 12:11:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        & &  layout_node ( ) . dom_node ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  layout_node ( ) . dom_node ( ) - > is_editable ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 17:40:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        HitTestResult  const  hit_test_result  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            . paintable  =  const_cast < PaintableWithLines & > ( * this ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            . index_in_node  =  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            . vertical_distance  =  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            . horizontal_distance  =  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( callback ( hit_test_result )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-04 14:57:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! layout_node ( ) . children_are_inline ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  PaintableBox : : hit_test ( position ,  type ,  callback ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-11 00:03:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-30 11:17:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: This CSSPixels -> Float -> CSSPixels conversion is because we can't AffineTransform::map() a CSSPixelPoint.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-20 14:34:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  offset_position  =  position_adjusted_by_scroll_offset . translated ( - transform_origin ( ) ) . to_type < float > ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-30 11:17:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transformed_position_adjusted_by_scroll_offset  =  combined_css_transform ( ) . inverse ( ) . value_or ( { } ) . map ( offset_position ) . to_type < CSSPixels > ( )  +  transform_origin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:32:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( hit_test_scrollbars ( transformed_position_adjusted_by_scroll_offset ,  callback )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-04 00:29:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-04 14:54:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( hit_test_children ( position ,  type ,  callback )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-13 13:11:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-26 00:35:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! visible_for_hit_testing ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-12 21:25:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  fragment  :  fragments ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-31 11:17:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( fragment . paintable ( ) . has_stacking_context ( )  | |  ! fragment . paintable ( ) . visible_for_hit_testing ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-12 21:25:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  fragment_absolute_rect  =  fragment . absolute_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:32:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( fragment_absolute_rect . contains ( transformed_position_adjusted_by_scroll_offset ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( fragment . paintable ( ) . hit_test ( transformed_position_adjusted_by_scroll_offset ,  type ,  callback )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 13:19:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            HitTestResult  hit_test_result  {  const_cast < Paintable & > ( fragment . paintable ( ) ) ,  fragment . index_in_node_for_point ( transformed_position_adjusted_by_scroll_offset ) ,  0 ,  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( callback ( hit_test_result )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( type  = =  HitTestType : : TextCursor )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const *  common_ancestor_parent  =  [ & ] ( )  - >  DOM : : Node  const *  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  selection  =  document ( ) . get_selection ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! selection ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  range  =  selection - > range ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! range ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  common_ancestor  =  range - > common_ancestor_container ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( common_ancestor - > parent ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  common_ancestor - > parent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  common_ancestor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const *  fragment_dom_node  =  fragment . layout_node ( ) . dom_node ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( common_ancestor_parent  & &  fragment_dom_node  & &  common_ancestor_parent - > is_ancestor_of ( * fragment_dom_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // If we reached this point, the position is not within the fragment. However, the fragment start or end might be
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // the place to place the cursor. To determine the best place, we first find the closest fragment horizontally to
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // the cursor. If we could not find one, then find for the closest vertically above the cursor.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // If we knew the direction of selection, we would look above if selecting upward.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:32:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( fragment_absolute_rect . bottom ( )  -  1  < =  transformed_position_adjusted_by_scroll_offset . y ( ) )  {  // fully below the fragment
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    HitTestResult  hit_test_result  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        . paintable  =  const_cast < Paintable & > ( fragment . paintable ( ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 14:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        . index_in_node  =  fragment . index_in_node_for_byte_offset ( fragment . start_byte_offset ( )  +  fragment . length_in_bytes ( ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:32:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        . vertical_distance  =  transformed_position_adjusted_by_scroll_offset . y ( )  -  fragment_absolute_rect . bottom ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( callback ( hit_test_result )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:32:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( fragment_absolute_rect . top ( )  < =  transformed_position_adjusted_by_scroll_offset . y ( ) )  {  // vertically within the fragment
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( transformed_position_adjusted_by_scroll_offset . x ( )  <  fragment_absolute_rect . left ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        HitTestResult  hit_test_result  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            . paintable  =  const_cast < Paintable & > ( fragment . paintable ( ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 14:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                            . index_in_node  =  fragment . index_in_node_for_byte_offset ( fragment . start_byte_offset ( ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                            . vertical_distance  =  0 , 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:32:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                            . horizontal_distance  =  fragment_absolute_rect . left ( )  -  transformed_position_adjusted_by_scroll_offset . x ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        if  ( callback ( hit_test_result )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:32:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    }  else  if  ( transformed_position_adjusted_by_scroll_offset . x ( )  >  fragment_absolute_rect . right ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        HitTestResult  hit_test_result  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            . paintable  =  const_cast < Paintable & > ( fragment . paintable ( ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-12 14:49:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                            . index_in_node  =  fragment . index_in_node_for_byte_offset ( fragment . start_byte_offset ( )  +  fragment . length_in_bytes ( ) ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                            . vertical_distance  =  0 , 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-23 20:32:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                            . horizontal_distance  =  transformed_position_adjusted_by_scroll_offset . x ( )  -  fragment_absolute_rect . right ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 20:12:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        if  ( callback ( hit_test_result )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 01:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-11 00:03:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-07-04 14:57:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! stacking_context ( )  & &  is_visible ( )  & &  ( ! layout_node ( ) . is_anonymous ( )  | |  layout_node ( ) . is_positioned ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-04 12:11:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        & &  absolute_border_box_rect ( ) . contains ( position_adjusted_by_scroll_offset ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 21:34:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( callback ( HitTestResult  {  const_cast < PaintableWithLines & > ( * this )  } )  = =  TraversalDecision : : Break ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  TraversalDecision : : Break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  TraversalDecision : : Continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-11 00:03:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 16:47:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : set_needs_display ( InvalidateDisplayList  should_invalidate_display_list )  
						 
					
						
							
								
									
										
										
										
											2024-01-14 13:46:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-09-02 16:47:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    document ( ) . set_needs_display ( absolute_rect ( ) ,  should_invalidate_display_list ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-14 13:46:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-26 00:28:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < CSSPixelRect >  PaintableBox : : get_masking_area ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  clip_path  =  computed_values ( ) . clip_path ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Support other clip sources.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! clip_path . has_value ( )  | |  ! clip_path - > is_basic_shape ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Support other geometry boxes. See: https://drafts.fxtf.org/css-masking/#typedef-geometry-box
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-05 15:15:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-transforms-1/#transform-box
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : transform_box_rect ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transform_box  =  computed_values ( ) . transform_box ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // For SVG elements without associated CSS layout box, the used value for content-box is fill-box and for
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // border-box is stroke-box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: This currently detects any SVG element except the <svg> one. Is that correct?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //        And is it correct to use `else` below?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is < Painting : : SVGPaintable > ( * this ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( transform_box )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TransformBox : : ContentBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transform_box  =  CSS : : TransformBox : : FillBox ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TransformBox : : BorderBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transform_box  =  CSS : : TransformBox : : StrokeBox ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // For elements with associated CSS layout box, the used value for fill-box is content-box and for
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // stroke-box and view-box is border-box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( transform_box )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TransformBox : : FillBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transform_box  =  CSS : : TransformBox : : ContentBox ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TransformBox : : StrokeBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  CSS : : TransformBox : : ViewBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transform_box  =  CSS : : TransformBox : : BorderBox ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    switch  ( transform_box )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  CSS : : TransformBox : : ContentBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Uses the content box as reference box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: The reference box of a table is the border box of its table wrapper box, not its table box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  absolute_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  CSS : : TransformBox : : BorderBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Uses the border box as reference box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: The reference box of a table is the border box of its table wrapper box, not its table box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  CSS : : TransformBox : : FillBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Uses the object bounding box as reference box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: For now we're using the content rect as an approximation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  absolute_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  CSS : : TransformBox : : StrokeBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Uses the stroke bounding box as reference box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: For now we're using the border rect as an approximation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  CSS : : TransformBox : : ViewBox : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Uses the nearest SVG viewport as reference box.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: If a viewBox attribute is specified for the SVG viewport creating element:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //  - The reference box is positioned at the origin of the coordinate system established by the viewBox attribute.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //  - The dimension of the reference box is set to the width and height values of the viewBox attribute.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto *  svg_paintable  =  first_ancestor_of_type < Painting : : SVGSVGPaintable > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! svg_paintable ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  svg_paintable - > absolute_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableBox : : resolve_paint_properties ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-02-20 12:18:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Base : : resolve_paint_properties ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  computed_values  =  this - > computed_values ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  layout_node  =  this - > layout_node ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Border radii
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-30 19:26:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    BorderRadiiData  radii_data  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( computed_values . has_noninitial_border_radii ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        CSSPixelRect  const  border_rect  {  0 ,  0 ,  border_box_width ( ) ,  border_box_height ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  border_top_left_radius  =  computed_values . border_top_left_radius ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  border_top_right_radius  =  computed_values . border_top_right_radius ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  border_bottom_right_radius  =  computed_values . border_bottom_right_radius ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  border_bottom_left_radius  =  computed_values . border_bottom_left_radius ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        radii_data  =  normalize_border_radii_data ( layout_node ,  border_rect ,  border_top_left_radius , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            border_top_right_radius ,  border_bottom_right_radius , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            border_bottom_left_radius ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    set_border_radii_data ( radii_data ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Box shadows
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  box_shadow_data  =  computed_values . box_shadow ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < Painting : : ShadowData >  resolved_box_shadow_data ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    resolved_box_shadow_data . ensure_capacity ( box_shadow_data . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  layer  :  box_shadow_data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        resolved_box_shadow_data . empend ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            layer . color , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            layer . offset_x . to_px ( layout_node ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            layer . offset_y . to_px ( layout_node ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            layer . blur_radius . to_px ( layout_node ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            layer . spread_distance . to_px ( layout_node ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            layer . placement  = =  CSS : : ShadowPlacement : : Outer  ?  Painting : : ShadowPlacement : : Outer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                                                           :  Painting : : ShadowPlacement : : Inner ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set_box_shadow_data ( move ( resolved_box_shadow_data ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  transformations  =  computed_values . transformations ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-22 16:42:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  translate  =  computed_values . translate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-22 16:11:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  rotate  =  computed_values . rotate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-22 18:07:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  scale  =  computed_values . scale ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-15 04:36:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  matrix  =  Gfx : : FloatMatrix4x4 : : identity ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( translate . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        matrix  =  matrix  *  translate - > to_matrix ( * this ) . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( rotate . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        matrix  =  matrix  *  rotate - > to_matrix ( * this ) . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( scale . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        matrix  =  matrix  *  scale - > to_matrix ( * this ) . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  transform  :  transformations ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        matrix  =  matrix  *  transform . to_matrix ( * this ) . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set_transform ( matrix ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  transform_origin  =  computed_values . transform_origin ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-05 15:15:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  reference_box  =  transform_box_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  x  =  reference_box . left ( )  +  transform_origin . x . to_px ( layout_node ,  reference_box . width ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  y  =  reference_box . top ( )  +  transform_origin . y . to_px ( layout_node ,  reference_box . height ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set_transform_origin ( {  x ,  y  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set_transform_origin ( {  x ,  y  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Outlines
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  outline_width  =  computed_values . outline_width ( ) . to_px ( layout_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  outline_data  =  borders_data_for_outline ( layout_node ,  computed_values . outline_color ( ) ,  computed_values . outline_style ( ) ,  outline_width ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  outline_offset  =  computed_values . outline_offset ( ) . to_px ( layout_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set_outline_data ( outline_data ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set_outline_offset ( outline_offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  combined_transform  =  compute_combined_css_transform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set_combined_css_transform ( combined_transform ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-02 16:58:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    CSSPixelRect  background_rect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Color  background_color  =  computed_values . background_color ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const *  background_layers  =  & computed_values . background_layers ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-13 21:29:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( layout_node_with_style_and_box_metrics ( ) . is_root_element ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-02 16:58:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_rect  =  navigable ( ) - > viewport_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Section 2.11.2: If the computed value of background-image on the root element is none and its background-color is transparent,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								        // user agents must instead propagate the computed values of the background properties from that element’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( document ( ) . html_element ( ) - > should_use_body_background_properties ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            background_layers  =  document ( ) . background_layers ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            background_color  =  document ( ) . background_color ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_rect  =  absolute_padding_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // HACK: If the Box has a border, use the bordered_rect to paint the background.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       This way if we have a border-radius there will be no gap between the filling and actual border.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( computed_values . border_top ( ) . width  ! =  0  | |  computed_values . border_right ( ) . width  ! =  0  | |  computed_values . border_bottom ( ) . width  ! =  0  | |  computed_values . border_left ( ) . width  ! =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_rect  =  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_resolved_background . layers . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( background_layers )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 22:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        m_resolved_background  =  resolve_background_layers ( * background_layers ,  * this ,  background_color ,  background_rect ,  normalized_border_radii_data ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-02 16:58:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-16 03:25:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  mask_image  =  computed_values . mask_image ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        mask_image - > resolve_for_size ( layout_node_with_style_and_box_metrics ( ) ,  absolute_padding_box_rect ( ) . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  PaintableWithLines : : resolve_paint_properties ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-02-20 12:18:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Base : : resolve_paint_properties ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  layout_node  =  this - > layout_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-16 18:05:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  fragment  :  fragments ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! fragment . m_layout_node - > is_text_node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  text_node  =  static_cast < Layout : : TextNode  const & > ( * fragment . m_layout_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  font  =  fragment . m_layout_node - > first_available_font ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const  glyph_height  =  CSSPixels : : nearest_value_for ( font . pixel_size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const  css_line_thickness  =  [ & ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  computed_thickness  =  text_node . computed_values ( ) . text_decoration_thickness ( ) . resolved ( text_node ,  CSS : : Length ( 1 ,  CSS : : Length : : Type : : Em ) . to_px ( text_node ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( computed_thickness . is_auto ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  max ( glyph_height . scaled ( 0.1 ) ,  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  computed_thickness . to_px ( * fragment . m_layout_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        fragment . set_text_decoration_thickness ( css_line_thickness ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  text_shadow  =  text_node . computed_values ( ) . text_shadow ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! text_shadow . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-16 18:05:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < ShadowData >  resolved_shadow_data ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            resolved_shadow_data . ensure_capacity ( text_shadow . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( auto  const &  layer  :  text_shadow )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                resolved_shadow_data . empend ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    layer . color , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    layer . offset_x . to_px ( layout_node ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    layer . offset_y . to_px ( layout_node ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    layer . blur_radius . to_px ( layout_node ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    layer . spread_distance . to_px ( layout_node ) , 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-16 18:05:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    ShadowPlacement : : Outer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2025-03-16 18:05:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            fragment . set_shadows ( move ( resolved_shadow_data ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-22 18:43:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:11:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < ScrollFrame  const >  PaintableBox : : nearest_scroll_frame ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-09-01 01:23:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_fixed_position ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:11:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const *  paintable  =  this - > containing_block ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( paintable )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( paintable - > own_scroll_frame ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  paintable - > own_scroll_frame ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-01 01:23:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( paintable - > is_fixed_position ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:11:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        paintable  =  paintable - > containing_block ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 14:06:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSPixelRect  PaintableBox : : border_box_rect_relative_to_nearest_scrollable_ancestor ( )  const  
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:20:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-09-02 14:06:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  result  =  absolute_border_box_rect ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:20:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const *  nearest_scrollable_ancestor  =  this - > nearest_scrollable_ancestor ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( nearest_scrollable_ancestor )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        result . set_location ( result . location ( )  -  nearest_scrollable_ancestor - > absolute_rect ( ) . top_left ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								PaintableBox  const *  PaintableBox : : nearest_scrollable_ancestor ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const *  paintable  =  this - > containing_block ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( paintable )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-30 15:47:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( paintable - > could_be_scrolled_by_wheel_event ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:20:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  paintable ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-01 01:23:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( paintable - > is_fixed_position ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 19:20:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        paintable  =  paintable - > containing_block ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-10 23:13:37 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}