mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:18:12 +00:00
LibWeb: Make Window.getSelection() forward to Document.getSelection()
(And have document create the Selection object on demand.)
This commit is contained in:
parent
b945d164e2
commit
a2348ebcc0
4 changed files with 24 additions and 10 deletions
|
@ -67,6 +67,7 @@
|
|||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Platform/Timer.h>
|
||||
#include <LibWeb/SVG/TagNames.h>
|
||||
#include <LibWeb/Selection/Selection.h>
|
||||
#include <LibWeb/UIEvents/EventNames.h>
|
||||
#include <LibWeb/UIEvents/FocusEvent.h>
|
||||
#include <LibWeb/UIEvents/KeyboardEvent.h>
|
||||
|
@ -335,6 +336,7 @@ void Document::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_forms);
|
||||
visitor.visit(m_scripts);
|
||||
visitor.visit(m_all);
|
||||
visitor.visit(m_selection);
|
||||
|
||||
for (auto& script : m_scripts_to_execute_when_parsing_has_finished)
|
||||
visitor.visit(script.ptr());
|
||||
|
@ -350,6 +352,20 @@ void Document::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(target.ptr());
|
||||
}
|
||||
|
||||
// https://w3c.github.io/selection-api/#dom-document-getselection
|
||||
JS::GCPtr<Selection::Selection> Document::get_selection()
|
||||
{
|
||||
// The method must return the selection associated with this if this has an associated browsing context,
|
||||
// and it must return null otherwise.
|
||||
if (!browsing_context()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!m_selection) {
|
||||
m_selection = Selection::Selection::create(realm());
|
||||
}
|
||||
return m_selection;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-write
|
||||
WebIDL::ExceptionOr<void> Document::write(Vector<String> const& strings)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue