2021-12-16 Brent Fulgham Rename forEachFrameFromMainFrame to forEachFrame https://bugs.webkit.org/show_bug.cgi?id=234396 Reviewed by Geoffrey Garen. Follow-up to r287110: Switch method naming to match 'forEachDocument'. * page/Page.cpp: (WebCore::Page::~Page): (WebCore::Page::notifyToInjectUserScripts): (WebCore::Page::forEachFrame): (WebCore::Page::forEachFrameFromMainFrame): Deleted. * page/Page.h: 2022-03-24 Kimmo Kinnunen REGRESSION (r287807): WEBGL_multi_draw validation rejecting valid arguments https://bugs.webkit.org/show_bug.cgi?id=238239 Reviewed by Darin Adler. Fix off-by-one error causing full buffer multidraws to be marked as invalid. Enable the newer WebGL conformance tests that test this. * html/canvas/WebGLMultiDraw.cpp: (WebCore::WebGLMultiDraw::validateOffset): 2022-01-07 Brent Fulgham [Hardening] Improve multi draw offset validation https://bugs.webkit.org/show_bug.cgi?id=234966 Reviewed by Darin Adler. Incorporate draw count into validation of the offset. * html/canvas/WebGLMultiDraw.cpp: (WebCore::WebGLMultiDraw::validateOffset): 2022-01-31 Brent Fulgham Fix handling of access key events https://bugs.webkit.org/show_bug.cgi?id=234147 Reviewed by David Kilzer. Improve focus handling for HTMLElement-based elements to ensure accessKey events are properly dispatched. * accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::press): Ensure correct object is used after 'accessKeyAction' is invoked. * dom/EventDispatcher.cpp: (WebCore::callDefaultEventHandlersInBubblingOrder) Protect element during default event bubbling. * html/HTMLFormControlElement.cpp: (WebCore::HTMLFormControlElement::reportValidity): Ensure correct element is used after focus event. * page/EventHandler.cpp: (WebCore::EventHandler::handleAccessKey): Ensure correct object is used after 'accessKeyAction' is invoked. 2021-12-15 Brent Fulgham Clean-up: Adopt Page::forEachDocument in some missed spots https://bugs.webkit.org/show_bug.cgi?id=234324 Reviewed by Darin Adler. Switch manual loops to our 'forEachDocument' style in a few places that were missed in earlier refactoring. No change in behavior. * history/BackForwardCache.cpp: (WebCore::setBackForwardCacheState) * page/EventHandler.cpp: (WebCore::removeDraggedContentDocumentMarkersFromAllFramesInPage): * page/Frame.cpp: (WebCore::Frame::orientationChanged): * page/Page.cpp: (WebCore::Page::~Page): (WebCore::Page::forEachDocumentFromMainFrame): Added. (WebCore::Page::forEachDocument): Use new method. (WebCore::Page::forEachFrameFromMainFrame): Added. (WebCore::Page::windowScreenDidChange): (WebCore::Page::userAgentChanged): * page/ios/FrameIOS.mm: (WebCore::Frame::dispatchPageHideEventBeforePause): (WebCore::Frame::dispatchPageShowEventBeforeResume): 2022-02-16 Adrian Perez de Castro [CMake] Cannot find OpenGL when system provides opengl.pc instead of gl.pc https://bugs.webkit.org/show_bug.cgi?id=236592 Reviewed by Don Olmstead. * CMakeLists.txt: Use the OpenGL::OpenGL and OpenGL::GLX imported targets instead of variables. * platform/graphics/GLContext.cpp: Move here includes for the GL headers. * platform/graphics/GLContext.h: Remove includes for the GL headers, none of their declarations are used here; instead include only the needed EGL headers to get the definition of EGLNativeWindowType. 2022-02-14 Simon Fraser Fix crash with deeply nested async overflow scroll https://bugs.webkit.org/show_bug.cgi?id=236599 rdar://88656665 Reviewed by Alan Bujtas. mergeClippingScopesRecursive() already does the append of the rects; doing so before calling recursing triggers double appends, hence exponentially growing rect lists. Test: compositing/layer-creation/clipping-scope/deeply-nested-overflow.html * rendering/LayerOverlapMap.cpp: (WebCore::OverlapMapContainer::mergeClippingScopesRecursive): 2022-02-14 Frédéric Wang Nullptr crash in CompositeEditCommand::splitTreeToNode via InsertParagraphSeparatorCommand::doApply https://bugs.webkit.org/show_bug.cgi?id=229283 Reviewed by Ryosuke Niwa. Position::upstream handles edge cases like tables specially which can lead to InsertParagraphSeparatorCommand::doApply incorrectly expecting a next sibling after a text node at last position in order to perform a split. This patch works around that by ignoring the split in that case. Test: editing/inserting/insert-paragraph-separator-with-inline-table-bold-crash.html * editing/InsertParagraphSeparatorCommand.cpp: (WebCore::InsertParagraphSeparatorCommand::doApply): Only try and remove remaining nodes if splitTo is not null. moveRemainingSiblingsToNewParent will be a no-op when n is null. Also switch from raw pointers to RefPtr. 2022-02-10 Antti Koivisto [:has() pseudo-class] Nullptr crash with non-function :has https://bugs.webkit.org/show_bug.cgi?id=236431 rdar://87061239 Reviewed by Cameron McCormack. Test: fast/selectors/malformed-has.html * css/parser/CSSSelectorParser.cpp: (WebCore::isOnlyPseudoClassFunction): :has() is legal, plain :has is not. 2022-02-11 Michael Catanzaro [GTK] WebKit browser scrollbars not always correctly displayed if overlay scrollbars are disabled https://bugs.webkit.org/show_bug.cgi?id=234874 Reviewed by Carlos Garcia Campos. If overlay scrollbars are disabled, and there is not enough content for the page to be scrollable, and scrollbars are forced using overflow:scroll, then we currently fail to paint the scrollbars properly. At minimum, we need to paint the scrollbar background, which is what the macOS port does. Do so. In the future, we might want to additionally paint the rest of the scrollbars, similar to the GTK_POLICY_ALWAYS scrollbar policy type, but this would require more work. * platform/adwaita/ScrollbarThemeAdwaita.cpp: (WebCore::ScrollbarThemeAdwaita::paint): * platform/gtk/ScrollbarThemeGtk.cpp: (WebCore::ScrollbarThemeGtk::paint): 2022-02-15 Carlos Garcia Campos [GTK] D-Bus crash atk-bridge https://bugs.webkit.org/show_bug.cgi?id=236208 Reviewed by Adrian Perez de Castro. When a root is unregistered, check first if the registration is still pending to just complete and remove it. * accessibility/atspi/AccessibilityAtspi.cpp: (WebCore::AccessibilityAtspi::unregisterRoot): 2022-02-15 Adrian Perez de Castro [GTK][WPE] Inclusion of OpenGLShims.h should not depend on USE(GLX) https://bugs.webkit.org/show_bug.cgi?id=236593 Reviewed by Michael Catanzaro. No new tests needed. * platform/graphics/GLContext.cpp: Remove inclusion of OpenGLShims.h guarded by USE(GLX). * platform/graphics/GLContext.h: Include OpenGLShims.h as fallback option when neither USE(LIBEPOXY) nor USE(OPENGL_ES) are into effect. 2022-01-24 Yusuke Suzuki Expand RefPtr / Ref use in FrameLoader https://bugs.webkit.org/show_bug.cgi?id=235551 rdar://87986840 Reviewed by Mark Lam. Apply Ref / RefPtr instead of taking SerializedScriptValue*. * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadInSameDocument): (WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy): * loader/FrameLoader.h: 2022-02-10 Alexander Mikhaylenko [GTK] Scrollbars painted incorrectly if theme enables steppers (steppers misplaced on vertical scrollbars, horizontal scrollbars very broken) https://bugs.webkit.org/show_bug.cgi?id=234871 Reviewed by Carlos Garcia Campos. Actually use the scrollbar orientation when creating its contents, instead of always using vertical. * platform/gtk/RenderThemeScrollbar.cpp: (WebCore::RenderThemeScrollbar::RenderThemeScrollbar): 2022-02-05 Philippe Normand [Flatpak SDK] Update to FDO 21.08.10 and GStreamer 1.20 releases https://bugs.webkit.org/show_bug.cgi?id=236136 Reviewed by Adrian Perez de Castro. Switch GStreamer 1.19 version checks to 1.20 now that it is officially released. Also include a couple fixes that are needed with GStreamer 1.20 and one that is useful whatever the GStreamer version: - GStreamer 1.20 ships a vp8alphadecodebin element able to handle video/x-vp8 caps, so our libwebrtc decoder factory needs to account for its presence, in addition to vp8dec. - With GStreamer 1.20 media/media-source/media-source-seek-back.html started racy crashing in the VideoTrackPrivateGStreamer configuration update, where the track was disconnected (hence its stream was cleared) and then a GObject notification was emitted by decodebin3. We should actually disconnect the GObject signal handlers before clearing the stream, to prevent potential null pointer access. * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp: (WebCore::AudioFileReader::handleNewDeinterleavePad): * platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp: (WebCore::AudioSourceProviderGStreamer::handleNewDeinterleavePad): * platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp: (WebCore::AudioTrackPrivateGStreamer::updateConfigurationFromCaps): (WebCore::AudioTrackPrivateGStreamer::disconnect): * platform/graphics/gstreamer/GStreamerCommon.h: * platform/graphics/gstreamer/ImageDecoderGStreamer.cpp: (WebCore::ImageDecoderGStreamer::InnerDecoder::connectDecoderPad): * platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp: (WebCore::VideoTrackPrivateGStreamer::updateConfigurationFromCaps): (WebCore::VideoTrackPrivateGStreamer::disconnect): * platform/mediastream/libwebrtc/gstreamer/GStreamerVideoDecoderFactory.cpp: (WebCore::VP8Decoder::Create): 2022-02-07 Adrian Perez de Castro Unreviewed non-unified build fixes. * Modules/webxr/XRReferenceSpaceEvent.cpp: Add missing wtf/IsoMallocInlines.h header. * Modules/webxr/XRReferenceSpaceEvent.h: Add missing wtf/IsoMalloc.h header. * css/calc/CSSCalcOperationNode.cpp: Add missing Logging.h header. * css/calc/CSSCalcPrimitiveValueNode.cpp: Ditto. * layout/formattingContexts/FormattingQuirks.cpp: Add missing LayoutState.h header. 2022-02-03 Frédéric Wang null ptr deref in RenderTreeBuilder::Block::attachIgnoringContinuation https://bugs.webkit.org/show_bug.cgi?id=234170 Reviewed by Antti Koivisto. When an element with "display: contents" is put into the top layer, its computed style for the display property becomes "block" [1]. However, RenderTreeUpdater::updateElementRenderer does not manage well this transition. In particular, a null ptr deref happens for some special configuration involving a . To work around that issue, always force tearing down renderers when updating an element in the top layer. [1] https://fullscreen.spec.whatwg.org/#new-stacking-layer Test: fast/layers/top-layer-display-contents-crash.html * rendering/updating/RenderTreeUpdater.cpp: (WebCore::RenderTreeUpdater::updateElementRenderer): Always force tearing down renderers for top layer element. 2022-02-01 Andres Gonzalez Check AccessibilityRenderObject::m_renderer for null before using it. https://bugs.webkit.org/show_bug.cgi?id=235950 Reviewed by Chris Fleizach. AccessibilityRenderObject::m_renderer is a WeakPtr that can become null due to a variety of changes in the render tree. This patch fixes a number of cases where AccessibilityRenderObject::m_renderer was being used without checking for null which leads to crashes such as: https://bugs.webkit.org/show_bug.cgi?id=235945 https://bugs.webkit.org/show_bug.cgi?id=235827 * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::parentObjectIfExists const): (WebCore::AccessibilityRenderObject::selection const): (WebCore::AccessibilityRenderObject::setSelectedTextRange): (WebCore::AccessibilityRenderObject::documentLinks): (WebCore::AccessibilityRenderObject::setSelectedVisiblePositionRange const): 2022-02-01 Antti Koivisto AX: nullptr crash under AccessibilityRenderObject::computeAccessibilityIsIgnored https://bugs.webkit.org/show_bug.cgi?id=235945 rdar://88217815 Reviewed by Andres Gonzalez. This is similar to https://bugs.webkit.org/show_bug.cgi?id=161276. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const): m_renderer is a WeakPtr and can become null during parentObjectUnignored call, same as the case below. 2022-01-27 Gabriel Nava Marino jsc_fuz/wktr: crash with new XRReferenceSpaceEvent('', {referenceSpace}) https://bugs.webkit.org/show_bug.cgi?id=235456 Reviewed by Chris Dumez. FastMalloc.h specifies that each derived class needs to be annotated as well with WTF_MAKE_ISO_ALLOCATED if the base class is annotated with WTF_MAKE_ISO_ALLOCATED. After doing this, the crash in WebCore::Event::operator new(unsigned long) is no longer reproducible. However, this caused ASSERT(m_transform) to be hit in debug builds with the attached test case. The XRReferenceSpaceEvent spec specifies the transform attribute as nullable (https://immersive-web.github.io/webxr/#dictdef-xrreferencespaceeventinit), so this patch updates the XRReferenceSpaceEvent IDL and implementation to match the spec, and removes the ASSERT accordingly. Test: webxr/xr-reference-space-event-crash.html * Modules/webxr/XRReferenceSpaceEvent.cpp: (WebCore::XRReferenceSpaceEvent::XRReferenceSpaceEvent): (WebCore::XRReferenceSpaceEvent::transform const): * Modules/webxr/XRReferenceSpaceEvent.h: * Modules/webxr/XRReferenceSpaceEvent.idl: 2022-01-25 Alexey Shvayka XPath::Step::nodesInAxis(): add null checks after Attr::ownerElement() calls https://bugs.webkit.org/show_bug.cgi?id=235500 Reviewed by Darin Adler. This patch adds null checks for results of Attr::ownerElement() to avoid crashes when evaluating XPath expressions with an orphaned Attr as the context node. Inspired by the recent Blink fix [1], yet this change covers all null pointer dereferencing sites, as proven by the updated test. [1] https://bugs.chromium.org/p/chromium/issues/detail?id=1236967 Test: imported/w3c/web-platform-tests/domxpath/xpath-evaluate-crash.html * xml/XPathStep.cpp: (WebCore::XPath::Step::nodesInAxis const): 2022-01-23 Antoine Quint m_lastStyleChangeEventStyle null ptr deref for accelerated CSS Animation with no duration and an implicit keyframe https://bugs.webkit.org/show_bug.cgi?id=235394 Reviewed by Antti Koivisto. Test: webanimations/accelerated-animation-without-duration-crash.html In r287827, the fix for bug 235014, we stopped filling implicit keyframes for CSS Animations at creation time such that the output of getKeyframes() would correctly account for the missing keyframes. This meant that we have to fill in those implicit keyframes when running an accelerated animation before we pass it on to GraphicsLayer. We would always use the value stored by lastStyleChangeEventStyle() with an assert that this value was never null. However, in the case of an animation that is not relevant, such as a CSS Animation with no duration, we've never had a chance to set that style since Style::TreeResolver::createAnimatedElementUpdate() would not see any "relevant" (a term defined by the Web Animations specification to specify an animation that has an effect on its target) animations. We now use the renderer's style as a fallback, which is guaranteed to be defined at this stage. * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::applyPendingAcceleratedActions): 2022-01-21 Antti Koivisto WPT version of css/css-cascade/parsing/layer-import-parsing.html crashes with nullptr https://bugs.webkit.org/show_bug.cgi?id=235434 rdar://87832940 Reviewed by Alan Bujtas. Test: fast/css/insert-import-rule-crash.html * css/StyleRuleImport.cpp: (WebCore::StyleRuleImport::setCSSStyleSheet): Null check the parent stylesheet. It can be null if the rule has been removed. * dom/InlineStyleSheetOwner.cpp: (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet): Also fix a debug assert in addPendingSheet, this can get called multiple times. 2022-01-19 Rob Buis Null check player in taintsOrigin https://bugs.webkit.org/show_bug.cgi?id=234257 Reviewed by Youenn Fablet. Null check player in taintsOrigin. Test: fast/media/createImageBitmap-from-video-crash.html * html/ImageBitmap.cpp: (WebCore::taintsOrigin): 2022-02-04 Alexander Mikhaylenko [GTK] Crash when starting DND on touchscreen https://bugs.webkit.org/show_bug.cgi?id=235694 Reviewed by Adrian Perez de Castro. * page/DragController.cpp: (WebCore::DragController::startDrag): Skip drags for touch events on GTK. * platform/PlatformMouseEvent.h: (WebCore::PlatformMouseEvent::isTouchEvent const): 2021-11-20 Carlos Garcia Campos Report the initiating url instead of the redirected one https://bugs.webkit.org/show_bug.cgi?id=233037 Reviewed by Brent Fulgham. As per the spec, blockedURI should use the requested URL of original request instead of redirected location. * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::isAllowedByContentSecurityPolicy): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::willSendRequestInternal): * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const): (WebCore::CachedResourceLoader::canRequestAfterRedirection const): (WebCore::CachedResourceLoader::updateRequestAfterRedirection): * loader/cache/CachedResourceLoader.h: * page/csp/ContentSecurityPolicy.cpp: (WebCore::ContentSecurityPolicy::allowChildContextFromSource const): (WebCore::ContentSecurityPolicy::allowScriptFromSource const): (WebCore::ContentSecurityPolicy::allowImageFromSource const): (WebCore::ContentSecurityPolicy::allowStyleFromSource const): (WebCore::ContentSecurityPolicy::allowFontFromSource const): (WebCore::ContentSecurityPolicy::allowManifestFromSource const): (WebCore::ContentSecurityPolicy::allowMediaFromSource const): * page/csp/ContentSecurityPolicy.h: 2021-11-04 Kate Cheney Form action with a redirect should report correct blocked URI https://bugs.webkit.org/show_bug.cgi?id=232660 Reviewed by Brent Fulgham. We currently report the blocked URI as the target of a redirect, per the spec it should actually be the initiating url. Test: http/tests/security/contentSecurityPolicy/form-action-redirect-with-correct-blocked-uri.html * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::willSendRequest): * loader/FrameLoader.cpp: (WebCore::FrameLoader::checkIfFormActionAllowedByCSP const): * loader/FrameLoader.h: * page/csp/ContentSecurityPolicy.cpp: (WebCore::ContentSecurityPolicy::allowResourceFromSource const): (WebCore::ContentSecurityPolicy::allowFormAction const): * page/csp/ContentSecurityPolicy.h: 2021-11-30 Chris Dumez Scripting attributes are sometimes not properly stripped from elements when JS is disabled https://bugs.webkit.org/show_bug.cgi?id=233642 Reviewed by Geoffrey Garen. HTMLConstructionSite::mergeAttributesFromTokenIntoElement() was not properly stripping scripting Element attributes when scripting is disabled, unlike other code paths in HTMLConstructionSite(). Covered by new API tests. * html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::mergeAttributesFromTokenIntoElement): 2022-01-21 Mike Gorse Build failure with g++ 12: std::exchange undefined https://bugs.webkit.org/show_bug.cgi?id=235445 Reviewed by Michael Catanzaro. * platform/graphics/x11/XUniqueResource.h: Include 2022-01-19 Rob Buis Null check m_progressTracker in clearProvisionalLoad https://bugs.webkit.org/show_bug.cgi?id=233063 Reviewed by Alex Christensen. Null check m_progressTracker in clearProvisionalLoad. Test: fast/frames/contentFrame-disconnecting-crash.html * loader/FrameLoader.cpp: (WebCore::FrameLoader::clearProvisionalLoad): 2022-01-14 Frederic Wang null ptr deref in WebCore::ReplaceSelectionCommand::moveNodeOutOfAncestor() https://bugs.webkit.org/show_bug.cgi?id=233463 Reviewed by Wenson Hsieh. One line of ReplaceSelectionCommand::moveNodeOutOfAncestor() assumes that the pointer ancestor.parentNode() is non-null. However, the call to removeNode(node) just before can lead to arbitrary tree mutations that leaves the ancestor orphan, causing a nullptr deref. This patch mitigates that issue by exiting early if that situation happens. * editing/ReplaceSelectionCommand.cpp: (WebCore::ReplaceSelectionCommand::moveNodeOutOfAncestor): Exit early if the ancestor is no longer connected. 2022-01-10 Alan Bujtas null ptr deref in WebCore::LayoutIntegration::LineLayout::collectOverflow() https://bugs.webkit.org/show_bug.cgi?id=234654 Reviewed by Antti Koivisto. needsLayout() check in invalidateLineLayoutPath is insufficient for modern line layout. m_lineLayout = std::monostate() does not only destroy the line layout object but it also nukes all the IFC geometries. It is equivalent to having all the child boxes dirty, since in order to re-generate the geometry information, we have to layout _all_ the boxes (note that nuking the legacy line layout object does not destroy the inline tree). The bug here is that needsLayout() returns true for cases (e.g. posChildNeedsLayout) when while the geometry is all gone, we are going to take a special layout codepath which expects pre-computed geometries. Test: fast/block/line-layout/line-layout-collect-overflow-crash.html * rendering/RenderBlockFlow.cpp: (WebCore::RenderBlockFlow::invalidateLineLayoutPath): 2022-01-08 Gabriel Nava Marino null ptr deref in WebCore::ModifySelectionListLevelCommand::appendSiblingNodeRange https://bugs.webkit.org/show_bug.cgi?id=234862 Reviewed by Darin Adler. ModifySelectionListLevelCommand::appendSiblingNodeRange loops through nodes assuming existence of siblings, which is not guaranteed, and can result in nullptr deref. Instead, check for node existence as part of loop condition, and change raw pointer usage to RefPtr. This addresses the crash but results in ASSERT(isEndOfParagraph(endOfParagraphToMove)) failing in CompositeEditCommand::moveParagraph. We modify WebCore::findEndOfParagraph to check for HTMLBRElement nodes to avoid unexpectedly changing the AnchorType. Test: http/tests/lists/list-new-parent-no-sibling-append.html * editing/ModifySelectionListLevel.cpp: (WebCore::ModifySelectionListLevelCommand::insertSiblingNodeRangeBefore): (WebCore::ModifySelectionListLevelCommand::insertSiblingNodeRangeAfter): (WebCore::ModifySelectionListLevelCommand::appendSiblingNodeRange): * editing/VisibleUnits.cpp: (WebCore::findEndOfParagraph): 2022-01-05 Chris Dumez [ Monterey Debug arm64 ] ASSERTION FAILED: result == &worker ./workers/service/server/SWServer.cpp(837) : void WebCore::SWServer::workerContextTerminated(WebCore::SWServerWorker &) https://bugs.webkit.org/show_bug.cgi?id=233219 Reviewed by Darin Adler. The crash would occur when we get notified by the service worker process that a given service worker was terminated right after we've determined that we no longer needed a given service worker process and called markAllWorkersForRegistrableDomainAsTerminated(). This race would cause SWServer::workerContextTerminated() to get called twice for the same worker. During the second call, we would retrieve a null worker from the HashMap and hit the assertion. I updated the call to ignore the call to workerContextTerminated() if the worker was already removed from the HashMap and added an assertion to make sure we've already marked the service worker as "not running" in this case. No new tests, covered by existing API test that is flakily crashing in debug. * workers/service/server/SWServer.cpp: (WebCore::SWServer::workerContextTerminated): 2021-12-24 Frederic Wang Simplify test for startOfLastParagraph in InsertListCommand::doApply https://bugs.webkit.org/show_bug.cgi?id=234600 Reviewed by Darin Adler. Current test is !startOfLastParagraph.deepEquivalent().anchorNode()->isConnected(). It could be replaced with the less verbose startOfLastParagraph.isOrphan() which is equivalent to startOfLastParagraph.deepEquivalent().isOrphan() and so to the condition startOfLastParagraph.deepEquivalent().anchorNode() && !startOfLastParagraph.deepEquivalent().anchorNode()->isConnected(). A difference can only happen for a page where anchorNode() is a null pointer. In such a test case exists, then it is already crashing with a null ptr deref anyway. No new tests, behavior essentially unchanged. * editing/InsertListCommand.cpp: (WebCore::InsertListCommand::doApply): Use startOfLastParagraph.isOrphan(). 2021-12-23 Philippe Normand [GStreamer] MediaPlayerPrivateGStreamer mishandles failure to create WebKitTextCombiner https://bugs.webkit.org/show_bug.cgi?id=233230 Reviewed by Michael Catanzaro. Gracefully fail when the subenc plugin is not available. It is optional, we should not assert or crash if it's not found. Two warnings are logged already when it's not found. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): 2021-12-22 Frédéric Wang null ptr deref in DocumentTimeline::animate https://bugs.webkit.org/show_bug.cgi?id=234260 Reviewed by Darin Adler. Test: webanimations/document-timeline-animate-crash.html * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::animate): If the WeakPtr m_document was destroyed, throw a TypeError exception so that the call to WebAnimation::create won't cause a null ptr deref. 2021-12-17 Gabriel Nava Marino null ptr deref in WebCore::findPlaceForCounter https://bugs.webkit.org/show_bug.cgi?id=234375 Reviewed by Alan Bujtas. Test: fast/css/counters/findPlaceForCounter-parent-renderer-crash.html When the current renderer's element is an HTML document and root of the tree, parentOrPseudoHostElement can return a nullptr, so we need to check for nullptr before trying to access the renderer() of the Element pointer it returns. * rendering/RenderCounter.cpp: (WebCore::findPlaceForCounter): 2021-12-16 Rob Buis Mark range boundary point containers https://bugs.webkit.org/show_bug.cgi?id=233462 Reviewed by Darin Adler. Mark range boundary point containers as unreachable for gc. Test: fast/dom/Range/delete-contents-crash.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSRangeCustom.cpp: Added. (WebCore::JSRange::visitAdditionalChildren): * dom/Range.cpp: (WebCore::Range::visitNodesConcurrently const): * dom/Range.h: * dom/Range.idl: 2021-12-15 Gabriel Nava Marino null ptr deref in WebCore::ApplyStyleCommand::applyRelativeFontStyleChange https://bugs.webkit.org/show_bug.cgi?id=234312 Reviewed by Chris Dumez. In some situations calling ApplyStyleCommand::nodeFullySelected forces layout in a way that disconnects the element. In this situation, we now break out of iteration. We also add an isOrphan() check in ApplyStyleCommand::applyInlineStyle given the possibility of this scenario. Test: fast/editing/apply-relative-font-style-change-crash-004.html * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): (WebCore::ApplyStyleCommand::applyInlineStyle): 2021-12-14 Youenn Fablet Null pointer crash in FetchResponse::clone https://bugs.webkit.org/show_bug.cgi?id=234236 Reviewed by Alex Christensen. From the log, we are most probably getting a null globalObject from a ScriptExecutionContext in FetchResponse::clone. This may happen in case the document is navigated away but we still execute some code for it. Add a null check to ensure we do not crash. * Modules/fetch/FetchResponse.cpp: (WebCore::FetchResponse::clone): 2021-12-10 Gabriel Nava Marino nullptr deref in ComputeFloatOffsetForLineLayoutAdapter::updateOffsetIfNeeded https://bugs.webkit.org/show_bug.cgi?id=234018 Reviewed by Alan Bujtas. Test: fast/rendering/floating-object-renderer-crash.html When destroying a given renderer, we first remove floats and out-of-flow positioned objects from their containing block before detaching the renderer from the tree. We do this by obtaining the renderer’s outermost block containing a floating object and recursively marking all siblings and descendants for layout. The criteria for continuing down the list of children require the current block to contain floats or be able to shrink to avoid floats. However, we can have a scenario where the current child block doesn’t have a float, but one of its descendants does. In this case, although we should continue to that descendant and remove the float, we do not. The proposal in this patch will instead check whether the child block contains a float, or any of its descendants do. If so we should continue traversing towards that descendant. * rendering/RenderBlockFlow.cpp: (WebCore::RenderBlockFlow::subtreeContainsFloat const): (WebCore::RenderBlockFlow::subtreeContainsFloats const): (WebCore::RenderBlockFlow::markAllDescendantsWithFloatsForLayout): * rendering/RenderBlockFlow.h: 2021-12-09 Cathie Chen Stack-overflow crash in WebCore::RenderBox::computeLogicalHeight() https://bugs.webkit.org/show_bug.cgi?id=233460 Reviewed by Sergio Villar Senin and Darin Adler. Like flexibleBox item, deprecatedFlexibleBox item should call clearOverridingContentSize if it is positioned. Otherwise, RenderReplaced::computeAspectRatioInformationForRenderBox might call itself recursively. Test: fast/css/deprecated-flex-box-with-min-content-crashes.html * rendering/RenderBox.cpp: (WebCore::RenderBox::styleDidChange): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::isDisplayFlexibleOrGridBoxIncludingDeprecated const): (WebCore::RenderStyle::isDisplayDeprecatedFlexibleBox): 2021-12-06 Rob Buis Null check in shouldUseBreakElement https://bugs.webkit.org/show_bug.cgi?id=229275 Reviewed by Ryosuke Niwa. Need to null check node in shouldUseBreakElement. Also bail out early in InsertLineBreakCommand::doApply in case position is not editable. Test: editing/execCommand/insert-line-break-crash.html * editing/InsertLineBreakCommand.cpp: (WebCore::InsertLineBreakCommand::shouldUseBreakElement): (WebCore::InsertLineBreakCommand::doApply): 2021-12-04 Rob Buis Fix parentNode in CompositeEditCommand::splitTreeToNode https://bugs.webkit.org/show_bug.cgi?id=230710 Reviewed by Ryosuke Niwa. Fix parentNode handling in CompositeEditCommand::splitTreeToNode and also a few more IndentOutdentCommand methods to support the test case. Test: editing/execCommand/outdent-cut-crash.html * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::moveParagraphs): * editing/IndentOutdentCommand.cpp: (WebCore::IndentOutdentCommand::indentIntoBlockquote): do not call positionInParentAfterNode if insertNodeBefore failed. (WebCore::IndentOutdentCommand::outdentParagraph): need to check for null positions before calling moveParagraphs. 2022-01-19 Alex Christensen [ResourceTiming] nextHopProtocol is exposed regardless of Timing-Allow-Origin https://bugs.webkit.org/show_bug.cgi?id=235294 Reviewed by Chris Dumez. Covered by an existing WPT test that starts passing. This was recently fixed in Chromium in https://chromium-review.googlesource.com/c/chromium/src/+/3354335 * page/PerformanceResourceTiming.cpp: (WebCore::PerformanceResourceTiming::nextHopProtocol const): 2021-11-30 Youenn Fablet ServiceWorkerContainer does not respond well to network process crash https://bugs.webkit.org/show_bug.cgi?id=233626 Reviewed by Chris Dumez. Add a boolean to SWClientConnection to identify whether connection is closed. ServiceWorkerContainer will retrieve a new connection if its existing connection is closed. Covered by updated test. * workers/service/SWClientConnection.h: (WebCore::SWClientConnection::isClosed const): (WebCore::SWClientConnection::setIsClosed): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::ensureSWClientConnection): 2021-11-18 Frédéric Wang Nullptr crash in SimplifiedBackwardsTextIterator::range() via previousSentencePosition https://bugs.webkit.org/show_bug.cgi?id=229282 Reviewed by Darin Adler. Constructors of TextIterator and SimplifiedBackwardsTextIterator update layout, which may make HTMLObjectElement switch to fallback content and invalidate their renderer. As a consequence their advance() method may incorrectly treat them as replaced elements. This patch updates the layout at the beginning of FrameSelection::modify and disable post resolution callbacks in order to prevent this kind of unaverted tree changes while browsing the tree for selection update. Test: editing/text-iterator/backward-textiterator-object-crash.html * editing/FrameSelection.cpp: (WebCore::FrameSelection::modify): Update layout and disable post resolution callback, so that all iterators used during the execution of the function handle s consistently. 2021-11-15 Gabriel Nava Marino nullptr deref in CompositeEditCommand::insertNodeAt https://bugs.webkit.org/show_bug.cgi?id=232837 Reviewed by Wenson Hsieh and Darin Adler. Check endingSelection is not orphan before inserting nodes at the start position. Test: fast/editing/editing-position-crash.html * editing/CreateLinkCommand.cpp: (WebCore::CreateLinkCommand::doApply): 2021-11-03 Rob Buis Return nullopt in aspect-ratio+intrinsic width case https://bugs.webkit.org/show_bug.cgi?id=230769 Reviewed by Javier Fernandez. Return nullopt in aspect-ratio+intrinsic width case, while calculating preferred widths we do not know the container width yet, so we can't determine the logical height reliably from it. Test: fast/css-grid-layout/aspect-ratio-auto-repeat-crash.html * rendering/RenderBlock.cpp: (WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const): 2021-10-25 Gabriel Nava Marino ASSERT(node) triggered after surroundNodeRangeWithElement for node without editable style https://bugs.webkit.org/show_bug.cgi?id=232133 Reviewed by Wenson Hsieh. If the last styled node was not parent node of a current text node, but we wish to style the text node, we will add a style span to surround the text node. However, this requires the parent to have an editable style, or we will not properly insert the span in the right location, which later leads to a traversal into an invalid node. This change makes it so we return early if the parent node does not have an editable style, but modifying the existing CompositeEditCommand::insertNodeBefore to return a boolean in the early return case. Test: fast/editing/apply-relative-font-style-change-crash-003.html * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement): * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::insertNodeBefore): * editing/CompositeEditCommand.h: 2021-10-23 Rob Buis Null check in traverseNodesForSerialization https://bugs.webkit.org/show_bug.cgi?id=230704 Reviewed by Wenson Hsieh. Pass startNode by value instead of by pointer to traverseNodesForSerialization. Test: editing/pasteboard/copy-with-shadow-tree-crash.html * editing/markup.cpp: (WebCore::StyledMarkupAccumulator::serializeNodes): (WebCore::StyledMarkupAccumulator::traverseNodesForSerialization): 2021-10-22 Gabriel Nava Marino https://bugs.webkit.org/show_bug.cgi?id=232177 Check if start and end positions are still valid after updating them through mergeEndWithNextIfIdentical Reviewed by Alan Bujtas. We currently check if start and end positions are still valid after updating them through mergeEndWithNextIfIdentical, but not through mergeStartWithPreviousIfIdentical. Add this check to avoid trying to deref a nullptr in ApplyStyleCommand::mergeEndWithNextIfIdentical. Test: fast/editing/create-link-inline-style-change-crash-001.html * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::applyInlineStyle): 2021-10-09 Rob Buis Remove scrollbars explicitly when destroying render tree https://bugs.webkit.org/show_bug.cgi?id=229274 Reviewed by Simon Fraser. Scrollbars in FrameViews that are hosted by RenderWidget need the RenderView to exist because of RenderScrollbarPart. So when we are destroying the render tree the RenderView will be destroyed too, so before that happens remove the scrollbars and its RenderScrollbarParts. Test: editing/inserting/insert-html-crash-02.html * page/FrameView.cpp: (WebCore::FrameView::willBeDestroyed): * page/FrameView.h: * platform/Widget.h: (WebCore::Widget::willBeDestroyed): * rendering/RenderWidget.cpp: (WebCore::RenderWidget::willBeDestroyed): 2021-10-05 Chris Dumez ASSERT(m_callback->hasCallback()) under IntersectionObserver::notify() https://bugs.webkit.org/show_bug.cgi?id=231235 Reviewed by Ryosuke Niwa. IntersectionObserver's JS callback stays alive as long as its JS wrapper and its JS wrapper's lifetime relies on the IntersectionObserver::isReachableFromOpaqueRoots() implementation. isReachableFromOpaqueRoots() keeps the wrapper alive as long as the JS wrappers of observation / pending targets are alive. However, as per specification, we always need to dispatch an observation for an observation target, even if that target is not connected. Our code was already taking care of dispatching such observation. However, there was nothing keeping the observation target alive in this case and thus nothing keeping the JS callback alive either. To address the issue, I am introducing a new m_targetsWaitingForFirstObservation data member which holds a strong ref to the observation target until the next time we call notify(). This makes sure that the observation target (and its JS wrapper) stays alive long enough for us to dispatch the first observation for it. I also updated isReachableFromOpaqueRoots() to return true as long as m_targetsWaitingForFirstObservation is non-empty so that the IntersectionObserver's JS wrapper (and thus the JS callback) stay alive long enough too. Tests: intersection-observer/observe-disconnected-target-crash.html intersection-observer/observe-disconnected-target.html * page/IntersectionObserver.cpp: (WebCore::IntersectionObserver::observe): (WebCore::IntersectionObserver::unobserve): (WebCore::IntersectionObserver::removeAllTargets): (WebCore::IntersectionObserver::notify): (WebCore::IntersectionObserver::isReachableFromOpaqueRoots const): * page/IntersectionObserver.h: 2021-09-28 Alicia Boya García [MSE][GStreamer] Don't create MediaSourceTrackGStreamer objects twice for the same track https://bugs.webkit.org/show_bug.cgi?id=230829 Reviewed by Xabier Rodriguez-Calvar. The existing code in SourceBufferPrivateGStreamer::didReceiveInitializationSegment() was not checking if the track already existing, creating and immediately destroying a MediaSourceTrackGStreamer, which then crashed on an assertion (ASSERTION FAILED: m_isRemoved). This fixes the following two tests which were crashing with the former assertion when running in Debug: - media/media-source/media-mp4-h264-partial-abort.html - media/media-source/media-source-abort-resets-parser.html * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp: (WebCore::SourceBufferPrivateGStreamer::didReceiveInitializationSegment): 2021-09-09 Frédéric Wang Nullptr crash in CompositeEditCommand::splitTreeToNode via InsertParagraphSeparatorCommand::doApply https://bugs.webkit.org/show_bug.cgi?id=229276 Reviewed by Ryosuke Niwa. The loop in CompositeEditCommand::splitTreeToNode calls splitElement with the parent node as an argument. This patch fixes a nullptr crash by following the rule of [1]: store the parent node as a local smart pointer. Additionally, it ensures that editingIgnoresContent() returns false on the parent so that the corresponding ASSERT in Position's constructor does not fail when firstPositionInNode is called. [1] https://lists.webkit.org/pipermail/webkit-dev/2020-September/031386.html Tests: editing/execCommand/indent-input-in-image-crash.html editing/execCommand/indent-input-in-image-editing-ignores-content-assert.html * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::moveParagraphs): Store parent node in a smart pointer and exit loop if it returns true for editingIgnoresContent. 2021-09-09 Chris Dumez Potential crash under CachedRawResource::didAddClient() https://bugs.webkit.org/show_bug.cgi?id=230121 Reviewed by Alex Christensen. In r280083, I tried to address this crash by holding a strong reference to the SharedBuffer before calling forEachSegment() on it. However, the crash is still happening after this fix. My suspicion is that the SharedBuffer's internal m_segments vector gets modified as we iterate over it. As a result, I am reverting r280083 and iterating over a copy of m_segments in forEachSegment() instead. No new tests, we haven't been able to reproduce. * WebCore.xcodeproj/project.pbxproj: * loader/cache/CachedRawResource.cpp: (WebCore::CachedRawResource::didAddClient): * platform/SharedBuffer.cpp: (WebCore::SharedBuffer::forEachSegment const): 2021-09-07 Rob Buis Nullptr crash in DeleteSelectionCommand::removeNodeUpdatingStates https://bugs.webkit.org/show_bug.cgi?id=229279 Reviewed by Ryosuke Niwa. Fix DeleteSelectionCommand::removeNodeUpdatingStates logic to use m_endBlock rather than m_startBlock here. Test: editing/deleting/delete-shadow-tree-crash.html * editing/DeleteSelectionCommand.cpp: (WebCore::DeleteSelectionCommand::removeNodeUpdatingStates): 2021-09-07 Rob Buis Nullptr crash in CSSValue::cssText() via DeleteSelectionCommand::calculateTypingStyleAfterDelete https://bugs.webkit.org/show_bug.cgi?id=229281 Reviewed by Ryosuke Niwa. Null check the CSSValue in EditingStyle::init. Test: editing/deleting/forward-delete-crash.html * editing/EditingStyle.cpp: (WebCore::EditingStyle::init): 2022-01-12 Frédéric Wang Protect DocumentLoader when a reference to its members is used. https://bugs.webkit.org/show_bug.cgi?id=233464 Reviewed by Brady Eidson. No new tests, due to our infra (bug 127676). * loader/FrameLoader.cpp: (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Ensure that DocumentLoader loader remains alive while DocumentLoader::m_mainDocumentError is used. 2022-01-04 Frédéric Wang Protect frame from destruction in HTMLMediaElement::setupAndCallJS https://bugs.webkit.org/show_bug.cgi?id=234259 Reviewed by Darin Adler. Test: http/tests/media/media-element-frame-destroyed-crash.html * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::setupAndCallJS): Protect the frame before executing the JS code, so that it is not destroyed before its associated ScriptController. 2022-01-16 Brady Eidson database names leak cross-origin within the same browser session https://bugs.webkit.org/show_bug.cgi?id=233548 Reviewed by Geoff Garen. Test: http/tests/security/getdatabases-crossorigin.html * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions): When iterating the set of all open UniqueIDBDatabases, only add them to the results list if their origins match. * page/ClientOrigin.h: (WebCore::ClientOrigin::operator!= const): 2021-12-18 Adrian Perez de Castro Unreviewed non-unified build fixes. * loader/DocumentWriter.cpp: Add missing DocumentLoader.h header. * page/PerformanceNavigationTiming.cpp: Remove "#pragma once" from non-header file. 2021-09-07 Brent Fulgham [wpt-improvement] Improve CSP support for window reuse https://bugs.webkit.org/show_bug.cgi?id=229882 Reviewed by Chris Dumez. If window.open is used to host content with a CSP sandbox header, we should always create a new window, rather than reusing the existing one, unless the header includes 'allow-same-site'. This improves our WPT score. Tested by: imported/w3c/web-platform-tests/content-security-policy/sandbox/window-reuse-sandboxed.html * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::responseReceived): Parse the HTTP headers earlier so we can make decisions based on their state. * loader/DocumentWriter.cpp: (WebCore::DocumentWriter::begin): Don't reuse the current window if 'allow-same-site' is not allowed. 2021-09-02 Chris Dumez [COOP] html/cross-origin-opener-policy/coop-navigate-same-origin-csp-sandbox.html WPT test is failing https://bugs.webkit.org/show_bug.cgi?id=229716 Reviewed by Darin Adler. The COOP algorithm is relying on the response origin for some of the checks. We were computing the response origin via `SecurityOrigin::create(response.url())`, which worked fine in most cases. However, the response may contain a CSP header, which could set sandbox flags. If sandbox flags are set, the response origin should be unique, not the origin of the response URL. This patch fixes that. No new tests, rebaselined existing WPT test. * loader/DocumentLoader.cpp: (WebCore::computeResponseOriginAndCOOP): (WebCore::DocumentLoader::doCrossOriginOpenerHandlingOfResponse): * loader/DocumentLoader.h: (WebCore::DocumentLoader::contentSecurityPolicy const): * loader/FrameLoader.cpp: (WebCore::FrameLoader::didBeginDocument): * page/csp/ContentSecurityPolicy.cpp: (WebCore::ContentSecurityPolicy::copyStateFrom): (WebCore::ContentSecurityPolicy::didReceiveHeaders): * page/csp/ContentSecurityPolicy.h: (WebCore::ContentSecurityPolicy::sandboxFlags const): 2021-10-02 Yusuke Suzuki Remove JSC hack after r283410 https://bugs.webkit.org/show_bug.cgi?id=230261 Reviewed by Mark Lam. We revert a hack for accessors in JSC since this is not necessary. * bindings/scripts/CodeGeneratorJS.pm: (GetJSCAttributesForAttribute): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjDOMConstructor::construct): (WebCore::jsTestObj_searchGetter): (WebCore::JSC_DEFINE_CUSTOM_GETTER): (WebCore::setJSTestObj_searchSetter): (WebCore::JSC_DEFINE_CUSTOM_SETTER): * bindings/scripts/test/TestObj.idl: 2021-10-01 Yusuke Suzuki Disable new incumbent-window until it is fully implemented https://bugs.webkit.org/show_bug.cgi?id=230261 Reviewed by Chris Dumez and Geoffrey Garen. This patch disables new incumbent-window until it is fully implemented to avoid compatibility issue. * bindings/js/JSDOMConvertCallbacks.h: (WebCore::Converter>::convert): (WebCore::Converter>::convert): * bindings/js/JSDOMGlobalObject.cpp: (WebCore::callerGlobalObject): (WebCore::legacyActiveGlobalObjectForAccessor): * bindings/js/JSDOMGlobalObject.h: * bindings/js/JSDOMWindowBase.cpp: (WebCore::incumbentDOMWindow): (WebCore::legacyActiveDOMWindowForAccessor): * bindings/js/JSDOMWindowBase.h: * bindings/scripts/CodeGeneratorJS.pm: (GetJSCAttributesForAttribute): (GenerateCallWith): * page/Location.idl: 2021-12-08 Philippe Normand [GStreamer] Fill in client-name property on audio sinks https://bugs.webkit.org/show_bug.cgi?id=233826 Reviewed by Xabier Rodriguez-Calvar. The audio sink client-name property is now set on sinks that support this property, such as pulsesink and pipewiresink. This is picked-up by GNOME settings and the corresponding audio streams now appear as owned by the WebKit application (MiniBrowser, ephy, etc) instead of "WebKitWebProcess". When the audio mixer is enabled, no media.role property is set, because the mixer can accept music and/or video roles simultaneously, so it doesn't make sense in this context. * platform/audio/gstreamer/AudioDestinationGStreamer.cpp: (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer): Drive-by refactoring, using a lambda instead of a static callback function. (WebCore::autoAudioSinkChildAddedCallback): Deleted. * platform/graphics/gstreamer/GStreamerAudioMixer.cpp: (WebCore::GStreamerAudioMixer::GStreamerAudioMixer): * platform/graphics/gstreamer/GStreamerCommon.cpp: (WebCore::createAutoAudioSink): (WebCore::createPlatformAudioSink): * platform/graphics/gstreamer/GStreamerCommon.h: * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer): (WebCore::MediaPlayerPrivateGStreamer::createAudioSink): (WebCore::MediaPlayerPrivateGStreamer::setAudioStreamPropertiesCallback): Deleted. (WebCore::MediaPlayerPrivateGStreamer::setAudioStreamProperties): Deleted. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: 2021-09-08 Fujii Hironori KeyboardEvent should setDefaultHandled if EventHandler::startKeyboardScrolling returns true https://bugs.webkit.org/show_bug.cgi?id=229784 Reviewed by Darin Adler. If a KeyboardEvent is handled by the default event handler, it should be marked by Event::setDefaultHandled. Test: fast/scrolling/keyboard-scrolling-last-timestamp.html * page/EventHandler.cpp: (WebCore::EventHandler::defaultKeyboardEventHandler): (WebCore::EventHandler::defaultArrowEventHandler): 2021-09-01 Fujii Hironori REGRESSION(r280928) The smooth keyboard scrolling is unconditionally enabled for PageUp and PageDown keys https://bugs.webkit.org/show_bug.cgi?id=229733 Reviewed by Tim Horton. Even though WinCairo port doesn't enable EventHandlerDrivenSmoothKeyboardScrollingEnabled yet, it had been enabled only for PageUp and PageDown keys since r280928. Other keys (Space and Arrow keys) don't trigger the smooth scrolling. r280928 changed to call startKeyboardScrolling for PageUp and PageDown keys, but it didn't check the setting. * page/EventHandler.cpp: (WebCore::EventHandler::startKeyboardScrolling): (WebCore::EventHandler::defaultKeyboardEventHandler): 2021-10-26 Adrian Perez de Castro Multiple build issues with ENABLE_VIDEO=OFF https://bugs.webkit.org/show_bug.cgi?id=232264 Reviewed by Carlos Garcia Campos. No new tests needed. * accessibility/AXObjectCache.cpp: (WebCore::isSimpleImage): Guard usage of HTMLMediaElement with ENABLE(VIDEO). * platform/graphics/BifurcatedGraphicsContext.cpp: Ditto. 2021-10-15 Michael Catanzaro [WPE][GTK] Update user agent browser versions https://bugs.webkit.org/show_bug.cgi?id=231772 Reviewed by Carlos Garcia Campos. * platform/UserAgentQuirks.cpp: (WebCore::UserAgentQuirks::stringForQuirk): * platform/glib/UserAgentGLib.cpp: (WebCore::buildUserAgentString): 2021-10-13 Philippe Normand [GStreamer] Crash in WebCore::MediaPlayerPrivateGStreamer::sourceSetup when loading reddit video https://bugs.webkit.org/show_bug.cgi?id=231519 Reviewed by Xabier Rodriguez-Calvar. Since this GStreamer commit: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/commit/52bca104e447309898ca8904b3914211ec7d4114 and starting from GStreamer 1.20, the playbin::source-setup signal is emitted before the source element is added to the pipeline, so this gave us the opportunity to refactor our code handling the downloadbuffer configuration, using the existing deep-element-added signal handler. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer): (WebCore::MediaPlayerPrivateGStreamer::sourceSetup): (WebCore::MediaPlayerPrivateGStreamer::configureDownloadBuffer): (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): (WebCore::MediaPlayerPrivateGStreamer::uriDecodeBinElementAddedCallback): Deleted. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: 2021-09-15 Carlos Garcia Campos Fix size calculation in ImageBufferCairoImageSurfaceBackend::create() https://bugs.webkit.org/show_bug.cgi?id=229365 Reviewed by Don Olmstead. * platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp: (WebCore::ImageBufferCairoImageSurfaceBackend::calculateSafeBackendSize): Check the result of cairo_format_stride_for_width() and the multiplication doesn't overflow. (WebCore::ImageBufferCairoImageSurfaceBackend::create): Use tryFastCalloc() instead of tryFastZeroedMalloc(). 2021-09-07 Adrian Perez de Castro Fix non-unified builds Unreviewed non-unified build fixes. * workers/Worker.h: Add missing wtf/Deque.h header. 2021-09-01 Myles C. Maxfield CSSFontFaceSet.clear() should not clear CSS-connected members https://bugs.webkit.org/show_bug.cgi?id=229643 Reviewed by Darin Adler. The spec https://drafts.csswg.org/css-font-loading-3/#dom-fontfaceset-clear says: > Remove all non-CSS-connected items * css/CSSFontFaceSet.h: * css/FontFaceSet.cpp: (WebCore::FontFaceSet::clear): 2021-08-13 Sergio Villar Senin [css-flexbox] Add initial support for css-align-3 positional alignment properties https://bugs.webkit.org/show_bug.cgi?id=229074 Reviewed by Simon Fraser. Added initial support for Start and End positional alignment properties from https://drafts.csswg.org/css-align-3/#positional-values. These two properties align the flex item to be flush with the alignment container's (the flex container) start and end edges in the appropriate axis. * rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::isColumnOrRowReverse const): New method. (WebCore::initialJustifyContentOffset): Handle Start and End. (WebCore::alignmentOffset): Ditto. (WebCore::RenderFlexibleBox::staticMainAxisPositionForPositionedChild): (WebCore::RenderFlexibleBox::alignmentForChild const): (WebCore::RenderFlexibleBox::layoutAndPlaceChildren): (WebCore::RenderFlexibleBox::layoutColumnReverse): (WebCore::initialAlignContentOffset): Handle Start and End. (WebCore::RenderFlexibleBox::alignFlexLines): * rendering/RenderFlexibleBox.h: 2021-09-01 Said Abou-Hallawa [GPU Process](REGRESSION): A detached canvas leaks all the images it draws https://bugs.webkit.org/show_bug.cgi?id=229668 Reviewed by Simon Fraser. Before drawing the canvas to the page, the canvas element may need to prepare its context for display. For 2D canvas elements, this should happen regardless whether they are attached to the Document or not. Because prepareForDisplay() calls ImageBuffer::flushDrawingContextAsync(), this will ensure the canvas drawing commands are pushed from WebProcess to GPUProcess. It will also release the cached shared images from both WebProcess and GPUProcess. Move the decision to skip the context prepareForDisplay() step from Document::prepareCanvasesForDisplayIfNeeded() to WebGLRenderingContextBase::prepareForDisplay(). * dom/Document.cpp: (WebCore::Document::prepareCanvasesForDisplayIfNeeded): * html/canvas/WebGLRenderingContextBase.cpp: (WebCore::WebGLRenderingContextBase::prepareForDisplay): 2021-08-31 Lauro Moura Non-unified build partial fixes, late late August 2021 https://bugs.webkit.org/show_bug.cgi?id=229741 Unreviewed non-unified build fixes. Still missing a strange WebCoreTestSupport.a-related link error. * Modules/mediastream/RTCIceTransportBackend.h: Add missing header. * Modules/mediastream/RTCPeerConnection.cpp: Ditto. * Modules/mediastream/libwebrtc/LibWebRTCIceTransportBackend.cpp: Ditto. * html/FormController.cpp: (WebCore::formSignature): Namespace HTMLNames. * html/FormController.h: Add missing header. * html/track/LoadableTextTrack.cpp: Add missing header. * loader/PrivateClickMeasurement.cpp: Ditto. * page/PageConfiguration.cpp: Ditto. 2021-08-31 Chris Dumez Enable SharedArrayBuffer support when COOP/COEP headers are used https://bugs.webkit.org/show_bug.cgi?id=229559 Reviewed by Alex Christensen. Make sure window.crossOriginIsolated returns true when COOP=same-origin and COEP=require-corp are used. Also make sure that cross-origin-isolates pages are allowed to use SharedArrayBuffer. Change is covered by rebaselined layout tests and new API tests. * loader/DocumentLoader.cpp: (WebCore::toNeedsBrowsingContextGroupSwitch): (WebCore::DocumentLoader::responseReceived): * loader/EmptyClients.cpp: (WebCore::EmptyFrameLoaderClient::dispatchDecidePolicyForResponse): * loader/EmptyFrameLoaderClient.h: * loader/FrameLoader.cpp: (WebCore::FrameLoader::checkContentPolicy): * loader/FrameLoader.h: * loader/FrameLoaderClient.h: * loader/FrameLoaderTypes.h: * page/DOMWindow.cpp: (WebCore::DOMWindow::crossOriginIsolated const): * page/DOMWindow.idl: 2021-08-31 Kate Cheney Use after move in ServiceWorkerThreadProxy https://bugs.webkit.org/show_bug.cgi?id=229731 Reviewed by Chris Dumez. * workers/service/context/ServiceWorkerThreadProxy.cpp: (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy): 2021-08-31 Marcos Caceres [Payment Request] Calling PaymentRequest's show() should consume user activation https://bugs.webkit.org/show_bug.cgi?id=217365 Reviewed by Youenn Fablet and Devin Rousso. Tested by existing WPT tests. * Modules/paymentrequest/PaymentRequest.cpp: (WebCore::PaymentRequest::show): 2021-08-31 Thibault Saunier [GStreamer] Fix deadlock tearing down pipeline when using fallback sink https://bugs.webkit.org/show_bug.cgi?id=229619 Reviewed by Xabier Rodriguez-Calvar. Whenever GstGL is disabled for whatever reason the fallback sink might be used and cancelling repaint need to be taken into account in any case. * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::cancelRepaint): 2021-08-31 Sihui Liu REGRESSION (r281771): ASSERTION FAILED: !m_deletionHasBegun under WebCore::Permissions::~Permissions() https://bugs.webkit.org/show_bug.cgi?id=229714 Reviewed by Chris Dumez. PageConfiguration should hold Ref instead of UniqueRef. * Modules/permissions/PermissionController.h: * loader/EmptyClients.cpp: (WebCore::pageConfigurationWithEmptyClients): * page/Page.h: * page/PageConfiguration.cpp: (WebCore::PageConfiguration::PageConfiguration): * page/PageConfiguration.h: 2021-08-31 Kate Cheney Loads after session restore marked app initiated in Safari https://bugs.webkit.org/show_bug.cgi?id=229721 Reviewed by Brent Fulgham. * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadDifferentDocumentItem): Set the proper app initiated value when creating a new request. 2021-08-31 Antti Koivisto REGRESSION (r272900): wpt.fyi loading performance is very slow (regressed, and slower than other browsers) https://bugs.webkit.org/show_bug.cgi?id=229680 Reviewed by Darin Adler. The page is inserting new children to shadow host and on each insertion we are traversing the composed tree to tear down renderers, even though there are none. * rendering/updating/RenderTreeUpdater.cpp: (WebCore::RenderTreeUpdater::tearDownRenderersAfterSlotChange): If the host doesn't have a renderer or 'display:contents' there can't be any renderers left in the subtree. 2021-08-31 Ross Kirsling Unreviewed build fix for PlayStation following r241123. * css/typedom/CSSStyleValue.h: Add missing include. 2021-08-31 Johnson Zhou Addition of CSSUnparsedValue. (TypedOM) https://bugs.webkit.org/show_bug.cgi?id=229069 Reviewed by Darin Adler. * css/typedom/CSSOMVariableReferenceValue.cpp: 2021-08-31 Chris Dumez Implement self.structuredClone() https://bugs.webkit.org/show_bug.cgi?id=228331 Reviewed by Ryosuke Niwa. Implement self.structuredClone() as per: - https://html.spec.whatwg.org/#dom-structuredclone Tests: imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone.any.html imported/w3c/web-platform-tests/html/webappapis/structured-clone/structured-clone.any.worker.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/MessagePort.cpp: (WebCore::MessagePort::postMessage): * dom/MessagePort.h: * dom/MessagePort.idl: * page/Base64Utilities.h: * page/DOMWindow.h: (WebCore::WindowPostMessageOptions::WindowPostMessageOptions): * page/DOMWindow.idl: * page/StructuredSerializeOptions.h: Renamed from Source/WebCore/page/PostMessageOptions.h. (WebCore::StructuredSerializeOptions::StructuredSerializeOptions): * page/StructuredSerializeOptions.idl: Renamed from Source/WebCore/page/PostMessageOptions.idl. * page/WindowOrWorkerGlobalScope.cpp: Copied from Source/WebCore/workers/service/ServiceWorkerClient.h. (WebCore::WindowOrWorkerGlobalScope::reportError): (WebCore::WindowOrWorkerGlobalScope::structuredClone): * page/WindowOrWorkerGlobalScope.h: Copied from Source/WebCore/page/Base64Utilities.h. (WebCore::WindowOrWorkerGlobalScope::structuredClone): * page/WindowOrWorkerGlobalScope.idl: * workers/DedicatedWorkerGlobalScope.cpp: (WebCore::DedicatedWorkerGlobalScope::postMessage): * workers/DedicatedWorkerGlobalScope.h: * workers/DedicatedWorkerGlobalScope.idl: * workers/Worker.cpp: (WebCore::Worker::postMessage): * workers/Worker.h: * workers/Worker.idl: * workers/WorkerGlobalScope.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::postMessage): * workers/service/ServiceWorker.h: * workers/service/ServiceWorker.idl: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerClient.h: * workers/service/ServiceWorkerClient.idl: 2021-08-31 Alan Bujtas [LFC][Integration] Remove unused LayoutIntegation::Run functions https://bugs.webkit.org/show_bug.cgi?id=229711 Reviewed by Antti Koivisto. * layout/integration/LayoutIntegrationRun.h: (WebCore::LayoutIntegration::Run::image const): Deleted. (WebCore::LayoutIntegration::Run::hasUnderlyingLayout const): Deleted. * layout/integration/LayoutIntegrationRunIteratorModernPath.h: (WebCore::LayoutIntegration::RunIteratorModernPath::atEnd const): 2021-08-31 Alan Bujtas [IFC][Integration] Move integral vertical position adjustment over to createDisplayLines https://bugs.webkit.org/show_bug.cgi?id=229679 Reviewed by Antti Koivisto. This is in preparation for not constructing text runs in InlineContentBuilder::createDisplayLineRuns. * layout/integration/LayoutIntegrationInlineContentBuilder.cpp: (WebCore::LayoutIntegration::InlineContentBuilder::build const): (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const): (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const): * layout/integration/LayoutIntegrationInlineContentBuilder.h: * layout/integration/LayoutIntegrationLine.h: (WebCore::LayoutIntegration::NonRootInlineBox::setVerticalPositionIntegral): * layout/integration/LayoutIntegrationRun.h: (WebCore::LayoutIntegration::Run::setVerticalPositionIntegral): 2021-08-31 Chris Dumez [COOP] html/cross-origin-opener-policy/coop-same-origin-allow-popups-document-write.html WPT test is failing https://bugs.webkit.org/show_bug.cgi?id=229692 Reviewed by Darin Adler. The test does the following: 1. An opener document with `COOP=same-origin-allow-popups` opens a new window that shows the initial empty document. Note that the openee inherits `COOP=same-origin-allow-popups` from its opener. 2. The opener document then calls document.write() on the openee. Note that, as per the HTML specification, this clears the 'is displaying initial empty document' flag. 3. The openee is navigated cross-origin to a destination without COOP. Normally, `COOP=same-origin-allow-popups` would allow the popup to be navigated cross-origin as per the logic here [1]: """ If all of the following are true: - isInitialAboutBlank, - activeDocumentCOOPValue's value is "same-origin-allow-popups". - responseCOOPValue is "unsafe-none", then return false (meaning, no context group switch). """ However, because of the document.write() call at step 2, the isInitialAboutBlank flag is no longer true and the check should fail, thus causing a browsing context group switch. [1] https://html.spec.whatwg.org/multipage/origin.html#check-browsing-context-group-switch-coop-value No new tests, rebaselined existing test. * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::maybeLoadEmpty): Replace the bad check to committedFirstRealDocumentLoad (which stays true after calling document.write() on the initial empty document) with a check to !isDisplayingInitialEmptyDocument, which matches the specification text. isDisplayingInitialEmptyDocument correctly becomes false after calling document.write() on the initial empty document. * loader/DocumentLoader.h: (WebCore::DocumentLoader::crossOriginOpenerPolicy const): * loader/FrameLoader.cpp: (WebCore::FrameLoader::didBeginDocument): Fix didBeginDocument() so that it doesn't overwrite the document's cross-origin-opener-policy when the DocumentLoader does not know what the policy is. When opening a popup, Document::initSecurityContext() will set the popup's cross-origin-opener-policy to the one of its opener. When didBeginDocument() gets called later for the initial empty document, we don't want to overwrite the inherited policy with a new default cross-origin-opener-policy of unsafe-none. The reason the DocumentLoader does not have a policy for us is because this is the initial empty document and DocumentLoader's doCrossOriginOpenerHandlingOfResponse() was thus never called with an actual network response. 2021-08-31 Carlos Garcia Campos [SOUP] Assertion in startObservingCookieChanges() https://bugs.webkit.org/show_bug.cgi?id=229708 Reviewed by Philippe Normand. Add an implementation for startObservingCookieChanges() and stopObservingCookieChanges() setting the cookies observer callback on the given storage session. * platform/network/CookieStorage.h: * platform/network/cf/CookieStorageCFNet.cpp: (WebCore::startObservingCookieChanges): (WebCore::stopObservingCookieChanges): * platform/network/curl/CookieStorageCurl.cpp: (WebCore::startObservingCookieChanges): (WebCore::stopObservingCookieChanges): * platform/network/mac/CookieStorageMac.mm: (WebCore::startObservingCookieChanges): (WebCore::stopObservingCookieChanges): * platform/network/soup/CookieStorageSoup.cpp: (WebCore::startObservingCookieChanges): (WebCore::stopObservingCookieChanges): 2021-08-31 Alan Bujtas [LFC][Integration] Make naming more consistent across Layout::Run and Integration::Run structs https://bugs.webkit.org/show_bug.cgi?id=229693 Reviewed by Antti Koivisto. This is in preparation for merging these 2 structs. * display/DisplayTreeBuilder.cpp: (WebCore::Display::TreeBuilder::buildInlineDisplayTree): * display/css/DisplayBoxFactory.cpp: (WebCore::Display::BoxFactory::displayBoxForTextRun const): * display/css/DisplayBoxFactory.h: * display/css/DisplayTextBox.cpp: (WebCore::Display::TextBox::TextBox): * display/css/DisplayTextBox.h: (WebCore::Display::TextBox::expansion const): (WebCore::Display::TextBox::text const): * layout/Verification.cpp: (WebCore::Layout::checkForMatchingNonTextRuns): (WebCore::Layout::checkForMatchingTextRuns): (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded): * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp: (WebCore::Layout::InlineDisplayContentBuilder::build): (WebCore::Layout::InlineDisplayContentBuilder::createRunsAndUpdateGeometryForLineContent): (WebCore::Layout::InlineDisplayContentBuilder::createRunsAndUpdateGeometryForLineSpanningInlineBoxes): * layout/formattingContexts/inline/InlineFormattingContext.cpp: (WebCore::Layout::InlineFormattingContext::lineLayout): (WebCore::Layout::InlineFormattingContext::computeStaticPositionForOutOfFlowContent): * layout/formattingContexts/inline/InlineFormattingState.h: (WebCore::Layout::InlineFormattingState::runs const): (WebCore::Layout::InlineFormattingState::runs): (WebCore::Layout::InlineFormattingState::addRun): (WebCore::Layout::InlineFormattingState::clearLineAndRuns): (WebCore::Layout::InlineFormattingState::shrinkToFit): (WebCore::Layout::InlineFormattingState::lineRuns const): Deleted. (WebCore::Layout::InlineFormattingState::lineRuns): Deleted. (WebCore::Layout::InlineFormattingState::addLineRun): Deleted. * layout/formattingContexts/inline/InlineLine.h: (WebCore::Layout::Line::Run::expansion const): (WebCore::Layout::Line::Run::setExpansion): * layout/formattingContexts/inline/InlineLineRun.h: (WebCore::Layout::Run::style const): (WebCore::Layout::Run::Run): (WebCore::Layout::Run::Text::Text): (WebCore::Layout::LineRun::Text::start const): Deleted. (WebCore::Layout::LineRun::Text::end const): Deleted. (WebCore::Layout::LineRun::Text::length const): Deleted. (WebCore::Layout::LineRun::Text::originalContent const): Deleted. (WebCore::Layout::LineRun::Text::renderedContent const): Deleted. (WebCore::Layout::LineRun::Text::hasHyphen const): Deleted. (WebCore::Layout::LineRun::isText const): Deleted. (WebCore::Layout::LineRun::isSoftLineBreak const): Deleted. (WebCore::Layout::LineRun::isLineBreakBox const): Deleted. (WebCore::Layout::LineRun::isLineBreak const): Deleted. (WebCore::Layout::LineRun::isAtomicInlineLevelBox const): Deleted. (WebCore::Layout::LineRun::isInlineBox const): Deleted. (WebCore::Layout::LineRun::isNonRootInlineBox const): Deleted. (WebCore::Layout::LineRun::isRootInlineBox const): Deleted. (WebCore::Layout::LineRun::isGenericInlineLevelBox const): Deleted. (WebCore::Layout::LineRun::isInlineLevelBox const): Deleted. (WebCore::Layout::LineRun::isNonRootInlineLevelBox const): Deleted. (WebCore::Layout::LineRun::type const): Deleted. (WebCore::Layout::LineRun::hasContent const): Deleted. (WebCore::Layout::LineRun::isLineSpanning const): Deleted. (WebCore::Layout::LineRun::logicalRect const): Deleted. (WebCore::Layout::LineRun::inkOverflow const): Deleted. (WebCore::Layout::LineRun::logicalTop const): Deleted. (WebCore::Layout::LineRun::logicalBottom const): Deleted. (WebCore::Layout::LineRun::logicalLeft const): Deleted. (WebCore::Layout::LineRun::logicalRight const): Deleted. (WebCore::Layout::LineRun::logicalWidth const): Deleted. (WebCore::Layout::LineRun::logicalHeight const): Deleted. (WebCore::Layout::LineRun::moveVertically): Deleted. (WebCore::Layout::LineRun::text): Deleted. (WebCore::Layout::LineRun::text const): Deleted. (WebCore::Layout::LineRun::expansion const): Deleted. (WebCore::Layout::LineRun::layoutBox const): Deleted. (WebCore::Layout::LineRun::lineIndex const): Deleted. (WebCore::Layout::LineRun::LineRun): Deleted. (WebCore::Layout::LineRun::Text::Text): Deleted. * layout/formattingContexts/table/TableFormattingContext.cpp: (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells): * layout/integration/LayoutIntegrationInlineContent.cpp: (WebCore::LayoutIntegration::InlineContent::iteratorForTextRun const): * layout/integration/LayoutIntegrationInlineContentBuilder.cpp: (WebCore::LayoutIntegration::InlineContentBuilder::build const): (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayRuns const): (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const): (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const): Deleted. * layout/integration/LayoutIntegrationInlineContentBuilder.h: * layout/integration/LayoutIntegrationLineLayout.cpp: (WebCore::LayoutIntegration::LineLayout::paint): (WebCore::LayoutIntegration::LineLayout::hitTest): (WebCore::LayoutIntegration::LineLayout::paintTextRunUsingPhysicalCoordinates): * layout/integration/LayoutIntegrationPagination.cpp: (WebCore::LayoutIntegration::makeAdjustedContent): * layout/integration/LayoutIntegrationRun.h: (WebCore::LayoutIntegration::Run::logicalRect const): (WebCore::LayoutIntegration::Run::text): (WebCore::LayoutIntegration::Run::text const): (WebCore::LayoutIntegration::Run::isLineBreak const): (WebCore::LayoutIntegration::Run::Run): (WebCore::LayoutIntegration::Run::Text::Text): (WebCore::LayoutIntegration::Run::TextContent::start const): Deleted. (WebCore::LayoutIntegration::Run::TextContent::end const): Deleted. (WebCore::LayoutIntegration::Run::TextContent::length const): Deleted. (WebCore::LayoutIntegration::Run::TextContent::originalContent const): Deleted. (WebCore::LayoutIntegration::Run::TextContent::renderedContent const): Deleted. (WebCore::LayoutIntegration::Run::TextContent::hasHyphen const): Deleted. (WebCore::LayoutIntegration::Run::rect const): Deleted. (WebCore::LayoutIntegration::Run::textContent): Deleted. (WebCore::LayoutIntegration::Run::textContent const): Deleted. (WebCore::LayoutIntegration::Run::TextContent::TextContent): Deleted. * layout/integration/LayoutIntegrationRunIteratorModernPath.h: (WebCore::LayoutIntegration::RunIteratorModernPath::isText const): (WebCore::LayoutIntegration::RunIteratorModernPath::rect const): (WebCore::LayoutIntegration::RunIteratorModernPath::hasHyphen const): (WebCore::LayoutIntegration::RunIteratorModernPath::text const): (WebCore::LayoutIntegration::RunIteratorModernPath::start const): (WebCore::LayoutIntegration::RunIteratorModernPath::end const): (WebCore::LayoutIntegration::RunIteratorModernPath::length const): (WebCore::LayoutIntegration::RunIteratorModernPath::traverseNextTextRun): * layout/layouttree/LayoutTreeBuilder.cpp: (WebCore::Layout::showInlineTreeAndRuns): 2021-08-31 Antti Koivisto [CSS Cascade Layers] Compute order correctly for late added sublayers https://bugs.webkit.org/show_bug.cgi?id=229666 Reviewed by Simon Fraser. In cases like @layer a.b { ... } @layer c { ... } @layer a.d { ... } 'c' should have higher priority than 'a.d'. Replace the per-RuleData layer order vector with references (indexes) to layer entry vector. These entries have order field that can be recomputed. * style/RuleSet.cpp: (WebCore::Style::RuleSet::addRule): (WebCore::Style::RuleSet::Builder::addStyleRule): (WebCore::Style::RuleSet::Builder::pushCascadeLayer): Instead of computing order directly we just give each layer an identifier and add an entry for it to the layer vector. (WebCore::Style::RuleSet::Builder::popCascadeLayer): (WebCore::Style::RuleSet::Builder::~Builder): Compute layer order after building for all layers. (WebCore::Style::RuleSet::shrinkToFit): * style/RuleSet.h: (WebCore::Style::RuleSet::cascadeLayerForIdentifier): (WebCore::Style::RuleSet::cascadeLayerForIdentifier const): (WebCore::Style::RuleSet::cascadeLayerOrderFor const): 2021-08-31 Philippe Normand Unreviewed, OpenXR build warning fix. * platform/xr/openxr/OpenXRInputMappings.h: 2021-08-31 Youenn Fablet Add support for RTCIceTransport https://bugs.webkit.org/show_bug.cgi?id=229285 Reviewed by Eric Carlson. Introduce RTCIceTransport as per spec. Reuse the same model as RTCDtlsTransport with a backend and RTCPeerConnection be responsible to reuse or create transports as needed. Covered by updated tests. * Modules/mediastream/RTCDtlsTransport.cpp: (WebCore::RTCDtlsTransport::RTCDtlsTransport): * Modules/mediastream/RTCDtlsTransport.h: * Modules/mediastream/RTCDtlsTransport.idl: * Modules/mediastream/RTCDtlsTransportBackend.h: * Modules/mediastream/RTCIceTransport.cpp: (WebCore::RTCIceTransport::RTCIceTransport): (WebCore::RTCIceTransport::~RTCIceTransport): (WebCore::RTCIceTransport::stop): (WebCore::RTCIceTransport::virtualHasPendingActivity const): (WebCore::RTCIceTransport::onStateChanged): (WebCore::RTCIceTransport::onGatheringStateChanged): * Modules/mediastream/RTCIceTransport.h: (WebCore::RTCIceTransport::create): (WebCore::RTCIceTransport::state const): (WebCore::RTCIceTransport::backend const): * Modules/mediastream/RTCIceTransport.idl: * Modules/mediastream/RTCIceTransportBackend.h: Added. (WebCore::operator==): * Modules/mediastream/RTCPeerConnection.cpp: (WebCore::RTCPeerConnection::computeConnectionState): (WebCore::RTCPeerConnection::updateConnectionState): (WebCore::isIceTransportUsedByTransceiver): (WebCore::RTCPeerConnection::computeIceConnectionStateFromIceTransports): (WebCore::RTCPeerConnection::processIceTransportStateChange): (WebCore::RTCPeerConnection::getOrCreateIceTransport): (WebCore::RTCPeerConnection::getOrCreateDtlsTransport): * Modules/mediastream/RTCPeerConnection.h: * Modules/mediastream/libwebrtc/LibWebRTCDtlsTransportBackend.cpp: (WebCore::LibWebRTCDtlsTransportBackend::iceTransportBackend): * Modules/mediastream/libwebrtc/LibWebRTCDtlsTransportBackend.h: * Modules/mediastream/libwebrtc/LibWebRTCIceTransportBackend.cpp: Added. (WebCore::toRTCIceTransportState): (WebCore::toRTCIceGatheringState): (WebCore::LibWebRTCIceTransportBackendObserver::LibWebRTCIceTransportBackendObserver): (WebCore::LibWebRTCIceTransportBackendObserver::start): (WebCore::LibWebRTCIceTransportBackendObserver::stop): (WebCore::LibWebRTCIceTransportBackendObserver::onIceTransportStateChanged): (WebCore::LibWebRTCIceTransportBackendObserver::onGatheringStateChanged): (WebCore::LibWebRTCIceTransportBackend::LibWebRTCIceTransportBackend): (WebCore::LibWebRTCIceTransportBackend::~LibWebRTCIceTransportBackend): (WebCore::LibWebRTCIceTransportBackend::registerClient): (WebCore::LibWebRTCIceTransportBackend::unregisterClient): * Modules/mediastream/libwebrtc/LibWebRTCIceTransportBackend.h: Added. * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: (WebCore::LibWebRTCMediaEndpoint::OnIceConnectionChange): * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/EventNames.h: * dom/EventTargetFactory.in: 2021-08-31 Rob Buis Nullptr crash in TypingCommand::willAddTypingToOpenCommand via TypingCommand::deleteKeyPressed https://bugs.webkit.org/show_bug.cgi?id=229277 Reviewed by Ryosuke Niwa. Rewtite CompositeEditCommand::shouldBreakOutOfEmptyListItem() to return just VisibleSelection and check that it is not none in TypingCommand::willAddTypingToOpenCommand. Test: editing/deleting/delete-key-crash.html * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::moveParagraphs): * editing/CompositeEditCommand.h: * editing/TypingCommand.cpp: (WebCore::TypingCommand::deleteKeyPressed): 2021-08-31 Ryosuke Niwa Re-generalize top layer element concept https://bugs.webkit.org/show_bug.cgi?id=229488 Reviewed by Antti Koivisto. r281548 made the concept of top layer is confined to dialog element to eliminate the runtime cost of making 5+ function calls and looking up the list hash set per removal of every element. This patch re-generalize this concept for all elements by introducing a new node flag to avoid the runtime cost so that we may use it in the future for the full screen element. No new tests since there should be no observable behavior changes. This patch also inverts the relationship between member functions in Element and Document to reduce the number of function calls involved by 1. * dom/Document.cpp: (Document::removedLastRef): Make sure the list of top layer elements is empty. (WebCore::Document::addTopLayerElement): Renamed from addToTopLayer. The code to update the layer has been moved to Element::addToTopLayer. Also release-time assert that the element is connected to this document. (WebCore::Document::removeTopLayerElement): Ditto. * dom/Document.h: * dom/Element.cpp: (WebCore::Element::removedFromAncestor): Call removeTopLayerElement if this element had a top layer. (WebCore::renderLayerForElement): Added. (WebCore::Element::addToTopLayer): Moved from Document. Set the node flag: IsInTopLayer. (WebCore::Element::removeFromTopLayer): Ditto, clear the node flag. (WebCore::Element::isInTopLayerWillChange): Deleted. (WebCore::Element::isInTopLayerDidChange): Deleted. * dom/Element.h: (WebCore::Element::isInTopLayer const): Rewritten to make use of new node flag. * dom/Node.h: (WebCore::NodeFlag): Added a new node flag: IsInTopLayer. * html/HTMLDialogElement.cpp: (WebCore::HTMLDialogElement::showModal): (WebCore::HTMLDialogElement::close): (WebCore::HTMLDialogElement::removedFromAncestor): Deleted. * html/HTMLDialogElement.h: 2021-08-26 Darin Adler Cut down on use of CFGetTypeID, using dynamic_cf_cast instead; related streamlining https://bugs.webkit.org/show_bug.cgi?id=229414 Reviewed by Tim Horton. * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp: (WebCore::makeSimpleColorFromARGBCFArray): Use dynamic_cf_cast. (WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Ditto. Also removed unnecessary type casts when comparing with kCFBooleanTrue. * platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm: Use dynamic_cf_cast. * platform/graphics/cocoa/FontCacheCoreText.cpp: (WebCore::FontCache::systemFontFamilies): Ditto. (WebCore::isUserInstalledFont): Use kCFBooleanTrue. * platform/graphics/cocoa/HEVCUtilitiesCocoa.mm: (WebCore::validateHEVCParameters): Use dynamic_cf_cast and kCFBooleanTrue. (WebCore::validateDoViParameters): Ditto. * platform/graphics/cocoa/WebCoreDecompressionSession.mm: (WebCore::WebCoreDecompressionSession::shouldDecodeSample): Use kCFBooleanFalse. * platform/graphics/coretext/FontPlatformDataCoreText.cpp: (WebCore::FontPlatformData::objectForEqualityCheck): Use auto. * platform/graphics/cv/GraphicsContextGLCVANGLE.cpp: (WebCore::transferFunctionFromString): Removed type check, which caller should do since the agument type is CFStringRef. (WebCore::GraphicsContextGLCVANGLE::copyPixelBufferToTexture): Use dynamic_cf_cast instead of an unchecked static_cast. * platform/ios/UserAgentIOS.mm: (WebCore::deviceNameForUserAgent): Improved efficiency by returning a StringView instead of a String, no need to create and destroy a string or churn the reference count each time this function is called. (WebCore::standardUserAgentWithApplicationName): Improved efficiency by using a better idiom for the space before the application name. Use dynamic_cf_cast. * platform/mediastream/mac/WindowDisplayCapturerMac.mm: (WebCore::anyOfCGWindow): Use kCFBooleanFalse. * platform/network/cf/ProxyServerCFNet.cpp: (WebCore::processProxyServers): Use dynamic_cf_cast. * platform/network/cf/ResourceRequestCFNet.cpp: Move WTF_DECLARE_CF_TYPE_TRAIT for CFURLRef out of here. * platform/network/cf/SocketStreamHandleImplCFNet.cpp: (WebCore::SocketStreamHandleImpl::chooseProxyFromArray): Ditto. * platform/network/ios/WebCoreURLResponseIOS.h: Tweaked a bit. * platform/network/ios/WebCoreURLResponseIOS.mm: (WebCore::createExtensionToMIMETypeMap): Deleted. (WebCore::adjustMIMETypeIfNecessary): Simplified the code that maps ".mjs" to "text/javascript" to make it much more efficient and not use a dictionary. Refactored to share code with the Mac, via the WebCoreURLResponse.h/mm files, which are not macOS-specific even though they are in a directory named "mac". Fixed one place where we did adoptCF where it should be adoptNS. Use CFSTR("application/octet-stream") directly instead of using WebCore::defaultMIMEType(). * platform/network/mac/NetworkStateNotifierMac.cpp: (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): Use dynamic_cf_cast. * platform/network/mac/UTIUtilities.h: Renamed MIMETypeFromUTITree to mimeTypeFromUTITree to make the style robot happy. Changed the argument and return type to CFStringRef since that's what the callers all want, and what the implementation uses, and there is no reason to convert back and forth to WTF::String. * platform/network/mac/UTIUtilities.mm: (WebCore::mimeTypeFromUTITree): Use nullptr, not emptyString(), for the value when there is no MIME type found. Use auto. Use dynamic_cf_cast. Make recursion more efficient since we don't keep converting back and forth between CFStringRef and WTF::String. (WebCore::UTIFromTag): Removed unneeded explicit converstion to WTF::String. * platform/network/mac/WebCoreURLResponse.h: Added helper functions to the header, shared by WebCoreURLResponse.mm and WebCoreURLResponseIOS.mm. Use CFSTR("application/octet-stream") directly instead of using WebCore::defaultMIMEType().6 * platform/network/mac/WebCoreURLResponse.mm: (WebCore::createExtensionToMIMETypeMap): Deleted. (WebCore::adjustMIMETypeIfNecessary): Refactored to use a SortedArrayMap instead of a CFDictionary, eliminating various type casts and conversions. Refactored to use the new functions below. Use makeNeverDestroyed to instead of RetainPtr::leakRef. Removed unnecessary check for equality since this function only does work when CFURLResponseGetMIMEType is nullptr. (WebCore::filePathExtension): Added. Refactored the code to get a path extension from a CFURLResponseRef into a function since it's used in two places. (WebCore::preferredMIMETypeForFileExtensionFromUTType): Added. Refactored this logical operation, mapping a file extension to a MIME type, into a function. This is used in two places. Also puts ALLOW_DEPRECATED_DECLARATIONS_BEGIN/END pair into a single place, and this is where we'll switch to use newer UTType machinery later on. * testing/cocoa/WebArchiveDumpSupport.mm: (WebCoreTestSupport::convertWebResourceResponseToDictionary): Use auto and dynamic_cf_cast. 2021-08-30 Patrick Angle Web Inspector: Refactor `WorkerInspectorAgent` to use weak pointers for `WorkerInspectorProxy`s https://bugs.webkit.org/show_bug.cgi?id=229632 Reviewed by Chris Dumez. Covered by existing tests in LayoutTests/inspector/worker/* Make `WorkerInspectorProxy` reference counted, and use `WeakPtr`s to them in `InspectorWorkerAgent`. * inspector/agents/InspectorWorkerAgent.cpp: (WebCore::InspectorWorkerAgent::initialized): (WebCore::InspectorWorkerAgent::sendMessageToWorker): (WebCore::InspectorWorkerAgent::connectToAllWorkerInspectorProxiesForPage): (WebCore::InspectorWorkerAgent::disconnectFromAllWorkerInspectorProxies): (WebCore::InspectorWorkerAgent::connectToWorkerInspectorProxy): * inspector/agents/InspectorWorkerAgent.h: * workers/WorkerInspectorProxy.cpp: (WebCore::WorkerInspectorProxy::allWorkerInspectorProxies): (WebCore::WorkerInspectorProxy::workerStarted): (WebCore::WorkerInspectorProxy::workerTerminated): * workers/WorkerInspectorProxy.h: (WebCore::WorkerInspectorProxy::create): * workers/WorkerMessagingProxy.cpp: (WebCore::WorkerMessagingProxy::WorkerMessagingProxy): * workers/WorkerMessagingProxy.h: 2021-08-30 Johnson Zhou Addition of CSSUnparsedValue. (TypedOM) https://bugs.webkit.org/show_bug.cgi?id=229069 Reviewed by Alex Christensen. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSCSSStyleValueCustom.cpp: (WebCore::toJSNewlyCreated): * bindings/js/WebCoreBuiltinNames.h: * css/typedom/CSSNumericValue.h: (WebCore::CSSNumericValue::getType const): * css/typedom/CSSOMVariableReferenceValue.cpp: Copied from Source/WebCore/css/typedom/CSSUnparsedValue.cpp. (WebCore::CSSOMVariableReferenceValue::create): (WebCore::CSSOMVariableReferenceValue::setVariable): (WebCore::CSSOMVariableReferenceValue::toString const): * css/typedom/CSSOMVariableReferenceValue.h: Copied from Source/WebCore/css/typedom/CSSUnparsedValue.h. * css/typedom/CSSOMVariableReferenceValue.idl: Copied from Source/WebCore/css/typedom/CSSStyleValue.idl. * css/typedom/CSSStyleImageValue.cpp: (WebCore::CSSStyleImageValue::CSSStyleImageValue): * css/typedom/CSSStyleImageValue.h: * css/typedom/CSSStyleValue.cpp: (WebCore::CSSStyleValue::parseStyleValue): (WebCore::CSSStyleValue::parse): (WebCore::CSSStyleValue::parseAll): (WebCore::CSSStyleValue::create): (WebCore::CSSStyleValue::CSSStyleValue): (WebCore::CSSStyleValue::reifyValue): (WebCore::CSSStyleValue::toString const): * css/typedom/CSSStyleValue.h: (WebCore::CSSStyleValue::getType const): (WebCore::CSSStyleValue::isUnitValue): Deleted. (WebCore::CSSStyleValue::isUnparsedValue): Deleted. (WebCore::CSSStyleValue::isImageValue): Deleted. * css/typedom/CSSStyleValue.idl: * css/typedom/CSSUnitValue.h: * css/typedom/CSSUnparsedValue.cpp: (WebCore::CSSUnparsedValue::create): (WebCore::CSSUnparsedValue::CSSUnparsedValue): (WebCore::CSSUnparsedValue::toString const): (WebCore::CSSUnparsedValue::item): (WebCore::CSSUnparsedValue::setItem): * css/typedom/CSSUnparsedValue.h: (WebCore::CSSUnparsedValue::length const): (isType): * css/typedom/CSSUnparsedValue.idl: * css/typedom/StylePropertyMapReadOnly.cpp: (WebCore::StylePropertyMapReadOnly::reifyValue): (WebCore::StylePropertyMapReadOnly::customPropertyValueOrDefault): * css/typedom/StylePropertyMapReadOnly.h: * dom/StyledElement.cpp: * html/CustomPaintImage.cpp: (WebCore::extractComputedProperty): 2021-08-30 Kiet Ho Remove hardcoded CSSUnitType enum values https://bugs.webkit.org/show_bug.cgi?id=229672 Reviewed by Simon Fraser. * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isFontIndependentLength): (WebCore::CSSPrimitiveValue::isLength): (WebCore::CSSPrimitiveValue::isResolution): (WebCore::CSSPrimitiveValue::isViewportPercentageLength): * css/CSSUnits.h: 2021-08-30 Jer Noble Fix include guards in PlatformScreenMac.mm https://bugs.webkit.org/show_bug.cgi?id=229430 Reviewed by Alex Christensen. The include guards should refer to the file they're including. * platform/mac/PlatformScreenMac.mm: 2021-08-30 Alex Christensen WKWebViewConfiguration._loadsSubresources=NO should prevent preconnecting https://bugs.webkit.org/show_bug.cgi?id=229684 Reviewed by Tim Horton. * Modules/websockets/ThreadableWebSocketChannel.cpp: (WebCore::ThreadableWebSocketChannel::validateURL): * loader/ResourceLoadNotifier.cpp: (WebCore::ResourceLoadNotifier::dispatchWillSendRequest): * page/Page.cpp: (WebCore::Page::allowsLoadFromURL const): * page/Page.h: (WebCore::Page::loadsSubresources const): Deleted. 2021-08-30 Lauro Moura [LFC][IFC] Remove unused variables after r281744 https://bugs.webkit.org/show_bug.cgi?id=229677 Reviewed by Darin Adler. Silence compiler warnings. Covered by existing tests. * display/css/DisplayBoxFactory.cpp: (WebCore::Display::BoxFactory::displayBoxForTextRun const): 2021-08-30 Sihui Liu Add stubs for Permissions API https://bugs.webkit.org/show_bug.cgi?id=229339 Reviewed by Chris Dumez. Add bindings code and a feature flag for Permissions API. Spec: https://w3c.github.io/permissions/ No new tests. Rebaseline existing tests. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Modules/permissions/Navigator+Permissions.idl: Added. * Modules/permissions/NavigatorPermissions.cpp: Added. (WebCore::NavigatorPermissions::NavigatorPermissions): (WebCore::NavigatorPermissions::permissions): (WebCore::NavigatorPermissions::from): (WebCore::NavigatorPermissions::supplementName): * Modules/permissions/NavigatorPermissions.h: Added. * Modules/permissions/PermissionController.h: Added. * Modules/permissions/PermissionDescriptor.h: Added. (WebCore::PermissionDescriptor::operator== const): (WebCore::PermissionDescriptor::encode const): (WebCore::PermissionDescriptor::decode): * Modules/permissions/PermissionDescriptor.idl: Added. * Modules/permissions/PermissionName.h: Added. * Modules/permissions/PermissionName.idl: Added. * Modules/permissions/PermissionObserver.h: Added. * Modules/permissions/PermissionState.h: Added. * Modules/permissions/PermissionState.idl: Added. * Modules/permissions/PermissionStatus.cpp: Added. (WebCore::PermissionStatus::create): (WebCore::PermissionStatus::PermissionStatus): (WebCore::PermissionStatus::~PermissionStatus): (WebCore::PermissionStatus::stateChanged): (WebCore::PermissionStatus::activeDOMObjectName const): (WebCore::PermissionStatus::virtualHasPendingActivity const): (WebCore::PermissionStatus::eventListenersDidChange): * Modules/permissions/PermissionStatus.h: Added. * Modules/permissions/PermissionStatus.idl: Added. * Modules/permissions/Permissions.cpp: Added. (WebCore::Permissions::create): (WebCore::Permissions::Permissions): (WebCore::Permissions::navigator): (WebCore::Permissions::query): * Modules/permissions/Permissions.h: Added. * Modules/permissions/Permissions.idl: Added. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::permissionController): * dom/Document.h: * dom/EventTargetFactory.in: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::permissionController): * dom/TaskSource.h: * loader/EmptyClients.cpp: (WebCore::pageConfigurationWithEmptyClients): * page/Page.cpp: (WebCore::m_permissionController): (WebCore::Page::permissionController): (WebCore::m_httpsUpgradeEnabled): Deleted. * page/Page.h: * page/PageConfiguration.cpp: (WebCore::PageConfiguration::PageConfiguration): * page/PageConfiguration.h: 2021-08-30 Chris Dumez SubmitEvent.submitter property isn't set for