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