clang -cc1 -cc1 -triple arm64-apple-ios26.2.0-simulator -Os -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name UnifiedSource60.cpp -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=26.2 -fdepfile-entry=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/SDKSettings.json -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/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebKit -target-linker-version 1230.1 -fcoverage-compilation-dir=/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebKit -resource-dir /Users/buildbot/Library/Developer/Toolchains/swift-webkit.xctoolchain/usr/lib/clang/21 -dependency-file /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/WebKit/WebKit/normal/arm64/UnifiedSource60.d -skip-unused-modulemap-deps -MT dependencies -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk -iquote /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/WebKit-generated-files.hmap -iquote /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/WebKit-project-headers.hmap -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/usr/local/include -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/SDKAdditions/usr/include -iframework /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/SDKAdditions/System/Library/Frameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/PrivateFrameworks -isystem /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/usr/local/include -include-pch /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/PrecompiledHeaders/SharedPrecompiledHeaders/12151610001510045616/WebKit2Prefix.h.gch -D _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D NDEBUG -D HAVE_CORE_PREDICTION -D ENABLE_LOWER_FORMATREADERBUNDLE_CODESIGNING_REQUIREMENTS -D WEBKIT_BUNDLE_VERSION="625.1.10+" -D FRAMEWORK_NAME=WebKit -D __clang_analyzer__ -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/WebKit-own-target-headers.hmap -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/WebKit-all-target-headers.hmap -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/WebCore.framework/PrivateHeaders/ForwardingHeaders -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/WebKit -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/WebKit/IPC -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/pal/graphics/WebGPU -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/pal/graphics/WebGPU -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/WebKitAdditions -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/WebKitAdditions -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/webrtc -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/webrtc -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/usr/local/include/webm -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include/webm -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/Source/WebKit -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/DerivedSources-normal/arm64 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/DerivedSources/arm64 -I /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/WebKit.build/Release-iphonesimulator/WebKit.build/DerivedSources -F/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator -F/Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitLibraries/SDKs/iphonesimulator26.0-additions.sdk/System/Library/PrivateFrameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/PrivateFrameworks -D __STDC_WANT_LIB_EXT1__=1 -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/local/include -internal-isystem /Users/buildbot/Library/Developer/Toolchains/swift-webkit.xctoolchain/usr/lib/clang/21/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/usr/include -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/Frameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/System/Library/SubFrameworks -internal-iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.2.sdk/Library/Frameworks -Wno-trigraphs -Werror -Wno-missing-field-initializers -Wmissing-prototypes -Wunreachable-code -Wnon-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -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-c++11-extensions -Wno-implicit-fallthrough -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 -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/Apple-iOS-26-Safer-CPP-Checks-EWS/build/scan-build-output/StaticAnalyzer/WebKit/WebKit/normal/arm64/UnifiedSource60.plist -x c++ /Volumes/Data/worker/Apple-iOS-26-Safer-CPP-Checks-EWS/build/WebKitBuild/Release-iphonesimulator/DerivedSources/WebKit/unified-sources/UnifiedSource60.cpp
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | #include "config.h" |
| 22 | #include "WebHitTestResultData.h" |
| 23 | |
| 24 | #include "ShareableBitmapUtilities.h" |
| 25 | #include "WebFrame.h" |
| 26 | #include <WebCore/DocumentView.h> |
| 27 | #include <WebCore/ElementInlines.h> |
| 28 | #include <WebCore/EventHandler.h> |
| 29 | #include <WebCore/FrameDestructionObserverInlines.h> |
| 30 | #include <WebCore/HitTestResult.h> |
| 31 | #include <WebCore/LocalFrame.h> |
| 32 | #include <WebCore/LocalFrameView.h> |
| 33 | #include <WebCore/NavigationAction.h> |
| 34 | #include <WebCore/Node.h> |
| 35 | #include <WebCore/RenderImage.h> |
| 36 | #include <WebCore/SharedBuffer.h> |
| 37 | #include <WebCore/Text.h> |
| 38 | #include <wtf/URL.h> |
| 39 | #include <wtf/text/WTFString.h> |
| 40 | |
| 41 | namespace WebKit { |
| 42 | using namespace WebCore; |
| 43 | |
| 44 | static WebHitTestResultData::ElementType elementTypeFromHitTestResult(const HitTestResult& hitTestResult) |
| 45 | { |
| 46 | if (!hitTestResult.hasMediaElement()) |
| 47 | return WebHitTestResultData::ElementType::None; |
| 48 | |
| 49 | return hitTestResult.mediaIsVideo() ? WebHitTestResultData::ElementType::Video : WebHitTestResultData::ElementType::Audio; |
| 50 | } |
| 51 | |
| 52 | static RefPtr<WebFrame> webFrameFromHitTestResult(const HitTestResult& hitTestResult) |
| 53 | { |
| 54 | RefPtr coreFrame = hitTestResult.frame(); |
| 55 | if (!coreFrame) |
| 56 | return nullptr; |
| 57 | |
| 58 | return WebFrame::fromCoreFrame(*coreFrame); |
| 59 | } |
| 60 | |
| 61 | static std::optional<ResourceResponse> linkLocalResourceFromHitTestResult(const HitTestResult& hitTestResult) |
| 62 | { |
| 63 | if (!hitTestResult.hasLocalDataForLinkURL()) |
| 64 | return std::nullopt; |
| 65 | |
| 66 | RefPtr webFrame = webFrameFromHitTestResult(hitTestResult); |
| 67 | if (!webFrame) |
| 68 | return std::nullopt; |
| 69 | |
| 70 | return webFrame->resourceResponseForURL(hitTestResult.absoluteLinkURL()); |
| 71 | } |
| 72 | |
| 73 | static String imageSuggestedFilenameFromHitTestResult(const HitTestResult& hitTestResult) |
| 74 | { |
| 75 | if (!hitTestResult.hasEntireImage()) |
| 76 | return nullString(); |
| 77 | |
| 78 | RefPtr webFrame = webFrameFromHitTestResult(hitTestResult); |
| 79 | if (!webFrame) |
| 80 | return nullString(); |
| 81 | |
| 82 | return webFrame->suggestedFilenameForResourceWithURL(hitTestResult.absoluteImageURL()); |
| 83 | } |
| 84 | |
| 85 | WebHitTestResultData::WebHitTestResultData() = default; |
| 86 | |
| 87 | WebHitTestResultData::WebHitTestResultData(const HitTestResult& hitTestResult, const String& tooltipText, bool includeImage) |
| 88 | : absoluteImageURL(hitTestResult.absoluteImageURL().string()) |
| 89 | , absolutePDFURL(hitTestResult.absolutePDFURL().string()) |
| 90 | , absoluteLinkURL(hitTestResult.absoluteLinkURL().string()) |
| 91 | , absoluteMediaURL(hitTestResult.absoluteMediaURL().string()) |
| 92 | , linkLabel(hitTestResult.textContent()) |
| 93 | , linkTitle(hitTestResult.titleDisplayString()) |
| 94 | , linkSuggestedFilename(hitTestResult.linkSuggestedFilename()) |
| 95 | , imageSuggestedFilename(imageSuggestedFilenameFromHitTestResult(hitTestResult)) |
| 96 | , isContentEditable(hitTestResult.isContentEditable()) |
| 97 | , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult)) |
| 98 | , isScrollbar(IsScrollbar::No) |
| 99 | , isSelected(hitTestResult.isSelected()) |
| 100 | , isTextNode(is<Text>(hitTestResult.innerNode())) |
| 101 | , isOverTextInsideFormControlElement(hitTestResult.isOverTextInsideFormControlElement()) |
| 102 | , isDownloadableMedia(hitTestResult.isDownloadableMedia()) |
| 103 | , mediaIsInFullscreen(hitTestResult.mediaIsInFullscreen()) |
| 104 | , isActivePDFAnnotation(false) |
| 105 | , elementType(elementTypeFromHitTestResult(hitTestResult)) |
| 106 | , frameInfo(frameInfoDataFromHitTestResult(hitTestResult)) |
| 107 | , targetFrame(hitTestResult.targetFrame() ? std::optional(hitTestResult.targetFrame()->frameID()) : std::nullopt) |
| 108 | , tooltipText(tooltipText) |
| 109 | , hasEntireImage(hitTestResult.hasEntireImage()) |
| 110 | , allowsFollowingLink(hitTestResult.allowsFollowingLink()) |
| 111 | , allowsFollowingImageURL(hitTestResult.allowsFollowingImageURL()) |
| 112 | , linkLocalResourceResponse(linkLocalResourceFromHitTestResult(hitTestResult)) |
| 113 | { |
| 114 | if (auto* scrollbar = hitTestResult.scrollbar()) |
| 115 | isScrollbar = scrollbar->orientation() == ScrollbarOrientation::Horizontal ? IsScrollbar::Horizontal : IsScrollbar::Vertical; |
| 116 | |
| 117 | if (!includeImage) |
| 118 | return; |
| 119 | |
| 120 | if (RefPtr image = hitTestResult.image()) { |
| 121 | if (RefPtr buffer = image->data()) |
| 122 | imageSharedMemory = WebCore::SharedMemory::copyBuffer(*buffer); |
| 123 | } |
| 124 | |
| 125 | if (RefPtr target = hitTestResult.innerNonSharedNode()) { |
| 126 | if (CheckedPtr renderer = dynamicDowncast<RenderImage>(target->renderer())) { |
| 127 | imageBitmap = createShareableBitmap(*renderer); |
| 128 | if (auto* cachedImage = renderer->cachedImage()) { |
| Local variable 'cachedImage' is uncounted and unsafe |
| 129 | if (RefPtr image = cachedImage->image()) |
| 130 | sourceImageMIMEType = image->mimeType(); |
| 131 | } |
| 132 | |
| 133 | imageText = [&]() -> String { |
| 134 | if (RefPtr element = dynamicDowncast<Element>(target.get())) { |
| 135 | auto& title = element->attributeWithoutSynchronization(HTMLNames::titleAttr); |
| 136 | if (!title.isEmpty()) |
| 137 | return title; |
| 138 | } |
| 139 | |
| 140 | return renderer->altText(); |
| 141 | }(); |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | WebHitTestResultData::WebHitTestResultData(const HitTestResult& hitTestResult, const String& tooltipText) |
| 147 | : WebHitTestResultData(hitTestResult, tooltipText, false) { } |
| 148 | |
| 149 | WebHitTestResultData::WebHitTestResultData(const HitTestResult& hitTestResult, bool includeImage) |
| 150 | : WebHitTestResultData(hitTestResult, String(), includeImage) { } |
| 151 | |
| 152 | WebHitTestResultData::WebHitTestResultData(const String& absoluteImageURL, const String& absolutePDFURL, const String& absoluteLinkURL, const String& absoluteMediaURL, const String& linkLabel, const String& linkTitle, const String& linkSuggestedFilename, const String& imageSuggestedFilename, bool isContentEditable, const WebCore::IntRect& elementBoundingBox, const WebKit::WebHitTestResultData::IsScrollbar& isScrollbar, bool isSelected, bool isTextNode, bool isOverTextInsideFormControlElement, bool isDownloadableMedia, bool mediaIsInFullscreen, bool isActivePDFAnnotation, const WebHitTestResultData::ElementType& elementType, std::optional<FrameInfoData>&& frameInfo, std::optional<WebCore::FrameIdentifier> targetFrame, std::optional<WebCore::RemoteUserInputEventData> remoteUserInputEventData, const String& lookupText, const String& tooltipText, const String& imageText, std::optional<WebCore::SharedMemory::Handle>&& imageHandle, const RefPtr<WebCore::ShareableBitmap>& imageBitmap, const String& sourceImageMIMEType, bool hasEntireImage, bool allowsFollowingLink, bool allowsFollowingImageURL, std::optional<WebCore::ResourceResponse>&& linkLocalResourceResponse, |
| 153 | #if PLATFORM(MAC) |
| 154 | const WebHitTestResultPlatformData& platformData, |
| 155 | #endif |
| 156 | const WebCore::DictionaryPopupInfo& dictionaryPopupInfo, const RefPtr<WebCore::TextIndicator>& linkTextIndicator) |
| 157 | : absoluteImageURL(absoluteImageURL) |
| 158 | , absolutePDFURL(absolutePDFURL) |
| 159 | , absoluteLinkURL(absoluteLinkURL) |
| 160 | , absoluteMediaURL(absoluteMediaURL) |
| 161 | , linkLabel(linkLabel) |
| 162 | , linkTitle(linkTitle) |
| 163 | , linkSuggestedFilename(linkSuggestedFilename) |
| 164 | , imageSuggestedFilename(imageSuggestedFilename) |
| 165 | , isContentEditable(isContentEditable) |
| 166 | , elementBoundingBox(elementBoundingBox) |
| 167 | , isScrollbar(isScrollbar) |
| 168 | , isSelected(isSelected) |
| 169 | , isTextNode(isTextNode) |
| 170 | , isOverTextInsideFormControlElement(isOverTextInsideFormControlElement) |
| 171 | , isDownloadableMedia(isDownloadableMedia) |
| 172 | , mediaIsInFullscreen(mediaIsInFullscreen) |
| 173 | , isActivePDFAnnotation(isActivePDFAnnotation) |
| 174 | , elementType(elementType) |
| 175 | , frameInfo(WTF::move(frameInfo)) |
| 176 | , targetFrame(targetFrame) |
| 177 | , remoteUserInputEventData(remoteUserInputEventData) |
| 178 | , lookupText(lookupText) |
| 179 | , tooltipText(tooltipText) |
| 180 | , imageText(imageText) |
| 181 | , imageBitmap(imageBitmap) |
| 182 | , sourceImageMIMEType(sourceImageMIMEType) |
| 183 | , hasEntireImage(hasEntireImage) |
| 184 | , allowsFollowingLink(allowsFollowingLink) |
| 185 | , allowsFollowingImageURL(allowsFollowingImageURL) |
| 186 | , linkLocalResourceResponse(linkLocalResourceResponse) |
| 187 | #if PLATFORM(MAC) |
| 188 | , platformData(platformData) |
| 189 | #endif |
| 190 | , dictionaryPopupInfo(dictionaryPopupInfo) |
| 191 | , linkTextIndicator(linkTextIndicator) |
| 192 | { |
| 193 | if (imageHandle) |
| 194 | imageSharedMemory = WebCore::SharedMemory::map(WTF::move(*imageHandle), WebCore::SharedMemory::Protection::ReadOnly); |
| 195 | } |
| 196 | |
| 197 | WebHitTestResultData::~WebHitTestResultData() |
| 198 | { |
| 199 | } |
| 200 | |
| 201 | IntRect WebHitTestResultData::elementBoundingBoxInWindowCoordinates(const WebCore::HitTestResult& hitTestResult) |
| 202 | { |
| 203 | RefPtr node = hitTestResult.innerNonSharedNode(); |
| 204 | if (!node) |
| 205 | return IntRect(); |
| 206 | |
| 207 | RefPtr frame = node->document().frame(); |
| 208 | if (!frame) |
| 209 | return IntRect(); |
| 210 | |
| 211 | RefPtr view = frame->view(); |
| 212 | if (!view) |
| 213 | return IntRect(); |
| 214 | |
| 215 | CheckedPtr renderer = node->renderer(); |
| 216 | if (!renderer) |
| 217 | return IntRect(); |
| 218 | |
| 219 | return view->contentsToWindow(renderer->absoluteBoundingBoxRect()); |
| 220 | } |
| 221 | |
| 222 | std::optional<WebCore::SharedMemory::Handle> WebHitTestResultData::getImageSharedMemoryHandle() const |
| 223 | { |
| 224 | std::optional<WebCore::SharedMemory::Handle> imageHandle = std::nullopt; |
| 225 | if (RefPtr memory = imageSharedMemory; memory && !memory->span().empty()) { |
| 226 | if (auto handle = memory->createHandle(WebCore::SharedMemory::Protection::ReadOnly)) |
| 227 | imageHandle = WTF::move(*handle); |
| 228 | } |
| 229 | return imageHandle; |
| 230 | } |
| 231 | |
| 232 | std::optional<FrameInfoData> WebHitTestResultData::frameInfoDataFromHitTestResult(const WebCore::HitTestResult& hitTestResult) |
| 233 | { |
| 234 | RefPtr webFrame = webFrameFromHitTestResult(hitTestResult); |
| 235 | if (!webFrame) |
| 236 | return std::nullopt; |
| 237 | |
| 238 | return webFrame->info(); |
| 239 | } |
| 240 | |
| 241 | } |