564abcec614f1c87b0e288a60841bc8af793c890
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2020-05-29  Commit Queue  <commit-queue@webkit.org>
2
3         Unreviewed, reverting r262245.
4         https://bugs.webkit.org/show_bug.cgi?id=212531
5
6         "Caused WebCore's 'Check .xcfilelists' build phase to be ~100x
7         slower"
8
9         Reverted changeset:
10
11         "[Cocoa] Pass all defines from Platform.h to various scripts,
12         not just the ones from .xcconfig"
13         https://bugs.webkit.org/show_bug.cgi?id=212451
14         https://trac.webkit.org/changeset/262245
15
16 2020-05-29  Sergio Villar Senin  <svillar@igalia.com>
17
18         Unreviewed build fix after r262299
19
20         We replaced ScriptExecutionContext* by Document& in WebXRSpace hierarchy, so the
21         failing ASSERT() was:
22         1. Invalid, there is no "context" parameter but "document"
23         2. Not needed anymore, as we're passing a reference
24
25         * Modules/webxr/WebXRSpace.cpp:
26         (WebCore::WebXRSpace::WebXRSpace): Removed invalid ASSERT().
27
28 2020-05-27  Sergio Villar Senin  <svillar@igalia.com>
29
30         [WebXR] Implement XRSession::requestReferenceSpace()
31         https://bugs.webkit.org/show_bug.cgi?id=212407
32
33         Reviewed by Youenn Fablet.
34
35         This patch implements the requestReferenceSpace() method of the XRSession which is used to
36         create reference spaces. A reference space establishes a space where pose data will be defined
37         and thus is mandatory to retrieve that pose information.
38
39         There are still some bits that have to implementated in follow up patches using platform code.
40
41         * Modules/webxr/WebXRBoundedReferenceSpace.cpp:
42         (WebCore::WebXRBoundedReferenceSpace::create): Added.
43         (WebCore::WebXRBoundedReferenceSpace::WebXRBoundedReferenceSpace): Ditto.
44         * Modules/webxr/WebXRBoundedReferenceSpace.h:
45         * Modules/webxr/WebXRReferenceSpace.cpp:
46         (WebCore::WebXRReferenceSpace::create): Added.
47         (WebCore::WebXRReferenceSpace::WebXRReferenceSpace): Ditto.
48         (WebCore::WebXRReferenceSpace::getOffsetReferenceSpace): Use the create() method.
49         * Modules/webxr/WebXRReferenceSpace.h:
50         * Modules/webxr/WebXRSession.cpp:
51         (WebCore::WebXRSession::referenceSpaceIsSupported const): New method to check whether a reference.
52         space is supported by session and device.
53         (WebCore::WebXRSession::requestReferenceSpace): New method that creates reference spaces for pose data.
54         * Modules/webxr/WebXRSession.h:
55         * Modules/webxr/WebXRSpace.cpp:
56         (WebCore::WebXRSpace::WebXRSpace): Store a reference to the session creating the space.
57         * Modules/webxr/WebXRSpace.h:
58
59 2020-05-29  Simon Fraser  <simon.fraser@apple.com>
60
61         Update debug overlays at rendering update time
62         https://bugs.webkit.org/show_bug.cgi?id=212510
63
64         Reviewed by Antoine Quint.
65
66         Don't eagerly update the regions in debug overlays when things change; this triggers
67         assertions for touch event overlays.
68
69         Instead, just mark them dirty and update the regions at "update the rendering" time.
70
71         * page/DebugPageOverlays.cpp:
72         (WebCore::RegionOverlay::setRegionChanged):
73         (WebCore::RegionOverlay::didMoveToPage):
74         (WebCore::RegionOverlay::recomputeRegion):
75         (WebCore::DebugPageOverlays::regionChanged):
76         (WebCore::DebugPageOverlays::updateRegionIfNecessary):
77         * page/DebugPageOverlays.h:
78         (WebCore::DebugPageOverlays::doAfterUpdateRendering):
79         * page/Page.cpp:
80         (WebCore::Page::doAfterUpdateRendering):
81
82 2020-05-29  Simon Fraser  <simon.fraser@apple.com>
83
84         Prepare for async scrolling in passive wheel event handler regions
85         https://bugs.webkit.org/show_bug.cgi?id=212455
86
87         Reviewed by Tim Horton.
88
89         Clarify the processing for wheel events by adding OptionSet<WheelEventProcessingSteps>,
90         which will, in future, allow us to describe the processing for an event in the passive
91         event handler region which does scrolling on the scrolling thread, and is then sent
92         to the main thread for DOM event dispatch.
93         
94         Removed ScrollingEventResult, which conflated "handled" with "send to another thread".
95         The thread sending behavior is now encoded in the WheelEventProcessingSteps, and we can just
96         use a bool for handled.
97         
98         Scrolling tree and node handleWheelEvent() functions return a WheelEventHandlingResult, which
99         is a tuple of OptionSet<WheelEventProcessingSteps> and 'handled', allowing for a node with
100         background-attachment:fixed to add the "send to main thread" processing step.
101
102         * page/FrameView.cpp:
103         (WebCore::FrameView::wheelEvent):
104         * page/scrolling/ScrollingCoordinator.h:
105         (WebCore::ScrollingCoordinator::handleWheelEvent):
106         * page/scrolling/ScrollingCoordinatorTypes.h:
107         * page/scrolling/ScrollingTree.cpp:
108         (WebCore::ScrollingTree::determineWheelEventProcessing):
109         (WebCore::ScrollingTree::handleWheelEvent):
110         (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously): Deleted.
111         * page/scrolling/ScrollingTree.h:
112         (WebCore::WheelEventHandlingResult::needsMainThreadProcessing const):
113         (WebCore::WheelEventHandlingResult::handled):
114         (WebCore::WheelEventHandlingResult::unhandled):
115         (WebCore::WheelEventHandlingResult::result):
116         * page/scrolling/ScrollingTreeScrollingNode.cpp:
117         (WebCore::ScrollingTreeScrollingNode::handleWheelEvent):
118         * page/scrolling/ScrollingTreeScrollingNode.h:
119         * page/scrolling/ThreadedScrollingTree.cpp:
120         (WebCore::ThreadedScrollingTree::handleWheelEvent):
121         (WebCore::ThreadedScrollingTree::handleWheelEventAfterMainThread):
122         * page/scrolling/ThreadedScrollingTree.h:
123         * page/scrolling/mac/ScrollingCoordinatorMac.h:
124         * page/scrolling/mac/ScrollingCoordinatorMac.mm:
125         (WebCore::ScrollingCoordinatorMac::handleWheelEvent):
126         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
127         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
128         (WebCore::ScrollingTreeFrameScrollingNodeMac::handleWheelEvent):
129         * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h:
130         * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
131         (WebCore::ScrollingTreeOverflowScrollingNodeMac::handleWheelEvent):
132         * platform/PlatformWheelEvent.cpp:
133         (WebCore::operator<<):
134         * platform/PlatformWheelEvent.h:
135
136 2020-05-29  Sergio Villar Senin  <svillar@igalia.com>
137
138         [WebXR] ActiveDOMObjects must call suspendIfNeeded() upon creation
139         https://bugs.webkit.org/show_bug.cgi?id=212517
140
141         Reviewed by Žan Doberšek.
142
143         We weren't calling suspendIfNeeded() upon ActiveDOMObjects creation (XRSession and XRSystem)
144         and that was triggering ASSERTION FAILED: m_suspendIfNeededWasCalled.
145
146         No new tests required as this was already detected by existing tests.
147
148         * Modules/webxr/WebXRSession.cpp:
149         (WebCore::WebXRSession::WebXRSession): Call suspendIfNeeded().
150         * Modules/webxr/WebXRSystem.cpp:
151         (WebCore::WebXRSystem::WebXRSystem): Call suspendIfNeeded().
152
153 2020-05-29  Sergio Villar Senin  <svillar@igalia.com>
154
155         [WebXR] WebXRSystem::unregisterSimulatedXRDeviceForTesting() ASSERTs in m_immersiveDevices.contains(device)
156         https://bugs.webkit.org/show_bug.cgi?id=212516
157
158         Reviewed by Žan Doberšek.
159
160         The ASSERT that was failing was wrong. It was assuming that every simulated device should be part of the list
161         of immersive devices. That's wrong, as devices only supporting inline sessions are not in that list.
162
163         Apart from that, fake devices were not removed from the list of available devices in WebXRTest after
164         disconnecting them all. That could potentially cause flakiness in the tests.
165
166         No new test required as the current tests were properly detecting the issue.
167
168         * Modules/webxr/WebXRSystem.cpp:
169         (WebCore::WebXRSystem::registerSimulatedXRDeviceForTesting): Use XRSessionMode directly.
170         (WebCore::WebXRSystem::unregisterSimulatedXRDeviceForTesting): Fixed the ASSERT. A simulated device
171         might not be in the list of immersive devices if only supports inline sessions.
172         * testing/WebXRTest.cpp:
173         (WebCore::WebXRTest::disconnectAllDevices): Clear the list of devices after disconnecting.
174
175 2020-05-29  Youenn Fablet  <youenn@apple.com>
176
177         MediaPlayerPrivateMediaStreamAVFObjC should enqueue samples in a background thread
178         https://bugs.webkit.org/show_bug.cgi?id=212073
179
180         Reviewed by Eric Carlson.
181
182         Do not hop to the main thread when rendering video samples anymore.
183         Instead, we enqueue to the display layer in the background thread but still hop to the main thread for two things:
184         - Update of various states of the player
185         - keep a ref to the video sample if canvas rendering is needed.
186
187         Most display layer operations stay in the main thread (creation, flushing...).
188         Deletion of the display layer and access from a background are covered by a lock.
189         The m_canEnqueueDisplayLayer boolean ensures we do not enqueue too early when the display layer is not yet properly initialized.
190
191         LocalSampleBufferDisplayLayer needs to handle the fact that enqueueing might be done in a background thread.
192         Instead of introducing a lock, we introduce a work queue and we hop to this queue whenever we need to enqueue/mutate the pending samples.
193
194         Covered by existing tests and manual testing.
195
196         * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h:
197         * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:
198         (-[WebAVSampleBufferStatusChangeListener observeValueForKeyPath:ofObject:change:context:]):
199         (WebCore::LocalSampleBufferDisplayLayer::enqueueSample):
200         (WebCore::LocalSampleBufferDisplayLayer::enqueueSampleBuffer):
201         (WebCore::LocalSampleBufferDisplayLayer::requestNotificationWhenReadyForVideoData):
202         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
203         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
204         (WebCore::videoTransformationMatrix):
205         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoSampleAvailable):
206         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoSampleAvailable):
207         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::applicationDidBecomeActive):
208         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::flushRenderers):
209         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::ensureLayers):
210         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::destroyLayers):
211         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateRenderingMode):
212         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::checkSelectedVideoTrack):
213         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext):
214         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setBufferingPolicy):
215         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::rootLayerBoundsDidChange):
216         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoTransformationMatrix): Deleted.
217         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueCorrectedVideoSample): Deleted.
218         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateDisplayLayer): Deleted.
219
220 2020-05-29  Carlos Garcia Campos  <cgarcia@igalia.com>
221
222         [GTK4] Implement script dialogs
223         https://bugs.webkit.org/show_bug.cgi?id=212318
224
225         Reviewed by Adrian Perez de Castro.
226
227         Add more definitions to avoid ifdefs.
228
229         * platform/gtk/GtkVersioning.h:
230         (gtk_entry_set_text):
231         (gtk_entry_get_text):
232         (gtk_label_set_line_wrap):
233         (gtk_window_set_default):
234         (gtk_widget_add_css_class):
235
236 2020-05-28  Andy Estes  <aestes@apple.com>
237
238         [Apple Pay] Buttons render with a corner radius of PKApplePayButtonDefaultCornerRadius even when explicitly specifying "border-radius: 0px"
239         https://bugs.webkit.org/show_bug.cgi?id=212476
240         <rdar://problem/63401433>
241
242         Reviewed by Antti Koivisto.
243
244         r256648 added support for customizing the corner radius of Apple Pay buttons using the
245         border-radius CSS property. PassKit buttons have a default corner radius of 4, but
246         border-radius has an initial value of 0, so to maintain web compatibility with existing
247         buttons we only want to customize the corner radius when a border-radius value has been
248         explicitly specified (otherwise, previously rounded buttons would all become squared off due
249         to border-radius's initial value).
250
251         r256648 checked for a non-initial border-radius by calling RenderStyle::hasBorderRadius, but
252         this check does not distinguish between an initial value and an explicit declaration of
253         "border-radius: 0px". As a result, authors are unable to create Apple Pay buttons with
254         square corners.
255
256         This patch adds a flag to RenderStyle::NonInheritedFlags that tracks whether any
257         border-radius longhand has been explicitly set (or has explicitly inherited an explicitly set
258         value), and uses that flag to adjust the computed border radius for Apple Pay buttons.
259
260         The addition of RenderStyle::NonInheritedFlags::hasExplicitlySetBorderRadius did not change
261         the size of RenderStyle.
262
263         Tests: fast/css/appearance-apple-pay-button-border-radius.html
264                fast/css/getComputedStyle/computed-style-apple-pay-button.html
265
266         * css/CSSProperties.json:
267         * rendering/RenderThemeCocoa.mm:
268         (WebCore::RenderThemeCocoa::adjustApplePayButtonStyle const):
269         (WebCore::RenderThemeCocoa::paintApplePayButton):
270         (WebCore::largestCornerRadius): Deleted.
271         * rendering/style/RenderStyle.cpp:
272         (WebCore::RenderStyle::RenderStyle):
273         * rendering/style/RenderStyle.h:
274         (WebCore::RenderStyle::hasExplicitlySetBorderRadius const):
275         (WebCore::RenderStyle::setHasExplicitlySetBorderRadius):
276         (WebCore::RenderStyle::NonInheritedFlags::operator== const):
277         (WebCore::RenderStyle::NonInheritedFlags::copyNonInheritedFrom):
278         * style/StyleBuilderCustom.h:
279         (WebCore::Style::BuilderCustom::applyInheritBorderBottomLeftRadius):
280         (WebCore::Style::BuilderCustom::applyValueBorderBottomLeftRadius):
281         (WebCore::Style::BuilderCustom::applyInheritBorderBottomRightRadius):
282         (WebCore::Style::BuilderCustom::applyValueBorderBottomRightRadius):
283         (WebCore::Style::BuilderCustom::applyInheritBorderTopLeftRadius):
284         (WebCore::Style::BuilderCustom::applyValueBorderTopLeftRadius):
285         (WebCore::Style::BuilderCustom::applyInheritBorderTopRightRadius):
286         (WebCore::Style::BuilderCustom::applyValueBorderTopRightRadius):
287
288 2020-05-28  Andy Estes  <aestes@apple.com>
289
290         Shrink StyleRareNonInheritedData by 8 bytes (on 64-bit platforms)
291         https://bugs.webkit.org/show_bug.cgi?id=212484
292
293         Reviewed by Tim Horton.
294
295         There were 4 bytes of padding after shapeImageThreshold, enough to fit order and shrink the
296         overall size of StyleRareNonInheritedData by 8 bytes on 64-bit platforms.
297
298         Before:
299         Total byte size: 480
300         Total pad bytes: 50
301         Padding percentage: 10.42 %
302
303         After:
304         Total byte size: 472
305         Total pad bytes: 42
306         Padding percentage: 8.90 %
307
308         * rendering/style/StyleRareNonInheritedData.cpp:
309         (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
310         (WebCore::StyleRareNonInheritedData::operator== const):
311         * rendering/style/StyleRareNonInheritedData.h:
312
313 2020-05-28  Megan Gardner  <megan_gardner@apple.com>
314
315         Responding to post commit review comments for https://bugs.webkit.org/show_bug.cgi?id=212060
316
317         * editing/InsertIntoTextNodeCommand.cpp:
318         (WebCore::InsertIntoTextNodeCommand::doApply):
319
320 2020-05-28  Simon Fraser  <simon.fraser@apple.com>
321
322         Simplify EventDispatcher wheel event dispatch
323         https://bugs.webkit.org/show_bug.cgi?id=212490
324
325         Reviewed by Tim Horton.
326
327         The various cross-thread bounces and completion lambdas in EventDispatcher::wheelEvent()
328         and ScrollingTree code made the logic very hard to follow.
329
330         Moving the ScrollingThread::dispatch() into EventHandler code simplifies things a little,
331         and allows for removal of the hokey "try to handle" ScrollingTree function, as well
332         as the clunky completion function.
333
334         Now, EventHandler call shouldHandleWheelEventSynchronously(), then does the
335         ScrollingThread::dispatch() which allows the lambda to easily call back into
336         EventHandler for the main thread dispatch.
337
338         * page/scrolling/ScrollingTree.h:
339         * page/scrolling/ThreadedScrollingTree.cpp:
340         (WebCore::ThreadedScrollingTree::tryToHandleWheelEvent): Deleted.
341         * page/scrolling/ThreadedScrollingTree.h:
342
343 2020-05-28  Oriol Brufau  <obrufau@igalia.com>
344
345         [css-grid] Fix referencing grid line names with auto repeat()
346         https://bugs.webkit.org/show_bug.cgi?id=209572
347
348         Reviewed by Darin Adler.
349
350         This patch fixes multiple problems when referencing named grid lines with the presence of
351         the auto repeat() syntax:
352
353           - If the 1st track was defined with auto repeat(), then the code used to assume that the
354             referenced line appeared after the repeated tracks. But it may actually precede them.
355
356           - If the referenced line appeared both inside and outside the auto repeat(), then it
357             could resolve to the outside raw index, without expanding the auto repeat().
358
359           - The logic for placing a placement property set to both an integer and an identifier
360             was wrong with auto repeat().
361             This patch fixes it by using the same proper logic that was already implemented in
362             OrderedNamedLinesCollectorInGridLayout::collectLineNamesForIndex
363
364           - The indices of both implicit grid lines defined with grid-template-areas and explicit
365             ones defined with grid-template-rows/columns used to be stored together in
366             NamedGridColumnLines and NamedGridRowLines. This was problematic because the former
367             indices already refer to the final explicit grid so they don't have to be increased when
368             expanding an auto repeat(), but the latter ones should.
369             Therefore, this patch stores the indices in separate fields and uses the correct logic
370             for each one. This also fixes 'grid-template-areas: inherit'.
371
372         This patch is a port of these Chromium patches:
373           - https://crrev.com/744426
374           - https://crrev.com/745925
375           - https://crrev.com/747631
376           - https://crrev.com/747669
377           - https://crrev.com/771984
378
379         Tests: imported/w3c/web-platform-tests/css/css-grid/placement/grid-placement-using-named-grid-lines-002.html
380                imported/w3c/web-platform-tests/css/css-grid/placement/grid-placement-using-named-grid-lines-004.html
381                imported/w3c/web-platform-tests/css/css-grid/placement/grid-placement-using-named-grid-lines-005.html
382                imported/w3c/web-platform-tests/css/css-grid/placement/grid-placement-using-named-grid-lines-008.html
383                imported/w3c/web-platform-tests/css/css-grid/placement/grid-placement-using-named-grid-lines-009.html
384
385         * rendering/style/GridPositionsResolver.cpp:
386         (WebCore::NamedLineCollection::NamedLineCollection):
387         (WebCore::NamedLineCollection::hasExplicitNamedLines const):
388         (WebCore::NamedLineCollection::hasNamedLines const):
389         (WebCore::NamedLineCollection::contains const):
390         (WebCore::NamedLineCollection::firstExplicitPosition const):
391         (WebCore::NamedLineCollection::firstPosition const):
392         * rendering/style/GridPositionsResolver.h:
393         * rendering/style/RenderStyle.h:
394         (WebCore::RenderStyle::implicitNamedGridColumnLines const):
395         (WebCore::RenderStyle::implicitNamedGridRowLines const):
396         (WebCore::RenderStyle::setImplicitNamedGridColumnLines):
397         (WebCore::RenderStyle::setImplicitNamedGridRowLines):
398         * rendering/style/StyleGridData.cpp:
399         (WebCore::StyleGridData::StyleGridData):
400         * rendering/style/StyleGridData.h:
401         (WebCore::StyleGridData::operator== const):
402         * style/StyleBuilderCustom.h:
403         (WebCore::Style::BuilderCustom::applyInitialGridTemplateAreas):
404         (WebCore::Style::BuilderCustom::applyInheritGridTemplateAreas):
405         (WebCore::Style::BuilderCustom::applyValueGridTemplateAreas):
406
407 2020-05-28  Andres Gonzalez  <andresg_22@apple.com>
408
409         [ macOS Debug ] accessibility/roles-exposed.html is a flaky timeout
410         https://bugs.webkit.org/show_bug.cgi?id=212478
411         <rdar://problem/63411656>
412
413         Reviewed by Chris Fleizach.
414
415         Logging the backingObject in every call to accessibilityAttributeValue
416         seems to be causing this long test to take too long and timeout in slow
417         systems.
418
419         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
420         (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
421
422 2020-05-27  Keith Miller  <keith_miller@apple.com>
423
424         for-of should check the iterable is a JSArray for FastArray in DFG iterator_open
425         https://bugs.webkit.org/show_bug.cgi?id=212383
426
427         Reviewed by Saam Barati.
428
429         Update various InheritsTraits specializations to contain a typeRange member.
430         Also, change the inherits function to use inheritsJSTypeImpl like the JSC
431         variants.
432
433         * bindings/js/JSDocumentCustom.h:
434         (JSC::JSCastingHelpers::InheritsTraits<WebCore::JSDocument>::inherits):
435         * bindings/js/JSElementCustom.h:
436         (JSC::JSCastingHelpers::InheritsTraits<WebCore::JSElement>::inherits):
437         * bindings/js/JSEventCustom.h:
438         (JSC::JSCastingHelpers::InheritsTraits<WebCore::JSEvent>::inherits):
439         * bindings/js/JSNodeCustom.h:
440         (JSC::JSCastingHelpers::InheritsTraits<WebCore::JSNode>::inherits):
441         * bindings/scripts/CodeGeneratorJS.pm:
442         (GenerateHeader):
443
444 2020-05-27  Darin Adler  <darin@apple.com>
445
446         [Cocoa] Pass all defines from Platform.h to various scripts, not just the ones from .xcconfig
447         https://bugs.webkit.org/show_bug.cgi?id=212451
448
449         Reviewed by Sam Weinig.
450
451         * DerivedSources.make: Run the preprocessor on Platform.h and parse the output into
452         FEATURE_AND_PLATFORM_DEFINES. Use that and FEATURE_AND_PLATFORM_DEFINE_DEPENDENCIES
453         whenever we need a list of defines. Also took out some Windows-specific stuff since
454         this is now only used on Mac platforms.
455
456 2020-05-27  Simon Fraser  <simon.fraser@apple.com>
457
458         ScrollingTreeMac::eventListenerRegionTypesForPoint() needs to convert the point to local coordinates
459         https://bugs.webkit.org/show_bug.cgi?id=212440
460
461         Reviewed by Tim Horton.
462
463         ScrollingTreeMac::eventListenerRegionTypesForPoint() needs to convert the point to local coordinates
464         before consulting the event region.
465
466         Also made EventListenerRegionType loggabale.
467
468         Will be tested by wheel event tests once we switch to using these kinds of regions.
469
470         * page/scrolling/mac/ScrollingTreeMac.mm:
471         (collectDescendantLayersAtPoint):
472         (ScrollingTreeMac::scrollingNodeForPoint):
473         (ScrollingTreeMac::eventListenerRegionTypesForPoint const):
474         * rendering/style/RenderStyleConstants.cpp:
475         (WebCore::operator<<):
476         * rendering/style/RenderStyleConstants.h:
477
478 2020-05-28  Youenn Fablet  <youenn@apple.com>
479
480         RealtimeIncomingVideoSourceCocoa::OnFrame should use video frame timestamp
481         https://bugs.webkit.org/show_bug.cgi?id=212402
482
483         Reviewed by Eric Carlson.
484
485         Use timestamp provided from the libwebrtc backend instread of marking the frames as display immediately.
486         Update LocalSampleBufferDisplayLayer to mark the frame as display immediately if their presentation time is in the past since we guarantee the frames are in order.
487
488         Remove the offset correction in MediaPlayerPrivateMediaStreamAVFObjC.
489         This does not work well when the display layer is in GPU process and it is simpler to use the system clock which is what AVSampleBufferDisplayLayser is using if controlTimebase is not set.
490
491         Manually tested.
492
493         * platform/graphics/avfoundation/SampleBufferDisplayLayer.h:
494         * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:
495         (WebCore::LocalSampleBufferDisplayLayer::enqueueSample):
496         (WebCore::LocalSampleBufferDisplayLayer::removeOldSamplesFromPendingQueue):
497         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
498         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
499         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample):
500         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoSampleAvailable):
501         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::sampleBufferDisplayLayerStatusDidChange):
502         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::applicationDidBecomeActive):
503         * platform/mediastream/VideoTrackPrivateMediaStream.h:
504         * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
505         (WebCore::RealtimeIncomingVideoSourceCocoa::OnFrame):
506
507 2020-05-28  Antti Koivisto  <antti@apple.com>
508
509         Incorrect clipping of absolute and fixed elements inside stacking-context composited overflow:hidden
510         https://bugs.webkit.org/show_bug.cgi?id=212419
511         <rdar://problem/55856170>
512
513         Reviewed by Simon Fraser.
514
515         We incorrectly clip descendants that are not in containing block chain.
516         There is already code to do the correct clipping, it just needs be enabled in this case.
517
518         Tests: compositing/overflow/non-contained-descendant-clipping-absolute.html
519                compositing/overflow/non-contained-descendant-clipping-fixed.html
520
521         * rendering/RenderLayer.cpp:
522         (WebCore::RenderLayer::RenderLayer):
523         * rendering/RenderLayer.h:
524
525         Add hasCompositedNonContainedDescendants bit.
526
527         * rendering/RenderLayerCompositor.cpp:
528         (WebCore::RenderLayerCompositor::CompositingState::stateForPaintOrderChildren const):
529         (WebCore::RenderLayerCompositor::CompositingState::updateWithDescendantStateAndLayer):
530
531         Check if the parent layer is for a containing block of this layer.
532
533         (WebCore::RenderLayerCompositor::computeCompositingRequirements):
534
535         Update the bit.
536
537         (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
538         (WebCore::RenderLayerCompositor::clipsCompositingDescendants):
539
540         Pick the clipping path where descendants are not clipped.
541
542 2020-05-27  Noam Rosenthal  <noam@webkit.org>
543
544         Implement AccessKeyLabel attribute.
545         https://bugs.webkit.org/show_bug.cgi?id=72715
546
547         Spec: https://html.spec.whatwg.org/multipage/interaction.html#dom-accesskeylabel
548
549         As per spec, return the modifiers+accessKey when requesting the element accessKeyLabel.
550
551         Equivalent to the existing Firefox implementation and (pending) Chrome implementation.
552
553         Alt is the hardcoded modifier for any non-cocoa platform, so hardcode it also for the label.
554         Use modifier text for Mac/iOS as it can change (e.g. for voice-over).
555
556         Reviewed by Darin Adler.
557
558         Test: fast/forms/access-key-label.html
559
560         * html/HTMLElement.cpp:
561         (WebCore::HTMLElement::accessKeyLabel const):
562         * html/HTMLElement.h:
563         * html/HTMLElement.idl:
564
565 2020-05-27  Sam Weinig  <weinig@apple.com>
566
567         Extended Color: Refactor FloatComponents and ColorComponents into a single templatized ColorComponents class
568         https://bugs.webkit.org/show_bug.cgi?id=212446
569
570         Reviewed by Simon Fraser.
571
572         Merge FloatComponents and ColorComponents into ColorComponents<T> and move them to their own
573         header. This avoids duplicate code and paves the way for further generalization down the line.
574         
575         Also moves some utility functions to ColorUtilities.h from SimpleColor.h as they make more sense
576         in the former.
577
578         * Headers.cmake:
579         * WebCore.xcodeproj/project.pbxproj:
580         Add ColorComponents.h
581
582         * platform/graphics/ColorComponents.h: Copied from Source/WebCore/platform/graphics/ColorUtilities.h.
583         Moved ColorComponents to its own header and templatized it to allow it to serve the
584         needs of both the old ColorComponents and old FloatComponents classes.
585         
586         * platform/graphics/ColorUtilities.cpp:
587         * platform/graphics/ColorUtilities.h:
588         Removed ColorComponents/FloatComponents and update existing usages to their new names.
589         Also moved roundAndClampColorChannel, fastMultiplyBy255, fastDivideBy255 
590         and colorFloatToSimpleColorByte here from SimpleColor to make it clear where
591         general helper functions can go.
592         
593         * platform/graphics/Color.h:
594         * platform/graphics/Color.cpp:
595         (WebCore::Color::colorSpaceAndComponents const):
596         (WebCore::Color::toSRGBAComponentsLossy const):
597         * platform/graphics/ExtendedColor.h:
598         (WebCore::ExtendedColor::channels const):
599         Update for rename of FloatComponents to ColorComponents<float>.
600
601         * platform/graphics/SimpleColor.cpp:
602         (WebCore::makeSimpleColorFromHSLA):
603         Use structured bindings and simplify code. 
604
605         * platform/graphics/SimpleColor.h:
606         (WebCore::roundAndClampColorChannel): Deleted.
607         (WebCore::fastMultiplyBy255): Deleted.
608         (WebCore::fastDivideBy255): Deleted.
609         (WebCore::colorFloatToSimpleColorByte): Deleted.
610         As noted above, moved roundAndClampColorChannel, fastMultiplyBy255, fastDivideBy255 
611         and colorFloatToSimpleColorByte to ColorUtilities.h
612
613         * platform/graphics/filters/FEColorMatrix.cpp:
614         Update for rename of FloatComponents to ColorComponents<float>.
615
616         * platform/graphics/filters/FEDisplacementMap.cpp:
617         (WebCore::byteOffsetOfPixel):
618         Moved byteOffsetOfPixel here from ColorUtilities. This file is the only user
619         and it wasn't general in a way that was clear for other users.
620
621         * platform/graphics/filters/FELighting.cpp:
622         (WebCore::FELighting::drawLighting):
623         Update for rename of FloatComponents to ColorComponents<float>.
624
625         * platform/graphics/filters/FEMorphology.cpp:
626         (WebCore::makeColorComponentsfromPixelValue):
627         Added. Used to be ColorComponents::fromRGBA(), but was only used here
628         and didn't seem generally useful.
629
630         (WebCore::makePixelValueFromColorComponents):
631         Added. Used to be ColorComponents::toRGBA(), but was only used here
632         and didn't seem generally useful.
633         
634         (WebCore::minOrMax):
635         (WebCore::columnExtremum):
636         (WebCore::kernelExtremum):
637         (WebCore::FEMorphology::platformApplyGeneric):
638         Update for rename of FloatComponents to ColorComponents<float> and ColorComponents
639         to ColorComponents<uint8_t>.
640
641         * platform/graphics/filters/FETurbulence.cpp:
642         (WebCore::FETurbulence::noise2D const):
643         (WebCore::toIntBasedColorComponents):
644         (WebCore::FETurbulence::calculateTurbulenceValueForPoint const):
645         (WebCore::FETurbulence::fillRegion const):
646         * platform/graphics/filters/FETurbulence.h:
647         Update for rename of FloatComponents to ColorComponents<float> and ColorComponents
648         to ColorComponents<uint8_t>. Also renames toColorComponents to toIntBasedColorComponents
649         as the former was no longer specific enough. Updated to use std::clamp.
650
651         * platform/graphics/filters/FilterOperation.cpp:
652         (WebCore::BasicColorMatrixFilterOperation::transformColor const):
653         (WebCore::BasicComponentTransferFilterOperation::transformColor const):
654         (WebCore::InvertLightnessFilterOperation::transformColor const):
655         (WebCore::InvertLightnessFilterOperation::inverseTransformColor const):
656         * platform/graphics/filters/FilterOperation.h:
657         (WebCore::FilterOperation::transformColor const):
658         (WebCore::FilterOperation::inverseTransformColor const):
659         * platform/graphics/filters/FilterOperations.cpp:
660         (WebCore::FilterOperations::transformColor const):
661         (WebCore::FilterOperations::inverseTransformColor const):
662         Update for rename of FloatComponents to ColorComponents<float>.
663
664 2020-05-27  David Kilzer  <ddkilzer@apple.com>
665
666         REGRESSION (r260023): ITP sparse plist decoding.
667         <https://bugs.webkit.org/show_bug.cgi?id=212424>
668         <rdar://problem/63683055>
669
670         Reviewed by John Wilander.
671
672         Reverted changeset:
673
674         "KeyedDecoder functions in ResourceLoadStatistics.{cpp,h} should return bool and use WARN_UNUSED_RETURN"
675         https://bugs.webkit.org/show_bug.cgi?id=210414
676         https://trac.webkit.org/changeset/260023
677
678         The revert did not compile due to changes in the KeyedDecoder
679         class that require checking the return value of its methods, so
680         additional changes were made below.
681
682         * loader/ResourceLoadStatistics.cpp:
683         (WebCore::decodeHashCountedSet):
684         (WebCore::decodeHashSet):
685         - Use IGNORE_WARNINGS_BEGIN("unused-result")/IGNORE_WARNINGS_END
686           to suppress warning about ignoring the return value from
687           KeyeDecoder::decodeObjects() since decoding these objects is
688           optional.
689         (WebCore::decodeOptionSet):
690         - Check return value of KeyedDecoder::decodeUInt64() before
691           setting `optionSet` parameter.
692
693 2020-05-27  Andres Gonzalez  <andresg_22@apple.com>
694
695         Empty alt attribute does not ignore the image for accessibility clients in Safari.
696         https://bugs.webkit.org/show_bug.cgi?id=212432
697
698         Reviewed by Chris Fleizach.
699
700         Test: accessibility/img-alt-attribute-unassigned-empty.html
701
702         - AccessibilityRenderObject::computeAccessibilityIsIgnored was handling
703         the case of images too late, after checking for ariaRoleAttribute(). So
704         if an image had a role attribute, it was exposed regardless whether its
705         alt attribute was an empty string. This change moves the handling of
706         images above the check for ariaroleAttribute and hence honors the empty
707         alt attribute rule.
708         - Also images that have an aria-label attribute are now exposed.
709         - Added logging of AccessibilityObjectInclusion.
710         - Changed signature of log(RefPtr<AXCoreObject>) as pointed out by Darin Adler in a separate review.
711
712         * accessibility/AXLogger.cpp:
713         (WebCore::AXLogger::log):
714         (WebCore::operator<<):
715         * accessibility/AXLogger.h:
716         * accessibility/AccessibilityNodeObject.cpp:
717         (WebCore::AccessibilityNodeObject::determineAccessibilityRole):
718         (WebCore::AccessibilityNodeObject::isImage const): Moved to base class.
719         * accessibility/AccessibilityNodeObject.h:
720         * accessibility/AccessibilityObject.h:
721         * accessibility/AccessibilityObjectInterface.h:
722         (WebCore::AXCoreObject::isImage const):
723         * accessibility/AccessibilityRenderObject.cpp:
724         (WebCore::objectInclusionFromAltText):
725         (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const):
726         (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
727         (WebCore::AccessibilityRenderObject::updateRoleAfterChildrenCreation):
728         * accessibility/isolatedtree/AXIsolatedObject.cpp:
729         (WebCore::AXIsolatedObject::initializeAttributeData):
730         * accessibility/isolatedtree/AXIsolatedObject.h:
731
732 2020-05-27  Chris Dumez  <cdumez@apple.com>
733
734         pageshow only fires the first time the back button is pressed
735         https://bugs.webkit.org/show_bug.cgi?id=156356
736         <rdar://problem/29256489>
737
738         Reviewed by Alexey Proskuryakov.
739
740         When FrameLoader::commitProvisionalLoad() would restore a page from the back/forward
741         cache, it would only call FrameLoader::checkCompleted() in the main frame and fail
742         to do so in subframes. Calling checkCompleted() is important, not only because it
743         sets m_isComplete to true but also because it calls checkCallImplicitClose(), which
744         resets m_didCallImplicitClose to true and m_wasUnloadEventEmitted to false.
745
746         Because checkCompleted() was not called, FrameLoader::dispatchUnloadEvents() would then
747         fail to fire the pagehide event because the `m_didCallImplicitClose && !m_wasUnloadEventEmitted`
748         was not met. Also, even though checkCompleted() was called for the main frame, if there
749         are subframes, it would just return early because allChildrenAreComplete() returned false.
750         Later on, when trying to fire the pageshow event, it would fail to because we have logic
751         in DOMWindow::dispatchEvent() to avoid firing a pageshow event if we did not previously
752         send a pagehide event.
753
754         To address the issue, I now call checkCompleted() in FrameLoader::open() for subframes, as
755         this gets called for every frame during restoration from the back/forward cache. For the main
756         frame, we keep calling checkCompleted(), after we've called sendRemainingDelegateMessages().
757
758         Test: fast/history/multiple-back-forward-navigations.html
759
760         * loader/FrameLoader.cpp:
761         (WebCore::FrameLoader::open):
762
763 2020-05-27  Sam Weinig  <weinig@apple.com>
764
765         Extended Color: Move ColorMatrix to its own files
766         https://bugs.webkit.org/show_bug.cgi?id=212431
767
768         Reviewed by Dean Jackson.
769
770         Move ColorMatrix to its own files from ColorUtilities.h/cpp
771
772         * Headers.cmake:
773         * Sources.txt:
774         * WebCore.xcodeproj/project.pbxproj:
775         * platform/graphics/ColorMatrix.cpp: Copied from Source/WebCore/platform/graphics/ColorUtilities.cpp.
776         * platform/graphics/ColorMatrix.h: Copied from Source/WebCore/platform/graphics/ColorUtilities.h.
777         * platform/graphics/ColorUtilities.cpp:
778         * platform/graphics/ColorUtilities.h:
779         * platform/graphics/filters/FilterOperation.cpp:
780
781 2020-05-27  David Kilzer  <ddkilzer@apple.com>
782
783         Add OptionSetTraits<> and use with WebCore::DragDestinationAction
784         <https://webkit.org/b/212397>
785
786         Reviewed by Alex Christensen.
787
788         * page/DragActions.h:
789         (WTF::OptionSetTraits<WebCore::DragDestinationAction>):
790         - Add for use with OptionSet<>.
791
792 2020-05-27  Wenson Hsieh  <wenson_hsieh@apple.com>
793
794         [Clipboard API] Support reading "image/png" on ClipboardItem
795         https://bugs.webkit.org/show_bug.cgi?id=212339
796         <rdar://problem/63588957>
797
798         Reviewed by Tim Horton.
799
800         Adds support for reading "image/png" data via ClipboardItem.getType(). See below for more details.
801
802         Tests:  ClipboardTests.ConvertTIFFToPNGWhenPasting
803                 editing/async-clipboard/clipboard-read-write-images.html
804
805         * Modules/async-clipboard/Clipboard.cpp:
806         (WebCore::Clipboard::getType):
807         (WebCore::Clipboard::updateSessionValidity):
808
809         Factor out logic for invalidating the `Clipboard`'s active `Pasteboard` object into a helper method. This is
810         invoked after reading data from the clipboard, and verifies that the changeCount of the pasteboard is still the
811         same as it was upon initially reading the contents of the clipboard. If the clipboard contents changed, we
812         invalidate the session, and `Clipboard` is subsequently denied pasteboard access (until the next time the user
813         explicitly grants programmatic pasteboard access).
814
815         Note that this step is here for correctness rather than security. While it is true that a compromised web
816         process could fake the changeCount at any given moment, other fairly recent changes around WebPasteboardProxy in
817         the UI process makes it impossible to take advantage of this fact to arbitrarily read content from the system
818         pasteboard. Instead of simply reading the empty string, this invalidation ensures that we actually reject the
819         promise returned by the async clipboard API.
820
821         * Modules/async-clipboard/Clipboard.h:
822         * Modules/async-clipboard/ClipboardImageReader.cpp: Added.
823
824         Add a PasteboardFileReader subclass that is responsible for sanitizing image data from the pasteboard into
825         data that may be exposed to the page via clipboard API. On both macOS and iOS, this ensures that potentially
826         sensitive EXIF data is stripped via conversion to the platform image type and back. On macOS, this additionally
827         allows us to handle transcoding TIFF data on the pasteboard to PNG (this is covered by the new API test).
828
829         (WebCore::ClipboardImageReader::readBuffer):
830
831         Add a stub implementation for non-Cocoa platforms for now, which don't implement this part of the API.
832
833         (WebCore::ClipboardImageReader::shouldReadBuffer const):
834
835         Add a new hook to skip over certain types when reading pasteboard data into Files. In particular,
836         `ClipboardImageReader` skips over any MIME type that does not match the MIME type specified (for now, this is
837         limited to "image/png", but may be extended to include more image types in the future after we implement more
838         transcoding logic).
839
840         * Modules/async-clipboard/ClipboardImageReader.h: Added.
841         (WebCore::ClipboardImageReader::ClipboardImageReader):
842         (WebCore::ClipboardImageReader::takeResult):
843         * Modules/async-clipboard/ios/ClipboardImageReaderIOS.mm: Added.
844         (WebCore::ClipboardImageReader::readBuffer):
845
846         Add iOS-specific `(PNG) => PNG` transcoding logic.
847
848         * Modules/async-clipboard/mac/ClipboardImageReaderMac.mm: Added.
849         (WebCore::ClipboardImageReader::readBuffer):
850
851         Add macOS-specific `(PNG, TIFF) => PNG` transcoding logic.
852
853         * Sources.txt:
854         * SourcesCocoa.txt:
855         * WebCore.xcodeproj/project.pbxproj:
856         * platform/Pasteboard.h:
857         (WebCore::PasteboardFileReader::shouldReadBuffer const):
858         * platform/cocoa/PasteboardCocoa.mm:
859         (WebCore::Pasteboard::read):
860
861         Add support for targeting a given pasteboard item index when reading files on Cocoa platforms.
862
863         * platform/gtk/PasteboardGtk.cpp:
864         (WebCore::Pasteboard::read):
865         * platform/ios/PlatformPasteboardIOS.mm:
866         (WebCore::safeTypeForDOMToReadAndWriteForPlatformType):
867         (WebCore::webSafeTypes):
868         (WebCore::PlatformPasteboard::informationForItemAtIndex):
869
870         Expose "image/png" as one of the readable pasteboard types on iOS when using the async clipboard API. For some
871         reason, this adjustment was made on macOS, but wasn't done on iOS, which led to a missing "image/png" type when
872         asking for `ClipboardItem.types`.
873
874         (WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const):
875
876         Add support for writing "image/png "data to the system pasteboard (note that this data has been sanitized
877         already, as it has been processed through `ClipboardItemTypeLoader::sanitizeDataIfNeeded()`). We simply needed
878         to use `forEachPlatformStringOrBuffer` instead of just `forEachPlatformString` when writing the custom
879         pasteboard data.
880
881         (WebCore::createItemProviderRegistrationList):
882         * platform/libwpe/PasteboardLibWPE.cpp:
883         (WebCore::Pasteboard::read):
884         * platform/win/PasteboardWin.cpp:
885         (WebCore::Pasteboard::read):
886
887 2020-05-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
888
889         REGRESSION (r254541): Valid mime types can only be added to the HashSet of the supported types for encoding
890         https://bugs.webkit.org/show_bug.cgi?id=212427
891
892         Reviewed by Darin Adler.
893
894         Add back a check for the mime type validity which was removed in r254541.
895
896         * platform/MIMETypeRegistry.cpp:
897         (WebCore::MIMETypeRegistry::createMIMETypeRegistryThreadGlobalData):
898
899 2020-05-27  Devin Rousso  <drousso@apple.com>
900
901         Web Inspector: replace `featureGuard` and `availability` with a combined `condition` that accepts any macro
902         https://bugs.webkit.org/show_bug.cgi?id=210014
903
904         Reviewed by Brian Burg.
905
906         Previously, the generated InspectorBackendCommands.js would include code for things that the
907         backend doesn't actually support. By using actual macros and preprocessing that file, we can
908         ensure that the frontend doesn't incorrectly think that something is supported by the page
909         being inspected:
910          - the `Canvas` commands and events related to shader programs/pipelines should only exist
911            when the corresponding context type exists, namely `ENABLE(WEBGL)` and `ENABLE(WEBGPU)`.
912          - iOS doesn't support showing rulers, so create a variant of `DOM.setInspectModeEnabled`
913            that only exists for `PLATFORM(IOS_FAMILY)` that doesn't have the `showRulers` optional
914            parameter, as well as removing `Page.setShowRulers` entirely.
915          - setting the forced appearance should only be possible if dark mode is supported.
916          - web archives only exist if CF is used.
917
918         * inspector/InspectorInstrumentation.h:
919         * inspector/InspectorInstrumentation.cpp:
920         * inspector/agents/InspectorCanvasAgent.h:
921         * inspector/agents/InspectorCanvasAgent.cpp:
922         (WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
923         (WebCore::InspectorCanvasAgent::enable):
924         (WebCore::InspectorCanvasAgent::startRecording):
925         (WebCore::InspectorCanvasAgent::reset):
926         (WebCore::InspectorCanvasAgent::unbindCanvas):
927         * inspector/InspectorShaderProgram.h:
928         * inspector/InspectorShaderProgram.cpp:
929         (WebCore::InspectorShaderProgram::requestShaderSource):
930         (WebCore::InspectorShaderProgram::updateShader):
931         * inspector/agents/InspectorDOMAgent.h:
932         * inspector/agents/InspectorDOMAgent.cpp:
933         (WebCore::InspectorDOMAgent::setInspectModeEnabled):
934         * inspector/agents/InspectorPageAgent.h:
935         * inspector/agents/InspectorPageAgent.cpp:
936         (WebCore::InspectorPageAgent::enable):
937         (WebCore::InspectorPageAgent::disable):
938         (WebCore::InspectorPageAgent::setForcedAppearance):
939         (WebCore::InspectorPageAgent::archive):
940
941         * Configurations/FeatureDefines.xcconfig:
942         Add `ENABLE_WEB_ARCHIVE` since it's always enabled in wtf/PlatformEnableCocoa.h.
943
944         * inspector/InspectorFrontendHost.idl:
945         Drive-by: replace the `#if` with the IDL `[Conditional=]`.
946
947 2020-05-27  Miguel Gomez  <magomez@igalia.com>
948
949         [WPE] REGRESSION(r253675) Crash when using threaded rendering
950         https://bugs.webkit.org/show_bug.cgi?id=212404
951
952         Reviewed by Carlos Garcia Campos.
953
954         Check whether the GraphicsContext has a PlatformGraphicsContext before trying to paint with
955         it. If there's no PlatformGraphicsContext, paint using the GraphicsContext methods instead.
956
957         * platform/graphics/cairo/ImageBufferCairoBackend.cpp:
958         (WebCore::ImageBufferCairoBackend::draw):
959         (WebCore::ImageBufferCairoBackend::drawPattern):
960
961 2020-05-27  Carlos Garcia Campos  <cgarcia@igalia.com>
962
963         Unreviewed. Fix build warning with GTK4
964
965         * platform/gtk/GtkUtilities.cpp:
966         (WebCore::widgetRootCoords):
967
968 2020-05-27  David Kilzer  <ddkilzer@apple.com>
969
970         Use OptionSet<DragDestinationAction> for mask values
971         <https://webkit.org/b/212115>
972         <rdar://problem/63423380>
973
974         Reviewed by Alex Christensen.
975
976         DragDestinationAction is used as both individual values and as a
977         bit mask. This changes bit mask uses to OptionSet<> and renames
978         variables to denote masks.
979
980         * page/DragActions.h:
981         (WebCore::DragDestinationAction):
982         - Convert to enum class and remove *None and *Any values.
983         (WebCore::DragDestinationActionAny):
984         - Add helper function to return OptionSet<DragDestinationAction>
985           with all values set.
986         * page/DragController.cpp:
987         (WebCore::DragController::performDragOperation):
988         (WebCore::DragController::dragEnteredOrUpdated):
989         (WebCore::DragController::tryDocumentDrag):
990         (WebCore::DragController::concludeEditDrag):
991         * page/DragController.h:
992         (WebCore::DragController::dragDestinationAction const): Rename.
993         (WebCore::DragController::dragDestinationActionMask const):
994         - Rename dragDestinationAction() to dragDestinationActionMask().
995         * platform/DragData.cpp:
996         (WebCore::DragData::DragData):
997         * platform/DragData.h:
998         (WebCore::DragData::DragData):
999         - Use DragDestinationActionAny() in place of removed
1000           DragDestinationActionAny.
1001         (WebCore::DragData::dragDestinationAction const): Rename.
1002         (WebCore::DragData::dragDestinationActionMask const):
1003         - Rename dragDestinationAction() to dragDestinationActionMask().
1004         (WebCore::DragData::operator =):
1005         * platform/cocoa/DragDataCocoa.mm:
1006         (WebCore::DragData::DragData):
1007
1008 2020-05-27  Youenn Fablet  <youenn@apple.com>
1009
1010         Video freezes when attaching a local MediaStream to multiple elements
1011         https://bugs.webkit.org/show_bug.cgi?id=194802
1012         <rdar://problem/63613107>
1013
1014         Reviewed by Eric Carlson.
1015
1016         AVSampleBufferDisplayLayer sometimes does not update the rendering when the same local source is rendered several times.
1017         To workaround this, we set kCMSampleAttachmentKey_DisplayImmediately to true, which fixes the issue as per my testing.
1018         We clone the sample buffer before setting this property as it might not be thread safe to modify the attachments of a sample
1019         that might also be encoded.
1020         We implement this at LocalSampleBufferDisplayLayer level and enable this for local capture sources only.
1021
1022         Manually tested.
1023
1024         * platform/graphics/avfoundation/SampleBufferDisplayLayer.h:
1025         (WebCore::SampleBufferDisplayLayer::setRenderPolicy):
1026         * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h:
1027         (WebCore::LocalSampleBufferDisplayLayer::setRenderPolicy):
1028         * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:
1029         (WebCore::LocalSampleBufferDisplayLayer::enqueueSample):
1030         (WebCore::LocalSampleBufferDisplayLayer::removeOldSamplesFromPendingQueue):
1031         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
1032         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::ensureLayers):
1033         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::checkSelectedVideoTrack):
1034         * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
1035         * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
1036         (WebCore::setSampleBufferAsDisplayImmediately):
1037         (WebCore::MediaSampleAVFObjC::setAsDisplayImmediately):
1038         (WebCore::MediaSampleAVFObjC::cloneSampleBuffer):
1039
1040 2020-05-19  Sergio Villar Senin  <svillar@igalia.com>
1041
1042         [WebXR] Implement XRSession::requestAnimationFrame()
1043         https://bugs.webkit.org/show_bug.cgi?id=212099
1044
1045         Reviewed by Youenn Fablet.
1046
1047         The WebXR spec defines a requestAnimationFrame() mechanism to provide information about XR tracking devices
1048         using callbacks. It's pretty similar to the requestAnimationFrame() exposed by Window but only used
1049         to update WebXR content. We're adding a basic implementation of this mechanism as long as cancellation
1050         support. It requires some platform code that will be added in follow up patches. That platform code will
1051         provide information like devices' refresh rates, pose (position & orientation), display resolution, etc...
1052
1053         This patch also replaces the type of the callback id from int to unsigned int as per the following change
1054         in specs https://github.com/immersive-web/webxr/pull/1062.
1055
1056         Apart from that we're adding a missing adoptRef() in the testing code that was causing assertions in some
1057         of the tests that are being unskipped as part of this change.
1058
1059         * Modules/webxr/WebXRSession.cpp:
1060         (WebCore::WebXRSession::WebXRSession):
1061         (WebCore::WebXRSession::animationTimerFired): Added.
1062         (WebCore::WebXRSession::scheduleAnimation): Ditto.
1063         (WebCore::WebXRSession::requestAnimationFrame): Ditto.
1064         (WebCore::WebXRSession::cancelAnimationFrame):
1065         * Modules/webxr/WebXRSession.h:
1066         * Modules/webxr/XRFrameRequestCallback.h:
1067         (WebCore::XRFrameRequestCallback::callbackId):
1068         (WebCore::XRFrameRequestCallback::setCallbackId):
1069         (WebCore::XRFrameRequestCallback::cancel):
1070         (WebCore::XRFrameRequestCallback::isCancelled const):
1071         * testing/WebFakeXRDevice.cpp:
1072         (WebCore::WebFakeXRDevice::simulateInputSourceConnection):
1073         * testing/WebFakeXRDevice.h:
1074         * testing/WebFakeXRInputController.h:
1075
1076 2020-05-27  Carlos Garcia Campos  <cgarcia@igalia.com>
1077
1078         [GTK4] Make PointerLock work
1079         https://bugs.webkit.org/show_bug.cgi?id=212314
1080
1081         Reviewed by Adrian Perez de Castro.
1082
1083         * platform/gtk/GtkUtilities.cpp:
1084         (WebCore::widgetDevicePosition): Helper function to avoid #ifdefs due to GTK version differences.
1085         * platform/gtk/GtkUtilities.h:
1086
1087 2020-05-27  Peng Liu  <peng.liu6@apple.com>
1088
1089         VideoFullscreenInterfaceAVKit is leaking when a video element enters and exits fullscreen/picture-in-picture
1090         https://bugs.webkit.org/show_bug.cgi?id=212293
1091
1092         Reviewed by Youenn Fablet.
1093
1094         WebAVPlayerViewControllerDelegate is created and retained by VideoFullscreenInterfaceAVKit,
1095         but it has a RefPtr to VideoFullscreenInterfaceAVKit. This leads to a memory leak
1096         when a video element enters and exit fullscreen or Picture-in-Picture. This patch
1097         replaces the RefPtr with a WeakPtr to fix the leak.
1098
1099         With this patch, we config playerController in VideoFullscreenInterfaceAVKit::setupFullscreen()
1100         and VideoFullscreenInterfaceAVKit::cleanupFullscreen(), so that we can avoid relying on
1101         VideoFullscreenManagerProxy::setHasVideo() and VideoFullscreenManagerProxy::setVideoDimensions().
1102         Those two functions are driven by IPC messages from the Web process, which may come before
1103         VideoFullscreenInterfaceAVKit is constructed or after VideoFullscreenInterfaceAVKit
1104         is destroyed.
1105
1106         Manually tested.
1107
1108         * platform/ios/VideoFullscreenInterfaceAVKit.h:
1109         * platform/ios/VideoFullscreenInterfaceAVKit.mm:
1110         (-[WebAVPlayerViewControllerDelegate setFullscreenInterface:]):
1111         (VideoFullscreenInterfaceAVKit::setupFullscreen):
1112         (VideoFullscreenInterfaceAVKit::cleanupFullscreen):
1113
1114 2020-05-27  Carlos Garcia Campos  <cgarcia@igalia.com>
1115
1116         [GTK][WTR] EventSender: stop using GdkEvent API in preparation for GTK4
1117         https://bugs.webkit.org/show_bug.cgi?id=212298
1118
1119         Reviewed by Adrian Perez de Castro.
1120
1121         Add helpers to GtkUtilities to avoid #ifdefs due to GTK version differences.
1122
1123         * platform/gtk/GtkUtilities.cpp:
1124         (WebCore::widgetRootCoords):
1125         (WebCore::widgetKeyvalToKeycode):
1126         * platform/gtk/GtkUtilities.h:
1127
1128 2020-05-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
1129
1130         SMILTimeContainer must protect its m_scheduledAnimations while it does updateAnimations()
1131         https://bugs.webkit.org/show_bug.cgi?id=212192
1132         <rdar://problem/56717734>
1133
1134         Reviewed by Youenn Fablet.
1135
1136         updateAnimations() needs to protect m_scheduledAnimations while processing
1137         the scheduled animations. m_scheduledAnimations may be changed from JavaScript
1138         callbacks. This will invalidate the HashMap iterators while the one used
1139         by the for-loop in updateAnimations() is still in use.
1140
1141         To allow copying m_scheduledAnimations, the value of the entry has to be
1142         of type AnimationVector instead of std::unique_ptr<AnimationVector>.        
1143
1144         Test: svg/animations/css-animation-reinsert-target.html
1145
1146         * svg/animation/SMILTimeContainer.cpp:
1147         (WebCore::SMILTimeContainer::schedule):
1148         (WebCore::SMILTimeContainer::unschedule):
1149         (WebCore::SMILTimeContainer::processScheduledAnimations):
1150         (WebCore::SMILTimeContainer::updateAnimations):
1151         * svg/animation/SMILTimeContainer.h:
1152
1153 2020-05-26  Alex Christensen  <achristensen@webkit.org>
1154
1155         MacApplication::isSafari should allow safari bundle id variants
1156         https://bugs.webkit.org/show_bug.cgi?id=212401
1157
1158         Reviewed by Timothy Hatcher.
1159
1160         There is a test environment with bundle ID com.apple.Safari.something.
1161         This change is blocking rdar://problem/63574451
1162
1163         * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
1164         (WebCore::MacApplication::isSafari):
1165
1166 2020-05-26  Simon Fraser  <simon.fraser@apple.com>
1167
1168         Rendering artifacts when scrolling overlays
1169         https://bugs.webkit.org/show_bug.cgi?id=204120
1170         <rdar://problem/57121358>
1171
1172         Reviewed by Zalan Bujtas.
1173
1174         RenderLayerBacking::setContentsNeedDisplayInRect() needs to adjust repaint rects in the
1175         scrolled contents layer by the RenderLayer's scrollOffset, because that's what's used
1176         during repaint rect computation. We haven't yet pushed the new scroll offset onto the
1177         GraphicsLayer, so m_scrolledContentsLayer->scrollOffset() would be stale here.
1178
1179         I tested RTL to make sure that scrollOffset(), and not scrollPosition() is the correct
1180         function to tall.
1181
1182         Test: compositing/repaint/compositing-toggle-in-overflow-scroll-repaint.html
1183
1184         * rendering/RenderLayerBacking.cpp:
1185         (WebCore::RenderLayerBacking::setContentsNeedDisplayInRect):
1186
1187 2020-05-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
1188
1189         An SVG animated property animator can stop animation while other animators are still running
1190         https://bugs.webkit.org/show_bug.cgi?id=207417
1191         <rdar://problem/59278306>
1192
1193         Reviewed by Simon Fraser.
1194
1195         An SVG animated property can be animated by multiple animators. When one
1196         animator stops the animation, the animVal should not be deleted since it
1197         will be used by other animators.
1198
1199         SVGAnimatedProperty will maintain a WeakHashSet<SVGAttributeAnimator> in
1200         which the animator will be added when the animation starts and will be 
1201         removed when the the animation stops. When all the animators stops their
1202         animations, the animated property may delete the animVal or keep it if it
1203         can be referenced by JavaScript.
1204
1205         Tests: svg/animations/animated-enum-mutiple-animators.svg
1206                svg/animations/animated-length-mutiple-animators.svg
1207
1208         * svg/properties/SVGAnimatedDecoratedProperty.h:
1209         * svg/properties/SVGAnimatedPrimitiveProperty.h:
1210         * svg/properties/SVGAnimatedProperty.h:
1211         (WebCore::SVGAnimatedProperty::isAnimating const):
1212         (WebCore::SVGAnimatedProperty::startAnimation):
1213         (WebCore::SVGAnimatedProperty::stopAnimation):
1214         (WebCore::SVGAnimatedProperty::instanceStartAnimation):
1215         (WebCore::SVGAnimatedProperty::instanceStopAnimation):
1216         * svg/properties/SVGAnimatedPropertyAnimator.h:
1217         * svg/properties/SVGAnimatedPropertyList.h:
1218         * svg/properties/SVGAnimatedValueProperty.h:
1219         * svg/properties/SVGAttributeAnimator.h:
1220
1221 2020-05-26  Simon Fraser  <simon.fraser@apple.com>
1222
1223         REGRESSION (async oveflow): scrubber missing from inline video inside overflow scroll
1224         https://bugs.webkit.org/show_bug.cgi?id=212391
1225         <rdar://problem/63089859>
1226
1227         Reviewed by Zalan Bujtas.
1228
1229         backgroundClipRect() is in the coordinate space of the ClipRectContext's rootLayer, not the receiver,
1230         so when converting to absolute coordinates we must use the ClipRectContext's rootLayer.
1231
1232         Test: compositing/layer-creation/overlap-in-scroller.html
1233
1234         * rendering/RenderLayerCompositor.cpp:
1235         (WebCore::RenderLayerCompositor::addToOverlapMap const):
1236
1237 2020-05-26  Jer Noble  <jer.noble@apple.com>
1238
1239         Can't scrub video on https://www.judiciary.senate.gov
1240         https://bugs.webkit.org/show_bug.cgi?id=212270
1241         <rdar://problem/57922919>
1242
1243         Reviewed by Eric Carlson.
1244
1245         Test: media/video-duration-seekable.html
1246
1247         www.judiciary.senate.gov uses the Akamai Media Player, which doesn't query HTMLMediaElement.duration
1248         directly. Rather, when it receives a "durationchange" event, it calculates the duration by using the
1249         HTMLMediaElement.seekable ranges to determine the effective media duration. But no event is fired when
1250         the seekable ranges change, and when they first query HTMLMediaElement.seekable, AVFoundation hasn't
1251         yet updated seekable ranges, so we report an empty set of seekable ranges.
1252
1253         The HTML specification suggests that UAs "should adopt a very liberal and optimistic view of what is
1254         seekable." With that advice in mind, when we are asked by the page for our seekable ranges, and we do
1255         not yet have the official ranges from AVPlayerItem, lets just respond with [0, duration).
1256
1257         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
1258         (WebCore::MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable const):
1259
1260 2020-05-25  Darin Adler  <darin@apple.com>
1261
1262         Eliminate Color constructors that take strings, moving color parsing entirely into the CSS parser
1263         https://bugs.webkit.org/show_bug.cgi?id=212296
1264
1265         Reviewed by Sam Weinig.
1266
1267         * css/parser/CSSParser.cpp:
1268         (WebCore::CSSParser::parseColor): Moved more of the logic into
1269         CSSParserFastPaths::parseSimpleColor. Also added a FIXME about what
1270         seems to be a mistake about strict mode.
1271         (WebCore::CSSParser::parseColorWorkerSafe): Ditto.
1272         (WebCore::CSSParser::parseSystemColor): Removed unused context argument.
1273         (WebCore::CSSParser::parseNamedColor): Added.
1274         (WebCore::CSSParser::parseHexColor): Added.
1275         (WebCore::CSSParser::parseSingleValue): Use auto.
1276         (WebCore::CSSParser::parseValue): Ditto.
1277
1278         * css/parser/CSSParser.h: Exported parseColor. Removed unused value pool
1279         and strict arguments from parseColorWorkerSafe. Removed unused context
1280         argument from parseSystemColor. Added parseNamedColor and parseHexColor.
1281
1282         * css/parser/CSSParserFastPaths.cpp:
1283         (WebCore::parseSimpleLengthValue): Take a StringView.
1284         (WebCore::finishParsingHexColor): Added, logic moved from Color constructor.
1285         (WebCore::parseHexColorInternal): Ditto.
1286         (WebCore::parseNumericColor): Added, logic moved from fastParseColorInternal.
1287         (WebCore::parseColor): Turned into a non-member function since it's private
1288         to this file. Use auto a bit more, and removed unneeded value pool argument.
1289         (WebCore::finishParsingNamedColor): Added, logic moved from Color constructor.
1290         (WebCore::parseNamedColorInternal): Ditto.
1291         (WebCore::parseSimpleColorInternal): Ditto.
1292         (WebCore::CSSParserFastPaths::parseSimpleColor): Ditto.
1293         (WebCore::CSSParserFastPaths::parseHexColor): Ditto.
1294         (WebCore::CSSParserFastPaths::parseNamedColor): Ditto.
1295         (WebCore::isUniversalKeyword): Take a StringView.
1296         (WebCore::parseKeywordValue): Ditto.
1297         (WebCore::parseSimpleTransform): Ditto.
1298         (WebCore::parseCaretColor): Ditto. Also take a parser context rather than
1299         a parser mode.
1300         (WebCore::CSSParserFastPaths::maybeParseValue): Take a StringView.
1301
1302         * css/parser/CSSParserFastPaths.h: Cut down includes. Use StringView.
1303         Added parseSimpleColor, parseHexColor, and parseNamedColor.
1304
1305         * css/parser/CSSPropertyParserHelpers.cpp:
1306         (WebCore::CSSPropertyParserHelpers::parseHexColor): Return an
1307         Optional<SimpleColor> instead of a Color.
1308         (WebCore::CSSPropertyParserHelpers::consumeColor): Refactor a bit for clarity.
1309
1310         * html/HTMLElement.cpp:
1311         (WebCore::parseLegacyColorValue): Renamed from parseColorStringWithCrazyLegacyRules
1312         and refactored a bit. Made this match the HTML specification more closely.
1313         (WebCore::HTMLElement::addHTMLColorToStyle): Simplify now that more of the logic
1314         was moved into parseLegacyColorValue.
1315
1316         * html/canvas/CanvasStyle.cpp:
1317         (WebCore::parseColor): Removed unneeded arguments for parseColorWorkerSafe
1318         and for parseSystemColor.
1319
1320         * platform/graphics/Color.cpp:
1321         (WebCore::findNamedColor): Deleted.
1322         (WebCore::Color::Color): Deleted overloadds that take strings.
1323         * platform/graphics/Color.h: Updated for the above.
1324
1325         * platform/graphics/SimpleColor.cpp:
1326         (WebCore::parseHexColorInternal): Deleted.
1327         (WebCore::SimpleColor::parseHexColor): Deleted.
1328         * platform/graphics/SimpleColor.h: Removed parseHexColor functions.
1329
1330 2020-05-26  Antoine Quint  <graouts@apple.com>
1331
1332         Hardware fill-forwards animation and transitions don't interact correctly
1333         https://bugs.webkit.org/show_bug.cgi?id=187839
1334         <rdar://problem/42410412>
1335
1336         Reviewed by Simon Fraser.
1337
1338         Test: webanimations/updating-property-targeted-by-css-transition-during-css-animation.html
1339
1340         We didn't follow the CSS Transitions spec closely enough when it came to defining the correct before and after
1341         change styles during a style change event.
1342
1343         We now correctly set the before-change style as one of three possible values:
1344         
1345             1. if there are running CSS-originated animations, we ensure those are updated to the current time and
1346                resolve them to get the style,
1347             2. otherwise we use the RenderStyle recorded in Style::TreeResolver::createAnimatedElementUpdate() prior
1348                to applying animations during the last style change event,
1349             3. otherwise we use the previous computed style, which should not have any animated values.
1350         
1351         As for the after-change style, we also need to ensure any running CSS Animations are update to the current time
1352         and resolve them to get the style. Otherwise, we just use the current computed style prior to applying animations.
1353
1354         Finally, we can exit from AnimationTimeline::updateCSSTransitionsForElementAndProperty() early if we find that
1355         we have a JS-originated animation running for the given property on the given element since we know that that
1356         animation will yield an overriding value for both the before and after change styles since JS-originated animations
1357         have the hightest composite order.
1358
1359         This means we no longer need to track the unanimated style on KeyframeEffect.
1360
1361         * animation/AnimationTimeline.cpp:
1362         (WebCore::AnimationTimeline::updateCSSAnimationsForElement):
1363         (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty):
1364         (WebCore::AnimationTimeline::updateCSSTransitionsForElement):
1365         * animation/AnimationTimeline.h:
1366         * animation/ElementAnimationRareData.h:
1367         (WebCore::ElementAnimationRareData::lastStyleChangeEventStyle const):
1368         (WebCore::ElementAnimationRareData::setLastStyleChangeEventStyle):
1369         * animation/KeyframeEffect.cpp:
1370         (WebCore::KeyframeEffect::clearBlendingKeyframes):
1371         (WebCore::KeyframeEffect::apply):
1372         (WebCore::KeyframeEffect::applyPendingAcceleratedActions):
1373         * animation/KeyframeEffect.h:
1374         (WebCore::KeyframeEffect::unanimatedStyle const): Deleted.
1375         * dom/Element.cpp:
1376         (WebCore::Element::lastStyleChangeEventStyle const):
1377         (WebCore::Element::setLastStyleChangeEventStyle):
1378         * dom/Element.h:
1379         * style/StyleTreeResolver.cpp:
1380         (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
1381
1382 2020-05-26  Sam Weinig  <weinig@apple.com>
1383
1384         Extended Color Cleanup: Remove red()/green()/blue() accessors from ExtendedColor in preperation for supporting non-RGB based ColorSpaces
1385         https://bugs.webkit.org/show_bug.cgi?id=212366
1386
1387         Reviewed by Simon Fraser.
1388
1389         * platform/graphics/Color.cpp:
1390         (WebCore::differenceSquared):
1391         Switch to using toSRGBASimpleColorLossy() rather than poking at the ExtendedColor
1392         components directly. The old code was already incorrect if the two colors had 
1393         differing color spaces so this at least now gives reasonable results.
1394
1395         (WebCore::Color::colorWithAlpha const):
1396         (WebCore::Color::colorWithAlphaUsingAlternativeRounding const):
1397         Delegate to ExtendedColor completely for colorWithAlpha() to allow for more
1398         control over how the components might be stored in the future.
1399         
1400         * platform/graphics/Color.h:
1401         (WebCore::Color::isBlackColor):
1402         (WebCore::Color::isWhiteColor):
1403         Delegate to ExtendedColor for isBlack()/isWhite() to allow per-color space
1404         interpretations of the predicate.
1405
1406         (WebCore::Color::encode const):
1407         (WebCore::Color::decode):
1408         Use c1, c2, c3 rather than red/green/blue. This should be acceptable for the
1409         forseeable future, as all expected colorspaces only have 3 channels, but at 
1410         some point, it may make sense to delegate coding to ExtendedColor completely.
1411
1412         * platform/graphics/ExtendedColor.cpp:
1413         * platform/graphics/ExtendedColor.h:
1414         (WebCore::ExtendedColor::channels const):
1415         (WebCore::ExtendedColor::red const): Deleted.
1416         (WebCore::ExtendedColor::green const): Deleted.
1417         (WebCore::ExtendedColor::blue const): Deleted.
1418         (WebCore::ExtendedColor::colorWithAlpha const): Added.
1419         (WebCore::ExtendedColor::isWhite const): Added.
1420         (WebCore::ExtendedColor::isBlack const): Added.
1421         Use channels() with structured bindings rather than the red()/green()/blue() accessors
1422         everywhere.
1423
1424 2020-05-26  Peng Liu  <peng.liu6@apple.com>
1425
1426         ASSERTION FAILED: m_clientCounts.contains(contextId) - WebKit::VideoFullscreenManagerProxy::removeClientForContext()
1427         https://bugs.webkit.org/show_bug.cgi?id=212308
1428
1429         Reviewed by Jer Noble.
1430
1431         Call m_videoFullscreenModel->didExitPictureInPicture() after the video player
1432         completes the process to exit Picture-in-Picture.
1433
1434         Covered by existing tests.
1435
1436         * platform/ios/VideoFullscreenInterfaceAVKit.mm:
1437         (VideoFullscreenInterfaceAVKit::cleanupFullscreen):
1438         (VideoFullscreenInterfaceAVKit::didStopPictureInPicture):
1439
1440 2020-05-26  Zalan Bujtas  <zalan@apple.com>
1441
1442         [LFC][TFC] Use padding to space out sections
1443         https://bugs.webkit.org/show_bug.cgi?id=212377
1444
1445         Reviewed by Antti Koivisto.
1446
1447         Use fake padding before/after to space out sections.
1448
1449         Test: fast/layoutformattingcontext/table-simple-multiple-sections-with-border-spacing-and-collapse.html
1450
1451         * layout/tableformatting/TableFormattingContext.cpp:
1452         (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
1453
1454 2020-05-26  Keith Rollin  <krollin@apple.com>
1455
1456         Enable the use of XCBuild by default in Apple builds
1457         https://bugs.webkit.org/show_bug.cgi?id=209890
1458         <rdar://problem/44182078>
1459
1460         Reviewed by Darin Adler.
1461
1462         Switch from the "legacy" Xcode build system to the "new" build system
1463         (also known as "XCBuild"). Switching to the new system speeds up
1464         builds by a small percentage, better validates projects for
1465         build-related issues (such as dependency cycles), lets WebKit benefit
1466         from future improvements in XCBuild such as those coming from the
1467         underlying llbuild open source project, and prepares us for any other
1468         tools built for this new ecosystem.
1469
1470         Specific changes:
1471
1472         - Remove Xcode project and workspace settings that selected the Build
1473           system, allowing the default to take hold (which is currently the
1474           New build system).
1475         - Updated webkitdirs.pm with a terser check for Xcode version.
1476         - Update build-webkit and Makefile.shared to be explicit when using
1477           the old build system (no longer treat it as a default or fall-back
1478           configuration).
1479         - Update various xcconfig files similarly to treat the default as
1480           using the new build system.
1481         - Update various post-processing build steps to check for Xcode 11.4
1482           and to no longer treat the default as using the old build system.
1483
1484         No new tests -- no changed functionality.
1485
1486         * WebCore.xcodeproj/project.pbxproj:
1487
1488 2020-05-26  Zalan Bujtas  <zalan@apple.com>
1489
1490         [LFC][TFC] Add support for multiple sections
1491         https://bugs.webkit.org/show_bug.cgi?id=212354
1492
1493         Reviewed by Antti Koivisto.
1494
1495         Let's keep the grid about rows and columns and about distributing available space.
1496         Use the layout tree to find sections. 
1497
1498         Test: fast/layoutformattingcontext/table-simple-multiple-sections.html
1499
1500         * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
1501         (WebCore::Layout::TableWrapperBlockFormattingContext::computeBorderAndPaddingForTableBox):
1502         * layout/tableformatting/TableFormattingContext.cpp:
1503         (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
1504         (WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
1505         (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
1506         * layout/tableformatting/TableGrid.cpp:
1507         (WebCore::Layout::TableGrid::appendCell):
1508         (WebCore::Layout::TableGrid::Section::Section): Deleted.
1509         * layout/tableformatting/TableGrid.h:
1510         (WebCore::Layout::TableGrid::Section::box const): Deleted.
1511         (WebCore::Layout::TableGrid::sections const): Deleted.
1512         (WebCore::Layout::TableGrid::sections): Deleted.
1513
1514 2020-05-26  Carlos Garcia Campos  <cgarcia@igalia.com>
1515
1516         [GTK4] Use screen font options as default
1517         https://bugs.webkit.org/show_bug.cgi?id=212332
1518
1519         Reviewed by Adrian Perez de Castro.
1520
1521         There's no gdk_screen_get_font_options() in GTK4, so we need to get the individual properties from the settings
1522         and build a cairo_font_options_t. We can just do the same in GTK3 to avoid ifdefs. Add a helper
1523         SystemFontOptions singleton class to monitor and parse the font settings.
1524
1525         * platform/graphics/gtk/GdkCairoUtilities.cpp:
1526         (WebCore::SystemFontOptions::singleton):
1527         (WebCore::SystemFontOptions::SystemFontOptions):
1528         (WebCore::SystemFontOptions::fontOptions const):
1529         (WebCore::SystemFontOptions::updateFontOptions):
1530         (WebCore::getDefaultCairoFontOptions):
1531
1532 2020-05-25  Simon Fraser  <simon.fraser@apple.com>
1533
1534         Use an Optional<> for LayerFragment::boundingBox
1535         https://bugs.webkit.org/show_bug.cgi?id=212358
1536
1537         Reviewed by Zalan Bujtas.
1538
1539         Replace a bool + LayoutRect with Optional<LayoutRect>.
1540
1541         * rendering/LayerFragment.h:
1542         (WebCore::LayerFragment::setRects):
1543         (WebCore::LayerFragment::moveBy):
1544         (WebCore::LayerFragment::intersect):
1545         * rendering/RenderLayer.cpp:
1546         (WebCore::RenderLayer::collectFragments):
1547         (WebCore::RenderLayer::updatePaintingInfoForFragments):
1548         (WebCore::RenderLayer::calculateClipRects const):
1549         * rendering/RenderLayer.h:
1550
1551 2020-05-25  Simon Fraser  <simon.fraser@apple.com>
1552
1553         Make isTableRow() an inline function
1554         https://bugs.webkit.org/show_bug.cgi?id=212360
1555
1556         Reviewed by Darin Adler.
1557
1558         isTableCell() is a virtual function that's called in some hot code paths, like RenderLayer::localBoundingBox(),
1559         so make it inline by using a spare bit on RenderObject.
1560
1561         * rendering/RenderObject.h:
1562         (WebCore::RenderObject::isTableCaption const):
1563         (WebCore::RenderObject::isTableRow const):
1564         (WebCore::RenderObject::setIsTableRow):
1565         (WebCore::RenderObject::RenderObjectBitfields::RenderObjectBitfields):
1566         * rendering/RenderTableRow.cpp:
1567         (WebCore::RenderTableRow::RenderTableRow):
1568         * rendering/RenderTableRow.h:
1569
1570 2020-05-25  Alex Christensen  <achristensen@webkit.org>
1571
1572         Expose more network metrics to WebCoreNSURLSession
1573         https://bugs.webkit.org/show_bug.cgi?id=212359
1574         <rdar://problem/62909440>
1575
1576         Reviewed by Darin Adler.
1577
1578         * platform/network/NetworkLoadMetrics.h:
1579         (WebCore::NetworkLoadMetrics::isolatedCopy const):
1580         (WebCore::NetworkLoadMetrics::operator== const):
1581         (WebCore::NetworkLoadMetrics::encode const):
1582         (WebCore::NetworkLoadMetrics::decode):
1583         * platform/network/cocoa/WebCoreNSURLSession.mm:
1584         (-[WebCoreNSURLSessionTaskTransactionMetrics networkProtocolName]):
1585         (-[WebCoreNSURLSessionTaskTransactionMetrics isReusedConnection]):
1586         (-[WebCoreNSURLSessionTaskTransactionMetrics cellular]):
1587         (-[WebCoreNSURLSessionTaskTransactionMetrics expensive]):
1588         (-[WebCoreNSURLSessionTaskTransactionMetrics constrained]):
1589         (-[WebCoreNSURLSessionTaskTransactionMetrics multipath]):
1590
1591 2020-05-25  Oriol Brufau  <obrufau@igalia.com>
1592
1593         [css-grid] Prevent grid-template-rows from serializing adjacent <line-names>
1594         https://bugs.webkit.org/show_bug.cgi?id=212345
1595
1596         Reviewed by Manuel Rego Casasnovas.
1597
1598         The parser for the grid-template shorthand has this code:
1599
1600             // Persists between loop iterations so we can use the same value for
1601             // consecutive <line-names> values
1602             RefPtr<CSSGridLineNamesValue> lineNames;
1603
1604         However, this wasn't working because of a lineNames.releaseNonNull() at
1605         the end of the loop. So each iteration started with a null lineNames, and
1606         consecutive <line-names> values were not merged together.
1607
1608         Tests: fast/css-grid-layout/grid-template-shorthand-get-set.html
1609                imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand.html
1610                imported/w3c/web-platform-tests/css/css-grid/parsing/grid-shorthand-valid.html
1611                imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand.html
1612                imported/w3c/web-platform-tests/css/css-grid/parsing/grid-template-shorthand-valid.html
1613
1614         * css/parser/CSSPropertyParser.cpp:
1615         (WebCore::CSSPropertyParser::consumeGridTemplateRowsAndAreasAndColumns):
1616
1617 2020-05-25  Sam Weinig  <weinig@apple.com>
1618
1619         Extended Color Cleanup: Assert !isExtended() in Color::asSimpleColor()...finally
1620         https://bugs.webkit.org/show_bug.cgi?id=212357
1621
1622         Reviewed by Simon Fraser.
1623
1624         Reap the reward of the cleanup, and add the ASSERT(!isExtended()) to Color::asSimpleColor()
1625         as was the original goal of this effort. Only tree non-checked places remained and were 
1626         trivial to add isExtended() checks for.
1627
1628         * platform/graphics/Color.cpp:
1629         (WebCore::Color::nameForRenderTreeAsText const):
1630         Use ExtenedColor::cssText() for the RenderTree representation. It is stable 
1631         and as good as any, no need to re-invent the wheel here.
1632
1633         (WebCore::Color::light const):
1634         (WebCore::Color::dark const):
1635         Add isExtended() checks before doing white/black checks,
1636
1637         * platform/graphics/Color.h:
1638         (WebCore::Color::asSimpleColor const):
1639         Add ASSERT.
1640
1641 2020-05-24  Sam Weinig  <weinig@apple.com>
1642
1643         Extended Color Cleanup: Use the name SimpleColor consistently
1644         https://bugs.webkit.org/show_bug.cgi?id=212337
1645
1646         Reviewed by Anders Carlsson.
1647         
1648         - Removes RGBA32 type alias, updating all remaining users of it.
1649         - Renames functions that take/return SimpleColor to use the name
1650           SimpleColor rather than RGB (e.g. makeRGBA -> makeSimpleColor)
1651         - Moves hex color parsing from Color to SimpleColor, as that is
1652           the type it returns. Also took the opportunity to make it return
1653           an Optional<SimpleColor> instead of using a bool/out parameter.
1654         - Move Color::compositionFill to editing/CompositionHighlight.h
1655           It makes no real sense to keep it in Color.h
1656         - Replaces rgb() function in Color with asSimpleColor() for 
1657           symmetry with asExtended().
1658         - Replaced std::max(a, std::min(value, b)) with std::clamp(value, a, b)
1659           for clarity.
1660
1661         * css/parser/CSSParserFastPaths.cpp:
1662         (WebCore::fastParseColorInternal):
1663         (WebCore::CSSParserFastPaths::parseColor):
1664         * css/parser/CSSPropertyParserHelpers.cpp:
1665         (WebCore::CSSPropertyParserHelpers::parseRGBParameters):
1666         (WebCore::CSSPropertyParserHelpers::parseHSLParameters):
1667         (WebCore::CSSPropertyParserHelpers::parseHexColor):
1668         * editing/CompositionHighlight.h:
1669         * editing/cocoa/DataDetection.mm:
1670         (WebCore::DataDetection::detectContentInRange):
1671         * html/ColorInputType.cpp:
1672         (WebCore::parseSimpleColorValue):
1673         * html/HTMLElement.cpp:
1674         (WebCore::parseColorStringWithCrazyLegacyRules):
1675         * platform/adwaita/ScrollbarThemeAdwaita.cpp:
1676         * platform/adwaita/ThemeAdwaita.cpp:
1677         (WebCore::ThemeAdwaita::activeSelectionForegroundColor const):
1678         (WebCore::ThemeAdwaita::activeSelectionBackgroundColor const):
1679         (WebCore::ThemeAdwaita::inactiveSelectionForegroundColor const):
1680         * platform/graphics/Color.cpp:
1681         (WebCore::differenceSquared):
1682         (WebCore::Color::Color):
1683         (WebCore::Color::operator=):
1684         (WebCore::Color::serialized const):
1685         (WebCore::Color::cssText const):
1686         (WebCore::Color::nameForRenderTreeAsText const):
1687         (WebCore::Color::light const):
1688         (WebCore::Color::dark const):
1689         (WebCore::Color::blend const):
1690         (WebCore::Color::blendWithWhite const):
1691         (WebCore::Color::colorWithAlpha const):
1692         (WebCore::Color::colorWithAlphaUsingAlternativeRounding const):
1693         (WebCore::Color::invertedColorWithAlpha const):
1694         (WebCore::Color::colorSpaceAndComponents const):
1695         (WebCore::Color::toSRGBASimpleColorLossy const):
1696         (WebCore::blend):
1697         (WebCore::Color::tagAsValid):
1698         (WebCore::parseHexColorInternal): Deleted.
1699         (WebCore::Color::parseHexColor): Deleted.
1700         (WebCore::Color::asExtended const): Deleted.
1701         * platform/graphics/Color.h:
1702         (WebCore::Color::Color):
1703         (WebCore::Color::isHashTableDeletedValue const):
1704         (WebCore::Color::isValid const):
1705         (WebCore::Color::isOpaque const):
1706         (WebCore::Color::isVisible const):
1707         (WebCore::Color::alpha const):
1708         (WebCore::Color::alphaAsFloat const):
1709         (WebCore::Color::isSemantic const):
1710         (WebCore::Color::isExtended const):
1711         (WebCore::Color::setIsSemantic):
1712         (WebCore::operator==):
1713         (WebCore::equalIgnoringSemanticColor):
1714         (WebCore::Color::hash const):
1715         (WebCore::Color::asExtended const):
1716         (WebCore::Color::asSimpleColor const):
1717         (WebCore::Color::setSimpleColor):
1718         (WebCore::Color::isBlackColor):
1719         (WebCore::Color::isWhiteColor):
1720         (WebCore::Color::encode const):
1721         (WebCore::Color::decode):
1722         (WebCore::Color::setRGB): Deleted.
1723         (WebCore::Color::rgb const): Deleted.
1724         * platform/graphics/ColorUtilities.h:
1725         (WebCore::clampedColorComponent):
1726         * platform/graphics/ImageBackingStore.h:
1727         (WebCore::ImageBackingStore::blendPixel):
1728         (WebCore::ImageBackingStore::pixelValue const):
1729         * platform/graphics/SimpleColor.cpp:
1730         (WebCore::makePremultipliedSimpleColor):
1731         (WebCore::makeUnpremultipliedSimpleColor):
1732         (WebCore::makeSimpleColorFromFloats):
1733         (WebCore::makeSimpleColorFromHSLA):
1734         (WebCore::makeSimpleColorFromCMYKA):
1735         (WebCore::parseHexColorInternal):
1736         (WebCore::SimpleColor::parseHexColor):
1737         (WebCore::makePremultipliedRGBA): Deleted.
1738         (WebCore::makeUnPremultipliedRGBA): Deleted.
1739         (WebCore::makeRGBA32FromFloats): Deleted.
1740         (WebCore::makeRGBAFromHSLA): Deleted.
1741         (WebCore::makeRGBAFromCMYKA): Deleted.
1742         * platform/graphics/SimpleColor.h:
1743         (WebCore::roundAndClampColorChannel):
1744         (WebCore::colorFloatToSimpleColorByte):
1745         (WebCore::makeSimpleColor):
1746         (WebCore::colorFloatToRGBAByte): Deleted.
1747         (WebCore::makeRGB): Deleted.
1748         (WebCore::makeRGBA): Deleted.
1749         * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
1750         (WebCore::makeSimpleColorFromARGBCFArray):
1751         (WebCore::InbandTextTrackPrivateAVF::processCueAttributes):
1752         (WebCore::makeRGBA32FromARGBCFArray): Deleted.
1753         * platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp:
1754         (WebCore::ImageBufferCairoImageSurfaceBackend::platformTransformColorSpace):
1755         * platform/graphics/cairo/NativeImageCairo.cpp:
1756         (WebCore::nativeImageSinglePixelSolidColor):
1757         * platform/graphics/cg/ColorCG.cpp:
1758         (WebCore::makeSimpleColorFromCGColor):
1759         (WebCore::Color::Color):
1760         (WebCore::cachedCGColor):
1761         (WebCore::makeRGBAFromCGColor): Deleted.
1762         * platform/graphics/gtk/ColorGtk.cpp:
1763         (WebCore::Color::Color):
1764         * platform/graphics/mac/ColorMac.mm:
1765         (WebCore::makeSimpleColorFromNSColor):
1766         (WebCore::colorFromNSColor):
1767         (WebCore::semanticColorFromNSColor):
1768         (WebCore::makeRGBAFromNSColor): Deleted.
1769         * platform/graphics/win/ColorDirect2D.cpp:
1770         (WebCore::Color::Color):
1771         * platform/graphics/win/GraphicsContextCGWin.cpp:
1772         (WebCore::GraphicsContext::drawDotsForDocumentMarker):
1773         * platform/graphics/win/PlatformContextDirect2D.cpp:
1774         (WebCore::PlatformContextDirect2D::brushWithColor):
1775         * platform/ios/ColorIOS.mm:
1776         (WebCore::colorFromUIColor):
1777         * rendering/InlineTextBox.cpp:
1778         (WebCore::InlineTextBox::paintCompositionBackground):
1779         * rendering/RenderLayer.cpp:
1780         (WebCore::RenderLayer::paintResizer):
1781         * rendering/RenderLayerBacking.cpp:
1782         (WebCore::patternForTouchAction):
1783         (WebCore::patternForEventListenerRegionType):
1784         * rendering/RenderThemeAdwaita.cpp:
1785         * rendering/RenderThemeMac.mm:
1786         (WebCore::menuBackgroundColor):
1787
1788 2020-05-25  Zalan Bujtas  <zalan@apple.com>
1789
1790         [Subpixel layout] Bad scrolling on mercurynews.com article
1791         https://bugs.webkit.org/show_bug.cgi?id=201038
1792         <rdar://problem/28489812>
1793
1794         Reviewed by Dean Jackson.
1795
1796         The scrolling is caused by the mismatching subpixel handling between block and inline content.
1797         Inline content (and in this particular case ascent/descent handling) is still integral based while block content supports fractional pixel values.
1798         When the (inline)line height relies on the (block)inline-block height, we need to make sure that the computed line height encloses the inline-block.
1799         This patch changes the rounding behavior of computed the line height from floor to round.
1800
1801         Test: fast/inline/hidpi-inline-block-is-subpixel-while-line-is-not.html
1802
1803         * rendering/RenderBox.cpp:
1804         (WebCore::RenderBox::baselinePosition const):
1805         * rendering/RootInlineBox.cpp:
1806         (WebCore::RootInlineBox::ascentAndDescentForBox const):
1807
1808 2020-05-25  Rob Buis  <rbuis@igalia.com>
1809
1810         Use child text content when determining whether to bail early in running a script
1811         https://bugs.webkit.org/show_bug.cgi?id=182695
1812
1813         Reviewed by Youenn Fablet.
1814
1815         Check that the text content is not empty instead of just checking
1816         for the first child [1].
1817
1818         Behavior matches Chrome and Firefox.
1819
1820         [1] https://html.spec.whatwg.org/#prepare-a-script step 5 and 6
1821
1822         Test: web-platform-tests/html/semantics/scripting-1/the-script-element/emptyish-script-elements.html
1823
1824         * dom/ScriptElement.cpp:
1825         (WebCore::ScriptElement::prepareScript):
1826
1827 2020-05-22  Sergio Villar Senin  <svillar@igalia.com>
1828
1829         [css-flex] Allow indefinite size flex items to be definite wrt resolving percentages inside them
1830         https://bugs.webkit.org/show_bug.cgi?id=212264
1831
1832         Reviewed by Manuel Rego Casasnovas.
1833
1834         Implement https://github.com/w3c/csswg-drafts/commit/5b5db39d21f3658ae2f4d7992daaf822aca178d8 which modified
1835         the way percentages were resolved in flexible items with indefinite sizes. From now on we can pretend that
1836         they're really definite.
1837
1838         This allows us to mark 3 tests which were testing percentages in flex items as correct.
1839
1840         Based on Blink's crrev.com/1247184 by <cbiesinger@chromium.org>
1841
1842         * rendering/RenderFlexibleBox.cpp:
1843         (WebCore::RenderFlexibleBox::mainSizeForPercentageResolution): Do only check flex container main size
1844         definiteness when computing the main size for percentage resolution, no need to check flex basis at all.
1845
1846 2020-05-25  Youenn Fablet  <youenn@apple.com>
1847
1848         AVVideoCaptureSource should notify of video samples in a background thread
1849         https://bugs.webkit.org/show_bug.cgi?id=212072
1850
1851         Reviewed by Eric Carlson.
1852
1853         Do not hop to the main thread to send samples.
1854         Instead, directly call the observer callback.
1855         Manually tested.
1856
1857         * platform/mediastream/mac/AVVideoCaptureSource.h:
1858         * platform/mediastream/mac/AVVideoCaptureSource.mm:
1859         (WebCore::AVVideoCaptureSource::captureOutputDidOutputSampleBufferFromConnection):
1860
1861 2020-05-25  Adrian Perez de Castro  <aperez@igalia.com>
1862
1863         Non-unified build fixes, late May 2020 edition
1864         https://bugs.webkit.org/show_bug.cgi?id=212342
1865
1866         Unreviewed build fix.
1867
1868         No new tests needed.
1869
1870         * loader/ImageLoader.h: Add missing inclusion of Element.h and remove forward declaration.
1871         * page/PageConfiguration.h: Add missing inclusion of ShouldRelaxThirdPartyCookieBlocking.h
1872
1873 2020-05-25  Youenn Fablet  <youenn@apple.com>
1874
1875         MediaPlayerPrivateMediaStreamAVFObjC::m_activeVideoTrack should be a VideoTrackPrivateMediaStream
1876         https://bugs.webkit.org/show_bug.cgi?id=212129
1877
1878         Reviewed by Eric Carlson.
1879
1880         Instead of looking in the map when wanting to get the VideoTrackPrivateMediaStream corresponding to the active video track,
1881         store directly the VideoTrackPrivateMediaStream as the active video track and use streamTrack() to get the corresponding MediaStreamTrack.
1882         Small refactoring to use more Ref<>.
1883         Covered by existing tests.
1884
1885         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
1886         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
1887         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::~MediaPlayerPrivateMediaStreamAVFObjC):
1888         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoSampleAvailable):
1889         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::sampleBufferDisplayLayerStatusDidChange):
1890         (WebCore::updateTracksOfType):
1891         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::checkSelectedVideoTrack):
1892         * platform/mediastream/AudioTrackPrivateMediaStream.h:
1893         * platform/mediastream/VideoTrackPrivateMediaStream.h:
1894
1895 2020-05-24  Youenn Fablet  <youenn@apple.com>
1896
1897         Do not allocate a WebAudioBufferList in the AudioContext rendering thread
1898         https://bugs.webkit.org/show_bug.cgi?id=212132
1899
1900         Reviewed by Eric Carlson.
1901
1902         Instead of allocating the buffer in the rendering thread, we do that in the audio sample producer thread.
1903         Also, we do it only once versus one for each rendering call previously.
1904         Covered by existing tests.
1905
1906         * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h:
1907         * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm:
1908         (WebCore::WebAudioSourceProviderAVFObjC::provideInput):
1909         (WebCore::WebAudioSourceProviderAVFObjC::prepare):
1910         (WebCore::WebAudioSourceProviderAVFObjC::unprepare):
1911
1912 2020-05-24  Wenson Hsieh  <wenson_hsieh@apple.com>
1913
1914         Add some missing includes due to unified sources
1915         https://bugs.webkit.org/show_bug.cgi?id=212306
1916
1917         Reviewed by Anders Carlsson.
1918
1919         * Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp: Include EnterPictureInPictureEvent.h.
1920
1921         * platform/PictureInPictureObserver.h: Include WeakPtr and forward declare the IntSize class.
1922
1923 2020-05-24  Sam Weinig  <weinig@apple.com>
1924
1925         Extended Color Cleanup: Move SimpleColor into its own files
1926         https://bugs.webkit.org/show_bug.cgi?id=212309
1927
1928         Reviewed by Simon Fraser.
1929
1930         Move SimpleColor into its own files. It's about time.
1931
1932         * Headers.cmake:
1933         * Sources.txt:
1934         * WebCore.xcodeproj/project.pbxproj:
1935         * platform/graphics/Color.cpp:
1936         (WebCore::premultipliedChannel): Deleted.
1937         (WebCore::unpremultipliedChannel): Deleted.
1938         (WebCore::makePremultipliedRGBA): Deleted.
1939         (WebCore::makeUnPremultipliedRGBA): Deleted.
1940         (WebCore::colorFloatToRGBAByte): Deleted.
1941         (WebCore::makeRGBA32FromFloats): Deleted.
1942         (WebCore::makeRGBAFromHSLA): Deleted.
1943         (WebCore::makeRGBAFromCMYKA): Deleted.
1944         (WebCore::SimpleColor::serializationForHTML const): Deleted.
1945         (WebCore::decimalDigit): Deleted.
1946         (WebCore::fractionDigitsForFractionalAlphaValue): Deleted.
1947         (WebCore::SimpleColor::serializationForCSS const): Deleted.
1948         (WebCore::RGBA32::serializationForRenderTreeAsText const): Deleted.
1949         * platform/graphics/Color.h:
1950         (WebCore::SimpleColor::SimpleColor): Deleted.
1951         (WebCore::SimpleColor::value const): Deleted.
1952         (WebCore::SimpleColor::redComponent const): Deleted.
1953         (WebCore::SimpleColor::greenComponent const): Deleted.
1954         (WebCore::SimpleColor::blueComponent const): Deleted.
1955         (WebCore::SimpleColor::alphaComponent const): Deleted.
1956         (WebCore::SimpleColor::alphaComponentAsFloat const): Deleted.
1957         (WebCore::SimpleColor::isOpaque const): Deleted.
1958         (WebCore::SimpleColor::isVisible const): Deleted.
1959         (WebCore::SimpleColor::colorWithAlpha const): Deleted.
1960         (WebCore::SimpleColor::get const): Deleted.
1961         (WebCore::roundAndClampColorChannel): Deleted.
1962         (WebCore::fastMultiplyBy255): Deleted.
1963         (WebCore::fastDivideBy255): Deleted.
1964         (WebCore::makeRGB): Deleted.
1965         (WebCore::makeRGBA): Deleted.
1966         * platform/graphics/SimpleColor.cpp: Copied from platform/graphics/Color.cpp.
1967         (WebCore::SimpleColor::serializationForRenderTreeAsText const):
1968         (): Deleted.
1969         (WebCore::colorFloatToRGBAByte): Deleted.
1970         (WebCore::parseHexColorInternal): Deleted.
1971         (WebCore::Color::parseHexColor): Deleted.
1972         (WebCore::differenceSquared): Deleted.
1973         (WebCore::findNamedColor): Deleted.
1974         (WebCore::Color::Color): Deleted.
1975         (WebCore::Color::operator=): Deleted.
1976         (WebCore::Color::serialized const): Deleted.
1977         (WebCore::Color::cssText const): Deleted.
1978         (WebCore::RGBA32::serializationForRenderTreeAsText const): Deleted.
1979         (WebCore::Color::nameForRenderTreeAsText const): Deleted.
1980         (WebCore::Color::light const): Deleted.
1981         (WebCore::Color::dark const): Deleted.
1982         (WebCore::Color::isDark const): Deleted.
1983         (WebCore::Color::lightness const): Deleted.
1984         (WebCore::blendComponent): Deleted.
1985         (WebCore::Color::blend const): Deleted.
1986         (WebCore::Color::blendWithWhite const): Deleted.
1987         (WebCore::Color::colorWithAlphaMultipliedBy const): Deleted.
1988         (WebCore::Color::colorWithAlphaMultipliedByUsingAlternativeRounding const): Deleted.
1989         (WebCore::Color::colorWithAlpha const): Deleted.
1990         (WebCore::Color::colorWithAlphaUsingAlternativeRounding const): Deleted.
1991         (WebCore::Color::colorSpaceAndComponents const): Deleted.
1992         (WebCore::Color::toSRGBASimpleColorLossy const): Deleted.
1993         (WebCore::Color::toSRGBAComponentsLossy const): Deleted.
1994         (WebCore::extendedColorsEqual): Deleted.
1995         (WebCore::blend): Deleted.
1996         (WebCore::blendWithoutPremultiply): Deleted.
1997         (WebCore::Color::tagAsValid): Deleted.
1998         (WebCore::Color::asExtended const): Deleted.
1999         (WebCore::operator<<): Deleted.
2000         * platform/graphics/SimpleColor.h: Copied from platform/graphics/Color.h.
2001         (WebCore::SimpleColor::alphaComponentAsFloat const):
2002         (WebCore::SimpleColor::colorWithAlpha const):
2003         (WebCore::SimpleColor::get const):
2004         (WebCore::colorFloatToRGBAByte):
2005         (WebCore::Color::Color): Deleted.
2006         (WebCore::Color::isHashTableDeletedValue const): Deleted.
2007         (WebCore::Color::~Color): Deleted.
2008         (WebCore::Color::isValid const): Deleted.
2009         (WebCore::Color::isOpaque const): Deleted.
2010         (WebCore::Color::isVisible const): Deleted.
2011         (WebCore::Color::red const): Deleted.
2012         (WebCore::Color::green const): Deleted.
2013         (WebCore::Color::blue const): Deleted.
2014         (WebCore::Color::alpha const): Deleted.
2015         (WebCore::Color::alphaAsFloat const): Deleted.
2016         (WebCore::Color::opaqueColor const): Deleted.
2017         (WebCore::Color::isSemantic const): Deleted.
2018         (WebCore::Color::isExtended const): Deleted.
2019         (WebCore::Color::setRGB): Deleted.
2020         (WebCore::Color::setIsSemantic): Deleted.
2021         (WebCore::equalIgnoringSemanticColor): Deleted.
2022         (WebCore::Color::hash const): Deleted.
2023         (WebCore::Color::colorWithAlphaMultipliedByUsingAlternativeRounding const): Deleted.
2024         (WebCore::Color::colorWithAlphaUsingAlternativeRounding const): Deleted.
2025         (WebCore::Color::rgb const): Deleted.
2026         (WebCore::Color::isBlackColor): Deleted.
2027         (WebCore::Color::isWhiteColor): Deleted.
2028         (WebCore::Color::encode const): Deleted.
2029         (WebCore::Color::decode): Deleted.
2030
2031 2020-05-24  Zalan Bujtas  <zalan@apple.com>
2032
2033         [LFC][TFC] Ignore section borders even when border collapse is off.
2034         https://bugs.webkit.org/show_bug.cgi?id=212336
2035
2036         Reviewed by Antti Koivisto.
2037
2038         Test: fast/layoutformattingcontext/table-simple-thead-border-ignore.html
2039
2040         * layout/Verification.cpp:
2041         (WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded):
2042         * layout/tableformatting/TableFormattingContext.cpp:
2043         (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
2044
2045 2020-05-24  Sam Weinig  <weinig@apple.com>
2046
2047         Extended Color Cleanup: Stop allowing direct access to the underlying SimpleColor (it is almost always incorrect with respect to extended colors)
2048         https://bugs.webkit.org/show_bug.cgi?id=212184
2049
2050         Reviewed by Dean Jackson.
2051
2052         - Makes Color::rgb() private, removing a class of extended color bugs from users 
2053           of the Color class. To get the equivilent functionality, users of the class must
2054           now use toSRGBASimpleColorLossy() which does actually does the conversion to sRGB
2055           if necessary and makes it clear to the caller that precision is being lost. 
2056         - Removes Color::red()/green()/blue() entirely. They were just calling down to 
2057           Color::rgb(), and going forward, it won't make sense to think about rgb components
2058           of Colors in general, since some extended color spaces don't deal in them (e.g. Lab)
2059           Color::alpha() was kept (and fixed to work even with ExtendedColor) since all
2060           ExtendedColors do need to have alpha.
2061
2062         * accessibility/AccessibilityNodeObject.cpp:
2063         (WebCore::AccessibilityNodeObject::colorValue const):
2064         Use toSRGBASimpleColorLossy() to get access to color components.
2065
2066         * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
2067         (getAttributeSetForAccessibilityObject):
2068         Use toSRGBASimpleColorLossy() to get access to color components.
2069
2070         * accessibility/isolatedtree/AXIsolatedObject.cpp:
2071         (WebCore::AXIsolatedObject::colorValue const):
2072         Use toSRGBASimpleColorLossy() to get access to color components.
2073
2074         * css/DeprecatedCSSOMRGBColor.h:
2075         Use toSRGBASimpleColorLossy() to get access to color components.
2076
2077         * page/CaptionUserPreferencesMediaAF.cpp:
2078         (WebCore::CaptionUserPreferencesMediaAF::captionsWindowCSS const):
2079         (WebCore::CaptionUserPreferencesMediaAF::captionsBackgroundCSS const):
2080         (WebCore::CaptionUserPreferencesMediaAF::captionsTextColor const):
2081         User Color::colorWithAlpha() to avoid the need to muck with components directly.
2082
2083         * platform/graphics/Color.cpp:
2084         (WebCore::differenceSquared):
2085         Use rgb() directly, which is ok, since this is explicitly checking isExtended().
2086         This code is still wrong (there is a FIXME) as it assumes the two colors are in
2087         the same color space.
2088
2089         (WebCore::Color::Color):
2090         Add constructor which takes an ExtendedColor to allow functions like 
2091         Color::invertedColorWithAlpha to delegate their functionality to ExtendedColor.
2092         
2093         (WebCore::Color::light const):
2094         Use new SimpleColor::colorWithAlpha() to avoid hardcoding constants here.
2095
2096         (WebCore::Color::blend const):
2097         (WebCore::Color::blendWithWhite const):
2098         Use toSRGBASimpleColorLossy() to get access to color components. These
2099         are still not ideal implementations, as they don't preserve extended colors
2100         as well as they could, but now they don't return bogus values for extended
2101         colors. Minor cleanup bringing constants and lambda inside the function they
2102         are used in.
2103         
2104         (WebCore::Color::colorWithAlpha const):
2105         (WebCore::Color::colorWithAlphaUsingAlternativeRounding const):
2106         Minor cleanups to use a more consistent style and make use of the new
2107         SimpleColor::colorWithAlpha.
2108         
2109         (WebCore::Color::invertedColorWithAlpha const):
2110         Added. Used to avoid direct component usage in line box code.
2111
2112         (WebCore::Color::semanticColor const):
2113         Added. Hopefully temporary. Used by RenderThemeIOS.mm to convert
2114         a Color from a map into a Color with the semantic bit set. This 
2115         should not be necessary as every color in the map should already
2116         have it set, but to avoid uncessary possible behavior changes this
2117         preserves that functionality until it can be researched further.
2118         Fixing coders to preserve the semantic bit may be required to 
2119         elliminate the need.
2120         
2121         (WebCore::Color::colorSpaceAndComponents const):
2122         Use rgb() rather than the individual components which have been removed.
2123         
2124         * platform/graphics/Color.h:
2125         (WebCore::SimpleColor::alphaComponentAsFloat const):
2126         Added. Needed by DeprecatedCSSOMRGBColor and useful to Color.
2127
2128         (WebCore::SimpleColor::colorWithAlpha const):
2129         Useful to simplify Color::colorWithAlpha implementations and
2130         in Color::dark().
2131
2132         (WebCore::SimpleColor::get const):
2133         Added tuple interface to SimpleColor to support structure bindings.
2134         NOTE: Unlike the storage of SimpleColor (ARGB), this produces the
2135         bindings in the more familiar [r,g,b,a] to match FloatComponents.
2136         
2137         (WebCore::Color::alpha const):
2138         Made work with ExtendedColor as well.
2139         
2140         (WebCore::Color::red const): Deleted.
2141         (WebCore::Color::green const): Deleted.
2142         (WebCore::Color::blue const): Deleted.
2143         Removed.
2144
2145         (CGColorRef cachedCGColor): 
2146         (int differenceSquared): 
2147         Made friends so they could use Color::rgb().
2148
2149         (WebCore::Color::rgb const): 
2150         Made private.
2151
2152         * platform/graphics/ExtendedColor.cpp:
2153         (WebCore::ExtendedColor::invertedColorWithAlpha const):
2154         * platform/graphics/ExtendedColor.h:
2155         Added invertedColorWithAlpha to allow inversion to be encapsulated.
2156         When future color spaces are added, we may need to choose per-colorspace
2157         algorithms for this instead of the trivial one used today.
2158
2159         * platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:
2160         (WebCore::PlatformCAAnimationCocoa::setFromValue):
2161         (WebCore::PlatformCAAnimationCocoa::setToValue):
2162         (WebCore::PlatformCAAnimationCocoa::setValues):
2163         Use toSRGBASimpleColorLossy() to get access to color components.
2164
2165         * platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
2166         (PlatformCAAnimationWin::setFromValue):
2167         (PlatformCAAnimationWin::setToValue):
2168         (PlatformCAAnimationWin::setValues):
2169         Use toSRGBASimpleColorLossy() to get access to color components.
2170
2171         * platform/graphics/cairo/CairoOperations.cpp:
2172         (WebCore::Cairo::drawFocusRing):
2173         Use Color::colorWithAlpha() to avoid needing access to components.
2174
2175         * platform/graphics/cpu/arm/filters/FELightingNEON.h:
2176         (WebCore::FELighting::platformApplyNeon):
2177         Use toSRGBASimpleColorLossy() to get access to color components.
2178
2179         * platform/graphics/texmap/TextureMapperGL.cpp:
2180         (WebCore::TextureMapperGL::clearColor):
2181         Use toSRGBASimpleColorLossy() to get access to color components.
2182
2183         * platform/graphics/win/Direct2DOperations.cpp:
2184         (WebCore::Direct2D::drawGlyphs):
2185         Use colorWithAlphaMultipliedBy() to avoid needing access to components.
2186
2187         * platform/graphics/win/FontCGWin.cpp:
2188         (WebCore::FontCascade::drawGlyphs):
2189         Use colorWithAlphaMultipliedBy() to avoid needing access to components.
2190
2191         * platform/graphics/win/FontCascadeDirect2D.cpp:
2192         (WebCore::FontCascade::drawGlyphs):
2193         Use colorWithAlphaMultipliedBy() to avoid needing access to components.
2194
2195         * rendering/EllipsisBox.cpp:
2196         (WebCore::EllipsisBox::paintSelection):
2197         Use invertedColorWithAlpha() to avoid needing access to components.
2198
2199         * rendering/InlineTextBox.cpp:
2200         (WebCore::InlineTextBox::resolveStyleForMarkedText):
2201         Use invertedColorWithAlpha() to avoid needing access to components.
2202
2203         * rendering/RenderBoxModelObject.cpp:
2204         (WebCore::RenderBoxModelObject::paintBoxShadow):
2205         Use opaqueColor() to avoid needing access to components.
2206
2207         * rendering/RenderThemeIOS.mm:
2208         (WebCore::RenderThemeIOS::systemColor const):
2209         Use opaqueColor() to avoid needing access to components.
2210
2211         * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h:
2212         (WebCore::SVGAnimationColorFunction::animate):
2213         Use toSRGBASimpleColorLossy() to get access to color components.
2214
2215 2020-05-24  Zalan Bujtas  <zalan@apple.com>
2216
2217         [LFC][TFC] Take sections into account when computing collapsed border.
2218         https://bugs.webkit.org/show_bug.cgi?id=212311
2219
2220         Reviewed by Antti Koivisto.
2221
2222         Test: fast/layoutformattingcontext/table-simple-collapsed-tbody-border.html
2223
2224         * layout/Verification.cpp:
2225         (WebCore::Layout::LayoutContext::verifyAndOutputMismatchingLayoutTree):
2226         * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
2227         (WebCore::Layout::TableWrapperBlockFormattingContext::computeBorderAndPaddingForTableBox):
2228         * layout/tableformatting/TableFormattingContext.cpp:
2229         (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
2230         * layout/tableformatting/TableGrid.cpp:
2231         (WebCore::Layout::TableGrid::Section::Section):
2232         (WebCore::Layout::TableGrid::appendCell):
2233         * layout/tableformatting/TableGrid.h:
2234         (WebCore::Layout::TableGrid::Section::box const):
2235         (WebCore::Layout::TableGrid::sections const):
2236         (WebCore::Layout::TableGrid::sections):
2237
2238 2020-05-24  Zalan Bujtas  <zalan@apple.com>
2239
2240         [LFC][TFC] Take collapsed in-between row border into account when computing cell height
2241         https://bugs.webkit.org/show_bug.cgi?id=212307
2242
2243         Reviewed by Antti Koivisto.
2244
2245         Test: fast/layoutformattingcontext/table-simple-collapsed-row-border2.html
2246
2247         * layout/tableformatting/TableFormattingContextGeometry.cpp:
2248         (WebCore::Layout::TableFormattingContext::Geometry::computedCellBorder const):
2249
2250 2020-05-23  Zalan Bujtas  <zalan@apple.com>
2251
2252         [LFC][TFC] Take row border into account when computing collapsed borders.
2253         https://bugs.webkit.org/show_bug.cgi?id=212305
2254
2255         Reviewed by Antti Koivisto.
2256
2257         Test: fast/layoutformattingcontext/table-simple-collapsed-row-border.html
2258
2259         * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
2260         (WebCore::Layout::TableWrapperBlockFormattingContext::computeBorderAndPaddingForTableBox):
2261
2262 2020-05-23  Jack Lee  <shihchieh_lee@apple.com>
2263
2264         ASSERTION FAILED: (!s_current || &m_view != &s_current->m_view) in RenderTreeBuilder::RenderTreeBuilder
2265         https://bugs.webkit.org/show_bug.cgi?id=212163
2266
2267         Unreviewed. Improve readability. Replace comments with curly brackets for scoping.
2268
2269         * dom/Document.cpp:
2270         (WebCore::Document::updateRenderTree):
2271
2272 2020-05-23  Zalan Bujtas  <zalan@apple.com>
2273
2274         [LFC][TFC] Maximum constraint of a cell should never be smaller than the minimum width
2275         https://bugs.webkit.org/show_bug.cgi?id=212304
2276
2277         Reviewed by Antti Koivisto.
2278
2279         Test: fast/layoutformattingcontext/table-simple-fixed-width-with-wide-content.html
2280
2281         * layout/tableformatting/TableFormattingContextGeometry.cpp:
2282         (WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):
2283
2284 2020-05-23  Zalan Bujtas  <zalan@apple.com>
2285
2286         [LFC][TFC] Used height of a cell is the maximum of the computed and the content height.
2287         https://bugs.webkit.org/show_bug.cgi?id=212302
2288
2289         Reviewed by Antti Koivisto.
2290
2291         Test: fast/layoutformattingcontext/table-simple-tall-cell-content-with-fixed-height.html
2292
2293         * layout/FormattingContextGeometry.cpp:
2294         (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
2295         * layout/tableformatting/TableFormattingContextGeometry.cpp:
2296         (WebCore::Layout::TableFormattingContext::Geometry::cellHeigh const):
2297
2298 2020-05-23  Zalan Bujtas  <zalan@apple.com>
2299
2300         [LFC][TFC] Non-collapsing row border should not make the table wider/taller
2301         https://bugs.webkit.org/show_bug.cgi?id=212263
2302
2303         Reviewed by Antti Koivisto.
2304
2305         Non-collapsing row border eats into the content box but oddly it does not
2306         constraint the cell boxes, so we can end up with smaller row content box than
2307         the cell box it contains.
2308
2309         Test: fast/layoutformattingcontext/table-simple-row-border.html
2310
2311         * layout/LayoutUnits.h:
2312         (WebCore::Layout::Edges::width const):
2313         (WebCore::Layout::Edges::height const):
2314         (WebCore::Layout::HorizontalEdges::width const): Deleted.
2315         (WebCore::Layout::VerticalEdges::height const): Deleted.
2316         * layout/tableformatting/TableFormattingContext.cpp:
2317         (WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
2318         * layout/tableformatting/TableFormattingContextGeometry.cpp:
2319         (WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):
2320
2321 2020-05-22  Jack Lee  <shihchieh_lee@apple.com>
2322
2323         ASSERTION FAILED: (!s_current || &m_view != &s_current->m_view) in RenderTreeBuilder::RenderTreeBuilder
2324         https://bugs.webkit.org/show_bug.cgi?id=212163
2325         <rdar://problem/57028096>
2326
2327         Reviewed by Geoffrey Garen.
2328
2329         Calling ~PostResolutionCallbackDisabler() before completing render tree updating and releasing RenderTreeBuilder 
2330         triggers this assertion. Therefore we added a utility function "updateRenderTree" in which PostResolutionCallback
2331         is delayed until RenderTreeUpdater is released and m_inRenderTreeUpdate is cleared.
2332
2333         Test: fast/rendering/nested-render-tree-update-crash.html
2334
2335         * Headers.cmake:
2336         * WebCore.xcodeproj/project.pbxproj:
2337         * dom/Document.cpp:
2338         (WebCore::Document::updateRenderTree):
2339         (WebCore::Document::resolveStyle):
2340         (WebCore::Document::updateTextRenderer):
2341         * dom/Document.h:
2342         * rendering/updating/RenderTreeUpdater.cpp:
2343         (WebCore::RenderTreeUpdater::RenderTreeUpdater):
2344         (WebCore::RenderTreeUpdater::commit):
2345         * rendering/updating/RenderTreeUpdater.h:
2346
2347 2020-05-22  Simon Fraser  <simon.fraser@apple.com>
2348
2349         Stuttery overflow scrolling in slow-scrolling regions (facebook messenger, feedly.com)
2350         https://bugs.webkit.org/show_bug.cgi?id=212291
2351         <rdar://problem/61940624>
2352
2353         Reviewed by Tim Horton.
2354
2355         Now that we do scrolling tree commits on the main thread, ThreadedScrollingTree::scrollingTreeNodeDidScroll()
2356         can be called on the main thread. In this case, don't do an RunLoop::main().dispatch() which introduces
2357         asynchrony; just call into the ScrollingCoordinator synchronously.
2358
2359         Do some minor refactoring to move noteScrollingThreadSyncCompleteForNode() into updateScrollPositionAfterAsyncScroll().
2360
2361         Hard to test because it involves scrolling thread/main thread interactions.
2362
2363         * page/scrolling/AsyncScrollingCoordinator.cpp:
2364         (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
2365         (WebCore::AsyncScrollingCoordinator::synchronizeStateFromScrollingTree):
2366         (WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll):
2367         (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired):
2368         (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
2369         * page/scrolling/AsyncScrollingCoordinator.h:
2370         * page/scrolling/ThreadedScrollingTree.cpp:
2371         (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
2372
2373 2020-05-22  Zalan Bujtas  <zalan@apple.com>
2374
2375         Nullptr deref in WebCore::RenderTreeBuilder::Block::attachIgnoringContinuation when parent and beforeChild are siblings
2376         https://bugs.webkit.org/show_bug.cgi?id=212116
2377         <rdar://problem/62993844>
2378
2379         Reviewed by Simon Fraser.
2380
2381         This patch fixes the case when a nested fragmented context has a spanner and we try to form a continuation while this nested fragmented context is being destroyed.
2382
2383         1. The continuation is triggered by a style change that turns a previously out-of-flow block container into an inflow box
2384         (and the parent inline level container can't have the box as a direct child anymore).
2385         2. An unrelated style change nukes the nested fragmented context. We need to "re-assign" the spanner to the parent fragment.
2386
2387         These 2 changes are split into 2 phases; first we take care of the tree mutation triggered by the continuation (updateRendererStyle), while
2388         we do the fragmented context cleanup (updateAfterDescendants) in a separate step.
2389         This 2 phase setup confuses the "where to put this spanner" logic.
2390
2391         This patch addresses the issue by keeping the spanner inside the about-to-be-destroyed fragmented context while forming the continuation (phase #1) and let the second phase (updateAfterDescendants)
2392         deal with the spanner moving.
2393
2394         Test: fast/multicol/nested-multicol-with-spanner-and-continuation.html
2395
2396         * rendering/updating/RenderTreeBuilderMultiColumn.cpp:
2397         (WebCore::isValidColumnSpanner):
2398
2399 2020-05-22  Chris Dumez  <cdumez@apple.com>
2400
2401         Revoking an object URL immediately after triggering navigation causes navigation to fail
2402         https://bugs.webkit.org/show_bug.cgi?id=212279
2403         <rdar://problem/63553090>
2404
2405         Reviewed by Geoffrey Garen.
2406
2407         When doing a policy check for a Blob URL, we clone the blob and create a new temporary Blob URL
2408         that stays alive for the duration of the policy check. We made sure to update the ResourceRequest
2409         URL with the new Blob URL, however, we were failing to update the DocumentLoader's request.
2410         As a result, if the client responded with Policy USE, the DocumentLoader would still attempt to
2411         navigate to the old Blob URL.
2412
2413         Test: fast/loader/revoke-blob-url-after-navigation.html
2414
2415         * loader/PolicyChecker.cpp:
2416         (WebCore::FrameLoader::PolicyChecker::extendBlobURLLifetimeIfNecessary const):
2417         (WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy):
2418         (WebCore::FrameLoader::PolicyChecker::checkNewWindowPolicy):
2419         * loader/PolicyChecker.h:
2420
2421 2020-05-22  Simon Fraser  <simon.fraser@apple.com>
2422
2423         Make sure we clean up CFTimerRefs when destroying scrolling tree nodes
2424         https://bugs.webkit.org/show_bug.cgi?id=212278
2425         <rdar://problem/63548212>
2426
2427         Reviewed by Tim Horton.
2428
2429         When destroying scrolling tree nodes, make sure we explicitly stop the RunLoop::Timers,
2430         and do this for all nodes when clearing the m_nodeMap, not just for orphaned nodes as
2431         was done in r262042.
2432
2433         * page/scrolling/ScrollingTree.cpp:
2434         (WebCore::ScrollingTree::commitTreeState):
2435         (WebCore::ScrollingTree::updateTreeFromStateNodeRecursive):
2436         (WebCore::ScrollingTree::removeAllNodes):
2437         * page/scrolling/ScrollingTree.h:
2438         * page/scrolling/ScrollingTreeNode.h:
2439         (WebCore::ScrollingTreeNode::willBeDestroyed):
2440         (WebCore::ScrollingTreeNode::wasRemovedFromTree): Deleted.
2441         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
2442         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
2443         (WebCore::ScrollingTreeFrameScrollingNodeMac::willBeDestroyed):
2444         (WebCore::ScrollingTreeFrameScrollingNodeMac::wasRemovedFromTree): Deleted.
2445         * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h:
2446         * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
2447         (WebCore::ScrollingTreeOverflowScrollingNodeMac::willBeDestroyed):
2448         (WebCore::ScrollingTreeOverflowScrollingNodeMac::wasRemovedFromTree): Deleted.
2449
2450 2020-05-22  Andres Gonzalez  <andresg_22@apple.com>
2451
2452         Updates to the isolated tree must happen before posting notifications to clients.
2453         https://bugs.webkit.org/show_bug.cgi?id=212266
2454
2455         Reviewed by Chris Fleizach.
2456
2457         Multiple tests.
2458
2459         In AXObjectCache::notificationPostTimerFired we were updating the
2460         isolated tree after the notifications were posted to the platform
2461         clients. This caused that in some cases when the client requested info
2462         as the result of those notifications, the isolated tree was out-of-date.
2463         In this patch updateIsolatedTree is called before notifying platform clients.
2464
2465         * accessibility/AXObjectCache.cpp:
2466         (WebCore::AXObjectCache::notificationPostTimerFired):
2467         (WebCore::AXObjectCache::postNotification):
2468         (WebCore::AXObjectCache::postTextStateChangeNotification):
2469         (WebCore::AXObjectCache::updateIsolatedTree):
2470
2471 2020-05-22  Sam Weinig  <weinig@apple.com>
2472
2473         Extended Color Cleanup: Make alpha premultiplication code more consistent and clear regarding what works with extended colors
2474         https://bugs.webkit.org/show_bug.cgi?id=212265
2475
2476         Reviewed by Simon Fraser.
2477
2478         - Adds premultiplied(const FloatComponents&) to do premutiplication directly on FloatComponents
2479           rather than doing it on the ints and losing precision.
2480         - Makes non-FloatComponent alpha premultiplication all take place only for SimpleColors as that
2481           is what callers need. The existing premulitplication for ExtendedColors in blend() was incorrect
2482           as it never did a conversion to sRGB.
2483         - Adds new toSRGBASimpleColorLossy() (to complement toSRGBAComponentsLossy()). Will make it easy
2484           to find all the conversions in the future.
2485         - Broke non-premultiplying blend() out of blend() (removing parameter) and made a new blendWithoutPremultiply()
2486           function for it (no callers needed to make this decision dynamically).
2487
2488         * css/CSSGradientValue.cpp:
2489         (WebCore::CSSGradientValue::computeStops):
2490         Use blendWithoutPremultiply() explicitly.
2491
2492         * platform/graphics/Color.h:
2493         * platform/graphics/Color.cpp:
2494         (WebCore::makePremultipliedRGBA): Renamed from premultipliedARGBFromColor and now only operates on SimpleColors.
2495         (WebCore::makeUnPremultipliedRGBA): Renamed from colorFromPremultipliedARGB and now only operates on SimpleColors.
2496         (WebCore::colorFromPremultipliedARGB): Deleted.
2497         (WebCore::premultipliedARGBFromColor): Deleted.
2498
2499         (WebCore::Color::toSRGBASimpleColorLossy const):
2500         Added. Useful for finding all non-colorspace preserving users of the color channels. 
2501
2502         (WebCore::blend):
2503         (WebCore::blendWithoutPremultiply):
2504         Split these out from each other. Made blend() use toSRGBASimpleColorLossy() and do all
2505         operations on SimpleColors directly. The old code that preported to work with extended
2506         colors was nonsense as it didn't actually take the colorspaces into account, just grabbed
2507         the channels regardless of space.  
2508         
2509         * platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp:
2510         (WebCore::ImageBufferCairoImageSurfaceBackend::platformTransformColorSpace):
2511         Adopt update premulitiplication names and stay in SimpleColor for entire conversion.
2512
2513         * platform/graphics/cairo/NativeImageCairo.cpp:
2514         (WebCore::nativeImageSinglePixelSolidColor):
2515         Adopt update premulitiplication names.
2516
2517         * platform/graphics/ColorUtilities.cpp:
2518         (WebCore::premultiplied):
2519         * platform/graphics/ColorUtilities.h:
2520         * platform/graphics/texmap/TextureMapperGL.cpp:
2521         (WebCore::TextureMapperGL::drawBorder):
2522         (WebCore::prepareFilterProgram):
2523         (WebCore::TextureMapperGL::drawSolidColor):
2524         Add and adopt premultiplied(const FloatComponents&).
2525
2526 2020-05-22  Andy Estes  <aestes@apple.com>
2527
2528         [Apple Pay] Add new ApplePayInstallmentConfiguration members
2529         https://bugs.webkit.org/show_bug.cgi?id=212160
2530         <rdar://problem/60703650>
2531
2532         Reviewed by Alex Christensen.
2533
2534         Test: http/tests/ssl/applepay/ApplePayInstallmentItems.https.html
2535
2536         * DerivedSources-input.xcfilelist:
2537         * DerivedSources-output.xcfilelist:
2538         * DerivedSources.make:
2539         * SourcesCocoa.txt:
2540         * WebCore.xcodeproj/project.pbxproj: Added IDLs, headers, and derived sources for
2541         ApplePayInstallment{Item,ItemType,RetailChannel}.
2542
2543         * Modules/applepay/ApplePayInstallmentConfiguration.idl:
2544         * Modules/applepay/ApplePayInstallmentConfigurationWebCore.h: Added items,
2545         applicationMetadata, and retailChannel members. Added missing conditionals to
2546         merchantIdentifier and referrerIdentifier.
2547
2548         * Modules/applepay/ApplePayInstallmentItem.h:
2549         * Modules/applepay/ApplePayInstallmentItem.idl:
2550         * Modules/applepay/ApplePayInstallmentItemType.h:
2551         * Modules/applepay/ApplePayInstallmentItemType.idl:
2552         * Modules/applepay/ApplePayInstallmentRetailChannel.h:
2553         * Modules/applepay/ApplePayInstallmentRetailChannel.idl: Added.
2554
2555         * Modules/applepay/ApplePayRequestBase.cpp:
2556         (WebCore::convertAndValidate): Changed to call PaymentInstallmentConfiguration::create,
2557         returning an exception if present.
2558
2559         * Modules/applepay/PaymentInstallmentConfiguration.mm:
2560         (WebCore::fromDecimalNumber): Allowed for a large maximum number of fractional digits to
2561         support formatting high-precision currency and APRs (note that this formatter is only used
2562         for test support).
2563
2564         (WebCore::applePayItemType):
2565         (WebCore::platformItemType): Added to convert between PKInstallmentItemType and
2566         ApplePayInstallmentItemType.
2567
2568         (WebCore::applePayRetailChannel):
2569         (WebCore::platformRetailChannel): Added to convert between PKInstallmentRetailChannel and
2570         ApplePayInstallmentRetailChannel.
2571
2572         (WebCore::makeNSArrayElement):
2573         (WebCore::makeVectorElement): Added to convert between NSArray<PKPaymentInstallmentItem *>
2574         and Vector<ApplePayInstallmentItem>.
2575
2576         (WebCore::createPlatformConfiguration): Added a parameter for passing in applicationMetadata
2577         as an NSDictionary. Set properties on PKPaymentInstallmentConfiguration for new
2578         ApplePayInstallmentConfiguration members.
2579         (WebCore::PaymentInstallmentConfiguration::create): Added; converts the applicationMetadata
2580         JSON string (if present) to an NSDictionary, returning a TypeError if the JSON string does
2581         not deserialize to an NSDictionary (as PassKit requires).
2582         (WebCore::PaymentInstallmentConfiguration::PaymentInstallmentConfiguration): Added a
2583         parameter for passing in applicationMetadata as an NSDictionary. Made private.
2584         (WebCore::PaymentInstallmentConfiguration::applePayInstallmentConfiguration const): Set
2585         members on ApplePayInstallmentConfiguration for new PKPaymentInstallmentConfiguration
2586         properties.
2587
2588         * Modules/applepay/PaymentInstallmentConfigurationWebCore.h:
2589
2590 2020-05-22  Alex Christensen  <achristensen@webkit.org>
2591
2592         Add SPI to unblock third party cookies from WKWebViews with ResourceLoadStatistics turned on
2593         https://bugs.webkit.org/show_bug.cgi?id=212058
2594         <rdar://problem/60595539>
2595
2596         Reviewed by John Wilander.
2597
2598         * WebCore.xcodeproj/project.pbxproj:
2599         * loader/CookieJar.cpp:
2600         (WebCore::shouldRelaxThirdPartyCookieBlocking):
2601         (WebCore::CookieJar::cookies const):
2602         (WebCore::CookieJar::setCookies):
2603         (WebCore::CookieJar::cookieRequestHeaderFieldValue const):
2604         (WebCore::CookieJar::getRawCookies const):
2605         * page/Page.cpp:
2606         (WebCore::m_shouldRelaxThirdPartyCookieBlocking):
2607         * page/Page.h:
2608         (WebCore::Page::shouldRelaxThirdPartyCookieBlocking const):
2609         * page/PageConfiguration.h:
2610         * platform/network/CacheValidation.cpp:
2611         (WebCore::cookieRequestHeaderFieldValue):
2612         * platform/network/NetworkStorageSession.cpp:
2613         (WebCore::NetworkStorageSession::shouldBlockCookies const):
2614         (WebCore::NetworkStorageSession::maxAgeCacheCap):
2615         * platform/network/NetworkStorageSession.h:
2616         * platform/network/ShouldRelaxThirdPartyCookieBlocking.h: Added.
2617         * platform/network/cf/NetworkStorageSessionCFNetWin.cpp:
2618         (WebCore::NetworkStorageSession::setCookiesFromDOM const):
2619         (WebCore::NetworkStorageSession::cookiesForDOM const):
2620         (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const):
2621         (WebCore::NetworkStorageSession::getRawCookies const):
2622         * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
2623         (WebCore::NetworkStorageSession::cookiesForURL const):
2624         (WebCore::NetworkStorageSession::cookiesForSession const):
2625         (WebCore::NetworkStorageSession::cookiesForDOM const):
2626         (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const):
2627         (WebCore::NetworkStorageSession::setCookiesFromDOM const):
2628         (WebCore::NetworkStorageSession::getRawCookies const):
2629         * platform/network/curl/NetworkStorageSessionCurl.cpp:
2630         (WebCore::NetworkStorageSession::setCookiesFromDOM const):
2631         (WebCore::NetworkStorageSession::cookiesForDOM const):
2632         (WebCore::NetworkStorageSession::getRawCookies const):
2633         (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const):
2634         * platform/network/curl/ResourceHandleCurl.cpp:
2635         (WebCore::ResourceHandle::createCurlRequest):
2636         * platform/network/soup/NetworkStorageSessionSoup.cpp:
2637         (WebCore::NetworkStorageSession::setCookiesFromDOM const):
2638         (WebCore::NetworkStorageSession::getRawCookies const):
2639         (WebCore::cookiesForSession):
2640         (WebCore::NetworkStorageSession::cookiesForDOM const):
2641         (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const):
2642
2643 2020-05-22  Oriol Brufau  <obrufau@igalia.com>
2644
2645         Don't put out-of-flow boxes in anonymous flex/grid items
2646         https://bugs.webkit.org/show_bug.cgi?id=205386
2647
2648         Reviewed by Manuel Rego Casasnovas.
2649
2650         A single anonymous flex/grid item should just contain a contiguous
2651         sequence of text runs.
2652
2653         This patch is based on https://crrev.com/533825 from Chromium.
2654
2655         Tests: imported/w3c/web-platform-tests/css/css-flexbox/anonymous-flex-item-004.html
2656                imported/w3c/web-platform-tests/css/css-grid/grid-items/anonymous-grid-item-001.html
2657
2658         * rendering/updating/RenderTreeBuilderBlock.cpp:
2659         (WebCore::RenderTreeBuilder::Block::attachIgnoringContinuation):
2660
2661 2020-05-22  Tim Horton  <timothy_horton@apple.com>
2662
2663         iOS: Pressing tab in the Mail subject field moves focus to the body, but pressing shift tab doesn't move it back
2664         https://bugs.webkit.org/show_bug.cgi?id=212243
2665         <rdar://problem/59127764>
2666
2667         Reviewed by Wenson Hsieh.
2668
2669         New API Tests: WebKit.ShiftTabTakesFocusFromEditableWebView and WebKit.TabDoesNotTakeFocusFromEditableWebView
2670
2671         * page/FocusController.cpp:
2672         (WebCore::FocusController::relinquishFocusToChrome):
2673         (WebCore::FocusController::advanceFocusInDocumentOrder):
2674         * page/FocusController.h:
2675         Factor out the code that decides whether the Chrome might accept focus,
2676         and transfers focus out to the Chrome, for use in EventHandler.
2677
2678         * page/EventHandler.cpp:
2679         (WebCore::EventHandler::defaultTabEventHandler):
2680         In the case where we are shift-tabbing out of an editable web view,
2681         allow focus to pass to the Chrome. Previously, we would not allow this,
2682         because tabKeyCyclesThroughElements is false in editable web views.
2683         However, focus exiting the web view entirely needn't be covered by
2684         "cycles through elements" behavior.
2685         We can't do this for plain "tab", because that needs to be allowed to
2686         insert a tab character instead.
2687
2688 2020-05-22  Tyler Wilcock  <twilco.o@protonmail.com>
2689
2690         Cannot style ::selection for a flex container
2691         https://bugs.webkit.org/show_bug.cgi?id=209822
2692
2693         Reviewed by Antti Koivisto.
2694
2695         When needing to query for pseudostyles, RenderText used to unconditionally check the parent's pseudostyles.  The parent of
2696         RenderText objects is often an anonymous box, depending on the presence of siblings, `display` type, etc.  This is problematic
2697         as pseudostyles are associated with an element of the DOM, meaning RenderText elements would often fail to find any pseudostyle
2698         thanks to their anonymous parent.
2699
2700         This patch changes RenderText to traverse its tree of ancestry upwards until it finds a non-anonymous ancestor and gets those pseudostyles,
2701         rather than unconditionally trying to get pseudostyles from its direct parent.
2702
2703         Blink does something similar when retrieving pseudostyles:
2704
2705         https://github.com/chromium/chromium/blob/793cb59c18334f8b506863192bf630776da0f4d2/third_party/blink/renderer/core/paint/selection_painting_utils.cc#L54
2706
2707         Tests: editing/selection/selection-display-block-sibling.html
2708                editing/selection/selection-display-flex.html
2709
2710         * rendering/RenderObject.cpp:
2711         (WebCore::RenderObject::firstNonAnonymousAncestor const):
2712         * rendering/RenderObject.h:
2713         * rendering/RenderText.h:
2714         (WebCore::RenderText::getCachedPseudoStyle const): getCachedPseudoStyle from first non-anonymous ancestor, rather than only checking the direct parent.
2715         (WebCore::RenderText::selectionBackgroundColor const): Retrieve selectionBackgroundColor from first non-anonymous ancestor rather than only checking the direct parent.
2716         (WebCore::RenderText::selectionForegroundColor const): Retrieve selectionForegroundColor from first non-anonymous ancestor rather than only checking the direct parent.
2717         (WebCore::RenderText::selectionEmphasisMarkColor const): Retrieve selectionEmphasisMarkColor from first non-anonymous ancestor rather than only checking the direct parent.
2718         (WebCore::RenderText::selectionPseudoStyle const): Retrieve selectionPseudoStyle from first non-anonymous ancestor rather than only checking the direct parent.
2719
2720 2020-05-21  Wenson Hsieh  <wenson_hsieh@apple.com>
2721
2722         DataTransfer.files contains multiple files when pasting a single image with multiple representations
2723         https://bugs.webkit.org/show_bug.cgi?id=212245
2724         <rdar://problem/60240436>
2725
2726         Reviewed by Tim Horton.
2727
2728         When pasting or dropping a single image that is backed by multiple representations in NSPasteboard (or
2729         UIPasteboard), we currently report more than one `File` to the page via `DataTransfer.files`. This is because
2730         `Pasteboard::read(PasteboardFileReader&)`, which is responsible for converting the contents of the pasteboard
2731         into a list of files, currently iterates over every pasteboard type and adds each of them as a file. This is
2732         wrong when an item has multiple type representations.
2733
2734         To differentiate the case where a single item has multiple representations from the case where it has multiple
2735         pasteboard items, we use `allPasteboardItemInfo()` instead to grab a per-item list of types from the pasteboard
2736         on Cocoa platforms, and only create at most 1 file per item using the highest fidelity type that contains data.
2737
2738         Test: PasteImage.PasteImageWithMultipleRepresentations
2739
2740         * platform/cocoa/PasteboardCocoa.mm:
2741         (WebCore::Pasteboard::read):
2742
2743 2020-05-21  Simon Fraser  <simon.fraser@apple.com>
2744
2745         Fix rare scrolling thread crash firing the m_delayedRenderingUpdateDetectionTimer timer
2746         https://bugs.webkit.org/show_bug.cgi?id=212250
2747
2748         Reviewed by Tim Horton.
2749
2750         It seems that we can fire the m_delayedRenderingUpdateDetectionTimer timer after the
2751         ScrollingTree has been destroyed (possibly because it's destroyed on another thread
2752         and CFRunLoopTimerRef isn't threadsafe), so explicitly clear the timer in invalidate()
2753         while holding m_treeMutex.
2754
2755         * page/scrolling/ThreadedScrollingTree.cpp:
2756         (WebCore::ThreadedScrollingTree::invalidate):
2757
2758 2020-05-21  Sam Weinig  <weinig@apple.com>
2759
2760         Extended Color Cleanup: Move Color coder definitions to Color to allow for future encaspulation improvements
2761         https://bugs.webkit.org/show_bug.cgi?id=212247
2762
2763         Reviewed by Simon Fraser.
2764
2765         Move IPC encoder/decoder definitions from WebKit down into Color itself to move closer
2766         to making Color::rgb() private.
2767
2768         * platform/graphics/Color.h:
2769         (WebCore::Color::encode const):
2770         (WebCore::Color::decode):
2771
2772 2020-05-21  Simon Fraser  <simon.fraser@apple.com>
2773
2774         Scrolling thread scrolls on sync-scrolling scrollers don't get to the main thread
2775         https://bugs.webkit.org/show_bug.cgi?id=212225
2776
2777         Fix builds that use Nicosia after r262041.
2778
2779         * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp:
2780         (WebCore::ScrollingTreeFrameScrollingNodeNicosia::currentScrollPositionChanged):
2781         * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h:
2782
2783 2020-05-21  Simon Fraser  <simon.fraser@apple.com>
2784
2785         Fix some thread safety issues with ScrollController timers
2786         https://bugs.webkit.org/show_bug.cgi?id=212238
2787
2788         Reviewed by Wenson Hsieh.
2789
2790         There were some problems with the timers fired by ScrollController, used for rubber-banding
2791         and scroll snap.
2792
2793         First, they could fire on the main thread when we intended them to fire on the scrolling thread.
2794         This happened because in r260716 I made the scrolling tree commit on the main thread, so we'd
2795         construct the ScrollingTreeScrollingNodeDelegateMac and its ScrollController there and its
2796         timers would grab the main thread runloop. Fix by creating the timers on demand.
2797
2798         Secondly, the timer callbacks called into scrolling tree code, but without taking
2799         the scrolling tree lock,
2800         and without any guarantee that the node would stay alive for the duration of the callback.
2801         Fix by having the ScrollControllerClient create the timers, allowing the client to have
2802         a callback wrapper that locks, and to ensure object lifetime (or make a weak ref). Now
2803         that scrolling tree nodes could be extended by a pending timer, we need to explicitly
2804         clear the timers when nodes are removed from the tree.
2805
2806         Finally, rename some confusingly named ScrollControllerClient functions.
2807
2808         * page/scrolling/ScrollingTree.cpp:
2809         (WebCore::ScrollingTree::commitTreeState):
2810         * page/scrolling/ScrollingTree.h:
2811         (WebCore::ScrollingTree::treeMutex):
2812         * page/scrolling/ScrollingTreeNode.h:
2813         (WebCore::ScrollingTreeNode::wasBeRemovedFromTree):
2814         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
2815         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
2816         (WebCore::ScrollingTreeFrameScrollingNodeMac::wasBeRemovedFromTree):
2817         * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h:
2818         * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
2819         (WebCore::ScrollingTreeOverflowScrollingNodeMac::wasBeRemovedFromTree):
2820         * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h:
2821         * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
2822         (WebCore::ScrollingTreeScrollingNodeDelegateMac::nodeWillBeDestroyed):
2823         (WebCore::ScrollingTreeScrollingNodeDelegateMac::createTimer):
2824         (WebCore::ScrollingTreeScrollingNodeDelegateMac::didStopRubberbandSnapAnimation):
2825         (WebCore::ScrollingTreeScrollingNodeDelegateMac::willStartScrollSnapAnimation):
2826         (WebCore::ScrollingTreeScrollingNodeDelegateMac::didStopScrollSnapAnimation):
2827         (WebCore::ScrollingTreeScrollingNodeDelegateMac::stopSnapRubberbandTimer): Deleted.
2828         (WebCore::ScrollingTreeScrollingNodeDelegateMac::startScrollSnapTimer): Deleted.
2829         (WebCore::ScrollingTreeScrollingNodeDelegateMac::stopScrollSnapTimer): Deleted.
2830         * platform/ScrollAnimator.cpp:
2831         (WebCore::ScrollAnimator::createTimer):
2832         * platform/ScrollAnimator.h:
2833         * platform/cocoa/ScrollController.h:
2834         (WebCore::ScrollControllerTimer::ScrollControllerTimer):
2835         (WebCore::ScrollControllerClient::willStartRubberBandSnapAnimation):
2836         (WebCore::ScrollControllerClient::didStopRubberbandSnapAnimation):
2837         (WebCore::ScrollControllerClient::willStartScrollSnapAnimation):
2838         (WebCore::ScrollControllerClient::didStopScrollSnapAnimation):
2839         (WebCore::ScrollControllerClient::startSnapRubberbandTimer): Deleted.
2840         (WebCore::ScrollControllerClient::stopSnapRubberbandTimer): Deleted.
2841         (WebCore::ScrollControllerClient::startScrollSnapTimer): Deleted.
2842         (WebCore::ScrollControllerClient::stopScrollSnapTimer): Deleted.
2843         * platform/cocoa/ScrollController.mm:
2844         (WebCore::ScrollController::ScrollController):
2845         (WebCore::ScrollController::stopAllTimers):
2846         (WebCore::ScrollController::handleWheelEvent):
2847         (WebCore::ScrollController::snapRubberBandTimerFired):
2848         (WebCore::ScrollController::isRubberBandInProgress const):
2849         (WebCore::ScrollController::isScrollSnapInProgress const):
2850         (WebCore::ScrollController::startSnapRubberbandTimer):
2851         (WebCore::ScrollController::stopSnapRubberbandTimer):
2852         (WebCore::ScrollController::snapRubberBand):
2853         (WebCore::ScrollController::scheduleStatelessScrollSnap):
2854         (WebCore::ScrollController::statelessSnapTransitionTimerFired):
2855         (WebCore::ScrollController::startScrollSnapTimer):
2856         (WebCore::ScrollController::stopScrollSnapTimer):
2857         * platform/mac/ScrollAnimatorMac.h:
2858
2859 2020-05-21  Simon Fraser  <simon.fraser@apple.com>
2860
2861         Scrolling thread scrolls on sync-scrolling scrollers don't get to the main thread
2862         https://bugs.webkit.org/show_bug.cgi?id=212225
2863
2864         Reviewed by Tim Horton.
2865
2866         Some scrolls on nodes with synchronousScrollingReasons failed to set the m_scrolledSinceLastCommit bit,
2867         because ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged() bypassed a call to the superclass.
2868
2869         Fix by passing ScrollingLayerPositionAction so that it can just call super.
2870
2871         This will be tested by existing tests after some upcoming scroll snap changes.
2872
2873         * page/scrolling/ScrollingTreeScrollingNode.cpp:
2874         (WebCore::ScrollingTreeScrollingNode::currentScrollPositionChanged):
2875         * page/scrolling/ScrollingTreeScrollingNode.h:
2876         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
2877         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
2878         (WebCore::ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged):
2879
2880 2020-05-21  Peng Liu  <peng.liu6@apple.com>
2881
2882         Fix issues of the Picture-in-Picture API under stress tests
2883         https://bugs.webkit.org/show_bug.cgi?id=212191
2884
2885         Reviewed by Eric Carlson.
2886
2887         The current implementation of the Picture-in-Picture API is not robust under stress tests.
2888         Changing the video presentation mode of a video element between inline and picture-in-picture
2889         continuously may corrupt the internal states of the video element.
2890
2891         This patch refactors the approach to tracking the progress of video presentation mode changes
2892         and make sure no new requestPictureInPicture() or exitPictureInPicture() will trigger
2893         a presentation mode change unless the previous operations are completed.
2894
2895         This patch also removes the code for testing purposes in the HTMLVideoElement class.
2896
2897         Covered by existing tests.
2898
2899         * html/HTMLMediaElement.h:
2900         * html/HTMLVideoElement.cpp:
2901         (WebCore::toPresentationMode):
2902         (WebCore::HTMLVideoElement::setFullscreenMode):
2903         (WebCore::HTMLVideoElement::fullscreenModeChanged):
2904         (WebCore::HTMLVideoElement::didEnterFullscreen):
2905         (WebCore::HTMLVideoElement::didExitFullscreen):
2906         (WebCore::HTMLVideoElement::setPictureInPictureObserver):
2907         (WebCore::HTMLVideoElement::setVideoFullscreenFrame):
2908         (WebCore::HTMLVideoElement::didBecomeFullscreenElement): Deleted.
2909         (WebCore::HTMLVideoElement::setPictureInPictureAPITestEnabled): Deleted.
2910         * html/HTMLVideoElement.h:
2911
2912         * testing/Internals.cpp:
2913         (WebCore::Internals::setPictureInPictureAPITestEnabled): Deleted.
2914         * testing/Internals.h:
2915         * testing/Internals.idl:
2916         Remove setPictureInPictureAPITestEnabled().
2917
2918 2020-05-21  Sam Weinig  <weinig@apple.com>
2919
2920         Extended Color Cleanup: Remove trivial uses of Color::rgb()
2921         https://bugs.webkit.org/show_bug.cgi?id=212231
2922
2923         Reviewed by Darin Adler
2924
2925         Replaces a few unnecessary uses of Color::rgb():
2926         - Uses of an idiom where code round-tripped a Color via Color(myColor.rgb()). This is
2927           not compatible with extended colors and seems to be unnecessary.
2928         - Uses of colorWithOverrideAlpha(). This function requires a SimpleColor, so required
2929           using color.rgb(). We can't transition to Color::colorWithAlpha due to a slightly 
2930           different rounding of the alpha, so a new function Color::colorWithAlphaUsingAlternativeRounding
2931           was added to which implements the alternative rounding. A later change can reconcile
2932           the two versions.
2933         - Creation of D2D1::ColorF. D2D1::ColorF has a constructor that takes a four floats that
2934           is used instead.
2935         - Comparing two colors using rgb() for each to avoid comparing the semantic bit. equalIgnoringSemanticColor
2936           exists for just this use.
2937
2938         * editing/cocoa/HTMLConverter.mm:
2939         (HTMLConverterCaches::colorPropertyValueForNode):
2940         * html/HTMLElement.cpp:
2941         (WebCore::HTMLElement::addHTMLColorToStyle):
2942         * html/canvas/CanvasRenderingContext2DBase.cpp:
2943         (WebCore::CanvasRenderingContext2DBase::setStrokeStyle):
2944         (WebCore::CanvasRenderingContext2DBase::setFillStyle):
2945         (WebCore::CanvasRenderingContext2DBase::setShadow):
2946         * html/canvas/CanvasStyle.cpp:
2947         (WebCore::CanvasStyle::createFromStringWithOverrideAlpha):
2948         * html/track/InbandGenericTextTrack.cpp:
2949         (WebCore::InbandGenericTextTrack::updateCueFromCueData):
2950         * platform/graphics/Color.cpp:
2951         (WebCore::Color::colorWithAlphaMultipliedByUsingAlternativeRounding const):
2952         (WebCore::Color::colorWithAlpha const):
2953         (WebCore::Color::colorWithAlphaUsingAlternativeRounding const):
2954         (WebCore::colorWithOverrideAlpha): Deleted.
2955         * platform/graphics/Color.h:
2956         (WebCore::colorWithOverrideAlpha): Deleted.
2957         * platform/graphics/cairo/CairoOperations.cpp:
2958         (WebCore::Cairo::prepareCairoContextSource):
2959         * platform/graphics/filters/FEFlood.cpp:
2960         (WebCore::FEFlood::platformApplySoftware):
2961         * platform/graphics/win/ColorDirect2D.cpp:
2962         (WebCore::Color::operator D2D1_COLOR_F const):
2963         (WebCore::Color::operator D2D1_VECTOR_4F const):
2964         * platform/graphics/win/GraphicsContextDirect2D.cpp:
2965         (WebCore::GraphicsContext::colorWithGlobalAlpha const):
2966         * platform/mac/ThemeMac.mm:
2967         (WebCore::drawCellFocusRingWithFrameAtTime):
2968         * rendering/RenderThemeIOS.mm:
2969         (WebCore::RenderThemeIOS::paintFileUploadIconDecorations):
2970         * rendering/RenderThemeMac.mm:
2971         (WebCore::RenderThemeMac::platformFocusRingColor const):
2972         * rendering/RenderTreeAsText.cpp:
2973         (WebCore::RenderTreeAsText::writeRenderObject):
2974         * svg/SVGStopElement.cpp:
2975         (WebCore::SVGStopElement::stopColorIncludingOpacity const):
2976
2977 2020-05-21  Oriol Brufau  <obrufau@igalia.com>
2978
2979         [css-grid] Don't create renderers for whitespace nodes
2980         https://bugs.webkit.org/show_bug.cgi?id=212220
2981
2982         Reviewed by Manuel Rego Casasnovas.
2983
2984         Even with 'white-space: pre' we shouldn't create RenderTexts
2985         for whitespace-only nodes in grid layout, according to
2986         https://drafts.csswg.org/css-grid/#grid-items
2987
2988         This patch is based on https://codereview.chromium.org/16888008
2989
2990         Tests: fast/text/simple-line-layout-with-zero-sized-font.html
2991                imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html
2992
2993         * rendering/updating/RenderTreeUpdater.cpp:
2994         (WebCore::RenderTreeUpdater::textRendererIsNeeded):
2995
2996 2020-05-21  Simon Fraser  <simon.fraser@apple.com>
2997
2998         Fix rare crash in TileGrid::platformCALayerShowRepaintCounter()
2999         https://bugs.webkit.org/show_bug.cgi?id=212182
3000         <rdar://problem/55618414>
3001
3002         Reviewed by Darin Adler.
3003
3004         Crash data suggest that owner() can be null in platformCALayerShowRepaintCounter(),
3005         so null-check in these functions.
3006
3007         * platform/graphics/ca/TileGrid.cpp:
3008         (WebCore::TileGrid::platformCALayerDeviceScaleFactor const):
3009         (WebCore::TileGrid::platformCALayerShowDebugBorders const):
3010         (WebCore::TileGrid::platformCALayerShowRepaintCounter const):
3011         (WebCore::TileGrid::isUsingDisplayListDrawing const):
3012
3013 2020-05-21  Youenn Fablet  <youenn@apple.com>
3014
3015         Incorrect location.origin in blob workers
3016         https://bugs.webkit.org/show_bug.cgi?id=211876
3017         <rdar://problem/63284717>
3018
3019         Reviewed by Sihui Liu.
3020
3021         Instead of computing the origin from the location URL in worker, get it directly from the WorkerGlobalScope origin.
3022         This ensures we unwrap properly blob URLs.
3023
3024         Test: http/tests/security/contentSecurityPolicy/worker-blob-location.html
3025
3026         * workers/WorkerGlobalScope.cpp:
3027         (WebCore::WorkerGlobalScope::location const):
3028         * workers/WorkerLocation.cpp:
3029         (WebCore::WorkerLocation::origin const):
3030         * workers/WorkerLocation.h:
3031         (WebCore::WorkerLocation::create):
3032         (WebCore::WorkerLocation::url const):
3033         (WebCore::WorkerLocation::WorkerLocation):
3034
3035 2020-05-21  John Wilander  <wilander@apple.com>
3036
3037         Storage Access API: Allow configurable storage access scope
3038         https://bugs.webkit.org/show_bug.cgi?id=212114
3039         <rdar://problem/63423063>
3040
3041         Reviewed by Alex Christensen.
3042
3043         The scope of storage access as per-frame or per-page was discussed in the
3044         standards process here: https://github.com/privacycg/storage-access/issues/3
3045
3046         The decision was to have per-page storage access by default. Recent feedback
3047         from Google and conversation with Mozilla suggest that we might want to
3048         support the caller choosing the scope.
3049
3050         This patch adds support for different scope configurations while keeping the
3051         existing default as per-frame. A later patch will switch the default and add
3052         test cases for per-page scope.
3053
3054         A new struct is added WebCore::RequestStorageAccessResult which carries full
3055         information about the storage access request result.
3056
3057         A new enum is added WebCore::StorageAccessScope to encode per-frame and
3058         per-page access.
3059
3060         No new tests. No changed functionality. Tests already exist.
3061
3062         * dom/DocumentStorageAccess.cpp:
3063         (WebCore::DocumentStorageAccess::requestStorageAccess):
3064         * dom/DocumentStorageAccess.h:
3065         (WebCore::RequestStorageAccessResult::encode const):
3066         (WebCore::RequestStorageAccessResult::decode):
3067         * page/ChromeClient.h:
3068         (WebCore::ChromeClient::requestStorageAccess):
3069
3070 2020-05-21  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
3071
3072         [PlayStation] Add minimal WKView API to enable TestWebKitAPI
3073         https://bugs.webkit.org/show_bug.cgi?id=211868
3074
3075         Reviewed by Alex Christensen.
3076
3077         Enable TestWebKitAPI
3078
3079         * PlatformPlayStation.cmake:
3080         Add WebKitRequirements library to WebCore_CopySharedLibs.
3081
3082 2020-05-21  Chris Dumez  <cdumez@apple.com>
3083
3084         ASSERTION FAILED: m_wrapper on fast/events/scoped/editing-commands.html
3085         https://bugs.webkit.org/show_bug.cgi?id=209862
3086         <rdar://problem/61164607>
3087
3088         Reviewed by Darin Adler.
3089
3090         Make sure ScopedEventQueue keeps its event targets alive using a GCReachableRef<Node>
3091         so that it keeps alive both the target and its JS wrapper.
3092
3093         No new tests, covered by existing test.
3094
3095         * dom/ScopedEventQueue.cpp:
3096         (WebCore::ScopedEventQueue::enqueueEvent):
3097         (WebCore::ScopedEventQueue::dispatchEvent const):
3098         (WebCore::ScopedEventQueue::dispatchAllEvents):
3099         * dom/ScopedEventQueue.h:
3100
3101 2020-05-21  Sihui Liu  <sihui_liu@apple.com>
3102
3103         SQLite database fails to close in SQLiteIDBBackingStore::databaseNameFromFile
3104         https://bugs.webkit.org/show_bug.cgi?id=212090
3105
3106         Reviewed by Darin Adler.
3107
3108         We should finish SQLite statement before closing database.
3109
3110         * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
3111         (WebCore::IDBServer::SQLiteIDBBackingStore::databaseNameFromFile):
3112
3113 2020-05-21  Doug Kelly  <dougk@apple.com>
3114
3115         Dispatch pending events only for current page
3116         https://bugs.webkit.org/show_bug.cgi?id=211975
3117         <rdar://problem/58942759>
3118
3119         Reviewed by Chris Dumez.
3120
3121         Document::implicitClose() should not dispatch events globally. The EventSender class operates as a singleton pattern
3122         for each event queue, so to add some means to restrict which documents are handling events, we can send the current
3123         page pointer and only dispatch the event if the event is for the same page. Other events are simply re-enqueued
3124         to be triggered at a later time.
3125
3126         * dom/Document.cpp:
3127         (WebCore::Document::implicitClose):
3128         * dom/EventSender.h:
3129         (WebCore::EventSender::timerFired):
3130         (WebCore::EventSender<T>::dispatchPendingEvents):
3131         * html/HTMLLinkElement.cpp:
3132         (WebCore::HTMLLinkElement::dispatchPendingLoadEvents):
3133         * html/HTMLLinkElement.h:
3134         * html/HTMLStyleElement.cpp:
3135         (WebCore::HTMLStyleElement::dispatchPendingLoadEvents):
3136         * html/HTMLStyleElement.h:
3137         * loader/ImageLoader.cpp:
3138         (WebCore::ImageLoader::dispatchPendingBeforeLoadEvents):
3139         (WebCore::ImageLoader::dispatchPendingLoadEvents):
3140         (WebCore::ImageLoader::dispatchPendingErrorEvents):
3141         * loader/ImageLoader.h:
3142         (WebCore::ImageLoader::document):
3143         * xml/parser/XMLDocumentParser.cpp:
3144         (WebCore::XMLDocumentParser::append):
3145
3146 2020-05-21  Simon Fraser  <simon.fraser@apple.com>
3147
3148         [macOS] Scrolling synchronization part 2: Have the scrolling thread detect when the main thread is slow to respond to start a rendering update
3149         https://bugs.webkit.org/show_bug.cgi?id=212175
3150
3151         Reviewed by Tim Horton.
3152
3153         The scrolling thread now detects when a main thread rendering update is taking too long, going into
3154         desynchronized mode when that happens.
3155
3156         However, there's another state that needs to be handled, which is the main thread being busy and
3157         taking too long to start the rendering update. The scrolling thread gets a "displayDidRefresh" ping
3158         and expects that the main thread will get the same ping, and use it to start the rendering update,
3159         but a busy main thread won't respond to this ping promptly.
3160
3161         Detect this with a short-duration (1ms) timer that fires on the scrolling thread; if the timer fires
3162         we go into desynchronized mode until the next update. The timer is canceled if the scrolling thread
3163         receives the willStartRenderingUpdate(). 
3164
3165         * page/scrolling/ThreadedScrollingTree.cpp:
3166         (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
3167         (WebCore::ThreadedScrollingTree::scheduleDelayedRenderingUpdateDetectionTimer):
3168         (WebCore::ThreadedScrollingTree::delayedRenderingUpdateDetectionTimerFired):
3169         (WebCore::ThreadedScrollingTree::displayDidRefreshOnScrollingThread):
3170         * page/scrolling/ThreadedScrollingTree.h:
3171
3172 2020-05-21  Sergio Villar Senin  <svillar@igalia.com>
3173
3174         [css-grid] [css-flex] Width of table as grid/flex item is infinite when the sum of columns' width exceed 100%
3175         https://bugs.webkit.org/show_bug.cgi?id=191365
3176
3177         Reviewed by Manuel Rego Casasnovas.
3178
3179         Automatic table layout algorithm generates infinite width tables
3180         (tableMaxWidth to be more exact) when the sum of the columns percentages
3181         exceed the 100% value and there is at least one non-percentage based
3182         column with positive width as in those cases it's impossible to fulfill
3183         the table constrains. That should not be done in the case of the table
3184         being a flex or a grid item because they both define new formatting
3185         contexts.
3186
3187         Based on Blink's crrev.com/1095220 by <mstensho@chromium.org>
3188
3189         * rendering/AutoTableLayout.cpp:
3190         (WebCore::shouldScaleColumnsForParent): return false when the table is
3191         either a grid or a flex item.
3192
3193 2020-05-21  Zalan Bujtas  <zalan@apple.com>
3194
3195         [ macOS debug ] REGRESSION: fast/layoutformattingcontext/table-basic-row-baseline-with-nested-table.html is a flaky crash
3196         https://bugs.webkit.org/show_bug.cgi?id=212139
3197         <rdar://problem/63447683>
3198
3199         Reviewed by Antti Koivisto.
3200
3201         Uninitialized row baseline value caused unexpected cell height in nested tables.
3202
3203         * layout/tableformatting/TableFormattingContext.cpp:
3204         (WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
3205         * layout/tableformatting/TableGrid.h:
3206
3207 2020-05-21  Zalan Bujtas  <zalan@apple.com>
3208
3209         [LFC][TFC] Collapse in-between cell borders
3210         https://bugs.webkit.org/show_bug.cgi?id=212183
3211
3212         Reviewed by Antti Koivisto.
3213
3214         This patch expands border collapsing to in-between cell borders.
3215
3216         Test: fast/layoutformattingcontext/table-simple-border-collapse3.html
3217
3218         * layout/tableformatting/TableFormattingContext.cpp:
3219         (WebCore::Layout::TableFormattingContext::layoutCell):
3220         * layout/tableformatting/TableFormattingContext.h:
3221         * layout/tableformatting/TableFormattingContextGeometry.cpp:
3222         (WebCore::Layout::TableFormattingContext::Geometry::computedCellBorder const):
3223         (WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):
3224
3225 2020-05-21  Enrique Ocaña González  <eocanha@igalia.com>
3226
3227         [GStreamer][GTK][WPE] Expose and honor the media content types requiring hardware support setting
3228         https://bugs.webkit.org/show_bug.cgi?id=211950
3229
3230         Reviewed by Adrian Perez de Castro.
3231
3232         Provide the needed information about media content types requiring hardware support
3233         when asking the MediaPlayer about what types are supported. This was already being done
3234         from HTMLMediaElement for player selection, but not in MediaSource nor in
3235         MediaSource::addSourceBuffer() when the webpage used the MSE API to check type support.
3236         In order to ask for the mediaContentTypesRequiringHardwareSupport setting we need a
3237         reference to the current Document in all the places where we need to check type support.
3238
3239         * Modules/mediasource/MediaSource.cpp:
3240         (WebCore::MediaSource::addSourceBuffer): Provide hardware content types extra info.
3241         (WebCore::MediaSource::isTypeSupported): Get hardware content types extra info from
3242         ScriptExecutionContext and provide it to a new refactored private version of
3243         isTypeSupported() which can also be reused from addSourceBuffer().
3244         * Modules/mediasource/MediaSource.h: Changed isTypeSupported() prototype to take
3245         ScriptExecutionContext and added a new overloaded version of the method.
3246         * Modules/mediasource/MediaSource.idl: isTypeSupported() now provides a reference to
3247         ScriptExecutionContext. It's the only way to access the required document settings from a
3248         static method.
3249         * platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
3250         (WebCore::GStreamerRegistryScanner::isContentTypeSupported const): Factor ContentType
3251         discrimination logic common to MediaPlayerPrivateGStreamer and
3252         MediaPlayerPrivateGStreamerMSE.
3253         * platform/graphics/gstreamer/GStreamerRegistryScanner.h: Added new method.
3254         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
3255         (WebCore::MediaPlayerPrivateGStreamer::supportsType): Provide hardware content types extra
3256         info when asking for type support.
3257         * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
3258         (WebCore::MediaPlayerPrivateGStreamerMSE::supportsType): Ditto.
3259
3260 2020-05-20  Simon Fraser  <simon.fraser@apple.com>
3261
3262         [macOS] Scrolling synchronization part 1: Have the scrolling thread wait half a frame for the main thread to complete the rendering update
3263         https://bugs.webkit.org/show_bug.cgi?id=212168
3264
3265         Reviewed by Tim Horton.
3266
3267         Currently the scrolling thread is a free-running thread that moves layers around in response
3268         to wheel events, and asynchronously posts data about scrolled layers back to the main thread.
3269         That results in an almost guaranteed lack of synchronization between the displayed layer
3270         positions, and the web-exposed values for scroll position (element.scrollTop, window.pageYOffset etc).
3271         This is a frequent source of stuttering or jumpy web content when scrolling.
3272
3273         The first step to fixing this is to synchronize the scrolling thread layer positions
3274         and the main thread state for the case where the main thread is responsive enough to
3275         render once per frame. This is achieved as follow:
3276             - When the main thread is starting a rendering update, Page::updateRendering() informs
3277               the scrolling tree via ScrollingCoordinatorMac::willStartRenderingUpdate(). This
3278               atomically waits for the scrolling thread to take the m_treeMutex (via a BinarySemaphore)
3279               and starts waiting on the m_stateCondition Condition. Now the main thread pulls the
3280               state of the scrolling tree via synchronizeStateFromScrollingTree() and uses it for
3281               the rendering update.
3282             - If the rendering update finishes within half a frame (8ms), then m_stateCondition
3283               is released, and the scrolling thread assumes that the main thread is going to
3284               commit layers rapidly enough to preserve 60fps scrolling.
3285             - If the rendering update takes too long, m_stateCondition times out, and the scrolling
3286               thread applies layer positions, triggering a CA commit on that thread.
3287
3288         We no longer apply layer positions directly when handling wheel events.
3289
3290         synchronizeStateFromScrollingTree() has to only pull state from nodes that have moved on the scrolling thread,
3291         so track that via ScrollingTreeScrollingNode::scrolledSinceLastCommit() and adjust the visitor function to
3292         make it available during scrolling tree traversal.
3293
3294         * page/Page.cpp:
3295         (WebCore::Page::updateRendering):
3296         (WebCore::Page::finalizeRenderingUpdate):
3297         * page/scrolling/AsyncScrollingCoordinator.cpp:
3298         (WebCore::AsyncScrollingCoordinator::synchronizeStateFromScrollingTree):
3299         * page/scrolling/AsyncScrollingCoordinator.h:
3300         * page/scrolling/ScrollingCoordinator.h:
3301         (WebCore::ScrollingCoordinator::willStartRenderingUpdate):
3302         (WebCore::ScrollingCoordinator::didCompleteRenderingUpdate):
3303         (WebCore::ScrollingCoordinator::synchronizeStateFromScrollingTree): Deleted.
3304         * page/scrolling/ScrollingTree.cpp:
3305         (WebCore::ScrollingTree::handleWheelEvent):
3306         (WebCore::ScrollingTree::traverseScrollingTreeRecursive):
3307         (WebCore::ScrollingTree::commitTreeState):
3308         (WebCore::ScrollingTree::updateTreeFromStateNodeRecursive):
3309         (WebCore::ScrollingTree::applyLayerPositionsInternal):
3310         (WebCore::ScrollingTree::nominalFramesPerSecond):
3311         * page/scrolling/ScrollingTree.h:
3312         * page/scrolling/ScrollingTreeNode.h:
3313         (WebCore::ScrollingTreeNode::didCompleteCommitForNode):
3314         * page/scrolling/ScrollingTreeScrollingNode.cpp:
3315         (WebCore::ScrollingTreeScrollingNode::didCompleteCommitForNode):
3316         (WebCore::ScrollingTreeScrollingNode::currentScrollPositionChanged):
3317         * page/scrolling/ScrollingTreeScrollingNode.h:
3318         * page/scrolling/ThreadedScrollingTree.cpp:
3319         (WebCore::ThreadedScrollingTree::willStartRenderingUpdate):
3320         (WebCore::ThreadedScrollingTree::maxAllowableRenderingUpdateDurationForSynchronization):
3321         (WebCore::ThreadedScrollingTree::waitForRenderingUpdateCompletionOrTimeout):
3322         (WebCore::ThreadedScrollingTree::didCompleteRenderingUpdate):
3323         (WebCore::ThreadedScrollingTree::displayDidRefreshOnScrollingThread):
3324         * page/scrolling/ThreadedScrollingTree.h:
3325         (WebCore::ThreadedScrollingTree::treeMutex):
3326         * page/scrolling/mac/ScrollingCoordinatorMac.h:
3327         * page/scrolling/mac/ScrollingCoordinatorMac.mm:
3328         (WebCore::ScrollingCoordinatorMac::willStartRenderingUpdate):
3329         (WebCore::ScrollingCoordinatorMac::didCompleteRenderingUpdate):
3330
3331 2020-05-20  Chris Fleizach  <cfleizach@apple.com>
3332
3333         REGRESSION (iOS 13.4.1): SpeechSynthesisUtterance.onend event won't fire on cancel().
3334         https://bugs.webkit.org/show_bug.cgi?id=211776
3335         <rdar://problem/63130249>
3336
3337         Reviewed by Per Arne Vollan.
3338
3339         With the move to having speech synthesis happen in the client, the cancel case hits a snag.
3340         We cancel the speech job and clear out the current utterance. By the time the cancel callback comes back,
3341         the current utterance is gone and nothing happens.
3342
3343         The fix is to process the speechError event immediately and not wait on the speech synthesizer -- which seems sane,
3344         since we're just cancelling a speech job.
3345
3346         * Modules/speech/SpeechSynthesis.cpp:
3347         (WebCore::SpeechSynthesis::cancel):
3348
3349 2020-05-20  Darin Adler  <darin@apple.com>
3350
3351         Dictation context should be an object identifier, not a type-punned pointer
3352         https://bugs.webkit.org/show_bug.cgi?id=212174
3353
3354         Reviewed by Anders Carlsson.
3355
3356         * Headers.cmake: Added DictationContext.h.
3357         * Sources.txt: Removed DictationAlternative.cpp.
3358         * WebCore.xcodeproj/project.pbxproj: Added DictationContext.h, removed DictationAlternative.cpp.
3359
3360         * dom/DocumentMarker.h: Use DictationContext instead of uint64_t.
3361         * editing/AlternativeTextController.cpp:
3362         (WebCore::AlternativeTextController::timerFired): Ditto.
3363         * editing/AlternativeTextController.h: Ditto.
3364
3365         * editing/DictationAlternative.h: Use DictationContext instead of uint64_t, but also
3366         use CharacterRange rather than two "unsigned" values. Also convert into a simple
3367         struct without constructors; don't really need those.
3368
3369         * editing/DictationAlternative.cpp: Removed.
3370
3371         * editing/DictationCommand.cpp:
3372         (WebCore::DictationCommand::collectDictationAlternativesInRange): Updated for
3373         changes to DictationAlternative.
3374
3375         * editing/DictationContext.h: Added.
3376
3377         * editing/Editor.h: Forward declare DictationAlternative rather than including
3378         its header.
3379
3380         * editing/cocoa/AlternativeTextContextController.h: Use a pair of maps to bind NSTextAlternatives
3381         objects to object identifiers. Remove unnecessary explicit constructor and destructor. Also removed
3382         unnecessary use of WTF_MAKE_FAST_ALLOCATED, since this is only used as a data member of another
3383         class. Removed unused invalidContext constant.
3384         * editing/cocoa/AlternativeTextContextController.mm: Removed the unneeded includes.
3385         This file treats NSTextAlternatives as an opaque Objective-C type and so doesn't need
3386         any details of that class.
3387         (WebCore::AlternativeTextContextController::addAlternatives): Changed to return a
3388         DictationContext and use two maps, using HashMap::ensure to avoid double hashing.
3389         (WebCore::AlternativeTextContextController::alternativesForContext): Added a null check.
3390         (WebCore::AlternativeTextContextController::removeAlternativesForContext): Ditto. Also
3391         updated to remove from both maps.
3392         (WebCore::AlternativeTextContextController::clear): Clear both maps.
3393
3394         * editing/cocoa/AlternativeTextUIController.h: Since this header is used only from Objective-C,
3395         removed use of OBJC_CLASS. Put showAlternatives inside a macOS-specific block. Use DictationContext
3396         instead of uint64_t.
3397         * editing/cocoa/AlternativeTextUIController.mm:
3398         (WebCore::AlternativeTextUIController::addAlternatives): Use DictationContext instead of uint64_t.
3399         (WebCore::AlternativeTextUIController::alternativesForContext): Ditto.
3400         (WebCore::AlternativeTextUIController::showAlternatives): Ditto.
3401         (WebCore::AlternativeTextUIController::handleAcceptedAlternative): Ditto.
3402         (WebCore::AlternativeTextUIController::removeAlternatives): Ditto.
3403
3404         * page/AlternativeTextClient.h: Use DictationContext instead of uint64_t.
3405
3406 2020-05-20  Zalan Bujtas  <zalan@apple.com>
3407
3408         [LFC][TFC] Preferred width computation should take border collapsing into account
3409         https://bugs.webkit.org/show_bug.cgi?id=212141
3410
3411         Reviewed by Antti Koivisto.
3412
3413         Test: fast/layoutformattingcontext/table-simple-border-collapse2.html
3414
3415         * layout/tableformatting/TableFormattingContext.cpp:
3416         (WebCore::Layout::TableFormattingContext::computedPreferredWidthForColumns):
3417         * layout/tableformatting/TableFormattingContext.h:
3418         (WebCore::Layout::TableFormattingContext::Geometry::Geometry):
3419         * layout/tableformatting/TableFormattingContextGeometry.cpp:
3420         (WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):
3421
3422 2020-05-20  Zalan Bujtas  <zalan@apple.com>
3423
3424         Repaint issues when the login field collapses on music.apple.com
3425         https://bugs.webkit.org/show_bug.cgi?id=212101
3426         <rdar://problem/62874369>
3427
3428         Reviewed by Simon Fraser.
3429
3430         RenderWidgets (e.g iframe) are painted on integral pixel boundaries. When we issue the repaints on such renderers, we need to
3431         make sure that the repaint rectangles are also snapped to integral pixel values.
3432         Currently trunk only covers the case when the renderer itself is positioned on a subpixel position (e.g when the containing block's content box has a non-integral position value).
3433         This patch ensures that we repaint the RenderWidgets properly when a non-direct ancestor puts the renderer on a subpixel position.
3434
3435         Test: fast/repaint/iframe-on-subpixel-position.html
3436
3437         * page/FrameView.h:
3438         * rendering/RenderBox.cpp:
3439         (WebCore::RenderBox::computeVisibleRectInContainer const):
3440         * rendering/RenderLayerBacking.cpp:
3441         (WebCore::RenderLayerBacking::setContentsNeedDisplay):
3442         (WebCore::RenderLayerBacking::setContentsNeedDisplayInRect):
3443         * rendering/RenderObject.h:
3444         * testing/Internals.cpp:
3445         (WebCore::Internals::enableSubframeRepaintTracking): add subframe repaint tracking 
3446         (WebCore::Internals::disableSubframeRepaintTracking):
3447         * testing/Internals.h:
3448         * testing/Internals.idl:
3449
3450 2020-05-20  Oriol Brufau  <obrufau@igalia.com>
3451
3452         Computed min-width/height for auto depends on box
3453         https://bugs.webkit.org/show_bug.cgi?id=209651
3454
3455         Reviewed by Manuel Rego Casasnovas.
3456
3457         Resolved value of min-width and min-height for auto min sizing of flex
3458         and grid items may be 'auto'. We based this on the computed style of the
3459         shadow including parent. Instead we should rely on whether the element
3460         will actually be a rendered flex/grid item.
3461
3462         The difference matters e.g. when the parent has 'display: contents' and
3463         thus is not a flex nor grid container, but the element can still be a
3464         flex or grid item, depending on the grand-parent.
3465
3466         This patch is based on https://crrev.com/540901 from Chromium.
3467
3468         Tests: imported/w3c/web-platform-tests/css/css-flexbox/getcomputedstyle/flexbox_computedstyle_min-auto-size.html
3469                imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-item-min-auto-size-001.html
3470
3471         * css/CSSComputedStyleDeclaration.cpp:
3472         (WebCore::isFlexOrGridItem):
3473         (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
3474
3475 2020-05-20  Alex Christensen  <achristensen@webkit.org>
3476
3477         Remove implicit URL->String conversion operators
3478         https://bugs.webkit.org/show_bug.cgi?id=211033
3479
3480         Reviewed by Darin Adler.
3481
3482         * accessibility/AccessibilityRenderObject.cpp:
3483         (WebCore::AccessibilityRenderObject::stringValueForMSAA const):
3484         * html/DOMURL.cpp:
3485         (WebCore::DOMURL::create):
3486         * html/HTMLPlugInElement.cpp:
3487         (WebCore::pluginReplacementForType):
3488         * html/URLUtils.h:
3489         (WebCore::URLUtils<T>::protocol const):
3490         (WebCore::URLUtils<T>::setUsername):
3491         (WebCore::URLUtils<T>::setPassword):
3492         * page/Location.cpp:
3493         (WebCore::Location::setProtocol):
3494         (WebCore::Location::setHost):
3495         (WebCore::Location::setHostname):
3496         (WebCore::Location::setPort):
3497         (WebCore::Location::setPathname):
3498         (WebCore::Location::setSearch):
3499         (WebCore::Location::setHash):
3500         * platform/graphics/MediaPlayer.cpp:
3501         (WebCore::MediaPlayer::load):
3502
3503 2020-05-20  Sam Weinig  <weinig@apple.com>
3504
3505         Replace Color::getHSL() with sRGBToHSL to ensure it at least gives somewhat sensible results for ExtendedColors and reduce code duplication
3506         https://bugs.webkit.org/show_bug.cgi?id=212143
3507
3508         Reviewed by Simon Fraser.
3509
3510         - Updated API tests to test sRGBToHSL() rather than Color::getHSL() and extended the tests
3511           to include lightness tests and round tripping tests.
3512         - Update editing/pasteboard/paste-dark-mode-color-filtered.html with extended color test cases.
3513
3514         Replaces Color::getHSL() with sRGBToHSL(color.toSRGBAComponentsLossy()) and adds
3515         an optimized variant, lightness(...) that just extracts the lightness component for 
3516         callers that only needed that.
3517         
3518         It is now required to explicitly use color.toSRGBAComponentsLossy() to indicate that
3519         for non-SRGB colors, this will be a lossy transformation and give us an easy way to
3520         find all these sites in the future, if we want to make a better conversion for other
3521         color spaces. 
3522
3523         * editing/ReplaceSelectionCommand.cpp:
3524         (WebCore::fragmentNeedsColorTransformed):
3525         Switch to using lightness(). This was previously broken for extended colors but now works (though 
3526         in a lossy way through sRGB). Update editing/pasteboard/paste-dark-mode-color-filtered.html with extended colors.
3527
3528         * editing/cocoa/DataDetection.mm:
3529         (WebCore::DataDetection::detectContentInRange):
3530         Switch to using sRGBToHSL(color.toSRGBAComponentsLossy()).
3531         
3532         * page/FrameView.cpp:
3533         (WebCore::FrameView::recalculateScrollbarOverlayStyle):
3534         Switch to using lightness().
3535         
3536         * platform/graphics/Color.cpp:
3537         (WebCore::Color::getHSL const): Deleted.
3538         * platform/graphics/Color.h:
3539         Remove Color::getHSL().
3540         
3541         * platform/graphics/ColorUtilities.cpp:
3542         (WebCore::lightness):
3543         Added optimized subset of sRGBToHSL which just computes the lightness component for callers
3544         that only need that.
3545
3546         (WebCore::sRGBToHSL):
3547         Simplify/cleanup code a little using initialize-list based std::max/std::min and structured bindings.
3548
3549         * platform/graphics/ColorUtilities.h:
3550         Export functions to allow testing them directly.
3551
3552 2020-05-20  Megan Gardner  <megan_gardner@apple.com>
3553
3554         Hide password echo when screen is being captured.
3555         https://bugs.webkit.org/show_bug.cgi?id=212060
3556         <rdar://problem/47653578>
3557
3558         Reviewed by Wenson Hsieh.
3559
3560         When the screen is being captured, turn off the password echo. 
3561
3562         * editing/InsertIntoTextNodeCommand.cpp:
3563         (WebCore::InsertIntoTextNodeCommand::doApply):
3564         * page/EditorClient.h:
3565         (WebCore::EditorClient::isScreenCaptured const):
3566
3567 2020-05-20  ChangSeok Oh  <changseok@webkit.org>
3568
3569         [GTK] Implement connected and disconnected events of GAMEPAD API with libmanette
3570         https://bugs.webkit.org/show_bug.cgi?id=133854
3571
3572         Reviewed by Carlos Garcia Campos.
3573
3574         This patch brings initial GAMEPAD API support to the gtk port. We use libmanette,
3575         a simple GObject game controller library to handle gamepad connection and input.
3576         This change aims to implement two GAMEPAD API events: 'gamepadconnected' and 'gamepaddisconnected'
3577         on top of libmanette. Rest of API will be implemented by following patches.
3578
3579         No new tests since existing tests can cover this change.
3580
3581         * PlatformGTK.cmake: Add header & library paths for libmanette.
3582         * SourcesGTK.txt:
3583         * platform/gamepad/manette/GUniquePtrManette.h: Added to define a smart pointer for ManetteMonitor.
3584         * platform/gamepad/manette/ManetteGamepad.cpp: Added. A wrapper class for ManetteDevice.
3585           A ManetteGamepad instance is created per a physically connected gamepad. Currently,
3586           it is empty but input handling login will be placed in this class.
3587         (WebCore::ManetteGamepad::ManetteGamepad):
3588         * platform/gamepad/manette/ManetteGamepad.h: Added.
3589         * platform/gamepad/manette/ManetteGamepadProvider.cpp: Added. A manager class
3590           for ManetteGamepad instances. This class represents ManetteMonitor that
3591           handles connection and disconnection of gamepads. Many parts of this class implementation
3592           is brought from HIDGamepad.cpp
3593         (WebCore::ManetteGamepadProvider::singleton):
3594         (WebCore::onDeviceConnected):
3595         (WebCore::onDeviceDisconnected):
3596         (WebCore::ManetteGamepadProvider::ManetteGamepadProvider):
3597         (WebCore::ManetteGamepadProvider::startMonitoringGamepads):
3598         (WebCore::ManetteGamepadProvider::stopMonitoringGamepads):
3599         (WebCore::ManetteGamepadProvider::deviceConnected):
3600         (WebCore::ManetteGamepadProvider::deviceDisconnected):
3601         (WebCore::ManetteGamepadProvider::indexForNewlyConnectedDevice):
3602         (WebCore::ManetteGamepadProvider::connectionDelayTimerFired):
3603         (WebCore::ManetteGamepadProvider::removeGamepadForDevice):
3604         * platform/gamepad/manette/ManetteGamepadProvider.h: Added.
3605
3606 2020-05-20  Antoine Quint  <graouts@apple.com>
3607
3608         Potential crash in PointerCaptureController::cancelPointer()
3609         https://bugs.webkit.org/show_bug.cgi?id=208347
3610         <rdar://problem/59866247>
3611
3612         Reviewed by David Kilzer and Daniel Bates.
3613
3614         * page/PointerCaptureController.cpp:
3615         (WebCore::PointerCaptureController::cancelPointer):
3616
3617 2020-05-20  Oriol Brufau  <obrufau@igalia.com>
3618
3619         [css-grid] Fix auto repeat with multiple tracks and gutters
3620         https://bugs.webkit.org/show_bug.cgi?id=182922
3621
3622         Reviewed by Manuel Rego Casasnovas.
3623
3624         The code that computes the number of auto repeat tracks wrongly assumes
3625         that the second argument of the repeat() notation is a single track
3626         function. That was true in the beginning, however specs were later on
3627         modified to allow a <track-list>. We support a <track-list> as a second
3628         argument since long ago but the code that computes the number of
3629         auto-repeat tracks was never updated.
3630
3631         This patch modifies two places that relate to the gaps between the
3632         auto-repeat tracks, which ensures the proper total length.
3633
3634         This is a port of https://crrev.com/620278 from Chromium.
3635
3636         Tests: fast/css-grid-layout/grid-auto-repeat-huge-grid.html
3637                imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-auto-repeat-multiple-values-001.html
3638
3639         * rendering/RenderGrid.cpp:
3640         (WebCore::RenderGrid::computeAutoRepeatTracksCount const):
3641
3642 2020-05-20  Simon Fraser  <simon.fraser@apple.com>
3643
3644         Plumb the display's nominal refresh rate down to ScrollingTree for use in scroll synchronization
3645         https://bugs.webkit.org/show_bug.cgi?id=212159
3646
3647         Reviewed by Tim Horton.
3648
3649         Plumb an Optional<unsigned> down windowScreenDidChange, which contains the nominal
3650         display refresh rate (as frames per second) if available. On macOS, we get this
3651         from CVDisplayLinkGetNominalOutputVideoRefreshPeriod().
3652
3653         To read it, WebProcessPool::nominalFramesPerSecondForDisplay() makes a DisplayLink
3654         that doesn't get any observers, but that DisplayLink will very likely get used
3655         as soon as we schedule a rendering update.
3656
3657         * page/Chrome.cpp:
3658         (WebCore::Chrome::windowScreenDidChange):
3659         * page/Chrome.h:
3660         * page/Page.cpp:
3661         (WebCore::Page::scrollingCoordinator):
3662         (WebCore::Page::windowScreenDidChange):
3663         * page/Page.h:
3664         (WebCore::Page::displayNominalFramesPerSecond const):
3665         * page/scrolling/AsyncScrollingCoordinator.cpp:
3666         (WebCore::AsyncScrollingCoordinator::windowScreenDidChange):
3667         * page/scrolling/AsyncScrollingCoordinator.h:
3668         * page/scrolling/ScrollingCoordinator.h:
3669         (WebCore::ScrollingCoordinator::windowScreenDidChange):
3670         * page/scrolling/ScrollingTree.cpp:
3671         (WebCore::ScrollingTree::windowScreenDidChange):
3672         * page/scrolling/ScrollingTree.h:
3673         * platform/HostWindow.h:
3674
3675 2020-05-20  Chris Dumez  <cdumez@apple.com>
3676
3677         Disable support for BeforeLoadEvent
3678         https://bugs.webkit.org/show_bug.cgi?id=212140
3679         <rdar://problem/62847577>
3680
3681         Reviewed by Antti Koivisto.
3682
3683         Disable support for BeforeLoadEvent. Other browsers do not support it and
3684         Chrome dropped it shortly after the fork:
3685         - https://bugs.chromium.org/p/chromium/issues/detail?id=333318
3686
3687         This is a synchronous event and therefore very dangerous.
3688
3689         Test: fast/frames/didBecomeCurrentDocumentInFrame-crash.html
3690
3691         * bindings/js/WebCoreBuiltinNames.h:
3692         * dom/BeforeLoadEvent.idl:
3693         * dom/Node.cpp:
3694         (WebCore::Node::dispatchBeforeLoadEvent):
3695         * page/RuntimeEnabledFeatures.h:
3696         (WebCore::RuntimeEnabledFeatures::setLegacyBeforeLoadEventEnabled):
3697         (WebCore::RuntimeEnabledFeatures::legacyBeforeLoadEventEnabled const):
3698
3699 2020-05-20  Zalan Bujtas  <zalan@apple.com>
3700
3701         RenderObject::VisibleRectContext members should not be prefixed with m_
3702         https://bugs.webkit.org/show_bug.cgi?id=212154
3703
3704         Reviewed by Simon Fraser.
3705
3706         * rendering/RenderBox.cpp:
3707         (WebCore::RenderBox::applyCachedClipAndScrollPosition const):
3708         (WebCore::RenderBox::computeVisibleRectInContainer const):
3709         * rendering/RenderInline.cpp:
3710         (WebCore::RenderInline::computeVisibleRectInContainer const):
3711         * rendering/RenderObject.cpp:
3712         (WebCore::RenderObject::computeVisibleRectInContainer const):
3713         * rendering/RenderObject.h:
3714         * rendering/RenderTableCell.cpp:
3715         (WebCore::RenderTableCell::computeVisibleRectInContainer const):
3716         * rendering/RenderView.cpp:
3717         (WebCore::RenderView::computeVisibleRectInContainer const):
3718         * rendering/svg/RenderSVGRoot.cpp:
3719         (WebCore::RenderSVGRoot::computeFloatVisibleRectInContainer const):
3720
3721 2020-05-20  Myles C. Maxfield  <mmaxfield@apple.com>
3722
3723         [iPadOS] -webkit-text-size-adjust:percentage doesn't work
3724         https://bugs.webkit.org/show_bug.cgi?id=212122
3725         <rdar://problem/54560875>
3726
3727         Reviewed by Wenson Hsieh.
3728
3729         We've gotten many bug reports that -webkit-text-size-adjust:X% no longer works in
3730         WebKit on iPads. We don't want to just start honoring the value, because our
3731         testing indicates that, with desktop-class browsing on iPad, more sites work better
3732         when we don't honor percentages. However, if Safari is using the mobile content mode,
3733         or if a native app has local content, it should be possible to get the old behavior
3734         of honoring percentages.
3735
3736         This patch adds a new Setting, idempotentModeAutosizingOnlyHonorsPercentages, which
3737         is hooked up to the desktop-class browsing feature. When
3738         WebPageProxy::effectiveContentModeAfterAdjustingPolicies() determines that the
3739         WebContentMode::Mobile mode should be used, it sets the new setting, which
3740         causes idempotent text autosizing mode to have the same behavior that WKWebViews
3741         on iPadOS used to have: -w-t-s-a:auto and -w-t-s-a:none have no effect, but
3742         -w-t-s-a:X% is honored. This affects both Safari and WKWebView apps.
3743
3744         If a native app wants the old behavior, they can set
3745         WKWebpagePreferences.preferredContentMode = WKContentModeMobile to force the old
3746         iPad behavior. It's expected that apps with legacy content would be doing this
3747         anyway.
3748
3749         Tests: fast/text-autosizing/ios/idempotentmode/idempotent-percentage.html
3750                TestWebKitAPI.PreferredContentMode.IdempotentModeAutosizingOnlyHonorsPercentages
3751
3752         * loader/DocumentLoader.cpp:
3753         (WebCore::DocumentLoader::applyPoliciesToSettings):
3754         * loader/DocumentLoader.h:
3755         (WebCore::DocumentLoader::setIdempotentModeAutosizingOnlyHonorsPercentages):
3756         (WebCore::DocumentLoader::idempotentModeAutosizingOnlyHonorsPercentages const):
3757         * page/Settings.yaml:
3758         * style/StyleAdjuster.cpp:
3759         (WebCore::Style::Adjuster::adjustmentForTextAutosizing):
3760         * style/StyleBuilderCustom.h:
3761         (WebCore::Style::computeBaseSpecifiedFontSize):
3762         * style/StyleBuilderState.cpp:
3763         (WebCore::Style::BuilderState::updateFontForTextSizeAdjust):
3764
3765 2020-05-20  ChangSeok Oh  <changseok@webkit.org>
3766
3767         Move the TextStream logging definition in VisibleSelection.cpp to the outside of the TREE_DEBUGGING guard
3768         https://bugs.webkit.org/show_bug.cgi?id=212127
3769
3770         Reviewed by Simon Fraser.
3771
3772         A linking failure occurs after r261819 where ENABLE_TREE_DEBUGGING is disabled.
3773         The TextStream logging defining is placed inside the guard while its declaration is not since r218976.
3774
3775         Build fix, no functionality changed.
3776
3777         * editing/VisibleSelection.cpp:
3778         (WebCore::operator<<):
3779
3780 2020-05-20  Andres Gonzalez  <andresg_22@apple.com>
3781
3782         Fix for accessibility-node-memory-management.html in isolated tree mode.
3783         https://bugs.webkit.org/show_bug.cgi?id=212142
3784
3785         Reviewed by Chris Fleizach.
3786
3787         LayoutTests/accessibility/accessibility-node-memory-management.html.
3788
3789         - Fix in applyPendingChanges that was not removing removed nodes from
3790         the nodes map. This was causing that some detached AXIsolatedObjects
3791         were being returned.
3792         - Also handle the case where pending changes can come from a detached
3793         AXObject with invalid ID and no platform wrapper.
3794         - updateChildren better handles the case when the notification target
3795         is not in the isolated tree by walking up the object hierarchy until it
3796         finds an associated object that does have a corresponding isolated object.
3797
3798         * accessibility/isolatedtree/AXIsolatedTree.cpp:
3799         (WebCore::AXIsolatedTree::treeForPageID):
3800         (WebCore::AXIsolatedTree::updateChildren):
3801         (WebCore::AXIsolatedTree::applyPendingChanges):
3802
3803 2020-05-20  Antoine Quint  <graouts@apple.com>
3804
3805         [Web Animations] Animation engine should not wake up every tick for steps timing functions
3806         https://bugs.webkit.org/show_bug.cgi?id=212103
3807         <rdar://problem/62737868>
3808
3809         Unreviewed. Clean up some stray FIXMEs mistakenly commited in the previous commit.
3810
3811         * animation/AnimationTimeline.cpp:
3812         (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty):
3813         * style/StyleTreeResolver.cpp:
3814         (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
3815
3816 2020-05-20  Antoine Quint  <graouts@apple.com>
3817
3818         [Web Animations] Animation engine should not wake up every tick for steps timing functions
3819         https://bugs.webkit.org/show_bug.cgi?id=212103
3820         <rdar://problem/62737868>
3821
3822         Reviewed by Simon Fraser.
3823
3824         Tests: webanimations/scheduling-of-animation-with-steps-timing-function-on-effect.html
3825                webanimations/scheduling-of-animation-with-steps-timing-function-on-keyframe.html
3826                webanimations/scheduling-of-css-animation-with-explicit-steps-timing-function-on-some-keyframes.html
3827                webanimations/scheduling-of-css-animation-with-implicit-steps-timing-function.html
3828
3829         When an animation uses a steps() timing function, it will appear to animate discretely between values such
3830         that there is only n visual changes, where n is the number of steps provided. This gives us an opportunity
3831         to be more efficient when scheduling animations using steps() timing functions.
3832
3833         In WebAnimation::timeToNextTick() we now ask the associated effect for the amount of progress until the next
3834         step. For an effect-wide steps() timing function, we can use the provided iteration progress. For animations
3835         with a linear effect-wide timing function (the default), we have to map the provided iteration progress to
3836         a keyframe interval, provided that interval uses a steps() timing function.
3837
3838         The new {Animation|Keyframe}Effect::progressUntilNextStep() method returns WTF::nullopt for any other case.
3839
3840         In order to test this, we add a new internals.timeToNextAnimationTick(animation) method which we use in the
3841         two new tests.
3842
3843         * animation/AnimationEffect.cpp:
3844         (WebCore::AnimationEffect::progressUntilNextStep const):
3845         * animation/AnimationEffect.h:
3846         * animation/KeyframeEffect.cpp:
3847         (WebCore::KeyframeEffect::setBlendingKeyframes):
3848         (WebCore::KeyframeEffect::computeSomeKeyframesUseStepsTimingFunction):
3849         (WebCore::KeyframeEffect::timingFunctionForKeyframeAtIndex const): Avoid any out-of-bounds use of the underlying data
3850         structures by returning nullptr for cases where we don't have an explicit keyframe. We also make the function const
3851         such that it may be called from progressUntilNextStep(), it always was const but wasn't marked as such.
3852         (WebCore::KeyframeEffect::progressUntilNextStep const):
3853         * animation/KeyframeEffect.h:
3854         * animation/WebAnimation.cpp:
3855         (WebCore::WebAnimation::timeToNextTick const):
3856         * animation/WebAnimation.h:
3857         * animation/WebAnimation.idl:
3858         * testing/Internals.cpp:
3859         (WebCore::Internals::timeToNextAnimationTick const):
3860         * testing/Internals.h:
3861         * testing/Internals.idl:
3862
3863 2020-05-20  Noam Rosenthal  <noam@webkit.org>
3864
3865         Fix table sizing when 'max-width' is used
3866         https://bugs.webkit.org/show_bug.cgi?id=115156
3867
3868         Reviewed by Zalan Bujtas.
3869
3870         Based on previous patch by László Langó  <lango@inf.u-szeged.hu>
3871
3872         Test: fast/table/html-table-width-max-width-constrained.html
3873
3874         A table should always be wide enough to contain its content (preferred logical width).
3875         This constraint should be stronger than the table style's specified min-width/width.
3876
3877         The behavior matches the spec, and behavior on Firefox/Chrome.
3878
3879         * rendering/RenderTable.cpp:
3880         (WebCore::RenderTable::updateLogicalWidth):
3881                 Max-width should only affect the table's max preferred width.
3882
3883         (WebCore::RenderTable::computePreferredLogicalWidths):
3884                 Change the order of constraints so that content constraint is stronger than style width/max-width constraint.
3885
3886 2020-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
3887
3888         REGRESSION(r261554): [GTK] Version 2.29.1 crashes using drag-n-drop API
3889         https://bugs.webkit.org/show_bug.cgi?id=212136
3890
3891         Reviewed by Adrian Perez de Castro.
3892
3893         * platform/gtk/PasteboardGtk.cpp:
3894         (WebCore::Pasteboard::read): Use m_selectionData if present.
3895
3896 2020-05-20  Philippe Normand  <pnormand@igalia.com>
3897
3898         [GStreamer] <img> tag needs to support video formats
3899         https://bugs.webkit.org/show_bug.cgi?id=180370
3900
3901         Reviewed by Xabier Rodriguez-Calvar.
3902
3903         GStreamer implementation of the ImageDecoder. It currently doesn't support zero-copy
3904         rendering though due to the the NativeImagePtr requirement.
3905
3906         * platform/GStreamer.cmake:
3907         * platform/MIMETypeRegistry.cpp:
3908         (WebCore::MIMETypeRegistry::isSupportedImageVideoOrSVGMIMEType):
3909         * platform/graphics/ImageDecoder.cpp:
3910         (WebCore::ImageDecoder::create):
3911         (WebCore::ImageDecoder::supportsMediaType):
3912         * platform/graphics/gstreamer/ImageDecoderGStreamer.cpp: Added.
3913         (WebCore::toSample):
3914         (WebCore::ImageDecoderGStreamer::create):
3915         (WebCore::ImageDecoderGStreamer::ImageDecoderGStreamer):
3916         (WebCore::ImageDecoderGStreamer::supportsContainerType):
3917         (WebCore::ImageDecoderGStreamer::canDecodeType):
3918         (WebCore::ImageDecoderGStreamer::encodedDataStatus const):
3919         (WebCore::ImageDecoderGStreamer::size const):
3920         (WebCore::ImageDecoderGStreamer::repetitionCount const):
3921         (WebCore::ImageDecoderGStreamer::uti const):
3922         (WebCore::ImageDecoderGStreamer::frameOrientationAtIndex const):
3923         (WebCore::ImageDecoderGStreamer::frameDurationAtIndex const):
3924         (WebCore::ImageDecoderGStreamer::frameHasAlphaAtIndex const):
3925         (WebCore::ImageDecoderGStreamer::frameBytesAtIndex const):
3926         (WebCore::ImageDecoderGStreamer::createFrameImageAtIndex):
3927         (WebCore::ImageDecoderGStreamer::setData):
3928         (WebCore::ImageDecoderGStreamer::clearFrameBufferCache):
3929         (