2017-11-03 Jason Marcell Cherry-pick r224405. rdar://problem/35296404 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-03 Jason Marcell Cherry-pick r224398. rdar://problem/35329684 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