mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:32:43 +00:00 
			
		
		
		
	 9c99182b1e
			
		
	
	
		9c99182b1e
		
	
	
	
	
		
			
			This change modifies hit_test() to no longer return the first paintable encountered at a specified position. Instead, this function accepts a callback that is invoked for each paintable located at a position, in hit-testing order. This modification will allow us to reuse this call for `Document.elementsFromPoint()` in upcoming changes.
		
			
				
	
	
		
			57 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Vector.h>
 | |
| #include <LibGfx/Matrix4x4.h>
 | |
| #include <LibWeb/Painting/InlinePaintable.h>
 | |
| #include <LibWeb/Painting/Paintable.h>
 | |
| 
 | |
| namespace Web::Painting {
 | |
| 
 | |
| class StackingContext {
 | |
| public:
 | |
|     StackingContext(Paintable&, StackingContext* parent, size_t index_in_tree_order);
 | |
| 
 | |
|     StackingContext* parent() { return m_parent; }
 | |
|     StackingContext const* parent() const { return m_parent; }
 | |
| 
 | |
|     Paintable const& paintable() const { return *m_paintable; }
 | |
|     PaintableBox const& paintable_box() const { return verify_cast<PaintableBox>(*m_paintable); }
 | |
|     InlinePaintable const& inline_paintable() const { return verify_cast<InlinePaintable>(*m_paintable); }
 | |
| 
 | |
|     enum class StackingContextPaintPhase {
 | |
|         BackgroundAndBorders,
 | |
|         Floats,
 | |
|         BackgroundAndBordersForInlineLevelAndReplaced,
 | |
|         Foreground,
 | |
|         FocusAndOverlay,
 | |
|     };
 | |
| 
 | |
|     static void paint_node_as_stacking_context(Paintable const&, PaintContext&);
 | |
|     static void paint_descendants(PaintContext&, Paintable const&, StackingContextPaintPhase);
 | |
|     void paint(PaintContext&) const;
 | |
| 
 | |
|     [[nodiscard]] TraversalDecision hit_test(CSSPixelPoint, HitTestType, Function<TraversalDecision(HitTestResult)> const& callback) const;
 | |
| 
 | |
|     Gfx::AffineTransform affine_transform_matrix() const;
 | |
| 
 | |
|     void dump(int indent = 0) const;
 | |
| 
 | |
|     void sort();
 | |
| 
 | |
| private:
 | |
|     JS::NonnullGCPtr<Paintable> m_paintable;
 | |
|     StackingContext* const m_parent { nullptr };
 | |
|     Vector<StackingContext*> m_children;
 | |
|     size_t m_index_in_tree_order { 0 };
 | |
| 
 | |
|     static void paint_child(PaintContext&, StackingContext const&);
 | |
|     void paint_internal(PaintContext&) const;
 | |
| };
 | |
| 
 | |
| }
 |