File: use_system_woff2.diff

package info (click to toggle)
qtwebkit-opensource-src 5.212.0~alpha2-21
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 126,448 kB
  • sloc: cpp: 1,398,101; ansic: 32,876; perl: 19,440; python: 12,790; ruby: 10,299; xml: 8,371; asm: 5,078; yacc: 2,166; lex: 906; sh: 414; makefile: 43
file content (139 lines) | stat: -rw-r--r-- 4,728 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
Description: use system WOFF2 library
Author: Dmitry Shachnev <mitya57@debian.org>
Forwarded: https://github.com/annulen/webkit/pull/725
Last-Update: 2018-02-24

--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -19,7 +19,7 @@
     add_subdirectory(ThirdParty/gtest)
 endif ()
 
-if (USE_WOFF2)
+if (USE_WOFF2 AND NOT WOFF2DEC_FOUND)
     add_subdirectory(ThirdParty/brotli)
     add_subdirectory(ThirdParty/woff2)
 endif ()
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -3353,8 +3353,13 @@
 endif ()
 
 if (USE_WOFF2)
-  list(APPEND WebCore_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/woff2/src")
-  list(APPEND WebCore_LIBRARIES woff2)
+    if (WOFF2DEC_FOUND)
+        list(APPEND WebCore_INCLUDE_DIRECTORIES "${WOFF2DEC_INCLUDE_DIRS}")
+        list(APPEND WebCore_LIBRARIES "${WOFF2DEC_LIBRARIES}")
+    else ()
+        list(APPEND WebCore_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/woff2/src")
+        list(APPEND WebCore_LIBRARIES woff2)
+    endif ()
 endif ()
 
 set(WebCoreTestSupport_INCLUDE_DIRECTORIES
--- /dev/null
+++ b/Source/cmake/FindWOFF2Dec.cmake
@@ -0,0 +1,53 @@
+# - Try to find WOFF2Dec.
+# Once done, this will define
+#
+#  WOFF2DEC_FOUND - system has WOFF2Dec.
+#  WOFF2DEC_INCLUDE_DIRS - the WOFF2Dec include directories
+#  WOFF2DEC_LIBRARIES - link these to use WOFF2Dec.
+#
+# Copyright (C) 2017 Igalia S.L.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+find_package(PkgConfig)
+pkg_check_modules(PC_WOFF2DEC libwoff2dec)
+
+find_path(WOFF2DEC_INCLUDE_DIRS
+    NAMES woff2/decode.h
+    HINTS ${PC_WOFF2DEC_INCLUDEDIR}
+)
+
+find_library(WOFF2DEC_LIBRARIES
+    NAMES woff2dec
+    HINTS ${PC_WOFF2DEC_LIBDIR}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WOFF2Dec
+    REQUIRED_VARS WOFF2DEC_INCLUDE_DIRS WOFF2DEC_LIBRARIES
+    FOUND_VAR WOFF2DEC_FOUND
+    VERSION_VAR PC_WOFF2DEC_VERSION)
+
+mark_as_advanced(
+    WOFF2DEC_INCLUDE_DIRS
+    WOFF2DEC_LIBRARIES
+)
--- a/Source/cmake/OptionsQt.cmake
+++ b/Source/cmake/OptionsQt.cmake
@@ -679,6 +679,15 @@
     endif ()
 endif ()
 
+if (USE_WOFF2)
+    find_package(WOFF2Dec 1.0.1)
+    if (WOFF2DEC_FOUND)
+        message(STATUS "Using system WOFF2Dec library.")
+    else ()
+        message(STATUS "WOFF2Dec not found, using the bundled library.")
+    endif ()
+endif ()
+
 # From OptionsGTK.cmake
 if (CMAKE_MAJOR_VERSION LESS 3)
     # Before CMake 3 it was necessary to use a build script instead of using cmake --build directly
--- a/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
+++ b/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
@@ -31,8 +31,8 @@
 #include <wtf/ByteOrder.h>
 
 #if USE(WOFF2)
-#include "woff2_common.h"
-#include "woff2_dec.h"
+#include <woff2/decode.h>
+static const uint32_t kWoff2Signature = 0x774f4632; // "wOF2"
 #endif
 
 namespace WebCore {
@@ -84,7 +84,7 @@
         return false;
 
 #if USE(WOFF2)
-    return signature == woffSignature || signature == woff2::kWoff2Signature;
+    return signature == woffSignature || signature == kWoff2Signature;
 #else
     return signature == woffSignature;
 #endif
@@ -140,7 +140,7 @@
     }
 
 #if USE(WOFF2)
-    if (signature == woff2::kWoff2Signature) {
+    if (signature == kWoff2Signature) {
         const uint8_t* woffData = reinterpret_cast_ptr<const uint8_t*>(woff.data());
         const size_t woffSize = woff.size();
         const size_t sfntSize = woff2::ComputeWOFF2FinalSize(woffData, woffSize);