mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:32:44 +00:00 
			
		
		
		
	 9927dab993
			
		
	
	
		9927dab993
		
	
	
	
	
		
			
			Previously, when having inline contexts consisting of just a `<br/>` tag, we would not create a line box. Ensure that there is always a line box when a line is explicitly being broken and also ensure it won't be trimmed due to being empty. This will a fix a number of sites that use `<br>` tags for layouts between block elements (even though the spec says they shouldn't).
		
			
				
	
	
		
			46 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Vector.h>
 | |
| #include <LibWeb/Layout/LineBoxFragment.h>
 | |
| 
 | |
| namespace Web::Layout {
 | |
| 
 | |
| class LineBox {
 | |
| public:
 | |
|     LineBox() = default;
 | |
| 
 | |
|     CSSPixels width() const { return m_width; }
 | |
|     CSSPixels height() const { return m_height; }
 | |
|     CSSPixels bottom() const { return m_bottom; }
 | |
|     CSSPixels baseline() const { return m_baseline; }
 | |
| 
 | |
|     void add_fragment(Node const& layout_node, int start, int length, CSSPixels leading_size, CSSPixels trailing_size, CSSPixels leading_margin, CSSPixels trailing_margin, CSSPixels content_width, CSSPixels content_height, CSSPixels border_box_top, CSSPixels border_box_bottom, LineBoxFragment::Type = LineBoxFragment::Type::Normal);
 | |
| 
 | |
|     Vector<LineBoxFragment> const& fragments() const { return m_fragments; }
 | |
|     Vector<LineBoxFragment>& fragments() { return m_fragments; }
 | |
| 
 | |
|     void trim_trailing_whitespace();
 | |
| 
 | |
|     bool is_empty_or_ends_in_whitespace() const;
 | |
|     bool is_empty() const { return m_fragments.is_empty() && !m_has_break; }
 | |
| 
 | |
| private:
 | |
|     friend class BlockContainer;
 | |
|     friend class InlineFormattingContext;
 | |
|     friend class LineBuilder;
 | |
| 
 | |
|     Vector<LineBoxFragment> m_fragments;
 | |
|     CSSPixels m_width { 0 };
 | |
|     CSSPixels m_height { 0 };
 | |
|     CSSPixels m_bottom { 0 };
 | |
|     CSSPixels m_baseline { 0 };
 | |
|     bool m_has_break { false };
 | |
| };
 | |
| 
 | |
| }
 |