2018-01-05 Jason Marcell Cherry-pick r226457. rdar://problem/36323985 2018-01-05 Said Abou-Hallawa SVGAnimatedListPropertyTearOff::synchronizeWrappersIfNeeded() should do nothing if the property is not animating https://bugs.webkit.org/show_bug.cgi?id=181316 Reviewed by Simon Fraser. This is a speculative change to fix a crash which appeared after r226065. The crash is very intermittent and sometimes very hard to reproduce. The basic code analysis did not show how this crash can even happen. * svg/SVGAnimatedTypeAnimator.h: (WebCore::SVGAnimatedTypeAnimator::resetFromBaseValues): For SVG property with two values, e.g. , we need to detach the wrappers of the animated property if the animated values are going to change. This is similar to what we did in resetFromBaseValue(). * svg/properties/SVGAnimatedListPropertyTearOff.h: (WebCore::SVGAnimatedListPropertyTearOff::synchronizeWrappersIfNeeded): 2017-12-18 Jason Marcell Apply patch. rdar://problem/36257607 Reduce the precision of "high" resolution time to 1ms https://bugs.webkit.org/show_bug.cgi?id=180910 Reviewed by Saam Barati. Add a flaky test expectation to imported/w3c/web-platform-tests/workers/worker-performance.worker.html due to a test bug. The test fix is tracked in https://github.com/w3c/web-platform-tests/pull/8711 * TestExpectations: 2017-12-18 Ryosuke Niwa Reduce the precision of "high" resolution time to 1ms https://bugs.webkit.org/show_bug.cgi?id=180910 Reviewed by Saam Barati. Reduced the high prevision time's resolution to 1ms, the same precision as Date.now(). Also fixed the bug in fillRTCStats that we weren't reducing the time resolution in RTCStats dictionaries. * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: (WebCore::fillRTCStats): * page/Performance.cpp: (WebCore::Performance::reduceTimeResolution): 2017-12-18 Jason Marcell Cherry-pick r226065. rdar://problem/36080413 2017-12-18 Zalan Bujtas [SVG] Detach list wrappers before resetting the base value. https://bugs.webkit.org/show_bug.cgi?id=180912 Reviewed by Simon Fraser. Before resetting the animation value (and destroying the assigned SVG object -SVGLengthValue in this case), we need to check if there's an associated tear off wrapper for the said SVG object and make a copy of it. This is currently done in the wrong order through animValDidChange. Test: svg/animations/crash-when-animation-is-running-while-getting-value.html * svg/SVGAnimatedTypeAnimator.h: (WebCore::SVGAnimatedTypeAnimator::resetFromBaseValue): * svg/properties/SVGAnimatedPropertyTearOff.h: * svg/properties/SVGAnimatedStaticPropertyTearOff.h: (WebCore::SVGAnimatedStaticPropertyTearOff::synchronizeWrappersIfNeeded): 2017-12-18 Jason Marcell Revert r225497. rdar://problem/36112729 2017-12-06 Jason Marcell Cherry-pick r225497. rdar://problem/34604139 2017-12-04 Zalan Bujtas REGRESSION (r211531): Text flow changes and overlaps other text after double-click selecting paragraph https://bugs.webkit.org/show_bug.cgi?id=180377 Reviewed by Antti Koivisto. Take floats into account when computing the available width for a certain vertical position. Test: fast/block/float/simple-line-layout-float-shrink-line.html * rendering/SimpleLineLayout.cpp: (WebCore::SimpleLineLayout::updateLineConstrains): 2017-12-05 Jason Marcell Cherry-pick r225528. rdar://problem/35838154 2017-12-05 Alex Christensen Fix non-unified build after r225381 https://bugs.webkit.org/show_bug.cgi?id=180434 Reviewed by Keith Miller. * loader/ResourceTimingInformation.cpp: FrameLoader.h is included in other files that are combined with this file in unified builds, but we need to merge r225381 to a branch that doesn't use unified builds. This build failure would've come up randomly in the future when we add files, too. 2017-12-04 Jason Marcell Cherry-pick r225381. rdar://problem/35838154 2017-11-30 Alex Christensen Extra PerformanceEntryList entry after iframe navigation https://bugs.webkit.org/show_bug.cgi?id=178433 Reviewed by Joseph Pecoraro. Test: http/tests/security/PerformanceEntryList-parent-only-first-navigation.html When an iframe is loaded, its main resource load should be reported to the parent frame's PerformanceEntryList. Subsequent main resource loads should not. * loader/FrameLoader.h: (WebCore::FrameLoader::shouldReportResourceTimingToParentFrame): * loader/ResourceTimingInformation.cpp: (WebCore::ResourceTimingInformation::addResourceTiming): 2017-11-30 Jason Marcell Cherry-pick r225141. rdar://problem/35732184 2017-11-24 Antti Koivisto Style resolution spin due to calc() values always comparing inequal (seen on arstechnica.com) https://bugs.webkit.org/show_bug.cgi?id=179982 Reviewed by Darin Adler. Test: transitions/transition-with-calc-spin.html Something like calc(100% - 10px) would compare inequal to itself. This causes the implicit animation engine think that there is a new target value after style resolution and restart the transition. Starting the transition triggers another style resolution on zero duration timer and so on. * platform/CalculationValue.cpp: (WebCore::operator==): * platform/CalculationValue.h: Deep compare the child vectors. 2017-11-03 Jason Marcell Cherry-pick r224405. rdar://problem/35339758 2017-11-03 Ryosuke Niwa Crash inside ChildListMutationAccumulator::enqueueMutationRecord() https://bugs.webkit.org/show_bug.cgi?id=179234 Reviewed by Darin Adler. Fixed the crash by keeping MutationObserver referenced by MutationObserverInterestGroup alive. Also added hasCallback() virtual function on MutationObserver to check whether the callback is alive to work around the bug that JS function referenced by MutationObserver isn't kept alive. We'll address this bug separately in https://webkit.org/b/179224. Test: fast/dom/MutationObserver/disconnect-observer-while-mutation-records-are-enqueued-crash.html * bindings/scripts/CodeGeneratorJS.pm: (GenerateCallbackHeaderContent): Added an override for the newly added virtual hasCallback(). * dom/MutationCallback.h: * dom/MutationObserver.cpp: (WebCore::MutationObserver::deliver): Added the aforementioned workaround. * dom/MutationObserverInterestGroup.cpp: (WebCore::MutationObserverInterestGroup::MutationObserverInterestGroup): Fixed the crash by using Ref. (WebCore::MutationObserverInterestGroup::enqueueMutationRecord): Ditto. * dom/MutationObserverInterestGroup.h: * dom/NativeNodeFilter.cpp: (WebCore::NativeNodeFilter::hasCallback const): Always return true here. This function is never called but we still need to implement it since NodeFilter has a pure virtual hasCallback() now. * dom/NativeNodeFilter.h: * dom/Node.cpp: (WebCore::collectMatchingObserversForMutation): Use Ref to fix the crash. (WebCore::Node::registeredMutationObservers): Ditto. * dom/Node.h: * dom/NodeFilter.h: 2017-11-22 Jason Marcell Cherry-pick r224398. rdar://problem/35329715 2017-11-03 Daniel Bates Invalidate node list when associated form control element is removed https://bugs.webkit.org/show_bug.cgi?id=179232 Reviewed by Ryosuke Niwa. A node list represents a live view of the DOM. Invalidate the node list associated with a form element whenever one of its associated form control elements is removed. Test: fast/forms/node-list-remove-button-from-form.html * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::removeFormElement): 2017-10-29 Jason Marcell Cherry-pick r224134. rdar://problem/35143359 2017-10-27 Daniel Bates Only allow non-mixed content protected subresources to ask for credentials https://bugs.webkit.org/show_bug.cgi?id=178919 Reviewed by Alex Christensen. Only allow non-mixed content protected subresources to ask for credentials. It is not meaningful to allow protected mixed-content subresources to ask for credentials. Tests: http/tests/security/mixedContent/insecure-image-redirects-to-basic-auth-secure-image.html http/tests/security/mixedContent/insecure-script-redirects-to-basic-auth-secure-script.html http/tests/security/mixedContent/insecure-stylesheet-redirects-to-basic-auth-secure-stylesheet.html http/tests/security/mixedContent/secure-redirect-to-insecure-redirect-to-basic-auth-secure-image.https.html http/tests/security/mixedContent/secure-redirect-to-secure-redirect-to-basic-auth-insecure-image.https.html http/tests/security/mixedContent/secure-redirect-to-secure-redirect-to-basic-auth-secure-image.https.html * loader/ResourceLoader.cpp: (WebCore::ResourceLoader::ResourceLoader): Initialize m_canAskClientForCredentials based on the specified resource loader options. (WebCore::ResourceLoader::init): Update m_canAskClientForCredentials based on the URL of the initial request. (WebCore::ResourceLoader::isMixedContent const): Helper function to check if the specified URL represents a mixed content resource. (WebCore::ResourceLoader::willSendRequestInternal): If the original request or the redirect request is mixed content then update state such that we will disallow asking for credentials. (WebCore::ResourceLoader::isAllowedToAskUserForCredentials const): Modified to use m_canAskClientForCredentials when determining whether the request is allowed to ask for credentials. * loader/ResourceLoader.h: 2017-10-27 Jason Marcell Cherry-pick r221233. rdar://problem/35228663 2017-08-27 Wenson Hsieh [iOS WK2] Web process crashes after changing selection to the end of the document when speaking a selection https://bugs.webkit.org/show_bug.cgi?id=176011 Reviewed by Ryosuke Niwa. Adds a null check to visiblePositionForPositionWithOffset. This is a crash point for accessibility codepaths, since indexForVisiblePosition is not guaranteed to set the given `root` outparam to a non-null value, yet visiblePositionForIndex requires root to be non-null. This causes a crash when selecting some text, hitting 'Speak', and then changing the selection to somewhere near the end of the document, since accessibility code will attempt to speak words at an offset past the end of the document. While this is a bug in and of itself, the web process should still handle this case gracefully and not crash. To fix this, we simply bail and return a null VisiblePosition if a root container node was not found. Currently, visiblePositionForPositionWithOffset is implemented twice, in WebCore (AXObjectCache.cpp) and also in WebKit (WebPageIOS.mm), as identical static functions. This patch moves this helper into Editing.cpp and removes it from AXObjectCache and WebPageIOS. Tests: AccessibilityTests.RectsForSpeakingSelectionBasic AccessibilityTests.RectsForSpeakingSelectionWithLineWrapping AccessibilityTests.RectsForSpeakingSelectionDoNotCrashWhenChangingSelection * accessibility/AXObjectCache.cpp: (WebCore::visiblePositionForPositionWithOffset): Deleted. * editing/Editing.cpp: (WebCore::visiblePositionForPositionWithOffset): * editing/Editing.h: 2017-10-26 Jason Marcell Cherry-pick r223974. rdar://problem/35178887 2017-10-25 Jer Noble UNPACK_FLIP_Y is broken for MSE-backed videos https://bugs.webkit.org/show_bug.cgi?id=178774 Reviewed by Dean Jackson. The global GLSL variable gl_Position can apparently only be set once, and any modifications made after that initial set are ignored. So rather than implement flipping by changing gl_Position.y, flip the texture coordinates instead. Drive-by fix: some of the constants used in VideoTextureCopierCV are not defined on older macOS versions, so make them optional. Tests: fast/canvas/webgl/texImage2D-mse-flipY-false.html fast/canvas/webgl/texImage2D-mse-flipY-true.html * platform/graphics/cv/VideoTextureCopierCV.cpp: (WebCore::transferFunctionFromString): (WebCore::VideoTextureCopierCV::initializeUVContextObjects): * platform/cocoa/CoreVideoSoftLink.cpp: * platform/cocoa/CoreVideoSoftLink.h: 2017-10-25 Jason Marcell Cherry-pick r223960. rdar://problem/35178892 2017-10-25 Jer Noble Autoplay muted videos still stop playback of other streaming apps in the background https://bugs.webkit.org/show_bug.cgi?id=177920 Reviewed by Eric Carlson. When creating a new