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