LibWeb/HTML: Start implementing the download attribute

This commit is contained in:
Chase Knowlden 2024-10-26 21:57:12 -04:00 committed by Andreas Kling
parent 85356094b5
commit 20376adbc3
Notes: github-actions[bot] 2024-10-27 09:36:48 +00:00
2 changed files with 9 additions and 1 deletions

View file

@ -119,8 +119,10 @@ void HTMLAnchorElement::activation_behavior(Web::DOM::Event const& event)
// 4. Let userInvolvement be event's user navigation involvement.
auto user_involvement = user_navigation_involvement(event);
// FIXME: 5. If the user has expressed a preference to download the hyperlink, then set userInvolvement to "browser UI".
// 5. If the user has expressed a preference to download the hyperlink, then set userInvolvement to "browser UI".
// NOTE: That is, if the user has expressed a specific preference for downloading, this no longer counts as merely "activation".
if (has_download_preference())
user_involvement = UserNavigationInvolvement::BrowserUI;
// FIXME: 6. If element has a download attribute, or if the user has expressed a preference to download the
// hyperlink, then download the hyperlink created by element with hyperlinkSuffix set to hyperlinkSuffix and
@ -130,6 +132,11 @@ void HTMLAnchorElement::activation_behavior(Web::DOM::Event const& event)
follow_the_hyperlink(hyperlink_suffix, user_involvement);
}
bool HTMLAnchorElement::has_download_preference() const
{
return has_attribute(HTML::AttributeNames::download);
}
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
i32 HTMLAnchorElement::default_tab_index_value() const
{

View file

@ -43,6 +43,7 @@ private:
virtual bool has_activation_behavior() const override;
virtual void activation_behavior(Web::DOM::Event const&) override;
virtual bool has_download_preference() const;
// ^DOM::Element
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override;