mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 01:59:31 +00:00
LibWeb: Make DOMException GC-allocated
This commit is contained in:
parent
0e47754ac8
commit
497ead37bc
Notes:
sideshowbarker
2024-07-17 23:07:41 +09:00
Author: https://github.com/awesomekling
Commit: 497ead37bc
Pull-request: https://github.com/SerenityOS/serenity/pull/14816
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/linusg ✅
58 changed files with 307 additions and 278 deletions
|
@ -23,17 +23,17 @@ StaticRange::StaticRange(Node& start_container, u32 start_offset, Node& end_cont
|
|||
StaticRange::~StaticRange() = default;
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-staticrange-staticrange
|
||||
ExceptionOr<StaticRange*> StaticRange::create_with_global_object(HTML::Window& window_object, StaticRangeInit& init)
|
||||
ExceptionOr<StaticRange*> StaticRange::create_with_global_object(HTML::Window& window, StaticRangeInit& init)
|
||||
{
|
||||
// 1. If init["startContainer"] or init["endContainer"] is a DocumentType or Attr node, then throw an "InvalidNodeTypeError" DOMException.
|
||||
if (is<DocumentType>(*init.start_container) || is<Attribute>(*init.start_container))
|
||||
return DOM::InvalidNodeTypeError::create("startContainer cannot be a DocumentType or Attribute node.");
|
||||
return DOM::InvalidNodeTypeError::create(window, "startContainer cannot be a DocumentType or Attribute node.");
|
||||
|
||||
if (is<DocumentType>(*init.end_container) || is<Attribute>(*init.end_container))
|
||||
return DOM::InvalidNodeTypeError::create("endContainer cannot be a DocumentType or Attribute node.");
|
||||
return DOM::InvalidNodeTypeError::create(window, "endContainer cannot be a DocumentType or Attribute node.");
|
||||
|
||||
// 2. Set this’s start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]).
|
||||
return window_object.heap().allocate<StaticRange>(window_object.realm(), *init.start_container, init.start_offset, *init.end_container, init.end_offset);
|
||||
return window.heap().allocate<StaticRange>(window.realm(), *init.start_container, init.start_offset, *init.end_container, init.end_offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue