mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:17:44 +00:00
LibWeb: Rename BrowsingContext::document() => active_document()
This better matches the spec nomenclature. Note that we don't yet *retrieve* the active document according to spec.
This commit is contained in:
parent
dd82f68326
commit
84fcf879f9
10 changed files with 69 additions and 69 deletions
|
@ -66,26 +66,26 @@ bool BrowsingContext::is_focused_context() const
|
|||
return m_page && &m_page->focused_context() == this;
|
||||
}
|
||||
|
||||
void BrowsingContext::set_document(DOM::Document* document)
|
||||
void BrowsingContext::set_active_document(DOM::Document* document)
|
||||
{
|
||||
if (m_document == document)
|
||||
if (m_active_document == document)
|
||||
return;
|
||||
|
||||
m_cursor_position = {};
|
||||
|
||||
if (m_document)
|
||||
m_document->detach_from_browsing_context({}, *this);
|
||||
if (m_active_document)
|
||||
m_active_document->detach_from_browsing_context({}, *this);
|
||||
|
||||
m_document = document;
|
||||
m_active_document = document;
|
||||
|
||||
if (m_document) {
|
||||
m_document->attach_to_browsing_context({}, *this);
|
||||
if (m_active_document) {
|
||||
m_active_document->attach_to_browsing_context({}, *this);
|
||||
if (m_page && is_top_level())
|
||||
m_page->client().page_did_change_title(m_document->title());
|
||||
m_page->client().page_did_change_title(m_active_document->title());
|
||||
}
|
||||
|
||||
if (m_page)
|
||||
m_page->client().page_did_set_document_in_top_level_browsing_context(m_document);
|
||||
m_page->client().page_did_set_document_in_top_level_browsing_context(m_active_document);
|
||||
}
|
||||
|
||||
void BrowsingContext::set_viewport_rect(Gfx::IntRect const& rect)
|
||||
|
@ -94,9 +94,9 @@ void BrowsingContext::set_viewport_rect(Gfx::IntRect const& rect)
|
|||
|
||||
if (m_size != rect.size()) {
|
||||
m_size = rect.size();
|
||||
if (m_document) {
|
||||
m_document->window().dispatch_event(DOM::Event::create(UIEvents::EventNames::resize));
|
||||
m_document->update_layout();
|
||||
if (active_document()) {
|
||||
active_document()->window().dispatch_event(DOM::Event::create(UIEvents::EventNames::resize));
|
||||
active_document()->update_layout();
|
||||
}
|
||||
did_change = true;
|
||||
}
|
||||
|
@ -117,9 +117,9 @@ void BrowsingContext::set_size(Gfx::IntSize const& size)
|
|||
if (m_size == size)
|
||||
return;
|
||||
m_size = size;
|
||||
if (m_document) {
|
||||
m_document->window().dispatch_event(DOM::Event::create(UIEvents::EventNames::resize));
|
||||
m_document->update_layout();
|
||||
if (active_document()) {
|
||||
active_document()->window().dispatch_event(DOM::Event::create(UIEvents::EventNames::resize));
|
||||
active_document()->update_layout();
|
||||
}
|
||||
|
||||
for (auto* client : m_viewport_clients)
|
||||
|
@ -153,12 +153,12 @@ void BrowsingContext::set_needs_display(Gfx::IntRect const& rect)
|
|||
|
||||
void BrowsingContext::scroll_to_anchor(String const& fragment)
|
||||
{
|
||||
if (!document())
|
||||
if (!active_document())
|
||||
return;
|
||||
|
||||
auto element = document()->get_element_by_id(fragment);
|
||||
auto element = active_document()->get_element_by_id(fragment);
|
||||
if (!element) {
|
||||
auto candidates = document()->get_elements_by_name(fragment);
|
||||
auto candidates = active_document()->get_elements_by_name(fragment);
|
||||
for (auto& candidate : candidates->collect_matching_elements()) {
|
||||
if (is<HTML::HTMLAnchorElement>(*candidate)) {
|
||||
element = verify_cast<HTML::HTMLAnchorElement>(*candidate);
|
||||
|
@ -168,7 +168,7 @@ void BrowsingContext::scroll_to_anchor(String const& fragment)
|
|||
}
|
||||
|
||||
// FIXME: This is overly aggressive and should be something more like a "update_layout_if_needed()"
|
||||
document()->force_layout();
|
||||
active_document()->force_layout();
|
||||
|
||||
if (!element || !element->layout_node())
|
||||
return;
|
||||
|
@ -227,9 +227,9 @@ void BrowsingContext::set_cursor_position(DOM::Position position)
|
|||
String BrowsingContext::selected_text() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
if (!m_document)
|
||||
if (!active_document())
|
||||
return {};
|
||||
auto* layout_root = m_document->layout_node();
|
||||
auto* layout_root = active_document()->layout_node();
|
||||
if (!layout_root)
|
||||
return {};
|
||||
if (!layout_root->selection().is_valid())
|
||||
|
@ -273,9 +273,9 @@ String BrowsingContext::selected_text() const
|
|||
|
||||
void BrowsingContext::select_all()
|
||||
{
|
||||
if (!m_document)
|
||||
if (!active_document())
|
||||
return;
|
||||
auto* layout_root = m_document->layout_node();
|
||||
auto* layout_root = active_document()->layout_node();
|
||||
if (!layout_root)
|
||||
return;
|
||||
|
||||
|
|
|
@ -39,10 +39,10 @@ public:
|
|||
bool is_top_level() const { return this == &top_level_browsing_context(); }
|
||||
bool is_focused_context() const;
|
||||
|
||||
DOM::Document const* document() const { return m_document; }
|
||||
DOM::Document* document() { return m_document; }
|
||||
DOM::Document const* active_document() const { return m_active_document; }
|
||||
DOM::Document* active_document() { return m_active_document; }
|
||||
|
||||
void set_document(DOM::Document*);
|
||||
void set_active_document(DOM::Document*);
|
||||
|
||||
Page* page() { return m_page; }
|
||||
Page const* page() const { return m_page; }
|
||||
|
@ -111,7 +111,7 @@ private:
|
|||
EventHandler m_event_handler;
|
||||
|
||||
WeakPtr<HTML::BrowsingContextContainer> m_container;
|
||||
RefPtr<DOM::Document> m_document;
|
||||
RefPtr<DOM::Document> m_active_document;
|
||||
Gfx::IntSize m_size;
|
||||
Gfx::IntPoint m_viewport_scroll_offset;
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void EditEventHandler::handle_delete(DOM::Range& range)
|
|||
// FIXME: When nodes are removed from the DOM, the associated layout nodes become stale and still
|
||||
// remain in the layout tree. This has to be fixed, this just causes everything to be recomputed
|
||||
// which really hurts performance.
|
||||
m_frame.document()->force_layout();
|
||||
m_frame.active_document()->force_layout();
|
||||
|
||||
m_frame.did_edit({});
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ void EditEventHandler::handle_insert(DOM::Position position, u32 code_point)
|
|||
// FIXME: When nodes are removed from the DOM, the associated layout nodes become stale and still
|
||||
// remain in the layout tree. This has to be fixed, this just causes everything to be recomputed
|
||||
// which really hurts performance.
|
||||
m_frame.document()->force_layout();
|
||||
m_frame.active_document()->force_layout();
|
||||
|
||||
m_frame.did_edit({});
|
||||
}
|
||||
|
|
|
@ -99,16 +99,16 @@ EventHandler::~EventHandler()
|
|||
|
||||
const Layout::InitialContainingBlock* EventHandler::layout_root() const
|
||||
{
|
||||
if (!m_frame.document())
|
||||
if (!m_frame.active_document())
|
||||
return nullptr;
|
||||
return m_frame.document()->layout_node();
|
||||
return m_frame.active_document()->layout_node();
|
||||
}
|
||||
|
||||
Layout::InitialContainingBlock* EventHandler::layout_root()
|
||||
{
|
||||
if (!m_frame.document())
|
||||
if (!m_frame.active_document())
|
||||
return nullptr;
|
||||
return m_frame.document()->layout_node();
|
||||
return m_frame.active_document()->layout_node();
|
||||
}
|
||||
|
||||
bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int buttons, unsigned int modifiers, int wheel_delta)
|
||||
|
@ -182,7 +182,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
|
|||
return true;
|
||||
}
|
||||
|
||||
NonnullRefPtr document = *m_frame.document();
|
||||
NonnullRefPtr document = *m_frame.active_document();
|
||||
RefPtr<DOM::Node> node;
|
||||
|
||||
{
|
||||
|
@ -279,7 +279,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
|||
return true;
|
||||
}
|
||||
|
||||
auto& document = *m_frame.document();
|
||||
auto& document = *m_frame.active_document();
|
||||
|
||||
bool hovered_node_changed = false;
|
||||
bool is_hovering_link = false;
|
||||
|
@ -356,13 +356,13 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
|||
|
||||
bool EventHandler::focus_next_element()
|
||||
{
|
||||
if (!m_frame.document())
|
||||
if (!m_frame.active_document())
|
||||
return false;
|
||||
auto* element = m_frame.document()->focused_element();
|
||||
auto* element = m_frame.active_document()->focused_element();
|
||||
if (!element) {
|
||||
element = m_frame.document()->first_child_of_type<DOM::Element>();
|
||||
element = m_frame.active_document()->first_child_of_type<DOM::Element>();
|
||||
if (element && element->is_focusable()) {
|
||||
m_frame.document()->set_focused_element(element);
|
||||
m_frame.active_document()->set_focused_element(element);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ bool EventHandler::focus_next_element()
|
|||
for (element = element->next_element_in_pre_order(); element && !element->is_focusable(); element = element->next_element_in_pre_order())
|
||||
;
|
||||
|
||||
m_frame.document()->set_focused_element(element);
|
||||
m_frame.active_document()->set_focused_element(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
|
|||
if (layout_root()->selection().is_valid()) {
|
||||
auto range = layout_root()->selection().to_dom_range()->normalized();
|
||||
if (range->start_container()->is_editable()) {
|
||||
m_frame.document()->layout_node()->set_selection({});
|
||||
m_frame.active_document()->layout_node()->set_selection({});
|
||||
|
||||
// FIXME: This doesn't work for some reason?
|
||||
m_frame.set_cursor_position({ *range->start_container(), range->start_offset() });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue