1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 15:55:07 +00:00

LibWeb: Rename "frame" to "browsing_context" in various places

We renamed the Frame class to BrowsingContext a while back, but forgot
to update some variable names.
This commit is contained in:
Andreas Kling 2022-02-06 14:41:29 +01:00
parent 5dd4b3eaaa
commit 41fe02e012
7 changed files with 82 additions and 82 deletions

View file

@ -223,27 +223,27 @@ void Window::cancel_animation_frame(i32 id)
void Window::did_set_location_href(Badge<Bindings::LocationObject>, AK::URL const& new_href) void Window::did_set_location_href(Badge<Bindings::LocationObject>, AK::URL const& new_href)
{ {
auto* frame = associated_document().browsing_context(); auto* browsing_context = associated_document().browsing_context();
if (!frame) if (!browsing_context)
return; return;
frame->loader().load(new_href, FrameLoader::Type::Navigation); browsing_context->loader().load(new_href, FrameLoader::Type::Navigation);
} }
void Window::did_call_location_reload(Badge<Bindings::LocationObject>) void Window::did_call_location_reload(Badge<Bindings::LocationObject>)
{ {
auto* frame = associated_document().browsing_context(); auto* browsing_context = associated_document().browsing_context();
if (!frame) if (!browsing_context)
return; return;
frame->loader().load(associated_document().url(), FrameLoader::Type::Reload); browsing_context->loader().load(associated_document().url(), FrameLoader::Type::Reload);
} }
void Window::did_call_location_replace(Badge<Bindings::LocationObject>, String url) void Window::did_call_location_replace(Badge<Bindings::LocationObject>, String url)
{ {
auto* frame = associated_document().browsing_context(); auto* browsing_context = associated_document().browsing_context();
if (!frame) if (!browsing_context)
return; return;
auto new_url = associated_document().parse_url(url); auto new_url = associated_document().parse_url(url);
frame->loader().load(move(new_url), FrameLoader::Type::Navigation); browsing_context->loader().load(move(new_url), FrameLoader::Type::Navigation);
} }
bool Window::dispatch_event(NonnullRefPtr<Event> event) bool Window::dispatch_event(NonnullRefPtr<Event> event)

View file

@ -27,10 +27,10 @@ void BrowsingContextContainer::inserted()
HTMLElement::inserted(); HTMLElement::inserted();
if (!is_connected()) if (!is_connected())
return; return;
if (auto* frame = document().browsing_context()) { if (auto* browsing_context = document().browsing_context()) {
VERIFY(frame->page()); VERIFY(browsing_context->page());
m_nested_browsing_context = BrowsingContext::create_nested(*frame->page(), *this); m_nested_browsing_context = BrowsingContext::create_nested(*browsing_context->page(), *this);
m_nested_browsing_context->set_frame_nesting_levels(frame->frame_nesting_levels()); m_nested_browsing_context->set_frame_nesting_levels(browsing_context->frame_nesting_levels());
m_nested_browsing_context->register_frame_nesting(document().url()); m_nested_browsing_context->register_frame_nesting(document().url());
} }
} }

View file

@ -70,7 +70,7 @@ void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& positio
// NOTE: Handling the click may run arbitrary JS, which could disappear this node. // NOTE: Handling the click may run arbitrary JS, which could disappear this node.
NonnullRefPtr protected_this = *this; NonnullRefPtr protected_this = *this;
NonnullRefPtr protected_frame = browsing_context(); NonnullRefPtr protected_browsing_context = browsing_context();
bool is_inside_node_or_label = enclosing_int_rect(absolute_rect()).contains(position); bool is_inside_node_or_label = enclosing_int_rect(absolute_rect()).contains(position);
if (!is_inside_node_or_label) if (!is_inside_node_or_label)
@ -82,7 +82,7 @@ void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& positio
m_being_pressed = false; m_being_pressed = false;
m_tracking_mouse = false; m_tracking_mouse = false;
protected_frame->event_handler().set_mouse_event_tracking_layout_node(nullptr); protected_browsing_context->event_handler().set_mouse_event_tracking_layout_node(nullptr);
} }
void ButtonBox::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned) void ButtonBox::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned)
@ -111,7 +111,7 @@ void ButtonBox::handle_associated_label_mouseup(Badge<Label>)
{ {
// NOTE: Handling the click may run arbitrary JS, which could disappear this node. // NOTE: Handling the click may run arbitrary JS, which could disappear this node.
NonnullRefPtr protected_this = *this; NonnullRefPtr protected_this = *this;
NonnullRefPtr protected_frame = browsing_context(); NonnullRefPtr protected_browsing_context = browsing_context();
dom_node().did_click_button({}); dom_node().did_click_button({});
m_being_pressed = false; m_being_pressed = false;

View file

@ -33,7 +33,7 @@ void EditEventHandler::handle_delete_character_after(const DOM::Position& cursor
builder.append(text.substring_view(cursor_position.offset() + code_point_length)); builder.append(text.substring_view(cursor_position.offset() + code_point_length));
node.set_data(builder.to_string()); node.set_data(builder.to_string());
m_frame.did_edit({}); m_browsing_context.did_edit({});
} }
// This method is quite convoluted but this is necessary to make editing feel intuitive. // This method is quite convoluted but this is necessary to make editing feel intuitive.
@ -92,9 +92,9 @@ void EditEventHandler::handle_delete(DOM::Range& range)
// FIXME: When nodes are removed from the DOM, the associated layout nodes become stale and still // 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 // remain in the layout tree. This has to be fixed, this just causes everything to be recomputed
// which really hurts performance. // which really hurts performance.
m_frame.active_document()->force_layout(); m_browsing_context.active_document()->force_layout();
m_frame.did_edit({}); m_browsing_context.did_edit({});
} }
void EditEventHandler::handle_insert(DOM::Position position, u32 code_point) void EditEventHandler::handle_insert(DOM::Position position, u32 code_point)
@ -114,8 +114,8 @@ 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 // 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 // remain in the layout tree. This has to be fixed, this just causes everything to be recomputed
// which really hurts performance. // which really hurts performance.
m_frame.active_document()->force_layout(); m_browsing_context.active_document()->force_layout();
m_frame.did_edit({}); m_browsing_context.did_edit({});
} }
} }

View file

@ -13,8 +13,8 @@ namespace Web {
class EditEventHandler { class EditEventHandler {
public: public:
explicit EditEventHandler(HTML::BrowsingContext& frame) explicit EditEventHandler(HTML::BrowsingContext& browsing_context)
: m_frame(frame) : m_browsing_context(browsing_context)
{ {
} }
@ -25,7 +25,7 @@ public:
virtual void handle_insert(DOM::Position, u32 code_point); virtual void handle_insert(DOM::Position, u32 code_point);
private: private:
HTML::BrowsingContext& m_frame; HTML::BrowsingContext& m_browsing_context;
}; };
} }

View file

@ -88,9 +88,9 @@ static Gfx::IntPoint compute_mouse_event_offset(const Gfx::IntPoint& position, c
}; };
} }
EventHandler::EventHandler(Badge<HTML::BrowsingContext>, HTML::BrowsingContext& frame) EventHandler::EventHandler(Badge<HTML::BrowsingContext>, HTML::BrowsingContext& browsing_context)
: m_frame(frame) : m_browsing_context(browsing_context)
, m_edit_event_handler(make<EditEventHandler>(frame)) , m_edit_event_handler(make<EditEventHandler>(browsing_context))
{ {
} }
@ -100,16 +100,16 @@ EventHandler::~EventHandler()
const Layout::InitialContainingBlock* EventHandler::layout_root() const const Layout::InitialContainingBlock* EventHandler::layout_root() const
{ {
if (!m_frame.active_document()) if (!m_browsing_context.active_document())
return nullptr; return nullptr;
return m_frame.active_document()->layout_node(); return m_browsing_context.active_document()->layout_node();
} }
Layout::InitialContainingBlock* EventHandler::layout_root() Layout::InitialContainingBlock* EventHandler::layout_root()
{ {
if (!m_frame.active_document()) if (!m_browsing_context.active_document())
return nullptr; return nullptr;
return m_frame.active_document()->layout_node(); return m_browsing_context.active_document()->layout_node();
} }
bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int buttons, unsigned int modifiers, int wheel_delta_x, int wheel_delta_y) bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int buttons, unsigned int modifiers, int wheel_delta_x, int wheel_delta_y)
@ -120,7 +120,7 @@ bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int
if (modifiers & KeyModifier::Mod_Shift) if (modifiers & KeyModifier::Mod_Shift)
swap(wheel_delta_x, wheel_delta_y); swap(wheel_delta_x, wheel_delta_y);
// FIXME: Support wheel events in subframes. // FIXME: Support wheel events in nested browsing contexts.
auto result = layout_root()->hit_test(position, Layout::HitTestType::Exact); auto result = layout_root()->hit_test(position, Layout::HitTestType::Exact);
if (result.layout_node) { if (result.layout_node) {
@ -128,7 +128,7 @@ bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int
return true; return true;
} }
if (auto* page = m_frame.page()) { if (auto* page = m_browsing_context.page()) {
page->client().page_did_request_scroll(wheel_delta_x * 20, wheel_delta_y * 20); page->client().page_did_request_scroll(wheel_delta_x * 20, wheel_delta_y * 20);
return true; return true;
} }
@ -162,8 +162,8 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button
if (result.layout_node && result.layout_node->dom_node()) { if (result.layout_node && result.layout_node->dom_node()) {
RefPtr<DOM::Node> node = result.layout_node->dom_node(); RefPtr<DOM::Node> node = result.layout_node->dom_node();
if (is<HTML::HTMLIFrameElement>(*node)) { if (is<HTML::HTMLIFrameElement>(*node)) {
if (auto* subframe = verify_cast<HTML::HTMLIFrameElement>(*node).nested_browsing_context()) if (auto* nested_browsing_context = static_cast<HTML::HTMLIFrameElement&>(*node).nested_browsing_context())
return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); return nested_browsing_context->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
return false; return false;
} }
auto offset = compute_mouse_event_offset(position, *result.layout_node); auto offset = compute_mouse_event_offset(position, *result.layout_node);
@ -186,7 +186,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
return true; return true;
} }
NonnullRefPtr document = *m_frame.active_document(); NonnullRefPtr document = *m_browsing_context.active_document();
RefPtr<DOM::Node> node; RefPtr<DOM::Node> node;
{ {
@ -211,13 +211,13 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
return false; return false;
if (is<HTML::HTMLIFrameElement>(*node)) { if (is<HTML::HTMLIFrameElement>(*node)) {
if (auto* subframe = verify_cast<HTML::HTMLIFrameElement>(*node).nested_browsing_context()) if (auto* nested_browsing_context = static_cast<HTML::HTMLIFrameElement&>(*node).nested_browsing_context())
return subframe->event_handler().handle_mousedown(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); return nested_browsing_context->event_handler().handle_mousedown(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
return false; return false;
} }
if (auto* page = m_frame.page()) if (auto* page = m_browsing_context.page())
page->set_focused_browsing_context({}, m_frame); page->set_focused_browsing_context({}, m_browsing_context);
auto offset = compute_mouse_event_offset(position, *result.layout_node); auto offset = compute_mouse_event_offset(position, *result.layout_node);
node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::mousedown, offset.x(), offset.y(), position.x(), position.y())); node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::mousedown, offset.x(), offset.y(), position.x(), position.y()));
@ -230,8 +230,8 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
if (button == GUI::MouseButton::Secondary && is<HTML::HTMLImageElement>(*node)) { if (button == GUI::MouseButton::Secondary && is<HTML::HTMLImageElement>(*node)) {
auto& image_element = verify_cast<HTML::HTMLImageElement>(*node); auto& image_element = verify_cast<HTML::HTMLImageElement>(*node);
auto image_url = image_element.document().parse_url(image_element.src()); auto image_url = image_element.document().parse_url(image_element.src());
if (auto* page = m_frame.page()) if (auto* page = m_browsing_context.page())
page->client().page_did_request_image_context_menu(m_frame.to_top_level_position(position), image_url, "", modifiers, image_element.bitmap()); page->client().page_did_request_image_context_menu(m_browsing_context.to_top_level_position(position), image_url, "", modifiers, image_element.bitmap());
return true; return true;
} }
@ -244,35 +244,35 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
document->run_javascript(href.substring_view(11, href.length() - 11)); document->run_javascript(href.substring_view(11, href.length() - 11));
} else if (href.starts_with('#')) { } else if (href.starts_with('#')) {
auto anchor = href.substring_view(1, href.length() - 1); auto anchor = href.substring_view(1, href.length() - 1);
m_frame.scroll_to_anchor(anchor); m_browsing_context.scroll_to_anchor(anchor);
} else { } else {
document->set_active_element(link); document->set_active_element(link);
if (m_frame.is_top_level()) { if (m_browsing_context.is_top_level()) {
if (auto* page = m_frame.page()) if (auto* page = m_browsing_context.page())
page->client().page_did_click_link(url, link->target(), modifiers); page->client().page_did_click_link(url, link->target(), modifiers);
} else { } else {
// FIXME: Handle different targets! // FIXME: Handle different targets!
m_frame.loader().load(url, FrameLoader::Type::Navigation); m_browsing_context.loader().load(url, FrameLoader::Type::Navigation);
} }
} }
} else if (button == GUI::MouseButton::Secondary) { } else if (button == GUI::MouseButton::Secondary) {
if (auto* page = m_frame.page()) if (auto* page = m_browsing_context.page())
page->client().page_did_request_link_context_menu(m_frame.to_top_level_position(position), url, link->target(), modifiers); page->client().page_did_request_link_context_menu(m_browsing_context.to_top_level_position(position), url, link->target(), modifiers);
} else if (button == GUI::MouseButton::Middle) { } else if (button == GUI::MouseButton::Middle) {
if (auto* page = m_frame.page()) if (auto* page = m_browsing_context.page())
page->client().page_did_middle_click_link(url, link->target(), modifiers); page->client().page_did_middle_click_link(url, link->target(), modifiers);
} }
} else { } else {
if (button == GUI::MouseButton::Primary) { if (button == GUI::MouseButton::Primary) {
auto result = layout_root()->hit_test(position, Layout::HitTestType::TextCursor); auto result = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
if (result.layout_node && result.layout_node->dom_node()) { if (result.layout_node && result.layout_node->dom_node()) {
m_frame.set_cursor_position(DOM::Position(*result.layout_node->dom_node(), result.index_in_node)); m_browsing_context.set_cursor_position(DOM::Position(*result.layout_node->dom_node(), result.index_in_node));
layout_root()->set_selection({ { result.layout_node, result.index_in_node }, {} }); layout_root()->set_selection({ { result.layout_node, result.index_in_node }, {} });
m_in_mouse_selection = true; m_in_mouse_selection = true;
} }
} else if (button == GUI::MouseButton::Secondary) { } else if (button == GUI::MouseButton::Secondary) {
if (auto* page = m_frame.page()) if (auto* page = m_browsing_context.page())
page->client().page_did_request_context_menu(m_frame.to_top_level_position(position)); page->client().page_did_request_context_menu(m_browsing_context.to_top_level_position(position));
} }
} }
return true; return true;
@ -288,7 +288,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
return true; return true;
} }
auto& document = *m_frame.active_document(); auto& document = *m_browsing_context.active_document();
bool hovered_node_changed = false; bool hovered_node_changed = false;
bool is_hovering_link = false; bool is_hovering_link = false;
@ -301,7 +301,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
document.set_hovered_node(result.layout_node->dom_node()); document.set_hovered_node(result.layout_node->dom_node());
result.layout_node->handle_mousemove({}, position, buttons, modifiers); result.layout_node->handle_mousemove({}, position, buttons, modifiers);
// FIXME: It feels a bit aggressive to always update the cursor like this. // FIXME: It feels a bit aggressive to always update the cursor like this.
if (auto* page = m_frame.page()) if (auto* page = m_browsing_context.page())
page->client().page_did_request_cursor_change(Gfx::StandardCursor::None); page->client().page_did_request_cursor_change(Gfx::StandardCursor::None);
return true; return true;
} }
@ -309,8 +309,8 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
RefPtr<DOM::Node> node = result.layout_node->dom_node(); RefPtr<DOM::Node> node = result.layout_node->dom_node();
if (node && is<HTML::HTMLIFrameElement>(*node)) { if (node && is<HTML::HTMLIFrameElement>(*node)) {
if (auto* subframe = verify_cast<HTML::HTMLIFrameElement>(*node).nested_browsing_context()) if (auto* nested_browsing_context = static_cast<HTML::HTMLIFrameElement&>(*node).nested_browsing_context())
return subframe->event_handler().handle_mousemove(position.translated(compute_mouse_event_offset({}, *result.layout_node)), buttons, modifiers); return nested_browsing_context->event_handler().handle_mousemove(position.translated(compute_mouse_event_offset({}, *result.layout_node)), buttons, modifiers);
return false; return false;
} }
@ -342,21 +342,21 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
if (m_in_mouse_selection) { if (m_in_mouse_selection) {
auto hit = layout_root()->hit_test(position, Layout::HitTestType::TextCursor); auto hit = layout_root()->hit_test(position, Layout::HitTestType::TextCursor);
if (hit.layout_node && hit.layout_node->dom_node()) { if (hit.layout_node && hit.layout_node->dom_node()) {
m_frame.set_cursor_position(DOM::Position(*hit.layout_node->dom_node(), result.index_in_node)); m_browsing_context.set_cursor_position(DOM::Position(*hit.layout_node->dom_node(), result.index_in_node));
layout_root()->set_selection_end({ hit.layout_node, hit.index_in_node }); layout_root()->set_selection_end({ hit.layout_node, hit.index_in_node });
} }
if (auto* page = m_frame.page()) if (auto* page = m_browsing_context.page())
page->client().page_did_change_selection(); page->client().page_did_change_selection();
} }
} }
if (auto* page = m_frame.page()) { if (auto* page = m_browsing_context.page()) {
page->client().page_did_request_cursor_change(hovered_node_cursor); page->client().page_did_request_cursor_change(hovered_node_cursor);
if (hovered_node_changed) { if (hovered_node_changed) {
RefPtr<HTML::HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr; RefPtr<HTML::HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr;
if (hovered_html_element && !hovered_html_element->title().is_null()) { if (hovered_html_element && !hovered_html_element->title().is_null()) {
page->client().page_did_enter_tooltip_area(m_frame.to_top_level_position(position), hovered_html_element->title()); page->client().page_did_enter_tooltip_area(m_browsing_context.to_top_level_position(position), hovered_html_element->title());
} else { } else {
page->client().page_did_leave_tooltip_area(); page->client().page_did_leave_tooltip_area();
} }
@ -371,13 +371,13 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
bool EventHandler::focus_next_element() bool EventHandler::focus_next_element()
{ {
if (!m_frame.active_document()) if (!m_browsing_context.active_document())
return false; return false;
auto* element = m_frame.active_document()->focused_element(); auto* element = m_browsing_context.active_document()->focused_element();
if (!element) { if (!element) {
element = m_frame.active_document()->first_child_of_type<DOM::Element>(); element = m_browsing_context.active_document()->first_child_of_type<DOM::Element>();
if (element && element->is_focusable()) { if (element && element->is_focusable()) {
m_frame.active_document()->set_focused_element(element); m_browsing_context.active_document()->set_focused_element(element);
return true; return true;
} }
} }
@ -385,7 +385,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()) for (element = element->next_element_in_pre_order(); element && !element->is_focusable(); element = element->next_element_in_pre_order())
; ;
m_frame.active_document()->set_focused_element(element); m_browsing_context.active_document()->set_focused_element(element);
return element; return element;
} }
@ -403,10 +403,10 @@ constexpr bool should_ignore_keydown_event(u32 code_point)
bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_point) bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_point)
{ {
if (!m_frame.active_document()) if (!m_browsing_context.active_document())
return false; return false;
NonnullRefPtr<DOM::Document> document = *m_frame.active_document(); NonnullRefPtr<DOM::Document> document = *m_browsing_context.active_document();
if (!document->layout_node()) if (!document->layout_node())
return false; return false;
@ -424,7 +424,7 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
layout_root->set_selection({}); layout_root->set_selection({});
// FIXME: This doesn't work for some reason? // FIXME: This doesn't work for some reason?
m_frame.set_cursor_position({ *range->start_container(), range->start_offset() }); m_browsing_context.set_cursor_position({ *range->start_container(), range->start_offset() });
if (key == KeyCode::Key_Backspace || key == KeyCode::Key_Delete) { if (key == KeyCode::Key_Backspace || key == KeyCode::Key_Delete) {
m_edit_event_handler->handle_delete(range); m_edit_event_handler->handle_delete(range);
@ -432,46 +432,46 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
} }
if (!should_ignore_keydown_event(code_point)) { if (!should_ignore_keydown_event(code_point)) {
m_edit_event_handler->handle_delete(range); m_edit_event_handler->handle_delete(range);
m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point); m_edit_event_handler->handle_insert(m_browsing_context.cursor_position(), code_point);
m_frame.increment_cursor_position_offset(); m_browsing_context.increment_cursor_position_offset();
return true; return true;
} }
} }
} }
if (m_frame.cursor_position().is_valid() && m_frame.cursor_position().node()->is_editable()) { if (m_browsing_context.cursor_position().is_valid() && m_browsing_context.cursor_position().node()->is_editable()) {
if (key == KeyCode::Key_Backspace) { if (key == KeyCode::Key_Backspace) {
if (!m_frame.decrement_cursor_position_offset()) { if (!m_browsing_context.decrement_cursor_position_offset()) {
// FIXME: Move to the previous node and delete the last character there. // FIXME: Move to the previous node and delete the last character there.
return true; return true;
} }
m_edit_event_handler->handle_delete_character_after(m_frame.cursor_position()); m_edit_event_handler->handle_delete_character_after(m_browsing_context.cursor_position());
return true; return true;
} }
if (key == KeyCode::Key_Delete) { if (key == KeyCode::Key_Delete) {
if (m_frame.cursor_position().offset_is_at_end_of_node()) { if (m_browsing_context.cursor_position().offset_is_at_end_of_node()) {
// FIXME: Move to the next node and delete the first character there. // FIXME: Move to the next node and delete the first character there.
return true; return true;
} }
m_edit_event_handler->handle_delete_character_after(m_frame.cursor_position()); m_edit_event_handler->handle_delete_character_after(m_browsing_context.cursor_position());
return true; return true;
} }
if (key == KeyCode::Key_Right) { if (key == KeyCode::Key_Right) {
if (!m_frame.increment_cursor_position_offset()) { if (!m_browsing_context.increment_cursor_position_offset()) {
// FIXME: Move to the next node. // FIXME: Move to the next node.
} }
return true; return true;
} }
if (key == KeyCode::Key_Left) { if (key == KeyCode::Key_Left) {
if (!m_frame.decrement_cursor_position_offset()) { if (!m_browsing_context.decrement_cursor_position_offset()) {
// FIXME: Move to the previous node. // FIXME: Move to the previous node.
} }
return true; return true;
} }
if (!should_ignore_keydown_event(code_point)) { if (!should_ignore_keydown_event(code_point)) {
m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point); m_edit_event_handler->handle_insert(m_browsing_context.cursor_position(), code_point);
m_frame.increment_cursor_position_offset(); m_browsing_context.increment_cursor_position_offset();
return true; return true;
} }
@ -484,7 +484,7 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
if (RefPtr<DOM::Element> focused_element = document->focused_element()) if (RefPtr<DOM::Element> focused_element = document->focused_element())
return focused_element->dispatch_event(move(event)); return focused_element->dispatch_event(move(event));
if (RefPtr<HTML::HTMLElement> body = m_frame.active_document()->body()) if (RefPtr<HTML::HTMLElement> body = m_browsing_context.active_document()->body())
return body->dispatch_event(move(event)); return body->dispatch_event(move(event));
return document->root().dispatch_event(move(event)); return document->root().dispatch_event(move(event));
@ -492,7 +492,7 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
bool EventHandler::handle_keyup(KeyCode key, unsigned modifiers, u32 code_point) bool EventHandler::handle_keyup(KeyCode key, unsigned modifiers, u32 code_point)
{ {
RefPtr<DOM::Document> document = m_frame.active_document(); RefPtr<DOM::Document> document = m_browsing_context.active_document();
if (!document) if (!document)
return false; return false;

View file

@ -41,7 +41,7 @@ private:
Layout::InitialContainingBlock* layout_root(); Layout::InitialContainingBlock* layout_root();
const Layout::InitialContainingBlock* layout_root() const; const Layout::InitialContainingBlock* layout_root() const;
HTML::BrowsingContext& m_frame; HTML::BrowsingContext& m_browsing_context;
bool m_in_mouse_selection { false }; bool m_in_mouse_selection { false };