fb600be334bc4b3a18dac2fb3b8a5fffd3dac1f4
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-12-19  Eric Carlson  <eric.carlson@apple.com>
2
3         [MediaStream] Clean up RealtimeMediaSource interfaces
4         https://bugs.webkit.org/show_bug.cgi?id=180934
5         <rdar://problem/36108648>
6
7         Reviewed by Youenn Fablet.
8
9         No new tests, updated http/tests/media/media-stream/disconnected-frame.html.
10         
11         Wrap video and audio constraints in a struct instead of passing both around as separate
12         parameters. Cleanup up the interface to RealTimeMediaSourceCenter.
13
14         * Modules/mediastream/MediaDevices.cpp:
15         (WebCore::MediaDevices::getUserMedia const):
16         * Modules/mediastream/MediaDevicesRequest.cpp:
17         (WebCore::MediaDevicesRequest::start):
18         * Modules/mediastream/UserMediaRequest.cpp:
19         (WebCore::UserMediaRequest::create):
20         (WebCore::UserMediaRequest::UserMediaRequest):
21         (WebCore::UserMediaRequest::start):
22         (WebCore::UserMediaRequest::allow):
23         (WebCore::UserMediaRequest::contextDestroyed):
24         * Modules/mediastream/UserMediaRequest.h:
25         (WebCore::UserMediaRequest::request const):
26         * WebCore.xcodeproj/project.pbxproj:
27         * platform/mediastream/CaptureDevice.h:
28         (WebCore::CaptureDevice::persistentId const):
29         (WebCore::CaptureDevice::label const):
30         (WebCore::CaptureDevice::groupId const):
31         (WebCore::CaptureDevice::type const):
32         (WebCore::CaptureDevice::setPersistentId): Deleted.
33         (WebCore::CaptureDevice::setLabel): Deleted.
34         (WebCore::CaptureDevice::setGroupId): Deleted.
35         (WebCore::CaptureDevice::setType): Deleted.
36         * platform/mediastream/CaptureDeviceManager.cpp:
37         (CaptureDeviceManager::getAudioSourcesInfo): Deleted.
38         (CaptureDeviceManager::getVideoSourcesInfo): Deleted.
39         (CaptureDeviceManager::deviceWithUID): Deleted.
40         * platform/mediastream/CaptureDeviceManager.h:
41         (WebCore::CaptureDeviceManager::captureDeviceWithPersistentID):
42         (WebCore::CaptureDeviceManager::refreshCaptureDevices):
43         * platform/mediastream/MediaStreamRequest.h: Copied from Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDevice.mm.
44         (WebCore::MediaStreamRequest::encode const):
45         (WebCore::MediaStreamRequest::decode):
46         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
47         (WebCore::RealtimeMediaSourceCenter::createMediaStream):
48         (WebCore::RealtimeMediaSourceCenter::getMediaStreamDevices):
49         (WebCore::RealtimeMediaSourceCenter::validateRequestConstraints):
50         (WebCore::RealtimeMediaSourceCenter::captureDeviceWithPersistentID):
51         * platform/mediastream/RealtimeMediaSourceCenter.h:
52         * platform/mediastream/RealtimeMediaSourceSettings.h:
53         * platform/mediastream/ios/AVAudioSessionCaptureDevice.mm:
54         (WebCore::AVAudioSessionCaptureDevice::AVAudioSessionCaptureDevice):
55         * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h:
56         * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm:
57         (WebCore::AVAudioSessionCaptureDeviceManager::captureDevices):
58         (WebCore::AVAudioSessionCaptureDeviceManager::captureDeviceWithPersistentID):
59         * platform/mediastream/mac/AVCaptureDeviceManager.h:
60         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
61         (WebCore::AVCaptureDeviceManager::captureDevicesInternal):
62         (WebCore::AVCaptureDeviceManager::captureDevices):
63         (WebCore::AVCaptureDeviceManager::refreshAVCaptureDevicesOfType):
64         (WebCore::AVCaptureDeviceManager::refreshCaptureDevices):
65         (WebCore::AVCaptureDeviceManager::deviceDisconnected):
66         (WebCore::AVCaptureDeviceManager::getAudioSourcesInfo): Deleted.
67         (WebCore::AVCaptureDeviceManager::getVideoSourcesInfo): Deleted.
68         * platform/mediastream/mac/CoreAudioCaptureDevice.cpp:
69         (WebCore::CoreAudioCaptureDevice::CoreAudioCaptureDevice):
70         * platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:
71         (WebCore::CoreAudioCaptureDeviceManager::captureDevices):
72         (WebCore::CoreAudioCaptureDeviceManager::captureDeviceWithPersistentID):
73         (WebCore::CoreAudioCaptureDeviceManager::refreshAudioCaptureDevices):
74         * platform/mediastream/mac/CoreAudioCaptureDeviceManager.h:
75         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
76         * platform/mock/MockRealtimeAudioSource.cpp:
77         (WebCore::MockRealtimeAudioSource::startProducingData):
78         (WebCore::MockRealtimeAudioSource::createMuted): Deleted.
79         * platform/mock/MockRealtimeAudioSource.h:
80         * platform/mock/MockRealtimeMediaSource.cpp:
81         (WebCore::deviceMap):
82         (WebCore::MockRealtimeMediaSource::captureDeviceWithPersistentID):
83         (WebCore::MockRealtimeMediaSource::audioDevices):
84         (WebCore::MockRealtimeMediaSource::videoDevices):
85         (WebCore::MockRealtimeMediaSource::MockRealtimeMediaSource):
86         * platform/mock/MockRealtimeMediaSource.h:
87         (WebCore::MockRealtimeMediaSource::device const):
88         (WebCore::MockRealtimeMediaSource::deviceIndex): Deleted.
89         * platform/mock/MockRealtimeMediaSourceCenter.h:
90         * platform/mock/MockRealtimeVideoSource.cpp:
91         (WebCore::MockRealtimeVideoSource::MockRealtimeVideoSource):
92         (WebCore::MockRealtimeVideoSource::initializeCapabilities):
93         (WebCore::MockRealtimeVideoSource::generateFrame):
94         (WebCore::MockRealtimeVideoSource::createMuted): Deleted.
95         * platform/mock/MockRealtimeVideoSource.h:
96
97 2017-12-19  Ryosuke Niwa  <rniwa@webkit.org>
98
99         Don't convert pasted content to use blob URL in WebKit1
100         https://bugs.webkit.org/show_bug.cgi?id=180969
101
102         Reviewed by Wenson Hsieh.
103
104         Turns out that some WebKit1 clients are relying on being able to see the original URLs of the pasted content;
105         e.g. not storing content referenced by HTTP/HTTPS protocol as opposed to local files.
106
107         This patch restores the behavior prior to r223440 and r222839 for WebKit1 clients by overriding resources in
108         DocumentLoader instead of converting URLs used in the pasted contents by blob URLs. In addition, this patch
109         disables the pasteboard sanitization and custom data transfer types for WebKit1 clients as the feature poses
110         a compatibility concern for WebKit1 clients.
111
112         Tests: WebKitLegacy.AccessingImageInPastedRTFD
113                WebKitLegacy.AccessingImageInPastedWebArchive
114
115         * editing/cocoa/WebContentReaderCocoa.mm:
116         (WebCore::createFragmentAndAddResources):
117         (WebCore::WebContentReader::readWebArchive):
118         * page/DeprecatedGlobalSettings.cpp:
119         (WebCore::DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled):
120
121 2017-12-19  Jer Noble  <jer.noble@apple.com>
122
123         Playing media elements which call "pause(); play()" will have the play promise rejected.
124         https://bugs.webkit.org/show_bug.cgi?id=180781
125         <rdar://problem/33191377>
126
127         Reviewed by Eric Carlson.
128
129         Follow-up to address failing iOS API tests. Rather than skipping the call to
130         prepareForLoad() in the case where media elements are not allowed to load data,
131         unconditionally call prepareForLoad(), but conditionally call selectMediaResource() inside
132         that function only if the media elemnet is allowed to load. This ensures that the
133         MediaPlayer is created when play(), pause(), or load() are called during a user gesture
134         later, and selectMediaResource() (which depends on having a non-null m_player) is called.
135
136         * html/HTMLMediaElement.cpp:
137         (WebCore::HTMLMediaElement::parseAttribute):
138         (WebCore::HTMLMediaElement::insertedIntoAncestor):
139         (WebCore::HTMLMediaElement::load):
140         (WebCore::HTMLMediaElement::prepareForLoad):
141         (WebCore::HTMLMediaElement::playInternal):
142
143 2017-12-19  Timothy Hatcher  <timothy@hatcher.name>
144
145         Build failure in WebGL2 when Video feature is disabled
146         https://bugs.webkit.org/show_bug.cgi?id=180946
147
148         Reviewed by Brian Burg.
149
150         * html/canvas/WebGL2RenderingContext.h: Make TexImageSource conditional on ENABLE(VIDEO).
151         * html/canvas/WebGL2RenderingContext.idl: Ditto.
152
153 2017-12-19  Chris Dumez  <cdumez@apple.com>
154
155         scopeURL should start with the provided scriptURL
156         https://bugs.webkit.org/show_bug.cgi?id=180983
157
158         Reviewed by Youenn Fablet.
159
160         scopeURL should start with the provided scriptURL, as per:
161         - https://w3c.github.io/ServiceWorker/#update (steps 7.8 to 7.18)
162
163         No new tests, rebaselined existing tests.
164
165         * platform/network/HTTPHeaderNames.in:
166         * workers/service/ServiceWorkerJob.cpp:
167         (WebCore::ServiceWorkerJob::didReceiveResponse):
168
169 2017-12-19  Zalan Bujtas  <zalan@apple.com>
170
171         [RenderTreeBuilder] Move finding-the-parent/creating-wrapper logic from RenderTableSection::addChild to RenderTreeBuilder
172         https://bugs.webkit.org/show_bug.cgi?id=180994
173         <rdar://problem/36139222>
174
175         Reviewed by Antti Koivisto.
176
177         This is in preparation for removing all tree mutation from renderering code.
178
179         Covered by existing tests.
180
181         * rendering/RenderTableSection.cpp:
182         (WebCore::RenderTableSection::addChild):
183         * rendering/updating/RenderTreeBuilder.cpp:
184         (WebCore::RenderTreeBuilder::insertChild):
185         * rendering/updating/RenderTreeBuilderTable.cpp:
186         (WebCore::RenderTreeBuilder::Table::findOrCreateParentForChild):
187         * rendering/updating/RenderTreeBuilderTable.h:
188
189 2017-12-19  Daniel Bates  <dabates@apple.com>
190
191         Implement InlineTextBox painting using marker subranges
192         https://bugs.webkit.org/show_bug.cgi?id=180984
193         <rdar://problem/36139364>
194
195         Reviewed by David Hyatt.
196
197         As a step towards implementing CSS Pseudo-Elements Module Level 4, explicitly decompose a
198         text line into subrange objects that may be styled (say, to give the appearance of selected
199         text) and painted.
200
201         No functionality changed. So, no new tests.
202
203         * rendering/InlineTextBox.cpp:
204         (WebCore::InlineTextBox::localSelectionRect const): Update comments.
205
206         (WebCore::InlineTextBox::MarkerSubrangeStyle::operator== const):
207         (WebCore::InlineTextBox::MarkerSubrangeStyle::operator!= const):
208         (WebCore::InlineTextBox::StyledMarkerSubrange::StyledMarkerSubrange):
209         Define a subclass to represent a marker subrange that has associated style information.
210         We will make use of the style information when painting the subrange.
211
212         (WebCore::createMarkerSubrangeFromSelectionInBox): Convenience function to instantiate a
213         MarkerSubrange instance from the current selection of a specified text box.
214
215         (WebCore::InlineTextBox::paint): Write in terms of MarkerSubrange. We keep composition backgrounds
216         and composition underlines as special cases for now. We represent all other subranges of the line
217         as MarkerSubrange instances, including unmarked text (i.e. non-selected text without an associated
218         document marker). The subranges for the gaps between document markers and selection are implicitly
219         created by subdividing the entire line. Support for PaintBehaviorExcludeSelection is implemented
220         by subdividing the entire line with the selection subrange and then removing the selection subrange
221         from the resulting list of subdivisions before painting with the resulting list.
222
223         (WebCore::InlineTextBox::paintPlatformDocumentMarkers): Renamed; formerly named paintDocumentMarkers.
224         (WebCore::InlineTextBox::paintPlatformDocumentMarker): Renamed; formerly named paintDocumentMarker.
225
226         (WebCore::InlineTextBox::computeStyleForUnmarkedMarkerSubrange const): Convenience function to
227         compute the style for unmarked text.
228
229         (WebCore::InlineTextBox::resolveStyleForSubrange): Added
230
231         (WebCore::InlineTextBox::subdivideAndResolveStyle): Subdivides the list of marker subranges and
232         coalesces subranges of the same type (e.g. selection) or with the same style. The latter strategy
233         preserves the optimization of drawing the text of the entire line in one draw command when we know
234         that the selected text looks identical to non-selected text. This optimization was performed in TextPainter::paint().
235
236         (WebCore::InlineTextBox::collectSubrangesForDraggedContent): Added.
237         (WebCore::InlineTextBox::collectSubrangesForDocumentMarkers): Added.
238         (WebCore::InlineTextBox::textOriginFromBoxRect const): Added.
239
240         (WebCore::InlineTextBox::paintMarkerSubranges):
241         (WebCore::InlineTextBox::paintTextSubrangeBackground):
242         (WebCore::InlineTextBox::paintTextSubrangeForeground):
243         (WebCore::InlineTextBox::paintTextSubrangeDecoration):
244         Paint the marker subrange.
245
246         (WebCore::InlineTextBox::paintCompositionBackground): Moved function to group it with the logic to
247         paint composition underlines. Modified to pass clamped offsets to paintTextSubrangeBackground() as
248         paintTextSubrangeBackground() now expects them.
249
250         (WebCore::mirrorRTLSegment): Moved function to be above paintCompositionUnderline() as it is the only
251         function that makes use of it.
252
253         (WebCore::InlineTextBox::paintSelection): Deleted.
254         (WebCore::InlineTextBox::paintTextMatchMarker): Deleted.
255         (WebCore::InlineTextBox::paintDecoration): Deleted.
256         (WebCore::InlineTextBox::paintDocumentMarker): Deleted; renamed to paintPlatformDocumentMarker.
257         (WebCore::InlineTextBox::paintDocumentMarkers): Deleted; renamed to paintPlatformDocumentMarkers.
258         * rendering/InlineTextBox.h:
259         (WebCore::InlineTextBox::paintMarkerSubranges): Added.
260         * rendering/MarkerSubrange.h:
261         (WebCore::MarkerSubrange::isEmpty const): Added.
262         (WebCore::MarkerSubrange::operator!= const): Added.
263         (WebCore::MarkerSubrange::operator== const): Added.
264         * rendering/SimpleLineLayoutFunctions.cpp:
265         (WebCore::SimpleLineLayout::paintFlow): Updated code as we no longer need to pass the text run length
266         to TextPainter::paint(). Also modernize the code while I am here.
267         * rendering/TextDecorationPainter.cpp:
268         (WebCore::TextDecorationPainter::Styles::operator== const): Added.
269         (WebCore::TextDecorationPainter::TextDecorationPainter): Modified to take an optional TextDecorationPainter::Styles
270         instance as an argument and removed the unused parameter for PseudoId.
271         * rendering/TextDecorationPainter.h:
272         (WebCore::TextDecorationPainter::Styles::operator!= const): Added.
273         * rendering/TextPaintStyle.cpp:
274         (WebCore::TextPaintStyle::operator== const): Added.
275         (WebCore::computeTextSelectionPaintStyle): Removed the now unused out-arguments paintSelectedTextOnly, paintSelectedTextSeparately,
276         and paintNonSelectedTextOnly. The values stored in these out-arguments were intended to be used by the caller to
277         minimize the number of drawing commands. The value of paintSelectedTextSeparately indicated whether selected text
278         would look identical to non-selected text so that a caller could use one paint command to draw the entire line
279         instead of issuing two or more drawing commands to paint non-selected and selected text separately. We now
280         accomplish the same optimization by coalescing subrange styles in InlineTextBox::subdivideAndResolveStyle().
281         The value of paintNonSelectedTextOnly, as its name states, indicated whether a caller should only paint non-selected
282         text and hence skip painting of selected text. This value was only used when painting dragged content (i.e. DocumentMarker::DraggedContent
283         markers) and its effect is now more directly achieved by the dragged content logic in InlineTextBox::paint().
284         * rendering/TextPaintStyle.h:
285         (WebCore::TextPaintStyle::operator!= const): Added.
286         * rendering/TextPainter.cpp:
287         (WebCore::TextPainter::paint): Implemented in terms TextPainter::paintRange() now that InlineTextBox::paint() optimizes
288         for the number of drawing calls. See remarks for WebCore::computeTextSelectionPaintStyle() for more details.
289         * rendering/TextPainter.h: Group together related member functions.
290         (WebCore::TextPainter::setSelectionStyle): Deleted.
291         (WebCore::TextPainter::setSelectionShadow): Deleted.
292
293 2017-12-19  Daniel Bates  <dabates@apple.com>
294
295         Add support for computing the frontmost longest effective marker subrange
296         https://bugs.webkit.org/show_bug.cgi?id=180985
297
298         Reviewed by Dave Hyatt.
299
300         Add a new subdivision overlap strategy to return the minimum list of maximal length non-
301         overlapping subranges. We will make use of this strategy together with an algorithm to
302         coalesce adjacent subranges with visually indistinct styles to minimize the total number
303         of drawing commands needed to paint an entire line of text. We are not making use of
304         this functionality now. We will make use of it to simplify the patch for <https://bugs.webkit.org/show_bug.cgi?id=180984>.
305
306         * rendering/MarkerSubrange.cpp:
307         (WebCore::subdivide):
308         * rendering/MarkerSubrange.h:
309
310 2017-12-19  Chris Dumez  <cdumez@apple.com>
311
312         Handle Fetch should wait for the service worker's state to become activated
313         https://bugs.webkit.org/show_bug.cgi?id=180959
314
315         Reviewed by Youenn Fablet.
316
317         Handle Fetch should wait for the service worker's state to become activated when
318         it is currently activating.
319
320         Specification:
321         - https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm (Step 16)
322
323         No new tests, rebaselined existing test.
324
325         * workers/service/server/SWServerWorker.cpp:
326         (WebCore::SWServerWorker::~SWServerWorker):
327         (WebCore::SWServerWorker::whenActivated):
328         (WebCore::SWServerWorker::setState):
329         (WebCore::SWServerWorker::callWhenActivatedHandler):
330         * workers/service/server/SWServerWorker.h:
331
332 2017-12-19  Yusuke Suzuki  <utatane.tea@gmail.com>
333
334         [YARR] Yarr should return ErrorCode instead of error messages (const char*)
335         https://bugs.webkit.org/show_bug.cgi?id=180966
336
337         Reviewed by Mark Lam.
338
339         Remove unnecessary String creation.
340
341         No behavior change.
342
343         * contentextensions/URLFilterParser.cpp:
344         (WebCore::ContentExtensions::URLFilterParser::addPattern):
345
346 2017-12-19  Zalan Bujtas  <zalan@apple.com>
347
348         [RenderTreeBuilder] Move finding-the-parent/creating-wrapper logic from RenderTableRow::addChild to RenderTreeBuilder
349         https://bugs.webkit.org/show_bug.cgi?id=180964
350         <rdar://problem/36123315>
351
352         Reviewed by Antti Koivisto.
353
354         This is in preparation for removing all tree mutation from renderering code.
355
356         Covered by existing tests.
357
358         * Sources.txt:
359         * WebCore.xcodeproj/project.pbxproj:
360         * rendering/RenderTableRow.cpp:
361         (WebCore::RenderTableRow::addChild):
362         * rendering/updating/RenderTreeBuilder.cpp:
363         (WebCore::RenderTreeBuilder::insertChild):
364         * rendering/updating/RenderTreeBuilder.h:
365         * rendering/updating/RenderTreeBuilderTable.cpp: Added.
366         (WebCore::RenderTreeBuilder::Table::findOrCreateParentForChild):
367         * rendering/updating/RenderTreeBuilderTable.h: Copied from Source/WebCore/rendering/updating/RenderTreeBuilder.h.
368
369 2017-12-19  Youenn Fablet  <youenn@apple.com>
370
371         Service Worker should not clean HTTP headers added by the application or by fetch specification before service worker interception
372         https://bugs.webkit.org/show_bug.cgi?id=180939
373
374         Reviewed by Chris Dumez.
375
376         Covered by modified WPT test.
377
378         Add support to clean only specific headers in cleanHTTPRequestHeadersForAccessControl,
379         renamed from cleanRedirectedRequestForAccessControl.
380         Compute the list of headers to keep in DocumentThreadableLoader.
381         Add a specific rule for Accept header which is set prior service worker interception and for
382         HTTP headers set by DocumentThreadableLoader clients.
383
384         * loader/CrossOriginAccessControl.cpp:
385         (WebCore::httpHeadersToKeepFromCleaning):
386         (WebCore::cleanRedirectedRequestForAccessControl):
387         * loader/CrossOriginAccessControl.h:
388         (WebCore::cleanRedirectedRequestForAccessControl):
389         * loader/DocumentThreadableLoader.cpp:
390         (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
391         * loader/ResourceLoaderOptions.h:
392         * workers/service/context/ServiceWorkerFetch.cpp:
393         (WebCore::ServiceWorkerFetch::dispatchFetchEvent):
394         * workers/service/context/ServiceWorkerFetch.h:
395         * workers/service/context/ServiceWorkerThread.cpp:
396         (WebCore::ServiceWorkerThread::postFetchTask):
397         * workers/service/context/ServiceWorkerThread.h:
398
399 2017-12-19  Andy Estes  <aestes@apple.com>
400
401         [Apple Pay] Stop maintaining a list of payment networks
402         https://bugs.webkit.org/show_bug.cgi?id=180965
403         <rdar://problem/34696560>
404
405         Reviewed by Tim Horton.
406
407         Instead of maintaining the list of valid payment networks in WebCore, allow the client to
408         provide the list when constructing a PaymentCoordinator. Then, use PaymentCoordinator's list
409         to validate ApplePaySessionPaymentRequests.
410
411         Validation will now be done case-insensitively since Cocoa clients will provide a list of
412         network names that differ in capitalization from the names formerly accepted by WebCore.
413
414         Added new test cases to http/tests/ssl/applepay/ApplePaySession.html.
415
416         * Modules/applepay/ApplePayRequestBase.cpp:
417         (WebCore::convertAndValidate): Changed to return a Vector of validated strings.
418         (WebCore::validate): Renamed to convertAndValidate.
419         * Modules/applepay/ApplePayRequestBase.h:
420         * Modules/applepay/ApplePaySession.cpp:
421         (WebCore::convertAndValidate):
422         (WebCore::ApplePaySession::create):
423         * Modules/applepay/ApplePaySessionPaymentRequest.cpp:
424         (WebCore::ApplePaySessionPaymentRequest::isValidSupportedNetwork): Deleted.
425         * Modules/applepay/ApplePaySessionPaymentRequest.h:
426         * Modules/applepay/PaymentCoordinator.cpp:
427         (WebCore::toHashSet):
428         (WebCore::PaymentCoordinator::PaymentCoordinator): Converted availablePaymentNetworks to a
429         case-insensitive HashSet and stored in m_availablePaymentNetworks.
430         (WebCore::PaymentCoordinator::validatedPaymentNetwork const): Added special cases for "jcb"
431         and "carteBancaire" for API compatibility. For other networks, checked m_availablePaymentNetworks.
432         * Modules/applepay/PaymentCoordinator.h:
433         * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
434         (WebCore::ApplePayPaymentHandler::show):
435         * page/MainFrame.cpp:
436         (WebCore::MainFrame::MainFrame): Constructed m_paymentCoordinator with configuration.availablePaymentNetworks.
437         * page/PageConfiguration.h:
438         * testing/Internals.cpp:
439         (WebCore::Internals::Internals):
440         * testing/MockPaymentCoordinator.cpp:
441         * testing/MockPaymentCoordinator.h:
442
443 2017-12-19  Wenson Hsieh  <wenson_hsieh@apple.com>
444
445         Unreviewed, try to fix the Windows build after r226097.
446
447         * editing/markup.cpp:
448         (WebCore::StyledMarkupAccumulator::appendCustomAttributes):
449
450 2017-12-18  Andy Estes  <aestes@apple.com>
451
452         [Apple Pay] Only include phonetic name properties in ApplePayPaymentContact when version >= 3
453         https://bugs.webkit.org/show_bug.cgi?id=180925
454         <rdar://problem/35907596>
455
456         Reviewed by Tim Horton.
457
458         No tests possible. The fix involves converting PKContacts, which we can't create in our test harness.
459
460         * Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp:
461         (WebCore::ApplePayPaymentAuthorizedEvent::ApplePayPaymentAuthorizedEvent):
462         * Modules/applepay/ApplePayPaymentAuthorizedEvent.h:
463         * Modules/applepay/ApplePaySession.cpp:
464         (WebCore::ApplePaySession::create):
465         (WebCore::ApplePaySession::ApplePaySession):
466         (WebCore::ApplePaySession::version const):
467         (WebCore::ApplePaySession::didAuthorizePayment):
468         (WebCore::ApplePaySession::didSelectShippingContact):
469         * Modules/applepay/ApplePaySession.h:
470         * Modules/applepay/ApplePayShippingContactSelectedEvent.cpp:
471         (WebCore::ApplePayShippingContactSelectedEvent::ApplePayShippingContactSelectedEvent):
472         * Modules/applepay/ApplePayShippingContactSelectedEvent.h:
473         * Modules/applepay/Payment.h:
474         * Modules/applepay/PaymentContact.h:
475         * Modules/applepay/PaymentCoordinator.cpp:
476         (WebCore::PaymentCoordinator::supportsVersion const):
477         (WebCore::PaymentCoordinator::supportsVersion): Deleted.
478         * Modules/applepay/PaymentCoordinator.h:
479         * Modules/applepay/PaymentSession.h:
480         * Modules/applepay/cocoa/PaymentCocoa.mm:
481         (WebCore::convert):
482         (WebCore::Payment::toApplePayPayment const):
483         * Modules/applepay/cocoa/PaymentContactCocoa.mm:
484         (WebCore::convert):
485         (WebCore::PaymentContact::toApplePayPaymentContact const):
486         * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
487         (WebCore::ApplePayPaymentHandler::document const):
488         (WebCore::ApplePayPaymentHandler::paymentCoordinator const):
489         (WebCore::ApplePayPaymentHandler::version const):
490         (WebCore::ApplePayPaymentHandler::didAuthorizePayment):
491         (WebCore::ApplePayPaymentHandler::didSelectShippingContact):
492         (WebCore::ApplePayPaymentHandler::document): Deleted.
493         (WebCore::ApplePayPaymentHandler::paymentCoordinator): Deleted.
494         * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
495
496 2017-12-18  Wenson Hsieh  <wenson_hsieh@apple.com>
497
498         [Attachment Support] The 'webkitattachmentbloburl' attribute should not persist after markup serialization
499         https://bugs.webkit.org/show_bug.cgi?id=180924
500         <rdar://problem/36099093>
501
502         Reviewed by Tim Horton.
503
504         Work towards dragging Blob-backed attachment elements as files on iOS and Mac. It doesn't make sense for the
505         attachment blob URL to stick around on the element after markup serialization, so this patch removes logic that
506         eagerly sets the blob URL upon setting an attachment's File. Instead, we just append this attribute when
507         generating markup.
508
509         This patch also augments existing WKAttachmentTests to ensure that these attributes are not present.
510
511         * editing/markup.cpp:
512         (WebCore::StyledMarkupAccumulator::appendCustomAttributes):
513         (WebCore::createFragmentFromMarkup):
514         * html/HTMLAttachmentElement.cpp:
515         (WebCore::HTMLAttachmentElement::setFile):
516         * rendering/HitTestResult.cpp:
517
518         Fixes a related issue where an attachment is backed by Blob data (and not a file path) would specify "file:///"
519         as its attachment file path in DragController when starting a drag. Instead, if there is no file path, fall back
520         to the blob URL.
521
522         This will be tested in a future patch once a WK2 dragging simulator for Mac is implemented, and support for
523         dragging out Blob-backed attachments as (platform) files is implemented.
524
525         (WebCore::HitTestResult::absoluteAttachmentURL const):
526
527 2017-12-18  Chris Dumez  <cdumez@apple.com>
528
529         Default scope used when registering a service worker is wrong
530         https://bugs.webkit.org/show_bug.cgi?id=180961
531
532         Reviewed by Youenn Fablet.
533
534         The default scope we used when registering a service worker was wrong, it did not match:
535         - https://w3c.github.io/ServiceWorker/#start-register (Step 4)
536
537         This patch aligns our behavior with the specification.
538
539         No new tests, rebaselined existing test.
540
541         * workers/service/ServiceWorkerContainer.cpp:
542         (WebCore::ServiceWorkerContainer::addRegistration):
543
544 2017-12-18  Ryosuke Niwa  <rniwa@webkit.org>
545
546         Assertion hit in DocumentOrderedMap::get while removing a form element
547         https://bugs.webkit.org/show_bug.cgi?id=137959
548         <rdar://problem/27702012>
549
550         Reviewed by Brent Fulgham.
551
552         The assertion failure was caused by FormAssociatedElement::findAssociatedForm calling TreeScope::getElementById
553         for a form associated element inside FormAttributeTargetObserver::idTargetChanged during the removal of
554         the owner form element, or the first non-form element with the matching ID. If there are other elements with
555         the same ID in the removed tree at that moment, MapEntry's count for the ID can be higher than it needs to be
556         since Element::removedFromAncestor has not been called on those elements yet.
557
558         Fixed the bug by checking this condition explicitly. This patch introduces ContainerChildRemovalScope which
559         keeps track of the container node from which a subtree was removed as well as the root of the removed subtree.
560         DocumentOrderedMap::get then checks whether the matching element can be found in this removed subtree, and its
561         isConnected() still returns true (the evidence that Element::removedFromAncestor has not been called) when
562         count > 0 and there was no matching element in the tree scope.
563
564         In the long term, we should refactor the way FormAssociatedElement and HTMLFormElement refers to each other
565         and avoid calling DocumentOrderedMap::get before finish calling removedFromAncestor on the removed subtree.
566
567         Tests: fast/forms/update-form-owner-in-moved-subtree-assertion-failure-5.html
568                fast/forms/update-form-owner-in-moved-subtree-assertion-failure-6.html
569
570         * dom/ContainerNodeAlgorithms.cpp:
571         (WebCore::notifyChildNodeRemoved):
572         * dom/ContainerNodeAlgorithms.h:
573         (WebCore::ContainerChildRemovalScope): Added.
574         (WebCore::ContainerChildRemovalScope::ContainerChildRemovalScope):
575         (WebCore::ContainerChildRemovalScope::~ContainerChildRemovalScope):
576         (WebCore::ContainerChildRemovalScope::parentOfRemovedTree):
577         (WebCore::ContainerChildRemovalScope::removedChild):
578         (WebCore::ContainerChildRemovalScope::currentScope):
579         * dom/DocumentOrderedMap.cpp:
580         (WebCore::DocumentOrderedMap::get const): Added a special early exit when this function is called during
581         a node removal.
582
583 2017-12-18  Timothy Hatcher  <timothy@hatcher.name>
584
585         [GTK][WPE] Conditionalize libTASN1 use behind ENABLE_SUBTLE_CRYPTO in the CMake files
586         https://bugs.webkit.org/show_bug.cgi?id=180949
587
588         Reviewed by Carlos Alberto Lopez Perez.
589
590         * PlatformGTK.cmake: Move the include path and library additions to conditional ENABLE_SUBTLE_CRYPTO section.
591         * PlatformWPE.cmake: Ditto.
592
593 2017-12-18  Wenson Hsieh  <wenson_hsieh@apple.com>
594
595         [Attachment Support] Support representing pasted or dropped content using attachment elements
596         https://bugs.webkit.org/show_bug.cgi?id=180892
597         <rdar://problem/36064210>
598
599         Reviewed by Tim Horton.
600
601         Support dropping and pasting attributed strings that contain NSTextAttachments. Teaches
602         replaceRichContentWithAttachmentsIfNecessary to replace object elements with attachments; see comments below for
603         more details.
604
605         Test: WKAttachmentTests.InsertPastedAttributedStringContainingMultipleAttachments
606
607         * editing/WebContentReader.h:
608
609         Add BlobReplacementInfo, which contains a map of blob URLs to replacement Blobs, as well as a map of blob URLs
610         to replaced subresource URLs.
611
612         (WebCore::BlobReplacementInfo::isEmpty const):
613         * editing/cocoa/EditorCocoa.mm:
614         (WebCore::Editor::replaceSelectionWithAttributedString):
615         * editing/cocoa/WebArchiveResourceFromNSAttributedString.h:
616         * editing/cocoa/WebArchiveResourceFromNSAttributedString.mm:
617
618         Implement -[WebArchiveResourceFromNSAttributedString MIMEType]. UIFoundation asks for -MIMEType in the process
619         of generating markup from NSTextAttachments; this currently causes the web process to crash on an unrecognized
620         selector.
621
622         Additionally, work around <rdar://problem/36074429>, a UIFoundation bug in which all but a few hard-coded file
623         extensions actually yield MIME types that are more specific than "application/octet-stream". This can safely be
624         removed once <rdar://problem/36074429> is addressed.
625
626         (-[WebArchiveResourceFromNSAttributedString MIMEType]):
627         * editing/cocoa/WebContentReaderCocoa.mm:
628         (WebCore::replaceRichContentWithAttachmentsIfNecessary):
629
630         Try to replace object elements with attachments, and also tweak the title of the attachment's File to use the
631         replaced subresource's filename if possible. Additionally, abstracts out information for replacing object or
632         image elements (formerly a pair of { File, Element }) into a separate struct, and add a AttachmentDisplayMode
633         parameter to determine whether the attachment should be presented in-line (in the case of images), or as an icon.
634
635         (WebCore::attributesForAttributedStringConversion):
636
637         Only exclude object elements from being generated from NSTextAttachments if the attachment element runtime
638         feature is disabled, or !ENABLE(ATTACHMENT_ELEMENT).
639
640         (WebCore::createFragmentAndAddResources):
641
642         Additionally keep track of a mapping from blob URL => replaced subresource URL. In all the places where we
643         previously only plumbed a map of blob URL => Blob, use a BlobReplacementInfo struct instead, which now includes
644         a map from blob URL => replaced URL.
645
646         (WebCore::sanitizeMarkupWithArchive):
647         (WebCore::WebContentReader::readWebArchive):
648         (WebCore::WebContentMarkupReader::readWebArchive):
649         (WebCore::WebContentReader::readRTFD):
650         (WebCore::WebContentMarkupReader::readRTFD):
651         (WebCore::WebContentReader::readRTF):
652         (WebCore::WebContentMarkupReader::readRTF):
653         (WebCore::WebContentReader::readImage):
654
655 2017-12-18  Youenn Fablet  <youenn@apple.com>
656
657         Service worker served response tainting should keep its tainting
658         https://bugs.webkit.org/show_bug.cgi?id=180952
659
660         Reviewed by Chris Dumez.
661
662         Covered by rebased tests.
663
664         * loader/cache/CachedResource.cpp:
665         (WebCore::CachedResource::setResponse):
666
667 2017-12-18  Wenson Hsieh  <wenson_hsieh@apple.com>
668
669         Unreviewed, attempt to fix watch and TV builds after r226085
670
671         Explicitly include a header in WebContentReaderCocoa.mm.
672
673         * editing/cocoa/WebContentReaderCocoa.mm:
674
675 2017-12-18  Brady Eidson  <beidson@apple.com>
676
677         Add ability to API test Service Workers via a custom protocol.
678         https://bugs.webkit.org/show_bug.cgi?id=180911
679
680         Reviewed by Chris Dumez.
681
682         Covered by API test ServiceWorkers.Basic
683
684         This adds a set of "Service Workers can handle this" schemes to the scheme registry
685         and uses it for SW decisions instead of a handful of previous techniques.
686
687         * bindings/scripts/CodeGeneratorJS.pm:
688         (NeedsRuntimeCheck):
689         (GenerateRuntimeEnableConditionalString):
690         * bindings/scripts/IDLAttributes.json:
691
692         * dom/ScriptExecutionContext.cpp:
693         (WebCore::ScriptExecutionContext::hasServiceWorkerScheme):
694         * dom/ScriptExecutionContext.h:
695
696         * page/NavigatorServiceWorker.idl:
697
698         * platform/SchemeRegistry.cpp:
699         (WebCore::serviceWorkerSchemesLock):
700         (WebCore::serviceWorkerSchemes):
701         (WebCore::SchemeRegistry::registerURLSchemeServiceWorkersCanHandle):
702         (WebCore::SchemeRegistry::canServiceWorkersHandleURLScheme):
703         (WebCore::SchemeRegistry::isServiceWorkerContainerCustomScheme):
704         * platform/SchemeRegistry.h:
705
706         * workers/service/ServiceWorkerContainer.cpp:
707         (WebCore::ServiceWorkerContainer::addRegistration):
708
709         * workers/service/server/SWServerJobQueue.cpp:
710         (WebCore::SWServerJobQueue::runRegisterJob):
711
712 2017-12-18  Chris Dumez  <cdumez@apple.com>
713
714         We should use "error" redirect mode for fetching service worker scripts
715         https://bugs.webkit.org/show_bug.cgi?id=180950
716
717         Reviewed by Youenn Fablet.
718
719         We should use "error" redirect mode for fetching service worker scripts, as per:
720         - https://w3c.github.io/ServiceWorker/#update (Step 7.5)
721
722         No new tests, rebaselined existing test.
723
724         * loader/SubresourceLoader.cpp:
725         (WebCore::SubresourceLoader::willSendRequestInternal):
726         * workers/Worker.cpp:
727         (WebCore::Worker::create):
728         * workers/WorkerScriptLoader.cpp:
729         (WebCore::WorkerScriptLoader::loadAsynchronously):
730         * workers/WorkerScriptLoader.h:
731         * workers/service/ServiceWorkerJob.cpp:
732         (WebCore::ServiceWorkerJob::fetchScriptWithContext):
733
734 2017-12-18  Chris Dumez  <cdumez@apple.com>
735
736         ExtendableMessageEvent constructor fails to initialize the 'source' attribute
737         https://bugs.webkit.org/show_bug.cgi?id=180954
738
739         Reviewed by Youenn Fablet.
740
741         No new tests, rebaselined existing test.
742
743         * workers/service/ExtendableMessageEvent.cpp:
744         (WebCore::ExtendableMessageEvent::ExtendableMessageEvent):
745
746 2017-12-18  Wenson Hsieh  <wenson_hsieh@apple.com>
747
748         [Attachment Support] Insert images as inline attachments when pasting and dropping
749         https://bugs.webkit.org/show_bug.cgi?id=180853
750         <rdar://problem/35756268>
751
752         Reviewed by Tim Horton.
753
754         Adds support for transforming dropped and pasted web content fragments prior to insertion, such that inline
755         elements (so far, only images) are replaced with attachment elements that have an inline representation. See
756         below comments for more detail.
757
758         Tests: WKAttachmentTests.InsertPastedImageAsAttachment
759                WKAttachmentTests.InsertPastedAttributedStringContainingImage
760                WKAttachmentTestsMac.InsertPastedFileURLsAsAttachments
761                WKAttachmentTestsIOS.InsertDroppedImageAsAttachment
762                WKAttachmentTestsIOS.InsertDroppedAttributedStringContainingAttachment
763
764         * editing/WebContentReader.h:
765         * editing/cocoa/EditorCocoa.mm:
766         (WebCore::Editor::replaceSelectionWithAttributedString):
767
768         Add a new helper to replace elements in a DOM fragment with inline attachment elements instead, using the given
769         Blobs. So far, we only replace image elements with these attachments, by mapping the source of each image to a
770         Blob, and constructing a replacement attachment backed by a File constructed from the image's corresponding
771         Blob. However, this mechanism can be generalized in the future to handle transformations from arbitrary elements
772         to attachment elements capable of representing the same elements using inline display mode.
773
774         This function is a noop if the attachment elements are disabled via runtime-enabled features.
775
776         * editing/cocoa/WebContentReaderCocoa.mm:
777         (WebCore::replaceRichContentWithAttachmentsIfNecessary):
778         (WebCore::createFragmentAndAddResources):
779         (WebCore::sanitizeMarkupWithArchive):
780
781         Add out-params to both of these helper functions that capture the map of blob URLs to Blobs being used to
782         replace subresource URLs in the pasted/dropped DOM fragment.
783
784         (WebCore::WebContentReader::readWebArchive):
785         (WebCore::WebContentMarkupReader::readWebArchive):
786         (WebCore::createFragmentFromAttributedString):
787         (WebCore::WebContentReader::readRTFD):
788         (WebCore::WebContentMarkupReader::readRTFD):
789         (WebCore::WebContentReader::readRTF):
790         (WebCore::WebContentMarkupReader::readRTF):
791         (WebCore::WebContentReader::readImage):
792
793         In these places where we swap out subresource URLs for blob URLs, collect a map of blob URL => Blob, and use it
794         to replace images in the DOM with attachments (if needed, and possible).
795
796         * editing/mac/WebContentReaderMac.mm:
797         (WebCore::WebContentReader::readFilenames):
798
799         Augment existing logic to generate attachment elements when pasting or dropping file URLs, so that the generated
800         attachment elements also have titles, subtitles, and content type information.
801
802         * html/HTMLAttachmentElement.cpp:
803         (WebCore::HTMLAttachmentElement::setFile):
804
805         Add an optional second param, UpdateDisplayAttributes. If UpdateDisplayAttributes::Yes is passed in, then we set
806         the elements's attributes that are displayed in the attachment representation (title, subtitle, and type) using
807         the given File.
808
809         (WebCore::HTMLAttachmentElement::updateFileWithData):
810         (WebCore::HTMLAttachmentElement::populateShadowRootIfNecessary):
811
812         Make a small tweak to correctly handle the case where an attachment with a content type that is a UTI is being
813         displayed inline. Content type can either be a UTI or a MIME type, but the code to construct the shadow tree of
814         an attachment element only handles MIME types.
815
816         * html/HTMLAttachmentElement.h:
817
818 2017-12-18  Youenn Fablet  <youenn@apple.com>
819
820         SameOrigin and CORS fetch should fail on opaque responses served from ServiceWorker
821         https://bugs.webkit.org/show_bug.cgi?id=180941
822
823         Reviewed by Chris Dumez.
824
825         Covered by rebased tests.
826
827         * loader/SubresourceLoader.cpp:
828         (WebCore::SubresourceLoader::checkResponseCrossOriginAccessControl):
829
830 2017-12-18  Dean Jackson  <dino@apple.com>
831
832         Make some functions in GraphicsContextCG use call_once for statics
833         https://bugs.webkit.org/show_bug.cgi?id=180841
834         <rdar://problem/36058448>
835
836         Reviewed by Antoine Quint.
837
838         In preparation for making OffscreenCanvas operate inside a Worker,
839         make sure GraphicsContext is thread safe. Change some functions
840         that use a static to call_once.
841
842         * platform/graphics/cg/GraphicsContextCG.cpp:
843         (WebCore::sRGBColorSpaceRef):
844         (WebCore::linearRGBColorSpaceRef):
845         (WebCore::extendedSRGBColorSpaceRef):
846         (WebCore::displayP3ColorSpaceRef):
847
848 2017-12-18  Chris Dumez  <cdumez@apple.com>
849
850         ExtendableMessageEvent.data should return the value it was initialized to
851         https://bugs.webkit.org/show_bug.cgi?id=180868
852
853         Reviewed by Geoffrey Garen.
854
855         No new tests, rebaselined existing test.
856
857         * bindings/js/JSExtendableMessageEventCustom.cpp:
858         (WebCore::constructJSExtendableMessageEvent):
859         * workers/service/ExtendableMessageEvent.cpp:
860         (WebCore::ExtendableMessageEvent::ExtendableMessageEvent):
861         * workers/service/ExtendableMessageEvent.idl:
862
863 2017-12-18  Megan Gardner  <megan_gardner@apple.com>
864
865         Support Autoscrolling in contenteditable for WK2
866         https://bugs.webkit.org/show_bug.cgi?id=180789
867
868         Reviewed by Simon Frasier and Wenson Hsieh..
869
870         Activate the autoscrollController to scroll to the position provided to us by the
871         UIProcess. Allows for scrolling in contentEditable for WebKit2
872
873         Test: fast/events/touch/ios/drag-to-autoscroll-in-single-line-editable.html
874
875         * page/AutoscrollController.cpp:
876         (WebCore::AutoscrollController::autoscrollTimerFired):
877         * page/EventHandler.cpp:
878         (WebCore::EventHandler::clearOrScheduleClearingLatchedStateIfNeeded):
879         (WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
880         (WebCore::EventHandler::shouldUpdateAutoscroll):
881         (WebCore::EventHandler::effectiveMousePositionForSelectionAutoscroll const): Deleted.
882         * page/EventHandler.h:
883         * page/ios/EventHandlerIOS.mm:
884         (WebCore::EventHandler::startTextAutoscroll):
885         (WebCore::EventHandler::cancelTextAutoscroll):
886         (WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
887         (WebCore::EventHandler::shouldUpdateAutoscroll):
888         * page/mac/EventHandlerMac.mm:
889         (WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
890         (WebCore::EventHandler::effectiveMousePositionForSelectionAutoscroll const): Deleted.
891
892 2017-12-18  Youenn Fablet  <youenn@apple.com>
893
894         Add support for response blob given to fetch events
895         https://bugs.webkit.org/show_bug.cgi?id=180894
896
897         Reviewed by Darin Adler.
898
899         Covered by updated test expectations.
900
901         Adding support for getting a blob URL from a FormData that only contains one blob.
902         Adding support to create a FetcLoader from a ServiceWorkerThreadProxy
903
904         * Modules/fetch/FetchLoader.cpp:
905         (WebCore::FetchLoader::start):
906         (WebCore::FetchLoader::startLoadingBlobURL):
907         * Modules/fetch/FetchLoader.h:
908         * WebCore.xcodeproj/project.pbxproj:
909         * platform/network/FormData.cpp:
910         (WebCore::FormData::asBlobURL const):
911         * platform/network/FormData.h:
912         * workers/service/context/ServiceWorkerThreadProxy.cpp:
913         (WebCore::ServiceWorkerThreadProxy::createBlobLoader):
914         * workers/service/context/ServiceWorkerThreadProxy.h:
915
916 2017-12-18  Zalan Bujtas  <zalan@apple.com>
917
918         [SVG] Detach list wrappers before resetting the base value.
919         https://bugs.webkit.org/show_bug.cgi?id=180912
920         <rdar://problem/36017970>
921
922         Reviewed by Simon Fraser.
923
924         Before resetting the animation value (and destroying the assigned SVG object -SVGLengthValue in this case),
925         we need to check if there's an associated tear off wrapper for the said SVG object and make a copy of it.
926         This is currently done in the wrong order through animValDidChange.
927
928         Test: svg/animations/crash-when-animation-is-running-while-getting-value.html
929
930         * svg/SVGAnimatedTypeAnimator.h:
931         (WebCore::SVGAnimatedTypeAnimator::resetFromBaseValue):
932         * svg/properties/SVGAnimatedPropertyTearOff.h:
933         * svg/properties/SVGAnimatedStaticPropertyTearOff.h:
934         (WebCore::SVGAnimatedStaticPropertyTearOff::synchronizeWrappersIfNeeded):
935
936 2017-12-18  Brady Eidson  <beidson@apple.com>
937
938         REGRESSION: ASSERTION FAILED: !m_importCompleted
939         https://bugs.webkit.org/show_bug.cgi?id=180935
940
941         Unreviewed bot gardening.
942
943         No new tests (Covered by existing tests)
944
945         The ASSERT was invalid for database pushes failing to open databases like this, so skip it for that scenario.
946
947         * workers/service/server/RegistrationStore.cpp:
948         (WebCore::RegistrationStore::databaseFailedToOpen):
949         * workers/service/server/SWServer.cpp:
950         (WebCore::SWServer::registrationStoreDatabaseFailedToOpen):
951         * workers/service/server/SWServer.h:
952
953 2017-12-18  Jer Noble  <jer.noble@apple.com>
954
955         Playing media elements which call "pause(); play()" will have the play promise rejected.
956         https://bugs.webkit.org/show_bug.cgi?id=180781
957
958         Reviewed by Eric Carlson.
959
960         Test: media/video-pause-play-resolve.html
961
962         When scheduling a rejection or resolution of existing play promises, move() the existing
963         promises into the block. This ensures that valid promises aren't added to the play promise
964         vector between when a rejection is scheduled and when it runs.
965
966         Drive-by fix: Don't return false from playInternal() just so the newly created promise will
967         get rejected. The pause() command will reject the promise, so just make sure it's added to
968         the m_pendingPlayPromises before calling playInternal().
969
970         Drive-by fix #2: The spec referenced by playInternal() and pauseInternal() doesn't say to
971         call the "Media Element Load Algorithm" (i.e., prepareForLoad()); it says to call the
972         "Resource Selection Algorithm" (i.e., selectMediaResource()). But fixing this bug caused
973         an assertion crash when the resource selection task was fired and m_player was null. This
974         was because the algorithm is being run at stop() time due to stop() calling pause(). The
975         solution to this ASSERT is to stop the m_resourceSelectionTaskQueue in stop().
976
977         * html/HTMLMediaElement.cpp:
978         (WebCore::HTMLMediaElement::scheduleRejectPendingPlayPromises):
979         (WebCore::HTMLMediaElement::rejectPendingPlayPromises):
980         (WebCore::HTMLMediaElement::resolvePendingPlayPromises):
981         (WebCore::HTMLMediaElement::scheduleNotifyAboutPlaying):
982         (WebCore::HTMLMediaElement::notifyAboutPlaying):
983         (WebCore::HTMLMediaElement::noneSupported):
984         (WebCore::HTMLMediaElement::cancelPendingEventsAndCallbacks):
985         (WebCore::HTMLMediaElement::play):
986         (WebCore::HTMLMediaElement::playInternal):
987         (WebCore::HTMLMediaElement::pauseInternal):
988         (WebCore::HTMLMediaElement::stop):
989         * html/HTMLMediaElement.h:
990
991 2017-12-18  Daniel Bates  <dabates@apple.com>
992
993         Add SPI to query for the current and last auto fill button type and pass user data object to _webView:focusShouldStartInputSession:
994         https://bugs.webkit.org/show_bug.cgi?id=180774
995         <rdar://problem/36033832>
996
997         Reviewed by Tim Horton.
998
999         Expose a way for an embedding client to query for the auto fill button type of a specific
1000         input element as it may not be feasible for a client to track such state themselves. For
1001         similar reasons track and expose SPI to query for the last auto fill button type for a
1002         specific field.
1003
1004         Test: fast/forms/auto-fill-button/last-auto-fill-button-type.html
1005
1006         * html/HTMLInputElement.cpp:
1007         (WebCore::HTMLInputElement::HTMLInputElement):
1008         (WebCore::HTMLInputElement::setShowAutoFillButton):
1009         Update the last auto fill button type.
1010
1011         * html/HTMLInputElement.h:
1012         (WebCore::HTMLInputElement::lastAutoFillButtonType const): Added.
1013
1014         * testing/Internals.cpp:
1015         (WebCore::toAutoFillButtonType):
1016         (WebCore::toInternalsAutoFillButtonType):
1017         (WebCore::Internals::autoFillButtonType):
1018         (WebCore::Internals::lastAutoFillButtonType):
1019         * testing/Internals.h:
1020         * testing/Internals.idl:
1021         Add functions for testing.
1022
1023 2017-12-17  John Wilander  <wilander@apple.com>
1024
1025         Storage Access API: Make document.hasStorageAccess() retrieve current status from the network process
1026         https://bugs.webkit.org/show_bug.cgi?id=180681
1027         <rdar://problem/35982161>
1028
1029         Reviewed by Alex Christensen.
1030
1031         Tests: http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-non-recent-user-interaction.html
1032                http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction.html
1033
1034         This change makes an asynchronous request to the network process
1035         to see if storage access has been granted for this frame, on this
1036         page, for this domain.
1037
1038         * dom/Document.cpp:
1039         (WebCore::Document::hasStorageAccess):
1040         * page/ChromeClient.h:
1041
1042 2017-12-17  Chris Dumez  <cdumez@apple.com>
1043
1044         Strip fragment identifier from ServiceWorker's scriptURL
1045         https://bugs.webkit.org/show_bug.cgi?id=180887
1046
1047         Reviewed by Darin Adler.
1048
1049         Strip fragment identifier from ServiceWorker's scriptURL to match Firefox and Chrome.
1050         This behavior does not appear to be specified so I filed:
1051         - https://github.com/w3c/ServiceWorker/issues/1249
1052
1053         No new tests, rebaselined existing test.
1054
1055         * workers/service/server/SWServerWorker.cpp:
1056         (WebCore::m_script):
1057
1058 2017-12-17  Antti Koivisto  <antti@apple.com>
1059
1060         Move render tree updating related files under rendering/updating/
1061         https://bugs.webkit.org/show_bug.cgi?id=180918
1062
1063         Reviewed by Darin Adler.
1064
1065         * CMakeLists.txt:
1066         * Sources.txt:
1067         * WebCore.xcodeproj/project.pbxproj:
1068         * rendering/RenderTreeBuilder.cpp: Removed.
1069         * rendering/RenderTreeBuilder.h: Removed.
1070         * rendering/updating: Added.
1071         * rendering/updating/RenderTreeBuilder.cpp: Copied from Source/WebCore/rendering/RenderTreeBuilder.cpp.
1072         * rendering/updating/RenderTreeBuilder.h: Copied from Source/WebCore/rendering/RenderTreeBuilder.h.
1073         * rendering/updating/RenderTreePosition.cpp: Copied from Source/WebCore/style/RenderTreePosition.cpp.
1074         * rendering/updating/RenderTreePosition.h: Copied from Source/WebCore/style/RenderTreePosition.h.
1075         * rendering/updating/RenderTreeUpdater.cpp: Copied from Source/WebCore/style/RenderTreeUpdater.cpp.
1076         * rendering/updating/RenderTreeUpdater.h: Copied from Source/WebCore/style/RenderTreeUpdater.h.
1077         * rendering/updating/RenderTreeUpdaterFirstLetter.cpp: Copied from Source/WebCore/style/RenderTreeUpdaterFirstLetter.cpp.
1078         * rendering/updating/RenderTreeUpdaterFirstLetter.h: Copied from Source/WebCore/style/RenderTreeUpdaterFirstLetter.h.
1079         * rendering/updating/RenderTreeUpdaterGeneratedContent.cpp: Copied from Source/WebCore/style/RenderTreeUpdaterGeneratedContent.cpp.
1080         * rendering/updating/RenderTreeUpdaterGeneratedContent.h: Copied from Source/WebCore/style/RenderTreeUpdaterGeneratedContent.h.
1081         * rendering/updating/RenderTreeUpdaterListItem.cpp: Copied from Source/WebCore/style/RenderTreeUpdaterListItem.cpp.
1082         * rendering/updating/RenderTreeUpdaterListItem.h: Copied from Source/WebCore/style/RenderTreeUpdaterListItem.h.
1083         * rendering/updating/RenderTreeUpdaterMultiColumn.cpp: Copied from Source/WebCore/style/RenderTreeUpdaterMultiColumn.cpp.
1084         * rendering/updating/RenderTreeUpdaterMultiColumn.h: Copied from Source/WebCore/style/RenderTreeUpdaterMultiColumn.h.
1085         * style/RenderTreePosition.cpp: Removed.
1086         * style/RenderTreePosition.h: Removed.
1087         * style/RenderTreeUpdater.cpp: Removed.
1088         * style/RenderTreeUpdater.h: Removed.
1089         * style/RenderTreeUpdaterFirstLetter.cpp: Removed.
1090         * style/RenderTreeUpdaterFirstLetter.h: Removed.
1091         * style/RenderTreeUpdaterGeneratedContent.cpp: Removed.
1092         * style/RenderTreeUpdaterGeneratedContent.h: Removed.
1093         * style/RenderTreeUpdaterListItem.cpp: Removed.
1094         * style/RenderTreeUpdaterListItem.h: Removed.
1095         * style/RenderTreeUpdaterMultiColumn.cpp: Removed.
1096         * style/RenderTreeUpdaterMultiColumn.h: Removed.
1097
1098 2017-12-17  Yusuke Suzuki  <utatane.tea@gmail.com>
1099
1100         [JSC][WebCore][CSSJIT] Remove VM reference in CSSJIT
1101         https://bugs.webkit.org/show_bug.cgi?id=180917
1102
1103         Reviewed by Sam Weinig.
1104
1105         Remove VM reference in CSSJIT. CSSJIT should not be
1106         bound to a specific VM.
1107
1108         No behavior change.
1109
1110         * css/ElementRuleCollector.cpp:
1111         (WebCore::ElementRuleCollector::ruleMatches):
1112         * cssjit/SelectorCompiler.cpp:
1113         (WebCore::SelectorCompiler::compileSelector):
1114         * cssjit/SelectorCompiler.h:
1115         * dom/SelectorQuery.cpp:
1116         (WebCore::SelectorDataList::compileSelector):
1117         (WebCore::SelectorDataList::execute const):
1118         * dom/SelectorQuery.h:
1119
1120 2017-12-16  Dan Bernstein  <mitz@apple.com>
1121
1122         WKWebView has no equivalent of -[WebView setAlwaysShowVerticalScroller:]
1123         https://bugs.webkit.org/show_bug.cgi?id=180613
1124         <rdar://problem/35946124>
1125
1126         Reviewed by Geoff Garen.
1127
1128         Test: TestWebKitAPI/Tests/WebKitCocoa/WKWebViewAlwaysShowsScroller.mm
1129
1130         * platform/ScrollView.h: Exported setScrollbarModes.
1131
1132 2017-12-16  Antti Koivisto  <antti@apple.com>
1133
1134         Introduce RenderTreeBuilder
1135         https://bugs.webkit.org/show_bug.cgi?id=180817
1136
1137         Reviewed by Zalan Bujtas.
1138
1139         RenderTreeBuilder is responsible of building the render tree, including construction of various anonymous
1140         renderers. Renderer subtype specific render tree construction code will eventually move there.
1141
1142         This patch adds RenderTreeBuilder class and passes it as a parameter for all addChild implementations.
1143         Future patches can then mechanically move the building code from renderers to RenderTreeBuilder.
1144
1145         It also moves one addChild implementation (RenderRuby::addChild -> RenderTreeBuilder::rubyRunInsertChild)
1146         to RenderTreeBuilder as a test.
1147
1148         * WebCore.xcodeproj/project.pbxproj:
1149         * rendering/RenderBlock.cpp:
1150         (WebCore::RenderBlock::addChildToContinuation):
1151         (WebCore::RenderBlock::addChild):
1152         (WebCore::RenderBlock::addChildIgnoringContinuation):
1153         * rendering/RenderBlock.h:
1154         * rendering/RenderBlockFlow.cpp:
1155         (WebCore::RenderBlockFlow::addChild):
1156         * rendering/RenderBlockFlow.h:
1157         * rendering/RenderBoxModelObject.cpp:
1158         (WebCore::RenderBoxModelObject::moveChildTo):
1159         * rendering/RenderButton.cpp:
1160         (WebCore::RenderButton::addChild):
1161         (WebCore::RenderButton::setText):
1162         * rendering/RenderButton.h:
1163         * rendering/RenderElement.cpp:
1164         (WebCore::RenderElement::addChild):
1165         * rendering/RenderElement.h:
1166         (WebCore::RenderElement::addChildIgnoringContinuation):
1167         * rendering/RenderFullScreen.cpp:
1168         (WebCore::RenderFullScreen::wrapNewRenderer):
1169         (WebCore::RenderFullScreen::wrapExistingRenderer):
1170         (WebCore::RenderFullScreen::unwrapRenderer):
1171         (WebCore::RenderFullScreen::createPlaceholder):
1172         * rendering/RenderGrid.cpp:
1173         (WebCore::RenderGrid::addChild):
1174         * rendering/RenderGrid.h:
1175         * rendering/RenderInline.cpp:
1176         (WebCore::RenderInline::addChild):
1177         (WebCore::RenderInline::addChildIgnoringContinuation):
1178         (WebCore::RenderInline::splitInlines):
1179         (WebCore::RenderInline::splitFlow):
1180         (WebCore::RenderInline::addChildToContinuation):
1181         (WebCore::RenderInline::childBecameNonInline):
1182         * rendering/RenderInline.h:
1183         * rendering/RenderMenuList.cpp:
1184         (WebCore::RenderMenuList::createInnerBlock):
1185         (RenderMenuList::addChild):
1186         (RenderMenuList::setText):
1187         * rendering/RenderMenuList.h:
1188         * rendering/RenderMultiColumnFlow.cpp:
1189         (WebCore::RenderMultiColumnFlow::processPossibleSpannerDescendant):
1190         * rendering/RenderQuote.cpp:
1191         (WebCore::RenderQuote::updateTextRenderer):
1192         (WebCore::RenderQuote::updateRenderer):
1193         * rendering/RenderQuote.h:
1194         * rendering/RenderRuby.cpp:
1195         (WebCore::RenderRubyAsInline::addChild):
1196         (WebCore::RenderRubyAsBlock::addChild):
1197         * rendering/RenderRuby.h:
1198         * rendering/RenderRubyBase.h:
1199         * rendering/RenderRubyRun.cpp:
1200         (WebCore::RenderRubyRun::rubyBaseSafe):
1201         (WebCore::RenderRubyRun::addChild): Deleted.
1202         * rendering/RenderRubyRun.h:
1203         * rendering/RenderTable.cpp:
1204         (WebCore::RenderTable::addChild):
1205         * rendering/RenderTable.h:
1206         * rendering/RenderTableRow.cpp:
1207         (WebCore::RenderTableRow::addChild):
1208         * rendering/RenderTableRow.h:
1209         * rendering/RenderTableSection.cpp:
1210         (WebCore::RenderTableSection::addChild):
1211         * rendering/RenderTableSection.h:
1212         * rendering/RenderTreeBuilder.cpp: Added.
1213         (WebCore::RenderTreeBuilder::RenderTreeBuilder):
1214         (WebCore::RenderTreeBuilder::~RenderTreeBuilder):
1215         (WebCore::RenderTreeBuilder::insertChild):
1216         (WebCore::RenderTreeBuilder::rubyRunInsertChild):
1217         * rendering/RenderTreeBuilder.h: Added.
1218         (WebCore::RenderTreeBuilder::current):
1219         * rendering/TextAutoSizing.cpp:
1220         (WebCore::TextAutoSizingValue::adjustTextNodeSizes):
1221         * rendering/mathml/RenderMathMLFenced.cpp:
1222         (WebCore::RenderMathMLFenced::updateFromElement):
1223         (WebCore::RenderMathMLFenced::makeFences):
1224         (WebCore::RenderMathMLFenced::addChild):
1225         * rendering/mathml/RenderMathMLFenced.h:
1226         * rendering/svg/RenderSVGContainer.cpp:
1227         (WebCore::RenderSVGContainer::addChild):
1228         * rendering/svg/RenderSVGContainer.h:
1229         * rendering/svg/RenderSVGInline.cpp:
1230         (WebCore::RenderSVGInline::addChild):
1231         * rendering/svg/RenderSVGInline.h:
1232         * rendering/svg/RenderSVGRoot.cpp:
1233         (WebCore::RenderSVGRoot::addChild):
1234         * rendering/svg/RenderSVGRoot.h:
1235         * rendering/svg/RenderSVGText.cpp:
1236         (WebCore::RenderSVGText::addChild):
1237         * rendering/svg/RenderSVGText.h:
1238         * style/RenderTreePosition.cpp:
1239         (WebCore::RenderTreePosition::insert): Deleted.
1240         * style/RenderTreePosition.h:
1241         (WebCore::RenderTreePosition::RenderTreePosition):
1242         (WebCore::RenderTreePosition::nextSibling const):
1243         (WebCore::RenderTreePosition::canInsert const): Deleted.
1244         * style/RenderTreeUpdater.cpp:
1245         (WebCore::RenderTreeUpdater::updateAfterDescendants):
1246         (WebCore::RenderTreeUpdater::createRenderer):
1247         (WebCore::RenderTreeUpdater::createTextRenderer):
1248         (WebCore::RenderTreeUpdater::updateTextRenderer):
1249         (WebCore::createTextRenderer): Deleted.
1250         * style/RenderTreeUpdater.h:
1251         * style/RenderTreeUpdaterFirstLetter.cpp:
1252         (WebCore::updateFirstLetterStyle):
1253         (WebCore::createFirstLetterRenderer):
1254         * style/RenderTreeUpdaterGeneratedContent.cpp:
1255         (WebCore::RenderTreeUpdater::GeneratedContent::updateQuotesUpTo):
1256         (WebCore::createContentRenderers):
1257         (WebCore::RenderTreeUpdater::GeneratedContent::updatePseudoElement):
1258         * style/RenderTreeUpdaterListItem.cpp:
1259         (WebCore::RenderTreeUpdater::ListItem::updateMarker):
1260         * style/RenderTreeUpdaterListItem.h:
1261         * style/RenderTreeUpdaterMultiColumn.cpp:
1262         (WebCore::RenderTreeUpdater::MultiColumn::createFragmentedFlow):
1263         (WebCore::RenderTreeUpdater::MultiColumn::destroyFragmentedFlow):
1264
1265 2017-12-16  Romain Bellessort  <romain.bellessort@crf.canon.fr>
1266
1267         [Readable Streams API] Fix filling of descriptor from queue
1268         https://bugs.webkit.org/show_bug.cgi?id=172717
1269
1270         Reviewed by Youenn Fablet.
1271
1272         Fixed the filling of descriptor from queue (step 10.d at [1]). When first implemented,
1273         spec comprised a bug and code was not reachable. Spec has now been fixed and code can
1274         now be reached.
1275
1276         [1] https://streams.spec.whatwg.org/#readable-byte-stream-controller-fill-pull-into-descriptor-from-queue
1277
1278         No new tests (covered by WPT tests, whose expectations have been updated).
1279
1280         * Modules/streams/ReadableByteStreamInternals.js:
1281         (readableByteStreamControllerFillDescriptorFromQueue): Updated.
1282
1283 2017-12-16  Brady Eidson  <beidson@apple.com>
1284
1285         Implement getting ServiceWorker registrations for the WKWebsiteDataStore API
1286         https://bugs.webkit.org/show_bug.cgi?id=180886
1287
1288         Reviewed by Chris Dumez.
1289
1290         No new tests (API test coming soon).
1291
1292         * workers/service/server/SWServer.cpp:
1293         (WebCore::SWServer::registrationStoreImportComplete):
1294         (WebCore::SWServer::SWServer):
1295         (WebCore::SWServer::getOriginsWithRegistrations):
1296         (WebCore::SWServer::performGetOriginsWithRegistrationsCallbacks):
1297         * workers/service/server/SWServer.h:
1298
1299 2017-12-16  Yusuke Suzuki  <utatane.tea@gmail.com>
1300
1301         Remove unnecessary boolean result of start() functions
1302         https://bugs.webkit.org/show_bug.cgi?id=180856
1303
1304         Reviewed by Darin Adler.
1305
1306         No behavior change.
1307
1308         * Modules/webaudio/AsyncAudioDecoder.cpp:
1309         (WebCore::AsyncAudioDecoder::~AsyncAudioDecoder):
1310         * Modules/webdatabase/DatabaseContext.cpp:
1311         (WebCore::DatabaseContext::databaseThread):
1312         * Modules/webdatabase/DatabaseThread.cpp:
1313         (WebCore::DatabaseThread::start):
1314         Now `Thread::create` always succeeds (if it fails, WebKit crashes).
1315         DatabaseThread::start() now always returns true. So, we do not need
1316         to return bool.
1317
1318         * Modules/webdatabase/DatabaseThread.h:
1319         * platform/network/curl/CurlDownload.cpp:
1320         (WebCore::CurlDownload::start):
1321         * platform/network/curl/CurlDownload.h:
1322         * platform/network/curl/ResourceHandleCurl.cpp:
1323         (WebCore::ResourceHandle::start):
1324         * platform/network/curl/ResourceHandleCurlDelegate.cpp:
1325         (WebCore::ResourceHandleCurlDelegate::start):
1326         * platform/network/curl/ResourceHandleCurlDelegate.h:
1327
1328 2017-12-16  Chris Dumez  <cdumez@apple.com>
1329
1330         Add optimization when updating a SW registration results in the exact same script
1331         https://bugs.webkit.org/show_bug.cgi?id=180891
1332
1333         Reviewed by Geoffrey Garen.
1334
1335         Add optimization when updating a SW registration results in the exact same script:
1336         - https://w3c.github.io/ServiceWorker/#update-algorithm (step 8)
1337
1338         No new tests, rebaselined existing test.
1339
1340         * workers/service/server/SWServerJobQueue.cpp:
1341         (WebCore::SWServerJobQueue::scriptFetchFinished):
1342
1343 2017-12-16  Youenn Fablet  <youenn@apple.com>
1344
1345         Service worker script fetch request should set the Service-Worker header
1346         https://bugs.webkit.org/show_bug.cgi?id=180889
1347
1348         Reviewed by Chris Dumez.
1349
1350         Test: http/wpt/service-workers/check-service-worker-header.https.html
1351
1352         Update WorkerScriptLoader to take a request instead of an URL.
1353         Updates Worker implementation and use it in ServiceWorkerJob to set the missing request header.
1354
1355         * workers/Worker.cpp:
1356         (WebCore::Worker::create):
1357         * workers/WorkerScriptLoader.cpp:
1358         (WebCore::WorkerScriptLoader::loadAsynchronously):
1359         * workers/WorkerScriptLoader.h:
1360         * workers/service/ServiceWorkerJob.cpp:
1361         (WebCore::ServiceWorkerJob::fetchScriptWithContext):
1362
1363 2017-12-15  Ryan Haddad  <ryanhaddad@apple.com>
1364
1365         Unreviewed, rolling out r225969.
1366
1367         This change introduced LayoutTest crashes.
1368
1369         Reverted changeset:
1370
1371         "Introduce RenderTreeBuilder"
1372         https://bugs.webkit.org/show_bug.cgi?id=180817
1373         https://trac.webkit.org/changeset/225969
1374
1375 2017-12-15  Chris Dumez  <cdumez@apple.com>
1376
1377         Support updating a service worker registration's updateViaCache flag
1378         https://bugs.webkit.org/show_bug.cgi?id=180888
1379
1380         Reviewed by Brady Eidson.
1381
1382         Support updating a service worker registration's updateViaCache flag to match other browsers:
1383         - https://github.com/w3c/ServiceWorker/issues/1189
1384
1385         No new tests, rebaselined existing test.
1386
1387         * workers/service/SWClientConnection.cpp:
1388         (WebCore::SWClientConnection::setRegistrationUpdateViaCache):
1389         * workers/service/SWClientConnection.h:
1390         * workers/service/ServiceWorkerRegistration.cpp:
1391         (WebCore::ServiceWorkerRegistration::setUpdateViaCache):
1392         * workers/service/ServiceWorkerRegistration.h:
1393         * workers/service/server/SWServer.h:
1394         * workers/service/server/SWServerJobQueue.cpp:
1395         (WebCore::SWServerJobQueue::runRegisterJob):
1396         * workers/service/server/SWServerRegistration.cpp:
1397         (WebCore::SWServerRegistration::setUpdateViaCache):
1398         * workers/service/server/SWServerRegistration.h:
1399
1400 2017-12-15  Ryan Haddad  <ryanhaddad@apple.com>
1401
1402         Unreviewed, rolling out r225941.
1403
1404         This change introduced LayoutTest crashes and assertion
1405         failures.
1406
1407         Reverted changeset:
1408
1409         "Web Inspector: replace HTMLCanvasElement with
1410         CanvasRenderingContext for instrumentation logic"
1411         https://bugs.webkit.org/show_bug.cgi?id=180770
1412         https://trac.webkit.org/changeset/225941
1413
1414 2017-12-15  Ryosuke Niwa  <rniwa@webkit.org>
1415
1416         Add a release assert that Timer::m_wasDeleted is false in setNextFireTime
1417         https://bugs.webkit.org/show_bug.cgi?id=180860
1418         <rdar://problem/36066500>
1419
1420         Reviewed by David Kilzer.
1421
1422         Turn an exist debug-only assertion into a release assertion to help diagnose a crash
1423         which appears to be caused by a freed timer getting scheduled back into the timer heap.
1424
1425         * platform/Timer.cpp:
1426         (WebCore::TimerBase::~TimerBase):
1427         (WebCore::TimerBase::setNextFireTime):
1428         * platform/Timer.h:
1429
1430 2017-12-15  Simon Fraser  <simon.fraser@apple.com>
1431
1432         Elements animated on-screen are missing sometimes
1433         https://bugs.webkit.org/show_bug.cgi?id=180773
1434         rdar://problem/34923438
1435
1436         Reviewed by Zalan Bujtas.
1437         
1438         After r225310 it was still possible for elements to be missing backing store when brought
1439         on-screen via an animation. This occurred if a child element was outside the bounds of the
1440         element being animated.
1441
1442         Fix by making sure that GraphicsLayer's "animatedExtent" took composited child layers into account.
1443
1444         As for r225310, no test because this is timing sensitive and hard to reliably make a test for.
1445
1446         * rendering/RenderLayer.cpp:
1447         (WebCore::RenderLayer::calculateClipRects const):
1448         * rendering/RenderLayer.h:
1449         * rendering/RenderLayerBacking.cpp:
1450         (WebCore::RenderLayerBacking::updateGeometry):
1451
1452 2017-12-15  Chris Dumez  <cdumez@apple.com>
1453
1454         imported/w3c/web-platform-tests/service-workers/service-worker/update.https.html is sometimes crashing in Debug builds
1455         https://bugs.webkit.org/show_bug.cgi?id=180867
1456
1457         Reviewed by Brady Eidson.
1458
1459         Fix assertion to make sure the worker is terminating if it is already in m_runningOrTerminatingWorkers.
1460
1461         * workers/service/server/SWServer.cpp:
1462         (WebCore::SWServer::runServiceWorker):
1463
1464 2017-12-15  Chris Dumez  <cdumez@apple.com>
1465
1466         Service Worker Registration promise is sometimes not rejected when the script load fails
1467         https://bugs.webkit.org/show_bug.cgi?id=180849
1468
1469         Reviewed by Brady Eidson.
1470
1471         Service Worker Registration promise is sometimes not rejected when the script load fails.
1472         This was caused by the ServiceWorkerJob sometimes passing a null ResourceError to the
1473         StorageProcess, even though the load failed.
1474
1475         No new tests, rebaselined exisiting tests.
1476
1477         * workers/WorkerScriptLoader.cpp:
1478         (WebCore::WorkerScriptLoader::notifyError):
1479         * workers/service/ServiceWorkerJob.cpp:
1480         (WebCore::ServiceWorkerJob::notifyFinished):
1481
1482 2017-12-15  Youenn Fablet  <youenn@apple.com>
1483
1484         WebRTC Stats should not be console logged from a background thread
1485         https://bugs.webkit.org/show_bug.cgi?id=180845
1486
1487         Reviewed by Eric Carlson.
1488
1489         Ensuring console log are done in the main thread.
1490
1491         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
1492         (WebCore::LibWebRTCMediaEndpoint::OnStatsDelivered):
1493
1494 2017-12-15  Antti Koivisto  <antti@apple.com>
1495
1496         Introduce RenderTreeBuilder
1497         https://bugs.webkit.org/show_bug.cgi?id=180817
1498
1499         Reviewed by Zalan Bujtas.
1500
1501         RenderTreeBuilder is responsible of building the render tree, including construction of various anonymous
1502         renderers. Renderer subtype specific render tree construction code will eventually move there.
1503
1504         This patch adds RenderTreeBuilder class and passes it as a parameter for all addChild implementations.
1505         Future patches can then mechanically move the building code from renderers to RenderTreeBuilder.
1506
1507         It also moves one addChild implementation (RenderRuby::addChild -> RenderTreeBuilder::rubyRunInsertChild)
1508         to RenderTreeBuilder as a test.
1509
1510         * WebCore.xcodeproj/project.pbxproj:
1511         * rendering/RenderBlock.cpp:
1512         (WebCore::RenderBlock::addChildToContinuation):
1513         (WebCore::RenderBlock::addChild):
1514         (WebCore::RenderBlock::addChildIgnoringContinuation):
1515         * rendering/RenderBlock.h:
1516         * rendering/RenderBlockFlow.cpp:
1517         (WebCore::RenderBlockFlow::addChild):
1518         * rendering/RenderBlockFlow.h:
1519         * rendering/RenderBoxModelObject.cpp:
1520         (WebCore::RenderBoxModelObject::moveChildTo):
1521         * rendering/RenderButton.cpp:
1522         (WebCore::RenderButton::addChild):
1523         (WebCore::RenderButton::setText):
1524         * rendering/RenderButton.h:
1525         * rendering/RenderElement.cpp:
1526         (WebCore::RenderElement::addChild):
1527         * rendering/RenderElement.h:
1528         (WebCore::RenderElement::addChildIgnoringContinuation):
1529         * rendering/RenderFullScreen.cpp:
1530         (WebCore::RenderFullScreen::wrapNewRenderer):
1531         (WebCore::RenderFullScreen::wrapExistingRenderer):
1532         (WebCore::RenderFullScreen::unwrapRenderer):
1533         (WebCore::RenderFullScreen::createPlaceholder):
1534         * rendering/RenderGrid.cpp:
1535         (WebCore::RenderGrid::addChild):
1536         * rendering/RenderGrid.h:
1537         * rendering/RenderInline.cpp:
1538         (WebCore::RenderInline::addChild):
1539         (WebCore::RenderInline::addChildIgnoringContinuation):
1540         (WebCore::RenderInline::splitInlines):
1541         (WebCore::RenderInline::splitFlow):
1542         (WebCore::RenderInline::addChildToContinuation):
1543         (WebCore::RenderInline::childBecameNonInline):
1544         * rendering/RenderInline.h:
1545         * rendering/RenderMenuList.cpp:
1546         (WebCore::RenderMenuList::createInnerBlock):
1547         (RenderMenuList::addChild):
1548         (RenderMenuList::setText):
1549         * rendering/RenderMenuList.h:
1550         * rendering/RenderMultiColumnFlow.cpp:
1551         (WebCore::RenderMultiColumnFlow::processPossibleSpannerDescendant):
1552         * rendering/RenderQuote.cpp:
1553         (WebCore::RenderQuote::updateTextRenderer):
1554         (WebCore::RenderQuote::updateRenderer):
1555         * rendering/RenderQuote.h:
1556         * rendering/RenderRuby.cpp:
1557         (WebCore::RenderRubyAsInline::addChild):
1558         (WebCore::RenderRubyAsBlock::addChild):
1559         * rendering/RenderRuby.h:
1560         * rendering/RenderRubyBase.h:
1561         * rendering/RenderRubyRun.cpp:
1562         (WebCore::RenderRubyRun::rubyBaseSafe):
1563         (WebCore::RenderRubyRun::addChild): Deleted.
1564         * rendering/RenderRubyRun.h:
1565         * rendering/RenderTable.cpp:
1566         (WebCore::RenderTable::addChild):
1567         * rendering/RenderTable.h:
1568         * rendering/RenderTableRow.cpp:
1569         (WebCore::RenderTableRow::addChild):
1570         * rendering/RenderTableRow.h:
1571         * rendering/RenderTableSection.cpp:
1572         (WebCore::RenderTableSection::addChild):
1573         * rendering/RenderTableSection.h:
1574         * rendering/RenderTreeBuilder.cpp: Added.
1575         (WebCore::RenderTreeBuilder::RenderTreeBuilder):
1576         (WebCore::RenderTreeBuilder::~RenderTreeBuilder):
1577         (WebCore::RenderTreeBuilder::insertChild):
1578         (WebCore::RenderTreeBuilder::rubyRunInsertChild):
1579         * rendering/RenderTreeBuilder.h: Added.
1580         (WebCore::RenderTreeBuilder::current):
1581         * rendering/TextAutoSizing.cpp:
1582         (WebCore::TextAutoSizingValue::adjustTextNodeSizes):
1583         * rendering/mathml/RenderMathMLFenced.cpp:
1584         (WebCore::RenderMathMLFenced::updateFromElement):
1585         (WebCore::RenderMathMLFenced::makeFences):
1586         (WebCore::RenderMathMLFenced::addChild):
1587         * rendering/mathml/RenderMathMLFenced.h:
1588         * rendering/svg/RenderSVGContainer.cpp:
1589         (WebCore::RenderSVGContainer::addChild):
1590         * rendering/svg/RenderSVGContainer.h:
1591         * rendering/svg/RenderSVGInline.cpp:
1592         (WebCore::RenderSVGInline::addChild):
1593         * rendering/svg/RenderSVGInline.h:
1594         * rendering/svg/RenderSVGRoot.cpp:
1595         (WebCore::RenderSVGRoot::addChild):
1596         * rendering/svg/RenderSVGRoot.h:
1597         * rendering/svg/RenderSVGText.cpp:
1598         (WebCore::RenderSVGText::addChild):
1599         * rendering/svg/RenderSVGText.h:
1600         * style/RenderTreePosition.cpp:
1601         (WebCore::RenderTreePosition::insert): Deleted.
1602         * style/RenderTreePosition.h:
1603         (WebCore::RenderTreePosition::RenderTreePosition):
1604         (WebCore::RenderTreePosition::nextSibling const):
1605         (WebCore::RenderTreePosition::canInsert const): Deleted.
1606         * style/RenderTreeUpdater.cpp:
1607         (WebCore::RenderTreeUpdater::updateAfterDescendants):
1608         (WebCore::RenderTreeUpdater::createRenderer):
1609         (WebCore::RenderTreeUpdater::createTextRenderer):
1610         (WebCore::RenderTreeUpdater::updateTextRenderer):
1611         (WebCore::createTextRenderer): Deleted.
1612         * style/RenderTreeUpdater.h:
1613         * style/RenderTreeUpdaterFirstLetter.cpp:
1614         (WebCore::updateFirstLetterStyle):
1615         (WebCore::createFirstLetterRenderer):
1616         * style/RenderTreeUpdaterGeneratedContent.cpp:
1617         (WebCore::RenderTreeUpdater::GeneratedContent::updateQuotesUpTo):
1618         (WebCore::createContentRenderers):
1619         (WebCore::RenderTreeUpdater::GeneratedContent::updatePseudoElement):
1620         * style/RenderTreeUpdaterListItem.cpp:
1621         (WebCore::RenderTreeUpdater::ListItem::updateMarker):
1622         * style/RenderTreeUpdaterListItem.h:
1623         * style/RenderTreeUpdaterMultiColumn.cpp:
1624         (WebCore::RenderTreeUpdater::MultiColumn::createFragmentedFlow):
1625         (WebCore::RenderTreeUpdater::MultiColumn::destroyFragmentedFlow):
1626
1627 2017-12-14  Youenn Fablet  <youenn@apple.com>
1628
1629         Implement <iframe allow="camera; microphone">
1630         https://bugs.webkit.org/show_bug.cgi?id=167430
1631
1632         Reviewed by Eric Carlson.
1633
1634         Tests: imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https.sub.html
1635
1636         Adding allow attribute to HTMLIFrameElement as per https://wicg.github.io/feature-policy/#iframe-allow-attribute.
1637         Cross-origin iframes will get access to camera/microphone based on this attribute value.
1638         Same-origin iframes do not need any attribute.
1639         In case getUserMedia requests both camera and microphone, and allow attribute is only one of these,
1640         getUserMedia access is denied. This goes against the tests but is not very clear from the specification.
1641
1642         * Modules/mediastream/UserMediaRequest.cpp:
1643         (WebCore::isSecure):
1644         (WebCore::isAllowedToUse):
1645         (WebCore::canCallGetUserMedia):
1646         (WebCore::UserMediaRequest::start):
1647         * html/HTMLAttributeNames.in:
1648         * html/HTMLIFrameElement.cpp:
1649         (WebCore::HTMLIFrameElement::parseAttribute):
1650         * html/HTMLIFrameElement.h:
1651         * html/HTMLIFrameElement.idl:
1652
1653 2017-12-14  Zalan Bujtas  <zalan@apple.com>
1654
1655         Inconsistent section grid could lead to CrashOnOverflow
1656         https://bugs.webkit.org/show_bug.cgi?id=180850
1657         <rdar://problem/34064811>
1658
1659         Reviewed by Simon Fraser.
1660
1661         Each RenderTableSection maintains a grid of rows and columns. The number of columns in this grid equals the
1662         maximum number of columns in the entire table (taking spans and multiple sections into account).
1663         Since the maximum number of columns might change while re-computing the sections, we need to
1664         adjust them accordingly at the end (otherwise it could lead to inconsistent grids where rows have different number of columns).
1665
1666         Test: fast/table/table-row-oveflow-crash.html
1667
1668         * rendering/RenderTable.cpp:
1669         (WebCore::RenderTable::recalcSections const):
1670         * rendering/RenderTableSection.cpp:
1671         (WebCore::RenderTableSection::removeRedundantColumns):
1672         * rendering/RenderTableSection.h:
1673
1674 2017-12-14  David Kilzer  <ddkilzer@apple.com>
1675
1676         Enable -Wstrict-prototypes for WebKit
1677         <https://webkit.org/b/180757>
1678         <rdar://problem/36024132>
1679
1680         Rubber-stamped by Joseph Pecoraro.
1681
1682         * Configurations/Base.xcconfig:
1683         (CLANG_WARN_STRICT_PROTOTYPES): Add. Set to YES.
1684
1685 2017-12-14  Youenn Fablet  <youenn@apple.com>
1686
1687         srflx and relay ICE candidates lack raddr (rel-addr) and rport (rel-port) attributes if getUserMedia access has not been granted
1688         https://bugs.webkit.org/show_bug.cgi?id=180842
1689
1690         Reviewed by Jon Lee.
1691
1692         Manually tested since there is no way to gather reflexive or stun candidates in WebKit CI.
1693
1694         * Modules/mediastream/PeerConnectionBackend.cpp:
1695         (WebCore::filterICECandidate):
1696
1697 2017-12-14  Commit Queue  <commit-queue@webkit.org>
1698
1699         Unreviewed, rolling out r225878.
1700         https://bugs.webkit.org/show_bug.cgi?id=180855
1701
1702         Introduced a crash in HTMLPictureElement. We're taking a
1703         different approach for webkit.org/b/180769 (Requested by rniwa
1704         on #webkit).
1705
1706         Reverted changeset:
1707
1708         "Crash inside ImageLoader::updateFromElement()"
1709         https://bugs.webkit.org/show_bug.cgi?id=180769
1710         https://trac.webkit.org/changeset/225878
1711
1712 2017-12-14  Ryan Haddad  <ryanhaddad@apple.com>
1713
1714         Unreviewed, rolling out r225931.
1715
1716         Breaks internal builds.
1717
1718         Reverted changeset:
1719
1720         "Fix Mac CMake build"
1721         https://bugs.webkit.org/show_bug.cgi?id=180835
1722         https://trac.webkit.org/changeset/225931
1723
1724 2017-12-14  Simon Fraser  <simon.fraser@apple.com>
1725
1726         Another Windows build fix.
1727
1728         * platform/graphics/cg/GraphicsContextCG.cpp:
1729         (WebCore::extendedSRGBColorSpaceRef):
1730
1731 2017-12-14  Simon Fraser  <simon.fraser@apple.com>
1732
1733         Fix Windows build after r225915.
1734
1735         Windows doens't have dispatch_once with blocks. Switch to use lambda functions instead.
1736
1737         * platform/graphics/cg/GraphicsContextCG.cpp:
1738         (WebCore::sRGBColorSpaceRef):
1739         (WebCore::linearRGBColorSpaceRef):
1740         (WebCore::extendedSRGBColorSpaceRef):
1741         (WebCore::displayP3ColorSpaceRef):
1742
1743 2017-12-14  Devin Rousso  <webkit@devinrousso.com>
1744
1745         Web Inspector: replace HTMLCanvasElement with CanvasRenderingContext for instrumentation logic
1746         https://bugs.webkit.org/show_bug.cgi?id=180770
1747
1748         Reviewed by Joseph Pecoraro.
1749
1750         No change in functionality.
1751
1752         * html/canvas/CanvasRenderingContext.h:
1753         * html/canvas/CanvasRenderingContext.cpp:
1754         (WebCore::CanvasRenderingContext::~CanvasRenderingContext):
1755         Instead of waiting on the HTMLCanvasElement to destruct to call willDestroyCanvasRenderingContext
1756         we can call out in the destructor and know that the CanvasRenderingContext will be destroyed
1757         immediately thereafter.
1758
1759         * html/canvas/CanvasRenderingContext2D.h:
1760         * html/canvas/CanvasRenderingContext2D.cpp:
1761         (WebCore::CanvasRenderingContext2D::create):
1762         * html/canvas/ImageBitmapRenderingContext.h:
1763         * html/canvas/ImageBitmapRenderingContext.cpp:
1764         (WebCore::ImageBitmapRenderingContext::create):
1765         * html/canvas/WebGL2RenderingContext.h:
1766         * html/canvas/WebGL2RenderingContext.cpp:
1767         (WebCore::WebGL2RenderingContext::create):
1768         * html/canvas/WebGLRenderingContext.h:
1769         * html/canvas/WebGLRenderingContext.cpp:
1770         (WebCore::WebGLRenderingContext::create):
1771         * html/canvas/WebGLRenderingContextBase.cpp:
1772         (WebCore::WebGLRenderingContextBase::create):
1773         * html/canvas/WebGPURenderingContext.cpp:
1774         (WebCore::WebGPURenderingContext::create):
1775         * html/HTMLCanvasElement.cpp:
1776         (WebCore::HTMLCanvasElement::createContext2d):
1777         (WebCore::HTMLCanvasElement::createContextWebGL):
1778         (WebCore::HTMLCanvasElement::createContextWebGPU):
1779         (WebCore::HTMLCanvasElement::createContextBitmapRenderer):
1780         (WebCore::HTMLCanvasElement::paint):
1781         (WebCore::HTMLCanvasElement::setImageBuffer const):
1782         Instead of adding didCreateCanvasRenderingContext calls at the construction sites of each
1783         context, we can make the constructors private and force the usage of static `create` functions.
1784         This way, we have access to the fully constructed object and have a guaranteed path for creation.
1785
1786         * inspector/InspectorCanvas.h:
1787         * inspector/InspectorCanvas.cpp:
1788         (WebCore::InspectorCanvas::create):
1789         (WebCore::InspectorCanvas::InspectorCanvas):
1790         (WebCore::InspectorCanvas::canvasElement):
1791         (WebCore::InspectorCanvas::resetRecordingData):
1792         (WebCore::InspectorCanvas::recordAction):
1793         (WebCore::InspectorCanvas::buildObjectForCanvas):
1794         (WebCore::InspectorCanvas::getCanvasContentAsDataURL):
1795         (WebCore::InspectorCanvas::buildInitialState):
1796         
1797         * inspector/InspectorShaderProgram.h:
1798         * inspector/InspectorShaderProgram.cpp:
1799         (WebCore::InspectorShaderProgram::context const):
1800
1801         * inspector/agents/InspectorCanvasAgent.h:
1802         * inspector/agents/InspectorCanvasAgent.cpp:
1803         (WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
1804         (WebCore::InspectorCanvasAgent::enable):
1805         (WebCore::InspectorCanvasAgent::disable):
1806         (WebCore::InspectorCanvasAgent::requestNode):
1807         (WebCore::InspectorCanvasAgent::requestContent):
1808         (WebCore::InspectorCanvasAgent::requestCSSCanvasClientNodes):
1809         (WebCore::contextAsScriptValue):
1810         (WebCore::InspectorCanvasAgent::resolveCanvasContext):
1811         (WebCore::InspectorCanvasAgent::startRecording):
1812         (WebCore::InspectorCanvasAgent::stopRecording):
1813         (WebCore::InspectorCanvasAgent::updateShader):
1814         (WebCore::InspectorCanvasAgent::frameNavigated):
1815         (WebCore::InspectorCanvasAgent::didChangeCSSCanvasClientNodes):
1816         (WebCore::InspectorCanvasAgent::didCreateCanvasRenderingContext):
1817         (WebCore::InspectorCanvasAgent::willDestroyCanvasRenderingContext):
1818         (WebCore::InspectorCanvasAgent::didChangeCanvasMemory):
1819         (WebCore::InspectorCanvasAgent::recordCanvasAction):
1820         (WebCore::InspectorCanvasAgent::didFinishRecordingCanvasFrame):
1821         (WebCore::InspectorCanvasAgent::consoleStartRecordingCanvas):
1822         (WebCore::InspectorCanvasAgent::didEnableExtension):
1823         (WebCore::InspectorCanvasAgent::didCreateProgram):
1824         (WebCore::InspectorCanvasAgent::canvasDestroyedTimerFired):
1825         (WebCore::InspectorCanvasAgent::canvasRecordingTimerFired):
1826         (WebCore::InspectorCanvasAgent::clearCanvasData):
1827         (WebCore::InspectorCanvasAgent::unbindCanvas):
1828         (WebCore::InspectorCanvasAgent::findInspectorCanvas):
1829         (WebCore::InspectorCanvasAgent::unbindProgram):
1830         (WebCore::InspectorCanvasAgent::didCreateCSSCanvas): Deleted.
1831         (WebCore::InspectorCanvasAgent::canvasDestroyed): Deleted.
1832
1833         * inspector/InspectorInstrumentation.h:
1834         (WebCore::InspectorInstrumentation::didCreateCanvasRenderingContext):
1835         (WebCore::InspectorInstrumentation::willDestroyCanvasRenderingContext):
1836         (WebCore::InspectorInstrumentation::didChangeCanvasMemory):
1837         (WebCore::InspectorInstrumentation::recordCanvasAction):
1838         (WebCore::InspectorInstrumentation::didFinishRecordingCanvasFrame):
1839         (WebCore::InspectorInstrumentation::didEnableExtension):
1840         (WebCore::InspectorInstrumentation::didCreateProgram):
1841         (WebCore::InspectorInstrumentation::willDeleteProgram):
1842         (WebCore::InspectorInstrumentation::isShaderProgramDisabled):
1843         (WebCore::InspectorInstrumentation::consoleStartRecordingCanvas):
1844         (WebCore::InspectorInstrumentation::didCreateCSSCanvas): Deleted.
1845         * inspector/InspectorInstrumentation.cpp:
1846         (WebCore::InspectorInstrumentation::consoleStartRecordingCanvasImpl):
1847         (WebCore::InspectorInstrumentation::didChangeCSSCanvasClientNodesImpl):
1848         (WebCore::InspectorInstrumentation::didCreateCanvasRenderingContextImpl):
1849         (WebCore::InspectorInstrumentation::willDestroyCanvasRenderingContextImpl):
1850         (WebCore::InspectorInstrumentation::didChangeCanvasMemoryImpl):
1851         (WebCore::InspectorInstrumentation::didFinishRecordingCanvasFrameImpl):
1852         (WebCore::InspectorInstrumentation::didEnableExtensionImpl):
1853         (WebCore::InspectorInstrumentation::didCreateProgramImpl):
1854         (WebCore::InspectorInstrumentation::didCreateCSSCanvasImpl): Deleted.
1855
1856         * page/PageConsoleClient.cpp:
1857         (WebCore::PageConsoleClient::record):
1858         (WebCore::PageConsoleClient::recordEnd):
1859
1860         * dom/Document.h:
1861         * dom/Document.cpp:
1862         (WebCore::Document::getCSSCanvasElement):
1863         (WebCore::Document::nameForCSSCanvasElement const):
1864         We have no reason to save the CSS canvas name for each InspectorCanvas object, so instead we
1865         can just query for the name based on the CanvasRenderingContext's HTMLCanvasElement (assuming
1866         it is not an OffscreenCanvas) when we need it.
1867
1868 2017-12-14  Chris Dumez  <cdumez@apple.com>
1869
1870         self.importScripts() should obey updateViaCache inside service workers
1871         https://bugs.webkit.org/show_bug.cgi?id=180826
1872
1873         Reviewed by Youenn Fablet.
1874
1875         self.importScripts() should obey updateViaCache inside service workers, as per:
1876         - https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts
1877
1878         Tests: http/tests/workers/service/registration-updateViaCache-all-importScripts.html
1879                http/tests/workers/service/registration-updateViaCache-imports-importScripts.html
1880                http/tests/workers/service/registration-updateViaCache-none-importScripts.html
1881
1882         * workers/WorkerGlobalScope.cpp:
1883         (WebCore::WorkerGlobalScope::importScripts):
1884         * workers/WorkerScriptLoader.cpp:
1885         (WebCore::WorkerScriptLoader::loadSynchronously):
1886         * workers/WorkerScriptLoader.h:
1887         * workers/service/SWClientConnection.cpp:
1888         (WebCore::SWClientConnection::setRegistrationLastUpdateTime):
1889         * workers/service/SWClientConnection.h:
1890         * workers/service/ServiceWorkerRegistration.cpp:
1891         (WebCore::ServiceWorkerRegistration::lastUpdateTime const):
1892         (WebCore::ServiceWorkerRegistration::setLastUpdateTime):
1893         * workers/service/ServiceWorkerRegistration.h:
1894         * workers/service/server/SWServer.h:
1895         * workers/service/server/SWServerRegistration.cpp:
1896         (WebCore::SWServerRegistration::setLastUpdateTime):
1897         * workers/service/server/SWServerRegistration.h:
1898
1899 2017-12-14  Yusuke Suzuki  <utatane.tea@gmail.com>
1900
1901         Drop Thread::tryCreate
1902         https://bugs.webkit.org/show_bug.cgi?id=180808
1903
1904         Reviewed by Darin Adler.
1905
1906         This change reveals that nobody cares the WorkerThread::start's failure.
1907         We should use `Thread::create` to ensure thread is actually starting.
1908
1909         * workers/WorkerThread.cpp:
1910         (WebCore::WorkerThread::start):
1911         * workers/WorkerThread.h:
1912
1913 2017-12-14  Alicia Boya García  <aboya@igalia.com>
1914
1915         [MSE] Add isValid() check before using trackBuffer.lastEnqueuedPresentationTime
1916         https://bugs.webkit.org/show_bug.cgi?id=180258
1917
1918         Reviewed by Jer Noble.
1919
1920         * Modules/mediasource/SourceBuffer.cpp:
1921         (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
1922
1923 2017-12-14  John Wilander  <wilander@apple.com>
1924
1925         Storage Access API: Implement frame-specific access in the document.cookie layer
1926         https://bugs.webkit.org/show_bug.cgi?id=180682
1927         <rdar://problem/35982257>
1928
1929         Reviewed by Alex Christensen.
1930
1931         No new tests. Changed expected result from existing test.
1932
1933         CookiesStrategy::cookiesForDOM(), CookiesStrategy::setCookiesFromDOM(),
1934         CookiesStrategy::cookieRequestHeaderFieldValue(), and
1935         CookiesStrategy::getRawCookies() now take optional parameters for
1936         frameID and pageID to allow frame-specific scoping of cookies.
1937
1938         This change makes the return values of FrameLoaderClient::frameID()
1939         and FrameLoaderClient::pageID() std::optional<uint64_t> so that
1940         WebCore can call those getters and get the right return values in
1941         WebKit and std:nullopt in WebKitLegacy.
1942
1943         * dom/Document.cpp:
1944         (WebCore::Document::requestStorageAccess):
1945         * loader/CookieJar.cpp:
1946         (WebCore::cookies):
1947         (WebCore::setCookies):
1948         (WebCore::cookieRequestHeaderFieldValue):
1949         (WebCore::getRawCookies):
1950         * loader/EmptyFrameLoaderClient.h:
1951         * loader/FrameLoaderClient.h:
1952         * platform/CookiesStrategy.h:
1953         * platform/network/CacheValidation.cpp:
1954         (WebCore::headerValueForVary):
1955         * platform/network/PlatformCookieJar.h:
1956         * platform/network/cf/CookieJarCFNet.cpp:
1957         (WebCore::setCookiesFromDOM):
1958         (WebCore::cookiesForDOM):
1959         (WebCore::cookieRequestHeaderFieldValue):
1960         (WebCore::getRawCookies):
1961         * platform/network/curl/CookieJarCurl.cpp:
1962         (WebCore::CookieJarCurlFileSystem::setCookiesFromDOM):
1963         (WebCore::CookieJarCurlFileSystem::cookiesForDOM):
1964         (WebCore::CookieJarCurlFileSystem::cookieRequestHeaderFieldValue):
1965         (WebCore::CookieJarCurlFileSystem::getRawCookies):
1966         (WebCore::cookiesForDOM):
1967         (WebCore::setCookiesFromDOM):
1968         (WebCore::cookieRequestHeaderFieldValue):
1969         (WebCore::getRawCookies):
1970         * platform/network/curl/CookieJarCurl.h:
1971         * platform/network/mac/CookieJarMac.mm:
1972         (WebCore::cookiesInPartitionForURL):
1973         (WebCore::cookiesForURL):
1974         (WebCore::cookiesForSession):
1975         (WebCore::cookiesForDOM):
1976         (WebCore::cookieRequestHeaderFieldValue):
1977         (WebCore::setCookiesFromDOM):
1978         (WebCore::getRawCookies):
1979         * platform/network/soup/CookieJarSoup.cpp:
1980         (WebCore::setCookiesFromDOM):
1981         (WebCore::cookiesForDOM):
1982         (WebCore::cookieRequestHeaderFieldValue):
1983         (WebCore::getRawCookies):
1984
1985 2017-12-14  Alex Christensen  <achristensen@webkit.org>
1986
1987         Fix Mac CMake build
1988         https://bugs.webkit.org/show_bug.cgi?id=180835
1989
1990         Reviewed by Andy Estes.
1991
1992         * PlatformMac.cmake:
1993         * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
1994
1995 2017-12-14  Antoine Quint  <graouts@apple.com>
1996
1997         [Web Animations] Use is<> when possible
1998         https://bugs.webkit.org/show_bug.cgi?id=180832
1999
2000         Reviewed by Dean Jackson.
2001
2002         Adopt is<> when possible.
2003
2004         * animation/WebAnimation.cpp:
2005         (WebCore::WebAnimation::setEffect):
2006         (WebCore::WebAnimation::setTimeline):
2007         (WebCore::WebAnimation::startOrStopAccelerated):
2008
2009 2017-12-14  Antoine Quint  <graouts@apple.com>
2010
2011         [Web Animations] Bring timeline and currentTime setters closer to compliance
2012         https://bugs.webkit.org/show_bug.cgi?id=180834
2013
2014         Reviewed by Dean Jackson.
2015
2016         Now that we've added support for the concept of a hold time, pending tasks
2017         and updating the finished state, adopt those in places we had already implemented
2018         but weren't fully compliant.
2019
2020         Web Platform Tests cover these behaviors, but we're currently failing those tests
2021         due to lacking an implementation for Element.animate().
2022
2023         * animation/WebAnimation.cpp:
2024         (WebCore::WebAnimation::setTimeline): Add some spec comments to clarify the code behavior
2025         and implement step 4 of the "setting the timeline" procedure where we reset the hold time
2026         to an unresolved value if the start time is resolved, as well as step 5 where we update the
2027         finished state. Finally, we also ensure we update the pending tasks as the ready state is
2028         dependent on a timeline being set.
2029         (WebCore::WebAnimation::bindingsStartTime const): Invert the way we test for an unresolved
2030         value to match prior review comments by Dean Jackson.
2031         (WebCore::WebAnimation::setBindingsStartTime): Use a boolean check rather than checking
2032         equality with std::nullopt.
2033         (WebCore::WebAnimation::setBindingsCurrentTime): Do not raise an exception when setting
2034         an unresolved time.
2035
2036 2017-12-14  Antoine Quint  <graouts@apple.com>
2037
2038         [Web Animations] Implement the cancel() method on Animation
2039         https://bugs.webkit.org/show_bug.cgi?id=180830
2040         <rdar://problem/36055816>
2041
2042         Reviewed by Dean Jackson.
2043
2044         We implement the cancel() method on the Animation interface with full spec text defining
2045         the normative behavior of those methods and code matching those steps. Implementing the
2046         cancel() method required implementing the notion of "resetting pending tasks",
2047         which the Web Animations spec defines as well.
2048
2049         * animation/WebAnimation.cpp:
2050         (WebCore::WebAnimation::setEffect):
2051         (WebCore::WebAnimation::cancel):
2052         (WebCore::WebAnimation::resetPendingTasks):
2053         * animation/WebAnimation.h:
2054         * animation/WebAnimation.idl:
2055
2056 2017-12-14  Jer Noble  <jer.noble@apple.com>
2057
2058         "Click to exit fullscreen" text not legible on High Sierra
2059         https://bugs.webkit.org/show_bug.cgi?id=180825
2060         <rdar://problem/32839983>
2061
2062         Reviewed by Eric Carlson.
2063
2064         Explicitly set the NSVisualAffectView's .appearance property.
2065
2066         * platform/mac/WebCoreFullScreenPlaceholderView.mm:
2067         (-[WebCoreFullScreenPlaceholderView initWithFrame:]):
2068
2069 2017-12-14  Antoine Quint  <graouts@apple.com>
2070
2071         [Web Animations] Implement the finish() method on Animation
2072         https://bugs.webkit.org/show_bug.cgi?id=180822
2073         <rdar://problem/36053282>
2074
2075         Reviewed by Dean Jackson.
2076
2077         We implement the finish() method on the Animation interface with full spec text defining
2078         the normative behavior of those methods and code matching those steps. Implementing the
2079         finish() method required implementing the notion of "silently setting the current time",
2080         which the Web Animations spec defines as well.
2081
2082         * animation/WebAnimation.cpp:
2083         (WebCore::WebAnimation::silentlySetCurrentTime):
2084         (WebCore::WebAnimation::setCurrentTime):
2085         (WebCore::WebAnimation::finish):
2086         * animation/WebAnimation.h:
2087         * animation/WebAnimation.idl:
2088
2089 2017-12-14  Chris Dumez  <cdumez@apple.com>
2090
2091         Service worker script fetching currently always uses the network cache
2092         https://bugs.webkit.org/show_bug.cgi?id=180816
2093
2094         Reviewed by Alex Christensen.
2095
2096         Service worker script fetching currently always uses the network cache. This is incorrect as per:
2097         - https://w3c.github.io/ServiceWorker/#update-algorithm (step 7.2)
2098
2099         Tests: http/tests/workers/service/registration-updateViaCache-all.html
2100                http/tests/workers/service/registration-updateViaCache-none.html
2101
2102         * workers/Worker.cpp:
2103         (WebCore::Worker::create):
2104         * workers/WorkerScriptLoader.cpp:
2105         (WebCore::WorkerScriptLoader::loadAsynchronously):
2106         * workers/WorkerScriptLoader.h:
2107         * workers/service/SWClientConnection.cpp:
2108         (WebCore::SWClientConnection::startScriptFetchForServer):
2109         * workers/service/SWClientConnection.h:
2110         * workers/service/ServiceWorkerContainer.cpp:
2111         (WebCore::ServiceWorkerContainer::startScriptFetchForJob):
2112         * workers/service/ServiceWorkerContainer.h:
2113         * workers/service/ServiceWorkerJob.cpp:
2114         (WebCore::ServiceWorkerJob::startScriptFetch):
2115         (WebCore::ServiceWorkerJob::fetchScriptWithContext):
2116         * workers/service/ServiceWorkerJob.h:
2117         * workers/service/ServiceWorkerJobClient.h:
2118         * workers/service/server/SWServer.cpp:
2119         (WebCore::SWServer::startScriptFetch):
2120         * workers/service/server/SWServer.h:
2121         * workers/service/server/SWServerJobQueue.cpp:
2122         (WebCore::SWServerJobQueue::runUpdateJob):
2123         * workers/service/server/SWServerRegistration.h:
2124         (WebCore::SWServerRegistration::lastUpdateTime const):
2125
2126 2017-12-14  Simon Fraser  <simon.fraser@apple.com>
2127
2128         Remove ColorSpaceDeviceRGB and most users of the obsolete deviceRGB colorspace
2129         https://bugs.webkit.org/show_bug.cgi?id=180689
2130
2131         Reviewed by Darin Adler.
2132         
2133         Address issues noted by Darin in r225797:
2134         
2135         Existing and new code mistakenly allocated colorspaces on every call, because
2136         they didn't initialize the static variable on the first call. Avoid this mistake
2137         by using dispatch_once() in these functions.
2138
2139         Fix a case where the extendedSRGBColorSpaceRef() fallback was returning deviceRGB
2140         instead of sRGB.
2141
2142         * platform/graphics/cg/GraphicsContextCG.cpp:
2143         (WebCore::sRGBColorSpaceRef):
2144         (WebCore::linearRGBColorSpaceRef):
2145         (WebCore::extendedSRGBColorSpaceRef):
2146         (WebCore::displayP3ColorSpaceRef):
2147         * platform/graphics/cocoa/GraphicsContextCocoa.mm:
2148         (WebCore::linearRGBColorSpaceRef):
2149
2150 2017-12-13  Keith Miller  <keith_miller@apple.com>
2151
2152         JSObjects should have a mask for loading indexed properties
2153         https://bugs.webkit.org/show_bug.cgi?id=180768
2154
2155         Reviewed by Mark Lam.
2156
2157         * bindings/js/JSDOMConvertSequences.h:
2158         (WebCore::Detail::NumericSequenceConverter::convertArray):
2159         (WebCore::Detail::SequenceConverter::convertArray):
2160
2161 2017-12-13  Antoine Quint  <graouts@apple.com>
2162
2163         [Web Animations] Implement the play() and pause() methods on Animation
2164         https://bugs.webkit.org/show_bug.cgi?id=178932
2165         <rdar://problem/35271069>
2166
2167         Reviewed by Eric Carlson.
2168
2169         We implement the play() and pause() methods of the Animation interface with full spec text defining
2170         the normative behavior of those methods and code matching those steps. Playing and pausing animations
2171         incur running a play or pause task when conditions are met, specifically here when the timeline is ready.
2172         So we add the notion of pending tasks and provide a proper implementation of pending() which we had
2173         introduced in an earlier patch with a constant false return value.
2174
2175         Note that the play() method exposes an auto-rewinding flag which we always set to true, but other specs,
2176         namely CSS Animations, do not require the rewinding behavior, so we expose it for future use.
2177
2178         * animation/WebAnimation.cpp:
2179         (WebCore::WebAnimation::play):
2180         (WebCore::WebAnimation::setTimeToRunPendingPlayTask):
2181         (WebCore::WebAnimation::runPendingPlayTask):
2182         (WebCore::WebAnimation::pause):
2183         (WebCore::WebAnimation::setTimeToRunPendingPauseTask):
2184         (WebCore::WebAnimation::runPendingPauseTask):
2185         (WebCore::WebAnimation::updatePendingTasks):
2186         * animation/WebAnimation.h:
2187         * animation/WebAnimation.idl:
2188
2189 2017-12-14  Frederic Wang  <fwang@igalia.com>
2190
2191         Make GraphicsLayer::dumpProperties dump m_offsetFromRenderer
2192         https://bugs.webkit.org/show_bug.cgi?id=180473
2193
2194         Reviewed by Antonio Gomes.
2195
2196         No new tests, this is just a new debug info.
2197
2198         * platform/graphics/GraphicsLayer.cpp:
2199         (WebCore::GraphicsLayer::dumpProperties const): Dump the offset from renderer if nonzero.
2200
2201 2017-12-12  Yusuke Suzuki  <utatane.tea@gmail.com>
2202
2203         REGRESSION(r225769): Build errors with constexpr std::tie on older gcc
2204         https://bugs.webkit.org/show_bug.cgi?id=180692
2205
2206         Reviewed by Carlos Garcia Campos.
2207
2208         * platform/graphics/FontSelectionAlgorithm.h:
2209         (WebCore::FontSelectionRange::operator== const):
2210         (WebCore::FontSelectionRequest::tied const):
2211         (WebCore::FontSelectionCapabilities::tied const):
2212         (WebCore::FontSelectionSpecifiedCapabilities:: const):
2213
2214 2017-12-13  Daniel Bates  <dabates@apple.com>
2215
2216         Fix the Windows build after <https://trac.webkit.org/changeset/225879>
2217         (https://bugs.webkit.org/show_bug.cgi?id=180651)
2218
2219         * html/TextFieldInputType.cpp:
2220         (WebCore::autoFillButtonTypeToAccessibilityLabel):
2221         (WebCore::autoFillButtonTypeToAutoFillButtonText):
2222         (WebCore::autoFillButtonTypeToAutoFillButtonPseudoClassName):
2223
2224 2017-12-13  Devin Rousso  <webkit@devinrousso.com>
2225
2226         Web Inspector: add instrumentation for ImageBitmapRenderingContext
2227         https://bugs.webkit.org/show_bug.cgi?id=180736
2228
2229         Reviewed by Joseph Pecoraro.
2230
2231         Tests: inspector/canvas/create-context-bitmaprenderer.html
2232                inspector/canvas/requestContent-bitmaprenderer.html
2233                inspector/canvas/resolveCanvasContext-bitmaprenderer.html
2234
2235         * CMakeLists.txt:
2236         * Sources.txt:
2237         * WebCore.xcodeproj/project.pbxproj:
2238
2239         * html/HTMLCanvasElement.cpp:
2240         (WebCore::HTMLCanvasElement::getContext):
2241         (WebCore::HTMLCanvasElement::createContextBitmapRenderer):
2242         Support passing an optional settings dictionary when creating an ImageBitmapRenderingContext.
2243
2244         * inspector/agents/InspectorCanvasAgent.cpp:
2245         (WebCore::InspectorCanvasAgent::requestContent):
2246         (WebCore::contextAsScriptValue):
2247
2248         * bindings/js/CallTracerTypes.h:
2249
2250         * inspector/InspectorCanvas.h:
2251         * inspector/InspectorCanvas.cpp:
2252         (WebCore::InspectorCanvas::buildObjectForCanvas):
2253         (WebCore::InspectorCanvas::indexForData):
2254         (WebCore::InspectorCanvas::buildAction):
2255         (WebCore::InspectorCanvas::buildArrayForImageBitmap): Deleted.
2256
2257 2017-12-13  Daniel Bates  <dabates@apple.com>
2258
2259         Add more auto fill button types
2260         https://bugs.webkit.org/show_bug.cgi?id=180651
2261         <rdar://problem/35891125>
2262         And
2263         <rdar://problem/35977943>
2264
2265         Reviewed by Brent Fulgham.
2266
2267         Tests: fast/forms/auto-fill-button/input-autofilled-disabled-strong-password-auto-fill-button.html
2268                fast/forms/auto-fill-button/input-autofilled-readonly-strong-password-auto-fill-button.html
2269                fast/forms/auto-fill-button/input-disabled-strong-password-and-strong-confirmation-password-auto-fill-buttons.html
2270                fast/forms/auto-fill-button/input-readonly-strong-password-and-strong-confirmation-password-auto-fill-buttons.html
2271                fast/forms/auto-fill-button/input-strong-confirmation-password-auto-fill-button.html
2272                fast/forms/auto-fill-button/input-strong-password-auto-fill-button.html
2273
2274         * English.lproj/Localizable.strings:
2275         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
2276         (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): Add strings for new auto fill button types.
2277
2278         * css/CSSSelector.cpp:
2279         (WebCore::CSSSelector::selectorText const):
2280         * css/CSSSelector.h:
2281         * css/SelectorChecker.cpp:
2282         (WebCore::SelectorChecker::checkOne const):
2283         * css/SelectorCheckerTestFunctions.h:
2284         (WebCore::isAutofilledStrongPassword):
2285         * css/SelectorPseudoClassAndCompatibilityElementMap.in:
2286         * css/html.css:
2287         (input::-webkit-strong-password-auto-fill-button):
2288         (input:-webkit-autofill-strong-password):
2289         (input:-webkit-autofill, input:-webkit-autofill-strong-password):
2290         (input:-webkit-autofill): Deleted.
2291         * cssjit/SelectorCompiler.cpp:
2292         (WebCore::SelectorCompiler::addPseudoClassType):
2293         Add new CSS pseudo class and CSS styles.
2294
2295         * html/HTMLInputElement.cpp:
2296         (WebCore::HTMLInputElement::reset): Hide the auto fill button when the form is reset. This is also called
2297         whenever we suspend the page to put it into the page cache.
2298         (WebCore::HTMLInputElement::setShowAutoFillButton): Modified to update the editability of the inner text element
2299         and invalidate styles for the subtree as the editability may have changed depending on the auto fill button type.
2300
2301         (WebCore::autoFillStrongPasswordMaskImage):
2302         (WebCore::HTMLInputElement::createInnerTextStyle):
2303         (WebCore::HTMLInputElement::createInnerTextStyle const): Deleted.
2304         Adjust the look of the inner text field. This function is not const because we may need to resolve style to
2305         generate a mask image.
2306
2307         * html/HTMLInputElement.h:
2308         (WebCore::HTMLInputElement::autoFillButtonType const): Fix style nit; use a C++ style cast while I am in
2309         this area.
2310         (WebCore::HTMLInputElement::hasAutoFillStrongPasswordButton const): Added.
2311
2312         * html/HTMLTextAreaElement.cpp:
2313         (WebCore::HTMLTextAreaElement::createInnerTextStyle):
2314         (WebCore::HTMLTextAreaElement::createInnerTextStyle const): Deleted.
2315         Made this non-const because HTMLInputElement::createInnerTextStyle() needs to be non-const. See above.
2316
2317         * html/HTMLTextAreaElement.h:
2318         * html/HTMLTextFormControlElement.cpp:
2319         (WebCore::HTMLTextFormControlElement::isInnerTextElementEditable const):
2320         (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability):
2321         Extract out the query to determine if the inner text element is editable into a virtual function isInnerTextElementEditable()
2322         and have updateInnerTextElementEditability() make use of it. By default a field is considered editable if it is not disabled
2323         or read-only. We override updateInnerTextElementEditability() in HTMLInputElement to also consider the auto fill button type.
2324
2325         * html/HTMLTextFormControlElement.h:
2326         * html/TextFieldInputType.cpp:
2327         (WebCore::autoFillButtonTypeToAccessibilityLabel):
2328         (WebCore::autoFillButtonTypeToAutoFillButtonText):
2329         (WebCore::autoFillButtonTypeToAutoFillButtonPseudoClassName):
2330         (WebCore::isAutoFillButtonTypeChanged):
2331         (WebCore::TextFieldInputType::createAutoFillButton):
2332         (WebCore::TextFieldInputType::updateAutoFillButton):
2333         Support having text for the auto fill button.
2334
2335         * platform/LocalizedStrings.cpp:
2336         (WebCore::AXAutoFillStrongPasswordLabel):
2337         (WebCore::AXAutoFillStrongConfirmationPasswordLabel):
2338         (WebCore::autoFillStrongPasswordLabel):
2339         * platform/LocalizedStrings.h:
2340         Add localized strings.
2341
2342         * rendering/RenderTextControlSingleLine.h: Disallow scrolling depending on the auto fill button type.
2343
2344         * testing/Internals.cpp:
2345         (WebCore::toAutoFillButtonType):
2346         * testing/Internals.h:
2347         * testing/Internals.idl:
2348         Add support for testing.
2349
2350 2017-12-13  Ryosuke Niwa  <rniwa@webkit.org>
2351
2352         Crash inside ImageLoader::updateFromElement()
2353         https://bugs.webkit.org/show_bug.cgi?id=180769
2354         <rdar://problem/35278782>
2355
2356         Reviewed by Antti Koivisto.
2357
2358         Fixed the crash by moving all call sites of ImageLoader::updateFromElement() to be post insertion callbacks
2359         where it's safe to execute arbitrary scripts.
2360
2361         No new test since existing tests cover this with a newly added release assert in ImageLoader.
2362
2363         * html/HTMLImageElement.cpp:
2364         (WebCore::HTMLImageElement::insertedIntoAncestor):
2365         (WebCore::HTMLImageElement::didFinishInsertingNode): Extracted from insertedIntoAncestor to call
2366         selectImageSource or updateFromElement.
2367         * html/HTMLImageElement.h: Made many member functions final.
2368         * html/HTMLInputElement.cpp:
2369         (WebCore::HTMLInputElement::didAttachRenderers): Delay the call to ImageLoader::updateFromElement() in
2370         ImageInputType using a post style resolution callback.
2371         * html/HTMLMetaElement.h:
2372         * html/HTMLPictureElement.cpp:
2373         (WebCore::HTMLPictureElement::sourcesChanged): Store the list of child image elements into a vector before
2374         calling selectImageSource since each call may execute arbitrary scripts.
2375         * html/HTMLSourceElement.cpp:
2376         (WebCore::HTMLSourceElement::insertedIntoAncestor): Delay the call to ImageLoader::updateFromElement()
2377         using a post style resolution callback.
2378         (WebCore::HTMLSourceElement::didFinishInsertingNode): Extracted from insertedIntoAncestor.
2379         * html/HTMLSourceElement.h:
2380         * html/HTMLVideoElement.cpp:
2381         (WebCore::HTMLVideoElement::didAttachRenderers):
2382         (WebCore::HTMLVideoElement::updateAfterStyleResolution): Extracted from didAttachRenderers.
2383         * html/HTMLVideoElement.h:
2384         * html/ImageInputType.cpp:
2385         (WebCore::ImageInputType::needsPostStyleResolutionCallback): Added. Returns true so that HTMLInputElement's
2386         didAttachRenderers would register a post style resolution callback.
2387         (WebCore::ImageInputType::updateAfterStyleResolution): Extracted from attach.
2388         (WebCore::ImageInputType::attach): Deleted.
2389         * html/ImageInputType.h:
2390         * html/InputType.cpp:
2391         (WebCore::InputType::needsPostStyleResolutionCallback): Added. All but ImageInputType returns false.
2392         (WebCore::InputType::updateAfterStyleResolution): Added.
2393         (WebCore::InputType::attach): Deleted.
2394         * html/InputType.h:
2395         * loader/ImageLoader.cpp:
2396         (WebCore::ImageLoader::updateFromElement): Added a release assertion. There is no direct security implication
2397         so there is no need to use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION here.
2398         * svg/SVGImageElement.cpp:
2399         (WebCore::SVGImageElement::insertedIntoAncestor):
2400         (WebCore::SVGImageElement::didFinishInsertingNode):
2401         * svg/SVGImageElement.h:
2402
2403 2017-12-13  Zalan Bujtas  <zalan@apple.com>
2404
2405         RenderImage can be destroyed even before setting the style on it.
2406         https://bugs.webkit.org/show_bug.cgi?id=180767
2407         <rdar://problem/33965995>
2408
2409         Reviewed by Simon Fraser.
2410
2411         In certain cases, when the newly constructed renderer can't be inserted into the tree (parent can only have specific type of children etc),
2412         RenderTreeUpdater destroys it right away. While destroying a RenderImage, the associated image resource assumes
2413         that the image renderer has been initialized through RenderElement::initializeStyle(). This is an incorrect
2414         assumption.
2415         This patch also makes RenderImageResource's m_renderer a weak pointer.
2416            
2417         Test: fast/images/crash-when-image-renderer-is-destroyed-before-calling-initializeStyle.html
2418
2419         * rendering/RenderImageResource.cpp:
2420         (WebCore::RenderImageResource::initialize):
2421         (WebCore::RenderImageResource::setCachedImage):
2422         (WebCore::RenderImageResource::resetAnimation):
2423         (WebCore::RenderImageResource::image const):
2424         (WebCore::RenderImageResource::setContainerContext):
2425         (WebCore::RenderImageResource::imageSize const):
2426         * rendering/RenderImageResource.h:
2427         (WebCore::RenderImageResource::renderer const):
2428         * rendering/RenderImageResourceStyleImage.cpp:
2429         (WebCore::RenderImageResourceStyleImage::shutdown):
2430
2431 2017-12-13  Ryosuke Niwa  <rniwa@webkit.org>
2432
2433         Update the SVG use element's shadow trees explicitly before the style recall
2434         https://bugs.webkit.org/show_bug.cgi?id=180729
2435         <rdar://problem/36009806>
2436
2437         Reviewed by Antti Koivisto.
2438
2439         Update the SVG use element's shadow trees before start resolving styles. Document now has a hash set of all
2440         connected SVG use elements with invalidated shadow trees. SVGUseElement adds itself to this set when its
2441         shadow tree gets invalidated, or it gets newly connected to a document with the invalidated shadow tree.
2442         SVGUseElement removes itself from this set when it updates its shadow tree or it gets disconnected from
2443         a document with the invalidated shadow tree.
2444
2445         No new tests. Covered by existing tests.
2446
2447         * dom/Document.cpp:
2448         (WebCore::Document::~Document): Assert that m_svgUseElements has been cleared.
2449         (WebCore::Document::resolveStyle): Update the shadow trees of SVG use elements with invalidated shadow trees.
2450         (WebCore::Document::addSVGUseElement): Added.
2451         (WebCore::Document::removeSVGUseElement): Added.
2452         * dom/Document.h:
2453         (WebCore::Document::svgUseElements const): Added.
2454         * dom/Element.cpp:
2455         (WebCore::Element::cloneElementWithChildren): Removed EventAllowedScope since the SVG use element's shadow
2456         tree is no longer updated when there is a NoEventDispatchAssertion in the stack.
2457         (WebCore::Element::cloneElementWithoutChildren): Ditto.
2458         * style/StyleTreeResolver.cpp:
2459         (WebCore::Style::TreeResolver::resolveComposedTree): No longer drops the assertion now that SVG use element's
2460         shadow tree is updated before calling this function.
2461         * svg/SVGUseElement.cpp:
2462         (WebCore::SVGUseElement::insertedIntoAncestor): Add the element to the document's hash set if this use element's
2463         shadow tree needs to be updated (m_shadowTreeNeedsUpdate is set), and it got newly connected.
2464         (WebCore::SVGUseElement::removedFromAncestor): Ditto for removal. We have to check m_shadowTreeNeedsUpdate before
2465         calling SVGGraphicsElement::removedFromAncestor or updateExternalDocument since either function can invoke
2466         m_shadowTreeNeedsUpdate to true.
2467         (WebCore::SVGUseElement::willRecalcStyle): Deleted. We no longer call updateShadowTree during style recalc.
2468         (WebCore::SVGUseElement::updateShadowTree): Remove this element from the document's hah set. We can't clear all
2469         the entries in the map at once in Document::resolveStyle because updating the shadow trees of a SVG use element
2470         can result in a sync IPC in ImageLoader::updateFromElement, which end up executing arbitrary author scripts.
2471         (WebCore::SVGUseElement::cloneTarget const): Removed EventAllowedScope since the SVG use element's shadow tree
2472         is no longer updated when there is a NoEventDispatchAssertion in the stack.
2473         (WebCore::SVGUseElement::expandUseElementsInShadowTree const): Ditto.
2474         (WebCore::SVGUseElement::expandSymbolElementsInShadowTree const): Ditto.
2475         (WebCore::SVGUseElement::invalidateShadowTree): Add the element to the document's hash set if it's connected.
2476         * svg/SVGUseElement.h:
2477
2478 2017-12-13  Per Arne Vollan  <pvollan@apple.com>
2479
2480         REGRESSION(225597): Can't select a text box or web view on a page when VO is on.
2481         https://bugs.webkit.org/show_bug.cgi?id=180756
2482         <rdar://problem/35996158>
2483
2484         Reviewed by Brent Fulgham.
2485
2486         No new tests.
2487
2488         * platform/mac/EventLoopMac.mm:
2489         (WebCore::EventLoop::cycle):
2490
2491 2017-12-13  Antoine Quint  <graouts@apple.com>
2492
2493         [Web Animations] Implement the "updating the finished state" procedure
2494         https://bugs.webkit.org/show_bug.cgi?id=180743
2495         <rdar://problem/36017232>
2496
2497         Reviewed by Simon Fraser.
2498
2499         The Web Animations spec defines a procedure for "updating the finished state", which should run as the timeline time
2500         changes and is responsible for ultimately triggering finish events and fulfil the "finished" promise. The procedure
2501         allows for two flags to control its behavior: didSeek and synchronouslyNotify. When synchronouslyNotify is true, the
2502         "finish notification steps" procedure is ran right away, otherwise it's queued as a microtask.
2503
2504         In this patch we introduce the notion of "hold time", which is the time held while an animation is paused. It will be
2505         set by the pause() and play() method in future patches.
2506
2507         * animation/DocumentTimeline.cpp:
2508         (WebCore::DocumentTimeline::updateAnimations): Update the finished state as the timeline time changes with both flags
2509         set to false.
2510         * animation/WebAnimation.cpp:
2511         (WebCore::WebAnimation::currentTime const): Add a private currentTime(bool) variant which allows for the hold time to
2512         be ignored in case updateFinishedState() was called with the didSeek flag set to false.
2513         (WebCore::WebAnimation::updateFinishedState): Implement the procedure as specified with all spec-mandated steps inline.
2514         (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Schedule a microtask to complete the "finish notification steps"
2515         if we haven't scheduled a microtask before.
2516         (WebCore::WebAnimation::performMicrotask): Perform the microtask if the "finish notification steps" procedure hasn't
2517         been canceled after it was originally scheduled, as tracked by the m_finishNotificationStepsMicrotaskPending flag, since
2518         microtasks are not presently cancelable.
2519         (WebCore::WebAnimation::finishNotificationSteps): Implement the procedure as specified with all spec-mandated steps inline,
2520         dispatching a "finish" events and fulfilling the "finished" promise.
2521         * animation/WebAnimation.h:
2522         * animation/WebAnimation.idl:
2523         * dom/EventNames.h:
2524
2525 2017-12-13  Simon Fraser  <simon.fraser@apple.com>
2526
2527         Fix crash under Document::visualUpdatesSuppressionTimerFired()
2528         https://bugs.webkit.org/show_bug.cgi?id=180758
2529         Document::visualUpdatesSuppressionTimerFired
2530
2531         Reviewed by Zalan Bujtas.
2532
2533         Speculative fix for crash under visualUpdatesSuppressionTimerFired() where view()
2534         can be null. Add null checks for the view() in all code called from this function.
2535
2536         * dom/Document.cpp:
2537         (WebCore::Document::setVisualUpdatesAllowed):
2538         (WebCore::Document::visualUpdatesSuppressionTimerFired):
2539
2540 2017-12-13  Zalan Bujtas  <zalan@apple.com>
2541
2542         ASSERT(LayoutDisallowedScope::isLayoutAllowed()) whenever hitting Enter in Web Inspector console
2543         https://bugs.webkit.org/show_bug.cgi?id=180690
2544
2545         Reviewed by Simon Fraser.
2546
2547         Defer text replacement notification until after layout is done to avoid unexpected forced layouts.
2548
2549         Covered by existing tests.
2550
2551         * accessibility/AXObjectCache.cpp:
2552         (WebCore::AXObjectCache::disableAccessibility):
2553         (WebCore::AXObjectCache::remove):
2554         (WebCore::filterMapForRemoval):
2555         (WebCore::filterListForRemoval):
2556         (WebCore::AXObjectCache::prepareForDocumentDestruction):
2557         (WebCore::AXObjectCache::performDeferredCacheUpdate):
2558         (WebCore::AXObjectCache::deferTextReplacementNotificationForTextControl):
2559         (WebCore::filterForRemoval): Deleted.
2560         * accessibility/AXObjectCache.h: Need to use the base (Element) class since
2561         we can't call is<HTMLTextFormControlElement> in Node d'tor.
2562         (WebCore::AXObjectCache::deferTextReplacementNotificationForTextControl):
2563         * html/HTMLTextFormControlElement.cpp:
2564         (WebCore::HTMLTextFormControlElement::setInnerTextValue):
2565
2566 2017-12-13  Ryan Haddad  <ryanhaddad@apple.com>
2567
2568         Unreviewed, rolling out r225836.
2569
2570         Broke the Windows build.
2571
2572         Reverted changeset:
2573
2574         "Unify some WebGL sources"
2575         https://bugs.webkit.org/show_bug.cgi?id=180726
2576         https://trac.webkit.org/changeset/225836
2577
2578 2017-12-13  Andy Estes  <aestes@apple.com>
2579
2580         [Payment Request] Remove ApplePayPaymentMethodUpdateEvent and use PaymentDetailsModifiers instead
2581         https://bugs.webkit.org/show_bug.cgi?id=180737
2582         <rdar://problem/36013152>
2583
2584         Reviewed by Brady Eidson.
2585
2586         Instead of firing a non-standard "applepaypaymentmethodupdate" event when the payment method
2587         changes, use the PaymentDetailsModifier mechanism to allow the merchant to specify override
2588         totals and additional display items per payment method type.
2589
2590         Test: http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https.html
2591
2592         * DerivedSources.make:
2593         * Modules/applepay/ApplePayLineItem.idl:
2594         * Modules/applepay/ApplePayPaymentMethod.h:
2595         * Modules/applepay/ApplePayPaymentMethod.idl:
2596         * Modules/applepay/ApplePayPaymentMethodType.h: Added.
2597         * Modules/applepay/ApplePayPaymentMethodType.idl: Added.
2598         * Modules/applepay/cocoa/PaymentMethodCocoa.mm:
2599         * Modules/applepay/paymentrequest/ApplePayModifier.h: Added.
2600         * Modules/applepay/paymentrequest/ApplePayModifier.idl: Added.
2601         * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
2602         (WebCore::ApplePayPaymentHandler::show):
2603         (WebCore::ApplePayPaymentHandler::computeTotalAndLineItems):
2604         (WebCore::ApplePayPaymentHandler::detailsUpdated):
2605         (WebCore::ApplePayPaymentHandler::shippingAddressUpdated):
2606         (WebCore::ApplePayPaymentHandler::shippingOptionUpdated):
2607         (WebCore::ApplePayPaymentHandler::paymentMethodUpdated):
2608         (WebCore::ApplePayPaymentHandler::didSelectPaymentMethod):
2609         * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
2610         * Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp: Removed.
2611         * Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h: Removed.
2612         * Modules/paymentrequest/PaymentRequest.h:
2613         * Modules/paymentrequest/PaymentRequest.idl:
2614         * WebCore.xcodeproj/project.pbxproj:
2615         * dom/EventNames.h:
2616         * dom/EventNames.in:
2617         * testing/MockPaymentCoordinator.cpp:
2618         (WebCore::convert):
2619         (WebCore::MockPaymentCoordinator::updateTotalAndLineItems):
2620         (WebCore::MockPaymentCoordinator::completeShippingMethodSelection):
2621         (WebCore::MockPaymentCoordinator::completeShippingContactSelection):
2622         (WebCore::MockPaymentCoordinator::completePaymentMethodSelection):
2623         * testing/MockPaymentCoordinator.h:
2624         * testing/MockPaymentCoordinator.idl:
2625
2626 2017-12-12  Zalan Bujtas  <zalan@apple.com>
2627
2628         is<HTMLTextFormControlElement> reports the input type.
2629         https://bugs.webkit.org/show_bug.cgi?id=180721
2630         <rdar://problem/36005123>
2631
2632         Reviewed by Ryosuke Niwa.
2633
2634         This patch ensures that is<HTMLTextFormControlElement> consistently returns true even
2635         when the input type changes from text to non-text (checkbox etc).
2636
2637         * accessibility/AccessibilityObject.cpp:
2638         (WebCore::AccessibilityObject::selectText):
2639         * dom/Element.h:
2640         (WebCore::Element::isTextFormControlElement const):
2641         (WebCore::Element::isTextField const):
2642         (WebCore::Element::isTextFormControl const): Deleted.
2643         * editing/Editor.cpp:
2644         (WebCore::Editor::selectionForCommand):
2645         (WebCore::Editor::setBaseWritingDirection):
2646         (WebCore::findFirstMarkable):
2647         * editing/FrameSelection.cpp:
2648         (WebCore::FrameSelection::selectAll):
2649         * html/FormController.cpp:
2650         (WebCore::FormController::formElementsCharacterCount const):
2651         * html/HTMLElement.cpp:
2652         (WebCore::HTMLElement::directionality const):
2653         * html/HTMLInputElement.h:
2654         * html/HTMLTextAreaElement.h:
2655         * html/HTMLTextFormControlElement.cpp:
2656         (WebCore::HTMLTextFormControlElement::didEditInnerTextValue):
2657         (WebCore::HTMLTextFormControlElement::selectedText const):
2658         (WebCore::HTMLTextFormControlElement::setSelectionRange):
2659         (WebCore::HTMLTextFormControlElement::selectionStart const):
2660         (WebCore::HTMLTextFormControlElement::computeSelectionStart const):
2661         (WebCore::HTMLTextFormControlElement::selectionEnd const):
2662         (WebCore::HTMLTextFormControlElement::computeSelectionEnd const):
2663         (WebCore::HTMLTextFormControlElement::selectionDirection const):
2664         (WebCore::HTMLTextFormControlElement::computeSelectionDirection const):
2665         (WebCore::HTMLTextFormControlElement::selection const):
2666         (WebCore::HTMLTextFormControlElement::selectionChanged):
2667         (WebCore::HTMLTextFormControlElement::lastChangeWasUserEdit const):
2668         (WebCore::HTMLTextFormControlElement::setInnerTextValue):
2669         (WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const):
2670         (WebCore::enclosingTextFormControl):
2671         * html/HTMLTextFormControlElement.h:
2672         (isType):
2673         * rendering/HitTestResult.cpp:
2674         (WebCore::HitTestResult::isOverTextInsideFormControlElement const):
2675
2676 2017-12-12  Dean Jackson  <dino@apple.com>
2677
2678         Unify some WebGL sources
2679         https://bugs.webkit.org/show_bug.cgi?id=180726
2680
2681         Rubber-stamped by Keith, weeks ago.
2682
2683         * Sources.txt:
2684         * WebCore.xcodeproj/project.pbxproj:
2685         * html/canvas/WebGLRenderingContextBase.cpp:
2686
2687 2017-12-12  Michael Catanzaro  <mcatanzaro@igalia.com>
2688
2689         Unreviewed, fix !ENABLE(MEDIA_STREAM) build after r225822
2690         https://bugs.webkit.org/show_bug.cgi?id=180666
2691         <rdar://problem/36008948>
2692
2693         * html/HTMLMediaElement.cpp:
2694
2695 2017-12-12  Alex Christensen  <achristensen@webkit.org>
2696
2697         Fix possible out-of-bounds read in protocolIsInHTTPFamily
2698         https://bugs.webkit.org/show_bug.cgi?id=180688
2699
2700         Reviewed by Daniel Bates.
2701
2702         It wouldn't read very far out of bounds, and it would just change a bool return value,
2703         but it's still out of bounds.  Covered by an API test that ASAN wouldn't like.
2704
2705         * platform/URL.cpp:
2706         (WebCore::protocolIsInHTTPFamily):
2707         Check bounds before reading a string.
2708
2709 2017-12-12  Youenn Fablet  <youenn@apple.com>
2710
2711         getUserMedia is resolving before the document knows it is capturing
2712         https://bugs.webkit.org/show_bug.cgi?id=180699
2713
2714         Reviewed by Eric Carlson.
2715
2716         Covered by updated test.
2717
2718         Ensure the document state is capturing when getUserMedia promise is resolved by doing the following:
2719         - Promise is resolved when MediaStream is producing data.
2720         - MediaStream asks Document to update its state when MediaStream state is updated.
2721
2722         Introduce PendingActivationMediaStream for waiting for the MediaStream to produce data.
2723
2724         * Modules/mediastream/MediaStream.cpp:
2725         (WebCore::MediaStream::statusDidChange):
2726         * Modules/mediastream/UserMediaRequest.cpp:
2727         (WebCore::UserMediaRequest::allow):
2728         (WebCore::UserMediaRequest::contextDestroyed):
2729         (WebCore::UserMediaRequest::PendingActivationMediaStream::PendingActivationMediaStream):
2730         (WebCore::UserMediaRequest::PendingActivationMediaStream::~PendingActivationMediaStream):
2731         (WebCore::UserMediaRequest::PendingActivationMediaStream::characteristicsChanged):
2732         (WebCore::UserMediaRequest::mediaStreamIsReady):
2733         * Modules/mediastream/UserMediaRequest.h:
2734         (WebCore::UserMediaRequest::PendingActivationMediaStream::create):
2735         * platform/mediastream/RealtimeMediaSourceCenter.h:
2736         * WebCore/WebCore.xcodeproj/project.pbxproj:
2737
2738 2017-12-12  John Wilander  <wilander@apple.com>
2739
2740         Storage Access API: Implement frame-specific access in the network storage session layer
2741         https://bugs.webkit.org/show_bug.cgi?id=180679
2742         <rdar://problem/35982116>
2743
2744         Reviewed by Alex Christensen.
2745
2746         Tests: http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-and-try-access-from-right-frame.html
2747                http/tests/storageAccess/request-and-grant-storage-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-non-recent-user-interaction-but-try-access-from-wrong-frame.html
2748
2749         This changes adds frameID and pageID to what is communicated for
2750         storage access and also stored in the network process' table of
2751         partitioning exceptions.
2752
2753         * dom/Document.cpp:
2754         (WebCore::Document::hasStorageAccess):
2755             Now makes use of the new m_hasFrameSpecificStorageAccess to check
2756             if access has already been granted to this document's domain and
2757             frame.
2758         (WebCore::Document::requestStorageAccess):
2759             Now submits frameID and pageID in the request call and sets
2760             m_hasFrameSpecificStorageAccess upon granted access callback.
2761         * dom/Document.h:
2762         * page/ChromeClient.h:
2763         * platform/network/NetworkStorageSession.h:
2764         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
2765         (WebCore::NetworkStorageSession::cookieStoragePartition const):
2766         (WebCore::NetworkStorageSession::setPrevalentDomainsToPartitionOrBlockCookies):
2767         (WebCore::NetworkStorageSession::isStorageAccessGranted const):
2768         (WebCore::NetworkStorageSession::setStorageAccessGranted):
2769             Now makes use of frameID and pageID for partitioning exceptions.
2770         * platform/network/mac/CookieJarMac.mm:
2771         (WebCore::cookiesInPartitionForURL):
2772         (WebCore::setCookiesFromDOM):
2773             Submits std::nullopt for frameID and pageID.
2774             Follow-up work tracked in https://bugs.webkit.org/show_bug.cgi?id=180682. 
2775         * platform/network/mac/ResourceHandleMac.mm:
2776         (WebCore::ResourceHandle::applySniffingPoliciesAndStoragePartitionIfNeeded):
2777             Submits std::nullopt for frameID and pageID.
2778             Follow-up work tracked in https://bugs.webkit.org/show_bug.cgi?id=180682. 
2779
2780 2017-12-12  Youenn Fablet  <youenn@apple.com>
2781
2782         Playing webrtc video tracks should prevent from display to got to sleep
2783         https://bugs.webkit.org/show_bug.cgi?id=180666
2784
2785         Reviewed by Darin Adler.
2786
2787         Done through manual testing by checking screen assertions taken on webrtc sites.
2788
2789         * html/HTMLMediaElement.cpp:
2790         (WebCore::HTMLMediaElement::shouldDisableSleep const):
2791
2792 2017-12-12  Dean Jackson  <dino@apple.com>
2793
2794         Add CanvasRenderingContext2DBase class and OffscreenCanvasRenderingContext2D
2795         https://bugs.webkit.org/show_bug.cgi?id=180718
2796         <rdar://problem/36004015>
2797
2798         Reviewed by Sam Weinig.
2799
2800         Add an OffscreenCanvasRenderingContext2D class, and in the process create a shared
2801         base class for it and CanvasRenderingContext2D, called CanvasRenderingContext2DBase.
2802         The base class has nearly all the functionality, with the exception of the text
2803         and focus rendering APIs, which are only exposed on CanvasRenderingContext2D.
2804
2805         At the moment CanvasRenderingContext2DBase's implementation still expects the attached
2806         canvas to be an HTMLCanvasElement, but that's ok since you can't yet create an
2807         OffscreenCanvasRenderingContext2D. A subsequent patch will do the right thing.
2808
2809         No change in functionality at the moment, so covered by the existing tests.
2810
2811         * DerivedSources.make: Add the new IDL file.
2812
2813         * Sources.txt: Add all the new files to compile.
2814         * WebCore.xcodeproj/project.pbxproj:
2815
2816         * bindings/js/JSCanvasRenderingContext2DCustom.cpp: Removed some unnecessary headers, and
2817         added JSC:: where appropriate.
2818         (WebCore::JSCanvasRenderingContext2DOwner::isReachableFromOpaqueRoots):
2819         (WebCore::JSCanvasRenderingContext2D::visitAdditionalChildren):
2820
2821         * bindings/js/JSOffscreenCanvasRenderingContext2DCustom.cpp: Copied from Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp.
2822         (WebCore::root): New root function that just returns the address of the OffscreenCanvas.
2823         (WebCore::JSOffscreenCanvasRenderingContext2DOwner::isReachableFromOpaqueRoots):
2824         (WebCore::JSOffscreenCanvasRenderingContext2D::visitAdditionalChildren):
2825
2826         * bindings/js/JSWorkerNavigatorCustom.cpp: Add JSC:: to fix a compilation error.
2827         (WebCore::JSWorkerNavigator::visitAdditionalChildren):
2828
2829         * bindings/js/WebCoreBuiltinNames.h: New IDL types.
2830
2831         * html/OffscreenCanvas.idl: Explicitly generates an IsReachable.
2832
2833         * html/canvas/CanvasRenderingContext.h:
2834         (WebCore::CanvasRenderingContext::isOffscreen2d const): Helper for is<> trait.
2835
2836         * html/canvas/CanvasRenderingContext2D.cpp: Nearly everything has been moved to the Base class.
2837         * html/canvas/CanvasRenderingContext2D.h:
2838         * html/canvas/CanvasRenderingContext2DBase.cpp: Copied from Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp.
2839         * html/canvas/CanvasRenderingContext2DBase.h: Copied from Source/WebCore/html/canvas/CanvasRenderingContext2D.h.
2840
2841         * html/canvas/OffscreenCanvasRenderingContext2D.cpp: Added. Basic implementation that
2842         just uses the Base class.
2843         (WebCore::OffscreenCanvasRenderingContext2D::OffscreenCanvasRenderingContext2D):
2844         * html/canvas/OffscreenCanvasRenderingContext2D.h: Added.
2845         * html/canvas/OffscreenCanvasRenderingContext2D.idl: Added.
2846
2847 2017-12-12  Jer Noble  <jer.noble@apple.com>
2848
2849         [EME] Support FPS-over-HLS in the Modern EME API
2850         https://bugs.webkit.org/show_bug.cgi?id=180707
2851
2852         Reviewed by Eric Carlson.
2853
2854         Add support for the "skd" initDataType, where the initData is the URI provided in the 
2855         EXT-X-KEY tag in a HLS manifest:
2856
2857         * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
2858         (WebCore::CDMPrivateFairPlayStreaming::sinfName):
2859         (WebCore::CDMPrivateFairPlayStreaming::skdName):
2860         (WebCore::extractSinfData):
2861         (WebCore::CDMPrivateFairPlayStreaming::sanitizeSkd):
2862         (WebCore::CDMPrivateFairPlayStreaming::extractKeyIDsSkd):
2863         (WebCore::validInitDataTypes):
2864         (WebCore::CDMFactory::platformRegisterFactories):
2865         (WebCore::CDMPrivateFairPlayStreaming::supportsInitDataType const):
2866         (WebCore::CDMPrivateFairPlayStreaming::supportsConfiguration const):
2867         (WebCore::CDMPrivateFairPlayStreaming::supportsInitData const):
2868         (WebCore::sinfName): Deleted.
2869
2870         Add support for creating a AVContentKeyRequest from a skd key URI rather than from
2871         initialization data, and for extracting keyIDs from the AVContentKeyRequest identifier.
2872
2873         * platform/graphics/avfoundation/CDMFairPlayStreaming.h:
2874         * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
2875         * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
2876         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::keyIDs):
2877         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::requestLicense):
2878         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::updateLicense):
2879         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest):
2880
2881         Add support for AVContentKeySession to MediaPlayerPrivateAVFoundationObjC, and for emitting
2882         initializationData messages when encountering a loading request for a "skd" URI.
2883
2884         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
2885         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
2886         (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
2887         (WebCore::MediaPlayerPrivateAVFoundationObjC::cdmInstanceAttached):
2888         (WebCore::MediaPlayerPrivateAVFoundationObjC::cdmInstanceDetached):
2889         (WebCore::MediaPlayerPrivateAVFoundationObjC::attemptToDecryptWithInstance):
2890
2891 2017-12-12  Antoine Quint  <graouts@apple.com>
2892
2893         [Web Animations] Expose promises on Animation interface
2894         https://bugs.webkit.org/show_bug.cgi?id=180710
2895         <rdar://problem/36000604>
2896
2897         Reviewed by Dean Jackson.
2898
2899         Expose the "ready" and "finished" promises on Animation. A future patch will fulfil or reject them.
2900
2901         * animation/WebAnimation.cpp:
2902         (WebCore::WebAnimation::WebAnimation):
2903         (WebCore::WebAnimation::readyPromiseResolve):
2904         (WebCore::WebAnimation::finishedPromiseResolve):
2905         * animation/WebAnimation.h:
2906         * animation/WebAnimation.idl:
2907
2908 2017-12-12  Youenn Fablet  <youenn@apple.com>
2909
2910         Fetch Event header filtering should apply in CORS mode only
2911         https://bugs.webkit.org/show_bug.cgi?id=180708
2912
2913         Reviewed by Alex Christensen.
2914
2915         Covered by no-longer failing test.
2916
2917         * workers/service/context/ServiceWorkerFetch.cpp: cleaning headers only in case of CORS mode.
2918
2919 2017-12-12  Myles C. Maxfield  <mmaxfield@apple.com>
2920
2921         REGRESSION (Safari 11): custom <font-face> tag crashes a page
2922         https://bugs.webkit.org/show_bug.cgi?id=177848
2923
2924         Reviewed by Darin Adler.
2925
2926         We currently use the CSS property parsers to parse SVG's <font-face> element attributes. Instead,
2927         we should be using the CSS descriptor parsers to parse these attributes. However, this is a
2928         fairly involved task, so until I can finish that, this patch fixes the crash. The crash is simple;
2929         the descriptors shouldn't accept the universal keywords ("initial", "inherit", etc.) and our
2930         font-face machinery assumes this. So the fix is just detect these keywords and explicitly disallow
2931         them.
2932
2933         Test: svg/text/font-style-keyword.html
2934
2935         * svg/SVGFontFaceElement.cpp:
2936         (WebCore::SVGFontFaceElement::parseAttribute):
2937
2938 2017-12-12  Antoine Quint  <graouts@apple.com>
2939
2940         [Web Animations] Implement the playState property on Animation
2941         https://bugs.webkit.org/show_bug.cgi?id=180711
2942         <rdar://problem/36000982>
2943
2944         Reviewed by Dean Jackson.
2945
2946         Expose the playState and pending properties. The playState property has a complete implementation but
2947         has some test failures due to Animation lacking correct behavior while running animations which will
2948         be fixed in a followup patch. The pending property is a placeholder until we implement pending play
2949         and pause tasks in followup patches.
2950
2951         * animation/WebAnimation.cpp:
2952         (WebCore::WebAnimation::playState const):
2953         (WebCore::WebAnimation::effectEndTime const):
2954         * animation/WebAnimation.h:
2955         * animation/WebAnimation.idl:
2956
2957 2017-12-12  Javier Fernandez  <jfernandez@igalia.com>
2958
2959         [css-grid] Implement alignment for absolute positioned grid items
2960         https://bugs.webkit.org/show_bug.cgi?id=180632
2961
2962         Reviewed by Manuel Rego Casasnovas.
2963
2964         We are changing how we compute the grid area's size of positioned
2965         items, trying to make the logic as independent as possible of the
2966         grid container's direction.
2967
2968         The new way of placing absolute positioned elements in their grid area
2969         is based on the previously computed area's size. This provide a
2970         mechanism to place an item in its area respecting the offsets derived
2971         from the Content Alignment CSS properties and, which is more important,
2972         ignoring the grid container's direction.
2973
2974         Additionally, we use the already implemented alignment logic that's
2975         used for regular grid items. This patch provides almost full alignment
2976         capabilities for positioned objects, with the exception of 'stretch'.
2977
2978         It's worth mentioning that some of the test cases using vertical-rl
2979         writing mode will fail because of the bug 180633.
2980
2981         Updated web-platform-tests results of the test cases that pass now.
2982
2983         * rendering/GridLayoutFunctions.cpp:
2984        (WebCore::GridLayoutFunctions::hasOverrideContainingBlockContentSizeForChild):
2985         (WebCore::GridLayoutFunctions::overrideContainingBlockContentSizeForChild):
2986         * rendering/GridLayoutFunctions.h:
2987         * rendering/GridTrackSizingAlgorithm.cpp:
2988         (WebCore::GridTrackSizingAlgorithmStrategy::updateOverrideContainingBlockContentSizeForChild const):
2989         * rendering/RenderGrid.cpp:
2990         (WebCore::RenderGrid::layoutBlock):
2991         (WebCore::RenderGrid::gridItemOffset const):
2992         (WebCore::RenderGrid::hasStaticPositionForChild const):
2993         (WebCore::RenderGrid::layoutPositionedObject):
2994         (WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded):
2995         (WebCore::RenderGrid::columnAxisPositionForChild const):
2996         (WebCore::RenderGrid::rowAxisPositionForChild const):
2997         (WebCore::RenderGrid::columnAxisOffsetForChild const):
2998         (WebCore::RenderGrid::rowAxisOffsetForChild const):
2999         (WebCore::RenderGrid::gridPositionIsAutoForOutOfFlow const):
3000         (WebCore::RenderGrid::resolveAutoStartGridPosition const):
3001         (WebCore::RenderGrid::resolveAutoEndGridPosition const):
3002         (WebCore::RenderGrid::gridAreaBreadthForOutOfFlowChild):
3003         (WebCore::RenderGrid::logicalOffsetForChild const):
3004         (WebCore::RenderGrid::gridAreaPositionForOutOfFlowChild const):
3005         (WebCore::RenderGrid::gridAreaPositionForInFlowChild const):
3006         (WebCore::RenderGrid::gridAreaPositionForChild const):
3007         (WebCore::RenderGrid::translateOutOfFlowRTLCoordinate const):
3008         (WebCore::RenderGrid::findChildLogicalPosition const):
3009         * rendering/RenderGrid.h:
3010         * rendering/style/GridPositionsResolver.cpp:
3011         (WebCore::adjustGridPositionsFromStyle):
3012         (WebCore::GridPositionsResolver::initialPositionSide):
3013         (WebCore::GridPositionsResolver::finalPositionSide):
3014         * rendering/style/GridPositionsResolver.h:
3015
3016 2017-12-12  Jer Noble  <jer.noble@apple.com>
3017
3018         [EME] Support reporting and restoring persistent usage data.
3019         https://bugs.webkit.org/show_bug.cgi?id=180684
3020
3021         Reviewed by Eric Carlson.
3022
3023         Add support for reading and acknowledging persistent usage data from the MediaKeys storage
3024         directory.
3025
3026         Add a mechanism for passing the storage location down to CDMPrivate and CDMInstance objects
3027         inside of the CDM class itself:
3028
3029         * Modules/encryptedmedia/CDM.cpp:
3030         (WebCore::CDM::createInstance):
3031         (WebCore::CDM::storageDirectory const):
3032         * Modules/encryptedmedia/CDM.h:
3033
3034         Support loading expired session data, acknowledging expired session data, closing sessions
3035         and removing usable key data.
3036
3037         * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
3038         * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
3039         (WebCore::isEqual):
3040         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::updateLicense):
3041         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::loadSession):
3042         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::closeSession):
3043         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::removeSessionData):
3044
3045 2017-12-12  Christopher Reid  <chris.reid@sony.com>
3046
3047         WebGL TextureMapperShaderProgram shaders don't compile in MSVC
3048         https://bugs.webkit.org/show_bug.cgi?id=180709
3049
3050         Reviewed by Myles C. Maxfield.
3051
3052         No new tests, no change in behavior.
3053
3054         Vertex and Fragment shaders were not compiling because TextureMapperShaderProgram.cpp was
3055         stringifying "#if USE(OPENGL_ES_2) ... #endif" into the shaders rather than evaluating these
3056         preprocessor directives before the STRINGIFY expansion.
3057
3058         Moved these #if conditions outside of STRINGIFY to remove compiler ambiguity.
3059
3060         * platform/graphics/texmap/TextureMapperShaderProgram.cpp:
3061
3062 2017-12-12  Zach Li  <zachli@apple.com>
3063         [WK2] Expose image via WKBundleHitTestResult API.
3064         https://bugs.webkit.org/show_bug.cgi?id=180552.
3065         rdar://problem/23951521
3066
3067         Reviewed by Simon Fraser.
3068
3069         * platform/graphics/ImageSource.h:
3070         This method will be used by clients outside WebCore, so
3071         add WEBCORE_EXPORT.
3072
3073 2017-12-12  Simon Fraser  <simon.fraser@apple.com>
3074
3075         Remove ColorSpaceDeviceRGB and most users of the obsolete deviceRGB colorspace
3076         https://bugs.webkit.org/show_bug.cgi?id=180689
3077
3078         Reviewed by Tim Horton.
3079
3080         Remove the ColorSpaceDeviceRGB enum and users.
3081
3082         ImageBuffer now uses sRGB instead of deviceRGB in the few cases that used the latter.
3083
3084         Switch Windows CG code to use sRGBColorSpaceRef() instead of deviceRGBColorSpaceRef().
3085
3086         Have linearRGBColorSpaceRef() use kCGColorSpaceLinearSRGB, which is present in iOS 9 and 10.11 and later.
3087
3088         * page/win/FrameCGWin.cpp:
3089         (WebCore::imageFromRect):
3090         * platform/graphics/Color.cpp:
3091         (WebCore::operator<<):
3092         * platform/graphics/ColorSpace.h:
3093         * platform/graphics/ImageBuffer.cpp:
3094         (WebCore::ImageBuffer::transformColorSpace):
3095         * platform/graphics/cg/ColorCG.cpp:
3096         (WebCore::Color::Color):
3097         (WebCore::leakCGColor):
3098         (WebCore::createCGColorWithDeviceRGBA): Deleted.
3099         * platform/graphics/cg/GraphicsContextCG.cpp:
3100         (WebCore::sRGBColorSpaceRef):
3101         (WebCore::linearRGBColorSpaceRef):
3102         (WebCore::extendedSRGBColorSpaceRef):
3103         (WebCore::displayP3ColorSpaceRef):
3104         (WebCore::deviceRGBColorSpaceRef): Deleted.
3105         * platform/graphics/cg/GraphicsContextCG.h:
3106         (WebCore::cachedCGColorSpace):
3107         * platform/graphics/cocoa/GraphicsContextCocoa.mm:
3108         * platform/graphics/win/GraphicsContextCGWin.cpp:
3109         (WebCore::CGContextWithHDC):
3110         (WebCore::GraphicsContext::releaseWindowsContext):
3111         (WebCore::GraphicsContext::drawWindowsBitmap):
3112         * platform/graphics/win/ImageCGWin.cpp:
3113         (WebCore::BitmapImage::create):
3114         (WebCore::BitmapImage::getHBITMAPOfSize):
3115         * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
3116         (WebCore::MockRealtimeVideoSourceMac::pixelBufferFromCGImage const):
3117         * platform/win/DragImageCGWin.cpp:
3118         (WebCore::allocImage):
3119         (WebCore::createCgContextFromBitmap):
3120         * rendering/svg/RenderSVGResourceFilter.cpp:
3121         (WebCore::RenderSVGResourceFilter::postApplyResource):
3122         * rendering/svg/RenderSVGResourceMasker.cpp:
3123         (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
3124
3125 2017-12-12  Youenn Fablet  <youenn@apple.com>
3126
3127         Navigation requests should use navigate fetch mode
3128         https://bugs.webkit.org/show_bug.cgi?id=179808
3129
3130         Reviewed by Chris Dumez.
3131
3132         Covered by existing tests.
3133
3134         * Modules/fetch/FetchRequest.cpp:
3135         (WebCore::buildOptions): Update to throw only if init.mode is Navigate.
3136         * Modules/fetch/FetchRequestInit.h:
3137         (WebCore::FetchRequestInit::hasMembers const): If init is present, set default values as per spec.
3138         * loader/DocumentLoader.cpp:
3139         (WebCore::DocumentLoader::loadMainResource): Set fetch mode to navigate.
3140         * loader/DocumentThreadableLoader.cpp:
3141         (WebCore::DocumentThreadableLoader::DocumentThreadableLoader): Bypass preflight in case fetch mode is navigate.
3142
3143 2017-12-12  Simon Fraser  <simon.fraser@apple.com>
3144
3145         HTML-page with <object type="image/svg+xml" data="foo.svg"> often is blank
3146         https://bugs.webkit.org/show_bug.cgi?id=180524
3147         <rdar://problem/35920554>
3148
3149         Reviewed by Antti Koivisto.
3150
3151         The test case has script that conditionalizes behavior on whether window.innerWidth/Height
3152         are zero during the load event. We didn't force layout in innerWidth/Height, so whether
3153         they would zero depended on whether the parent frame had laid out, which was timing-sensitive.
3154
3155         Fix by triggering enough layout in the parent document so that the FrameView is resized before
3156         fetching its dimensions in innerWidth/Height. This causes our behavior to match Chrome and Firefox.
3157
3158         Test: fast/dom/iframe-innerWidth.html
3159
3160         * dom/EventDispatcher.cpp:
3161         (WebCore::EventDispatcher::dispatchEvent): Add some logging that helped me diagnose this.
3162         * page/DOMWindow.cpp:
3163         (WebCore::DOMWindow::innerHeight const):
3164         (WebCore::DOMWindow::innerWidth const):
3165
3166 2017-12-11  Antoine Quint  <graouts@apple.com>
3167
3168         [Web Animations] Enqueue and dispatch animation events
3169         https://bugs.webkit.org/show_bug.cgi?id=180657
3170         <rdar://problem/35970103>
3171
3172         Reviewed by Chris Dumez.
3173
3174         Now that we have support for the AnimationPlaybackEvent interface, we need a way to enqueue
3175         such events for dispatch at the opportune time. The Web Animations spec defines two ways
3176         to queue and dispatch events.
3177
3178         If the animation has a "document for timing", it should enqueue events on this document.
3179         In our implementation, if the animation timeline is set to a DocumentTimeline, that means
3180         it has a document for timing, and we let the DocumentTimeline enqueue those events, which
3181         will be dispatched through a dedicated GenericTaskQueue<Timer>. These events will be sorted
3182         by their respective timeline time before being dispatched.
3183
3184         If there is no document for timing, events should be dispatched as a standalone task.
3185
3186         * animation/DocumentTimeline.cpp:
3187         (WebCore::DocumentTimeline::~DocumentTimeline): Close the event dispatch task queue when the
3188         document timeline is torn down.
3189         (WebCore::DocumentTimeline::enqueueAnimationPlaybackEvent): Add the provided event to the
3190         pending animation events queue and, if one hasn't been registered yet, enqueue a task to
3191         dispatch events using a GenericTaskQueue<Timer>.
3192         (WebCore::compareAnimationPlaybackEvents): Comparator used to sort events in performEventDispatchTask()
3193         where events are sorted such that unresolved timeline times come first, and then from the
3194         earlier resolved timeline times to the later resolved timeline times. Events with unresolved
3195         timeline times and equal resolved timeline times are sorted in the order they were enqueued.
3196         (WebCore::DocumentTimeline::performEventDispatchTask): Run a stable sort on a copy of the pending list
3197         of events to dispatch and dispatch the events individually on their respective animations.
3198         * animation/DocumentTimeline.h:
3199         * animation/WebAnimation.cpp:
3200         (WebCore::WebAnimation::create): Pass in the document to the constructor.
3201         (WebCore::WebAnimation::WebAnimation): Use the provided document to initialize ActiveDOMObject.
3202         (WebCore::WebAnimation::enqueueAnimationPlaybackEvent): Create an AnimationPlaybackEvent with
3203         the provided type, timeline time and animation time and enqueue it on the document timeline,
3204         if one is available, or dispatch on this animation as a standalone task.
3205         (WebCore::WebAnimation::acceleratedRunningStateDidChange):
3206         (WebCore::WebAnimation::activeDOMObjectName const):
3207         (WebCore::WebAnimation::canSuspendForDocumentSuspension const):
3208         (WebCore::WebAnimation::stop):
3209         * animation/WebAnimation.h: Define WebAnimation to be an EventTarget and an ActiveDOMObject.
3210         * animation/WebAnimation.idl: Define WebAnimation to be an EventTarget and an ActiveDOMObject.
3211         * dom/EventTargetFactory.in:
3212
3213 2017-12-12  Chris Dumez  <cdumez@apple.com>
3214
3215         Simplify IPC code between WebProcess and StorageProcess for serviceWorker.postMessage()
3216         https://bugs.webkit.org/show_bug.cgi?id=180683
3217
3218         Reviewed by Brady Eidson.
3219
3220         Merge the 2 code paths from calling postMessage() from a ServiceWorkerClient and from
3221         a ServiceWorker. Also, postMessage() now only IPCs an identifier from the WebContent
3222         process to the StorageProcess. The ServiceWorkerClientData is looked up on Storage
3223         process side from the identifier before being sent to the context process.
3224
3225         * workers/service/SWClientConnection.h:
3226         * workers/service/ServiceWorker.cpp:
3227         (WebCore::ServiceWorker::postMessage):
3228         * workers/service/ServiceWorkerTypes.h:
3229         * workers/service/server/SWServer.cpp:
3230         (WebCore::SWServer::clientByID const):
3231         (WebCore::SWServer::matchAll):
3232         (WebCore::SWServer::forEachClientForOrigin):
3233         (WebCore::SWServer::claim):
3234         (WebCore::SWServer::registerServiceWorkerClient):
3235         (WebCore::SWServer::unregisterServiceWorkerClient):
3236         * workers/service/server/SWServer.h:
3237         * workers/service/server/SWServerWorker.cpp:
3238         (WebCore::SWServerWorker::findClientByIdentifier):
3239         * workers/service/server/SWServerWorker.h:
3240
3241 2017-12-12  Youenn Fablet  <youenn@apple.com>
3242
3243         Allow AudioContext to start when getUserMedia is on
3244         https://bugs.webkit.org/show_bug.cgi?id=180680
3245
3246         Reviewed by Eric Carlson.
3247
3248         Test: webrtc/getUserMedia-webaudio-autoplay.html
3249
3250         * Modules/webaudio/AudioContext.cpp:
3251         (WebCore::AudioContext::willBeginPlayback):
3252
3253 2017-12-12  Romain Bellessort  <romain.bellessort@crf.canon.fr>
3254
3255         [Readable Streams API] Throw RangeError if a size is provided when creating a readable byte stream
3256         https://bugs.webkit.org/show_bug.cgi?id=180470
3257
3258         Reviewed by Youenn Fablet.
3259
3260         Throw a RangeError if a ReadableStream is created with type 'bytes' and with a
3261         non-undefined strategy size, as per latest spec:
3262         - https://github.com/whatwg/streams/pull/856
3263         - https://streams.spec.whatwg.org/#rs-constructor (step 4.c)
3264
3265         One new test imported from WPT to check that RangeError is thrown.
3266
3267         * Modules/streams/ReadableStream.js:
3268         (initializeReadableStream): Check strategy size and throw RangeError if needed.
3269
3270 2017-12-12  Carlos Alberto Lopez Perez  <clopez@igalia.com>
3271
3272         [GTK][WebRTC] Stop warning with so much verbosity about not implemented RealtimeMediaSourceCenter
3273         https://bugs.webkit.org/show_bug.cgi?id=180694
3274
3275         Reviewed by Youenn Fablet.
3276
3277         No new tests -- no change in functionality.
3278
3279         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
3280         (WebCore::RealtimeMediaSourceCenter::singleton):
3281
3282 2017-12-12  Ms2ger  <Ms2ger@igalia.com>
3283
3284         Implement {DOMMimeTypeArray, DOMPluginArray}::supportedPropertyNames().
3285         https://bugs.webkit.org/show_bug.cgi?id=180471
3286
3287         Reviewed by Darin Adler.
3288
3289         Test: imported/w3c/web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-pluginarray.html
3290
3291         * plugins/DOMMimeTypeArray.cpp:
3292         (WebCore::DOMMimeTypeArray::supportedPropertyNames):
3293         * plugins/DOMPluginArray.cpp:
3294         (WebCore::DOMPluginArray::supportedPropertyNames):
3295
3296 2017-12-12  Yusuke Suzuki  <utatane.tea@gmail.com>
3297
3298         [WTF] Thread::create should have Thread::tryCreate
3299         https://bugs.webkit.org/show_bug.cgi?id=180333
3300
3301         Reviewed by Darin Adler.
3302
3303         No behavior change.
3304
3305         * bindings/js/GCController.cpp:
3306         (WebCore::GCController::garbageCollectOnAlternateThreadForDebugging):
3307         * platform/audio/ReverbConvolver.cpp:
3308         (WebCore::ReverbConvolver::ReverbConvolver):
3309         * platform/audio/ReverbConvolver.h:
3310         * workers/WorkerThread.cpp:
3311         (WebCore::WorkerThread::start):
3312
3313 2017-12-11  Manuel Rego Casasnovas  <rego@igalia.com>
3314
3315         [css-grid] Automatic minimum size is not clamped if min track sizing function is auto
3316         https://bugs.webkit.org/show_bug.cgi?id=180283
3317
3318         Reviewed by Darin Adler.
3319
3320         We were not clamping the automatic minimum size when
3321         the min track sizing function was intrinsic (e.g. minmax(auto, 0px)).
3322         However the spec (https://drafts.csswg.org/css-grid/#min-size-auto)
3323         is very clear regarding that.
3324
3325         This patch modifies
3326         GridTrackSizingAlgorithm::sizeTrackToFitNonSpanningItem(),
3327         so in the case of a fixed max track sizing function it clamps
3328         the automatic minimum size of the item to the stretch fit
3329         of the grid area's size.
3330         It needs to take into account if the item has fixed size, margin, border
3331         and/or padding as those cannot be clamped.
3332
3333         Using WPT tests to verify this behavior,
3334         and corrected a bunch of other tests that were wrong.
3335
3336         Test: imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-minimum-size-grid-items-017.html
3337               imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-minimum-size-grid-items-022.html
3338               imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-minimum-size-grid-items-023.html
3339
3340         * rendering/GridTrackSizingAlgorithm.cpp:
3341         (WebCore::GridTrackSizingAlgorithm::sizeTrackToFitNonSpanningItem):
3342         * rendering/GridTrackSizingAlgorithm.h:
3343         (WebCore::GridTrack::growthLimitIsInfinite const):
3344         * rendering/style/GridTrackSize.h:
3345         (WebCore::GridTrackSize::cacheMinMaxTrackBreadthTypes):
3346         (WebCore::GridTrackSize::hasFixedMaxTrackBreadth const):
3347
3348 2017-12-11  Zan Dobersek  <zdobersek@igalia.com>
3349
3350         [Cairo] Cairo::clipToImageBuffer() should operate on a cairo_surface_t
3351         https://bugs.webkit.org/show_bug.cgi?id=180665
3352
3353         Reviewed by Michael Catanzaro.
3354
3355         Have the Cairo::clipToImageBuffer() function in the CairoUtilities code
3356         operate on a cairo_surface_t object, instead of an Image object.
3357
3358         Call site in GraphicsContext::clipToImageBuffer() is adjusted to first
3359         ensure a non-null Image object, and then retrieve a cairo_surface_t
3360         object from that, passing it on to Cairo::clipToImageBuffer().
3361
3362         No new tests -- no change in functionality.
3363
3364         * platform/graphics/cairo/CairoOperations.cpp:
3365         (WebCore::Cairo::clipToImageBuffer):
3366         * platform/graphics/cairo/CairoOperations.h:
3367         * platform/graphics/cairo/GraphicsContextCairo.cpp:
3368         (WebCore::GraphicsContext::clipToImageBuffer):
3369
3370 2017-12-11  Zan Dobersek  <zdobersek@igalia.com>
3371
3372         [Cairo] Don't use a static cairo_surface_t object for CairoPath contexts
3373         https://bugs.webkit.org/show_bug.cgi?id=180663
3374
3375         Reviewed by Michael Catanzaro.
3376
3377         Instead of using a single cairo_surface_t object and sharing it between
3378         different cairo_t objects handled by CairoPath, create a new mock 1x1px
3379         alpha-only surface for each cairo_t object that's allocated in the
3380         CairoPath constructor.
3381
3382         This avoids potential issues in how Cairo's state handling internally
3383         uses these surfaces, which is completely opaque to us and out of our
3384         control. This also avoids crashes when using this one cairo_surface_t
3385         object through different CairoPath objects across different threads.
3386
3387         No new tests -- no change in behavior.
3388
3389         * platform/graphics/cairo/PlatformPathCairo.cpp:
3390         (WebCore::CairoPath::CairoPath):
3391         (WebCore::pathSurface): Deleted.
3392         * platform/graphics/cairo/PlatformPathCairo.h:
3393         (WebCore::CairoPath::context):
3394
3395 2017-12-11  Zan Dobersek  <zdobersek@igalia.com>
3396
3397         [CoordGraphics] Move UpdateAtlas, AreaAllocator into the platform layer
3398         https://bugs.webkit.org/show_bug.cgi?id=180641
3399
3400         Reviewed by Michael Catanzaro.
3401
3402         Move the UpdateAtlas and AreaAllocator classes and their source files
3403         into the platform layer. This still means using the WebCore namespace,
3404         but apart from that these two classes have no dependency on anything in
3405         the WebKit layer, so they can be moved from there.
3406
3407         No new tests -- no change in functionality.
3408
3409         * platform/TextureMapper.cmake:
3410         * platform/graphics/texmap/coordinated/AreaAllocator.cpp: Renamed from Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp.
3411         (WebCore::AreaAllocator::AreaAllocator):
3412         (WebCore::AreaAllocator::~AreaAllocator):
3413         (WebCore::AreaAllocator::expand):
3414         (WebCore::AreaAllocator::expandBy):
3415         (WebCore::AreaAllocator::release):
3416         (WebCore::AreaAllocator::overhead const):
3417         (WebCore::AreaAllocator::roundAllocation const):
3418         (WebCore::GeneralAreaAllocator::GeneralAreaAllocator):
3419         (WebCore::GeneralAreaAllocator::~GeneralAreaAllocator):
3420         (WebCore::GeneralAreaAllocator::freeNode):
3421         (WebCore::GeneralAreaAllocator::expand):
3422         (WebCore::fitsWithin):
3423         (WebCore::GeneralAreaAllocator::allocate):
3424         (WebCore::GeneralAreaAllocator::allocateFromNode):
3425         (WebCore::GeneralAreaAllocator::splitNode):
3426         (WebCore::GeneralAreaAllocator::updateLargestFree):
3427         (WebCore::GeneralAreaAllocator::release):
3428         (WebCore::GeneralAreaAllocator::overhead const):
3429         * platform/graphics/texmap/coordinated/AreaAllocator.h: Renamed from Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h.
3430         (WebCore::nextPowerOfTwo):
3431         (WebCore::AreaAllocator::size const):
3432         (WebCore::AreaAllocator::minimumAllocation const):
3433         (WebCore::AreaAllocator::setMinimumAllocation):
3434         (WebCore::AreaAllocator::margin const):
3435         (WebCore::AreaAllocator::setMargin):
3436         * platform/graphics/texmap/coordinated/UpdateAtlas.cpp: Renamed from Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp.
3437         (WebCore::UpdateAtlas::UpdateAtlas):
3438         (WebCore::UpdateAtlas::~UpdateAtlas):
3439         (WebCore::UpdateAtlas::buildLayoutIfNeeded):
3440         (WebCore::UpdateAtlas::didSwapBuffers):
3441         (WebCore::UpdateAtlas::getCoordinatedBuffer):
3442         * platform/graphics/texmap/coordinated/UpdateAtlas.h: Renamed from Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h.
3443         (WebCore::UpdateAtlas::size const):
3444         (WebCore::UpdateAtlas::supportsAlpha const):
3445         (WebCore::UpdateAtlas::addTimeInactive):
3446         (WebCore::UpdateAtlas::isInactive const):
3447         (WebCore::UpdateAtlas::isInUse const):
3448
3449 2017-12-11  Ryosuke Niwa  <rniwa@webkit.org>
3450
3451         Disable NoEventDispatchAssertion release assertion in WebKit1
3452         https://bugs.webkit.org/show_bug.cgi?id=180616
3453
3454         Reviewed by Zalan Bujtas.
3455
3456         Disabled the release assertion for NoEventDispatchAssertion in WebKit1 since there are many
3457         delegate callbacks that happen at unsafe timing, and we don't have any hope of fixing them
3458         in short term.
3459
3460         * bindings/js/ScriptController.cpp:
3461         (WebCore::ScriptController::canExecuteScripts):
3462         * dom/Document.cpp:
3463         (WebCore::isSafeToUpdateStyleOrLayout):
3464         * dom/ScriptElement.cpp:
3465         (WebCore::ScriptElement::executeClassicScript):
3466         * platform/RuntimeApplicationChecks.h:
3467         (WebCore::isInWebProcess):
3468         * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
3469         (WebCore::isInWebProcess): Extracted from IOSApplication::isWebProcess.
3470         (WebCore::IOSApplication::isWebProcess):
3471
3472 2017-12-11  Darin Adler  <darin@apple.com>
3473
3474         Improve FontSelectionAlgorithm, including moving from IntegerHasher to Hasher
3475         https://bugs.webkit.org/show_bug.cgi?id=180340
3476
3477         Reviewed by Dan Bates.
3478
3479         * css/CSSFontFaceSet.h: Moved FontSelectionRequestKey and FontSelectionRequestKeyHash
3480         here to be private members, and used a std::optional instead of a class for this.
3481         Also use the new Hasher to compute the hash. Also added FontSelectionRequestKeyHashTraits.
3482
3483         * platform/graphics/FontDescription.cpp:
3484         (WebCore::FontDescription::FontDescription): Updated since FontSelectionRequest
3485         does not always have a constructor any more.
3486
3487         * platform/graphics/FontSelectionAlgorithm.h: Tweaked comments. Used "using" instead
3488         of typedef. Formatted some trivial functions as single lines. Stopped using
3489         NeverDestroyed for simple classes like FontSelectionValue; it's not needed unless
3490         there is a destructor. Got rid of some incorrect use of const. Replaced some member
3491         functions with non-member functions. Moved some function bodies out of class definitions.
3492         Used a lot of constexpr functions.
3493         (WebCore::FontSelectionRequest::tied const): Added so we can easily write both == and the
3494         hash function without listing the data members.
3495         (WebCore::add): Added an overload so we can hash things that include FontSelectionRequest.
3496         (WebCore::FontSelectionRequestKey::FontSelectionRequestKey): Changed this class to
3497         use std::optional instead of a separate boolean for deleted values.
3498         (WebCore::FontSelectionRequestKey::isHashTableDeletedValue const): Ditto.
3499         (WebCore::FontSelectionRequestKey::operator== const): Ditto.
3500         (WebCore::FontSelectionRequestKeyHash::hash): Ditto.
3501         (WebCore::FontSelectionRequestKeyHash::equal): Ditto.
3502         (WebCore::FontSelectionCapabilities::tied const): Added so we can easily write both ==
3503         and the hash function without listing the data members.
3504         (WebCore::FontSelectionSpecifiedCapabilities::tied const): Ditto.
3505         (WebCore::FontSelectionAlgorithm::FontSelectionAlgorithm): Use make_unique instead of new.
3506
3507         * platform/graphics/cocoa/FontCacheCoreText.cpp:
3508         (WebCore::findClosestFont): Move in the vector instead of copying it when creating a
3509         FontSelectionAlgorithm object.
3510
3511 2017-12-11  Jer Noble  <jer.noble@apple.com>
3512
3513         [EME] support update() for FairPlayStreaming in Modern EME API
3514         https://bugs.webkit.org/show_bug.cgi?id=180542
3515
3516         Reviewed by Eric Carlson.
3517
3518         Support the updateLicense() method in CDMInstanceFairPlayStreaming. Also, support adding a
3519         AVStreamDataParser to the AVContentKeySession.
3520
3521         Drive-by fixes:
3522
3523         - Sometimes, AVFoundation will give us a base64 encoded string with spaces url-disallowed
3524         characters, so use base64Decode() rather than base64URLDecode().
3525
3526         * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
3527         (WebCore::validFairPlayStreamingSchemes):
3528         (WebCore::extractSinfData):
3529         * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
3530         * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
3531         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::updateLicense):
3532         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest):
3533         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didFailToProvideRequest):
3534         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
3535         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmInstance const):
3536         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
3537         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmInstanceAttached):
3538         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmInstanceDetached):
3539         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::attemptToDecryptWithInstance):
3540         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
3541         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
3542         (WebCore::SourceBufferPrivateAVFObjC::destroyParser):
3543         (WebCore::SourceBufferPrivateAVFObjC::setCDMInstance):
3544
3545 2017-12-11  Eric Carlson  <eric.carlson@apple.com>
3546
3547         Web Inspector: Optionally log WebKit log parameters as JSON
3548         https://bugs.webkit.org/show_bug.cgi?id=180529
3549         <rdar://problem/35909462>
3550
3551         Reviewed by Joseph Pecoraro.
3552
3553         * dom/Document.cpp:
3554         (WebCore::Document::didLogMessage):Update for API change. Don't check for main thread, that
3555         is already done in addConsoleMessage.
3556         * dom/Document.h:
3557
3558         * html/HTMLMediaElement.cpp:
3559         (WebCore::HTMLMediaElement::updatePlayState): Cleanup logging.
3560
3561         * html/track/DataCue.cpp:
3562         (WebCore::DataCue::toJSONString const): Serialize to JSON string.
3563         (WebCore::DataCue::toString const): Deleted.
3564         * html/track/DataCue.h:
3565         (WTF::LogArgument<WebCore::DataCue>::toString):
3566
3567         * html/track/TextTrackCue.cpp:
3568         (WebCore::TextTrackCue::toJSON const): Ditto.
3569         (WebCore::TextTrackCue::toJSONString const):
3570         (WebCore::TextTrackCue::toString const): Deleted.
3571         * html/track/TextTrackCue.h:
3572         (WTF::LogArgument<WebCore::TextTrackCue>::toString):
3573
3574         * html/track/TextTrackCueGeneric.cpp:
3575         (WebCore::TextTrackCueGeneric::toJSONString const): Ditto.
3576         (WebCore::TextTrackCueGeneric::toString const): Deleted.
3577         * html/track/TextTrackCueGeneric.h:
3578         (WTF::LogArgument<WebCore::TextTrackCueGeneric>::toString):
3579
3580         * html/track/VTTCue.cpp:
3581         (WebCore::VTTCue::toJSONString const): Ditto.
3582         (WebCore::VTTCue::toString const): Deleted.
3583         * html/track/VTTCue.h:
3584         (WTF::LogArgument<WebCore::VTTCue>::toString):
3585
3586         * platform/graphics/InbandTextTrackPrivateClient.h:
3587         (WebCore::GenericCueData::toJSONString const): Ditto.
3588         (WTF::LogArgument<WebCore::GenericCueData>::toString):
3589         (WebCore::GenericCueData::toString const): Deleted.
3590
3591         * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
3592         (WebCore::InbandTextTrackPrivateAVF::processAttributedStrings): Cleanup logging.
3593         (WebCore::InbandTextTrackPrivateAVF::removeCompletedCues): Ditto.
3594         (WebCore::InbandTextTrackPrivateAVF::processNativeSamples): Log the entire cue.
3595         (WebCore::InbandTextTrackPrivateAVF::readNativeSampleBuffer): Cleanup logging.
3596
3597         * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
3598         (WebCore::MediaPlayerPrivateAVFoundation::maxMediaTimeSeekable const): Don't log, it isn't
3599         interesting and happens frequently.
3600         (WebCore::MediaPlayerPrivateAVFoundation::minMediaTimeSeekable const): Ditto.
3601
3602         * platform/graphics/iso/ISOVTTCue.cpp:
3603         (WebCore::ISOWebVTTCue::toJSONString const): Serialize to JSON string.
3604
3605         * platform/graphics/iso/ISOVTTCue.h:
3606         (WTF::LogArgument<WebCore::ISOWebVTTCue>::toString): Ditto.
3607
3608 2017-12-11  Youenn Fablet  <youenn@apple.com>
3609
3610         Use VCP H264 encoder for platforms supporting it
3611         https://bugs.webkit.org/show_bug.cgi?id=179076
3612         rdar://problem/35180773
3613
3614         Reviewed by Eric Carlson.
3615
3616         Covered by existing test coverage.
3617
3618         * platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.cpp:
3619         (WebCore::VideoToolboxVideoEncoderFactory::setActive):
3620         (WebCore::VideoToolboxVideoEncoderFactory::CreateSupportedVideoEncoder):
3621         (WebCore::VideoToolboxVideoEncoderFactory::DestroyVideoEncoder):
3622         * platform/mediastream/libwebrtc/VideoToolBoxEncoderFactory.h:
3623
3624 2017-12-11  Chris Dumez  <cdumez@apple.com>
3625
3626         Merge ServiceWorkerClientIdentifier into ServiceWorkerClientData
3627         https://bugs.webkit.org/show_bug.cgi?id=180669
3628
3629         Reviewed by Youenn Fablet.
3630
3631         Merge ServiceWorkerClientIdentifier into ServiceWorkerClientData, for consistency with
3632         ServiceWorkerIdentifier / ServiceWorkerData, and start simplifying the postMessage() code.
3633
3634         * WebCore.xcodeproj/project.pbxproj:
3635         * dom/Document.cpp:
3636         (WebCore::Document::setServiceWorkerConnection):
3637         * workers/service/SWClientConnection.h:
3638         * workers/service/ServiceWorker.cpp:
3639         (WebCore::ServiceWorker::postMessage):
3640         * workers/service/ServiceWorkerClient.cpp:
3641         (WebCore::ServiceWorkerClient::getOrCreate):
3642         (WebCore::ServiceWorkerClient::ServiceWorkerClient):
3643         * workers/service/ServiceWorkerClient.h:
3644         (WebCore::ServiceWorkerClient::identifier const):
3645         * workers/service/ServiceWorkerClientData.cpp:
3646         (WebCore::ServiceWorkerClientData::isolatedCopy const):
3647         (WebCore::ServiceWorkerClientData::from):
3648         * workers/service/ServiceWorkerClientData.h:
3649         (WebCore::ServiceWorkerClientData::encode const):
3650         (WebCore::ServiceWorkerClientData::decode):
3651         * workers/service/ServiceWorkerClientInformation.h: Removed.
3652         * workers/service/ServiceWorkerClients.cpp:
3653         (WebCore::didFinishGetRequest):
3654         (WebCore::ServiceWorkerClients::get):
3655         (WebCore::matchAllCompleted):
3656         * workers/service/ServiceWorkerTypes.h:
3657         * workers/service/ServiceWorkerWindowClient.cpp:
3658         (WebCore::ServiceWorkerWindowClient::ServiceWorkerWindowClient):
3659         * workers/service/ServiceWorkerWindowClient.h:
3660         * workers/service/context/SWContextManager.cpp:
3661         (WebCore::SWContextManager::postMessageToServiceWorker):
3662         * workers/service/context/SWContextManager.h:
3663         * workers/service/context/ServiceWorkerThread.cpp:
3664         (WebCore::ServiceWorkerThread::postMessageToServiceWorker):
3665         * workers/service/context/ServiceWorkerThread.h:
3666         * workers/service/server/SWServer.cpp:
3667         (WebCore::SWServer::findClientByIdentifier):
3668         (WebCore::SWServer::matchAll):
3669         (WebCore::SWServer::claim):
3670         (WebCore::SWServer::registerServiceWorkerClient):
3671         * workers/service/server/SWServer.h:
3672         * workers/service/server/SWServerToContextConnection.h:
3673         * workers/service/server/SWServerWorker.h:
3674
3675 2017-12-11  Daniel Bates  <dabates@apple.com>
3676
3677         Fix the macOS Sierra build following r225179
3678         (https://bugs.webkit.org/show_bug.cgi?id=180011)
3679
3680         Substitute TARGET_MAC_OS_X_VERSION_LESS_THAN_101300 for TARGET_MAC_OS_X_VERSION_LESS_THAN_1013000.
3681
3682         * Configurations/WebCore.xcconfig:
3683
3684 2017-12-11  Zalan Bujtas  <zalan@apple.com>
3685
3686         Make FrameView objects IsoHeap allocated
3687         https://bugs.webkit.org/show_bug.cgi?id=180668
3688         <rdar://problem/35976738>
3689
3690         Reviewed by Simon Fraser.
3691
3692         Related to <https://trac.webkit.org/changeset/225719/webkit>
3693
3694         * page/FrameView.cpp:
3695         * page/FrameView.h:
3696
3697 2017-12-11  Antoine Quint  <graouts@apple.com>
3698
3699         [Web Animations] Implement AnimationPlaybackEvent and AnimationPlaybackEventInit
3700         https://bugs.webkit.org/show_bug.cgi?id=180647
3701
3702         Reviewed by Dean Jackson.
3703
3704         Actually fix Windows build this time.
3705
3706         * animation/AnimationPlaybackEventInit.h:
3707
3708 2017-12-11  Antoine Quint  <graouts@apple.com>
3709
3710         [Web Animations] Implement AnimationPlaybackEvent and AnimationPlaybackEventInit
3711         https://bugs.webkit.org/show_bug.cgi?id=180647
3712         <rdar://problem/35966325>
3713
3714         Reviewed by Dean Jackson.
3715
3716         Unreviewed, fix Windows build.
3717
3718         * animation/AnimationPlaybackEventInit.h:
3719
3720 2017-12-11  Zalan Bujtas  <zalan@apple.com>
3721
3722         FloatingObjects/FloatingObject classes should hold weak references to renderers
3723         https://bugs.webkit.org/show_bug.cgi?id=180627
3724         <rdar://problem/35954069>
3725
3726         Reviewed by Antti Koivisto.
3727
3728         * rendering/FloatingObjects.cpp:
3729         (WebCore::FloatingObject::FloatingObject):
3730         (WebCore::ComputeFloatOffsetAdapter::ComputeFloatOffsetAdapter):
3731         (WebCore::ComputeFloatOffsetForFloatLayoutAdapter::ComputeFloatOffsetForFloatLayoutAdapter):
3732         (WebCore::ComputeFloatOffsetForLineLayoutAdapter::ComputeFloatOffsetForLineLayoutAdapter):
3733         (WebCore::FindNextFloatLogicalBottomAdapter::FindNextFloatLogicalBottomAdapter):
3734         (WebCore::FindNextFloatLogicalBottomAdapter::collectIfNeeded):
3735         (WebCore::FloatingObjects::findNextFloatLogicalBottomBelow):
3736         (WebCore::FloatingObjects::findNextFloatLogicalBottomBelowForBlock):
3737         (WebCore::FloatingObjects::FloatingObjects):
3738         (WebCore::FloatingObjects::clearLineBoxTreePointers):
3739         (WebCore::FloatingObjects::logicalLeftOffsetForPositioningFloat):
3740         (WebCore::FloatingObjects::logicalRightOffsetForPositioningFloat):
3741         (WebCore::FloatingObjects::logicalLeftOffset):
3742         (WebCore::FloatingObjects::logicalRightOffset):
3743         (WebCore::ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded):
3744         (WebCore::ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight>::updateOffsetIfNeeded):
3745         (WebCore::ComputeFloatOffsetForFloatLayoutAdapter<FloatTypeValue>::heightRemaining const):
3746         (WebCore::ComputeFloatOffsetAdapter<FloatTypeValue>::collectIfNeeded):
3747         (WebCore::ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded):
3748         (WebCore::ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight>::updateOffsetIfNeeded):
3749         * rendering/FloatingObjects.h:
3750         (WebCore::FloatingObject::renderer const):
3751         (WebCore::FloatingObjects::renderer const):
3752
3753 2017-12-11  David Quesada  <david_quesada@apple.com>
3754
3755         Turn on ENABLE_APPLICATION_MANIFEST
3756         https://bugs.webkit.org/show_bug.cgi?id=180562
3757         rdar://problem/35924737
3758
3759         Reviewed by Geoffrey Garen.
3760
3761         * Configurations/FeatureDefines.xcconfig:
3762         * loader/LinkLoader.cpp:
3763         (WebCore::createLinkPreloadResourceClient):
3764         * loader/cached/CachedResourceRequest.cpp:
3765             Add a missing #include that was implicitly added in the unified source when
3766             the feature is disabled.
3767
3768 2017-12-11  Dean Jackson  <dino@apple.com>
3769
3770         Add a runtime feature flag for ImageBitmap and OffscreenCanvas
3771         https://bugs.webkit.org/show_bug.cgi?id=180652
3772         <rdar://problem/35969611>
3773
3774         Reviewed by Antoine Quint.
3775
3776         Add a RuntimeEnabledFeature for these interfaces, and link the bindings
3777         to the feature.
3778
3779         Test: fast/canvas/offscreen-enabled.html
3780
3781         * bindings/js/WebCoreBuiltinNames.h:
3782         * html/ImageBitmap.idl:
3783         * html/OffscreenCanvas.idl:
3784         * page/RuntimeEnabledFeatures.h:
3785         (WebCore::RuntimeEnabledFeatures::setImageBitmapOffscreenCanvasEnabled):
3786         (WebCore::RuntimeEnabledFeatures::imageBitmapOffscreenCanvasEnabled const):
3787         * page/WindowOrWorkerGlobalScope.idl:
3788
3789 2017-12-11  Antoine Quint  <graouts@apple.com>
3790
3791         [Web Animations] Implement AnimationPlaybackEvent and AnimationPlaybackEventInit
3792         https://bugs.webkit.org/show_bug.cgi?id=180647
3793         <rdar://problem/35966325>
3794
3795         Reviewed by Dean Jackson.
3796
3797         We implement the AnimationPlaybackEvent interface and AnimationPlaybackEventInit dictionary
3798         as the first step towards dispatching animation "finish" and "cancel" events.
3799
3800         Animation playback events will be dispatched on Animation objects and expose the timeline time
3801         and animation current time at the time they were constructed. Dispatch itself, which will be
3802         the focus of the next patch, is not synchronous, so it's important to track those values
3803         at creation time.
3804
3805         No new tests yet, followup patches will enable event dispatch and existing Web Platform Tests
3806         will show progressions.
3807
3808         * CMakeLists.txt:
3809         * DerivedSources.make:
3810         * Sources.txt:
3811         * WebCore.xcodeproj/project.pbxproj:
3812         * animation/AnimationPlaybackEvent.cpp: Added.
3813         (WebCore::AnimationPlaybackEvent::AnimationPlaybackEvent):
3814         (WebCore::AnimationPlaybackEvent::bindingsCurrentTime const):
3815         (WebCore::AnimationPlaybackEvent::bindingsTimelineTime const):
3816         * animation/AnimationPlaybackEvent.h: Added.
3817         * animation/AnimationPlaybackEvent.idl: Added.
3818         * animation/AnimationPlaybackEventInit.h: Added.
3819         * animation/AnimationPlaybackEventInit.idl: Added.
3820         * bindings/js/WebCoreBuiltinNames.h:
3821         * dom/EventNames.in:
3822
3823 2017-12-11  Basuke Suzuki  <Basuke.Suzuki@sony.com>
3824
3825         [WinCairo] DumpRenderTree times out for all non-http tests
3826         https://bugs.webkit.org/show_bug.cgi?id=180571
3827
3828         Reviewed by Alex Christensen.
3829
3830         Bug fix on processing the curl event for file protocol.
3831
3832         No new tests. This fix is to run existing tests.
3833
3834         * platform/network/curl/CurlRequest.cpp:
3835         (WebCore::CurlRequest::completeDidReceiveResponse):
3836         * platform/network/curl/CurlRequest.h:
3837         (WebCore::CurlRequest::isCompleted const):
3838         (WebCore::CurlRequest::isCancelled const):
3839         (WebCore::CurlRequest::isCompletedOrCancelled const):
3840
3841 2017-12-11  Manuel Rego Casasnovas  <rego@igalia.com>
3842
3843         REGRESSION(r221931): Row stretch doesn't work for grid container with min-height
3844         https://bugs.webkit.org/show_bug.cgi?id=180287
3845
3846         Reviewed by Darin Adler.
3847
3848         In r221931 we moved the stretch phase as the last step of
3849         the track sizing algorithm.
3850         However this introduced a regression as we were no longer
3851         taking into account the grid container min-width|height constraints
3852         during this step.
3853
3854         The CSS WG modified the spec so it now defines what to do
3855         in these situations (https://drafts.csswg.org/css-grid/#algo-stretch):
3856           "If the free space is indefinite, but the grid container
3857            has a definite min-width/height, use that size to calculate
3858            the free space for this step instead."
3859
3860         This patch adds a new method
3861         GridTrackSizingAlgorithmStrategy::freeSpaceForStretchAutoTracksStep().
3862         When we're in the DefiniteSizeStrategy it just returns the current
3863         free space.
3864         For the IndefiniteSizeStrategy in the columns case we don't need
3865         any special computation (the same that happens in
3866         recomputeUsedFlexFractionIfNeeded()); for rows it uses the min size
3867         of the grid container (respecting min-width|height properties)
3868         to calculate the free space.
3869
3870         Test: imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/grid-stretch-respects-min-size-001.html
3871
3872         * rendering/GridTrackSizingAlgorithm.cpp:
3873         (WebCore::IndefiniteSizeStrategy::freeSpaceForStretchAutoTracksStep const):
3874         (WebCore::DefiniteSizeStrategy::freeSpaceForStretchAutoTracksStep const):
3875         (WebCore::GridTrackSizingAlgorithm::stretchAutoTracks):
3876         * rendering/GridTrackSizingAlgorithm.h:
3877
3878 2017-12-10  Minsheng Liu  <lambda@liu.ms>
3879
3880         Incorrect bounds inside <mover>/<munder> when a stretchy operator is present
3881         https://bugs.webkit.org/show_bug.cgi?id=179682
3882
3883         Reviewed by Frédéric Wang.
3884
3885         Currently a stretchy operator inside <mover>/<munder>/<munderover> is stretched
3886         during paint() rather than layout(), which leads to both end user confusion
3887         and many unexpected behaviors. This patch rewrites
3888         RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren()
3889         to both eliminate the issue and make operator stretching more standard
3890         conforming.
3891
3892         A test is added to check the stretch width of stretchy operators in various
3893         scenarios:
3894         mathml/opentype/munderover-stretch-width.html
3895
3896         A previous test is updated:
3897         mathml/opentype/opentype-stretchy-horizontal.html
3898
3899         * rendering/mathml/RenderMathMLOperator.cpp:
3900         (WebCore::RenderMathMLOperator::stretchTo):
3901         (WebCore::RenderMathMLOperator::resetStretchSize):
3902         (WebCore::RenderMathMLOperator::paint):
3903         * rendering/mathml/RenderMathMLOperator.h:
3904         (WebCore::RenderMathMLOperator::setStretchWidthLocked):
3905         (WebCore::RenderMathMLOperator::isStretchWidthLocked const):
3906         * rendering/mathml/RenderMathMLUnderOver.cpp:
3907         (WebCore::toHorizontalStretchyOperator):
3908         (WebCore::fixLayoutAfterStretch):
3909         (WebCore::RenderMathMLUnderOver::stretchHorizontalOperatorsAndLayoutChildren):
3910
3911 2017-12-10  Yusuke Suzuki  <utatane.tea@gmail.com>
3912
3913         Unreviewed, follow-up patch after r225470
3914         https://bugs.webkit.org/show_bug.cgi?id=180308
3915
3916         * Modules/webdatabase/SQLTransaction.cpp:
3917         (WebCore::SQLTransaction::checkAndHandleClosedDatabase):
3918         Use consistent operands.
3919
3920         * bindings/js/JSCallbackData.h:
3921         (WebCore::JSCallbackData::JSCallbackData):
3922         Use class field initializer.
3923
3924         * xml/parser/XMLDocumentParserLibxml2.cpp:
3925         (WebCore::openFunc):
3926         Use consistent operands.
3927
3928 2017-12-09  Ryosuke Niwa  <rniwa@webkit.org>
3929
3930         iOS: Crash in Document::updateLayout() via Document::processViewport
3931         https://bugs.webkit.org/show_bug.cgi?id=180619
3932         <rdar://problem/35717575>
3933
3934         Reviewed by Zalan Bujtas.
3935
3936         The crash is caused by modern media controls updating the layout in the middle of insertedIntoAncestor
3937         via HTMLMediaElement::setControllerJSProperty inside Document::pageScaleFactorChangedAndStable.
3938
3939         Fixed the crash by delaying the work to update the viewport configuration until didFinishInsertingNode
3940         since updating the viewport configuration results in a lot of related code running in response,
3941         and making sure all that code never tries to execute an author script is not attainable in the short term,
3942         and a maintenance nightmare in the long term.
3943
3944         Test: media/ios/viewport-change-with-video.html
3945
3946         * html/HTMLMetaElement.cpp:
3947         (WebCore::HTMLMetaElement::insertedIntoAncestor):
3948         (WebCore::HTMLMetaElement::didFinishInsertingNode): Added.
3949         * html/HTMLMetaElement.h:
3950
3951 2017-12-08  Zalan Bujtas  <zalan@apple.com>
3952
3953         Document::updateLayout() could destroy current frame.
3954         https://bugs.webkit.org/show_bug.cgi?id=180525
3955         <rdar://problem/35906836>
3956
3957         Reviewed by Simon Fraser.
3958
3959         Early return when Document::updateLayout() triggers Frame destruction.
3960
3961         Test: fast/frames/crash-when-iframe-is-remove-in-eventhandler.html
3962
3963         * dom/TreeScope.cpp:
3964         (WebCore::absolutePointIfNotClipped):
3965
3966 2017-12-08  Chris Dumez  <cdumez@apple.com>
3967
3968         ServiceWorkerGlobalScope is a global object and should be marked as [ImplicitThis] in the IDL
3969         https://bugs.webkit.org/show_bug.cgi?id=180615
3970
3971         Reviewed by Brady Eidson.
3972
3973         ServiceWorkerGlobalScope is a global object and should be marked as [ImplicitThis] in the IDL, similarly to what we do for Window.
3974         This allows a getter to be fallback to the global object as ThisValue when the cast of the ThisValue to the expected type fails.
3975
3976         No new tests, rebaselined existing test.
3977
3978         * workers/DedicatedWorkerGlobalScope.idl:
3979         * workers/WorkerGlobalScope.idl:
3980         * workers/service/ServiceWorkerGlobalScope.idl:
3981
3982 2017-12-08  Brady Eidson  <beidson@apple.com>
3983
3984         Delay some service worker operations until after the database import completes.
3985         https://bugs.webkit.org/show_bug.cgi?id=180573
3986
3987         Reviewed by Chris Dumez.
3988
3989         No new tests (Not testable yet).
3990
3991         Right after the storage process launches it starts importing registration records.
3992         During this time, a lot of the decisions we make regarding registrations, fetch, etc.
3993         are invalid, as they rely on those in-memory records being in place.
3994         
3995         This patch delays certain things until after the initial origin table import is complete.
3996