Adopt simple structured bindings in more places
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jul 2019 20:46:41 +0000 (20:46 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jul 2019 20:46:41 +0000 (20:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199247

Reviewed by Alex Christensen.

Replaces simple uses of std::tie() with structured bindings. Does not touch
uses of std::tie() that are not initial declarations, use std::ignore or in
case where the binding is captured by a lambda, as structured bindings don't
work for those cases yet.

Source/JavaScriptCore:

* runtime/PromiseDeferredTimer.cpp:
(JSC::PromiseDeferredTimer::doWork):
* wasm/WasmFaultSignalHandler.cpp:
(JSC::Wasm::trapHandler):
* wasm/js/JSWebAssemblyHelpers.h:
(JSC::createSourceBufferFromValue):
* wasm/js/WebAssemblyPrototype.cpp:
(JSC::webAssemblyValidateFunc):

Source/WebCore:

* css/StyleResolver.cpp:
(WebCore::checkForOrientationChange):
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::allowInlineScript const):
(WebCore::ContentSecurityPolicy::allowInlineStyle const):
* platform/graphics/ComplexTextController.cpp:
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):
* platform/graphics/PathUtilities.cpp:
(WebCore::PathUtilities::pathWithShrinkWrappedRectsForOutline):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::advanceInternal):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacters):
(WebCore::FontCache::lastResortFallbackFont):
* platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
(WebCore::FontFamilySpecificationCoreText::fontRanges const):
* platform/network/SocketStreamHandleImpl.cpp:
(WebCore::cookieDataForHandshake):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionState):
(WebCore::createMarkedTextFromSelectionInBox):
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paintSelectionBackground):
* style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::constructAttributeName const):

Source/WebKit:

* NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
(WebKit::NetworkCache::printSpeculativeLoadingDiagnosticMessageCounts):
* NetworkProcess/cache/PrefetchCache.cpp:
(WebKit::PrefetchCache::clearExpiredEntries):
* Platform/IPC/MessageReceiverMap.cpp:
(IPC::MessageReceiverMap::removeMessageReceiver):
* UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
(WebKit::PlaybackSessionManagerProxy::invalidate):
* UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenManagerProxy::invalidate):
(WebKit::VideoFullscreenManagerProxy::requestHideAndExitFullscreen):
(WebKit::VideoFullscreenManagerProxy::hasMode const):
(WebKit::VideoFullscreenManagerProxy::mayAutomaticallyShowVideoPictureInPicture const):
(WebKit::VideoFullscreenManagerProxy::isPlayingVideoInEnhancedFullscreen const):
(WebKit::VideoFullscreenManagerProxy::applicationDidBecomeActive):
(WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
(WebKit::VideoFullscreenManagerProxy::didCleanupFullscreen):
* UIProcess/ios/SmartMagnificationController.mm:
(WebKit::SmartMagnificationController::zoomFactorForTargetRect):
(WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
(WebKit::SmartMagnificationController::magnify):
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit:: const):
* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation):
(WebKit::WebPage::performDictionaryLookupForSelection):
* WebProcess/cocoa/PlaybackSessionManager.mm:
(WebKit::PlaybackSessionManager::~PlaybackSessionManager):
(WebKit::PlaybackSessionManager::removeContext):
* WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::VideoFullscreenManager::~VideoFullscreenManager):
(WebKit::VideoFullscreenManager::removeContext):
(WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
(WebKit::VideoFullscreenManager::requestVideoContentLayer):
(WebKit::VideoFullscreenManager::didSetupFullscreen):
(WebKit::VideoFullscreenManager::willExitFullscreen):
(WebKit::VideoFullscreenManager::didEnterFullscreen):
(WebKit::VideoFullscreenManager::didCleanupFullscreen):
(WebKit::VideoFullscreenManager::setVideoLayerFrameFenced):

Source/WebKitLegacy/mac:

* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController _animationControllerForText]):

Tools:

* TestWebKitAPI/ios/PreferredContentMode.mm:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247102 268f45cc-cd09-0410-ab3c-d52691b4dbfc

33 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/PromiseDeferredTimer.cpp
Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h
Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp
Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/page/csp/ContentSecurityPolicy.cpp
Source/WebCore/platform/graphics/ComplexTextController.cpp
Source/WebCore/platform/graphics/PathUtilities.cpp
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
Source/WebCore/platform/network/SocketStreamHandleImpl.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
Source/WebCore/style/StyleResolveForDocument.cpp
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp
Source/WebKit/NetworkProcess/cache/PrefetchCache.cpp
Source/WebKit/Platform/IPC/MessageReceiverMap.cpp
Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm
Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
Source/WebKit/UIProcess/ios/SmartMagnificationController.mm
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm
Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm
Tools/ChangeLog
Tools/TestWebKitAPI/ios/PreferredContentMode.mm

index e2a364e..25959af 100644 (file)
@@ -1,3 +1,24 @@
+2019-07-03  Sam Weinig  <weinig@apple.com>
+
+        Adopt simple structured bindings in more places
+        https://bugs.webkit.org/show_bug.cgi?id=199247
+
+        Reviewed by Alex Christensen.
+
+        Replaces simple uses of std::tie() with structured bindings. Does not touch
+        uses of std::tie() that are not initial declarations, use std::ignore or in
+        case where the binding is captured by a lambda, as structured bindings don't
+        work for those cases yet.
+
+        * runtime/PromiseDeferredTimer.cpp:
+        (JSC::PromiseDeferredTimer::doWork):
+        * wasm/WasmFaultSignalHandler.cpp:
+        (JSC::Wasm::trapHandler):
+        * wasm/js/JSWebAssemblyHelpers.h:
+        (JSC::createSourceBufferFromValue):
+        * wasm/js/WebAssemblyPrototype.cpp:
+        (JSC::webAssemblyValidateFunc):
+
 2019-07-03  Keith Miller  <keith_miller@apple.com>
 
         PACCage should first cage leaving PAC bits intact then authenticate
index 343ee2a..e63d31b 100644 (file)
@@ -54,9 +54,7 @@ void PromiseDeferredTimer::doWork(VM& vm)
     }
 
     while (!m_tasks.isEmpty()) {
-        JSPromiseDeferred* ticket;
-        Task task;
-        std::tie(ticket, task) = m_tasks.takeLast();
+        auto [ticket, task] = m_tasks.takeLast();
         dataLogLnIf(PromiseDeferredTimerInternal::verbose, "Doing work on promise: ", RawPointer(ticket));
 
         // We may have already canceled these promises.
index 64c3590..78b54ac 100644 (file)
@@ -77,10 +77,7 @@ static SignalAction trapHandler(Signal, SigInfo& sigInfo, PlatformRegisters& con
         if (faultedInActiveFastMemory) {
             dataLogLnIf(WasmFaultSignalHandlerInternal::verbose, "found active fast memory for faulting address");
             LockHolder locker(codeLocationsLock);
-            for (auto range : codeLocations.get()) {
-                void* start;
-                void* end;
-                std::tie(start, end) = range;
+            for (auto [start, end] : codeLocations.get()) {
                 dataLogLnIf(WasmFaultSignalHandlerInternal::verbose, "function start: ", RawPointer(start), " end: ", RawPointer(end));
                 if (start <= faultingInstruction && faultingInstruction < end) {
                     dataLogLnIf(WasmFaultSignalHandlerInternal::verbose, "found match");
index 13d0a09..95ffa17 100644 (file)
@@ -83,9 +83,7 @@ ALWAYS_INLINE std::pair<const uint8_t*, size_t> getWasmBufferFromValue(ExecState
 ALWAYS_INLINE Vector<uint8_t> createSourceBufferFromValue(VM& vm, ExecState* exec, JSValue value)
 {
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    const uint8_t* data;
-    size_t byteSize;
-    std::tie(data, byteSize) = getWasmBufferFromValue(exec, value);
+    auto [data, byteSize] = getWasmBufferFromValue(exec, value);
     RETURN_IF_EXCEPTION(throwScope, Vector<uint8_t>());
 
     Vector<uint8_t> result;
index 20c34b2..8a44433 100644 (file)
@@ -290,9 +290,7 @@ static EncodedJSValue JSC_HOST_CALL webAssemblyValidateFunc(ExecState* exec)
     VM& vm = exec->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
-    const uint8_t* base;
-    size_t byteSize;
-    std::tie(base, byteSize) = getWasmBufferFromValue(exec, exec->argument(0));
+    auto [base, byteSize] = getWasmBufferFromValue(exec, exec->argument(0));
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
     BBQPlan plan(&vm.wasmContext, BBQPlan::Validation, Plan::dontFinalize());
     // FIXME: We might want to throw an OOM exception here if we detect that something will OOM.
index 45456ee..e1c36e9 100644 (file)
@@ -1,3 +1,44 @@
+2019-07-03  Sam Weinig  <weinig@apple.com>
+
+        Adopt simple structured bindings in more places
+        https://bugs.webkit.org/show_bug.cgi?id=199247
+
+        Reviewed by Alex Christensen.
+
+        Replaces simple uses of std::tie() with structured bindings. Does not touch
+        uses of std::tie() that are not initial declarations, use std::ignore or in
+        case where the binding is captured by a lambda, as structured bindings don't
+        work for those cases yet.
+
+        * css/StyleResolver.cpp:
+        (WebCore::checkForOrientationChange):
+        * page/csp/ContentSecurityPolicy.cpp:
+        (WebCore::ContentSecurityPolicy::allowInlineScript const):
+        (WebCore::ContentSecurityPolicy::allowInlineStyle const):
+        * platform/graphics/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+        * platform/graphics/PathUtilities.cpp:
+        (WebCore::PathUtilities::pathWithShrinkWrappedRectsForOutline):
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::advanceInternal):
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::FontCache::createFontPlatformData):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        (WebCore::FontCache::lastResortFallbackFont):
+        * platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
+        (WebCore::FontFamilySpecificationCoreText::fontRanges const):
+        * platform/network/SocketStreamHandleImpl.cpp:
+        (WebCore::cookieDataForHandshake):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::selectionState):
+        (WebCore::createMarkedTextFromSelectionInBox):
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paintSelectionBackground):
+        * style/StyleResolveForDocument.cpp:
+        (WebCore::Style::resolveForDocument):
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::constructAttributeName const):
+
 2019-07-03  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         REGRESSION (iOS 13): Tapping an element with a click event handler no longer clears the selection
index 0a14632..56d8727 100644 (file)
@@ -1199,9 +1199,7 @@ void StyleResolver::adjustRenderStyleForSiteSpecificQuirks(RenderStyle& style, c
 
 static void checkForOrientationChange(RenderStyle& style)
 {
-    FontOrientation fontOrientation;
-    NonCJKGlyphOrientation glyphOrientation;
-    std::tie(fontOrientation, glyphOrientation) = style.fontAndGlyphOrientation();
+    auto [fontOrientation, glyphOrientation] = style.fontAndGlyphOrientation();
 
     const auto& fontDescription = style.fontDescription();
     if (fontDescription.orientation() == fontOrientation && fontDescription.nonCJKGlyphOrientation() == glyphOrientation)
index 47b932d..7047e83 100644 (file)
@@ -427,9 +427,7 @@ bool ContentSecurityPolicy::allowInlineScript(const String& contextURL, const WT
     if (overrideContentSecurityPolicy)
         return true;
     bool didNotifyInspector = false;
-    bool foundHashInEnforcedPolicies;
-    bool foundHashInReportOnlyPolicies;
-    std::tie(foundHashInEnforcedPolicies, foundHashInReportOnlyPolicies) = findHashOfContentInPolicies(&ContentSecurityPolicyDirectiveList::violatedDirectiveForScriptHash, scriptContent, m_hashAlgorithmsForInlineScripts);
+    auto [foundHashInEnforcedPolicies, foundHashInReportOnlyPolicies] = findHashOfContentInPolicies(&ContentSecurityPolicyDirectiveList::violatedDirectiveForScriptHash, scriptContent, m_hashAlgorithmsForInlineScripts);
     if (foundHashInEnforcedPolicies && foundHashInReportOnlyPolicies)
         return true;
     auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) {
@@ -453,9 +451,7 @@ bool ContentSecurityPolicy::allowInlineStyle(const String& contextURL, const WTF
         return true;
     if (m_overrideInlineStyleAllowed)
         return true;
-    bool foundHashInEnforcedPolicies;
-    bool foundHashInReportOnlyPolicies;
-    std::tie(foundHashInEnforcedPolicies, foundHashInReportOnlyPolicies) = findHashOfContentInPolicies(&ContentSecurityPolicyDirectiveList::violatedDirectiveForStyleHash, styleContent, m_hashAlgorithmsForInlineStylesheets);
+    auto [foundHashInEnforcedPolicies, foundHashInReportOnlyPolicies] = findHashOfContentInPolicies(&ContentSecurityPolicyDirectiveList::violatedDirectiveForStyleHash, styleContent, m_hashAlgorithmsForInlineStylesheets);
     if (foundHashInEnforcedPolicies && foundHashInReportOnlyPolicies)
         return true;
     auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) {
index 7424d4f..0d35561 100644 (file)
@@ -788,8 +788,7 @@ void ComplexTextController::adjustGlyphsAndAdvances()
                 if (treatAsSpace || ideograph || forceLeadingExpansion || forceTrailingExpansion) {
                     // Distribute the run's total expansion evenly over all expansion opportunities in the run.
                     if (m_expansion) {
-                        bool expandLeft, expandRight;
-                        std::tie(expandLeft, expandRight) = expansionLocation(ideograph, treatAsSpace, m_run.ltr(), afterExpansion, forbidLeadingExpansion, forbidTrailingExpansion, forceLeadingExpansion, forceTrailingExpansion);
+                        auto [expandLeft, expandRight] = expansionLocation(ideograph, treatAsSpace, m_run.ltr(), afterExpansion, forbidLeadingExpansion, forbidTrailingExpansion, forceLeadingExpansion, forceTrailingExpansion);
                         if (expandLeft) {
                             m_expansion -= m_expansionPerOpportunity;
                             // Increase previous width
index 32bf95c..3e68805 100644 (file)
@@ -580,14 +580,10 @@ Path PathUtilities::pathWithShrinkWrappedRectsForOutline(const Vector<FloatRect>
             continue;
         }
         }
-        FloatPoint startPoint;
-        FloatPoint endPoint;
-        std::tie(startPoint, endPoint) = startAndEndPointsForCorner(fromEdge, toEdge, radius);
+        auto [startPoint, endPoint] = startAndEndPointsForCorner(fromEdge, toEdge, radius);
         moveOrAddLineTo(startPoint);
 
-        FloatPoint cp1;
-        FloatPoint cp2;
-        std::tie(cp1, cp2) = controlPointsForBezierCurve(corner, fromEdge, toEdge, radius);
+        auto [cp1, cp2] = controlPointsForBezierCurve(corner, fromEdge, toEdge, radius);
         path.addBezierCurveTo(cp1, cp2, endPoint);
     }
     path.closeSubpath();
index 2d0972a..e48a19d 100644 (file)
@@ -276,8 +276,7 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
             if (treatAsSpace || ideograph || forceLeadingExpansion || forceTrailingExpansion) {
                 // Distribute the run's total expansion evenly over all expansion opportunities in the run.
                 if (m_expansion) {
-                    bool expandLeft, expandRight;
-                    std::tie(expandLeft, expandRight) = expansionLocation(ideograph, treatAsSpace, m_run.ltr(), m_isAfterExpansion, forbidLeadingExpansion, forbidTrailingExpansion, forceLeadingExpansion, forceTrailingExpansion);
+                    auto [expandLeft, expandRight] = expansionLocation(ideograph, treatAsSpace, m_run.ltr(), m_isAfterExpansion, forbidLeadingExpansion, forbidTrailingExpansion, forceLeadingExpansion, forceTrailingExpansion);
                     if (expandLeft) {
                         if (m_run.ltr()) {
                             // Increase previous width
index cf281a7..4821186 100644 (file)
@@ -1308,8 +1308,7 @@ std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe
     if (fontDescription.shouldAllowUserInstalledFonts() == AllowUserInstalledFonts::No)
         m_seenFamiliesForPrewarming.add(FontCascadeDescription::foldedFamilyName(family));
 
-    bool syntheticBold, syntheticOblique;
-    std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(font.get(), fontDescription).boldObliquePair();
+    auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(font.get(), fontDescription).boldObliquePair();
 
     return std::make_unique<FontPlatformData>(font.get(), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.textRenderingMode());
 }
@@ -1409,8 +1408,7 @@ RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr
     // font pointer.
     CTFontRef substituteFont = fallbackDedupSet().add(result).iterator->get();
 
-    bool syntheticBold, syntheticOblique;
-    std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(substituteFont, description, isForPlatformFont == IsForPlatformFont::Yes).boldObliquePair();
+    auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(substituteFont, description, isForPlatformFont == IsForPlatformFont::Yes).boldObliquePair();
 
     FontPlatformData alternateFont(substituteFont, platformData.size(), syntheticBold, syntheticOblique, platformData.orientation(), platformData.widthVariant(), platformData.textRenderingMode());
 
@@ -1546,8 +1544,7 @@ Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescripti
     // a thin wrapper around a GraphicsFont which represents LastResort.
     auto font = adoptCF(CTFontCreateWithName(CFSTR("Helvetica"), fontDescription.computedPixelSize(), nullptr));
 #endif
-    bool syntheticBold, syntheticOblique;
-    std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(font.get(), fontDescription).boldObliquePair();
+    auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(font.get(), fontDescription).boldObliquePair();
     FontPlatformData platformData(font.get(), fontDescription.computedPixelSize(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.textRenderingMode());
     return fontForPlatformData(platformData);
 }
index c8911c4..c96a2ed 100644 (file)
@@ -110,8 +110,7 @@ FontRanges FontFamilySpecificationCoreText::fontRanges(const FontDescription& fo
 
         font = preparePlatformFont(font.get(), fontDescription, nullptr, nullptr, { });
 
-        bool syntheticBold, syntheticOblique;
-        std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(fontForSynthesisComputation.get(), fontDescription).boldObliquePair();
+        auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(fontForSynthesisComputation.get(), fontDescription).boldObliquePair();
 
         return std::make_unique<FontPlatformData>(font.get(), size, false, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.textRenderingMode());
     }).iterator->value;
index b4a9ce7..94223f1 100644 (file)
@@ -82,9 +82,7 @@ static Optional<std::pair<Vector<uint8_t>, bool>> cookieDataForHandshake(const N
     if (!networkStorageSession)
         return WTF::nullopt;
     
-    String cookieDataString;
-    bool secureCookiesAccessed = false;
-    std::tie(cookieDataString, secureCookiesAccessed) = networkStorageSession->cookieRequestHeaderFieldValue(headerFieldProxy);
+    auto [cookieDataString, secureCookiesAccessed] = networkStorageSession->cookieRequestHeaderFieldValue(headerFieldProxy);
     if (cookieDataString.isEmpty())
         return std::pair<Vector<uint8_t>, bool> { { }, secureCookiesAccessed };
 
index 5f5bd62..dff8b11 100644 (file)
@@ -180,9 +180,7 @@ RenderObject::SelectionState InlineTextBox::selectionState()
     if (m_truncation != cNoTruncation && root().ellipsisBox()) {
         EllipsisBox* ellipsis = root().ellipsisBox();
         if (state != RenderObject::SelectionNone) {
-            unsigned selectionStart;
-            unsigned selectionEnd;
-            std::tie(selectionStart, selectionEnd) = selectionStartEnd();
+            auto [selectionStart, selectionEnd] = selectionStartEnd();
             // The ellipsis should be considered to be selected if the end of
             // the selection is past the beginning of the truncation and the
             // beginning of the selection is before or at the beginning of the
@@ -438,9 +436,7 @@ struct InlineTextBox::StyledMarkedText : MarkedText {
 
 static MarkedText createMarkedTextFromSelectionInBox(const InlineTextBox& box)
 {
-    unsigned selectionStart;
-    unsigned selectionEnd;
-    std::tie(selectionStart, selectionEnd) = box.selectionStartEnd();
+    auto [selectionStart, selectionEnd] = box.selectionStartEnd();
     if (selectionStart < selectionEnd)
         return { selectionStart, selectionEnd, MarkedText::Selection };
     return { };
index d0efd89..55c2b79 100644 (file)
@@ -202,9 +202,7 @@ void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo)
 
     auto& style = parentRenderer.style();
 
-    unsigned startPosition;
-    unsigned endPosition;
-    std::tie(startPosition, endPosition) = selectionStartEnd();
+    auto [startPosition, endPosition] = selectionStartEnd();
 
     unsigned fragmentStartPosition = 0;
     unsigned fragmentEndPosition = 0;
index c6d6a4e..0e43d41 100644 (file)
@@ -117,9 +117,7 @@ RenderStyle resolveForDocument(const Document& document)
     bool useSVGZoomRules = document.isSVGDocument();
     fontDescription.setComputedSize(computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), useSVGZoomRules, &documentStyle, document));
 
-    FontOrientation fontOrientation;
-    NonCJKGlyphOrientation glyphOrientation;
-    std::tie(fontOrientation, glyphOrientation) = documentStyle.fontAndGlyphOrientation();
+    auto [fontOrientation, glyphOrientation] = documentStyle.fontAndGlyphOrientation();
     fontDescription.setOrientation(fontOrientation);
     fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
 
index 81d17f4..3664c17 100644 (file)
@@ -219,8 +219,7 @@ inline QualifiedName SVGSMILElement::constructAttributeName() const
     if (parseResult.hasException())
         return anyQName();
 
-    AtomString prefix, localName;
-    std::tie(prefix, localName) = parseResult.releaseReturnValue();
+    auto [prefix, localName] = parseResult.releaseReturnValue();
 
     if (prefix.isNull())
         return { nullAtom(), localName, nullAtom() };
index c81df1f..699e9af 100644 (file)
@@ -1,3 +1,55 @@
+2019-07-03  Sam Weinig  <weinig@apple.com>
+
+        Adopt simple structured bindings in more places
+        https://bugs.webkit.org/show_bug.cgi?id=199247
+
+        Reviewed by Alex Christensen.
+
+        Replaces simple uses of std::tie() with structured bindings. Does not touch
+        uses of std::tie() that are not initial declarations, use std::ignore or in
+        case where the binding is captured by a lambda, as structured bindings don't
+        work for those cases yet.
+
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
+        (WebKit::NetworkCache::printSpeculativeLoadingDiagnosticMessageCounts):
+        * NetworkProcess/cache/PrefetchCache.cpp:
+        (WebKit::PrefetchCache::clearExpiredEntries):
+        * Platform/IPC/MessageReceiverMap.cpp:
+        (IPC::MessageReceiverMap::removeMessageReceiver):
+        * UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
+        (WebKit::PlaybackSessionManagerProxy::invalidate):
+        * UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
+        (WebKit::VideoFullscreenManagerProxy::invalidate):
+        (WebKit::VideoFullscreenManagerProxy::requestHideAndExitFullscreen):
+        (WebKit::VideoFullscreenManagerProxy::hasMode const):
+        (WebKit::VideoFullscreenManagerProxy::mayAutomaticallyShowVideoPictureInPicture const):
+        (WebKit::VideoFullscreenManagerProxy::isPlayingVideoInEnhancedFullscreen const):
+        (WebKit::VideoFullscreenManagerProxy::applicationDidBecomeActive):
+        (WebKit::VideoFullscreenManagerProxy::setupFullscreenWithID):
+        (WebKit::VideoFullscreenManagerProxy::didCleanupFullscreen):
+        * UIProcess/ios/SmartMagnificationController.mm:
+        (WebKit::SmartMagnificationController::zoomFactorForTargetRect):
+        (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
+        (WebKit::SmartMagnificationController::magnify):
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit:: const):
+        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+        (WebKit::WebPage::performDictionaryLookupAtLocation):
+        (WebKit::WebPage::performDictionaryLookupForSelection):
+        * WebProcess/cocoa/PlaybackSessionManager.mm:
+        (WebKit::PlaybackSessionManager::~PlaybackSessionManager):
+        (WebKit::PlaybackSessionManager::removeContext):
+        * WebProcess/cocoa/VideoFullscreenManager.mm:
+        (WebKit::VideoFullscreenManager::~VideoFullscreenManager):
+        (WebKit::VideoFullscreenManager::removeContext):
+        (WebKit::VideoFullscreenManager::enterVideoFullscreenForVideoElement):
+        (WebKit::VideoFullscreenManager::requestVideoContentLayer):
+        (WebKit::VideoFullscreenManager::didSetupFullscreen):
+        (WebKit::VideoFullscreenManager::willExitFullscreen):
+        (WebKit::VideoFullscreenManager::didEnterFullscreen):
+        (WebKit::VideoFullscreenManager::didCleanupFullscreen):
+        (WebKit::VideoFullscreenManager::setVideoLayerFrameFenced):
+
 2019-07-03  Zalan Bujtas  <zalan@apple.com>
 
         [ContentChangeObserver] REGRESSION (r244356): Drop down menus collapse without user input - Ebay.com
index 62f7de5..1cd6b49 100644 (file)
@@ -59,8 +59,8 @@ static HashCountedSet<String>& allSpeculativeLoadingDiagnosticMessages()
 static void printSpeculativeLoadingDiagnosticMessageCounts()
 {
     LOG(NetworkCacheSpeculativePreloading, "-- Speculative loading statistics --");
-    for (auto& pair : allSpeculativeLoadingDiagnosticMessages())
-        LOG(NetworkCacheSpeculativePreloading, "%s: %u", pair.key.utf8().data(), pair.value);
+    for (auto& [message, count] : allSpeculativeLoadingDiagnosticMessages())
+        LOG(NetworkCacheSpeculativePreloading, "%s: %u", message.utf8().data(), count);
 }
 #endif
 
index 10977d0..d8a0594 100644 (file)
@@ -96,11 +96,9 @@ void PrefetchCache::storeRedirect(const URL& requestUrl, WebCore::ResourceRespon
 
 void PrefetchCache::clearExpiredEntries()
 {
-    URL requestUrl;
-    WallTime timestamp;
     auto timeout = WallTime::now();
     while (!m_sessionExpirationList.isEmpty()) {
-        std::tie(requestUrl, timestamp) = m_sessionExpirationList.first();
+        auto [requestUrl, timestamp] = m_sessionExpirationList.first();
         auto* resources = m_sessionPrefetches.get();
         ASSERT(resources);
         ASSERT(resources->contains(requestUrl));
index aa5eba8..b36ef3f 100644 (file)
@@ -80,22 +80,22 @@ void MessageReceiverMap::removeMessageReceiver(StringReference messageReceiverNa
 void MessageReceiverMap::removeMessageReceiver(MessageReceiver& messageReceiver)
 {
     Vector<StringReference> globalReceiversToRemove;
-    for (auto& nameAndReceiver : m_globalMessageReceivers) {
-        if (nameAndReceiver.value == &messageReceiver)
-            globalReceiversToRemove.append(nameAndReceiver.key);
+    for (auto& [name, receiver] : m_globalMessageReceivers) {
+        if (receiver == &messageReceiver)
+            globalReceiversToRemove.append(name);
     }
 
     for (auto& globalReceiverToRemove : globalReceiversToRemove)
         removeMessageReceiver(globalReceiverToRemove);
 
     Vector<std::pair<StringReference, uint64_t>> receiversToRemove;
-    for (auto& nameAndIdAndReceiver : m_messageReceivers) {
-        if (nameAndIdAndReceiver.value == &messageReceiver)
-            receiversToRemove.append(std::make_pair(nameAndIdAndReceiver.key.first, nameAndIdAndReceiver.key.second));
+    for (auto& [nameAndDestinationID, receiver] : m_messageReceivers) {
+        if (receiver == &messageReceiver)
+            receiversToRemove.append(std::make_pair(nameAndDestinationID.first, nameAndDestinationID.second));
     }
 
-    for (auto& receiverToRemove : receiversToRemove)
-        removeMessageReceiver(receiverToRemove.first, receiverToRemove.second);
+    for (auto& [name, destinationID] : receiversToRemove)
+        removeMessageReceiver(name, destinationID);
 }
 
 void MessageReceiverMap::invalidate()
index 6706597..e59be91 100644 (file)
@@ -320,13 +320,8 @@ void PlaybackSessionManagerProxy::invalidate()
     auto contextMap = WTFMove(m_contextMap);
     m_clientCounts.clear();
 
-    for (auto& tuple : contextMap.values()) {
-        RefPtr<PlaybackSessionModelContext> model;
-        RefPtr<PlatformPlaybackSessionInterface> interface;
-        std::tie(model, interface) = tuple;
-
+    for (auto& [model, interface] : contextMap.values())
         interface->invalidate();
-    }
 }
 
 PlaybackSessionManagerProxy::ModelInterfaceTuple PlaybackSessionManagerProxy::createModelAndInterface(uint64_t contextId)
index 4ea1b6d..f78a804 100644 (file)
@@ -343,11 +343,7 @@ void VideoFullscreenManagerProxy::invalidate()
     auto contextMap = WTFMove(m_contextMap);
     m_clientCounts.clear();
 
-    for (auto& tuple : contextMap.values()) {
-        RefPtr<VideoFullscreenModelContext> model;
-        RefPtr<PlatformVideoFullscreenInterface> interface;
-        std::tie(model, interface) = tuple;
-
+    for (auto& [model, interface] : contextMap.values()) {
         interface->invalidate();
         [model->layerHostView() removeFromSuperview];
         model->setLayerHostView(nullptr);
@@ -356,14 +352,14 @@ void VideoFullscreenManagerProxy::invalidate()
 
 void VideoFullscreenManagerProxy::requestHideAndExitFullscreen()
 {
-    for (auto& tuple : m_contextMap.values())
-        std::get<1>(tuple)->requestHideAndExitFullscreen();
+    for (auto& [model, interface] : m_contextMap.values())
+        interface->requestHideAndExitFullscreen();
 }
 
 bool VideoFullscreenManagerProxy::hasMode(HTMLMediaElementEnums::VideoFullscreenMode mode) const
 {
-    for (auto& tuple : m_contextMap.values()) {
-        if (std::get<1>(tuple)->hasMode(mode))
+    for (auto& [model, interface] : m_contextMap.values()) {
+        if (interface->hasMode(mode))
             return true;
     }
     return false;
@@ -371,8 +367,8 @@ bool VideoFullscreenManagerProxy::hasMode(HTMLMediaElementEnums::VideoFullscreen
 
 bool VideoFullscreenManagerProxy::mayAutomaticallyShowVideoPictureInPicture() const
 {
-    for (auto& tuple : m_contextMap.values()) {
-        if (std::get<1>(tuple)->mayAutomaticallyShowVideoPictureInPicture())
+    for (auto& [model, interface] : m_contextMap.values()) {
+        if (interface->mayAutomaticallyShowVideoPictureInPicture())
             return true;
     }
     return false;
@@ -381,8 +377,8 @@ bool VideoFullscreenManagerProxy::mayAutomaticallyShowVideoPictureInPicture() co
 #if ENABLE(VIDEO_PRESENTATION_MODE)
 bool VideoFullscreenManagerProxy::isPlayingVideoInEnhancedFullscreen() const
 {
-    for (auto& tuple : m_contextMap.values()) {
-        if (std::get<1>(tuple)->isPlayingVideoInEnhancedFullscreen())
+    for (auto& [model, interface] : m_contextMap.values()) {
+        if (interface->isPlayingVideoInEnhancedFullscreen())
             return true;
     }
     
@@ -399,8 +395,8 @@ PlatformVideoFullscreenInterface* VideoFullscreenManagerProxy::controlsManagerIn
 
 void VideoFullscreenManagerProxy::applicationDidBecomeActive()
 {
-    for (auto& tuple : m_contextMap.values())
-        std::get<1>(tuple)->applicationDidBecomeActive();
+    for (auto& [model, interface] : m_contextMap.values())
+        interface->applicationDidBecomeActive();
 }
 
 void VideoFullscreenManagerProxy::requestRouteSharingPolicyAndContextUID(uint64_t contextId, CompletionHandler<void(WebCore::RouteSharingPolicy, String)>&& callback)
@@ -497,10 +493,8 @@ void VideoFullscreenManagerProxy::setupFullscreenWithID(uint64_t contextId, uint
     MESSAGE_CHECK_CONTEXTID(contextId);
 
     ASSERT(videoLayerID);
-    RefPtr<VideoFullscreenModelContext> model;
-    RefPtr<PlatformVideoFullscreenInterface> interface;
 
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto& [model, interface] = ensureModelAndInterface(contextId);
     addClientForContext(contextId);
 
     RetainPtr<WKLayerHostView> view = static_cast<WKLayerHostView*>(model->layerHostView());
@@ -686,10 +680,7 @@ void VideoFullscreenManagerProxy::didEnterFullscreen(uint64_t contextId)
 
 void VideoFullscreenManagerProxy::didCleanupFullscreen(uint64_t contextId)
 {
-    RefPtr<VideoFullscreenModelContext> model;
-    RefPtr<PlatformVideoFullscreenInterface> interface;
-
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto& [model, interface] = ensureModelAndInterface(contextId);
 
     [CATransaction flush];
     [model->layerHostView() removeFromSuperview];
index 6eff64b..c0e43dc 100644 (file)
@@ -97,10 +97,7 @@ double SmartMagnificationController::zoomFactorForTargetRect(FloatRect targetRec
 {
     // FIXME: Share some of this code with didCollectGeometryForSmartMagnificationGesture?
 
-    FloatRect adjustedTargetRect;
-    double minimumScale = viewportMinimumScale;
-    double maximumScale = viewportMaximumScale;
-    std::tie(adjustedTargetRect, minimumScale, maximumScale) = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, !fitEntireRect);
+    auto [adjustedTargetRect, minimumScale, maximumScale] = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, !fitEntireRect);
 
     double currentScale = [m_contentView _contentZoomScale];
     double targetScale = [m_contentView _targetContentZoomScaleForRect:adjustedTargetRect currentScale:currentScale fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale];
@@ -118,10 +115,7 @@ void SmartMagnificationController::didCollectGeometryForSmartMagnificationGestur
         [m_contentView _zoomToInitialScaleWithOrigin:origin];
         return;
     }
-    FloatRect adjustedTargetRect;
-    double minimumScale = viewportMinimumScale;
-    double maximumScale = viewportMaximumScale;
-    std::tie(adjustedTargetRect, minimumScale, maximumScale) = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, !fitEntireRect);
+    auto [adjustedTargetRect, minimumScale, maximumScale] = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, !fitEntireRect);
 
     // FIXME: Check if text selection wants to consume the double tap before we attempt magnification.
 
@@ -147,10 +141,7 @@ void SmartMagnificationController::didCollectGeometryForSmartMagnificationGestur
 
 void SmartMagnificationController::magnify(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale)
 {
-    FloatRect adjustedTargetRect;
-    double maximumScale = viewportMaximumScale;
-    double minimumScale = viewportMinimumScale;
-    std::tie(adjustedTargetRect, minimumScale, maximumScale) = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, true);
+    auto [adjustedTargetRect, minimumScale, maximumScale] = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, true);
 
     [m_contentView _zoomToRect:adjustedTargetRect withOrigin:origin fitEntireRect:NO minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:0];
 }
index f6f41f9..dea6a5d 100644 (file)
@@ -2094,9 +2094,7 @@ std::tuple<String, PDFSelection *, NSDictionary *> PDFPlugin::lookupTextAtLocati
         return { selection.string, selection, nil };
     }
 
-    NSString *lookupText;
-    NSDictionary *options;
-    std::tie(lookupText, options) = DictionaryLookup::stringForPDFSelection(selection);
+    auto [lookupText, options] = DictionaryLookup::stringForPDFSelection(selection);
     if (!lookupText.length)
         return { emptyString(), selection, nil };
 
index ad7a8e3..4970cf5 100644 (file)
@@ -85,9 +85,7 @@ void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint)
     
     // Find the frame the point is over.
     HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(roundedIntPoint(floatPoint)));
-    RefPtr<Range> range;
-    NSDictionary *options;
-    std::tie(range, options) = DictionaryLookup::rangeAtHitTestResult(result);
+    auto [range, options] = DictionaryLookup::rangeAtHitTestResult(result);
     if (!range)
         return;
     
@@ -100,9 +98,7 @@ void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint)
 
 void WebPage::performDictionaryLookupForSelection(Frame& frame, const VisibleSelection& selection, TextIndicatorPresentationTransition presentationTransition)
 {
-    RefPtr<Range> selectedRange;
-    NSDictionary *options;
-    std::tie(selectedRange, options) = DictionaryLookup::rangeForSelection(selection);
+    auto [selectedRange, options] = DictionaryLookup::rangeForSelection(selection);
     if (selectedRange)
         performDictionaryLookupForRange(frame, *selectedRange, options, presentationTransition);
 }
index 765eff4..66f04de 100644 (file)
@@ -175,10 +175,7 @@ PlaybackSessionManager::PlaybackSessionManager(WebPage& page)
 
 PlaybackSessionManager::~PlaybackSessionManager()
 {
-    for (auto& tuple : m_contextMap.values()) {
-        RefPtr<PlaybackSessionModelMediaElement> model;
-        RefPtr<PlaybackSessionInterfaceContext> interface;
-        std::tie(model, interface) = tuple;
+    for (auto& [model, interface] : m_contextMap.values()) {
         model->removeClient(*interface);
         model->setMediaElement(nullptr);
 
@@ -229,9 +226,7 @@ PlaybackSessionInterfaceContext& PlaybackSessionManager::ensureInterface(uint64_
 
 void PlaybackSessionManager::removeContext(uint64_t contextId)
 {
-    RefPtr<PlaybackSessionModelMediaElement> model;
-    RefPtr<PlaybackSessionInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto& [model, interface] = ensureModelAndInterface(contextId);
 
     RefPtr<HTMLMediaElement> mediaElement = model->mediaElement();
     model->setMediaElement(nullptr);
index 7066397..f536c3d 100644 (file)
@@ -122,11 +122,7 @@ VideoFullscreenManager::VideoFullscreenManager(WebPage& page, PlaybackSessionMan
 
 VideoFullscreenManager::~VideoFullscreenManager()
 {
-    for (auto& tuple : m_contextMap.values()) {
-        RefPtr<VideoFullscreenModelVideoElement> model;
-        RefPtr<VideoFullscreenInterfaceContext> interface;
-        std::tie(model, interface) = tuple;
-
+    for (auto& [model, interface] : m_contextMap.values()) {
         model->setVideoElement(nullptr);
         model->removeClient(*interface);
 
@@ -180,9 +176,7 @@ VideoFullscreenInterfaceContext& VideoFullscreenManager::ensureInterface(uint64_
 
 void VideoFullscreenManager::removeContext(uint64_t contextId)
 {
-    RefPtr<VideoFullscreenModelVideoElement> model;
-    RefPtr<VideoFullscreenInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto [model, interface] = ensureModelAndInterface(contextId);
 
     m_playbackSessionManager->removeClientForContext(contextId);
 
@@ -250,9 +244,7 @@ void VideoFullscreenManager::enterVideoFullscreenForVideoElement(HTMLVideoElemen
     UNUSED_PARAM(addResult);
     ASSERT(addResult.iterator->value == contextId);
 
-    RefPtr<VideoFullscreenModelVideoElement> model;
-    RefPtr<VideoFullscreenInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto [model, interface] = ensureModelAndInterface(contextId);
     addClientForContext(contextId);
     if (!interface->layerHostingContext())
         interface->setLayerHostingContext(LayerHostingContext::createForExternalHostingProcess());
@@ -369,9 +361,7 @@ void VideoFullscreenManager::requestUpdateInlineRect(uint64_t contextId)
 
 void VideoFullscreenManager::requestVideoContentLayer(uint64_t contextId)
 {
-    RefPtr<VideoFullscreenModelVideoElement> model;
-    RefPtr<VideoFullscreenInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto [model, interface] = ensureModelAndInterface(contextId);
 
     CALayer* videoLayer = interface->layerHostingContext()->rootLayer();
 
@@ -406,9 +396,7 @@ void VideoFullscreenManager::didSetupFullscreen(uint64_t contextId)
     LOG(Fullscreen, "VideoFullscreenManager::didSetupFullscreen(%p, %x)", this, contextId);
 
     ASSERT(m_page);
-    RefPtr<VideoFullscreenModelVideoElement> model;
-    RefPtr<VideoFullscreenInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto [model, interface] = ensureModelAndInterface(contextId);
 
 #if PLATFORM(IOS_FAMILY)
     dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), this, contextId] {
@@ -431,9 +419,7 @@ void VideoFullscreenManager::willExitFullscreen(uint64_t contextId)
 {
     LOG(Fullscreen, "VideoFullscreenManager::willExitFullscreen(%p, %x)", this, contextId);
 
-    RefPtr<VideoFullscreenModelVideoElement> model;
-    RefPtr<VideoFullscreenInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto [model, interface] = ensureModelAndInterface(contextId);
 
     RefPtr<HTMLVideoElement> videoElement = model->videoElement();
     if (!videoElement)
@@ -450,9 +436,7 @@ void VideoFullscreenManager::didEnterFullscreen(uint64_t contextId)
 {
     LOG(Fullscreen, "VideoFullscreenManager::didEnterFullscreen(%p, %x)", this, contextId);
 
-    RefPtr<VideoFullscreenModelVideoElement> model;
-    RefPtr<VideoFullscreenInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto [model, interface] = ensureModelAndInterface(contextId);
 
     interface->setIsAnimating(false);
     interface->setIsFullscreen(false);
@@ -510,9 +494,7 @@ void VideoFullscreenManager::didCleanupFullscreen(uint64_t contextId)
 {
     LOG(Fullscreen, "VideoFullscreenManager::didCleanupFullscreen(%p, %x)", this, contextId);
 
-    RefPtr<VideoFullscreenModelVideoElement> model;
-    RefPtr<VideoFullscreenInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto [model, interface] = ensureModelAndInterface(contextId);
 
     if (interface->layerHostingContext()) {
         interface->layerHostingContext()->setRootLayer(nullptr);
@@ -572,9 +554,7 @@ void VideoFullscreenManager::setVideoLayerFrameFenced(uint64_t contextId, WebCor
         return;
     }
 
-    RefPtr<VideoFullscreenModelVideoElement> model;
-    RefPtr<VideoFullscreenInterfaceContext> interface;
-    std::tie(model, interface) = ensureModelAndInterface(contextId);
+    auto [model, interface] = ensureModelAndInterface(contextId);
 
     if (std::isnan(bounds.x()) || std::isnan(bounds.y()) || std::isnan(bounds.width()) || std::isnan(bounds.height())) {
         auto videoRect = inlineVideoFrame(*model->videoElement());
index f1dd4a1..0797db0 100644 (file)
@@ -1,3 +1,18 @@
+2019-07-03  Sam Weinig  <weinig@apple.com>
+
+        Adopt simple structured bindings in more places
+        https://bugs.webkit.org/show_bug.cgi?id=199247
+
+        Reviewed by Alex Christensen.
+
+        Replaces simple uses of std::tie() with structured bindings. Does not touch
+        uses of std::tie() that are not initial declarations, use std::ignore or in
+        case where the binding is captured by a lambda, as structured bindings don't
+        work for those cases yet.
+
+        * WebView/WebImmediateActionController.mm:
+        (-[WebImmediateActionController _animationControllerForText]):
+
 2019-07-02  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Debug: "Reset Web Inspector" should also clear the saved window size and attachment side
index 281a1e9..f7936b5 100644 (file)
@@ -558,9 +558,7 @@ static IntRect elementBoundingBoxInWindowCoordinatesFromNode(Node* node)
     if (!frame)
         return nil;
 
-    RefPtr<Range> dictionaryRange;
-    NSDictionary *options;
-    std::tie(dictionaryRange, options) = DictionaryLookup::rangeAtHitTestResult(_hitTestResult);
+    auto [dictionaryRange, options] = DictionaryLookup::rangeAtHitTestResult(_hitTestResult);
     if (!dictionaryRange)
         return nil;
 
index 8fb514c..0f9aa75 100644 (file)
@@ -1,3 +1,18 @@
+2019-07-03  Sam Weinig  <weinig@apple.com>
+
+        Adopt simple structured bindings in more places
+        https://bugs.webkit.org/show_bug.cgi?id=199247
+
+        Reviewed by Alex Christensen.
+
+        Replaces simple uses of std::tie() with structured bindings. Does not touch
+        uses of std::tie() that are not initial declarations, use std::ignore or in
+        case where the binding is captured by a lambda, as structured bindings don't
+        work for those cases yet.
+
+        * TestWebKitAPI/ios/PreferredContentMode.mm:
+        (TestWebKitAPI::TEST):
+
 2019-07-03  Aakash Jain  <aakash_jain@apple.com>
 
         Unreviewed follow-up fix to r247049, default the platform to '*' when platform property is not set.
index bebc49b..70a3f38 100644 (file)
@@ -217,30 +217,32 @@ TEST(PreferredContentMode, SetDefaultWebpagePreferences)
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
 
-    RetainPtr<WKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
-    [webView loadHTMLString:@"<pre>Foo</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
-        EXPECT_EQ(WKContentModeRecommended, defaultPreferences.preferredContentMode);
-        decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
-    }];
-    [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
-    EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
-
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop);
-    [webView loadHTMLString:@"<pre>Bar</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
-        EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
-        decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
-    }];
-    [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
-    EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+    {
+        auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+        [webView loadHTMLString:@"<pre>Foo</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+            EXPECT_EQ(WKContentModeRecommended, defaultPreferences.preferredContentMode);
+            decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
+        }];
+        [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+        EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+    }
 
-    [webView loadHTMLString:@"<pre>Baz</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
-        EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
-        decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:WKContentModeMobile]);
-    }];
-    [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil];
-    EXPECT_TRUE([[webView navigatorPlatform] containsString:@"iP"]);
+    {
+        auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop);
+        [webView loadHTMLString:@"<pre>Bar</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+            EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
+            decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
+        }];
+        [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Mac", @"TestWebKitAPI", nil];
+        EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+
+        [webView loadHTMLString:@"<pre>Baz</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+            EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
+            decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:WKContentModeMobile]);
+        }];
+        [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (iP", @"TestWebKitAPI", nil];
+        EXPECT_TRUE([[webView navigatorPlatform] containsString:@"iP"]);
+    }
 }
 
 TEST(PreferredContentMode, DesktopModeWithoutNavigationDelegate)
@@ -264,9 +266,7 @@ TEST(PreferredContentMode, DesktopModeOnPhone)
 {
     IPhoneUserInterfaceSwizzler iPhoneUserInterface;
 
-    RetainPtr<WKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+    auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>();
     [webView loadHTMLString:@"<pre>Foo</pre>" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
         EXPECT_EQ(WKContentModeRecommended, defaultPreferences.preferredContentMode);
         decisionHandler(WKNavigationActionPolicyAllow, [WKWebpagePreferences preferencesWithContentMode:WKContentModeDesktop]);
@@ -286,9 +286,7 @@ TEST(PreferredContentMode, DesktopModeTopLevelFrameSupercedesSubframe)
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
 
-    RetainPtr<WKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+    auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>();
 
     __block BOOL decidedPolicyForMainFrame = NO;
     __block BOOL decidedPolicyForSubFrame = NO;
@@ -314,9 +312,7 @@ TEST(PreferredContentMode, DesktopModeUsesNativeViewportByDefault)
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
 
-    RetainPtr<WKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+    auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>();
 
     [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)];
     EXPECT_EQ(1024, [[webView objectByEvaluatingJavaScript:@"innerWidth"] intValue]);
@@ -334,9 +330,7 @@ TEST(PreferredContentMode, CustomUserAgentOverridesDesktopContentModeUserAgent)
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
 
-    RetainPtr<TestWKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<TestWKWebView>(WKContentModeDesktop);
+    auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<TestWKWebView>(WKContentModeDesktop);
 
     NSString *customUserAgent = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
     [webView setCustomUserAgent:customUserAgent];
@@ -352,9 +346,7 @@ TEST(PreferredContentMode, DoNotAllowChangingDefaultWebpagePreferencesInDelegate
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
 
-    RetainPtr<TestWKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<TestWKWebView>(WKContentModeDesktop);
+    auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<TestWKWebView>(WKContentModeDesktop);
 
     [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
         EXPECT_EQ(WKContentModeDesktop, defaultPreferences.preferredContentMode);
@@ -374,9 +366,7 @@ TEST(PreferredContentMode, EffectiveContentModeOnIPad)
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
 
-    RetainPtr<TestWKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+    auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>();
 
     [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:nil];
     [webView loadTestPageNamed:@"simple2" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)];
@@ -387,9 +377,7 @@ TEST(PreferredContentMode, EffectiveContentModeOnPhone)
 {
     IPhoneUserInterfaceSwizzler iPhoneUserInterface;
 
-    RetainPtr<TestWKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+    auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>();
 
     [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:nil];
     [webView loadTestPageNamed:@"simple2" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:makeContentModeDecisionHandler(WKContentModeDesktop)];
@@ -400,9 +388,7 @@ TEST(PreferredContentMode, RecommendedContentModeAtVariousViewWidths)
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
 
-    RetainPtr<TestWKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>({ }, { "TestWebKitAPI" }, CGSizeZero);
+    auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>({ }, { "TestWebKitAPI" }, CGSizeZero);
     [webView loadTestPageNamed:@"simple" andExpectEffectiveContentMode:WKContentModeDesktop withPolicyDecisionHandler:nil];
     [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"TestWebKitAPI", nil];
 
@@ -419,20 +405,20 @@ TEST(PreferredContentMode, ApplicationNameForDesktopUserAgent)
 {
     IPadUserInterfaceSwizzler iPadUserInterface;
 
-    RetainPtr<TestWKWebView> webView;
-    RetainPtr<ContentModeNavigationDelegate> delegate;
-    std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>();
-    [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
-        defaultPreferences._applicationNameForUserAgentWithModernCompatibility = @"DesktopBrowser";
-        decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
-    }];
-    [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"DesktopBrowser", nil];
-    EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+    {
+        auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>();
+        [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:^(WKNavigationAction *, WKWebpagePreferences *defaultPreferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+            defaultPreferences._applicationNameForUserAgentWithModernCompatibility = @"DesktopBrowser";
+            decisionHandler(WKNavigationActionPolicyAllow, defaultPreferences);
+        }];
+        [[webView navigatorUserAgent] shouldContainStrings:@"Mozilla/5.0 (Macintosh", @"DesktopBrowser", nil];
+        EXPECT_WK_STREQ("MacIntel", [webView navigatorPlatform]);
+    }
 
     {
         // Don't attempt to change the application name, but still opt into desktop-class browsing;
         // the application name should not default to "Mobile/15E148".
-        std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop, { });
+        auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop, { });
         [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:nil];
         NSString *userAgent = [webView navigatorUserAgent];
         EXPECT_FALSE([userAgent containsString:@"Mobile"]);
@@ -441,7 +427,7 @@ TEST(PreferredContentMode, ApplicationNameForDesktopUserAgent)
     {
         // Don't attempt to change the application name, but this time, opt into mobile content. The application
         // name should default to "Mobile/15E148".
-        std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeMobile, { });
+        auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeMobile, { });
         [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:nil];
         NSString *userAgent = [webView navigatorUserAgent];
         EXPECT_TRUE([userAgent containsString:@"Mobile"]);
@@ -449,7 +435,7 @@ TEST(PreferredContentMode, ApplicationNameForDesktopUserAgent)
     }
     {
         // Manually set the application name for user agent to the default value, Mobile/15E148.
-        std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop, { "Mobile/15E148" });
+        auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop, { "Mobile/15E148" });
         [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:nil];
         NSString *userAgent = [webView navigatorUserAgent];
         EXPECT_TRUE([userAgent containsString:@"Mobile"]);
@@ -457,7 +443,7 @@ TEST(PreferredContentMode, ApplicationNameForDesktopUserAgent)
     }
     {
         // Manually set the application name for user agent to nil.
-        std::tie(webView, delegate) = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop, {{ }});
+        auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeDesktop, {{ }});
         [webView loadTestPageNamed:@"simple" withPolicyDecisionHandler:nil];
         NSString *userAgent = [webView navigatorUserAgent];
         EXPECT_FALSE([userAgent containsString:@"Mobile"]);