Sfoglia il codice sorgente

LibWeb: Repeat last available quote-type, instead of looping them all

I misunderstood this part of the spec before.
Sam Atkins 1 anno fa
parent
commit
d431aeed04
1 ha cambiato i file con 4 aggiunte e 3 eliminazioni
  1. 4 3
      Userland/Libraries/LibWeb/CSS/StyleProperties.cpp

+ 4 - 3
Userland/Libraries/LibWeb/CSS/StyleProperties.cpp

@@ -659,10 +659,11 @@ CSS::ContentData StyleProperties::content() const
             // FIXME: "A typographically appropriate used value for quotes is automatically chosen by the UA
             //        based on the content language of the element and/or its parent."
             if (open)
-                return depth % 2 ? "“"_string : "‘"_string;
-            return depth % 2 ? "”"_string : "’"_string;
+                return depth == 0 ? "“"_string : "‘"_string;
+            return depth == 0 ? "”"_string : "’"_string;
         case QuotesData::Type::Specified:
-            auto& level = quotes_data.strings[depth % quotes_data.strings.size()];
+            // If the depth is greater than the number of pairs, the last pair is repeated.
+            auto& level = quotes_data.strings[min(depth, quotes_data.strings.size() - 1)];
             return open ? level[0] : level[1];
         }
         VERIFY_NOT_REACHED();