mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:22:45 +00:00 
			
		
		
		
	 c4826eae4f
			
		
	
	
		c4826eae4f
		
	
	
	
	
		
			
			There's a subtle difference here. A "block box" in the spec is a block-level box, while a "block container" is a box whose children are either all inline-level boxes in an IFC, or all block-level boxes participating in a BFC. Notably, an "inline-block" box is a "block container" but not a "block box" since it is itself inline-level.
		
			
				
	
	
		
			38 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/DOM/Element.h>
 | |
| #include <LibWeb/Layout/BlockContainer.h>
 | |
| #include <LibWeb/Layout/InlineFormattingContext.h>
 | |
| #include <LibWeb/Layout/ReplacedBox.h>
 | |
| 
 | |
| namespace Web::Layout {
 | |
| 
 | |
| ReplacedBox::ReplacedBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
 | |
|     : Box(document, &element, move(style))
 | |
| {
 | |
|     // FIXME: Allow non-inline replaced elements.
 | |
|     set_inline(true);
 | |
| }
 | |
| 
 | |
| ReplacedBox::~ReplacedBox()
 | |
| {
 | |
| }
 | |
| 
 | |
| void ReplacedBox::split_into_lines(InlineFormattingContext& context, LayoutMode layout_mode)
 | |
| {
 | |
|     auto& containing_block = context.containing_block();
 | |
| 
 | |
|     prepare_for_replaced_layout();
 | |
|     context.dimension_box_on_line(*this, layout_mode);
 | |
| 
 | |
|     auto* line_box = &containing_block.ensure_last_line_box();
 | |
|     if (line_box->width() > 0 && line_box->width() + width() > context.available_width_at_line(containing_block.line_boxes().size() - 1))
 | |
|         line_box = &containing_block.add_line_box();
 | |
|     line_box->add_fragment(*this, 0, 0, width(), height());
 | |
| }
 | |
| 
 | |
| }
 |