mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
LibWeb: Stub out a basic Selection interface
This patch establishes scaffolding for the Selection API.
This commit is contained in:
parent
6782cf5193
commit
5c9ca5c2dc
11 changed files with 269 additions and 1 deletions
|
@ -740,7 +740,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto interface = IDL::parse_interface(path, data, import_base_path);
|
auto interface = IDL::parse_interface(path, data, import_base_path);
|
||||||
|
|
||||||
if (namespace_.is_one_of("Crypto", "CSS", "DOM", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "NavigationTiming", "RequestIdleCallback", "SVG", "XHR", "URL")) {
|
if (namespace_.is_one_of("Crypto", "CSS", "DOM", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "NavigationTiming", "RequestIdleCallback", "SVG", "Selection", "XHR", "URL")) {
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.append(namespace_);
|
builder.append(namespace_);
|
||||||
builder.append("::");
|
builder.append("::");
|
||||||
|
@ -862,6 +862,10 @@ static bool is_wrappable_type(IDL::Type const& type)
|
||||||
return true;
|
return true;
|
||||||
if (type.name == "Window")
|
if (type.name == "Window")
|
||||||
return true;
|
return true;
|
||||||
|
if (type.name == "Range")
|
||||||
|
return true;
|
||||||
|
if (type.name == "Selection")
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1387,6 +1391,8 @@ static void generate_header(IDL::Interface const& interface)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
# include <LibWeb/Selection/@name@.h>
|
||||||
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
||||||
# include <LibWeb/XHR/@name@.h>
|
# include <LibWeb/XHR/@name@.h>
|
||||||
#elif __has_include(<LibWeb/URL/@name@.h>)
|
#elif __has_include(<LibWeb/URL/@name@.h>)
|
||||||
|
@ -1553,6 +1559,7 @@ using namespace Web::DOM;
|
||||||
using namespace Web::Geometry;
|
using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::Selection;
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
|
@ -2468,6 +2475,8 @@ void generate_constructor_implementation(IDL::Interface const& interface)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
# include <LibWeb/Selection/@name@.h>
|
||||||
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
||||||
# include <LibWeb/XHR/@name@.h>
|
# include <LibWeb/XHR/@name@.h>
|
||||||
#elif __has_include(<LibWeb/URL/@name@.h>)
|
#elif __has_include(<LibWeb/URL/@name@.h>)
|
||||||
|
@ -2480,6 +2489,7 @@ using namespace Web::DOM;
|
||||||
using namespace Web::Geometry;
|
using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::Selection;
|
||||||
using namespace Web::UIEvents;
|
using namespace Web::UIEvents;
|
||||||
using namespace Web::XHR;
|
using namespace Web::XHR;
|
||||||
|
|
||||||
|
@ -2775,6 +2785,8 @@ void generate_prototype_implementation(IDL::Interface const& interface)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
# include <LibWeb/Selection/@name@.h>
|
||||||
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
||||||
# include <LibWeb/XHR/@name@.h>
|
# include <LibWeb/XHR/@name@.h>
|
||||||
#elif __has_include(<LibWeb/URL/@name@.h>)
|
#elif __has_include(<LibWeb/URL/@name@.h>)
|
||||||
|
@ -2803,6 +2815,8 @@ void generate_prototype_implementation(IDL::Interface const& interface)
|
||||||
# include <LibWeb/RequestIdleCallback/@iterator_name@.h>
|
# include <LibWeb/RequestIdleCallback/@iterator_name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@iterator_name@.h>)
|
#elif __has_include(<LibWeb/SVG/@iterator_name@.h>)
|
||||||
# include <LibWeb/SVG/@iterator_name@.h>
|
# include <LibWeb/SVG/@iterator_name@.h>
|
||||||
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
# include <LibWeb/Selection/@name@.h>
|
||||||
#elif __has_include(<LibWeb/XHR/@iterator_name@.h>)
|
#elif __has_include(<LibWeb/XHR/@iterator_name@.h>)
|
||||||
# include <LibWeb/XHR/@iterator_name@.h>
|
# include <LibWeb/XHR/@iterator_name@.h>
|
||||||
#elif __has_include(<LibWeb/URL/@iterator_name@.h>)
|
#elif __has_include(<LibWeb/URL/@iterator_name@.h>)
|
||||||
|
@ -2820,6 +2834,7 @@ using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::NavigationTiming;
|
using namespace Web::NavigationTiming;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::Selection;
|
||||||
using namespace Web::XHR;
|
using namespace Web::XHR;
|
||||||
using namespace Web::URL;
|
using namespace Web::URL;
|
||||||
|
|
||||||
|
@ -3243,6 +3258,8 @@ static void generate_iterator_header(IDL::Interface const& interface)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
# include <LibWeb/Selection/@name@.h>
|
||||||
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
||||||
# include <LibWeb/XHR/@name@.h>
|
# include <LibWeb/XHR/@name@.h>
|
||||||
#elif __has_include(<LibWeb/URL/@name@.h>)
|
#elif __has_include(<LibWeb/URL/@name@.h>)
|
||||||
|
@ -3307,6 +3324,7 @@ using namespace Web::DOM;
|
||||||
using namespace Web::Geometry;
|
using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::Selection;
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
|
@ -3422,6 +3440,8 @@ void generate_iterator_prototype_implementation(IDL::Interface const& interface)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
# include <LibWeb/Selection/@name@.h>
|
||||||
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
#elif __has_include(<LibWeb/XHR/@name@.h>)
|
||||||
# include <LibWeb/XHR/@name@.h>
|
# include <LibWeb/XHR/@name@.h>
|
||||||
#elif __has_include(<LibWeb/URL/@name@.h>)
|
#elif __has_include(<LibWeb/URL/@name@.h>)
|
||||||
|
@ -3435,6 +3455,7 @@ using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::NavigationTiming;
|
using namespace Web::NavigationTiming;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::Selection;
|
||||||
using namespace Web::XHR;
|
using namespace Web::XHR;
|
||||||
using namespace Web::URL;
|
using namespace Web::URL;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <LibWeb/Bindings/PerformanceWrapper.h>
|
#include <LibWeb/Bindings/PerformanceWrapper.h>
|
||||||
#include <LibWeb/Bindings/Replaceable.h>
|
#include <LibWeb/Bindings/Replaceable.h>
|
||||||
#include <LibWeb/Bindings/ScreenWrapper.h>
|
#include <LibWeb/Bindings/ScreenWrapper.h>
|
||||||
|
#include <LibWeb/Bindings/SelectionWrapper.h>
|
||||||
#include <LibWeb/Bindings/WindowObject.h>
|
#include <LibWeb/Bindings/WindowObject.h>
|
||||||
#include <LibWeb/Bindings/WindowObjectHelper.h>
|
#include <LibWeb/Bindings/WindowObjectHelper.h>
|
||||||
#include <LibWeb/Crypto/Crypto.h>
|
#include <LibWeb/Crypto/Crypto.h>
|
||||||
|
@ -89,6 +90,7 @@ void WindowObject::initialize_global_object()
|
||||||
|
|
||||||
define_native_function("getComputedStyle", get_computed_style, 1, attr);
|
define_native_function("getComputedStyle", get_computed_style, 1, attr);
|
||||||
define_native_function("matchMedia", match_media, 1, attr);
|
define_native_function("matchMedia", match_media, 1, attr);
|
||||||
|
define_native_function("getSelection", get_selection, 0, attr);
|
||||||
|
|
||||||
// FIXME: These properties should be [Replaceable] according to the spec, but [Writable+Configurable] is the closest we have.
|
// FIXME: These properties should be [Replaceable] according to the spec, but [Writable+Configurable] is the closest we have.
|
||||||
define_native_accessor("scrollX", scroll_x_getter, {}, attr);
|
define_native_accessor("scrollX", scroll_x_getter, {}, attr);
|
||||||
|
@ -575,6 +577,17 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::get_computed_style)
|
||||||
return wrap(global_object, impl->get_computed_style(static_cast<ElementWrapper*>(object)->impl()));
|
return wrap(global_object, impl->get_computed_style(static_cast<ElementWrapper*>(object)->impl()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS_DEFINE_NATIVE_FUNCTION(WindowObject::get_selection)
|
||||||
|
{
|
||||||
|
auto* impl = impl_from(vm, global_object);
|
||||||
|
if (!impl)
|
||||||
|
return {};
|
||||||
|
auto* selection = impl->get_selection();
|
||||||
|
if (!selection)
|
||||||
|
return JS::js_null();
|
||||||
|
return wrap(global_object, *selection);
|
||||||
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::match_media)
|
JS_DEFINE_NATIVE_FUNCTION(WindowObject::match_media)
|
||||||
{
|
{
|
||||||
auto* impl = impl_from(vm, global_object);
|
auto* impl = impl_from(vm, global_object);
|
||||||
|
|
|
@ -108,6 +108,7 @@ private:
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(get_computed_style);
|
JS_DECLARE_NATIVE_FUNCTION(get_computed_style);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(match_media);
|
JS_DECLARE_NATIVE_FUNCTION(match_media);
|
||||||
|
JS_DECLARE_NATIVE_FUNCTION(get_selection);
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(queue_microtask);
|
JS_DECLARE_NATIVE_FUNCTION(queue_microtask);
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,8 @@
|
||||||
#include <LibWeb/Bindings/ProcessingInstructionPrototype.h>
|
#include <LibWeb/Bindings/ProcessingInstructionPrototype.h>
|
||||||
#include <LibWeb/Bindings/ProgressEventConstructor.h>
|
#include <LibWeb/Bindings/ProgressEventConstructor.h>
|
||||||
#include <LibWeb/Bindings/ProgressEventPrototype.h>
|
#include <LibWeb/Bindings/ProgressEventPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/RangeConstructor.h>
|
||||||
|
#include <LibWeb/Bindings/RangePrototype.h>
|
||||||
#include <LibWeb/Bindings/SVGElementConstructor.h>
|
#include <LibWeb/Bindings/SVGElementConstructor.h>
|
||||||
#include <LibWeb/Bindings/SVGElementPrototype.h>
|
#include <LibWeb/Bindings/SVGElementPrototype.h>
|
||||||
#include <LibWeb/Bindings/SVGGeometryElementConstructor.h>
|
#include <LibWeb/Bindings/SVGGeometryElementConstructor.h>
|
||||||
|
@ -243,6 +245,8 @@
|
||||||
#include <LibWeb/Bindings/SVGSVGElementPrototype.h>
|
#include <LibWeb/Bindings/SVGSVGElementPrototype.h>
|
||||||
#include <LibWeb/Bindings/ScreenConstructor.h>
|
#include <LibWeb/Bindings/ScreenConstructor.h>
|
||||||
#include <LibWeb/Bindings/ScreenPrototype.h>
|
#include <LibWeb/Bindings/ScreenPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/SelectionConstructor.h>
|
||||||
|
#include <LibWeb/Bindings/SelectionPrototype.h>
|
||||||
#include <LibWeb/Bindings/ShadowRootConstructor.h>
|
#include <LibWeb/Bindings/ShadowRootConstructor.h>
|
||||||
#include <LibWeb/Bindings/ShadowRootPrototype.h>
|
#include <LibWeb/Bindings/ShadowRootPrototype.h>
|
||||||
#include <LibWeb/Bindings/StyleSheetConstructor.h>
|
#include <LibWeb/Bindings/StyleSheetConstructor.h>
|
||||||
|
@ -390,7 +394,9 @@
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(PerformanceTiming) \
|
ADD_WINDOW_OBJECT_INTERFACE(PerformanceTiming) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(ProcessingInstruction) \
|
ADD_WINDOW_OBJECT_INTERFACE(ProcessingInstruction) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(ProgressEvent) \
|
ADD_WINDOW_OBJECT_INTERFACE(ProgressEvent) \
|
||||||
|
ADD_WINDOW_OBJECT_INTERFACE(Range) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(Screen) \
|
ADD_WINDOW_OBJECT_INTERFACE(Screen) \
|
||||||
|
ADD_WINDOW_OBJECT_INTERFACE(Selection) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(ShadowRoot) \
|
ADD_WINDOW_OBJECT_INTERFACE(ShadowRoot) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(StyleSheet) \
|
ADD_WINDOW_OBJECT_INTERFACE(StyleSheet) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(StyleSheetList) \
|
ADD_WINDOW_OBJECT_INTERFACE(StyleSheetList) \
|
||||||
|
|
|
@ -253,6 +253,7 @@ set(SOURCES
|
||||||
SVG/SVGSVGElement.cpp
|
SVG/SVGSVGElement.cpp
|
||||||
SVG/TagNames.cpp
|
SVG/TagNames.cpp
|
||||||
SVG/ViewBox.cpp
|
SVG/ViewBox.cpp
|
||||||
|
Selection/Selection.cpp
|
||||||
StylePropertiesModel.cpp
|
StylePropertiesModel.cpp
|
||||||
UIEvents/EventNames.cpp
|
UIEvents/EventNames.cpp
|
||||||
UIEvents/KeyboardEvent.cpp
|
UIEvents/KeyboardEvent.cpp
|
||||||
|
@ -476,6 +477,7 @@ libweb_js_wrapper(SVG/SVGGeometryElement)
|
||||||
libweb_js_wrapper(SVG/SVGGraphicsElement)
|
libweb_js_wrapper(SVG/SVGGraphicsElement)
|
||||||
libweb_js_wrapper(SVG/SVGPathElement)
|
libweb_js_wrapper(SVG/SVGPathElement)
|
||||||
libweb_js_wrapper(SVG/SVGSVGElement)
|
libweb_js_wrapper(SVG/SVGSVGElement)
|
||||||
|
libweb_js_wrapper(Selection/Selection)
|
||||||
libweb_js_wrapper(UIEvents/KeyboardEvent)
|
libweb_js_wrapper(UIEvents/KeyboardEvent)
|
||||||
libweb_js_wrapper(UIEvents/MouseEvent)
|
libweb_js_wrapper(UIEvents/MouseEvent)
|
||||||
libweb_js_wrapper(UIEvents/UIEvent)
|
libweb_js_wrapper(UIEvents/UIEvent)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||||
#include <LibWeb/Page/BrowsingContext.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/Page/Page.h>
|
#include <LibWeb/Page/Page.h>
|
||||||
|
#include <LibWeb/Selection/Selection.h>
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
|
||||||
|
@ -404,4 +405,11 @@ int Window::screen_y() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/selection-api/#dom-window-getselection
|
||||||
|
Selection::Selection* Window::get_selection()
|
||||||
|
{
|
||||||
|
// FIXME: Implement.
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,8 @@ public:
|
||||||
int screen_x() const;
|
int screen_x() const;
|
||||||
int screen_y() const;
|
int screen_y() const;
|
||||||
|
|
||||||
|
Selection::Selection* get_selection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Window(Document&);
|
explicit Window(Document&);
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,10 @@ class SVGPathElement;
|
||||||
class SVGSVGElement;
|
class SVGSVGElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::Selection {
|
||||||
|
class Selection;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
enum class LayoutMode;
|
enum class LayoutMode;
|
||||||
enum class PaintPhase;
|
enum class PaintPhase;
|
||||||
|
@ -400,6 +404,7 @@ class SVGGeometryElementWrapper;
|
||||||
class SVGGraphicsElementWrapper;
|
class SVGGraphicsElementWrapper;
|
||||||
class SVGPathElementWrapper;
|
class SVGPathElementWrapper;
|
||||||
class SVGSVGElementWrapper;
|
class SVGSVGElementWrapper;
|
||||||
|
class SelectionWrapper;
|
||||||
class StyleSheetWrapper;
|
class StyleSheetWrapper;
|
||||||
class StyleSheetListWrapper;
|
class StyleSheetListWrapper;
|
||||||
class TextWrapper;
|
class TextWrapper;
|
||||||
|
|
135
Userland/Libraries/LibWeb/Selection/Selection.cpp
Normal file
135
Userland/Libraries/LibWeb/Selection/Selection.cpp
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Selection/Selection.h>
|
||||||
|
|
||||||
|
namespace Web::Selection {
|
||||||
|
|
||||||
|
NonnullRefPtr<Selection> Selection::create()
|
||||||
|
{
|
||||||
|
return adopt_ref(*new Selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
DOM::Node* Selection::anchor_node()
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Selection::anchor_offset()
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
DOM::Node* Selection::focus_node()
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Selection::focus_offset() const
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Selection::is_collapsed() const
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Selection::range_count() const
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
String Selection::type() const
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
NonnullRefPtr<DOM::Range> Selection::get_range_at(unsigned index)
|
||||||
|
{
|
||||||
|
(void)index;
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::add_range(DOM::Range&)
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::remove_range(DOM::Range&)
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::remove_all_ranges()
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::empty()
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::collapse(DOM::Node*, unsigned offset)
|
||||||
|
{
|
||||||
|
(void)offset;
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::set_position(DOM::Node*, unsigned offset)
|
||||||
|
{
|
||||||
|
(void)offset;
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::collapse_to_start()
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::collapse_to_end()
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::extend(DOM::Node&, unsigned offset)
|
||||||
|
{
|
||||||
|
(void)offset;
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::set_base_and_extent(DOM::Node& anchor_node, unsigned anchor_offset, DOM::Node& focus_node, unsigned focus_offset)
|
||||||
|
{
|
||||||
|
(void)anchor_node;
|
||||||
|
(void)anchor_offset;
|
||||||
|
(void)focus_node;
|
||||||
|
(void)focus_offset;
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::select_all_children(DOM::Node&)
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Selection::delete_from_document()
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Selection::contains_node(DOM::Node&, bool allow_partial_containment) const
|
||||||
|
{
|
||||||
|
(void)allow_partial_containment;
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
String Selection::to_string() const
|
||||||
|
{
|
||||||
|
TODO();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
48
Userland/Libraries/LibWeb/Selection/Selection.h
Normal file
48
Userland/Libraries/LibWeb/Selection/Selection.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/NonnullRefPtr.h>
|
||||||
|
#include <AK/RefCounted.h>
|
||||||
|
#include <LibWeb/Bindings/Wrappable.h>
|
||||||
|
|
||||||
|
namespace Web::Selection {
|
||||||
|
|
||||||
|
class Selection
|
||||||
|
: public RefCounted<Selection>
|
||||||
|
, public Bindings::Wrappable {
|
||||||
|
public:
|
||||||
|
using WrapperType = Bindings::SelectionWrapper;
|
||||||
|
|
||||||
|
static NonnullRefPtr<Selection> create();
|
||||||
|
|
||||||
|
DOM::Node* anchor_node();
|
||||||
|
unsigned anchor_offset();
|
||||||
|
DOM::Node* focus_node();
|
||||||
|
unsigned focus_offset() const;
|
||||||
|
bool is_collapsed() const;
|
||||||
|
unsigned range_count() const;
|
||||||
|
String type() const;
|
||||||
|
NonnullRefPtr<DOM::Range> get_range_at(unsigned index);
|
||||||
|
void add_range(DOM::Range&);
|
||||||
|
void remove_range(DOM::Range&);
|
||||||
|
void remove_all_ranges();
|
||||||
|
void empty();
|
||||||
|
void collapse(DOM::Node*, unsigned offset);
|
||||||
|
void set_position(DOM::Node*, unsigned offset);
|
||||||
|
void collapse_to_start();
|
||||||
|
void collapse_to_end();
|
||||||
|
void extend(DOM::Node&, unsigned offset);
|
||||||
|
void set_base_and_extent(DOM::Node& anchor_node, unsigned anchor_offset, DOM::Node& focus_node, unsigned focus_offset);
|
||||||
|
void select_all_children(DOM::Node&);
|
||||||
|
void delete_from_document();
|
||||||
|
bool contains_node(DOM::Node&, bool allow_partial_containment) const;
|
||||||
|
|
||||||
|
String to_string() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
27
Userland/Libraries/LibWeb/Selection/Selection.idl
Normal file
27
Userland/Libraries/LibWeb/Selection/Selection.idl
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
[Exposed=Window]
|
||||||
|
interface Selection {
|
||||||
|
|
||||||
|
readonly attribute Node? anchorNode;
|
||||||
|
readonly attribute unsigned long anchorOffset;
|
||||||
|
readonly attribute Node? focusNode;
|
||||||
|
readonly attribute unsigned long focusOffset;
|
||||||
|
readonly attribute boolean isCollapsed;
|
||||||
|
readonly attribute unsigned long rangeCount;
|
||||||
|
readonly attribute DOMString type;
|
||||||
|
Range getRangeAt(unsigned long index);
|
||||||
|
undefined addRange(Range range);
|
||||||
|
undefined removeRange(Range range);
|
||||||
|
undefined removeAllRanges();
|
||||||
|
undefined empty();
|
||||||
|
undefined collapse(Node? node, optional unsigned long offset = 0);
|
||||||
|
undefined setPosition(Node? node, optional unsigned long offset = 0);
|
||||||
|
undefined collapseToStart();
|
||||||
|
undefined collapseToEnd();
|
||||||
|
undefined extend(Node node, optional unsigned long offset = 0);
|
||||||
|
undefined setBaseAndExtent(Node anchorNode, unsigned long anchorOffset, Node focusNode, unsigned long focusOffset);
|
||||||
|
undefined selectAllChildren(Node node);
|
||||||
|
[CEReactions] undefined deleteFromDocument();
|
||||||
|
boolean containsNode(Node node, optional boolean allowPartialContainment = false);
|
||||||
|
stringifier;
|
||||||
|
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue