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