mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:28:11 +00:00
LibWeb: Rename Layout::BlockBox => BlockContainer
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.
This commit is contained in:
parent
5408913b22
commit
c4826eae4f
38 changed files with 95 additions and 94 deletions
76
Userland/Libraries/LibWeb/Layout/BlockContainer.h
Normal file
76
Userland/Libraries/LibWeb/Layout/BlockContainer.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Layout/Box.h>
|
||||
#include <LibWeb/Layout/LineBox.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
// https://drafts.csswg.org/css-display/#block-container
|
||||
class BlockContainer : public Box {
|
||||
public:
|
||||
BlockContainer(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
|
||||
BlockContainer(DOM::Document&, DOM::Node*, CSS::ComputedValues);
|
||||
virtual ~BlockContainer() override;
|
||||
|
||||
virtual void paint(PaintContext&, PaintPhase) override;
|
||||
|
||||
virtual HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const override;
|
||||
|
||||
BlockContainer* previous_sibling() { return verify_cast<BlockContainer>(Node::previous_sibling()); }
|
||||
const BlockContainer* previous_sibling() const { return verify_cast<BlockContainer>(Node::previous_sibling()); }
|
||||
BlockContainer* next_sibling() { return verify_cast<BlockContainer>(Node::next_sibling()); }
|
||||
const BlockContainer* next_sibling() const { return verify_cast<BlockContainer>(Node::next_sibling()); }
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_fragment(Callback);
|
||||
template<typename Callback>
|
||||
void for_each_fragment(Callback) const;
|
||||
|
||||
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
|
||||
|
||||
bool is_scrollable() const;
|
||||
const Gfx::FloatPoint& scroll_offset() const { return m_scroll_offset; }
|
||||
void set_scroll_offset(const Gfx::FloatPoint&);
|
||||
|
||||
private:
|
||||
virtual bool is_block_box() const final { return true; }
|
||||
virtual bool wants_mouse_events() const override { return false; }
|
||||
virtual bool handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta) override;
|
||||
|
||||
bool should_clip_overflow() const;
|
||||
|
||||
Gfx::FloatPoint m_scroll_offset;
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool Node::fast_is<BlockContainer>() const { return is_block_box(); }
|
||||
|
||||
template<typename Callback>
|
||||
void BlockContainer::for_each_fragment(Callback callback)
|
||||
{
|
||||
for (auto& line_box : line_boxes()) {
|
||||
for (auto& fragment : line_box.fragments()) {
|
||||
if (callback(fragment) == IterationDecision::Break)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void BlockContainer::for_each_fragment(Callback callback) const
|
||||
{
|
||||
for (auto& line_box : line_boxes()) {
|
||||
for (auto& fragment : line_box.fragments()) {
|
||||
if (callback(fragment) == IterationDecision::Break)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue