Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Libraries/LibWeb/CSS/TransitionEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "TransitionEvent.h"
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/TransitionEvent.h>
#include <LibWeb/CSS/CSSTransition.h>

namespace Web::CSS {

Expand All @@ -29,6 +30,7 @@ TransitionEvent::TransitionEvent(JS::Realm& realm, Utf16FlyString const& type, B
, m_property_name(event_init.property_name)
, m_elapsed_time(event_init.elapsed_time)
, m_pseudo_element(event_init.pseudo_element)
, m_animation(event_init.animation)
{
}

Expand All @@ -40,4 +42,10 @@ void TransitionEvent::initialize(JS::Realm& realm)
Base::initialize(realm);
}

void TransitionEvent::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_animation);
}

}
4 changes: 4 additions & 0 deletions Libraries/LibWeb/CSS/TransitionEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class TransitionEvent final : public DOM::Event {
Utf16String const& property_name() const { return m_property_name; }
double elapsed_time() const { return m_elapsed_time; }
Utf16String const& pseudo_element() const { return m_pseudo_element; }
GC::Ptr<CSSTransition> animation() const { return m_animation; }

virtual void visit_edges(Cell::Visitor&) override;

private:
TransitionEvent(JS::Realm&, Utf16FlyString const& event_name, Bindings::TransitionEventInit const& event_init);
Expand All @@ -34,6 +37,7 @@ class TransitionEvent final : public DOM::Event {
Utf16String m_property_name {};
double m_elapsed_time {};
Utf16String m_pseudo_element {};
GC::Ptr<CSSTransition> m_animation;
};

}
13 changes: 12 additions & 1 deletion Libraries/LibWeb/CSS/TransitionEvent.idl
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
// https://drafts.csswg.org/css-transitions/#transitionevent
// https://drafts.csswg.org/css-transitions-2/#interface-transitionevent-idl
[Exposed=Window]
interface TransitionEvent : Event {
constructor([Utf16FlyString] Utf16CSSOMString type, optional TransitionEventInit transitionEventInitDict = {});
readonly attribute Utf16CSSOMString propertyName;
readonly attribute double elapsedTime;
readonly attribute Utf16CSSOMString pseudoElement;
readonly attribute CSSTransition? animation;
};

// https://drafts.csswg.org/css-transitions-2/#interface-transitionevent-idl
dictionary TransitionEventInit : EventInit {
Utf16CSSOMString propertyName = "";
double elapsedTime = 0.0;
Utf16CSSOMString pseudoElement = "";
CSSTransition? animation = null;
};

// https://drafts.csswg.org/css-transitions/#interface-globaleventhandlers-idl
partial interface mixin GlobalEventHandlers {
attribute EventHandler ontransitionrun;
attribute EventHandler ontransitionstart;
attribute EventHandler ontransitionend;
attribute EventHandler ontransitioncancel;
};
1 change: 1 addition & 0 deletions Libraries/LibWeb/DOM/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3909,6 +3909,7 @@ void Document::dispatch_events_for_transition(GC::Ref<CSS::CSSTransition> transi
pseudo_element.has_value()) {
event_init.pseudo_element = pseudo_element.release_value();
}
event_init.animation = transition;

auto timeline = transition->timeline();

Expand Down
3 changes: 2 additions & 1 deletion Libraries/LibWeb/DOM/Document.idl
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ interface Document : Node {
[LegacyLenientThis] attribute EventHandler onreadystatechange;
attribute EventHandler onvisibilitychange;

// https://drafts.csswg.org/css-view-transitions-1/#additions-to-document-api
// https://drafts.csswg.org/css-view-transitions-2/#additions-to-document-api
[Experimental] ViewTransition startViewTransition(optional ViewTransitionUpdateCallback updateCallback);
[Experimental] readonly attribute ViewTransition? activeViewTransition;

// https://w3c.github.io/svgwg/svg2-draft/struct.html#InterfaceDocumentExtensions
readonly attribute SVGSVGElement? rootElement;
Expand Down
27 changes: 27 additions & 0 deletions Libraries/LibWeb/DOM/StyleElementBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,33 @@ CSS::CSSStyleSheet const* StyleElementBase::sheet() const
return m_associated_css_style_sheet;
}

// https://html.spec.whatwg.org/multipage/semantics.html#dom-style-disabled
bool StyleElementBase::disabled()
{
// 1. If this does not have an associated CSS style sheet, return false.
if (!sheet())
return false;

// 2. If this's associated CSS style sheet's disabled flag is set, return true.
if (sheet()->disabled())
return true;

// 3. Return false.
return false;
}

// https://html.spec.whatwg.org/multipage/semantics.html#dom-style-disabled
void StyleElementBase::set_disabled(bool disabled)
{
// 1. If this does not have an associated CSS style sheet, return.
if (!sheet())
return;

// 2. If the given value is true, set this's associated CSS style sheet's disabled flag.
// Otherwise, unset this's associated CSS style sheet's disabled flag.
sheet()->set_disabled(disabled);
}

void StyleElementBase::visit_style_element_edges(JS::Cell::Visitor& visitor)
{
visitor.visit(m_associated_css_style_sheet);
Expand Down
3 changes: 3 additions & 0 deletions Libraries/LibWeb/DOM/StyleElementBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class StyleElementBase {
CSS::CSSStyleSheet* sheet();
CSS::CSSStyleSheet const* sheet() const;

bool disabled();
void set_disabled(bool disabled);

[[nodiscard]] GC::Ptr<CSS::StyleSheetList> style_sheet_list() { return m_style_sheet_list; }
[[nodiscard]] GC::Ptr<CSS::StyleSheetList const> style_sheet_list() const { return m_style_sheet_list; }

Expand Down
4 changes: 4 additions & 0 deletions Libraries/LibWeb/HTML/AttributeNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ namespace AttributeNames {
__ENUMERATE_HTML_ATTRIBUTE(onsuspend, "onsuspend") \
__ENUMERATE_HTML_ATTRIBUTE(ontimeupdate, "ontimeupdate") \
__ENUMERATE_HTML_ATTRIBUTE(ontoggle, "ontoggle") \
__ENUMERATE_HTML_ATTRIBUTE(ontransitioncancel, "ontransitioncancel") \
__ENUMERATE_HTML_ATTRIBUTE(ontransitionend, "ontransitionend") \
__ENUMERATE_HTML_ATTRIBUTE(ontransitionrun, "ontransitionrun") \
__ENUMERATE_HTML_ATTRIBUTE(ontransitionstart, "ontransitionstart") \
__ENUMERATE_HTML_ATTRIBUTE(onunhandledrejection, "onunhandledrejection") \
__ENUMERATE_HTML_ATTRIBUTE(onunload, "onunload") \
__ENUMERATE_HTML_ATTRIBUTE(onvolumechange, "onvolumechange") \
Expand Down
4 changes: 4 additions & 0 deletions Libraries/LibWeb/HTML/GlobalEventHandlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
E(onsuspend, HTML::EventNames::suspend) \
E(ontimeupdate, HTML::EventNames::timeupdate) \
E(ontoggle, HTML::EventNames::toggle) \
E(ontransitioncancel, HTML::EventNames::transitioncancel) \
E(ontransitionend, HTML::EventNames::transitionend) \
E(ontransitionrun, HTML::EventNames::transitionrun) \
E(ontransitionstart, HTML::EventNames::transitionstart) \
E(onvolumechange, HTML::EventNames::volumechange) \
E(onwaiting, HTML::EventNames::waiting) \
E(onwebkitanimationend, HTML::EventNames::webkitAnimationEnd) \
Expand Down
27 changes: 0 additions & 27 deletions Libraries/LibWeb/HTML/HTMLStyleElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,6 @@ void HTMLStyleElement::attribute_changed(Utf16FlyString const& name, Optional<Ut
style_element_attribute_changed(name, value);
}

// https://html.spec.whatwg.org/multipage/semantics.html#dom-style-disabled
bool HTMLStyleElement::disabled()
{
// 1. If this does not have an associated CSS style sheet, return false.
if (!sheet())
return false;

// 2. If this's associated CSS style sheet's disabled flag is set, return true.
if (sheet()->disabled())
return true;

// 3. Return false.
return false;
}

// https://html.spec.whatwg.org/multipage/semantics.html#dom-style-disabled
void HTMLStyleElement::set_disabled(bool disabled)
{
// 1. If this does not have an associated CSS style sheet, return.
if (!sheet())
return;

// 2. If the given value is true, set this's associated CSS style sheet's disabled flag.
// Otherwise, unset this's associated CSS style sheet's disabled flag.
sheet()->set_disabled(disabled);
}

// https://html.spec.whatwg.org/multipage/semantics.html#contributes-a-script-blocking-style-sheet
bool HTMLStyleElement::contributes_a_script_blocking_style_sheet() const
{
Expand Down
3 changes: 0 additions & 3 deletions Libraries/LibWeb/HTML/HTMLStyleElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class HTMLStyleElement final
virtual void removed_from(IsSubtreeRoot, Node* old_ancestor, Node& old_root) override;
virtual void attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_) override;

bool disabled();
void set_disabled(bool disabled);

virtual bool contributes_a_script_blocking_style_sheet() const final;

private:
Expand Down
1 change: 1 addition & 0 deletions Libraries/LibWeb/HTML/PopStateEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ GC::Ref<PopStateEvent> PopStateEvent::construct_impl(JS::Realm& realm, Utf16FlyS
PopStateEvent::PopStateEvent(JS::Realm& realm, Utf16FlyString const& event_name, Bindings::PopStateEventInit const& event_init)
: DOM::Event(realm, event_name, event_init)
, m_state(event_init.state)
, m_has_ua_visual_transition(event_init.has_ua_visual_transition)
{
}

Expand Down
2 changes: 2 additions & 0 deletions Libraries/LibWeb/HTML/PopStateEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class PopStateEvent final : public DOM::Event {
[[nodiscard]] static GC::Ref<PopStateEvent> construct_impl(JS::Realm&, Utf16FlyString const& event_name, Bindings::PopStateEventInit const&);

JS::Value const& state() const { return m_state; }
bool has_ua_visual_transition() const { return m_has_ua_visual_transition; }

private:
PopStateEvent(JS::Realm&, Utf16FlyString const& event_name, Bindings::PopStateEventInit const& event_init);
Expand All @@ -28,6 +29,7 @@ class PopStateEvent final : public DOM::Event {
virtual void visit_edges(JS::Cell::Visitor& visitor) override;

JS::Value m_state { JS::js_null() };
bool m_has_ua_visual_transition { false };
};

}
4 changes: 2 additions & 2 deletions Libraries/LibWeb/HTML/PopStateEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ interface PopStateEvent : Event {
constructor([Utf16FlyString] Utf16DOMString type, optional PopStateEventInit eventInitDict = {});

readonly attribute any state;
[FIXME] readonly attribute boolean hasUAVisualTransition;
readonly attribute boolean hasUAVisualTransition;
};

dictionary PopStateEventInit : EventInit {
any state = null;
// FIXME: boolean hasUAVisualTransition = false;
boolean hasUAVisualTransition = false;
};
7 changes: 7 additions & 0 deletions Libraries/LibWeb/SVG/SVGSVGElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/FragmentIdentifier.h>
#include <LibWeb/SVG/SVGAnimatedRect.h>
#include <LibWeb/SVG/SVGNumber.h>
#include <LibWeb/SVG/SVGSVGElement.h>
#include <LibWeb/SVG/SVGViewElement.h>
#include <LibWeb/Selection/Selection.h>
Expand Down Expand Up @@ -225,6 +226,12 @@ void SVGSVGElement::deselect_all() const
selection->remove_all_ranges();
}

// https://w3c.github.io/svgwg/svg2-draft/struct.html#__svg__SVGSVGElement__createSVGNumber
GC::Ref<SVGNumber> SVGSVGElement::create_svg_number() const
{
return SVGNumber::create(realm(), 0, SVGNumber::ReadOnly::No);
}

GC::Ref<SVGLength> SVGSVGElement::create_svg_length() const
{
// A new, detached SVGLength object whose value is the unitless <number> 0.
Expand Down
1 change: 1 addition & 0 deletions Libraries/LibWeb/SVG/SVGSVGElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class SVGSVGElement final : public SVGGraphicsElement

void deselect_all() const;

GC::Ref<SVGNumber> create_svg_number() const;
GC::Ref<SVGLength> create_svg_length() const;
GC::Ref<Geometry::DOMPoint> create_svg_point() const;
GC::Ref<Geometry::DOMMatrix> create_svg_matrix() const;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibWeb/SVG/SVGSVGElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface SVGSVGElement : SVGGraphicsElement {

undefined deselectAll();

// FIXME: [NewObject] SVGNumber createSVGNumber();
[NewObject] SVGNumber createSVGNumber();
[NewObject] SVGLength createSVGLength();
[FIXME, NewObject] SVGAngle createSVGAngle();
[NewObject] DOMPoint createSVGPoint();
Expand Down
3 changes: 2 additions & 1 deletion Libraries/LibWeb/SVG/SVGStyleElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
interface SVGStyleElement : SVGElement {
[Reflect] attribute Utf16DOMString media;
[Reflect] attribute Utf16DOMString title;

attribute boolean disabled;

// obsolete members
[Reflect] attribute Utf16DOMString type;
};
Expand Down
3 changes: 3 additions & 0 deletions Libraries/LibWeb/UIEvents/InputEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <LibWeb/Bindings/InputEvent.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/DataTransfer.h>
#include <LibWeb/UIEvents/InputEvent.h>

namespace Web::UIEvents {
Expand Down Expand Up @@ -33,6 +34,7 @@ InputEvent::InputEvent(JS::Realm& realm, Utf16FlyString const& event_name, Bindi
, m_data(event_init.data)
, m_is_composing(event_init.is_composing)
, m_input_type(event_init.input_type)
, m_data_transfer(event_init.data_transfer)
, m_target_ranges(target_ranges)
{
}
Expand All @@ -48,6 +50,7 @@ void InputEvent::initialize(JS::Realm& realm)
void InputEvent::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_data_transfer);
visitor.visit(m_target_ranges);
}

Expand Down
3 changes: 3 additions & 0 deletions Libraries/LibWeb/UIEvents/InputEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class InputEvent final : public UIEvent {
// https://w3c.github.io/uievents/#dom-inputevent-inputtype
Utf16FlyString input_type() const { return m_input_type; }

GC::Ptr<HTML::DataTransfer> data_transfer() const { return m_data_transfer; }

ReadonlySpan<GC::Ref<DOM::StaticRange>> get_target_ranges() const;

private:
Expand All @@ -41,6 +43,7 @@ class InputEvent final : public UIEvent {
Optional<Utf16String> m_data;
bool m_is_composing;
Utf16FlyString m_input_type;
GC::Ptr<HTML::DataTransfer> m_data_transfer;
Vector<GC::Ref<DOM::StaticRange>> m_target_ranges;
};

Expand Down
5 changes: 5 additions & 0 deletions Libraries/LibWeb/UIEvents/InputEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ interface InputEvent : UIEvent {
readonly attribute boolean isComposing;
readonly attribute Utf16DOMString inputType;

// https://w3c.github.io/input-events/#interface-InputEvent
readonly attribute DataTransfer? dataTransfer;
sequence<StaticRange> getTargetRanges();
};

Expand All @@ -14,4 +16,7 @@ dictionary InputEventInit : UIEventInit {
Utf16DOMString? data = null;
boolean isComposing = false;
[Utf16FlyString] Utf16DOMString inputType = "";

// https://w3c.github.io/input-events/#interface-InputEvent
DataTransfer? dataTransfer = null;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
};
2 changes: 2 additions & 0 deletions Tests/LibWeb/TestConfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ Text/input/wpt-import/css/css-animations/idlharness.html
Text/input/wpt-import/css/css-conditional/idlharness.html
Text/input/wpt-import/css/css-counter-styles/idlharness.html
Text/input/wpt-import/css/css-fonts/idlharness.html
Text/input/wpt-import/css/css-transitions/idlharness.html
Text/input/wpt-import/css/css-typed-om/idlharness.html
Text/input/wpt-import/css/cssom-view/idlharness.html
Text/input/wpt-import/gamepad/idlharness.window.html
Text/input/wpt-import/geolocation/idlharness.https.window.html
Text/input/wpt-import/input-events/idlharness.window.html
Text/input/wpt-import/notifications/idlharness.https.any.html
Text/input/wpt-import/permissions/idlharness.any.html
Text/input/wpt-import/permissions/idlharness.any.worker.html
Expand Down
4 changes: 4 additions & 0 deletions Tests/LibWeb/Text/expected/SVG/svg-create-svg-number.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
is an SVGNumber: true
initial value: 0
value after assignment: 12.5
returns a new object each call: true
6 changes: 6 additions & 0 deletions Tests/LibWeb/Text/expected/SVG/svg-style-element-disabled.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
disabled: false
fill: rgb(0, 128, 0)
disabled after disabling: true
fill after disabling: rgb(0, 0, 0)
disabled after enabling: false
fill after enabling: rgb(0, 128, 0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Harness status: OK

Found 3 tests

3 Pass
Pass transitionrun event has animation property and its value is the corresponding CSSTransition object
Pass transitionstart event has animation property and its value is the corresponding CSSTransition object
Pass transitionend event has animation property and its value is the corresponding CSSTransition object
Loading
Loading