فهرست منبع

LibWeb/HTML: Start implementing the download attribute

Chase Knowlden 8 ماه پیش
والد
کامیت
20376adbc3
2فایلهای تغییر یافته به همراه9 افزوده شده و 1 حذف شده
  1. 8 1
      Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp
  2. 1 0
      Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h

+ 8 - 1
Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp

@@ -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
 {

+ 1 - 0
Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h

@@ -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;