mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all its users with one of the following: - A normal, empty DeprecatedString - Optional<DeprecatedString> Note that null states of DeprecatedFlyString/StringView/etc are *not* affected by this commit. However, DeprecatedString::empty() is now considered equal to a null StringView.
This commit is contained in:
parent
daf6d8173c
commit
aeee98b3a1
189 changed files with 597 additions and 652 deletions
|
@ -1092,10 +1092,11 @@ void BlockFormattingContext::layout_list_item_marker(ListItemBox const& list_ite
|
|||
|
||||
CSSPixels default_marker_width = max(4, marker.font().pixel_size_rounded_up() - 4);
|
||||
|
||||
if (marker.text().is_empty()) {
|
||||
auto marker_text = marker.text().value_or("");
|
||||
if (marker_text.is_empty()) {
|
||||
marker_state.set_content_width(image_width + default_marker_width);
|
||||
} else {
|
||||
auto text_width = marker.font().width(marker.text());
|
||||
auto text_width = marker.font().width(marker_text);
|
||||
marker_state.set_content_width(image_width + CSSPixels::nearest_value_for(text_width));
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ Label const* Label::label_for_control_node(LabelableNode const& control)
|
|||
// same tree as the label element. If the attribute is specified and there is an element in the tree
|
||||
// whose ID is equal to the value of the for attribute, and the first such element in tree order is
|
||||
// a labelable element, then that element is the label element's labeled control.
|
||||
if (auto id = control.dom_node().deprecated_attribute(HTML::AttributeNames::id); !id.is_empty()) {
|
||||
if (auto id = control.dom_node().attribute(HTML::AttributeNames::id); id.has_value() && !id->is_empty()) {
|
||||
Label const* label = nullptr;
|
||||
|
||||
control.document().layout_node()->for_each_in_inclusive_subtree_of_type<Label>([&](auto& node) {
|
||||
|
@ -126,9 +126,9 @@ LabelableNode* Label::labeled_control()
|
|||
// same tree as the label element. If the attribute is specified and there is an element in the tree
|
||||
// whose ID is equal to the value of the for attribute, and the first such element in tree order is
|
||||
// a labelable element, then that element is the label element's labeled control.
|
||||
if (auto for_ = dom_node().for_(); !for_.is_null()) {
|
||||
if (auto for_ = dom_node().for_(); for_.has_value()) {
|
||||
document().layout_node()->for_each_in_inclusive_subtree_of_type<LabelableNode>([&](auto& node) {
|
||||
if (node.dom_node().deprecated_attribute(HTML::AttributeNames::id) == for_) {
|
||||
if (node.dom_node().attribute(HTML::AttributeNames::id) == for_) {
|
||||
control = &node;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, size_t index, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~ListItemMarkerBox() override;
|
||||
|
||||
DeprecatedString const& text() const { return m_text; }
|
||||
Optional<DeprecatedString> const& text() const { return m_text; }
|
||||
|
||||
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
|
@ -33,7 +33,7 @@ private:
|
|||
CSS::ListStylePosition m_list_style_position { CSS::ListStylePosition::Outside };
|
||||
size_t m_index;
|
||||
|
||||
DeprecatedString m_text {};
|
||||
Optional<DeprecatedString> m_text {};
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -306,9 +306,9 @@ void TextNode::invalidate_text_for_rendering()
|
|||
|
||||
DeprecatedString const& TextNode::text_for_rendering() const
|
||||
{
|
||||
if (m_text_for_rendering.is_null())
|
||||
if (!m_text_for_rendering.has_value())
|
||||
const_cast<TextNode*>(this)->compute_text_for_rendering();
|
||||
return m_text_for_rendering;
|
||||
return *m_text_for_rendering;
|
||||
}
|
||||
|
||||
// NOTE: This collapses whitespace into a single ASCII space if the CSS white-space property tells us to.
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
private:
|
||||
virtual bool is_text_node() const final { return true; }
|
||||
|
||||
DeprecatedString m_text_for_rendering;
|
||||
Optional<DeprecatedString> m_text_for_rendering;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue