@@ -932,6 +932,33 @@ void HTMLImageElement::restart_the_animation()
932
932
}
933
933
}
934
934
935
+ static bool is_supported_image_type (String const & type)
936
+ {
937
+ if (type.is_empty ())
938
+ return true ;
939
+ if (!type.starts_with_bytes (" image/" sv, CaseSensitivity::CaseInsensitive))
940
+ return false ;
941
+ // FIXME: These should be derived from ImageDecoder
942
+ if (type.equals_ignoring_ascii_case (" image/bmp" sv)
943
+ || type.equals_ignoring_ascii_case (" image/gif" sv)
944
+ || type.equals_ignoring_ascii_case (" image/vnd.microsoft.icon" sv)
945
+ || type.equals_ignoring_ascii_case (" image/x-icon" sv)
946
+ || type.equals_ignoring_ascii_case (" image/jpeg" sv)
947
+ || type.equals_ignoring_ascii_case (" image/jpg" sv)
948
+ || type.equals_ignoring_ascii_case (" image/pjpeg" sv)
949
+ || type.equals_ignoring_ascii_case (" image/jxl" sv)
950
+ || type.equals_ignoring_ascii_case (" image/png" sv)
951
+ || type.equals_ignoring_ascii_case (" image/apng" sv)
952
+ || type.equals_ignoring_ascii_case (" image/x-png" sv)
953
+ || type.equals_ignoring_ascii_case (" image/tiff" sv)
954
+ || type.equals_ignoring_ascii_case (" image/tinyvg" sv)
955
+ || type.equals_ignoring_ascii_case (" image/webp" sv)
956
+ || type.equals_ignoring_ascii_case (" image/svg+xml" sv))
957
+ return true ;
958
+
959
+ return false ;
960
+ }
961
+
935
962
// https://html.spec.whatwg.org/multipage/images.html#update-the-source-set
936
963
static void update_the_source_set (DOM::Element& element)
937
964
{
@@ -1041,8 +1068,15 @@ static void update_the_source_set(DOM::Element& element)
1041
1068
// 7. Parse child's sizes attribute, and let source set's source size be the returned value.
1042
1069
source_set.m_source_size = parse_a_sizes_attribute (element.document (), child->get_attribute_value (HTML::AttributeNames::sizes));
1043
1070
1044
- // FIXME: 8. If child has a type attribute, and its value is an unknown or unsupported MIME type, continue to the next child.
1071
+ // 8. If child has a type attribute, and its value is an unknown or unsupported MIME type, continue to the next child.
1045
1072
if (child->has_attribute (HTML::AttributeNames::type)) {
1073
+ auto mime_type = child->get_attribute_value (HTML::AttributeNames::type);
1074
+ if (is<HTMLImageElement>(element)) {
1075
+ if (!is_supported_image_type (mime_type))
1076
+ continue ;
1077
+ }
1078
+
1079
+ // FIXME: Implement this step for link elements
1046
1080
}
1047
1081
1048
1082
// FIXME: 9. If child has width or height attributes, set el's dimension attribute source to child.
0 commit comments