mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:17:46 +00:00
LibWeb: Move set_needs_display() from layout node to paintable
For this method, there is no need to go through the layout node when we can directly reach the paintable.
This commit is contained in:
parent
814bed33b4
commit
7c2713c14f
21 changed files with 97 additions and 87 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/HTMLMediaElement.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
#include <LibWeb/Platform/AudioCodecPlugin.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -30,8 +31,8 @@ AudioTrack::AudioTrack(JS::Realm& realm, JS::NonnullGCPtr<HTMLMediaElement> medi
|
|||
, m_audio_plugin(Platform::AudioCodecPlugin::create(move(loader)).release_value_but_fixme_should_propagate_errors())
|
||||
{
|
||||
m_audio_plugin->on_playback_position_updated = [this](auto position) {
|
||||
if (auto* layout_node = m_media_element->layout_node())
|
||||
layout_node->set_needs_display();
|
||||
if (auto const* paintable = m_media_element->paintable())
|
||||
paintable->set_needs_display();
|
||||
|
||||
auto playback_position = static_cast<double>(position.to_milliseconds()) / 1000.0;
|
||||
m_media_element->set_current_playback_position(playback_position);
|
||||
|
|
|
@ -273,9 +273,9 @@ BrowsingContext::BrowsingContext(JS::NonnullGCPtr<Page> page, HTML::NavigableCon
|
|||
m_cursor_blink_timer = Core::Timer::create_repeating(500, [this] {
|
||||
if (!is_focused_context())
|
||||
return;
|
||||
if (m_cursor_position && m_cursor_position->node()->layout_node()) {
|
||||
if (m_cursor_position && m_cursor_position->node()->layout_node() && m_cursor_position->node()->layout_node()->paintable()) {
|
||||
m_cursor_blink_state = !m_cursor_blink_state;
|
||||
m_cursor_position->node()->layout_node()->set_needs_display();
|
||||
m_cursor_position->node()->paintable()->set_needs_display();
|
||||
}
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
@ -327,8 +327,8 @@ void BrowsingContext::reset_cursor_blink_cycle()
|
|||
{
|
||||
m_cursor_blink_state = true;
|
||||
m_cursor_blink_timer->restart();
|
||||
if (m_cursor_position && m_cursor_position->node()->layout_node())
|
||||
m_cursor_position->node()->layout_node()->set_needs_display();
|
||||
if (m_cursor_position && m_cursor_position->node()->paintable())
|
||||
m_cursor_position->node()->paintable()->set_needs_display();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsers.html#top-level-browsing-context
|
||||
|
@ -404,13 +404,13 @@ void BrowsingContext::set_cursor_position(JS::NonnullGCPtr<DOM::Position> positi
|
|||
if (m_cursor_position && m_cursor_position->equals(position))
|
||||
return;
|
||||
|
||||
if (m_cursor_position && m_cursor_position->node()->layout_node())
|
||||
m_cursor_position->node()->layout_node()->set_needs_display();
|
||||
if (m_cursor_position && m_cursor_position->node()->paintable())
|
||||
m_cursor_position->node()->paintable()->set_needs_display();
|
||||
|
||||
m_cursor_position = position;
|
||||
|
||||
if (m_cursor_position && m_cursor_position->node()->layout_node())
|
||||
m_cursor_position->node()->layout_node()->set_needs_display();
|
||||
if (m_cursor_position && m_cursor_position->node()->paintable())
|
||||
m_cursor_position->node()->paintable()->set_needs_display();
|
||||
|
||||
reset_cursor_blink_cycle();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <LibWeb/HTML/TextMetrics.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
#include <LibWeb/Platform/FontPlugin.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
|
@ -174,9 +175,9 @@ WebIDL::ExceptionOr<void> CanvasRenderingContext2D::draw_image_internal(CanvasIm
|
|||
void CanvasRenderingContext2D::did_draw(Gfx::FloatRect const&)
|
||||
{
|
||||
// FIXME: Make use of the rect to reduce the invalidated area when possible.
|
||||
if (!canvas_element().layout_node())
|
||||
if (!canvas_element().paintable())
|
||||
return;
|
||||
canvas_element().layout_node()->set_needs_display();
|
||||
canvas_element().paintable()->set_needs_display();
|
||||
}
|
||||
|
||||
Gfx::Painter* CanvasRenderingContext2D::painter()
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -78,8 +79,8 @@ void HTMLBodyElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
} else if (name.equals_ignoring_ascii_case("background"sv)) {
|
||||
m_background_style_value = CSS::ImageStyleValue::create(document().parse_url(value.value_or(String {})));
|
||||
m_background_style_value->on_animate = [this] {
|
||||
if (layout_node()) {
|
||||
layout_node()->set_needs_display();
|
||||
if (paintable()) {
|
||||
paintable()->set_needs_display();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1005,8 +1005,8 @@ void HTMLImageElement::animate()
|
|||
}
|
||||
}
|
||||
|
||||
if (layout_node())
|
||||
layout_node()->set_needs_display();
|
||||
if (paintable())
|
||||
paintable()->set_needs_display();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <LibWeb/HTML/VideoTrackList.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/MimeSniff/MimeType.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -325,8 +326,8 @@ void HTMLMediaElement::set_duration(double duration)
|
|||
|
||||
m_duration = duration;
|
||||
|
||||
if (auto* layout_node = this->layout_node())
|
||||
layout_node->set_needs_display();
|
||||
if (auto* paintable = this->paintable())
|
||||
paintable->set_needs_display();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> HTMLMediaElement::play()
|
||||
|
@ -424,8 +425,8 @@ void HTMLMediaElement::volume_or_muted_attribute_changed()
|
|||
|
||||
// FIXME: Then, if the media element is not allowed to play, the user agent must run the internal pause steps for the media element.
|
||||
|
||||
if (auto* layout_node = this->layout_node())
|
||||
layout_node->set_needs_display();
|
||||
if (auto* paintable = this->paintable())
|
||||
paintable->set_needs_display();
|
||||
|
||||
on_volume_change();
|
||||
}
|
||||
|
@ -1586,8 +1587,8 @@ void HTMLMediaElement::set_show_poster(bool show_poster)
|
|||
|
||||
m_show_poster = show_poster;
|
||||
|
||||
if (auto* layout_node = this->layout_node())
|
||||
layout_node->set_needs_display();
|
||||
if (auto* paintable = this->paintable())
|
||||
paintable->set_needs_display();
|
||||
}
|
||||
|
||||
void HTMLMediaElement::set_paused(bool paused)
|
||||
|
@ -1600,8 +1601,8 @@ void HTMLMediaElement::set_paused(bool paused)
|
|||
if (m_paused)
|
||||
on_paused();
|
||||
|
||||
if (auto* layout_node = this->layout_node())
|
||||
layout_node->set_needs_display();
|
||||
if (auto* paintable = this->paintable())
|
||||
paintable->set_needs_display();
|
||||
set_needs_style_update(true);
|
||||
}
|
||||
|
||||
|
@ -1928,8 +1929,8 @@ void HTMLMediaElement::set_layout_display_time(Badge<Painting::MediaPaintable>,
|
|||
|
||||
m_display_time = move(display_time);
|
||||
|
||||
if (auto* layout_node = this->layout_node())
|
||||
layout_node->set_needs_display();
|
||||
if (auto* paintable = this->paintable())
|
||||
paintable->set_needs_display();
|
||||
}
|
||||
|
||||
double HTMLMediaElement::layout_display_time(Badge<Painting::MediaPaintable>) const
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <LibWeb/HTML/HTMLVideoElement.h>
|
||||
#include <LibWeb/HTML/VideoTrack.h>
|
||||
#include <LibWeb/Layout/VideoBox.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
#include <LibWeb/Platform/ImageCodecPlugin.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -102,8 +103,8 @@ void HTMLVideoElement::set_video_track(JS::GCPtr<HTML::VideoTrack> video_track)
|
|||
void HTMLVideoElement::set_current_frame(Badge<VideoTrack>, RefPtr<Gfx::Bitmap> frame, double position)
|
||||
{
|
||||
m_current_frame = { move(frame), position };
|
||||
if (layout_node())
|
||||
layout_node()->set_needs_display();
|
||||
if (paintable())
|
||||
paintable()->set_needs_display();
|
||||
}
|
||||
|
||||
void HTMLVideoElement::on_playing()
|
||||
|
|
|
@ -1990,8 +1990,8 @@ void Navigable::set_needs_display(CSSPixelRect const& rect)
|
|||
return;
|
||||
}
|
||||
|
||||
if (container() && container()->layout_node())
|
||||
container()->layout_node()->set_needs_display();
|
||||
if (container() && container()->paintable())
|
||||
container()->paintable()->set_needs_display();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#rendering-opportunity
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue