Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Fix #36431: Fix crash on send screen in wallet (uplift to 1.63.x) #22481

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions ios/browser/svg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

import("//brave/ios/browser/svg/svg.gni")
import("//third_party/skia/modules/skottie/skottie.gni")
import("//third_party/skia/modules/skresources/skresources.gni")
import("//third_party/skia/modules/sksg/sksg.gni")
import("//third_party/skia/modules/skshaper/skshaper.gni")
import("//third_party/skia/modules/svg/svg.gni")

source_set("svg") {
# //skia:skia does the same thing
# There is no other way to include the skia/module files
check_includes = false

defines = [
"SK_SHAPER_CORETEXT_AVAILABLE",
"SK_SHAPER_PRIMITIVE_AVAILABLE",
]

cflags_cc = [
"-Wno-extra-semi",
"-Wno-unreachable-code-aggressive",
Expand All @@ -17,32 +31,6 @@ source_set("svg") {
]

sources += [
"//third_party/skia/src/codec/SkBmpBaseCodec.cpp",
"//third_party/skia/src/codec/SkBmpCodec.cpp",
"//third_party/skia/src/codec/SkBmpMaskCodec.cpp",
"//third_party/skia/src/codec/SkBmpRLECodec.cpp",
"//third_party/skia/src/codec/SkBmpStandardCodec.cpp",
"//third_party/skia/src/codec/SkCodec.cpp",
"//third_party/skia/src/codec/SkCodecImageGenerator.cpp",
"//third_party/skia/src/codec/SkCodecImageGenerator.h",
"//third_party/skia/src/codec/SkCodecPriv.h",
"//third_party/skia/src/codec/SkColorPalette.cpp",
"//third_party/skia/src/codec/SkColorPalette.h",
"//third_party/skia/src/codec/SkEncodedInfo.cpp",
"//third_party/skia/src/codec/SkFrameHolder.h",
"//third_party/skia/src/codec/SkIcoCodec.cpp",
"//third_party/skia/src/codec/SkMaskSwizzler.cpp",
"//third_party/skia/src/codec/SkMaskSwizzler.h",
"//third_party/skia/src/codec/SkParseEncodedOrigin.cpp",
"//third_party/skia/src/codec/SkPixmapUtils.cpp",
"//third_party/skia/src/codec/SkPixmapUtilsPriv.h",
"//third_party/skia/src/codec/SkPngCodec.cpp",
"//third_party/skia/src/codec/SkSampler.cpp",
"//third_party/skia/src/codec/SkSampler.h",
"//third_party/skia/src/codec/SkSwizzler.cpp",
"//third_party/skia/src/codec/SkSwizzler.h",
"//third_party/skia/src/codec/SkWbmpCodec.cpp",
"//third_party/skia/src/codec/SkWebpCodec.cpp",
"//third_party/skia/src/ports/SkImageGenerator_skia.cpp",
"//third_party/skia/src/utils/SkOSPath.h",
"//third_party/skia/src/utils/SkParsePath.cpp",
Expand All @@ -56,6 +44,16 @@ source_set("svg") {

sources += skia_svg_public
sources += skia_svg_sources
sources += skia_skottie_sources
sources += skia_skresources_sources
sources += skia_sksg_sources
sources += skia_shaper_primitive_sources
sources += skia_shaper_coretext_sources

include_dirs = [
"//third_party/skia",
"$root_gen_dir/third_party/skia",
]

deps = [
"//base",
Expand All @@ -66,4 +64,9 @@ source_set("svg") {
"//third_party/libwebp:libwebp_webp",
"//ui/gfx",
]

frameworks = [
"CoreFoundation.framework",
"CoreText.framework",
]
}
4 changes: 3 additions & 1 deletion ios/browser/svg/DEPS
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
include_rules = [
"+skia/ext/skia_utils_ios.h",
"+skia/ext/font_utils.h",
"+third_party/skia/include/core/SkBitmap.h",
"+third_party/skia/include/core/SkCanvas.h",
"+third_party/skia/include/core/SkFontMgr.h",
"+third_party/skia/include/core/SkRefCnt.h",
"+third_party/skia/include/core/SkStream.h",
"+third_party/skia/include/core/SkSurface.h",
"+third_party/skia/modules/svg/include/SkSVGDOM.h",
"+third_party/skia/modules/svg/include/SkSVGRenderContext.h",
"+third_party/skia/modules/svg/include/SkSVGSVG.h",
Expand Down
8 changes: 8 additions & 0 deletions ios/browser/svg/svg.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2024 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

declare_args() {
skia_use_fonthost_mac = true
}
7 changes: 6 additions & 1 deletion ios/browser/svg/svg_image.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@

#import "brave/ios/browser/svg/svg_image.h"

#include "skia/ext/font_utils.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkFontMgr.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkStream.h"
#include "third_party/skia/modules/svg/include/SkSVGDOM.h"
#include "third_party/skia/modules/svg/include/SkSVGRenderContext.h"
#include "third_party/skia/modules/svg/include/SkSVGSVG.h"
#include "ui/gfx/image/image.h"

#include "third_party/skia/include/core/SkSurface.h"

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
Expand Down Expand Up @@ -68,7 +72,8 @@ SkBitmap MakeFromData(const NSData* data,
return SkBitmap();
}

sk_sp<SkSVGDOM> document = SkSVGDOM::MakeFromStream(*stream);
sk_sp<SkSVGDOM> document =
SkSVGDOM::Builder().setFontManager(skia::DefaultFontMgr()).make(*stream);
if (!document || !document->getRoot()) {
return SkBitmap();
}
Expand Down
Loading