2017-03-23 Andreas Kling Let the UI process do memory kills and replace crashes with diagnostic logging. Reviewed by Chris Dumez. Remove the memory kill code from WebCore that just crashes in favor of controlled teardown from UI process side in WebKit2. * page/DiagnosticLoggingKeys.cpp: (WebCore::DiagnosticLoggingKeys::simulatedProcessCrashKey): (WebCore::DiagnosticLoggingKeys::exceededActiveMemoryLimitKey): (WebCore::DiagnosticLoggingKeys::exceededInactiveMemoryLimitKey): (WebCore::DiagnosticLoggingKeys::exceededBackgroundCPULimitKey): * page/DiagnosticLoggingKeys.h: * page/MemoryRelease.cpp: (WebCore::didExceedMemoryLimitAndFailedToRecover): Deleted. * page/MemoryRelease.h: 2017-03-23 Youenn Fablet Clean RTCPeerConnection.idl after bug 169978 https://bugs.webkit.org/show_bug.cgi?id=169989 Reviewed by Eric Carlson. No change of behavior. Moving addTransceiver to overloaded method to union type to match spec. Refactoring RTCRtpSender to take a String&&. * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask): * Modules/mediastream/RTCPeerConnection.cpp: (WebCore::RTCPeerConnection::addTransceiver): (WebCore::RTCPeerConnection::completeAddTransceiver): * Modules/mediastream/RTCPeerConnection.h: * Modules/mediastream/RTCPeerConnection.idl: Cosmetic changes except for addTransceiver. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::create): (WebCore::RTCRtpSender::RTCRtpSender): * Modules/mediastream/RTCRtpSender.h: 2017-03-23 Youenn Fablet Add logging in case libwebrtc.dylib cannot be opened https://bugs.webkit.org/show_bug.cgi?id=170017 Reviewed by Geoffrey Garen. No change of behavior. * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp: (WebCore::LibWebRTCProvider::webRTCAvailable): 2017-03-23 Jiewen Tan Unreviewed, a speculative build fix * crypto/CommonCryptoUtilities.h: 2017-03-23 Brady Eidson WebSQL databases should not openable in private browsing. and https://bugs.webkit.org/show_bug.cgi?id=170013 Reviewed by Alex Christensen. Test: storage/websql/private-browsing-open-disabled.html * Modules/webdatabase/DatabaseManager.cpp: (WebCore::DatabaseManager::openDatabaseBackend): (WebCore::DatabaseManager::tryToOpenDatabaseBackend): Throw an exception if in private browsing. * Modules/webdatabase/DatabaseManager.h: 2017-03-22 Dean Jackson NeverDestroyed must explicitly construct with a String https://bugs.webkit.org/show_bug.cgi?id=169987 Reviewed by Alex Christensen. CSSDefaultStyleSheets creates a static MediaQueryEvaluator, but thanks to the template magic of NeverDestroyed, it was converting the char* argument into a bool, and calling the wrong constructor. Unfortunately this is difficult to test because it only affects the default UA style sheets, and they currently don't have and @media rules (which would always evaluate to true given the bug). I don't want to put in a useless rule just to check if the bug is fixed. When one is added for bug 168447, this change will be exercised. * css/CSSDefaultStyleSheets.cpp: Explicitly construct with a String rather than a char*. (WebCore::screenEval): (WebCore::printEval): 2017-03-23 Eric Carlson [MediaStream] Make mock video source work on iOS https://bugs.webkit.org/show_bug.cgi?id=169923 Reviewed by Youenn Fablet. Generate IOSurface-backed CVPixelBuffers. Allocate them from a CVPixelBufferPool for efficiency. No new tests, no functional change. * platform/cocoa/CoreVideoSoftLink.cpp: * platform/cocoa/CoreVideoSoftLink.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoTransformationMatrix): * platform/mediastream/mac/MockRealtimeVideoSourceMac.h: * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: (WebCore::MockRealtimeVideoSourceMac::pixelBufferFromCGImage): (WebCore::MockRealtimeVideoSourceMac::applySize): * platform/mock/MockRealtimeVideoSource.h: 2017-03-22 Andreas Kling Let MemoryPressureHandler track whether the process is active or inactive. Reviewed by Antti Koivisto. Have PerformanceMonitor inform MemoryPressureHandler about relevant changes to the page activity states. Also change the "1 hour after last page load" policy to "1 hour after last being visible in an active window." * page/MainFrame.cpp: (WebCore::MainFrame::didCompleteLoad): * page/MainFrame.h: * page/MemoryRelease.cpp: (WebCore::processIsEligibleForMemoryKill): Deleted. * page/MemoryRelease.h: * page/Page.h: (WebCore::Page::performanceMonitor): * page/PerformanceMonitor.cpp: (WebCore::PerformanceMonitor::PerformanceMonitor): (WebCore::PerformanceMonitor::activityStateChanged): (WebCore::PerformanceMonitor::processMayBecomeInactiveTimerFired): (WebCore::PerformanceMonitor::updateProcessStateForMemoryPressure): * page/PerformanceMonitor.h: 2017-03-22 Youenn Fablet Support RTCPeerConnectionState https://bugs.webkit.org/show_bug.cgi?id=169978 Reviewed by Jon Lee. Test: webrtc/connection-state.html Implementing https://www.w3.org/TR/webrtc/#rtcpeerconnectionstate-enum. Its state and event is based on changes made to ice gathering state and ice connection state. * CMakeLists.txt: Adding RTCPeerConnectionState idl. * DerivedSources.make: Ditto. * Modules/mediastream/RTCPeerConnection.cpp: Splitting close in doClose/doStop so that we can send closed event in case close is called, but not if stopped. (WebCore::RTCPeerConnection::doClose): (WebCore::RTCPeerConnection::close): (WebCore::RTCPeerConnection::stop): (WebCore::RTCPeerConnection::doStop): (WebCore::RTCPeerConnection::updateIceGatheringState): (WebCore::RTCPeerConnection::updateIceConnectionState): (WebCore::RTCPeerConnection::updateConnectionState): * Modules/mediastream/RTCPeerConnection.h: * Modules/mediastream/RTCPeerConnection.idl: Fixing IDL and minor cosmetic changes * Modules/mediastream/RTCPeerConnection.js: (setLocalDescription): Cosmetic change. (setRemoteDescription): * Modules/mediastream/RTCPeerConnectionState.idl: Added. * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: (WebCore::LibWebRTCMediaEndpoint::OnIceGatheringChange): Adding 'gathering' state * WebCore.xcodeproj/project.pbxproj: * dom/EventNames.h: * platform/mediastream/RTCPeerConnectionState.h: Added. 2017-03-22 Jiewen Tan ASSERT_WITH_SECURITY_IMPLICATION hit when removing an while dragging on iOS https://bugs.webkit.org/show_bug.cgi?id=165535 Reviewed by Ryosuke Niwa. Utimately we should prevent SliderThumbElement::unregisterForTouchEvents() being called while updating render tree. A quick fix for this is to move dispatchFormControlChangeEvent for input from stopDragging up to the callers which really needs to dispatch this event, i.e., finishing dragging the slider. It is clear that not every caller of stopDragging wants to dispatchFormControlChangeEvent. Test: fast/forms/range/range-remove-on-drag.html * html/shadow/SliderThumbElement.cpp: (WebCore::SliderThumbElement::stopDragging): (WebCore::SliderThumbElement::defaultEventHandler): (WebCore::SliderThumbElement::handleTouchEndAndCancel): 2017-03-22 Antti Koivisto Dynamically applied :empty pseudo class with display:none does not get unapplied https://bugs.webkit.org/show_bug.cgi?id=169907 Reviewed by Ryosuke Niwa. We improperly reset the styleAffectedByEmpty bit when removing the renderer when :empty starts applying. We then fail to invalidate the style when the element becomes non-empty again. Fix by resetting the style relation bits only when computing the style. Test: fast/css/empty-display-none-invalidation.html * dom/Element.cpp: (WebCore::Element::resetStyleRelations): Expose this separately. (WebCore::Element::clearStyleDerivedDataBeforeDetachingRenderer): Don't reset style relation bits when removing renderers. * dom/Element.h: * dom/ElementRareData.h: (WebCore::ElementRareData::resetComputedStyle): (WebCore::ElementRareData::resetStyleRelations): Reset all these bits in one function. (WebCore::ElementRareData::resetDynamicRestyleObservations): Deleted. * style/StyleTreeResolver.cpp: (WebCore::Style::resetStyleForNonRenderedDescendants): (WebCore::Style::TreeResolver::resolveComposedTree): Call the explicit style relation reset function when recomputing style. 2017-03-22 Michael Catanzaro [GTK] Honor GTK+ font settings https://bugs.webkit.org/show_bug.cgi?id=82889 Reviewed by Carlos Garcia Campos. After much discussion with Behdad and Martin (who is still not completely convinced I think :) I want to merge cairo font options into the Fontconfig pattern used for rendering using cairo_ft_font_options_substitute(). This is how the API was designed to be used anyway. Fontconfig will still have final say over whether to actually respect the desktop settings or not, so it can still choose to ignore the desktop's settings, but I don't think it makes sense to have desktop-wide font settings and not tell Fontconfig about them, especially when the whole point of WebKitGTK+ is desktop integration. This should also reduce complaints that we're not following desktop settings and that we're drawing fonts differently than Firefox. * PlatformGTK.cmake: * platform/graphics/cairo/CairoUtilities.cpp: (WebCore::getDefaultCairoFontOptions): * platform/graphics/cairo/CairoUtilities.h: * platform/graphics/freetype/FontCacheFreeType.cpp: (WebCore::createFontConfigPatternForCharacters): (WebCore::strongAliasesForFamily): (WebCore::FontCache::createFontPlatformData): * platform/graphics/freetype/FontPlatformDataFreeType.cpp: (WebCore::getDefaultFontconfigOptions): (WebCore::getDefaultCairoFontOptions): Deleted. * platform/graphics/gtk/GdkCairoUtilities.cpp: (getDefaultCairoFontOptions): 2017-03-22 Antoine Quint [Modern Media Controls] Controls size lags behind media size https://bugs.webkit.org/show_bug.cgi?id=169962 Reviewed by Dean Jackson. We used to dispatch the "resize" event to the shadow root on a timer and commit changes to the DOM when handling it inside of a requestAnimationFrame() callback. We now dispatch the "resize" event as a post-layout task and commit to the DOM right away which ensures immediate size changes of the controls. * Modules/modern-media-controls/controls/ios-inline-media-controls.js: (IOSInlineMediaControls.prototype.layout): * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js: (MacOSFullscreenMediaControls.prototype.layout): * Modules/modern-media-controls/controls/macos-inline-media-controls.js: (MacOSInlineMediaControls.prototype.layout): Making some layout() safer by returning early in case they're called during the object construction phase, due to the LayoutNode "width" setter now calling that method. * Modules/modern-media-controls/controls/media-controls.js: (MediaControls.prototype.get width): (MediaControls.prototype.set width): Calling layout() in the "width" setter to ensure that the inline controls layout is invalidated as soon as the controls width changes instead of waiting on the next rAF to update the layout. * Modules/modern-media-controls/controls/scheduler.js: (const.scheduler.new.prototype.flushScheduledLayoutCallbacks): Add a new method to immediately call queued layouts. * Modules/modern-media-controls/media/media-controller.js: (MediaController.prototype.handleEvent): Flush all queued layouts when handling a "resize" event. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::layoutSizeChanged): Queue the "resize" event as a post-layout task. (WebCore::HTMLMediaElement::contextDestroyed): * html/HTMLMediaElement.h: Remove the queue we no longer use. 2017-03-22 Andy Estes Try to fix the Mac CMake build after r214266. * PlatformMac.cmake: 2017-03-22 Chris Dumez WebKit should disallow beforeunload alerts from web pages users have never interacted with https://bugs.webkit.org/show_bug.cgi?id=169936 Reviewed by Brent Fulgham. WebKit should disallow beforeunload alerts from web pages users have never interacted with. This reduces the risk of annoyance to the user and is allowed by the specification: - https://html.spec.whatwg.org/multipage/browsers.html#prompt-to-unload-a-document (Step 8): which says: """ The user agent is encouraged to avoid asking the user for confirmation if it judges that doing so would be annoying, deceptive, or pointless. A simple heuristic might be that if the user has not interacted with the document, the user agent would not ask for confirmation before unloading it. """ Firefox already implements this, Chrome does not. Tests: fast/events/beforeunload-alert-no-user-interaction.html fast/events/beforeunload-alert-user-interaction.html fast/events/beforeunload-alert-user-interaction2.html * loader/FrameLoader.cpp: (WebCore::shouldAskForNavigationConfirmation): (WebCore::FrameLoader::dispatchBeforeUnloadEvent): 2017-03-22 Brent Fulgham ASan violation in IconLoader::stopLoading https://bugs.webkit.org/show_bug.cgi?id=169960 Reviewed by David Kilzer. DocumentLoader::finishLoadingIcon handles the life cycle of the IconLoader. Once this method is called, we should return immediately rather than attempt to make further modifications to the IconLoader. No new tests due to lack of test features (see https://bugs.webkit.org/show_bug.cgi?id=164895). Easily tested in MiniBrowser under ASan visiting websites with icons. * loader/icon/IconLoader.cpp: (WebCore::IconLoader::notifyFinished): 2017-03-22 Nan Wang AX: WebKit is returning the wrong rangeForLine https://bugs.webkit.org/show_bug.cgi?id=169940 Reviewed by Chris Fleizach. The AXRangeForLine is being calculated using VisiblePostition, so when we try to use the index we should validate it using VisiblePosition. Changes are covered in the modified test. * accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::traverseToOffsetInRange): (WebCore::AXObjectCache::characterOffsetForIndex): 2017-03-22 John Wilander Resource Load Statistics: Fix partitioning bug for client-side cookie access https://bugs.webkit.org/show_bug.cgi?id=169906 Reviewed by Alex Christensen. The existing test case was expanded to cover this change. * platform/network/NetworkStorageSession.h: Moved the two cookieStoragePartition() functions into the class. Also declared them const. * platform/network/cf/NetworkStorageSessionCFNet.cpp: (WebCore::NetworkStorageSession::cookieStoragePartition): Now checks whether it should partition or not. (WebCore::getPartitioningDomain): Inline convenience function. (WebCore::NetworkStorageSession::shouldPartitionCookies): Renamed since it now receives a top privately controlled domain instead of a host. (WebCore::cookieStoragePartition): Deleted. This moved into NetworkStorageSession. (WebCore::hostIsInDomain): Deleted. No longer needed since we generate the top privately controlled domain for both the resource and the partition. (WebCore::NetworkStorageSession::shouldPartitionCookiesForHost): Deleted. Renamed WebCore::NetworkStorageSession::shouldPartitionCookies(). * platform/network/mac/CookieJarMac.mm: (WebCore::cookiesInPartitionForURL): Now calls WebCore::NetworkStorageSession::cookieStoragePartition(). (WebCore::setCookiesFromDOM): Now calls WebCore::NetworkStorageSession::cookieStoragePartition(). * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::createNSURLConnection): Now calls WebCore::NetworkStorageSession::cookieStoragePartition(). 2017-03-22 Jer Noble Media files served without an extension will not load in