2014-09-13 Babak Shafiei Merge r173595 2014-09-12 Tim Horton Swiping back from a Twitter image to Twitter flashes to the wrong position https://bugs.webkit.org/show_bug.cgi?id=136798 Reviewed by Darin Adler and Sam Weinig. * UIProcess/mac/ViewGestureController.h: * UIProcess/mac/ViewGestureControllerMac.mm: (WebKit::ViewGestureController::ViewGestureController): (WebKit::ViewGestureController::didFinishLoadForMainFrame): (WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame): Add a 250ms repeating timer that we start in didFinishLoadForMainFrame if we are for some reason still loading, and in didSameDocumentNavigationForMainFrame unconditionally, to match behavior of the old swipe implementation. Also, do the active gesture check in both of those places so that we don't start the timer if we're in the middle of a live swipe or have already torn down the snapshot (removeSwipeSnapshotAfterRepaint does this as well, so this isn't really a behavior change). (WebKit::ViewGestureController::activeLoadMonitoringTimerFired): Every time the timer fires, check if we're still loading; if not, tear down the swipe snapshot (after repainting). (WebKit::ViewGestureController::removeSwipeSnapshotAfterRepaint): Stop the active load monitoring timer. 2014-09-12 Lucas Forschler Merge r173573 2014-09-12 Tim Horton Flash of page scrolled to wrong origin before restoring scroll position after swiping back to CNN front page from an article https://bugs.webkit.org/show_bug.cgi?id=136788 Reviewed by Sam Weinig. * UIProcess/mac/ViewGestureControllerMac.mm: (WebKit::ViewGestureController::didHitRenderTreeSizeThreshold): (WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame): Always wait until didFinishLoadForMainFrame or didSameDocumentNavigationForMainFrame before removing the snapshot, because otherwise we don't know if the scroll position has been restored yet. We should revisit this at some point, because it should be possible to determine if the scroll position has been restored appropriately, but for now it is safest to restore the antique behavior. 2014-08-29 Lucas Forschler Merge r173121 2014-08-29 Alexey Proskuryakov Crashes in IPC code under VisitedLinkProvider::pendingVisitedLinksTimerFired https://bugs.webkit.org/show_bug.cgi?id=136384 rdar://problem/16991213 Reviewed by Sam Weinig. VisitedLinkProvider process tracking relied on a combination of WebPageProxy process lifecycle notifications and checking process state. As evidenced by multiple FIXMEs, these are not yet as reliable as they should be. Changed to unregister a process when it closes, not when it no longer has any pages using the particular VisitedLinkProvider or WebUserContentControllerProxy. This is a deoptimization that should not matter in practice. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): * UIProcess/UserContent/WebUserContentControllerProxy.h: * UIProcess/VisitedLinkProvider.cpp: (WebKit::VisitedLinkProvider::~VisitedLinkProvider): (WebKit::VisitedLinkProvider::removeProcess): (WebKit::VisitedLinkProvider::removeAll): (WebKit::VisitedLinkProvider::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkProvider::resizeTable): * UIProcess/VisitedLinkProvider.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::WebPageProxy): (WebKit::WebPageProxy::close): (WebKit::WebPageProxy::processDidFinishLaunching): (WebKit::WebPageProxy::resetStateAfterProcessExited): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::disconnect): (WebKit::WebProcessProxy::addVisitedLinkProvider): (WebKit::WebProcessProxy::addWebUserContentControllerProxy): (WebKit::WebProcessProxy::didDestroyVisitedLinkProvider): (WebKit::WebProcessProxy::didDestroyWebUserContentControllerProxy): * UIProcess/WebProcessProxy.h: 2014-08-29 Lucas Forschler Merge r173118 2014-08-29 Alexey Proskuryakov WebPageProxy::close() is a no-op for terminated processes https://bugs.webkit.org/show_bug.cgi?id=136378 Related to and to Reviewed by Brady Eidson. Also fixes issues that got uncovered after making close() work. * UIProcess/WebInspectorProxy.cpp: (WebKit::WebInspectorProxy::invalidate): Don't close the page, because it makes no sense, and causes an assertion now. Previosly, this was OK because the page was invalid already, and close() was a no-op. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::~WebPageProxy): Added some assertions to catch invalidation issues earlier. (WebKit::WebPageProxy::reattachToWebProcess): Make it an invariant that a page's process always has a message receiver for it, until close() removes it. (WebKit::WebPageProxy::close): Make this function work for all open pages, whether they have a page or not. (WebKit::WebPageProxy::processDidFinishLaunching): Added an asserion that process agrees about its state. (WebKit::WebPageProxy::resetStateAfterProcessExited): Don't remove a message receiver, we now only do this in reattach or close. 2014-08-28 Lucas Forschler Merge r173093 2014-08-28 Tim Horton _setDidMoveSwipeSnapshotCallback's block should only be called if the snapshot is going to move https://bugs.webkit.org/show_bug.cgi?id=136354 Reviewed by Simon Fraser. * UIProcess/API/Cocoa/WKViewPrivate.h: Update the comment to note the new behavior. * UIProcess/mac/ViewGestureControllerMac.mm: (WebKit::ViewGestureController::beginSwipeGesture): Don't call the block until the snapshot is actually moving (if the snapshot never moves because it's behind the live view, don't call the block at all). 2014-08-28 Lucas Forschler Merge r173092 2014-08-28 Tim Horton Occasional thread-safety-related crashes on the ServicesController queue https://bugs.webkit.org/show_bug.cgi?id=136356 Reviewed by Dan Bernstein. * UIProcess/mac/ServicesController.mm: (WebKit::hasCompatibleServicesForItems): Added. Check directly with NSSharingService if we have any services for the given items. We should eventually check Viewer and Editor services separately so the Web process can be smarter about when it shows the overlay, but for now this maintains the existing behavior. (WebKit::ServicesController::refreshExistingServices): Make use of hasCompatibleServicesForItems instead of having NSSharingServicePicker construct NSMenus. 2014-08-28 Lucas Forschler Merge r172989 2014-08-26 Joseph Pecoraro FileReader cannot read files selected with in iOS 8 https://bugs.webkit.org/show_bug.cgi?id=136117 Reviewed by Alexey Proskuryakov. * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb: Correct an overzealous deny that was accidentally denying all com.apple.app-sandbox.read extensions instead of just the ones in Application bundles it was trying to deny. 2014-08-28 Lucas Forschler Merge r171782 2014-07-29 Enrica Casucci REGRESSION [WebKit2 iOS]: Cannot add shortcut to user dictionary from non editable content. https://bugs.webkit.org/show_bug.cgi?id=135392 Reviewed by Benjamin Poulain. Adding a shortcut to the user dictionary needs to be available in non editable content too. * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _addShortcut:]): 2014-08-28 Lucas Forschler Merge r173078 2014-08-28 Tim Horton WebKit2 doesn't support viewer services that accept image attachments https://bugs.webkit.org/show_bug.cgi?id=136349 Reviewed by Brady Eidson. * Shared/WebProcessCreationParameters.cpp: (WebKit::WebProcessCreationParameters::encode): (WebKit::WebProcessCreationParameters::decode): Encode the already-existing parameter. 2014-08-28 Lucas Forschler Merge r173040 2014-08-27 Tim Horton WebKit2 swipe gesture should report the position of the snapshot to the client https://bugs.webkit.org/show_bug.cgi?id=136308 rdar://problem/18105827 Reviewed by Simon Fraser. * UIProcess/API/Cocoa/WKViewPrivate.h: * UIProcess/API/mac/WKView.mm: (-[WKView _setDidMoveSwipeSnapshotCallback:]): Add _setDidMoveSwipeSnapshotCallback, and plumb it to ViewGestureController. Callers provide a block which is called whenever ViewGestureController moves the swipe *snapshot* layer around. * UIProcess/PageClient.h: * UIProcess/WebPageProxy.h: * UIProcess/mac/PageClientImpl.h: * UIProcess/mac/PageClientImpl.mm: (WebKit::PageClientImpl::boundsOfLayerInLayerBackedWindowCoordinates): * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::boundsOfLayerInLayerBackedWindowCoordinates): Expose a Mac-only way to get the bounds of a given CALayer in window coordinates, respecting transforms. This only works for layer-backed windows because it uses CA in order to do the mapping respecting transforms. * UIProcess/mac/ViewGestureController.h: * UIProcess/mac/ViewGestureControllerMac.mm: (WebKit::ViewGestureController::ViewGestureController): (WebKit::ViewGestureController::~ViewGestureController): (WebKit::ViewGestureController::setDidMoveSwipeSnapshotCallback): Do the Block_copy and Block_release dance to keep our copy of the callback block. (WebKit::ViewGestureController::beginSwipeGesture): (WebKit::ViewGestureController::handleSwipeGesture): (WebKit::ViewGestureController::didMoveSwipeSnapshotLayer): When the swipe snapshot layer moves around, call the block. 2014-08-28 Lucas Forschler Merge r173029 2014-08-27 Tim Horton Occasional crashes in commitTransientZoom's transaction completion block https://bugs.webkit.org/show_bug.cgi?id=136309 Reviewed by Dan Bernstein. * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: (WebKit::TiledCoreAnimationDrawingArea::commitTransientZoom): Hold a reference to zoomLayer and the WebPage. It's possible that either of these things could have gone away by the time the transaction is committed. 2014-08-28 Lucas Forschler Merge r172939 2014-08-25 Brady Eidson Don't crash when the DataDetectors framework is unavailable. and https://bugs.webkit.org/show_bug.cgi?id=136234 Reviewed by Tim Horton. * WebProcess/WebPage/mac/ServicesOverlayController.mm: (WebKit::ServicesOverlayController::buildPhoneNumberHighlights): Bail if DD.framework didn’t soft link. (WebKit::ServicesOverlayController::buildSelectionHighlight): Ditto. 2014-08-26 Dana Burkart Merge r172988. 2014-08-26 Tim Horton Crashes in ViewGestureController::beginSwipeGesture when swiping in rapid succession https://bugs.webkit.org/show_bug.cgi?id=136271 Reviewed by Simon Fraser. It was possible to get into trackSwipeGesture while another swipe was still occurring, because the guard against this happening depended on m_pendingSwipeReason never being set while a swipe was occurring. However, if the very first scroll event had sufficient magnitude, we would still set m_pendingSwipeReason to InsufficientMagnitude, and then *never clear it*, leading to a path around the guard against multiple live swipes. This in turn allowed stale layers in m_liveSwipeLayers, which lead to the crash. * UIProcess/mac/ViewGestureControllerMac.mm: (WebKit::ViewGestureController::handleScrollWheelEvent): Don't unset m_pendingSwipeReason before calling trackSwipeGesture; trackSwipeGesture will do it itself. Don't set m_pendingSwipeReason to InsufficientMagnitude if the event actually *has* sufficient magnitude to start a swipe. (WebKit::ViewGestureController::trackSwipeGesture): Assert that we don't have an active gesture while starting a swipe. Reset m_pendingSwipeReason, because the swipe is no longer pending! 2014-08-26 Dana Burkart Merge r172966. 2014-08-26 Tim Horton REGRESSION (r172771): Amazon product page becomes unresponsive after swiping back to it https://bugs.webkit.org/show_bug.cgi?id=136260 Reviewed by Dan Bernstein. Previously, when a swipe ended up performing a same-document navigation, we would never get didFinishLoadForMainFrame nor didFirstVisuallyNonEmptyLayoutForMainFrame nor would we even get didHitRenderTreeSizeThreshold in all cases, so we would never remove the swipe snapshot. Previous implementations removed the snapshot on didSameDocumentNavigation for the main frame if the navigation type was Replace or Pop, so we will match that behavior. Also, reinstate the watchdog that starts at swipe-end which would have prevented this bug from forever breaking the view it was associated with. Also, defend against removing the snapshot before the swipe has finished (before we have even caused the navigation that we're watching for the effects of). * UIProcess/API/mac/WKView.mm: (-[WKView _didSameDocumentNavigationForMainFrame:]): * UIProcess/API/mac/WKViewInternal.h: * UIProcess/PageClient.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::didSameDocumentNavigationForFrame): * UIProcess/ios/PageClientImplIOS.h: * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame): * UIProcess/mac/PageClientImpl.h: * UIProcess/mac/PageClientImpl.mm: (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame): Plumb main-frame same-document navigation notification from WebPageProxy to ViewGestureControllerMac via PageClient and WKView. * UIProcess/mac/ViewGestureController.h: * UIProcess/mac/ViewGestureControllerMac.mm: (WebKit::ViewGestureController::ViewGestureController): (WebKit::ViewGestureController::beginSwipeGesture): (WebKit::ViewGestureController::endSwipeGesture): Keep track of whether a swipe is currently occurring. We can't use activeGestureType for this because the swipe currently remains the "active" gesture until the snapshot is removed. Reintroduce the old swipeWatchdogTimer (and rename the shorter timer that starts when we get a visually non-empty layout) so that we will always remove the snapshot after 5 seconds, even if we haven't committed the load. This could lead to flashing back to the old content if we fail to get a single byte for 5 seconds, but that is a rare case and should eventually get additional special treatment (dropping the tiles until we do get content, or some such). (WebKit::ViewGestureController::didHitRenderTreeSizeThreshold): If a swipe is still in progress, we haven't done our navigation and thus don't care about render tree size changes. (WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame): If a swipe is still in progress, we haven't done our navigation and thus don't care about layouts. Stop the 5 second overall watchdog if we start the 3 second after-visuallyNonEmptyLayout watchdog. This means that the snapshot could stay up for a maximum of 8 seconds for a very, very slow load. (WebKit::ViewGestureController::didFinishLoadForMainFrame): If a swipe is still in progress, we haven't done our navigation and thus don't care about loads that complete. (WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame): Remove the swipe snapshot after painting if we do replaceState or popState. (WebKit::ViewGestureController::removeSwipeSnapshotAfterRepaint): If a swipe is still in progress, we shouldn't remove the snapshot yet. 2014-08-19 Dana Burkart Merge r172643. 2014-08-15 Enrica Casucci [Services with UI] Selections are incorrect when selecting three lines. https://bugs.webkit.org/show_bug.cgi?id=135989 Reviewed by Tim Horton. The stitching algorithm did not handle correctly the case of selections over three lines if the middle line is composed of only one rectangle. * WebProcess/WebPage/mac/ServicesOverlayController.mm: (WebKit::stitchRects): 2014-08-19 Dana Burkart Merge r172639. 2014-08-15 Tim Horton Service overlays stay fixed when