Before

…lines 1–80 unchanged (80 lines)
81 // 12. Set this’s internal [[delay]] slot to options.delay to delay.
82 // 13. Set this’s internal [[trackVisibility]] slot to options.trackVisibility.
83 // 14. Return this.
84 return realm.create<IntersectionObserver>(realm, callback, options.root, move(root_margin.value()), move(scroll_margin.value()), move(thresholds), move(delay), move(options.track_visibility));
85}
86
87IntersectionObserver::IntersectionObserver(JS::Realm& realm, GC::Ptr<WebIDL::CallbackType> callback, Optional<Variant<GC::Root<DOM::Element>, GC::Root<DOM::Document>>> const& root, Vector<CSS::LengthPercentage> root_margin, Vector<CSS::LengthPercentage> scroll_margin, Vector<double>&& thresholds, double delay, bool track_visibility)
88 : PlatformObject(realm)
89 , m_callback(callback)
90 , m_root_margin(root_margin)
91 , m_scroll_margin(scroll_margin)
92 , m_thresholds(move(thresholds))
93 , m_delay(delay)
94 , m_track_visibility(track_visibility)
95{
96 m_root = root.has_value() ? root->visit([](auto& value) -> GC::Ptr<DOM::Node> { return *value; }) : nullptr;
97 intersection_root().visit([this](auto& node) {
98 m_document = node->document();
99 });
100 m_document->register_intersection_observer({}, *this);
101}
102
…lines 103–186 unchanged (84 lines)
187 // 2. Clear this’s internal [[QueuedEntries]] slot.
188 m_queued_entries.clear();
189
190 // 3. Return queue.
191 return queue;
192}
193
194Variant<GC::Root<DOM::Element>, GC::Root<DOM::Document>, Empty> IntersectionObserver::root() const
195{
196 if (!m_root)
197 return Empty {};
198 if (m_root->is_element())
199 return GC::make_root(static_cast<DOM::Element&>(*m_root));
200 if (m_root->is_document())
…lines 201–388 unchanged (188 lines)

After

…lines 1–80 unchanged (80 lines)
81 // 12. Set this’s internal [[delay]] slot to options.delay to delay.
82 // 13. Set this’s internal [[trackVisibility]] slot to options.trackVisibility.
83 // 14. Return this.
84 return realm.create<IntersectionObserver>(realm, callback, options.root, move(root_margin.value()), move(scroll_margin.value()), move(thresholds), move(delay), move(options.track_visibility));
85}
86
87IntersectionObserver::IntersectionObserver(JS::Realm& realm, GC::Ptr<WebIDL::CallbackType> callback, NullableIntersectionObserverRoot const& root, Vector<CSS::LengthPercentage> root_margin, Vector<CSS::LengthPercentage> scroll_margin, Vector<double>&& thresholds, double delay, bool track_visibility)
88 : PlatformObject(realm)
89 , m_callback(callback)
90 , m_root_margin(root_margin)
91 , m_scroll_margin(scroll_margin)
92 , m_thresholds(move(thresholds))
93 , m_delay(delay)
94 , m_track_visibility(track_visibility)
95{
96 m_root = root.has<Empty>() ? nullptr : root.visit([](GC::Root<DOM::Element> const& value) -> GC::Ptr<DOM::Node> { return *value; }, [](GC::Root<DOM::Document> const& value) -> GC::Ptr<DOM::Node> { return *value; }, [](Empty) -> GC::Ptr<DOM::Node> { return nullptr; });
97 intersection_root().visit([this](auto& node) {
98 m_document = node->document();
99 });
100 m_document->register_intersection_observer({}, *this);
101}
102
…lines 103–186 unchanged (84 lines)
187 // 2. Clear this’s internal [[QueuedEntries]] slot.
188 m_queued_entries.clear();
189
190 // 3. Return queue.
191 return queue;
192}
193
194NullableIntersectionObserverRoot IntersectionObserver::root() const
195{
196 if (!m_root)
197 return Empty {};
198 if (m_root->is_element())
199 return GC::make_root(static_cast<DOM::Element&>(*m_root));
200 if (m_root->is_document())
…lines 201–388 unchanged (188 lines)

Before

translation_unit
comment "/*\n * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.or"...
preproc_include
#include "#include"
system_lib_string "<AK/QuickSort.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/Bindings/IntersectionObserverPrototype.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/Bindings/Intrinsics.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/CSS/Parser/Parser.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/CSS/StyleValues/LengthStyleValue.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/DOM/Document.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/DOM/Element.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/HTML/BrowsingContext.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/HTML/TraversableNavigable.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/HTML/Window.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/IntersectionObserver/IntersectionObserver.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/Layout/Viewport.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/Page/Page.h>"
namespace_definition
namespace "namespace"
nested_namespace_specifier
namespace_identifier "Web"
:: "::"
namespace_identifier "IntersectionObserver"
declaration_list
{ "{"
expression_statement
call_expression
identifier "GC_DEFINE_ALLOCATOR"
argument_list
( "("
identifier "IntersectionObserver"
) ")"
; ";"
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+546 nodes collapsed)
function_definition
function_declarator
qualified_identifier
namespace_identifier "IntersectionObserver"
:: "::"
identifier "IntersectionObserver"
parameter_list
( "("
parameter_declaration
qualified_identifier
namespace_identifier "JS"
:: "::"
type_identifier "Realm"
reference_declarator
& "&"
identifier "realm"
, ","
parameter_declaration
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Ptr"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "WebIDL"
:: "::"
type_identifier "CallbackType"
> ">"
identifier "callback"
, ","
parameter_declaration
template_type
type_identifier "Optional"
template_argument_list
< "<"
type_descriptor
template_type
type_identifier "Variant"
template_argument_list
< "<"
qualified_identifier
namespace_identifier "GC"
:: "::"
template_function
identifier "Root"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Element"
> ">"
, ","
type_descriptor
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Root"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Document"
> ">"
> ">"
> ">"
type_qualifier
const "const"
reference_declarator
& "&"
identifier "root"
, ","
parameter_declaration
template_type
type_identifier "Vector"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "CSS"
:: "::"
type_identifier "LengthPercentage"
> ">"
identifier "root_margin"
, ","
parameter_declaration
template_type
type_identifier "Vector"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "CSS"
:: "::"
type_identifier "LengthPercentage"
> ">"
identifier "scroll_margin"
, ","
parameter_declaration
template_type
type_identifier "Vector"
template_argument_list
< "<"
type_descriptor
primitive_type "double"
> ">"
reference_declarator
&& "&&"
identifier "thresholds"
, ","
parameter_declaration
primitive_type "double"
identifier "delay"
, ","
parameter_declaration
primitive_type "bool"
identifier "track_visibility"
) ")"
field_initializer_list (+55 nodes collapsed)
compound_statement
{ "{"
expression_statement
assignment_expression
identifier "m_root"
= "="
conditional_expression
call_expression
field_expression
identifier "root"
. "."
field_identifier "has_value"
argument_list
( "("
) ")"
? "?"
call_expression
field_expression
identifier "root"
-> "->"
field_identifier "visit"
argument_list
( "("
lambda_expression
lambda_capture_specifier
[ "["
] "]"
abstract_function_declarator
parameter_list
( "("
parameter_declaration
placeholder_type_specifier
auto "auto"
reference_declarator
& "&"
identifier "value"
) ")"
trailing_return_type
-> "->"
type_descriptor
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Ptr"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Node"
> ">"
compound_statement
{ "{"
return_statement
return "return"
pointer_expression
* "*"
identifier "value"
; ";"
} "}"
) ")"
: ":"
null
nullptr "nullptr"
; ";"
expression_statement (+45 nodes collapsed)
expression_statement
call_expression
field_expression
identifier "m_document"
-> "->"
field_identifier "register_intersection_observer"
argument_list
( "("
initializer_list
{ "{"
} "}"
, ","
pointer_expression
* "*"
this "this"
) ")"
; ";"
} "}"
function_definition
function_declarator
qualified_identifier
namespace_identifier "IntersectionObserver"
:: "::"
destructor_name
~ "~"
identifier "IntersectionObserver"
parameter_list
( "("
) ")"
default_method_clause
= "="
default "default"
; ";"
function_definition (+46 nodes collapsed)
function_definition (+40 nodes collapsed)
function_definition (+79 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+124 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+100 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+58 nodes collapsed)
comment "// https://www.w3.org/TR/intersection-observer/#dom-intersec"...
function_definition (+88 nodes collapsed)
function_definition
template_type
type_identifier "Variant"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Root"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Element"
> ">"
, ","
type_descriptor
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Root"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Document"
> ">"
, ","
type_descriptor
type_identifier "Empty"
> ">"
function_declarator
qualified_identifier
namespace_identifier "IntersectionObserver"
:: "::"
identifier "root"
parameter_list
( "("
) ")"
type_qualifier
const "const"
compound_statement (+112 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+204 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+204 nodes collapsed)
comment "// https://www.w3.org/TR/intersection-observer/#intersection"...
function_definition (+133 nodes collapsed)
function_definition (+91 nodes collapsed)
comment "// https://www.w3.org/TR/intersection-observer/#intersection"...
function_definition (+608 nodes collapsed)
function_definition (+48 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#parse-a-margi"...
function_definition (+622 nodes collapsed)
} "}"

After

translation_unit
comment "/*\n * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.or"...
preproc_include
#include "#include"
system_lib_string "<AK/QuickSort.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/Bindings/IntersectionObserverPrototype.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/Bindings/Intrinsics.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/CSS/Parser/Parser.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/CSS/StyleValues/LengthStyleValue.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/DOM/Document.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/DOM/Element.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/HTML/BrowsingContext.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/HTML/TraversableNavigable.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/HTML/Window.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/IntersectionObserver/IntersectionObserver.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/Layout/Viewport.h>"
preproc_include
#include "#include"
system_lib_string "<LibWeb/Page/Page.h>"
namespace_definition
namespace "namespace"
nested_namespace_specifier
namespace_identifier "Web"
:: "::"
namespace_identifier "IntersectionObserver"
declaration_list
{ "{"
expression_statement
call_expression
identifier "GC_DEFINE_ALLOCATOR"
argument_list
( "("
identifier "IntersectionObserver"
) ")"
; ";"
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+546 nodes collapsed)
function_definition
function_declarator
qualified_identifier
namespace_identifier "IntersectionObserver"
:: "::"
identifier "IntersectionObserver"
parameter_list
( "("
parameter_declaration
qualified_identifier
namespace_identifier "JS"
:: "::"
type_identifier "Realm"
reference_declarator
& "&"
identifier "realm"
, ","
parameter_declaration
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Ptr"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "WebIDL"
:: "::"
type_identifier "CallbackType"
> ">"
identifier "callback"
, ","
parameter_declaration
type_identifier "NullableIntersectionObserverRoot"
type_qualifier
const "const"
reference_declarator
& "&"
identifier "root"
, ","
parameter_declaration
template_type
type_identifier "Vector"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "CSS"
:: "::"
type_identifier "LengthPercentage"
> ">"
identifier "root_margin"
, ","
parameter_declaration
template_type
type_identifier "Vector"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "CSS"
:: "::"
type_identifier "LengthPercentage"
> ">"
identifier "scroll_margin"
, ","
parameter_declaration
template_type
type_identifier "Vector"
template_argument_list
< "<"
type_descriptor
primitive_type "double"
> ">"
reference_declarator
&& "&&"
identifier "thresholds"
, ","
parameter_declaration
primitive_type "double"
identifier "delay"
, ","
parameter_declaration
primitive_type "bool"
identifier "track_visibility"
) ")"
field_initializer_list (+55 nodes collapsed)
compound_statement
{ "{"
expression_statement
assignment_expression
identifier "m_root"
= "="
conditional_expression
call_expression
field_expression
identifier "root"
. "."
template_method
field_identifier "has"
template_argument_list
< "<"
type_descriptor
type_identifier "Empty"
> ">"
argument_list
( "("
) ")"
? "?"
null
nullptr "nullptr"
: ":"
call_expression
field_expression
identifier "root"
. "."
field_identifier "visit"
argument_list
( "("
lambda_expression
lambda_capture_specifier
[ "["
] "]"
abstract_function_declarator
parameter_list
( "("
parameter_declaration
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Root"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Element"
> ">"
type_qualifier
const "const"
reference_declarator
& "&"
identifier "value"
) ")"
trailing_return_type
-> "->"
type_descriptor
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Ptr"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Node"
> ">"
compound_statement
{ "{"
return_statement
return "return"
pointer_expression
* "*"
identifier "value"
; ";"
} "}"
, ","
lambda_expression
lambda_capture_specifier
[ "["
] "]"
abstract_function_declarator
parameter_list
( "("
parameter_declaration
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Root"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Document"
> ">"
type_qualifier
const "const"
reference_declarator
& "&"
identifier "value"
) ")"
trailing_return_type
-> "->"
type_descriptor
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Ptr"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Node"
> ">"
compound_statement
{ "{"
return_statement
return "return"
pointer_expression
* "*"
identifier "value"
; ";"
} "}"
, ","
lambda_expression
lambda_capture_specifier
[ "["
] "]"
abstract_function_declarator
parameter_list
( "("
parameter_declaration
type_identifier "Empty"
) ")"
trailing_return_type
-> "->"
type_descriptor
qualified_identifier
namespace_identifier "GC"
:: "::"
template_type
type_identifier "Ptr"
template_argument_list
< "<"
type_descriptor
qualified_identifier
namespace_identifier "DOM"
:: "::"
type_identifier "Node"
> ">"
compound_statement
{ "{"
return_statement
return "return"
null
nullptr "nullptr"
; ";"
} "}"
) ")"
; ";"
expression_statement (+45 nodes collapsed)
expression_statement
call_expression
field_expression
identifier "m_document"
-> "->"
field_identifier "register_intersection_observer"
argument_list
( "("
initializer_list
{ "{"
} "}"
, ","
pointer_expression
* "*"
this "this"
) ")"
; ";"
} "}"
function_definition
function_declarator
qualified_identifier
namespace_identifier "IntersectionObserver"
:: "::"
destructor_name
~ "~"
identifier "IntersectionObserver"
parameter_list
( "("
) ")"
default_method_clause
= "="
default "default"
; ";"
function_definition (+46 nodes collapsed)
function_definition (+40 nodes collapsed)
function_definition (+79 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+124 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+100 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+58 nodes collapsed)
comment "// https://www.w3.org/TR/intersection-observer/#dom-intersec"...
function_definition (+88 nodes collapsed)
function_definition
type_identifier "NullableIntersectionObserverRoot"
function_declarator
qualified_identifier
namespace_identifier "IntersectionObserver"
:: "::"
identifier "root"
parameter_list
( "("
) ")"
type_qualifier
const "const"
compound_statement (+112 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+204 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#dom-intersect"...
function_definition (+204 nodes collapsed)
comment "// https://www.w3.org/TR/intersection-observer/#intersection"...
function_definition (+133 nodes collapsed)
function_definition (+91 nodes collapsed)
comment "// https://www.w3.org/TR/intersection-observer/#intersection"...
function_definition (+608 nodes collapsed)
function_definition (+48 nodes collapsed)
comment "// https://w3c.github.io/IntersectionObserver/#parse-a-margi"...
function_definition (+622 nodes collapsed)
} "}"