haikuwebkit/Source/WTF/wtf/URLHelpers.h

49 lines
2.1 KiB
C
Raw Permalink Normal View History

[GTK][WPE] Need a function to convert internal URI to display ("pretty") URI https://bugs.webkit.org/show_bug.cgi?id=174816 Patch by Ms2ger <Ms2ger@igalia.com> on 2019-02-04 Reviewed by Michael Catanzaro. Source/WebCore: Tests: enabled fast/url/user-visible/. * testing/Internals.cpp: (WebCore::Internals::userVisibleString): Enable method on all platforms. Source/WebKit: Add webkit_uri_for_display for GTK and WPE. * PlatformGTK.cmake: * PlatformWPE.cmake: * SourcesGTK.txt: * SourcesWPE.txt: * UIProcess/API/glib/WebKitURIUtilities.cpp: Added. (webkit_uri_for_display): * UIProcess/API/gtk/WebKitURIUtilities.h: Added. * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: * UIProcess/API/gtk/webkit2.h: * UIProcess/API/wpe/WebKitURIUtilities.h: Added. * UIProcess/API/wpe/docs/wpe-0.1-sections.txt: * UIProcess/API/wpe/docs/wpe-docs.sgml: * UIProcess/API/wpe/webkit.h: Source/WTF: Translate userVisibleString and dependent code into platform-neutral C++ in wtf/URLHelpers.{h,cpp}. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/URLHelpers.cpp: Added. (WTF::URLHelpers::loadIDNScriptWhiteList): (WTF::URLHelpers::isArmenianLookalikeCharacter): (WTF::URLHelpers::isArmenianScriptCharacter): (WTF::URLHelpers::isASCIIDigitOrValidHostCharacter): (WTF::URLHelpers::isLookalikeCharacter): (WTF::URLHelpers::whiteListIDNScript): (WTF::URLHelpers::initializeDefaultIDNScriptWhiteList): (WTF::URLHelpers::allCharactersInIDNScriptWhiteList): (WTF::URLHelpers::isSecondLevelDomainNameAllowedByTLDRules): (WTF::URLHelpers::isRussianDomainNameCharacter): (WTF::URLHelpers::allCharactersAllowedByTLDRules): (WTF::URLHelpers::mapHostName): (WTF::URLHelpers::collectRangesThatNeedMapping): (WTF::URLHelpers::applyHostNameFunctionToMailToURLString): (WTF::URLHelpers::applyHostNameFunctionToURLString): (WTF::URLHelpers::mapHostNames): (WTF::URLHelpers::createStringWithEscapedUnsafeCharacters): (WTF::URLHelpers::toNormalizationFormC): (WTF::URLHelpers::userVisibleURL): * wtf/URLHelpers.h: Added. * wtf/cocoa/NSURLExtras.mm: (WTF::URLHelpers::loadIDNScriptWhiteList): (WTF::decodePercentEscapes): (WTF::decodeHostName): (WTF::encodeHostName): (WTF::URLWithUserTypedString): (WTF::userVisibleString): Tools: Add tests for webkit_uri_for_display(). * TestWebKitAPI/Tests/WebKitGLib/TestWebKitURIUtilities.cpp: Added. (testURIForDisplayUnaffected): (testURIForDisplayAffected): (beforeAll): (afterAll): * TestWebKitAPI/glib/CMakeLists.txt: LayoutTests: * TestExpectations: Enable fast/url/user-visible/. Canonical link: https://commits.webkit.org/208722@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-05 04:04:30 +00:00
/*
* Copyright (C) 2005, 2007, 2014 Apple Inc. All rights reserved.
* Copyright (C) 2018 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.
* 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE 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 APPLE 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.
*/
#pragma once
Remove <wtf/Optional.h> https://bugs.webkit.org/show_bug.cgi?id=226437 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Remove include of <wtf/Optional.h>. * inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py: (CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes): Don't generate an include of wtf/Optional.h; including WTFString.h takes care of this anyway. * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py: (CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes): Ditto. * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator._generate_secondary_header_includes): Ditto. * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: (CppProtocolTypesImplementationGenerator.generate_output): Generate an include of <optional> instead of <wtf/Optional.h>. * inspector/scripts/tests/expected/*: Regenerate. Source/WebCore: * <many files>: Removed include of <wtf/Optional.h>. * platform/graphics/Font.h: Tweaked style a bit. * Modules/geolocation/GeolocationClient.h: Added include of <optional>. * Modules/mediastream/DoubleRange.h: Ditto. * Modules/mediastream/LongRange.h: Ditto. * Modules/webauthn/AuthenticationExtensionsClientOutputs.h: Ditto. * css/CSSToLengthConversionData.h: Ditto. * css/DOMMatrix2DInit.h: Ditto. * dom/AddEventListenerOptions.h: Ditto. * dom/DeviceMotionData.h: Ditto. * dom/DeviceOrientationData.h: Ditto. * dom/SuccessOr.h: Ditto. * html/DateTimeFieldsState.h: Ditto. * html/ImageBitmapOptions.h: Ditto. * html/canvas/PredefinedColorSpace.h: Ditto. * layout/LayoutPhase.h: Ditto. * layout/MarginTypes.h: Ditto. * loader/ResourceLoadNotifier.h: Ditto. * page/RuntimeEnabledFeatures.h: Ditto. * page/ScrollOptions.h: Ditto. * platform/MediaCapabilitiesInfo.h: Ditto. * platform/cocoa/SystemBattery.h: Ditto. * platform/graphics/DecodingOptions.h: Ditto. * platform/graphics/DestinationColorSpace.h: Ditto. * platform/graphics/DisplayRefreshMonitorClient.h: Ditto. * platform/graphics/FloatLine.h: Ditto. * platform/graphics/gpu/GPURequestAdapterOptions.h: Ditto. * platform/graphics/x11/PlatformDisplayX11.h: Ditto. * platform/ios/SelectionGeometry.h: Ditto. * platform/mac/NSScrollerImpDetails.h: Ditto. * platform/network/DNS.h: Ditto. * platform/text/EncodingTables.h: Ditto. * platform/text/TextCodecCJK.h: Ditto. * platform/text/TextCodecUTF16.h: Ditto. * platform/text/TextFlags.h: Ditto. Source/WebCore/PAL: * pal/SessionID.h: Include <optional>. * pal/crypto/gcrypt/Utilities.h: Ditto. * pal/crypto/tasn1/Utilities.cpp: Removed include of <wtf/Optional.h>. Source/WebDriver: * SessionHost.h: Removed include of <wtf/Optional.h>. Source/WebKit: * <many files>: Removed include of <wtf/Optional.h>. Source/WebKitLegacy/mac: * DOM/DOMRangeInternal.h: Added import of <optional>. * WebView/WebGeolocationPosition.mm: Removed import of <wtf/Optional.h>. * WebView/WebGeolocationPositionInternal.h: Added import of <optional>. Source/WTF: * <many files>: Removed include of <wtf/Optional.h>. * WTF.xcodeproj/project.pbxproj: Removed Optional.h. * wtf/Markable.h: Added include of <optional>. * wtf/OptionSet.h: Ditto. * wtf/Optional.h: Emptied this file. On the Windows build system, we can't seem to build successfully without an empty file here. The copied forwarding header seems to linger even if we remove the original. Until we fix the Windows build system, if we want to support incremental builds, we need to keep this empty file around. * wtf/PrintStream.h: Added include of <optional>. * wtf/Seconds.h: Ditto. * wtf/StackTrace.h: Ditto. * wtf/StdLibExtras.h: Moved the valueOrCompute function here from Optional.h. Re-sorted the "using" at the bottom of the file. * wtf/URLHelpers.h: Added include of <optional>. * wtf/Vector.h: Ditto. Tools: * <many files>: Removed include of <wtf/Optional.h>. Canonical link: https://commits.webkit.org/238372@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 06:45:51 +00:00
#include <optional>
[GTK][WPE] Need a function to convert internal URI to display ("pretty") URI https://bugs.webkit.org/show_bug.cgi?id=174816 Patch by Ms2ger <Ms2ger@igalia.com> on 2019-02-04 Reviewed by Michael Catanzaro. Source/WebCore: Tests: enabled fast/url/user-visible/. * testing/Internals.cpp: (WebCore::Internals::userVisibleString): Enable method on all platforms. Source/WebKit: Add webkit_uri_for_display for GTK and WPE. * PlatformGTK.cmake: * PlatformWPE.cmake: * SourcesGTK.txt: * SourcesWPE.txt: * UIProcess/API/glib/WebKitURIUtilities.cpp: Added. (webkit_uri_for_display): * UIProcess/API/gtk/WebKitURIUtilities.h: Added. * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: * UIProcess/API/gtk/webkit2.h: * UIProcess/API/wpe/WebKitURIUtilities.h: Added. * UIProcess/API/wpe/docs/wpe-0.1-sections.txt: * UIProcess/API/wpe/docs/wpe-docs.sgml: * UIProcess/API/wpe/webkit.h: Source/WTF: Translate userVisibleString and dependent code into platform-neutral C++ in wtf/URLHelpers.{h,cpp}. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/URLHelpers.cpp: Added. (WTF::URLHelpers::loadIDNScriptWhiteList): (WTF::URLHelpers::isArmenianLookalikeCharacter): (WTF::URLHelpers::isArmenianScriptCharacter): (WTF::URLHelpers::isASCIIDigitOrValidHostCharacter): (WTF::URLHelpers::isLookalikeCharacter): (WTF::URLHelpers::whiteListIDNScript): (WTF::URLHelpers::initializeDefaultIDNScriptWhiteList): (WTF::URLHelpers::allCharactersInIDNScriptWhiteList): (WTF::URLHelpers::isSecondLevelDomainNameAllowedByTLDRules): (WTF::URLHelpers::isRussianDomainNameCharacter): (WTF::URLHelpers::allCharactersAllowedByTLDRules): (WTF::URLHelpers::mapHostName): (WTF::URLHelpers::collectRangesThatNeedMapping): (WTF::URLHelpers::applyHostNameFunctionToMailToURLString): (WTF::URLHelpers::applyHostNameFunctionToURLString): (WTF::URLHelpers::mapHostNames): (WTF::URLHelpers::createStringWithEscapedUnsafeCharacters): (WTF::URLHelpers::toNormalizationFormC): (WTF::URLHelpers::userVisibleURL): * wtf/URLHelpers.h: Added. * wtf/cocoa/NSURLExtras.mm: (WTF::URLHelpers::loadIDNScriptWhiteList): (WTF::decodePercentEscapes): (WTF::decodeHostName): (WTF::encodeHostName): (WTF::URLWithUserTypedString): (WTF::userVisibleString): Tools: Add tests for webkit_uri_for_display(). * TestWebKitAPI/Tests/WebKitGLib/TestWebKitURIUtilities.cpp: Added. (testURIForDisplayUnaffected): (testURIForDisplayAffected): (beforeAll): (afterAll): * TestWebKitAPI/glib/CMakeLists.txt: LayoutTests: * TestExpectations: Enable fast/url/user-visible/. Canonical link: https://commits.webkit.org/208722@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-05 04:04:30 +00:00
#include <wtf/Forward.h>
namespace WTF {
namespace URLHelpers {
Fix problems caught by replacing WTF::Optional with std::optional https://bugs.webkit.org/show_bug.cgi?id=211703 Reviewed by Chris Dumez. Source/JavaScriptCore: * runtime/MachineContext.h: (JSC::MachineContext::instructionPointer): Use explcit makeOptional here, to work around the fact that MacroAssemblerCodePtr uses an unusual technique to disable conversions to everything except bool. Source/WebCore: * editing/EditorCommand.cpp: (WebCore::executeSelectToMark): Remove erroneous code that converts a live range to a SimpleRange and then back again. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::willSendRequest): Pass a pointer to a ResourceRequest. (WebCore::InspectorNetworkAgent::didLoadResourceFromMemoryCache): Ditto. (WebCore::InspectorNetworkAgent::buildInitiatorObject): Take a const* to a ResourceRequest instead of an Optional<const ResourceRequest&> because std::optional does not work with reference types. * inspector/agents/InspectorNetworkAgent.h: Update for the change above. * layout/floats/FloatingContext.cpp: (WebCore::Layout::Iterator::operator++): Fix code that was accidentally comparing two optionals, after already checking them for null. Instead we should compare their values. * platform/PlatformScreen.cpp: (WebCore::screenData): Return a const* instead of an Optional<const&> because std::optonal does not work with reference types. * platform/PlatformScreen.h: Updated for the above. Also removed both the unneeded include of Optional.h (could have included Forward.h) and of HashMap.h and put the Mac-specific type IORegistryGPUID inside a PLATFORM(MAC) #if statement. * platform/ScreenProperties.h: Moved the HashMap.h include here, since this is the header that uses it. Changed the EncodedColorSpaceDataType enum to an enum class and gave it much shorter names. (WebCore::ScreenData::encode const): Updated for the enum class change. Also fixed a mistake where the code would use operator<< instead of encodeEnum for the color space type of Null. This would lead to some kind of decoding error, rather than a null cgColorSpace. (WebCore::ScreenData::decode): Ditto. * platform/ios/PlatformScreenIOS.mm: (WebCore::screenIsMonochrome): Updated since screenData returns a pointer. (WebCore::screenHasInvertedColors): Ditto. (WebCore::screenSupportsExtendedColor): Ditto. (WebCore::screenSize): Ditto. (WebCore::availableScreenSize): Ditto. * platform/mac/PlatformScreenMac.mm: Moved declaration of CGDisplayUsesForceToGray to CoreGraphicsSPI.h. Removed unused declaration of CGDisplayUsesInvertedPolarity. (WebCore::primaryOpenGLDisplayMask): Updated since screendData returns a pointer. (WebCore::displayMaskForDisplay): Ditto. (WebCore::gpuIDForDisplay): Ditto. (WebCore::screenProperties): Ditto. Also renamed from getScreenProperties to adhere to WebKit coding style. (WebCore::screenIsMonochrome): Ditto. (WebCore::screenHasInvertedColors): Ditto. (WebCore::screenDepth): Ditto. (WebCore::screenDepthPerComponent): Ditto. (WebCore::screenRectForDisplay): Ditto. (WebCore::screenRect): Ditto. (WebCore::screenAvailableRect): Ditto. (WebCore::screenColorSpace): Ditto. (WebCore::screenSupportsExtendedColor): Ditto. (WebCore::screenSupportsHighDynamicRange): Ditto. * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::queueTaskToFireInstallEvent): Removed capture of unused jobDataIdentifier. Source/WebCore/PAL: * pal/spi/cg/CoreGraphicsSPI.h: Moved definition of CGDisplayUsesForceToGray here from PlatformScreenMac.mm and also added include of the private header it's from when compiling with the Apple internal SDK for the additional checking that we get from using both. Source/WebKit: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::plainTextForContext): Clarified ambiguous overload resolution by writing the conversion from a live range to a SimpleRange out explicitly. Also fixed a typo where there was a missing "&" in a "const&" argument. Source/WTF: * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Make URLDecodeFunction a function pointer and use nullptr instead of trying to use Optional<> with a function reference. (WTF::URLHelpers::collectRangesThatNeedMapping): Ditto. (WTF::URLHelpers::applyHostNameFunctionToMailToURLString): Ditto. (WTF::URLHelpers::applyHostNameFunctionToURLString): Ditto. (WTF::URLHelpers::mapHostNames): Ditto. (WTF::URLHelpers::userVisibleURL): Ditto. * wtf/URLHelpers.h: Ditto. * wtf/cocoa/NSURLExtras.mm: (WTF::decodeHostName): Pass nullptr for URLDecodeFunction. Canonical link: https://commits.webkit.org/224664@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261546 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 05:46:28 +00:00
using URLDecodeFunction = String(*)(const String&);
[GTK][WPE] Need a function to convert internal URI to display ("pretty") URI https://bugs.webkit.org/show_bug.cgi?id=174816 Patch by Ms2ger <Ms2ger@igalia.com> on 2019-02-04 Reviewed by Michael Catanzaro. Source/WebCore: Tests: enabled fast/url/user-visible/. * testing/Internals.cpp: (WebCore::Internals::userVisibleString): Enable method on all platforms. Source/WebKit: Add webkit_uri_for_display for GTK and WPE. * PlatformGTK.cmake: * PlatformWPE.cmake: * SourcesGTK.txt: * SourcesWPE.txt: * UIProcess/API/glib/WebKitURIUtilities.cpp: Added. (webkit_uri_for_display): * UIProcess/API/gtk/WebKitURIUtilities.h: Added. * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: * UIProcess/API/gtk/webkit2.h: * UIProcess/API/wpe/WebKitURIUtilities.h: Added. * UIProcess/API/wpe/docs/wpe-0.1-sections.txt: * UIProcess/API/wpe/docs/wpe-docs.sgml: * UIProcess/API/wpe/webkit.h: Source/WTF: Translate userVisibleString and dependent code into platform-neutral C++ in wtf/URLHelpers.{h,cpp}. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/URLHelpers.cpp: Added. (WTF::URLHelpers::loadIDNScriptWhiteList): (WTF::URLHelpers::isArmenianLookalikeCharacter): (WTF::URLHelpers::isArmenianScriptCharacter): (WTF::URLHelpers::isASCIIDigitOrValidHostCharacter): (WTF::URLHelpers::isLookalikeCharacter): (WTF::URLHelpers::whiteListIDNScript): (WTF::URLHelpers::initializeDefaultIDNScriptWhiteList): (WTF::URLHelpers::allCharactersInIDNScriptWhiteList): (WTF::URLHelpers::isSecondLevelDomainNameAllowedByTLDRules): (WTF::URLHelpers::isRussianDomainNameCharacter): (WTF::URLHelpers::allCharactersAllowedByTLDRules): (WTF::URLHelpers::mapHostName): (WTF::URLHelpers::collectRangesThatNeedMapping): (WTF::URLHelpers::applyHostNameFunctionToMailToURLString): (WTF::URLHelpers::applyHostNameFunctionToURLString): (WTF::URLHelpers::mapHostNames): (WTF::URLHelpers::createStringWithEscapedUnsafeCharacters): (WTF::URLHelpers::toNormalizationFormC): (WTF::URLHelpers::userVisibleURL): * wtf/URLHelpers.h: Added. * wtf/cocoa/NSURLExtras.mm: (WTF::URLHelpers::loadIDNScriptWhiteList): (WTF::decodePercentEscapes): (WTF::decodeHostName): (WTF::encodeHostName): (WTF::URLWithUserTypedString): (WTF::userVisibleString): Tools: Add tests for webkit_uri_for_display(). * TestWebKitAPI/Tests/WebKitGLib/TestWebKitURIUtilities.cpp: Added. (testURIForDisplayUnaffected): (testURIForDisplayAffected): (beforeAll): (afterAll): * TestWebKitAPI/glib/CMakeLists.txt: LayoutTests: * TestExpectations: Enable fast/url/user-visible/. Canonical link: https://commits.webkit.org/208722@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-05 04:04:30 +00:00
WTF_EXPORT_PRIVATE String userVisibleURL(const CString& URL);
void loadIDNAllowedScriptList();
void addScriptToIDNAllowedScriptList(const char* scriptName);
void initializeDefaultIDNAllowedScriptList();
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<String> mapHostName(const String&, URLDecodeFunction);
Fix problems caught by replacing WTF::Optional with std::optional https://bugs.webkit.org/show_bug.cgi?id=211703 Reviewed by Chris Dumez. Source/JavaScriptCore: * runtime/MachineContext.h: (JSC::MachineContext::instructionPointer): Use explcit makeOptional here, to work around the fact that MacroAssemblerCodePtr uses an unusual technique to disable conversions to everything except bool. Source/WebCore: * editing/EditorCommand.cpp: (WebCore::executeSelectToMark): Remove erroneous code that converts a live range to a SimpleRange and then back again. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::willSendRequest): Pass a pointer to a ResourceRequest. (WebCore::InspectorNetworkAgent::didLoadResourceFromMemoryCache): Ditto. (WebCore::InspectorNetworkAgent::buildInitiatorObject): Take a const* to a ResourceRequest instead of an Optional<const ResourceRequest&> because std::optional does not work with reference types. * inspector/agents/InspectorNetworkAgent.h: Update for the change above. * layout/floats/FloatingContext.cpp: (WebCore::Layout::Iterator::operator++): Fix code that was accidentally comparing two optionals, after already checking them for null. Instead we should compare their values. * platform/PlatformScreen.cpp: (WebCore::screenData): Return a const* instead of an Optional<const&> because std::optonal does not work with reference types. * platform/PlatformScreen.h: Updated for the above. Also removed both the unneeded include of Optional.h (could have included Forward.h) and of HashMap.h and put the Mac-specific type IORegistryGPUID inside a PLATFORM(MAC) #if statement. * platform/ScreenProperties.h: Moved the HashMap.h include here, since this is the header that uses it. Changed the EncodedColorSpaceDataType enum to an enum class and gave it much shorter names. (WebCore::ScreenData::encode const): Updated for the enum class change. Also fixed a mistake where the code would use operator<< instead of encodeEnum for the color space type of Null. This would lead to some kind of decoding error, rather than a null cgColorSpace. (WebCore::ScreenData::decode): Ditto. * platform/ios/PlatformScreenIOS.mm: (WebCore::screenIsMonochrome): Updated since screenData returns a pointer. (WebCore::screenHasInvertedColors): Ditto. (WebCore::screenSupportsExtendedColor): Ditto. (WebCore::screenSize): Ditto. (WebCore::availableScreenSize): Ditto. * platform/mac/PlatformScreenMac.mm: Moved declaration of CGDisplayUsesForceToGray to CoreGraphicsSPI.h. Removed unused declaration of CGDisplayUsesInvertedPolarity. (WebCore::primaryOpenGLDisplayMask): Updated since screendData returns a pointer. (WebCore::displayMaskForDisplay): Ditto. (WebCore::gpuIDForDisplay): Ditto. (WebCore::screenProperties): Ditto. Also renamed from getScreenProperties to adhere to WebKit coding style. (WebCore::screenIsMonochrome): Ditto. (WebCore::screenHasInvertedColors): Ditto. (WebCore::screenDepth): Ditto. (WebCore::screenDepthPerComponent): Ditto. (WebCore::screenRectForDisplay): Ditto. (WebCore::screenRect): Ditto. (WebCore::screenAvailableRect): Ditto. (WebCore::screenColorSpace): Ditto. (WebCore::screenSupportsExtendedColor): Ditto. (WebCore::screenSupportsHighDynamicRange): Ditto. * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::queueTaskToFireInstallEvent): Removed capture of unused jobDataIdentifier. Source/WebCore/PAL: * pal/spi/cg/CoreGraphicsSPI.h: Moved definition of CGDisplayUsesForceToGray here from PlatformScreenMac.mm and also added include of the private header it's from when compiling with the Apple internal SDK for the additional checking that we get from using both. Source/WebKit: * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::plainTextForContext): Clarified ambiguous overload resolution by writing the conversion from a live range to a SimpleRange out explicitly. Also fixed a typo where there was a missing "&" in a "const&" argument. Source/WTF: * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Make URLDecodeFunction a function pointer and use nullptr instead of trying to use Optional<> with a function reference. (WTF::URLHelpers::collectRangesThatNeedMapping): Ditto. (WTF::URLHelpers::applyHostNameFunctionToMailToURLString): Ditto. (WTF::URLHelpers::applyHostNameFunctionToURLString): Ditto. (WTF::URLHelpers::mapHostNames): Ditto. (WTF::URLHelpers::userVisibleURL): Ditto. * wtf/URLHelpers.h: Ditto. * wtf/cocoa/NSURLExtras.mm: (WTF::decodeHostName): Pass nullptr for URLDecodeFunction. Canonical link: https://commits.webkit.org/224664@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261546 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-12 05:46:28 +00:00
String mapHostNames(const String&, URLDecodeFunction);
[GTK][WPE] Need a function to convert internal URI to display ("pretty") URI https://bugs.webkit.org/show_bug.cgi?id=174816 Patch by Ms2ger <Ms2ger@igalia.com> on 2019-02-04 Reviewed by Michael Catanzaro. Source/WebCore: Tests: enabled fast/url/user-visible/. * testing/Internals.cpp: (WebCore::Internals::userVisibleString): Enable method on all platforms. Source/WebKit: Add webkit_uri_for_display for GTK and WPE. * PlatformGTK.cmake: * PlatformWPE.cmake: * SourcesGTK.txt: * SourcesWPE.txt: * UIProcess/API/glib/WebKitURIUtilities.cpp: Added. (webkit_uri_for_display): * UIProcess/API/gtk/WebKitURIUtilities.h: Added. * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: * UIProcess/API/gtk/webkit2.h: * UIProcess/API/wpe/WebKitURIUtilities.h: Added. * UIProcess/API/wpe/docs/wpe-0.1-sections.txt: * UIProcess/API/wpe/docs/wpe-docs.sgml: * UIProcess/API/wpe/webkit.h: Source/WTF: Translate userVisibleString and dependent code into platform-neutral C++ in wtf/URLHelpers.{h,cpp}. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/URLHelpers.cpp: Added. (WTF::URLHelpers::loadIDNScriptWhiteList): (WTF::URLHelpers::isArmenianLookalikeCharacter): (WTF::URLHelpers::isArmenianScriptCharacter): (WTF::URLHelpers::isASCIIDigitOrValidHostCharacter): (WTF::URLHelpers::isLookalikeCharacter): (WTF::URLHelpers::whiteListIDNScript): (WTF::URLHelpers::initializeDefaultIDNScriptWhiteList): (WTF::URLHelpers::allCharactersInIDNScriptWhiteList): (WTF::URLHelpers::isSecondLevelDomainNameAllowedByTLDRules): (WTF::URLHelpers::isRussianDomainNameCharacter): (WTF::URLHelpers::allCharactersAllowedByTLDRules): (WTF::URLHelpers::mapHostName): (WTF::URLHelpers::collectRangesThatNeedMapping): (WTF::URLHelpers::applyHostNameFunctionToMailToURLString): (WTF::URLHelpers::applyHostNameFunctionToURLString): (WTF::URLHelpers::mapHostNames): (WTF::URLHelpers::createStringWithEscapedUnsafeCharacters): (WTF::URLHelpers::toNormalizationFormC): (WTF::URLHelpers::userVisibleURL): * wtf/URLHelpers.h: Added. * wtf/cocoa/NSURLExtras.mm: (WTF::URLHelpers::loadIDNScriptWhiteList): (WTF::decodePercentEscapes): (WTF::decodeHostName): (WTF::encodeHostName): (WTF::URLWithUserTypedString): (WTF::userVisibleString): Tools: Add tests for webkit_uri_for_display(). * TestWebKitAPI/Tests/WebKitGLib/TestWebKitURIUtilities.cpp: Added. (testURIForDisplayUnaffected): (testURIForDisplayAffected): (beforeAll): (afterAll): * TestWebKitAPI/glib/CMakeLists.txt: LayoutTests: * TestExpectations: Enable fast/url/user-visible/. Canonical link: https://commits.webkit.org/208722@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-05 04:04:30 +00:00
} // namespace URLHelpers
} // namespace WTF