浏览代码

LibWeb: Use Unicode data for CSS text-transform property

Previously it was only transforming ASCII characters.
Karol Kosek 3 年之前
父节点
当前提交
ae28e3ff5c
共有 2 个文件被更改,包括 4 次插入2 次删除
  1. 1 0
      Userland/Libraries/LibWeb/CMakeLists.txt
  2. 3 2
      Userland/Libraries/LibWeb/Painting/PaintableBox.cpp

+ 1 - 0
Userland/Libraries/LibWeb/CMakeLists.txt

@@ -380,6 +380,7 @@ set(GENERATED_SOURCES
 
 serenity_lib(LibWeb web)
 target_link_libraries(LibWeb LibCore LibJS LibMarkdown LibGemini LibGUI LibGfx LibTextCodec LibProtocol LibImageDecoderClient LibWasm LibXML)
+link_with_unicode_data(LibWeb)
 
 function(libweb_js_wrapper class)
     cmake_parse_arguments(PARSE_ARGV 1 LIBWEB_WRAPPER "ITERABLE" "" "")

+ 3 - 2
Userland/Libraries/LibWeb/Painting/PaintableBox.cpp

@@ -4,6 +4,7 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
+#include <LibUnicode/CharacterTypes.h>
 #include <LibWeb/DOM/Document.h>
 #include <LibWeb/HTML/HTMLHtmlElement.h>
 #include <LibWeb/Layout/BlockContainer.h>
@@ -381,9 +382,9 @@ static void paint_text_fragment(PaintContext& context, Layout::TextNode const& t
         auto text = text_node.text_for_rendering();
         auto text_transform = text_node.computed_values().text_transform();
         if (text_transform == CSS::TextTransform::Uppercase)
-            text = text_node.text_for_rendering().to_uppercase();
+            text = Unicode::to_unicode_uppercase_full(text_node.text_for_rendering());
         if (text_transform == CSS::TextTransform::Lowercase)
-            text = text_node.text_for_rendering().to_lowercase();
+            text = Unicode::to_unicode_lowercase_full(text_node.text_for_rendering());
 
         Gfx::FloatPoint baseline_start { fragment_absolute_rect.x(), fragment_absolute_rect.y() + fragment.baseline() };
         Utf8View view { text.substring_view(fragment.start(), fragment.length()) };