clang -cc1 -cc1 -triple arm64-apple-macosx15.5.0 -Os -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name UnifiedSource74-nonARC.mm -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=osx -analyzer-checker=security.insecureAPI.decodeValueOfObjCType -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -target-sdk-version=15.5 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fno-modulemap-allow-subdirectory-search -fdefine-target-os-macros -enable-tlsdesc -target-cpu apple-m1 -target-feature +v8.4a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +ccpp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +flagm -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -target-abi darwinpcs -dwarf-ext-refs -fmodule-format=obj -debug-info-kind=standalone -dwarf-version=5 -debugger-tuning=lldb -fdebug-compilation-dir=/Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/Source/WebKit -target-linker-version 1167.5 -fcoverage-compilation-dir=/Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/Source/WebKit -resource-dir /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/llvm-project/build/lib/clang/21 -dependency-file /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/WebKit/WebKit/normal/arm64/UnifiedSource74-nonARC.d -skip-unused-modulemap-deps -MT dependencies -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk -iquote /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release/WebKit.build/WebKit-generated-files.hmap -iquote /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release/WebKit.build/WebKit-project-headers.hmap -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/local/include -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/System/Library/PrivateFrameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/System/Library/PrivateFrameworks -isystem /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/macosx15.0-additions.sdk/usr/local/include -include-pch /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/PrecompiledHeaders/SharedPrecompiledHeaders/12103950607181003560/WebKit2Prefix.h.gch -D _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D CLANG_WEBKIT_BRANCH=1 -D NDEBUG -D HAVE_CORE_PREDICTION -D ENABLE_LOWER_FORMATREADERBUNDLE_CODESIGNING_REQUIREMENTS -D WEBKIT_BUNDLE_VERSION="625.1.10+" -D FRAMEWORK_NAME=WebKit -D OBJC_OLD_DISPATCH_PROTOTYPES=0 -D __clang_analyzer__ -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release/WebKit.build/WebKit-own-target-headers.hmap -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release/WebKit.build/WebKit-all-target-headers.hmap -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/include -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/usr/local/include -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/WebCore.framework/Versions/A/PrivateHeaders/ForwardingHeaders -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/DerivedSources/WebKit -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/DerivedSources/WebKit/IPC -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/usr/local/include/pal/graphics/WebGPU -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/local/include/pal/graphics/WebGPU -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/usr/local/include/WebKitAdditions -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/local/include/WebKitAdditions -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/usr/local/include/webrtc -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/local/include/webrtc -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/usr/local/include/webm -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/local/include/webm -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/Source/WebKit -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release/WebKit.build/DerivedSources-normal/arm64 -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release/WebKit.build/DerivedSources/arm64 -I /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release/WebKit.build/DerivedSources -F/Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks -D __STDC_WANT_LIB_EXT1__=1 -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/local/include -internal-isystem /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/llvm-project/build/lib/clang/21/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/System/Library/Frameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/System/Library/SubFrameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/Library/Frameworks -Wno-trigraphs -Werror -Wno-missing-field-initializers -Wmissing-prototypes -Wunreachable-code -Wno-implicit-atomic-properties -Wno-objc-interface-ivars -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wnon-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wsign-compare -Wno-shorten-64-to-32 -Wnewline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -Wno-c++11-extensions -Wno-implicit-fallthrough -Wprotocol -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wall -Wc99-designator -Wconditional-uninitialized -Wextra -Wdeprecated-enum-enum-conversion -Wdeprecated-enum-float-conversion -Wenum-float-conversion -Wfinal-dtor-non-final-class -Wformat=2 -Wmisleading-indentation -Wpointer-to-int-cast -Wreorder-init-list -Wundef -Wunused-but-set-variable -Wvla -Werror=unguarded-availability -Wno-elaborated-enum-base -Wno-unused-parameter -Wcast-qual -Wchar-subscripts -Wextra-tokens -Winit-self -Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough -Wvla -Wliteral-conversion -Wthread-safety -Wno-profile-instr-out-of-date -Wno-profile-instr-unprofiled -Wno-backend-plugin -Wunsafe-buffer-usage -Wno-unknown-warning-option -Wno-missing-field-initializers -Wno-nullability-completeness -std=c++2b -fdeprecated-macro -ferror-limit 19 -fmacro-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden -stack-protector 1 -fblocks -fencode-extended-block-signature -fno-rtti -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fno-implicit-modules -fskip-odr-check-in-gmf -fobjc-runtime=macosx-15.5.0 -fobjc-weak -fobjc-exceptions -fexceptions -fpascal-strings -fmax-type-align=16 -fdiagnostics-show-note-include-stack -vectorize-loops -vectorize-slp -fsafe-buffer-usage-suggestions -analyzer-output=html -analyzer-config report-in-main-source-file=true -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -analyzer-checker optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker security.insecureAPI.UncheckedReturn -analyzer-checker security.insecureAPI.getpw -analyzer-checker security.insecureAPI.gets -analyzer-checker security.insecureAPI.mkstemp -analyzer-checker security.insecureAPI.mktemp -analyzer-disable-checker security.insecureAPI.rand -analyzer-disable-checker security.insecureAPI.strcpy -analyzer-checker security.insecureAPI.vfork -analyzer-disable-checker alpha,apiModeling,core,cplusplus,deadcode,debug,fuchsia,nullability,optin,osx,security,unix,webkit -analyzer-checker alpha.webkit.ForwardDeclChecker,alpha.webkit.MemoryUnsafeCastChecker,alpha.webkit.NoDeleteChecker,alpha.webkit.NoUncheckedPtrMemberChecker,alpha.webkit.NoUnretainedMemberChecker,alpha.webkit.RetainPtrCtorAdoptChecker,alpha.webkit.UncheckedCallArgsChecker,alpha.webkit.UncheckedLocalVarsChecker,alpha.webkit.UncountedCallArgsChecker,alpha.webkit.UncountedLocalVarsChecker,alpha.webkit.UnretainedCallArgsChecker,alpha.webkit.UnretainedLambdaCapturesChecker,alpha.webkit.UnretainedLocalVarsChecker,webkit.NoUncountedMemberChecker,webkit.RefCntblBaseVirtualDtor,webkit.UncountedLambdaCapturesChecker -analyzer-config max-nodes=10000000 -analyzer-config verbose-report-filename=true -fdwarf2-cfi-asm -o /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/WebKit/WebKit/normal/arm64/UnifiedSource74-nonARC.plist -x objective-c++ /Volumes/Data/worker/macOS-Safer-CPP-Checks-EWS/build/WebKitBuild/Release/DerivedSources/WebKit/unified-sources/UnifiedSource74-nonARC.mm
| 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 | #import "config.h" |
| 27 | #import "WebDragClient.h" |
| 28 | |
| 29 | #if ENABLE(DRAG_SUPPORT) |
| 30 | |
| 31 | #import "MessageSenderInlines.h" |
| 32 | #import "PasteboardTypes.h" |
| 33 | #import "WebPage.h" |
| 34 | #import "WebPageProxyMessages.h" |
| 35 | #import <CoreGraphics/CGContext.h> |
| 36 | #import <WebCore/CachedImage.h> |
| 37 | #import <WebCore/ContainerNodeInlines.h> |
| 38 | #import <WebCore/DocumentPage.h> |
| 39 | #import <WebCore/DragController.h> |
| 40 | #import <WebCore/Editor.h> |
| 41 | #import <WebCore/ElementInlines.h> |
| 42 | #import <WebCore/FrameDestructionObserverInlines.h> |
| 43 | #import <WebCore/FrameIdentifier.h> |
| 44 | #import <WebCore/FrameView.h> |
| 45 | #import <WebCore/GraphicsContextCG.h> |
| 46 | #import <WebCore/LegacyWebArchive.h> |
| 47 | #import <WebCore/LocalCurrentGraphicsContext.h> |
| 48 | #import <WebCore/LocalFrame.h> |
| 49 | #import <WebCore/NotImplemented.h> |
| 50 | #import <WebCore/Page.h> |
| 51 | #import <WebCore/PagePasteboardContext.h> |
| 52 | #import <WebCore/Pasteboard.h> |
| 53 | #import <WebCore/RenderImage.h> |
| 54 | #import <WebCore/ShareableBitmap.h> |
| 55 | #import <WebCore/StringTruncator.h> |
| 56 | #import <wtf/StdLibExtras.h> |
| 57 | #import <wtf/cocoa/NSURLExtras.h> |
| 58 | |
| 59 | #if PLATFORM(IOS_FAMILY) |
| 60 | #import "UIKitSPI.h" |
| 61 | #endif |
| 62 | |
| 63 | namespace WebKit { |
| 64 | using namespace WebCore; |
| 65 | |
| 66 | #if USE(APPKIT) |
| 67 | using DragImage = NSImage *; |
| 68 | #else |
| 69 | using DragImage = CGImageRef; |
| 70 | #endif |
| 71 | |
| 72 | static RefPtr<ShareableBitmap> convertDragImageToBitmap(DragImage image, const IntSize& size, Frame& frame) |
| 73 | { |
| 74 | auto bitmap = ShareableBitmap::create({ size, screenColorSpace(protect(protect(frame.mainFrame())->virtualView()).get()) }); |
| 75 | if (!bitmap) |
| 76 | return nullptr; |
| 77 | |
| 78 | auto graphicsContext = bitmap->createGraphicsContext(); |
| 79 | if (!graphicsContext) |
| 80 | return nullptr; |
| 81 | |
| 82 | LocalCurrentGraphicsContext savedContext(*graphicsContext); |
| 83 | #if USE(APPKIT) |
| 84 | [image drawInRect:NSMakeRect(0, 0, bitmap->size().width(), bitmap->size().height()) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1 respectFlipped:YES hints:nil]; |
| 85 | #else |
| 86 | CGContextDrawImage(protect(graphicsContext->platformContext()).get(), CGRectMake(0, 0, size.width(), size.height()), image); |
| 87 | #endif |
| 88 | |
| 89 | return bitmap; |
| 90 | } |
| 91 | |
| 92 | void WebDragClient::startDrag(DragItem dragItem, DataTransfer&, Frame& frame, const std::optional<NodeIdentifier>& nodeID) |
| 93 | { |
| 94 | auto& image = dragItem.image; |
| 95 | |
| 96 | #if USE(APPKIT) |
| 97 | IntSize bitmapSize([image.get() size]); |
| 98 | #else |
| 99 | IntSize bitmapSize(CGImageGetWidth(image.get().get()), CGImageGetHeight(image.get().get())); |
| 100 | #endif |
| 101 | auto bitmap = convertDragImageToBitmap(image.get().get(), bitmapSize, frame); |
| 102 | if (!bitmap) |
| 103 | return; |
| 104 | auto handle = bitmap->createHandle(); |
| 105 | if (!handle) |
| 106 | return; |
| 107 | |
| 108 | m_page->willStartDrag(); |
| 109 | m_page->send(Messages::WebPageProxy::StartDrag(dragItem, WTF::move(*handle), nodeID, frame.frameID())); |
| 110 | } |
| 111 | |
| 112 | void WebDragClient::didConcludeEditDrag() |
| 113 | { |
| 114 | #if PLATFORM(IOS_FAMILY) |
| 115 | protect(m_page)->didConcludeEditDrag(); |
| 116 | #endif |
| 117 | } |
| 118 | |
| 119 | #if USE(APPKIT) |
| 120 | |
| 121 | static WebCore::CachedImage* cachedImage(Element& element) |
| 122 | { |
| 123 | CheckedPtr renderImage = dynamicDowncast<WebCore::RenderImage>(element.renderer()); |
| 124 | if (!renderImage) |
| 125 | return nullptr; |
| 126 | auto* image = renderImage->cachedImage(); |
| 127 | if (!image || image->errorOccurred()) |
| 128 | return nullptr; |
| 129 | return image; |
| 130 | } |
| 131 | |
| 132 | void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& label, LocalFrame*) |
| 133 | { |
| 134 | ASSERT(pasteboardName == String(NSPasteboardNameDrag)); |
| 135 | |
| 136 | WebCore::CachedImage* image = cachedImage(element); |
| Local variable 'image' is uncounted and unsafe |
| 137 | |
| 138 | String extension; |
| 139 | if (image) { |
| 140 | extension = protect(image->image())->filenameExtension(); |
| 141 | if (extension.isEmpty()) |
| 142 | return; |
| 143 | } |
| 144 | |
| 145 | String title = label; |
| 146 | if (title.isEmpty()) { |
| 147 | title = url.lastPathComponent().toString(); |
| 148 | if (title.isEmpty()) |
| 149 | title = WTF::userVisibleString(url.createNSURL().get()); |
| 150 | } |
| 151 | |
| 152 | auto archive = LegacyWebArchive::create(element); |
| 153 | |
| 154 | RetainPtr response = image->response().nsURLResponse(); |
| 155 | |
| 156 | RefPtr imageBuffer = image->image()->data(); |
| 157 | |
| 158 | std::optional<SharedMemory::Handle> imageHandle; |
| 159 | { |
| 160 | auto sharedMemoryBuffer = SharedMemory::copyBuffer(imageBuffer.releaseNonNull()); |
| 161 | if (!sharedMemoryBuffer) |
| 162 | return; |
| 163 | imageHandle = sharedMemoryBuffer->createHandle(SharedMemory::Protection::ReadOnly); |
| 164 | if (!imageHandle) |
| 165 | return; |
| 166 | } |
| 167 | RetainPtr<CFDataRef> data = archive ? archive->rawDataRepresentation() : 0; |
| 168 | std::optional<SharedMemory::Handle> archiveHandle; |
| 169 | if (data) { |
| 170 | auto archiveBuffer = SharedBuffer::create((__bridge NSData *)data.get()); |
| 171 | auto archiveSharedMemoryBuffer = SharedMemory::copyBuffer(archiveBuffer.get()); |
| 172 | if (!archiveSharedMemoryBuffer) |
| 173 | return; |
| 174 | archiveHandle = archiveSharedMemoryBuffer->createHandle(SharedMemory::Protection::ReadOnly); |
| 175 | if (!archiveHandle) |
| 176 | return; |
| 177 | } |
| 178 | |
| 179 | String filename = String([response suggestedFilename]); |
| 180 | if (m_page->isInspectorPage()) { |
| 181 | String downloadFilename = ResourceResponseBase::sanitizeSuggestedFilename(element.attributeWithoutSynchronization(HTMLNames::filenameAttr)); |
| 182 | if (!downloadFilename.isEmpty()) |
| 183 | filename = downloadFilename; |
| 184 | } |
| 185 | |
| 186 | m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, WTF::move(*imageHandle), filename, extension, title, String([[response URL] absoluteString]), WTF::userVisibleString(url.createNSURL().get()), WTF::move(*archiveHandle), protect(element.document())->originIdentifierForPasteboard())); |
| 187 | } |
| 188 | |
| 189 | #else |
| 190 | |
| 191 | void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Element& element, const URL& url, const String& label, LocalFrame*) |
| 192 | { |
| 193 | if (RefPtr frame = element.document().frame()) |
| 194 | protect(frame->editor())->writeImageToPasteboard(*Pasteboard::createForDragAndDrop(PagePasteboardContext::create(frame->pageID())), element, url, label); |
| 195 | } |
| 196 | |
| 197 | #endif // USE(APPKIT) |
| 198 | |
| 199 | } |
| 200 | |
| 201 | #endif // ENABLE(DRAG_SUPPORT) |