
In #10434 an issue with leading whitespace in new lines after a <br> element was fixed by checking whether the last fragment of LineBox is empty. However, this introduced a regression by which whitespace following inline elements was swallowed, so `<b>Test</b> 123` would appear like `Test123`. By asking specifically if we are handling a forced linebreak instead of implicity asking for a property that may be shared by other Node types, we can maintain the correct behavior in regards to leading whitespace on new lines, as well as trailing whitespace of inline elements.
31 lines
845 B
C++
31 lines
845 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/HTML/HTMLBRElement.h>
|
|
#include <LibWeb/Layout/Node.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class BreakNode final : public NodeWithStyleAndBoxModelMetrics {
|
|
public:
|
|
BreakNode(DOM::Document&, HTML::HTMLBRElement&, NonnullRefPtr<CSS::StyleProperties>);
|
|
virtual ~BreakNode() override;
|
|
|
|
const HTML::HTMLBRElement& dom_node() const { return verify_cast<HTML::HTMLBRElement>(*Node::dom_node()); }
|
|
|
|
private:
|
|
virtual bool is_break_node() const final { return true; }
|
|
virtual void paint(PaintContext&, PaintPhase) override;
|
|
|
|
virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override;
|
|
};
|
|
|
|
template<>
|
|
inline bool Node::fast_is<BreakNode>() const { return is_break_node(); }
|
|
|
|
}
|