Opaque being-loaded responses should clone their body
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2018-01-24  Youenn Fablet  <youenn@apple.com>
2
3         Opaque being-loaded responses should clone their body
4         https://bugs.webkit.org/show_bug.cgi?id=182056
5
6         Reviewed by Brady Eidson.
7
8         Test: http/wpt/service-workers/clone-opaque-being-loaded-response.https.html
9
10         When cloning a being-loaded response, make sure we create a ReadableStream.
11         Before the patch, the readableStream was not created in that case for opaque responses.
12
13         * Modules/fetch/FetchBodyOwner.cpp:
14         (WebCore::FetchBodyOwner::readableStream):
15         (WebCore::FetchBodyOwner::createReadableStream):
16         * Modules/fetch/FetchBodyOwner.h:
17         * Modules/fetch/FetchResponse.cpp:
18         (WebCore::FetchResponse::clone):
19
20 2018-01-24  Chris Dumez  <cdumez@apple.com>
21
22         close() operation should not be exposed inside a ServiceWorkerGlobalScope
23         https://bugs.webkit.org/show_bug.cgi?id=182057
24
25         Reviewed by Youenn Fablet.
26
27         Move close() from WorkerGlobalScope to DedicatedWorkerGlobalScope as per:
28         - https://html.spec.whatwg.org/multipage/workers.html#dedicatedworkerglobalscope
29
30         This change to the specification was made to avoid exposing this deprecated
31         features to service workers (which are new).
32
33         No new tests, rebaselined existing test.
34
35         * workers/DedicatedWorkerGlobalScope.idl:
36         * workers/WorkerGlobalScope.idl:
37
38 2018-01-24  David Hyatt  <hyatt@apple.com>
39
40         Implement line clamp for mail.
41         https://bugs.webkit.org/show_bug.cgi?id=180818
42
43         Reviewed by Dean Jackson.
44
45         This patch implements a form of clamping that can clamp lines at both the top
46         and the bottom, and the interior can be replaced with a DOM element (identified
47         by id) that replaces the middle section.
48
49         The implementation derives from the multicolumn classes, but ultimately the
50         clamp should derive from the fragmentset classes instead (with most of the current
51         multicolumn code moving into base classes).
52
53         The virtualization of many of the multicolumn functions is something that would happen
54         once we move pages/printing over to this pagination model anyway.
55
56         * Sources.txt:
57         * WebCore.xcodeproj/project.pbxproj:
58         Add the new clamp classes.
59
60         * css/CSSComputedStyleDeclaration.cpp:
61         (WebCore::ComputedStyleExtractor::valueForPropertyinStyle):
62         * css/CSSProperties.json:
63         * css/StyleBuilderCustom.h:
64         (WebCore::StyleBuilderCustom::applyValueWebkitLinesClamp):
65         * css/parser/CSSParser.cpp:
66         (WebCore::CSSParserContext::CSSParserContext):
67         * css/parser/CSSParserMode.h:
68         (WebCore::CSSParserContextHash::hash):
69         * css/parser/CSSPropertyParser.cpp:
70         (WebCore::consumeLinesClamp):
71         (WebCore::CSSPropertyParser::parseSingleValue):
72         Implement the new CSS property, webkit-lines-clamp. This is only exposed if a preference
73         is set, so it is not exposed to the Web.
74
75         * page/Settings.yaml:
76         Add a new setting to control allowing access to the new CSS property.
77
78         * rendering/RenderBlockFlow.cpp:
79         (WebCore::RenderBlockFlow::willCreateColumns const):
80         Make sure columns are created when lines clamp is set.
81
82         (WebCore::getHeightForLineCount):
83         (WebCore::RenderBlockFlow::logicalHeightForLineCount):
84         (WebCore::RenderBlockFlow::logicalHeightExcludingLineCount):
85         (WebCore::RenderBlockFlow::layoutExcludedChildren):
86         (WebCore::RenderBlockFlow::heightForLineCount): Deleted.
87         * rendering/RenderBlockFlow.h:
88         Re-use the same clamping logic as the old line clamp code, but modernize it to work
89         with writing modes and to be able to go backwards from the end of the block.
90
91         * rendering/RenderDeprecatedFlexibleBox.cpp:
92         (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):
93         The line count method got renamed to have the word "logical" in it, since it now
94         works with vertical writing.
95
96         * rendering/RenderFragmentContainer.cpp:
97         (WebCore::RenderFragmentContainer::pageLogicalHeightForOffset const):
98         * rendering/RenderFragmentContainer.h:
99         Since line clamp sets have variable page heights, this new method takes the offset
100         as an argument so that it can return the appropriate page for the given offset.
101         This method will eventually be used by printing/page sets as well, since pages
102         can have variable heights.
103
104         * rendering/RenderFragmentedFlow.cpp:
105         (WebCore::RenderFragmentedFlow::validateFragments):
106         (WebCore::RenderFragmentedFlow::pageLogicalHeightForOffset const):
107         (WebCore::RenderFragmentedFlow::pageRemainingLogicalHeightForOffset const):
108         * rendering/RenderFragmentedFlow.h:
109         Support for variable page heights in a fragment set.
110
111         * rendering/RenderLinesClampFlow.cpp: Added.
112         (WebCore::RenderLinesClampFlow::RenderLinesClampFlow):
113         (WebCore::RenderLinesClampFlow::renderName const):
114         (WebCore::RenderLinesClampFlow::layout):
115         (WebCore::RenderLinesClampFlow::createMultiColumnSet):
116         (WebCore::RenderLinesClampFlow::isChildAllowedInFragmentedFlow const):
117         (WebCore::RenderLinesClampFlow::layoutFlowExcludedObjects):
118         * rendering/RenderLinesClampFlow.h: Added.
119         * rendering/RenderLinesClampSet.cpp: Added.
120         (WebCore::RenderLinesClampSet::RenderLinesClampSet):
121         (WebCore::RenderLinesClampSet::recalculateColumnHeight):
122         (WebCore::RenderLinesClampSet::computeLogicalHeight const):
123         (WebCore::RenderLinesClampSet::columnCount const):
124         (WebCore::RenderLinesClampSet::columnRectAt const):
125         (WebCore::RenderLinesClampSet::columnIndexAtOffset const):
126         (WebCore::RenderLinesClampSet::pageLogicalTopForOffset const):
127         (WebCore::RenderLinesClampSet::pageLogicalHeightForOffset const):
128         (WebCore::RenderLinesClampSet::fragmentedFlowPortionRectAt const):
129         (WebCore::RenderLinesClampSet::fragmentedFlowPortionOverflowRect):
130         (WebCore::RenderLinesClampSet::customBlockProgressionAdjustmentForColumn const):
131         (WebCore::RenderLinesClampSet::renderName const):
132         * rendering/RenderLinesClampSet.h: Added.
133         The new classes. They subclass all the methods necessary to do multi-pass layout,
134         and to determine the page heights of each section.
135
136         * rendering/RenderMultiColumnFlow.cpp:
137         (WebCore::RenderMultiColumnFlow::isColumnSpanningDescendant const):
138         (WebCore::isValidColumnSpanner):
139         (WebCore::RenderMultiColumnFlow::processPossibleSpannerDescendant):
140         (WebCore::RenderMultiColumnFlow::createMultiColumnSet):
141         * rendering/RenderMultiColumnFlow.h:
142         * rendering/RenderMultiColumnSet.cpp:
143         (WebCore::RenderMultiColumnSet::collectLayerFragments):
144         (WebCore::RenderMultiColumnSet::columnTranslationForOffset const):
145         * rendering/RenderMultiColumnSet.h:
146         (WebCore::RenderMultiColumnSet::skipLayerFragmentCollectionForColumn const):
147         (WebCore::RenderMultiColumnSet::customBlockProgressionAdjustmentForColumn const):
148         Virtualized methods so that lines clamp can subclass and change behavior.
149
150         * rendering/RenderObject.h:
151         (WebCore::RenderObject::isRenderLinesClampFlow const):
152         (WebCore::RenderObject::isRenderLinesClampSet const):
153         Add new functions for type checking.
154
155         * rendering/RenderRubyText.cpp:
156         Include adjustment.
157
158         * rendering/style/LineClampValue.h:
159         (WebCore::LinesClampValue::LinesClampValue):
160         (WebCore::LinesClampValue::isNone const):
161         (WebCore::LinesClampValue::operator== const):
162         (WebCore::LinesClampValue::operator!= const):
163         (WebCore::LinesClampValue::start const):
164         (WebCore::LinesClampValue::end const):
165         (WebCore::LinesClampValue::center const):
166         * rendering/style/RenderStyle.h:
167         (WebCore::RenderStyle::linesClamp const):
168         (WebCore::RenderStyle::hasLinesClamp const):
169         (WebCore::RenderStyle::setLinesClamp):
170         (WebCore::RenderStyle::initialLinesClamp):
171         (WebCore::RenderStyle::hasInlineColumnAxis const):
172         * rendering/style/StyleRareNonInheritedData.cpp:
173         (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
174         (WebCore::StyleRareNonInheritedData::operator== const):
175         * rendering/style/StyleRareNonInheritedData.h:
176         The front end style implementation of the new property.
177
178         * rendering/updating/RenderTreeBuilderMultiColumn.cpp:
179         (WebCore::RenderTreeBuilder::MultiColumn::createFragmentedFlow):
180         Make sure to build the correct renderer when lines clamp is set.
181
182 2018-01-24  Basuke Suzuki  <Basuke.Suzuki@sony.com>
183
184         [Curl] Allocate CurlSSLVerifier only when it is required.
185         https://bugs.webkit.org/show_bug.cgi?id=182061
186
187         CurlSSLVerifier was a member function of CurlRequest. This patch do
188         lazy initialization of it only when actually it is required.
189         Also configuration method is not required by moving those stuff to
190         constructor of SSLVerifier which makes much safer because there's
191         no change to change its behavior from outside.
192
193         Reviewed by Alex Christensen.
194
195         * platform/network/curl/CurlRequest.cpp:
196         (WebCore::CurlRequest::willSetupSslCtx):
197         (WebCore::CurlRequest::didCompleteTransfer):
198         (WebCore::CurlRequest::finalizeTransfer):
199         * platform/network/curl/CurlRequest.h:
200         * platform/network/curl/CurlSSLVerifier.cpp:
201         (WebCore::CurlSSLVerifier::CurlSSLVerifier):
202         (WebCore::CurlSSLVerifier::setSslCtx): Deleted.
203         * platform/network/curl/CurlSSLVerifier.h:
204         (WebCore::CurlSSLVerifier::setCurlHandle): Deleted.
205         (WebCore::CurlSSLVerifier::setHostName): Deleted.
206
207 2018-01-24  Antti Koivisto  <antti@apple.com>
208
209         Assertion failure in RenderMultiColumnSet::requiresBalancing() on fast/multicol/spanner-crash-when-adding-summary.html
210         https://bugs.webkit.org/show_bug.cgi?id=179308
211         <rdar://problem/34592771>
212
213         Reviewed by Zalan Bujtas.
214
215         The issue here is that we fail to tear down render tree for a summary element because adding another summary element
216         takes it out of the composed tree. This leaves behind renderers that break some multicolumn assumptions.
217
218         * rendering/updating/RenderTreeUpdater.cpp:
219         (WebCore::RenderTreeUpdater::tearDownRenderers):
220         (WebCore::RenderTreeUpdater::tearDownLeftoverShadowHostChildren):
221
222         When tearing down renderers go through the real children of the shadow hosts at the end and see if we left any renderers behind.
223         If so, tear them down too.
224
225         * rendering/updating/RenderTreeUpdater.h:
226
227 2018-01-24  Daniel Bates  <dabates@apple.com>
228
229         [CSP] Check policy for targeted windows when navigating to a JavaScript URL
230         https://bugs.webkit.org/show_bug.cgi?id=182018
231         <rdar://problem/36795781>
232
233         Reviewed by Brent Fulgham.
234
235         Move the CSP check to be earlier in the function.
236
237         Test: http/tests/security/contentSecurityPolicy/window-open-javascript-url-with-target-blocked.html
238
239         * loader/FrameLoader.cpp:
240         (WebCore::createWindow):
241
242 2018-01-24  Chris Dumez  <cdumez@apple.com>
243
244         Add a IPC::SendSyncOption indicating we should not process incoming IPC while waiting for the sync reply
245         https://bugs.webkit.org/show_bug.cgi?id=182021
246         <rdar://problem/21629943>
247
248         Reviewed by Ryosuke Niwa.
249
250         Add layout testing infrastructure for the new flag.
251
252         Test: fast/misc/testIncomingSyncIPCMessageWhileWaitingForSyncReply.html
253
254         * page/ChromeClient.h:
255         * testing/Internals.cpp:
256         (WebCore::Internals::testIncomingSyncIPCMessageWhileWaitingForSyncReply):
257         * testing/Internals.h:
258         * testing/Internals.idl:
259
260 2018-01-24  Alex Christensen  <achristensen@webkit.org>
261
262         Remove pre-Sierra-OS-specific code in WebCore
263         https://bugs.webkit.org/show_bug.cgi?id=182026
264
265         Reviewed by Tim Horton.
266
267         * page/cocoa/UserAgent.mm:
268         (WebCore::systemMarketingVersionForUserAgentString):
269         * page/scrolling/mac/ScrollingMomentumCalculatorMac.mm:
270         (WebCore::ScrollingMomentumCalculatorMac::retargetedScrollOffsetDidChange):
271         * platform/cocoa/PasteboardCocoa.mm:
272         (WebCore::bitmapPNGFileType):
273         * platform/graphics/FontPlatformData.cpp:
274         * platform/graphics/FontPlatformData.h:
275         * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm:
276         (WebCore::VideoFullscreenLayerManager::setVideoFullscreenLayer):
277         * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
278         (layerContentsFormat):
279         (PlatformCALayerCocoa::updateContentsFormat):
280         (PlatformCALayerCocoa::backingStoreBytesPerPixel const):
281         * platform/graphics/cg/GraphicsContextCG.cpp:
282         (WebCore::linearRGBColorSpaceRef):
283         (WebCore::extendedSRGBColorSpaceRef):
284         * platform/graphics/cg/PDFDocumentImage.cpp:
285         (WebCore::PDFDocumentImage::drawPDFPage):
286         * platform/graphics/cocoa/FontCacheCoreText.cpp:
287         (WebCore::getCSSAttribute):
288         (WebCore::capabilitiesForFontDescriptor):
289         (WebCore::findClosestFont):
290         (WebCore::platformFontLookupWithFamily):
291         (WebCore::lookupFallbackFont):
292         (WebCore::fontWeightFromCoreText): Deleted.
293         * platform/graphics/cocoa/FontCocoa.mm:
294         (WebCore::Font::variantCapsSupportsCharacterForSynthesis const):
295         (WebCore::Font::platformWidthForGlyph const):
296         (WebCore::advanceForColorBitmapFont): Deleted.
297         (WebCore::canUseFastGlyphAdvanceGetter): Deleted.
298         * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
299         (WebCore::FontPlatformData::FontPlatformData):
300         (WebCore::FontPlatformData::hash const):
301         (WebCore::FontPlatformData::platformIsEqual const):
302         (WebCore::FontPlatformData::ctFont const):
303         * platform/graphics/cocoa/GraphicsContextCocoa.mm:
304         (WebCore::linearRGBColorSpaceRef): Deleted.
305         * platform/graphics/cocoa/WebCoreDecompressionSession.mm:
306         (WebCore::WebCoreDecompressionSession::setTimebase):
307         * platform/graphics/mac/FontCustomPlatformData.cpp:
308         (WebCore::FontCustomPlatformData::supportsFormat):
309         * platform/mac/PlatformScreenMac.mm:
310         (WebCore::screenSupportsExtendedColor):
311         * platform/mac/ScrollbarThemeMac.mm:
312         (WebCore::ScrollbarThemeMac::didCreateScrollerImp):
313         (WebCore::ScrollbarThemeMac::isLayoutDirectionRTL):
314         * platform/mac/ThemeMac.mm:
315         (WebCore::ThemeMac::userPrefersReducedMotion const):
316         * platform/network/cocoa/ResourceRequestCocoa.mm:
317         (WebCore::ResourceRequest::doUpdatePlatformRequest):
318         * platform/text/mac/TextBoundaries.mm:
319         (WebCore::findNextWordFromIndex):
320         * rendering/RenderLayerModelObject.cpp:
321         (WebCore::RenderLayerModelObject::shouldPlaceBlockDirectionScrollbarOnLeft const):
322         * testing/Internals.mm:
323         (WebCore::Internals::userPrefersReducedMotion const):
324
325 2018-01-24  Alex Christensen  <achristensen@webkit.org>
326
327         Remove WebProcess authentication code
328         https://bugs.webkit.org/show_bug.cgi?id=182020
329
330         Reviewed by Brady Eidson.
331
332         We were keeping it around for pre-NetworkSession media loading, which is gone now.
333
334         * html/HTMLMediaElement.cpp:
335         (WebCore::HTMLMediaElement::mediaPlayerShouldWaitForResponseToAuthenticationChallenge): Deleted.
336         * html/HTMLMediaElement.h:
337         * loader/ResourceLoader.cpp:
338         (WebCore::ResourceLoader::didReceiveAuthenticationChallenge):
339         * loader/ResourceLoader.h:
340         * platform/graphics/MediaPlayer.cpp:
341         (WebCore::MediaPlayer::shouldWaitForResponseToAuthenticationChallenge): Deleted.
342         * platform/graphics/MediaPlayer.h:
343         (WebCore::MediaPlayerClient::mediaPlayerShouldWaitForResponseToAuthenticationChallenge): Deleted.
344         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
345         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
346         (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]):
347         (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForResponseToAuthenticationChallenge): Deleted.
348
349 2018-01-24  Joanmarie Diggs  <jdiggs@igalia.com>
350
351         AX: SVG AAM mapping trumps ARIA role attribute in the case of SVG root
352         https://bugs.webkit.org/show_bug.cgi?id=181994
353
354         Reviewed by Chris Fleizach.
355
356         Only return AccessibilityRole::Group if we have no author-provided
357         ARIA role attribute value.
358
359         Test: accessibility/svg-element-with-aria-role.html
360
361         * accessibility/AccessibilitySVGRoot.cpp:
362         (WebCore::AccessibilitySVGRoot::roleValue const):
363         * accessibility/AccessibilitySVGRoot.h:
364
365 2018-01-24  Alex Christensen  <achristensen@webkit.org>
366
367         Remove unused QTKit preference
368         https://bugs.webkit.org/show_bug.cgi?id=181968
369
370         Reviewed by Alexey Proskuryakov.
371
372         They weren't used and didn't do anything.
373
374         * page/DeprecatedGlobalSettings.cpp:
375         (WebCore::DeprecatedGlobalSettings::setQTKitEnabled): Deleted.
376         * page/DeprecatedGlobalSettings.h:
377         (WebCore::DeprecatedGlobalSettings::isQTKitEnabled): Deleted.
378
379 2018-01-24  Antoine Quint  <graouts@apple.com>
380
381         [Web Animations] Compute the progress and currentIteration properties on getComputedTiming()
382         https://bugs.webkit.org/show_bug.cgi?id=182039
383         <rdar://problem/36813568>
384
385         Reviewed by Dean Jackson.
386
387         Compute the "progress" and "currentIteration" properties on the dictionary returned by getComputedTiming().
388         To support this we implement several procedures from the specification implemented separately with links
389         and steps copied from the specification. There is one last procedure we don't implement, which is to obtain
390         the transformed time following the application of the provided easing, which will be the next patch.
391
392         * animation/AnimationEffect.cpp:
393         (WebCore::AnimationEffect::phase const):
394         (WebCore::AnimationEffect::activeTime const):
395         (WebCore::AnimationEffect::overallProgress const):
396         (WebCore::AnimationEffect::simpleIterationProgress const):
397         (WebCore::AnimationEffect::currentIteration const):
398         (WebCore::AnimationEffect::currentDirection const):
399         (WebCore::AnimationEffect::directedProgress const):
400         (WebCore::AnimationEffect::iterationProgress const):
401         (WebCore::AnimationEffect::getComputedTiming):
402         * animation/AnimationEffect.h:
403
404 2018-01-24  Daniel Bates  <dabates@apple.com>
405
406         REGRESSION (r226138): Selecting a line that ends with zero-width joiner (ZWJ) may cause text transformation
407         https://bugs.webkit.org/show_bug.cgi?id=181993
408         <rdar://problem/36421080>
409
410         Reviewed by David Hyatt.
411
412         Re-implement paint optimization that was inadvertently removed in r226138. This optimization
413         works around an issue where selecting the last printable character in a line that is followed
414         followed by a zero-width joiner transforms the selected character.
415
416         We need to fix <https://bugs.webkit.org/show_bug.cgi?id=181964> to improve the interaction
417         of selection and zero-width joiner characters. For now, re-implement a paint optimization
418         to perform a single paint operation when the style of the non-selected text is identical
419         to the style of the selected text.
420
421         Test: fast/text/mac/select-character-before-zero-width-joiner.html
422
423         * rendering/InlineTextBox.cpp:
424         (WebCore::InlineTextBox::MarkerSubrangeStyle::areBackgroundMarkerSubrangeStylesEqual):
425         (WebCore::InlineTextBox::MarkerSubrangeStyle::areForegroundMarkerSubrangeStylesEqual):
426         (WebCore::InlineTextBox::MarkerSubrangeStyle::areDecorationMarkerSubrangeStylesEqual):
427         Add helper functions to determine when marker styles are identical. We make use of these
428         equality functions to coalesce adjacent subranges that have the same visual style and
429         hence reduce the number of drawing commands to paint all the subranges in a line.
430  
431         (WebCore::InlineTextBox::paint): Coalesce subranges before painting.
432
433         (WebCore::InlineTextBox::subdivideAndResolveStyle): Split out the logic to coalesce
434         subranges with the same style into its own function InlineTextBox::coalesceAdjacentSubranges()
435         and kept this function focused on subdivision and style resolution. Manually compute
436         the frontmost subranges so that we can resolve style for each subrange with respect to
437         the correct base style. Formerly we always resolved style with respect the specified
438         base style. Now we resolve style with respect the previous frontmost subrange to ensure
439         styles cascade as expected. This change causes no visual difference now. Once we implement
440         <https://bugs.webkit.org/show_bug.cgi?id=175784> we will be able to test this change
441         with respect to selection of ::spelling-error/::grammar-error pseudo elements.
442
443         (WebCore::InlineTextBox::coalesceAdjacentSubranges): Extracted logic from InlineTextBox::subdivideAndResolveStyle().
444
445         (WebCore::InlineTextBox::MarkerSubrangeStyle::operator== const): Deleted.
446         (WebCore::InlineTextBox::MarkerSubrangeStyle::operator!= const): Deleted.
447         Comparing MarkerSubrangeStyle objects should be performed using the appropriate
448         are*MarkerSubrangeStylesEqual() non-member function.
449
450         * rendering/InlineTextBox.h:
451         * rendering/MarkerSubrange.cpp:
452         (WebCore::subdivide): Remove overlap strategy FrontmostWithLongestEffectiveRange
453         as this strategy is now implemented by InlineTextBox::subdivideAndResolveStyle() and
454         InlineTextBox::coalesceAdjacentSubranges() that compute the set of frontmost subranges and
455         coalesces adjacent subranges with the same style into the longest effective subrange,
456         respectively. Unlike WebCore::subdivide(), InlineTextBox knows what the base style should
457         be for the subranges and can more aggressively coalesce adjacent subranges of different
458         types that have the same visual style.
459         * rendering/MarkerSubrange.h:
460
461 2018-01-24  Youenn Fablet  <youenn@apple.com>
462
463         Fetch response should copy its url from the request if null
464         https://bugs.webkit.org/show_bug.cgi?id=182048
465
466         Reviewed by Chris Dumez.
467
468         No change of behavior.
469
470         * loader/DocumentLoader.cpp:
471         (WebCore::DocumentLoader::responseReceived): Add assertion to check that the response URL is not null.
472
473 2018-01-24  Youenn Fablet  <youenn@apple.com>
474
475         Account for memory cache in DocumentThreadableLoader::didReceiveResponse assertion
476         https://bugs.webkit.org/show_bug.cgi?id=182049
477
478         Reviewed by Chris Dumez.
479
480         No change of behavior.
481         A response served from Service Worker may be cached in Memory Cache and reused later on.
482         Update DTL assertion to handle that case.
483
484         * loader/DocumentThreadableLoader.cpp:
485         (WebCore::DocumentThreadableLoader::didReceiveResponse):
486
487 2018-01-24  Eric Carlson  <eric.carlson@apple.com>
488
489         REGRESSION(r227457): Release assert in updateLayout while destructing a media element
490         https://bugs.webkit.org/show_bug.cgi?id=182038
491         <rdar://problem/36812083>
492
493         Reviewed by Jer Noble.
494
495         * html/MediaElementSession.cpp:
496         (WebCore::isMainContentForPurposesOfAutoplay): Early return if element.isSuspended().
497         * platform/audio/mac/MediaSessionManagerMac.mm:
498         (WebCore::MediaSessionManagerMac::clientCharacteristicsChanged): Call scheduleUpdateNowPlayingInfo
499         instead of updateNowPlayingInfo.
500
501 2018-01-24  Chris Fleizach  <cfleizach@apple.com>
502
503         AX: Provide a way for VoiceOver to uniquely identify a web session
504         https://bugs.webkit.org/show_bug.cgi?id=181894
505
506         Reviewed by Joanmarie Diggs.
507
508         Add a way for VoiceOver to uniquely track a web page session.
509
510         Test: accessibility/mac/session-id.html
511
512         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
513         (-[WebAccessibilityObjectWrapper accessibilityAttributeNames]):
514         (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
515
516 2018-01-24  Antti Koivisto  <antti@apple.com>
517
518         RenderBlockRareData::m_enclosingFragmentedFlow should be WeakPtr
519         https://bugs.webkit.org/show_bug.cgi?id=182045
520         <rdar://problem/36334787>
521
522         Reviewed by Zalan Bujtas.
523
524         For safety.
525
526         * rendering/RenderBlock.cpp:
527         (WebCore::RenderBlock::cachedEnclosingFragmentedFlow const):
528         (WebCore::RenderBlock::updateCachedEnclosingFragmentedFlow const):
529         (WebCore::RenderBlock::locateEnclosingFragmentedFlow const):
530
531 2018-01-23  Dean Jackson  <dino@apple.com>
532
533         REGRESSION (r222961?): sRGB images shown in WebGL are over-saturated on a wide gamut monitor
534         https://bugs.webkit.org/show_bug.cgi?id=182033
535         <rdar://problem/36377780>
536
537         Reviewed by Antoine Quint.
538
539         My fix for YouTube360 changed the way we composite WebGL on macOS. Unfortunately it dropped
540         a flag telling the compositor the colorspace of the content should be sRGB. Reinstate this
541         by explicitly setting the colorspace on the IOSurface we use for WebGL back buffers.
542
543         This *should* be covered by the test in:
544         fast/canvas/webgl/match-page-color-space.html
545         ... however, it shows a problem with our testing infrastructure. As long as it is not
546         testing on a Wide Gamut display, and explicitly setting the color profile, an automated
547         test won't pick up this regression. I could add an Internals helper to query the colorspace
548         of the WebGL content, but that doesn't actually verify the composited result, which is
549         all that matters.
550
551         * platform/graphics/cocoa/WebGLLayer.mm:
552         (-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]):
553
554 2018-01-24  Ms2ger  <Ms2ger@igalia.com>
555
556         [GTK] Fix some test failures in ATK selection handling.
557         https://bugs.webkit.org/show_bug.cgi?id=168369
558         <rdar://problem/30534881>
559
560         Reviewed by Joanmarie Diggs.
561
562         In r208479, selectionBelongsToObject was changed to return false if the
563         intersectsNode call returns an exception.
564
565         In particular, this caused accessibility/gtk/text-at-offset-textarea.html
566         to fail. In this test, the selection is situated in the shadow DOM of the
567         textarea, while the node that is checked for intersection is the textarea
568         itself. In line with the standard, intersectsNode returns an exception in
569         this case.
570
571         This caused webkitAccessibleText{Word, Line, Sentence}ForBoundary to stop
572         returning the expected text in the tested case. Removing this check fixes
573         the test, along with some others.
574
575         Tests: accessibility/gtk/text-at-offset-textarea.html
576                accessibility/gtk/text-at-offset-textinput.html
577                accessibility/selected-text-range-aria-elements.html
578                accessibility/textarea-selected-text-range.html
579
580         * accessibility/atk/WebKitAccessibleInterfaceText.cpp:
581         (getSelectionOffsetsForObject): Remove the selectionBelongsToObject() call.
582
583 2018-01-18  Sergio Villar Senin  <svillar@igalia.com>
584
585         [WebVR] Add OpenVR to the tree and to the build
586         https://bugs.webkit.org/show_bug.cgi?id=177298
587
588         Reviewed by Žan Doberšek.
589
590         Added build dependencies with the OpenVR library.
591
592         * CMakeLists.txt:
593
594 2018-01-23  Wenson Hsieh  <wenson_hsieh@apple.com>
595
596         Harden against layout passes triggered when iterating through HTMLFormElement::associatedElements
597         https://bugs.webkit.org/show_bug.cgi?id=182037
598         <rdar://problem/36747812>
599
600         Reviewed by Ryosuke Niwa.
601
602         Observe that HTMLFormElement::associatedElements returns a const reference to a Vector of raw
603         FormAssociatedElement pointers. In various call sites that iterate through these associated elements using this
604         function, some require synchronous layout updates per iteration, which can lead to a bad time when combined with
605         the first observation.
606
607         To address this, we introduce HTMLFormElement::copyAssociatedElementsVector. This returns a new vector
608         containing strong Refs to each associated element. From each call site that may trigger synchronous layout and
609         execute arbitrary script while iterating over associated form elements, we instead use iterate over protected
610         FormAssociatedElements.
611
612         From each call site that currently doesn't (and shouldn't) require a layout update, we use the old version that
613         returns a list of raw FormAssociatedElement pointers, but add ScriptDisallowedScopes to ensure that we never
614         execute script there in the future.
615
616         Test: fast/forms/form-data-associated-element-iteration.html
617
618         * html/DOMFormData.cpp:
619         (WebCore::DOMFormData::DOMFormData):
620
621         Change to use copyAssociatedElementsVector().
622
623         * html/FormController.cpp:
624         (WebCore::recordFormStructure):
625         (WebCore::FormController::restoreControlStateIn):
626
627         Change to use copyAssociatedElementsVector().
628
629         * html/HTMLFieldSetElement.cpp:
630         (WebCore::HTMLFieldSetElement::copyAssociatedElementsVector const):
631         (WebCore:: const):
632         (WebCore::HTMLFieldSetElement::length const):
633
634         Refactor to use unsafeAssociatedElements().
635
636         * html/HTMLFieldSetElement.h:
637         * html/HTMLFormControlsCollection.cpp:
638         (WebCore:: const):
639         (WebCore::HTMLFormControlsCollection::copyFormControlElementsVector const):
640         (WebCore::HTMLFormControlsCollection::customElementAfter const):
641         (WebCore::HTMLFormControlsCollection::updateNamedElementCache const):
642
643         Refactor these to use unsafeAssociatedElements().
644
645         * html/HTMLFormControlsCollection.h:
646         * html/HTMLFormElement.cpp:
647         (WebCore::HTMLFormElement::unsafeAssociatedElements const):
648         (WebCore::HTMLFormElement::copyAssociatedElementsVector const):
649         * html/HTMLFormElement.h:
650         * loader/FormSubmission.cpp:
651         (WebCore::FormSubmission::create):
652
653         Refactor to use copyAssociatedElementsVector().
654
655 2018-01-23  Basuke Suzuki  <Basuke.Suzuki@sony.com>
656
657         [Curl] Fix wrong redirection with relative url when it happens from
658         different host than original host.
659         https://bugs.webkit.org/show_bug.cgi?id=181873
660
661         Reviewed by Alex Christensen.
662
663         * platform/network/curl/CurlDownload.cpp:
664         (WebCore::CurlDownload::willSendRequest):
665         * platform/network/curl/ResourceHandleCurlDelegate.cpp:
666         (WebCore::ResourceHandleCurlDelegate::willSendRequest):
667
668 2018-01-23  Eric Carlson  <eric.carlson@apple.com>
669
670         Resign NowPlaying status when no media element is eligible
671         https://bugs.webkit.org/show_bug.cgi?id=181914
672         <rdar://problem/35294116>
673
674         Reviewed by Jer Noble.
675
676         Updated API test.
677
678         * html/HTMLMediaElement.cpp:
679         (WebCore::HTMLMediaElement::removedFromAncestor): Call mediaSession->clientCharacteristicsChanged
680         so NowPlaying status will be updated.
681
682         * html/MediaElementSession.cpp:
683         (WebCore::MediaElementSession::playbackPermitted const): Return early when the media 
684         element has been suspended.
685         (WebCore::MediaElementSession::canShowControlsManager const): Return false when being queried
686         for NowPlaying status in an inactive document or when element has been suspended.
687         (WebCore::isMainContentForPurposesOfAutoplay): Return early if it isn't safe to update
688         style because HitTest can force a layout.
689         (WebCore::MediaElementSession::updateIsMainContent const): Ditto.
690
691         * platform/audio/PlatformMediaSessionManager.cpp:
692         (WebCore::PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary): Implement in for all
693         ports.
694         * platform/audio/PlatformMediaSessionManager.h:
695         (WebCore::PlatformMediaSessionManager::registeredAsNowPlayingApplication const):
696         * platform/audio/ios/MediaSessionManagerIOS.h:
697         * platform/audio/mac/MediaSessionManagerMac.h:
698         * platform/audio/mac/MediaSessionManagerMac.mm:
699         (WebCore::MediaSessionManagerMac::updateNowPlayingInfo): Call MRMediaRemoteSetCanBeNowPlayingApplication
700         whenever status changes.
701         (WebCore::PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary): Deleted, implemented
702         in the base class.
703
704 2018-01-23  Alex Christensen  <achristensen@webkit.org>
705
706         Use CompletionHandlers for ResourceHandleClient::didReceiveResponseAsync
707         https://bugs.webkit.org/show_bug.cgi?id=181961
708
709         Reviewed by Michael Catanzaro.
710
711         No change in behavior.
712
713         * loader/ResourceLoader.cpp:
714         (WebCore::ResourceLoader::didReceiveResponseAsync):
715         * loader/ResourceLoader.h:
716         * loader/appcache/ApplicationCacheGroup.cpp:
717         (WebCore::ApplicationCacheGroup::didReceiveResponseAsync):
718         * loader/appcache/ApplicationCacheGroup.h:
719         * platform/network/BlobResourceHandle.cpp:
720         (WebCore::BlobResourceHandle::notifyResponseOnSuccess):
721         (WebCore::BlobResourceHandle::notifyResponseOnError):
722         (WebCore::BlobResourceHandle::continueDidReceiveResponse): Deleted.
723         * platform/network/BlobResourceHandle.h:
724         * platform/network/PingHandle.h:
725         * platform/network/ResourceHandle.cpp:
726         (WebCore::ResourceHandle::didReceiveResponse):
727         * platform/network/ResourceHandle.h:
728         * platform/network/ResourceHandleClient.h:
729         * platform/network/SynchronousLoaderClient.cpp:
730         (WebCore::SynchronousLoaderClient::didReceiveResponseAsync):
731         * platform/network/SynchronousLoaderClient.h:
732         * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
733         (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveResponse):
734         (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::continueDidReceiveResponse): Deleted.
735         * platform/network/curl/ResourceHandleCurlDelegate.cpp:
736         (WebCore::ResourceHandleCurlDelegate::curlDidReceiveResponse):
737         (WebCore::ResourceHandleCurlDelegate::handleDataURL):
738         (WebCore::ResourceHandleCurlDelegate::continueDidReceiveResponse): Deleted.
739         * platform/network/mac/ResourceHandleMac.mm:
740         (WebCore::ResourceHandle::continueDidReceiveResponse): Deleted.
741         * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h:
742         * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
743         (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]):
744         (-[WebCoreResourceHandleAsOperationQueueDelegate continueDidReceiveResponse]): Deleted.
745         * platform/network/soup/ResourceHandleSoup.cpp:
746         (WebCore::nextMultipartResponsePartCallback):
747         (WebCore::sendRequestCallback):
748         (WebCore::ResourceHandle::continueDidReceiveResponse): Deleted.
749
750 2018-01-23  Chris Dumez  <cdumez@apple.com>
751
752         Unreviewed, rollout r227216 as it seems to be causing deadlocks
753         https://bugs.webkit.org/show_bug.cgi?id=182013
754
755         * page/ChromeClient.h:
756         * testing/Internals.cpp:
757         (WebCore::Internals::testIncomingSyncIPCMessageWhileWaitingForSyncReply): Deleted.
758         * testing/Internals.h:
759         * testing/Internals.idl:
760
761 2018-01-23  Ali Juma  <ajuma@chromium.org>
762
763         REGRESSION (r226622): ASSERTION FAILED: !m_frame in WebCore::DOMWindowProperty::willDestroyGlobalObjectInCachedFrame()
764         https://bugs.webkit.org/show_bug.cgi?id=181756
765
766         Reviewed by Simon Fraser.
767
768         Don't create a VisualViewport for a suspended DOMWindow. When a DOMWindow is suspended
769         for document suspension, all DOMWindowProperties are disconnected from their frame.
770         Creating a new VisualViewport while in this state means unexpectedly having a DOMWindowProperty
771         that's connected to a frame, and this leads to an assertion failure.
772
773         Test: http/tests/navigation/https-in-page-cache.html
774
775         * page/DOMWindow.cpp:
776         (WebCore::DOMWindow::visualViewport const):
777         Don't create a VisualViewport while suspended.
778         * page/FrameView.cpp:
779         (WebCore::FrameView::updateLayoutViewport):
780         Handle null DOMWindow::visualViewport.
781
782 2018-01-23  Basuke Suzuki  <Basuke.Suzuki@sony.com>
783
784         [Curl] CurlRequest must protect its client from disposal while it's on duty.
785         https://bugs.webkit.org/show_bug.cgi?id=181875
786
787         Reviewed by Alex Christensen.
788
789         No new tests. It's covered by existing tests.
790
791         * platform/network/curl/CurlDownload.h:
792         * platform/network/curl/CurlRequest.cpp:
793         (WebCore::CurlRequest::callClient):
794         (WebCore::CurlRequest::didReceiveData):
795         (WebCore::CurlRequest::didReceiveDataFromMultipart):
796         (WebCore::CurlRequest::didCompleteTransfer):
797         (WebCore::CurlRequest::invokeDidReceiveResponse):
798         * platform/network/curl/CurlRequest.h:
799         * platform/network/curl/CurlRequestClient.h:
800         * platform/network/curl/ResourceHandleCurlDelegate.h:
801
802 2018-01-23  Commit Queue  <commit-queue@webkit.org>
803
804         Unreviewed, rolling out r227437.
805         https://bugs.webkit.org/show_bug.cgi?id=182011
806
807         broke build (Requested by alexchristensen on #webkit).
808
809         Reverted changeset:
810
811         "Remove unused QTKit preference"
812         https://bugs.webkit.org/show_bug.cgi?id=181968
813         https://trac.webkit.org/changeset/227437
814
815 2018-01-23  Antoine Quint  <graouts@apple.com>
816
817         [Web Animations] Expose getKeyframes() and parsing of remaining keyframe properties
818         https://bugs.webkit.org/show_bug.cgi?id=181978
819
820         Not reviewed.
821
822         Fix failures for http/wpt/web-animations/interfaces/AnimationEffectTiming/easing.html introduced in the previous patch.
823         Those keyword values are not expected.
824
825         * platform/animation/TimingFunction.cpp:
826         (WebCore::TimingFunction::cssText const):
827
828 2018-01-23  Simon Fraser  <simon.fraser@apple.com>
829
830         feMorphology stops applying if either x or y radius is 0 but should not.
831         https://bugs.webkit.org/show_bug.cgi?id=181903
832
833         Reviewed by Dean Jackson.
834         
835         feMorphology should allow the radius on one axis to be zero but still apply the effect
836         (it's akin to a blur on just one axis). Also, any negative radius, or zero on both axes
837         should act like a pass-through, rather than outputting transparent blank (this is a spec
838         change from SVG 1.1 to SVG 2).
839
840         Tests: svg/filters/feMorphology-zero-radius-one-axis-expected.svg
841                svg/filters/feMorphology-zero-radius-one-axis.svg
842
843         * platform/graphics/filters/FEMorphology.cpp:
844         (WebCore::FEMorphology::platformApplyDegenerate):
845         * platform/graphics/filters/FilterEffect.cpp:
846         (WebCore::FilterEffect::createImageBufferResult):
847
848 2018-01-23  Alex Christensen  <achristensen@webkit.org>
849
850         Remove unused MediaPlayerSupportsTypeClient
851         https://bugs.webkit.org/show_bug.cgi?id=182003
852
853         Reviewed by Sam Weinig.
854
855         This was used for a QTKit-specific hack I removed in r227372.
856
857         * Modules/encryptedmedia/CDM.cpp:
858         (WebCore::CDM::getSupportedCapabilitiesForAudioVideoType):
859         * Modules/mediasource/MediaSource.cpp:
860         (WebCore::MediaSource::isTypeSupported):
861         * dom/DOMImplementation.cpp:
862         (WebCore::DOMImplementation::createDocument):
863         (WebCore::DOMImplementationSupportsTypeClient::DOMImplementationSupportsTypeClient): Deleted.
864         (): Deleted.
865         * html/HTMLMediaElement.cpp:
866         (WebCore::HTMLMediaElement::canPlayType const):
867         (WebCore::HTMLMediaElement::selectNextSourceChild):
868         (WebCore::HTMLMediaElement::mediaPlayerNeedsSiteSpecificHacks const): Deleted.
869         (WebCore::HTMLMediaElement::mediaPlayerDocumentHost const): Deleted.
870         * html/HTMLMediaElement.h:
871         * platform/graphics/MediaPlayer.cpp:
872         (WebCore::MediaPlayer::supportsType):
873         * platform/graphics/MediaPlayer.h:
874         (WebCore::MediaPlayerSupportsTypeClient::mediaPlayerNeedsSiteSpecificHacks const): Deleted.
875         (WebCore::MediaPlayerSupportsTypeClient::mediaPlayerDocumentHost const): Deleted.
876
877 2018-01-23  Alex Christensen  <achristensen@webkit.org>
878
879         Remove unused QTKit preference
880         https://bugs.webkit.org/show_bug.cgi?id=181968
881
882         Reviewed by Alexey Proskuryakov.
883
884         They weren't used and didn't do anything.
885
886         * page/DeprecatedGlobalSettings.cpp:
887         (WebCore::DeprecatedGlobalSettings::setQTKitEnabled): Deleted.
888         * page/DeprecatedGlobalSettings.h:
889         (WebCore::DeprecatedGlobalSettings::isQTKitEnabled): Deleted.
890
891 2018-01-23  Javier Fernandez  <jfernandez@igalia.com>
892
893         [css-align] 'left' and 'right' should parse as invalid in block/cross-axis alignment
894         https://bugs.webkit.org/show_bug.cgi?id=181792
895
896         Reviewed by Antti Koivisto.
897
898         The CSS WG resolved to remove the 'left' and 'right' values from the
899         block/cross axis alignment properties.
900
901         https://github.com/w3c/csswg-drafts/issues/1403
902
903         This patch changes the CSS parsing logic of all the CSS Box Alignment
904         properties, both block-axis (align-{self, items, content} and
905         inline-axis (justify-{self, items, content}).
906
907         Additionally, the alignment shorthands (place-{self, items, content})
908         have been also changed to respect the new syntax.
909
910         Despite the number of layout tests changed, I don't think this
911         change will break any content in current sites. The CSS values
912         'left' and 'right' were introduced by the new CSS Box Alignment
913         spec and only implemented by the CSS Grid Layout feature, shipped
914         last year. Additionally, the removed values have no effect on the
915         layout result when they are applied to the block/cross-axis CSS
916         Alignment properties.
917
918         Tests: imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-align-content-001.html
919                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-align-content-002.html
920                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-align-content-003.html
921                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-align-content-004.html
922                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-align-content-005.html
923                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-justify-content-001.html
924                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-justify-content-002.html
925                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-justify-content-003.html
926                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-justify-content-004.html
927                imported/w3c/web-platform-tests/css/css-align/content-distribution/parse-justify-content-005.html
928                imported/w3c/web-platform-tests/css/css-align/content-distribution/place-content-shorthand-001.html
929                imported/w3c/web-platform-tests/css/css-align/content-distribution/place-content-shorthand-002.html
930                imported/w3c/web-platform-tests/css/css-align/content-distribution/place-content-shorthand-003.html
931                imported/w3c/web-platform-tests/css/css-align/content-distribution/place-content-shorthand-004.html
932                imported/w3c/web-platform-tests/css/css-align/content-distribution/place-content-shorthand-005.html
933                imported/w3c/web-platform-tests/css/css-align/content-distribution/place-content-shorthand-006.html
934                imported/w3c/web-platform-tests/css/css-align/default-alignment/justify-items-legacy-001.html
935                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-align-items-001.html
936                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-align-items-002.html
937                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-align-items-003.html
938                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-align-items-004.html
939                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-align-items-005.html
940                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-justify-items-001.html
941                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-justify-items-002.html
942                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-justify-items-003.html
943                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-justify-items-004.html
944                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-justify-items-005.html
945                imported/w3c/web-platform-tests/css/css-align/default-alignment/parse-justify-items-006.html
946                imported/w3c/web-platform-tests/css/css-align/default-alignment/place-items-shorthand-001.html
947                imported/w3c/web-platform-tests/css/css-align/default-alignment/place-items-shorthand-002.html
948                imported/w3c/web-platform-tests/css/css-align/default-alignment/place-items-shorthand-003.html
949                imported/w3c/web-platform-tests/css/css-align/default-alignment/place-items-shorthand-004.html
950                imported/w3c/web-platform-tests/css/css-align/default-alignment/place-items-shorthand-005.html
951                imported/w3c/web-platform-tests/css/css-align/default-alignment/place-items-shorthand-006.html
952                imported/w3c/web-platform-tests/css/css-align/distribution-values/space-evenly-001.html
953                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-align-self-001.html
954                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-align-self-002.html
955                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-align-self-003.html
956                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-align-self-004.html
957                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-align-self-005.html
958                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-justify-self-001.html
959                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-justify-self-002.html
960                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-justify-self-003.html
961                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-justify-self-004.html
962                imported/w3c/web-platform-tests/css/css-align/self-alignment/parse-justify-self-005.html
963                imported/w3c/web-platform-tests/css/css-align/self-alignment/place-self-shorthand-001.html
964                imported/w3c/web-platform-tests/css/css-align/self-alignment/place-self-shorthand-002.html
965                imported/w3c/web-platform-tests/css/css-align/self-alignment/place-self-shorthand-003.html
966                imported/w3c/web-platform-tests/css/css-align/self-alignment/place-self-shorthand-004.html
967                imported/w3c/web-platform-tests/css/css-align/self-alignment/place-self-shorthand-005.html
968                imported/w3c/web-platform-tests/css/css-align/self-alignment/place-self-shorthand-006.html
969
970         * css/parser/CSSPropertyParser.cpp:
971         (WebCore::isLeftOrRightKeyword):
972         (WebCore::isContentPositionKeyword):
973         (WebCore::isContentPositionOrLeftOrRightKeyword):
974         (WebCore::consumeContentDistributionOverflowPosition):
975         (WebCore::isSelfPositionKeyword):
976         (WebCore::isSelfPositionOrLeftOrRightKeyword):
977         (WebCore::consumeSelfPositionOverflowPosition):
978         (WebCore::consumeAlignItems):
979         (WebCore::consumeJustifyItems):
980         (WebCore::CSSPropertyParser::parseSingleValue):
981         (WebCore::consumeSimplifiedContentPosition):
982         (WebCore::CSSPropertyParser::consumePlaceContentShorthand):
983         (WebCore::consumeSimplifiedItemPosition):
984         (WebCore::CSSPropertyParser::consumePlaceItemsShorthand):
985         (WebCore::CSSPropertyParser::consumePlaceSelfShorthand):
986
987 2018-01-23  Simon Fraser  <simon.fraser@apple.com>
988
989         Element with position:fixed stops scrolling at the bottom of the page, but is painted in the right place on Chacos.com.
990         https://bugs.webkit.org/show_bug.cgi?id=181741
991         rdar://problem/36593581
992
993         Reviewed by Tim Horton.
994
995         The #ifdef for iOS was wrong; on iOS, visibleSize() is in content coordinates and matches
996         unscaledDocumentRect, so there's no need to scale it. Doing so computed the wrong unscaledMaximumScrollPosition
997         which broke hit-testing when the document minimum scale was > 1.
998
999         Test: fast/visual-viewport/ios/min-scale-greater-than-one.html
1000
1001         * page/FrameView.cpp:
1002         (WebCore::FrameView::unscaledMaximumScrollPosition const):
1003
1004 2018-01-23  Antoine Quint  <graouts@apple.com>
1005
1006         [Web Animations] Expose getKeyframes() and parsing of remaining keyframe properties
1007         https://bugs.webkit.org/show_bug.cgi?id=181978
1008         <rdar://problem/36772586>
1009
1010         Reviewed by Dean Jackson.
1011
1012         We finish our implementation of multiple keyframes by exposing the getKeyframes() method on KeyframeEffect and
1013         parsing the remaining properties that can be exposed on keyframes: "easing" and "composite". And since we parse
1014         those properties on keyframes, we also parse "easing" on AnimationEffectTiming and "composite" and "iterationComposite"
1015         on KeyframeEffect. 
1016
1017         To support this, we implement a new TimingFunction::createFromCSSText() method which takes in a string that is
1018         a value provided directly via the JS API. As its converse, we expose a TimingFunction::cssText() method which
1019         provides a string that can be sent back to JS to represent a timing function, using keywords when the timing
1020         function matches one and ommitting default values.
1021
1022         We now also keep track of the original "offset" value provided through the JS API since that value is required
1023         when calling getKeyframes() and distinct from the "computedOffset". These original offsets, composite operations
1024         and timing functions are kept as separate Vectors from the KeyframeList since this type does not support exposing
1025         those. We may consider improving that in a future patch.
1026
1027         Finally, we make some adjustments in the keyframe parsing to comply with the specification and correctly parse
1028         all provided timing functions, regardless of the number of keyframes and timing functions provided.
1029
1030         Note that this patch is only about parsing, storing and returning provided easing and composite operations but
1031         that such values will only be used for the resolution of animation effects in future patches.
1032
1033         * animation/AnimationEffect.cpp:
1034         (WebCore::AnimationEffect::getComputedTiming): Set the "easing" property on the getComputedTiming() return value
1035         now that we expose "easing" on AnimationEffectTiming.
1036         * animation/AnimationEffectTiming.cpp:
1037         (WebCore::AnimationEffectTiming::AnimationEffectTiming): Create a linear TimingFunction by default.
1038         (WebCore::AnimationEffectTiming::setEasing): Parse the "easing" value and propagate an exception for invalid values.
1039         * animation/AnimationEffectTiming.h: Expose the new "easing" property and backing TimingFunction.
1040         * animation/AnimationEffectTiming.idl: Expose the new "easing" property.
1041         * animation/KeyframeEffect.cpp:
1042         (WebCore::CSSPropertyIDToIDLAttributeName): Provide a way to convert the name of a CSS property to a string that can
1043         be used to generate a JS property name for use by getKeyframes().
1044         (WebCore::computeMissingKeyframeOffsets): Implement the full steps of the spec.
1045         (WebCore::processIterableKeyframes): Fix a problematic declaration for the easing variable.
1046         (WebCore::processPropertyIndexedKeyframes): Now that ProcessedKeyframe has both an offset and a computedOffset, use
1047         computed offsets. We also fix a couple of loops to fix compliance issues revealed by WPT tests.
1048         (WebCore::KeyframeEffect::create): Parse the provided "easing" property on the KeyframeEffectOptions object.
1049         (WebCore::KeyframeEffect::getKeyframes): Implement the getKeyframes() method as mandated by the spec.
1050         (WebCore::KeyframeEffect::processKeyframes): Keep a list of unused easings so these might be parsed as well, and
1051         potentially throw exceptions, as mandated by the spec. For valid easings, store their matching TimingFunction in
1052         m_timingFunctions, original offset values in m_offsets and CompositeOperation values in m_compositeOperations.
1053         * animation/KeyframeEffect.h: Switch the order in which we specify some of the Variant types so that default values
1054         are correctly used.
1055         * animation/KeyframeEffect.idl: Switch the order in which we specify some of the Variant types so that default values
1056         are correctly used.
1057         * platform/animation/TimingFunction.cpp:
1058         (WebCore::TimingFunction::createFromCSSText):
1059         (WebCore::TimingFunction::cssText const):
1060         * platform/animation/TimingFunction.h:
1061
1062 2018-01-23  Brady Eidson  <beidson@apple.com>
1063
1064         Allow passing MessagePorts across processes (e.g. ServiceWorkers).
1065         https://bugs.webkit.org/show_bug.cgi?id=181178
1066
1067         Reviewed by Andy Estes.
1068
1069         Test: http/tests/workers/service/basic-messageport.html
1070
1071         * dom/MessagePort.cpp:
1072         (WebCore::MessagePort::MessagePort):
1073         (WebCore::MessagePort::~MessagePort):
1074
1075         * dom/messageports/MessagePortChannel.cpp:
1076         (WebCore::MessagePortChannel::entanglePortWithProcess):
1077         * dom/messageports/MessagePortChannel.h:
1078
1079         * workers/service/SWClientConnection.cpp:
1080         (WebCore::SWClientConnection::postMessageToServiceWorkerClient):
1081         * workers/service/SWClientConnection.h:
1082
1083         * workers/service/ServiceWorker.cpp:
1084         (WebCore::ServiceWorker::postMessage):
1085
1086         * workers/service/ServiceWorkerClient.cpp:
1087         (WebCore::ServiceWorkerClient::postMessage):
1088
1089         * workers/service/context/SWContextManager.cpp:
1090         (WebCore::SWContextManager::postMessageToServiceWorker):
1091         * workers/service/context/SWContextManager.h:
1092
1093 2018-01-23  Commit Queue  <commit-queue@webkit.org>
1094
1095         Unreviewed, rolling out r227279 and r227373.
1096         https://bugs.webkit.org/show_bug.cgi?id=181988
1097
1098         The LayoutTest crash fix introduced an API test failure.
1099         (Requested by ryanhaddad on #webkit).
1100
1101         Reverted changesets:
1102
1103         "Resign NowPlaying status when no media element is eligible"
1104         https://bugs.webkit.org/show_bug.cgi?id=181914
1105         https://trac.webkit.org/changeset/227279
1106
1107         "Resign NowPlaying status when no media element is eligible"
1108         https://bugs.webkit.org/show_bug.cgi?id=181914
1109         https://trac.webkit.org/changeset/227373
1110
1111 2018-01-23  Michael Catanzaro  <mcatanzaro@igalia.com>
1112
1113         Unreviewed, fix some format specifiers added in r227190
1114         https://bugs.webkit.org/show_bug.cgi?id=181454
1115
1116         * dom/messageports/MessagePortChannel.cpp:
1117         (WebCore::MessagePortChannel::takeAllMessagesForPort):
1118
1119 2018-01-23  Ting-Wei Lan  <lantw44@gmail.com>
1120
1121         [GTK] Add user agent quirk for Microsoft Outlook Web App
1122         https://bugs.webkit.org/show_bug.cgi?id=181982
1123
1124         Reviewed by Michael Catanzaro.
1125
1126         Microsoft Outlook Web App forces users to switch to the lite version on
1127         the login page with our standard user agent on all non-macOS systems.
1128         Since it is an application that can be installed by different companies,
1129         schools and organizations, it is not possible to fix the issue unless
1130         we keep a big list of host names that are known to run it. We check the
1131         host name instead of the base domain name here because it is not
1132         expected to run all sites under a base domain on this webmail and
1133         calendar application.
1134
1135         https://mail.ntu.edu.tw is a site that is known to run Microsoft Outlook
1136         Web App for several years, and it is not likely to change. When there
1137         are other sites found to run it and having the same user agent problem,
1138         we can expand the list to include them.
1139
1140         * platform/UserAgentQuirks.cpp:
1141         (WebCore::urlRequiresMacintoshPlatform):
1142
1143 2018-01-23  Yacine Bandou  <yacine.bandou_ext@softathome.com>
1144
1145         [EME] Add support of multi keys from different sessions in CDMinstanceClearKey
1146         https://bugs.webkit.org/show_bug.cgi?id=180083
1147
1148         Reviewed by Xabier Rodriguez-Calvar.
1149
1150         Add support of multi keys from different MediaKeySession in CDMInstanceClearKey.
1151
1152         Currently the CDMInstanceClearKey manages two "m_keys", one is a WTF::Vector
1153         where it stores the list of last added keys, an other which is defined in the
1154         ClearKeyState::singleton it is a WTF::HashMap, in this last one, it stores the
1155         keys lists of each created session.
1156
1157         The method "keys()" of CDMInstanceClearKey returns the first "m_keys" which
1158         contains just the list of last keys.
1159
1160         The goal of this commit is to return all keys lists of all sessions, thus
1161         we remove the "m_keys" which is WTF::Vector and we modify the method
1162         "keys()" to return all keys lists, which is stored in "m_keys" WTF::HashMap,
1163         in one Vector instead of return just the list of last keys.
1164
1165         * platform/encryptedmedia/clearkey/CDMClearKey.cpp:
1166         (WebCore::CDMInstanceClearKey::keys const):
1167         (WebCore::CDMInstanceClearKey::updateLicense):
1168         * platform/encryptedmedia/clearkey/CDMClearKey.h:
1169
1170 2018-01-22  Simon Fraser  <simon.fraser@apple.com>
1171
1172         Optimize building the non-fast scrollable region with multiple iframes
1173         https://bugs.webkit.org/show_bug.cgi?id=181971
1174
1175         Reviewed by Zalan Bujtas.
1176
1177         AsyncScrollingCoordinator::frameViewLayoutUpdated() is called every time a subframe lays out.
1178         We don't need to eagerly update the non-fast scrollable region at this time; we can just mark
1179         it dirty, and rely on the existing scrolling tree commit code to recompute it.
1180
1181         On my machine this makes fast/frames/lots-of-objects.html no longer a timeout.
1182
1183         * page/scrolling/AsyncScrollingCoordinator.cpp:
1184         (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
1185
1186 2018-01-22  Jiewen Tan  <jiewen_tan@apple.com>
1187
1188         [WebAuthN] Implement PublicKeyCredential's [[Create]] with a dummy authenticator
1189         https://bugs.webkit.org/show_bug.cgi?id=181928
1190         <rdar://problem/36459893>
1191
1192         Reviewed by Brent Fulgham.
1193
1194         This patch implements PublicKeyCredential's [[Create]] from https://www.w3.org/TR/webauthn/#createCredential
1195         as of 5 December 2017. In order to do testing, a dummy authenticator is implemented to exercise a failure
1196         and a pass path. A number of dependencies need to be resolved later in order to comply with the spec.
1197         Also, the current architecture of handling async WebAuthN operations including dispatching, timeout, and aborting
1198         might need a redesign once the underlying authenticator is clear. Since this is our first attempt to implement
1199         a prototype, all those limitations, in my opinion, can be marked as non-blocking to accelerate the whole
1200         process. Those limitations will then be addressed once the first prototype is finshed.
1201
1202         Tests: http/tests/webauthn/public-key-credential-create-with-invalid-parameters.https.html
1203                http/tests/webauthn/public-key-credential-same-origin-with-ancestors-2.https.html
1204                http/tests/webauthn/public-key-credential-same-origin-with-ancestors.https.html
1205                http/wpt/webauthn/idl.https.html
1206                http/wpt/webauthn/public-key-credential-create-failure.https.html
1207                http/wpt/webauthn/public-key-credential-create-success.https.html
1208
1209         * Modules/credentialmanagement/BasicCredential.h:
1210         * Modules/credentialmanagement/BasicCredential.idl:
1211         * Modules/credentialmanagement/CredentialsContainer.cpp:
1212         (WebCore::CredentialsContainer::PendingPromise::PendingPromise):
1213         (WebCore::CredentialsContainer::dispatchTask):
1214         (WebCore::CredentialsContainer::get):
1215         (WebCore::CredentialsContainer::isCreate):
1216         (WebCore::CredentialsContainer::preventSilentAccess const):
1217         (WebCore::CredentialsContainer::preventSilentAccess): Deleted.
1218         * Modules/credentialmanagement/CredentialsContainer.h:
1219         (WebCore::CredentialsContainer::PendingPromise::create):
1220         * Modules/webauthn/Authenticator.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp.
1221         (WebCore::Authenticator::singleton):
1222         (WebCore::Authenticator::makeCredential const):
1223         * Modules/webauthn/Authenticator.h: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h.
1224         * Modules/webauthn/AuthenticatorAssertionResponse.cpp:
1225         (WebCore::AuthenticatorAssertionResponse::authenticatorData const):
1226         (WebCore::AuthenticatorAssertionResponse::signature const):
1227         (WebCore::AuthenticatorAssertionResponse::userHandle const):
1228         (WebCore::AuthenticatorAssertionResponse::~AuthenticatorAssertionResponse): Deleted.
1229         (WebCore::AuthenticatorAssertionResponse::authenticatorData): Deleted.
1230         (WebCore::AuthenticatorAssertionResponse::signature): Deleted.
1231         (WebCore::AuthenticatorAssertionResponse::userHandle): Deleted.
1232         * Modules/webauthn/AuthenticatorAssertionResponse.h:
1233         (WebCore::AuthenticatorAssertionResponse::create):
1234         * Modules/webauthn/AuthenticatorAttestationResponse.cpp:
1235         (WebCore::AuthenticatorAttestationResponse::attestationObject const):
1236         (WebCore::AuthenticatorAttestationResponse::~AuthenticatorAttestationResponse): Deleted.
1237         (WebCore::AuthenticatorAttestationResponse::attestationObject): Deleted.
1238         * Modules/webauthn/AuthenticatorAttestationResponse.h:
1239         (WebCore::AuthenticatorAttestationResponse::create):
1240         * Modules/webauthn/AuthenticatorResponse.cpp:
1241         (WebCore::AuthenticatorResponse::clientDataJSON const):
1242         (WebCore::AuthenticatorResponse::~AuthenticatorResponse): Deleted.
1243         (WebCore::AuthenticatorResponse::clientDataJSON): Deleted.
1244         * Modules/webauthn/AuthenticatorResponse.h:
1245         * Modules/webauthn/AuthenticatorResponse.idl:
1246         * Modules/webauthn/PublicKeyCredential.cpp:
1247         (WebCore::PublicKeyCredentialInternal::produceClientDataJson):
1248         (WebCore::PublicKeyCredentialInternal::produceClientDataJsonHash):
1249         (WebCore::PublicKeyCredentialInternal::getIdFromAttestationObject):
1250         (WebCore::PublicKeyCredential::PublicKeyCredential):
1251         (WebCore::PublicKeyCredential::discoverFromExternalSource):
1252         (WebCore::PublicKeyCredential::create):
1253         (WebCore::PublicKeyCredential::rawId const):
1254         (WebCore::PublicKeyCredential::response const):
1255         (WebCore::PublicKeyCredential::getClientExtensionResults const):
1256         (WebCore::PublicKeyCredential::rawId): Deleted.
1257         (WebCore::PublicKeyCredential::response): Deleted.
1258         (WebCore::PublicKeyCredential::getClientExtensionResults): Deleted.
1259         * Modules/webauthn/PublicKeyCredential.h:
1260         * Modules/webauthn/PublicKeyCredential.idl:
1261         * Modules/webauthn/PublicKeyCredentialCreationOptions.h:
1262         (): Deleted.
1263         * Modules/webauthn/PublicKeyCredentialDescriptor.h:
1264         * Modules/webauthn/PublicKeyCredentialDescriptor.idl:
1265         * Sources.txt:
1266         * WebCore.xcodeproj/project.pbxproj:
1267         * bindings/js/JSAuthenticatorResponseCustom.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp.
1268         (WebCore::toJSNewlyCreated):
1269         (WebCore::toJS):
1270         * bindings/js/JSBasicCredentialCustom.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp.
1271         (WebCore::toJSNewlyCreated):
1272         (WebCore::toJS):
1273         * bindings/js/JSBindingsAllInOne.cpp:
1274
1275 2018-01-22  Myles C. Maxfield  <mmaxfield@apple.com>
1276
1277         [Cocoa] Support font collections
1278         https://bugs.webkit.org/show_bug.cgi?id=181826
1279         <rdar://problem/36455137>
1280
1281         Reviewed by Dean Jackson.
1282
1283         Use the CoreText call CTFontManagerCreateFontDescriptorsFromData() to get all the descriptors inside
1284         the collection file. We select which one by using the fragment identifier at the end of the url linking
1285         to the remote font. For example, to select the 4th font inside a TTC file, the @font-face block would
1286         look like:
1287
1288         @font-face {
1289             font-family: "MyFont";
1290             src: url("path/to/font.ttc#4");
1291         }
1292
1293         Note that these numbers are 1-indexed.
1294
1295         The CSS Fonts spec states:
1296         > Fragment identifiers are used to indicate which font to load. If a container format lacks a defined
1297         > fragment identifier scheme, implementations should use a simple 1-based indexing scheme (e.g.
1298         > "font-collection#1" for the first font, "font-collection#2" for the second font).
1299
1300         Not only are TTC font collections supported, but WOFF2 font collections are also supported, which is
1301         increasingly important web standard.
1302
1303         No new tests because I don't have a font collection file with the appropriate license for the
1304         WebKit repository. I tested manually.
1305
1306         * css/CSSFontFaceSource.cpp:
1307         (WebCore::CSSFontFaceSource::load):
1308         * loader/cache/CachedFont.cpp:
1309         (WebCore::CachedFont::calculateIndex const):
1310         (WebCore::CachedFont::ensureCustomFontData):
1311         (WebCore::CachedFont::createCustomFontData):
1312         * loader/cache/CachedFont.h:
1313         * platform/graphics/cairo/FontCustomPlatformData.h:
1314         * platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
1315         (WebCore::createFontCustomPlatformData):
1316         * platform/graphics/mac/FontCustomPlatformData.cpp:
1317         (WebCore::createFontCustomPlatformData):
1318         * platform/graphics/mac/FontCustomPlatformData.h:
1319         * platform/graphics/win/FontCustomPlatformData.cpp:
1320         (WebCore::createFontCustomPlatformData):
1321         * platform/graphics/win/FontCustomPlatformData.h:
1322         * platform/graphics/win/FontCustomPlatformDataCairo.cpp:
1323         (WebCore::createFontCustomPlatformData):
1324
1325 2018-01-22  Simon Fraser  <simon.fraser@apple.com>
1326
1327         REGRESSION (r227011): fast/frames/hidpi-position-iframe-on-device-pixel.html times out
1328         https://bugs.webkit.org/show_bug.cgi?id=181959
1329
1330         Reviewed by Zalan Bujtas.
1331
1332         This test creates 300 iframes, which became slow after r227011 because they all became part
1333         of the non-fast scrollable region, slowing down ScrollingCoordinator::absoluteEventTrackingRegionsForFrame().
1334
1335         Fix by not adding non-scrollable iframes, and making FrameView::isScrollable() more efficient for frames
1336         that have not done layout yet.
1337
1338         * page/FrameView.cpp:
1339         (WebCore::FrameView::isScrollable):
1340         (WebCore::FrameView::addChild):
1341
1342 2018-01-22  Dan Bernstein  <mitz@apple.com>
1343
1344         Fixed building for macOS 10.12 with the macOS 10.13 SDK after r227156.
1345
1346         * Configurations/WebCore.xcconfig:
1347
1348 2018-01-22  Simon Fraser  <simon.fraser@apple.com>
1349
1350         REGRESSION (r226981): ASSERTION FAILED: startY >= 0 && endY <= height && startY < endY in WebCore::FEMorphology::platformApplyGeneric
1351         https://bugs.webkit.org/show_bug.cgi?id=181836
1352
1353         Reviewed by Tim Horton.
1354         
1355         All the filters that use ParallelJobs<> has the same type of bug where very wide but not tall
1356         filter regions could result in computing an optimalThreadNumber that was greater than the
1357         number of rows to process, which resulted in jobs with zero rows to process.
1358
1359         Since we split the work by rows, cap the maximum number of threads to height/8 so that each job
1360         has at least 8 rows of pixels to process. Add some assertions to detect jobs with zero rows.
1361
1362         FEMorphology was also using implicit float -> int conversion to detect integer overflow of radius,
1363         so change that to use explicit clamping.
1364         
1365         Tests: svg/filters/feLighting-parallel-jobs.svg
1366                svg/filters/feTurbulence-parallel-jobs-wide.svg
1367
1368         * platform/graphics/filters/FELighting.cpp:
1369         (WebCore::FELighting::platformApplyGenericPaint):
1370         (WebCore::FELighting::platformApplyGeneric):
1371         * platform/graphics/filters/FEMorphology.cpp:
1372         (WebCore::FEMorphology::platformApplyGeneric):
1373         (WebCore::FEMorphology::platformApply):
1374         (WebCore::FEMorphology::platformApplyDegenerate):
1375         (WebCore::FEMorphology::platformApplySoftware):
1376         * platform/graphics/filters/FETurbulence.cpp:
1377         (WebCore::FETurbulence::fillRegion const):
1378         (WebCore::FETurbulence::platformApplySoftware):
1379
1380 2018-01-22  Eric Carlson  <eric.carlson@apple.com>
1381
1382         Resign NowPlaying status when no media element is eligible
1383         https://bugs.webkit.org/show_bug.cgi?id=181914
1384         <rdar://problem/35294116>
1385
1386         Reviewed by Jer Noble.
1387
1388         No new tests, these changes prevent existing tests from crashing.
1389
1390         * html/HTMLMediaElement.h:
1391         * html/MediaElementSession.cpp:
1392         (WebCore::MediaElementSession::playbackPermitted const): Return early when the media 
1393         element has been suspended.
1394         (WebCore::MediaElementSession::canShowControlsManager const): Return false when the
1395         media element has been suspended.
1396         (WebCore::isMainContentForPurposesOfAutoplay): Return early if it isn't safe to update
1397         style because HitTest can force a layout.
1398         (WebCore::MediaElementSession::updateIsMainContent const): Ditto.
1399
1400 2018-01-22  Alex Christensen  <achristensen@webkit.org>
1401
1402         Begin removing QTKit code
1403         https://bugs.webkit.org/show_bug.cgi?id=181951
1404
1405         Reviewed by Jer Noble.
1406
1407         QTKit was being used on El Capitan and before.
1408
1409         * Configurations/WebCore.xcconfig:
1410         * SourcesMac.txt:
1411         * WebCore.xcodeproj/project.pbxproj:
1412         * platform/graphics/MediaPlayer.cpp:
1413         (WebCore::buildMediaEnginesVector):
1414         (WebCore::MediaPlayer::supportsType):
1415         * platform/graphics/mac/MediaPlayerPrivateQTKit.h: Removed.
1416         * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: Removed.
1417         * platform/graphics/mac/MediaTimeQTKit.h: Removed.
1418         * platform/graphics/mac/MediaTimeQTKit.mm: Removed.
1419         * platform/mac/WebVideoFullscreenController.mm:
1420         (-[WebVideoFullscreenController setVideoElement:]):
1421         (-[WebVideoFullscreenController updatePowerAssertions]):
1422
1423 2018-01-22  Per Arne Vollan  <pvollan@apple.com>
1424
1425         [Win] Null pointer crash under WebCore::RenderStyle::colorIncludingFallback.
1426         https://bugs.webkit.org/show_bug.cgi?id=181801
1427         <rdar://problem/35614900>
1428
1429         Reviewed by Brent Fulgham.
1430
1431         Do not paint synchronously when popup items have been added or changed while the popup is visible.
1432         If new popup items have been added after the popup was shown, a synchronous paint operation will
1433         possibly access their style before it is ready, leading to a null pointer crash. The invalidated
1434         area will be painted asynchronously.
1435
1436         No new tests. To reproduce this crash, it is necessary to open a popup with JavaScript, add new
1437         popup items, and then end the test. Opening the popup can be done by sending a mousedown event
1438         with the eventsender. However, on Windows the mousedown event is sent synchronously, and will
1439         block as long as the popup is open and running the popup event loop. This means no JS can be
1440         executed until the popup is closed, causing the test to always time out before new popup items
1441         can be added. I have verified the fix with a manual test case.
1442
1443         * platform/win/PopupMenuWin.cpp:
1444         (WebCore::PopupMenuWin::updateFromElement):
1445
1446 2018-01-22  Chris Dumez  <cdumez@apple.com>
1447
1448         RELEASE_ASSERT(registration) hit in SWServer::installContextData(const ServiceWorkerContextData&)
1449         https://bugs.webkit.org/show_bug.cgi?id=181941
1450         <rdar://problem/36744892>
1451
1452         Reviewed by Youenn Fablet.
1453
1454         Make sure we clear SWServer::m_pendingContextDatas & SWServer::m_pendingJobs as needed
1455         when clearing Website data. Otherwise, we will hit assertion when those gets processed
1456         after the connection to the SW process has been established (not to mentioned we failed
1457         to clear some in-memory data even though the user asked us to).
1458
1459         * workers/service/server/SWServer.cpp:
1460         (WebCore::SWServer::clearAll):
1461         (WebCore::SWServer::clear):
1462
1463 2018-01-22  Ryosuke Niwa  <rniwa@webkit.org>
1464
1465         Blob conversion and sanitization doesn't work with Microsoft Word for Mac 2011
1466         https://bugs.webkit.org/show_bug.cgi?id=181616
1467         <rdar://problem/36484908>
1468
1469         Reviewed by Wenson Hsieh.
1470
1471         The bug was caused by WebContentReader::readHTML and WebContentMarkupReader::readHTML not sanitizing plain HTML string
1472         as done for web archives even when custom pasteboard data is enabled. Fixed the bug by doing the sanitization.
1473
1474         Unfortunately, we can't make file URLs available in this case because WebContent process doesn't have sandbox extensions
1475         to access local files referenced by the HTML source in the clipboard, and we can't make WebContent process request for
1476         a sandbox extension¸on an arbitrary local file, as it would defeat the whole point of sandboxing.
1477
1478         Instead, we strip away all HTML attributes referencing a URL whose scheme is not HTTP, HTTPS, or data when sanitizing
1479         text/html from the clipboard to avoid exposing local file paths, which can reveal privacy & security sensitive data
1480         such as the user's full name, and the location of private containers of other applications in the system.
1481
1482         Tests: PasteHTML.DoesNotSanitizeHTMLWhenCustomPasteboardDataIsDisabled
1483                PasteHTML.DoesNotStripFileURLsWhenCustomPasteboardDataIsDisabled
1484                PasteHTML.ExposesHTMLTypeInDataTransfer
1485                PasteHTML.KeepsHTTPURLs
1486                PasteHTML.SanitizesHTML
1487                PasteHTML.StripsFileURLs
1488
1489         * editing/cocoa/WebContentReaderCocoa.mm:
1490         (WebCore::WebContentReader::readHTML): Fixed the bug by sanitizing the markup, and stripping away file URLs.
1491         (WebCore::WebContentMarkupReader::readHTML): Ditto.
1492         * editing/markup.cpp:
1493         (WebCore::removeSubresourceURLAttributes): Added.
1494         (WebCore::sanitizeMarkup): Added.
1495         * editing/markup.h:
1496
1497 2018-01-22  Chris Dumez  <cdumez@apple.com>
1498
1499         Add release logging to help debug issues related to service workers
1500         https://bugs.webkit.org/show_bug.cgi?id=181935
1501         <rdar://problem/36735900>
1502
1503         Reviewed by Brady Eidson.
1504
1505         * workers/service/ServiceWorker.cpp:
1506         (WebCore::ServiceWorker::ServiceWorker):
1507         (WebCore::ServiceWorker::scheduleTaskToUpdateState):
1508         (WebCore::ServiceWorker::postMessage):
1509         (WebCore::ServiceWorker::isAlwaysOnLoggingAllowed const):
1510         * workers/service/ServiceWorker.h:
1511         * workers/service/ServiceWorkerContainer.cpp:
1512         (WebCore::ServiceWorkerContainer::addRegistration):
1513         (WebCore::ServiceWorkerContainer::removeRegistration):
1514         (WebCore::ServiceWorkerContainer::updateRegistration):
1515         (WebCore::ServiceWorkerContainer::jobFailedWithException):
1516         (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
1517         (WebCore::ServiceWorkerContainer::jobResolvedWithUnregistrationResult):
1518         (WebCore::ServiceWorkerContainer::startScriptFetchForJob):
1519         (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
1520         (WebCore::ServiceWorkerContainer::jobFailedLoadingScript):
1521         (WebCore::ServiceWorkerContainer::isAlwaysOnLoggingAllowed const):
1522         * workers/service/ServiceWorkerContainer.h:
1523         * workers/service/ServiceWorkerRegistration.cpp:
1524         (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
1525         (WebCore::ServiceWorkerRegistration::updateStateFromServer):
1526         (WebCore::ServiceWorkerRegistration::scheduleTaskToFireUpdateFoundEvent):
1527         * workers/service/server/SWServer.cpp:
1528         (WebCore::SWServer::scriptContextFailedToStart):
1529         (WebCore::SWServer::didFinishInstall):
1530         (WebCore::SWServer::didFinishActivation):
1531         (WebCore::SWServer::terminateWorkerInternal):
1532         * workers/service/server/SWServerJobQueue.cpp:
1533         (WebCore::SWServerJobQueue::didResolveRegistrationPromise):
1534         (WebCore::SWServerJobQueue::runRegisterJob):
1535
1536 2018-01-22  Youenn Fablet  <youenn@apple.com>
1537
1538         Safari Tech Preview can't use GitHub login at forums.swift.org
1539         https://bugs.webkit.org/show_bug.cgi?id=181908
1540         <rdar://problem/36715111>
1541
1542         Reviewed by Chris Dumez.
1543
1544         Test: http/wpt/service-workers/navigation-redirect.https.html
1545
1546         For subresource loads, redirections will not change who is in charge of continuing the load (service worker or network process).
1547         For navigation loads, we need to match the registration for every redirection since this is using the Manual redirect mode.
1548         This allows starting the load with a service worker and finishing the load with another service worker, which will become the controller.
1549
1550         Implement this by wrapping the registration matching of an URL within DocumentLoader::matchRegistration.
1551         Use that method in DocumentLoader::redirectReceived.
1552
1553         * loader/DocumentLoader.cpp:
1554         (WebCore::DocumentLoader::matchRegistration):
1555         (WebCore::doRegistrationsMatch):
1556         (WebCore::DocumentLoader::redirectReceived):
1557         (WebCore::DocumentLoader::startLoadingMainResource):
1558         * loader/DocumentLoader.h:
1559
1560 2018-01-22  Antti Koivisto  <antti@apple.com>
1561
1562         REGRESSION (Safari 11): Buttons inside a fieldset legend cannot be clicked on in Safari 11
1563         https://bugs.webkit.org/show_bug.cgi?id=179666
1564         <rdar://problem/35534292>
1565
1566         Reviewed by Zalan Bujtas.
1567
1568         The legend element of a fieldset is in the border area, outside the clip rect.
1569         With overflow:hidden mouse events won't reach it.
1570
1571         Test case by Dhaya Benmessaoud.
1572
1573         Test: fast/forms/legend-overflow-hidden-hit-test.html
1574
1575         * rendering/RenderBlock.cpp:
1576         (WebCore::RenderBlock::nodeAtPoint):
1577         (WebCore::RenderBlock::hitTestExcludedChildrenInBorder):
1578
1579         Add a special case to hit testing to handle legend, similarly to what is done for painting.
1580
1581         * rendering/RenderBlock.h:
1582
1583 2018-01-22  Joanmarie Diggs  <jdiggs@igalia.com>
1584
1585         AX: Implement support for Graphics ARIA roles
1586         https://bugs.webkit.org/show_bug.cgi?id=181796
1587
1588         Reviewed by Chris Fleizach.
1589
1590         Add mappings for the three new roles (graphics-document, graphics-object,
1591         and graphics-symbol) as per the Graphics Accessibility API Mappings spec.
1592
1593         No new tests; instead, new test cases added to roles-computedRoleString.html
1594         and roles-exposed.html.
1595
1596         * accessibility/AccessibilityObject.cpp:
1597         (WebCore::initializeRoleMap):
1598         (WebCore::AccessibilityObject::computedRoleString const):
1599         * accessibility/AccessibilityObject.h:
1600         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
1601         (atkRole):
1602         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
1603         (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
1604         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
1605         (createAccessibilityRoleMap):
1606         (-[WebAccessibilityObjectWrapper subrole]):
1607         (-[WebAccessibilityObjectWrapper roleDescription]):
1608
1609 2018-01-22  Antti Koivisto  <antti@apple.com>
1610
1611         REGRESSION(r224535): Can't write reviews in the App Store
1612         https://bugs.webkit.org/show_bug.cgi?id=181936
1613         <rdar://problem/36670246>
1614
1615         Reviewed by Zalan Bujtas.
1616
1617         * page/LayoutContext.cpp:
1618         (WebCore::LayoutContext::updateStyleForLayout):
1619
1620         r224535 was about media queries but it also removed a seemingly spurious call to SyleScope::didChangeStyleSheetEnvironment
1621         from the path that does not involve media queries.
1622         Turns out UITextContentView somehow depended on it, so revert this specific change.
1623
1624 2018-01-22  Brady Eidson  <beidson@apple.com>
1625
1626         In WebKit2, make the MessagePortChannelRegistry live in the UI process.
1627         https://bugs.webkit.org/show_bug.cgi?id=181922
1628
1629         Reviewed by Andy Estes.
1630
1631         No new tests (Refactor, no behavior change)
1632
1633         Add encoder/decoders and EXPORT a whole bunch of stuff.
1634         
1635         * WebCore.xcodeproj/project.pbxproj:
1636
1637         * dom/MessagePort.h:
1638
1639         * dom/messageports/MessagePortChannel.cpp:
1640         (WebCore::MessagePortChannel::processForPort):
1641         * dom/messageports/MessagePortChannel.h:
1642
1643         * dom/messageports/MessagePortChannelProvider.h:
1644         * dom/messageports/MessagePortChannelRegistry.h:
1645
1646         * dom/messageports/MessageWithMessagePorts.h:
1647         (WebCore::MessageWithMessagePorts::encode const):
1648         (WebCore::MessageWithMessagePorts::decode):
1649
1650 2018-01-22  Youenn Fablet  <youenn@apple.com>
1651
1652         Fetch Headers from an Opaque response should be filtered out
1653         https://bugs.webkit.org/show_bug.cgi?id=181926
1654
1655         Reviewed by Chris Dumez.
1656
1657         Covered by updated test.
1658
1659         Refactor to use the same FetchResponse::create for Cache API and cloning.
1660         In this method, ensure that response and headers are filtered correctly according response tainting.
1661         Make also sure that synthetic responses do not get filtered (not needed since created by JavaScript).
1662
1663         Introduce helper routine to set the header map of a resource response.
1664         Use this routine when cloning a synthetic response as in that case, m_internalResponse has no header at all.
1665
1666         * Modules/cache/DOMCache.cpp:
1667         (WebCore::DOMCache::updateRecords):
1668         * Modules/fetch/FetchResponse.cpp:
1669         (WebCore::FetchResponse::create):
1670         (WebCore::FetchResponse::clone):
1671         * Modules/fetch/FetchResponse.h:
1672         * platform/network/ResourceResponseBase.cpp:
1673         (WebCore::ResourceResponseBase::setHTTPHeaderFields):
1674         * platform/network/ResourceResponseBase.h:
1675         * testing/ServiceWorkerInternals.cpp:
1676         (WebCore::ServiceWorkerInternals::createOpaqueWithBlobBodyResponse):
1677
1678 2018-01-22  Javier Fernandez  <jfernandez@igalia.com>
1679
1680         [css-align] 'overflow' keyword must precede the self-position and content-position value
1681         https://bugs.webkit.org/show_bug.cgi?id=181793
1682
1683         Reviewed by Antti Koivisto.
1684
1685         There were several discussions to avoid ambiguities with the complex
1686         values, specially when it comes to define the place-xxx shorthands.
1687
1688         One of the sources of problems is the 'overflow-position' keyword. The
1689         CSS WG has decided to change the syntax of all the CSS Box Alignment
1690         properties so that the 'overflow-position' keyword always precede the
1691         'self-position' or the 'content-position' keywords.
1692
1693         https://github.com/w3c/csswg-drafts/issues/1446#event-1125715434
1694
1695         In order to apply this change to the Content Distribution properties'
1696         (align-content and justify-content) syntax I had to completely
1697         re-implement their parsing function. Thanks to this I addressed also
1698         the issue with the content-distribution fallback, which cannot be
1699         specified explicitly now.
1700
1701         https://github.com/w3c/csswg-drafts/issues/1002#ref-commit-c38cac4
1702
1703         No new tests, just rebaselined the expected results of the test cases affected.
1704
1705         Despite the so many layout tests affected by this change, it's
1706         unlikely that it might break any content in current web
1707         sites. This patch changes the new CSS syntax, obviously backward
1708         compatible, defined by the new CSS Box Alignment. The
1709         'overflow-position' keyword is only used by the layout models
1710         implementing the new spec, so far only CSS Grid Layout.
1711         Considering that CSS Grid has been shipped last year, it's unlikely
1712         that many sites are using the new CSS values.
1713
1714         * css/CSSComputedStyleDeclaration.cpp:
1715         (WebCore::valueForItemPositionWithOverflowAlignment):
1716         (WebCore::valueForContentPositionAndDistributionWithOverflowAlignment):
1717         * css/CSSContentDistributionValue.cpp:
1718         (WebCore::CSSContentDistributionValue::customCSSText const):
1719         * css/StyleBuilderConverter.h:
1720         (WebCore::StyleBuilderConverter::convertSelfOrDefaultAlignmentData):
1721         * css/parser/CSSPropertyParser.cpp:
1722         (WebCore::consumeOverflowPositionKeyword):
1723         (WebCore::consumeContentPositionKeyword):
1724         (WebCore::consumeContentDistributionOverflowPosition):
1725         (WebCore::consumeSelfPositionOverflowPosition):
1726
1727 2018-01-22  Chris Nardi  <csnardi1@gmail.com>
1728
1729         Parse calc() in CSS media queries
1730         https://bugs.webkit.org/show_bug.cgi?id=181716
1731
1732         calc() was previously unsupported inside of media queries. This change
1733         adds in support for parsing calc inside of media queries.
1734
1735         Reviewed by Antti Koivisto.
1736
1737         Tests: Imported web-platform-tests/css/mediaqueries
1738
1739         * css/MediaQueryExpression.cpp:
1740         (WebCore::featureWithValidIdent): Updated function to take a CSSPrimitiveValue.
1741         (WebCore::featureWithValidDensity): Updated function to take a CSSPrimitiveValue instead of a CSSParserToken.
1742         (WebCore::featureWithValidPositiveLength): Ditto.
1743         (WebCore::featureExpectingPositiveInteger): Ditto.
1744         (WebCore::featureWithPositiveInteger): Ditto.
1745         (WebCore::featureWithPositiveNumber): Ditto.
1746         (WebCore::featureWithZeroOrOne): Ditto.
1747         (WebCore::MediaQueryExpression::MediaQueryExpression): Use CSSPropertyParserHelpers for consuming.
1748         * css/MediaQueryExpression.h:
1749         * css/parser/CSSPropertyParserHelpers.cpp:
1750         (WebCore::CSSPropertyParserHelpers::consumeResolution): Added function for use in media query expression parsing.
1751         * css/parser/CSSPropertyParserHelpers.h:
1752         * css/parser/MediaQueryParser.cpp:
1753         (WebCore::MediaQueryParser::readRestrictor): Updated functions to take a CSSParserTokenRange in order to use CSSPropertyParserHelpers.
1754         (WebCore::MediaQueryParser::readMediaNot): Ditto.
1755         (WebCore::MediaQueryParser::readMediaType): Ditto.
1756         (WebCore::MediaQueryParser::readAnd): Ditto.
1757         (WebCore::MediaQueryParser::readFeatureStart): Ditto.
1758         (WebCore::MediaQueryParser::readFeature): Ditto.
1759         (WebCore::MediaQueryParser::readFeatureColon): Ditto.
1760         (WebCore::MediaQueryParser::readFeatureValue): Ditto.
1761         (WebCore::MediaQueryParser::readFeatureEnd): Ditto.
1762         (WebCore::MediaQueryParser::skipUntilComma): Ditto.
1763         (WebCore::MediaQueryParser::skipUntilBlockEnd): Ditto.
1764         (WebCore::MediaQueryParser::processToken): Ditto.
1765         (WebCore::MediaQueryParser::parseInternal): Ditto.
1766         (WebCore::MediaQueryData::clear): Removed reference to m_valueList
1767         (WebCore::MediaQueryData::addExpression): Use CSSParserTokenRange.
1768         (WebCore::MediaQueryData::lastExpressionValid): New helper function.
1769         (WebCore::MediaQueryData::removeLastExpression): New helper function.
1770         * css/parser/MediaQueryParser.h:
1771
1772 2018-01-22  Zan Dobersek  <zdobersek@igalia.com>
1773
1774         [Cairo] Refactor PlatformContextCairo::drawSurfaceToContext() into a Cairo operation
1775         https://bugs.webkit.org/show_bug.cgi?id=181930
1776
1777         Reviewed by Carlos Garcia Campos.
1778
1779         Move the PlatformContextCairo::drawSurfaceToContext() code into the
1780         Cairo namespace as an operation, renaming it to drawSurface(). Mirroring
1781         other operations, the PlatformContextCairo object is now passed through
1782         a reference as the first argument to the function, and cairo_t context
1783         object is retrieved from that.
1784
1785         Call sites of the PlatformContextCairo::drawSurfaceToContext() method
1786         are adjusted to now call Cairo::drawSurface() and properly pass the
1787         PlatformContextCairo object to the function.
1788
1789         No new tests -- no change in functionality.
1790
1791         * platform/graphics/cairo/CairoOperations.cpp:
1792         (WebCore::Cairo::prepareForStroking): Make this static.
1793         (WebCore::Cairo::drawPatternToCairoContext):
1794         (WebCore::Cairo::drawNativeImage):
1795         (WebCore::Cairo::drawSurface):
1796         * platform/graphics/cairo/CairoOperations.h:
1797         * platform/graphics/cairo/PlatformContextCairo.cpp:
1798         (WebCore::drawPatternToCairoContext): Deleted.
1799         (WebCore::PlatformContextCairo::drawSurfaceToContext): Deleted.
1800         * platform/graphics/cairo/PlatformContextCairo.h:
1801         * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
1802         (WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::paintCurrentFrame):
1803
1804 2018-01-22  Manuel Rego Casasnovas  <rego@igalia.com>
1805
1806         [css-grid] Spanning Grid item has too much space at the bottom / is too high
1807         https://bugs.webkit.org/show_bug.cgi?id=181677
1808
1809         Reviewed by Javier Fernandez.
1810
1811         In IndefiniteSizeStrategy::findUsedFlexFraction() we were not
1812         subtracting the size of the gutters when we call findFrUnitSize().
1813         If an item spans several tracks, we cannot pass the maxContentForChild()
1814         directly, we need to subtract the gutters as they are treated
1815         as fixed size tracks in the algorithm.
1816
1817         The spec text is pretty clear regarding this
1818         (https://drafts.csswg.org/css-grid/#algo-find-fr-size):
1819         "Let leftover space be the space to fill minus the base sizes
1820          of the non-flexible grid tracks."
1821
1822         Gutters are treated as fixed-size tracks for the purpose
1823         of the track sizing algorithm, so we need to subtract them from the
1824         leftover space while finding the size of an "fr".
1825
1826         Tests: imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/grid-find-fr-size-gutters-001.html
1827                imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/grid-find-fr-size-gutters-002.html
1828
1829         * rendering/GridTrackSizingAlgorithm.cpp:
1830         (WebCore::GridTrackSizingAlgorithm::findFrUnitSize const):
1831         (WebCore::IndefiniteSizeStrategy::findUsedFlexFraction const):
1832
1833 2018-01-21  Ryosuke Niwa  <rniwa@webkit.org>
1834
1835         Turning off custom pasteboard data doesn't actually turn it off in WK2
1836         https://bugs.webkit.org/show_bug.cgi?id=181920
1837         <rdar://problem/36686429>
1838
1839         Reviewed by Wenson Hsieh.
1840
1841         Replaced the global settings for custom pasteboard data by regular runtime enabled flags.
1842
1843         * dom/DataTransfer.cpp:
1844         (WebCore::DataTransfer::getDataForItem const):
1845         (WebCore::DataTransfer::shouldSuppressGetAndSetDataToAvoidExposingFilePaths const):
1846         (WebCore::DataTransfer::setDataFromItemList):
1847         (WebCore::DataTransfer::types const):
1848         (WebCore::DataTransfer::commitToPasteboard):
1849         * dom/DataTransferItemList.cpp:
1850         (WebCore::shouldExposeTypeInItemList):
1851         * editing/Editor.cpp:
1852         (WebCore::createDataTransferForClipboardEvent):
1853         * editing/cocoa/WebContentReaderCocoa.mm:
1854         (WebCore::createFragmentAndAddResources):
1855         (WebCore::WebContentReader::readWebArchive):
1856         * page/DeprecatedGlobalSettings.cpp:
1857         (WebCore::DeprecatedGlobalSettings::defaultCustomPasteboardDataEnabled): Deleted.
1858         * page/DeprecatedGlobalSettings.h:
1859         (WebCore::DeprecatedGlobalSettings::setCustomPasteboardDataEnabled): Deleted.
1860         (WebCore::DeprecatedGlobalSettings::customPasteboardDataEnabled): Deleted.
1861         * page/RuntimeEnabledFeatures.h:
1862         (WebCore::RuntimeEnabledFeatures::setCustomPasteboardDataEnabled):
1863         (WebCore::RuntimeEnabledFeatures::customPasteboardDataEnabled const):
1864         * testing/InternalSettings.cpp:
1865         (WebCore::InternalSettings::Backup::Backup):
1866         (WebCore::InternalSettings::Backup::restoreTo):
1867         (WebCore::InternalSettings::setCustomPasteboardDataEnabled):
1868
1869 2018-01-21  Wenson Hsieh  <wenson_hsieh@apple.com>
1870
1871         Add a new feature flag for EXTRA_ZOOM_MODE and reintroduce AdditionalFeatureDefines.h
1872         https://bugs.webkit.org/show_bug.cgi?id=181918
1873
1874         Reviewed by Tim Horton.
1875
1876         Add EXTRA_ZOOM_MODE to FeatureDefines.xconfig (off by default). No change in behavior.
1877
1878         * Configurations/FeatureDefines.xcconfig:
1879
1880 2018-01-19  Ryosuke Niwa  <rniwa@webkit.org>
1881
1882         Release assertion in canExecuteScript when executing scripts during page cache restore
1883         https://bugs.webkit.org/show_bug.cgi?id=181902
1884
1885         Reviewed by Antti Koivisto.
1886
1887         The crash was caused by an erroneous instantiation of ScriptDisallowedScope::InMainThread in CachedPage::restore.
1888         It can execute arbitrary scripts since CachedFrame::open can update style, layout, and evaluate media queries.
1889
1890         This is fine because there is no way to put this page back into a page cache until the load is commited via
1891         FrameLoader::commitProvisionalLoad is invoked later which only happens after CachedPage::restore had exited.
1892
1893         Also added a release assert to make sure this condition holds.
1894
1895         Tests: fast/history/page-cache-execute-script-during-restore.html
1896                fast/history/page-cache-navigate-during-restore.html
1897
1898         * history/CachedPage.cpp:
1899         (WebCore::CachedPageRestorationScope::CachedPageRestorationScope): Added.
1900         (WebCore::CachedPageRestorationScope::~CachedPageRestorationScope): Added.
1901         (WebCore::CachedPage::restore): Don't instantiate ScriptDisallowedScope::InMainThread. Set isRestoringCachedPage
1902         on the cached pate to release-assert that there won't be any attempt to put this very page back into the cache.
1903         * history/PageCache.cpp:
1904         (WebCore::canCachePage): Added a release assert to make sure the page which is in the process of being restored
1905         from the page cache is not put into the page cache.
1906         * page/Page.h:
1907         (WebCore::Page::setIsRestoringCachedPage): Added.
1908         (WebCore::Page::isRestoringCachedPage const): Added.
1909
1910 2018-01-21  Eric Carlson  <eric.carlson@apple.com>
1911
1912         Resign NowPlaying status when no media element is eligible
1913         https://bugs.webkit.org/show_bug.cgi?id=181914
1914         <rdar://problem/35294116>
1915
1916         Reviewed by Jer Noble.
1917
1918         Updated API test.
1919
1920         * html/HTMLMediaElement.cpp:
1921         (WebCore::HTMLMediaElement::removedFromAncestor): Call mediaSession->clientCharacteristicsChanged
1922         so NowPlaying status will be updated.
1923
1924         * html/MediaElementSession.cpp:
1925         (WebCore::MediaElementSession::canShowControlsManager const): Return false when being queried
1926         for NowPlaying status in an inactive document.
1927
1928         * platform/audio/PlatformMediaSessionManager.cpp:
1929         (WebCore::PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary): Implement in for all
1930         ports.
1931         * platform/audio/PlatformMediaSessionManager.h:
1932         (WebCore::PlatformMediaSessionManager::registeredAsNowPlayingApplication const):
1933         * platform/audio/ios/MediaSessionManagerIOS.h:
1934         * platform/audio/mac/MediaSessionManagerMac.h:
1935         * platform/audio/mac/MediaSessionManagerMac.mm:
1936         (WebCore::MediaSessionManagerMac::updateNowPlayingInfo): Call MRMediaRemoteSetCanBeNowPlayingApplication
1937         whenever status changes.
1938         (WebCore::PlatformMediaSessionManager::updateNowPlayingInfoIfNecessary): Deleted, implemented
1939         in the base class.
1940
1941 2018-01-21  Jer Noble  <jer.noble@apple.com>
1942
1943         REGRESSION (macOS 10.13.2): imported/w3c/web-platform-tests/media-source/mediasource-* LayoutTests failing
1944         https://bugs.webkit.org/show_bug.cgi?id=181891
1945
1946         Reviewed by Eric Carlson.
1947
1948         In macOS 10.13.2, CoreMedia changed the definition of CMSampleBufferGetDuration() to return
1949         the presentation duration rather than the decode duration. For media streams where those two
1950         durations are identical (or at least, closely similar), this isn't a problem. But the media
1951         file used in the WPT tests have an unusual frame cadence: decode durations go {3000, 1, 5999,
1952         1, 5999,...} and presentation durations go {3000, 2999, 3000, 2999}. This caused one check in
1953         the "Coded Frame Processing" algorithm to begin failing, where it checks that the delta
1954         between the last sample's decode time and the new decode time is no more than 2x as far as
1955         the last sample's duration. That's not a problem as long as the "duration" is the "decode
1956         duration" and the samples are all adjacent. Once the "duration" is "presentation duration",
1957         all the assumptions in the algorithm are invalidated. In the WPT test case, the delta between
1958         decode times is 5999, and 2 * the presentation duration is 5998, causing all samples up to
1959         the next sync sample to be dropped.
1960
1961         To work around this change in behavior, we'll adopt the same technique used by Mozilla's MSE
1962         implementation, which was done for similar reasons. Rather than track the "last frame duration",
1963         we'll record the "greatest frame duration", and use actual decode timestamps to derive this
1964         duration. The "greatest frame duration" field will be reset at the same times as "last frame
1965         duration", and will be used only in the part of the algorithm that checks for large decode
1966         timestamp gaps.
1967
1968         * Modules/mediasource/SourceBuffer.cpp:
1969         (WebCore::SourceBuffer::TrackBuffer::TrackBuffer):
1970         (WebCore::SourceBuffer::resetParserState):
1971         (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
1972
1973 2018-01-21  Andy Estes  <aestes@apple.com>
1974
1975         [ios] LayoutTest imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html is crashing in JSC::JSONParse
1976         https://bugs.webkit.org/show_bug.cgi?id=177832
1977         <rdar://problem/34805315>
1978
1979         Reviewed by Tim Horton.
1980
1981         Test: http/tests/paymentrequest/rejects_if_not_active.https.html
1982
1983         * Modules/paymentrequest/PaymentRequest.cpp:
1984         (WebCore::PaymentRequest::show): Rejected promise if the document is not active.
1985
1986 2018-01-20  Brady Eidson  <beidson@apple.com>
1987
1988         Make garbage collection of MessagePort objects be asynchronous.
1989         https://bugs.webkit.org/show_bug.cgi?id=181910
1990
1991         Reviewed by Andy Estes.
1992
1993         No new tests (Covered by existing tests, including GC-specific ones).
1994
1995         The basic premise here is as follows:
1996         - You can *always* GC a MessagePort that is closed
1997         - You can *always* GC a MessagePort that has no onmessage handler, as incoming messages cannot 
1998           possibly revive it.
1999         - You can GC a MessagePort, even if it has a message handler, as long as there are no messages 
2000           in flight between it and the remote port, and as long as the remote port is "maybe eligible for GC."
2001           
2002         A MessagePort is considered "maybe eligible for GC" once hasPendingActivity is asked once.
2003         
2004         A MessagePort loses "maybe eligible for GC" status once it is used for sending or receiving a message.
2005         
2006         The changes to MessagePort.cpp implement the above with a tiny little bool-driven state machine.
2007         * dom/MessagePort.cpp:
2008         (WebCore::MessagePort::postMessage):
2009         (WebCore::MessagePort::disentangle):
2010         (WebCore::MessagePort::registerLocalActivity):
2011         (WebCore::MessagePort::start):
2012         (WebCore::MessagePort::close):
2013         (WebCore::MessagePort::contextDestroyed):
2014         (WebCore::MessagePort::dispatchMessages):
2015         (WebCore::MessagePort::hasPendingActivity const):
2016         (WebCore::MessagePort::isLocallyReachable const):
2017         (WebCore::MessagePort::addEventListener):
2018         (WebCore::MessagePort::removeEventListener):
2019         * dom/MessagePort.h:
2020
2021         - Remove the lock and any background-thread code paths
2022         - Add ASSERT(isMainThread())s throughout
2023         * dom/messageports/MessagePortChannel.cpp:
2024         (WebCore::MessagePortChannel::MessagePortChannel):
2025         (WebCore::MessagePortChannel::includesPort):
2026         (WebCore::MessagePortChannel::entanglePortWithProcess):
2027         (WebCore::MessagePortChannel::disentanglePort):
2028         (WebCore::MessagePortChannel::closePort):
2029         (WebCore::MessagePortChannel::postMessageToRemote):
2030         (WebCore::MessagePortChannel::takeAllMessagesForPort):
2031         (WebCore::MessagePortChannel::checkRemotePortForActivity):
2032         (WebCore::MessagePortChannel::hasAnyMessagesPendingOrInFlight const):
2033         * dom/messageports/MessagePortChannel.h:
2034         
2035         Add a callback for a MessagePortChannel to go ask the remote MessagePort object about local activity:
2036         * dom/messageports/MessagePortChannelProvider.h:
2037         * dom/messageports/MessagePortChannelProviderImpl.cpp:
2038         (WebCore::MessagePortChannelProviderImpl::checkRemotePortForActivity):
2039         (WebCore::MessagePortChannelProviderImpl::checkProcessLocalPortForActivity):
2040         (WebCore::MessagePortChannelProviderImpl::hasMessagesForPorts_temporarySync): Deleted.
2041         * dom/messageports/MessagePortChannelProviderImpl.h:
2042         
2043         - Remove the lock and any background-thread code paths
2044         - Add ASSERT(isMainThread())s throughout
2045         * dom/messageports/MessagePortChannelRegistry.cpp:
2046         (WebCore::MessagePortChannelRegistry::messagePortChannelCreated):
2047         (WebCore::MessagePortChannelRegistry::messagePortChannelDestroyed):
2048         (WebCore::MessagePortChannelRegistry::didEntangleLocalToRemote):
2049         (WebCore::MessagePortChannelRegistry::didDisentangleMessagePort):
2050         (WebCore::MessagePortChannelRegistry::didCloseMessagePort):
2051         (WebCore::MessagePortChannelRegistry::didPostMessageToRemote):
2052         (WebCore::MessagePortChannelRegistry::takeAllMessagesForPort):
2053         (WebCore::MessagePortChannelRegistry::checkRemotePortForActivity):
2054         (WebCore::MessagePortChannelRegistry::existingChannelContainingPort):
2055         (WebCore::MessagePortChannelRegistry::hasMessagesForPorts_temporarySync): Deleted.
2056         * dom/messageports/MessagePortChannelRegistry.h:
2057
2058 2018-01-20  Andy Estes  <aestes@apple.com>
2059
2060         [Apple Pay] Stop eagerly loading PassKit.framework
2061         https://bugs.webkit.org/show_bug.cgi?id=181911
2062         <rdar://problem/36555369>
2063
2064         Reviewed by Tim Horton.
2065
2066         r226458 and r226123 added code that caused PassKit.framework to be eagerly loaded when
2067         initializing a WKWebView. This is costly and should only be done when Apple Pay is first used.
2068
2069         To avoid eagerly loading PassKit, this patch does two things:
2070
2071         1. Instead of sending the available payment networks as part of WebPageCreationParameters,
2072         PaymentCoordinator asks for them using a syncrhonous message the first time they are needed.
2073         2. Instead of setting the Apple Pay preference to false when PassKit can't be loaded,
2074         the following API entry points check for a missing PassKit and return false, or throw
2075         exceptions, or reject promises:
2076             - ApplePaySession.canMakePayments()
2077             - ApplePaySession.canMakePaymentsWithActiveCard()
2078             - ApplePaySession.openPaymentSetup()
2079             - ApplePaySession.begin()
2080
2081         No new tests for (1), which causes no change in behavior. (2) was manually verified by
2082         locally moving aside PassKit.framework, but that's not possible to do in an automated test.
2083
2084         * Modules/applepay/PaymentCoordinator.cpp:
2085         (WebCore::PaymentCoordinator::PaymentCoordinator):
2086         (WebCore::PaymentCoordinator::validatedPaymentNetwork const):
2087         (WebCore::toHashSet): Deleted.
2088         * Modules/applepay/PaymentCoordinator.h:
2089         * Modules/applepay/PaymentCoordinatorClient.h:
2090         * loader/EmptyClients.cpp:
2091         * page/MainFrame.cpp:
2092         (WebCore::MainFrame::MainFrame):
2093
2094         Removed PaymentCoordinator::m_availablePaymentNetworks and made
2095         PaymentCoordinator::validatedPaymentNetwork() call
2096         PaymentCoordinatorClient::validatedPaymentNetwork() instead.
2097
2098         * page/PageConfiguration.h:
2099
2100         Removed availablePaymentNetworks from PageConfiguration.
2101
2102         * testing/Internals.cpp:
2103         (WebCore::Internals::Internals):
2104         * testing/MockPaymentCoordinator.cpp:
2105         (WebCore::MockPaymentCoordinator::validatedPaymentNetwork):
2106         * testing/MockPaymentCoordinator.h:
2107
2108         Implemented PaymentCoordinatorClient::validatedPaymentNetwork().
2109
2110 2018-01-20  Jer Noble  <jer.noble@apple.com>
2111
2112         Release ASSERT when reloading Vimeo page @ WebCore: WebCore::Document::updateLayout
2113         https://bugs.webkit.org/show_bug.cgi?id=181840
2114         <rdar://problem/36186214>
2115
2116         Reviewed by Simon Fraser.
2117
2118         Test: media/video-fullscreen-reload-crash.html
2119
2120         Short circuit play() or pause() operations if the document is suspended or stopped.
2121
2122         * html/HTMLMediaElement.cpp:
2123         (WebCore::HTMLMediaElement::playInternal):
2124         (WebCore::HTMLMediaElement::pauseInternal):
2125
2126 2018-01-20  Youenn Fablet  <youenn@apple.com>
2127
2128         fetch redirect is incompatible with "no-cors" mode
2129         https://bugs.webkit.org/show_bug.cgi?id=181866
2130         <rdar://problem/35827140>
2131
2132         Reviewed by Chris Dumez.
2133
2134         Covered by updated tests.
2135
2136         Return a network error when no-cors mode and redirect mode is manual or error.
2137         Update preflight implementation to no longer use manual redirect mode to simulate https://fetch.spec.whatwg.org/#http-network-or-cache-fetch.
2138         Instead implement redirectReceived callback to treat any redirect response as the preflight response.
2139
2140         * loader/cache/CachedResourceLoader.cpp:
2141         (WebCore::CachedResourceLoader::canRequest):
2142         * loader/CrossOriginPreflightChecker.cpp:
2143         (WebCore::CrossOriginPreflightChecker::redirectReceived):
2144         (WebCore::CrossOriginPreflightChecker::startPreflight):
2145         * loader/CrossOriginPreflightChecker.h:
2146
2147 2018-01-19  Wenson Hsieh  <wenson_hsieh@apple.com>
2148
2149         [macOS] [WK2] Drag location is computed incorrectly when dragging content from subframes
2150         https://bugs.webkit.org/show_bug.cgi?id=181896
2151         <rdar://problem/35479043>
2152
2153         Reviewed by Tim Horton.
2154
2155         In r218837, I packaged most of the information needed to start a drag into DragItem, which is propagated to the client layer
2156         via the startDrag codepath. However, this introduced a bug in computing the event position and drag location in window
2157         coordinates. Consider the case where we're determining the drag image offset for a dragged element in a subframe:
2158
2159         Before the patch, the drag location (which starts out in the subframe's content coordinates) would be converted to root view
2160         coordinates, which would then be converted to mainframe content coordinates, which would then be converted to window coordinates
2161         using the mainframe's view. After the patch, we carry out the same math until the last step, where we erroneously use the
2162         _subframe's_ view to convert to window coordinates from content coordinates. This results in the position of the iframe relative
2163         to the mainframe being accounted for twice.
2164
2165         To fix this, we simply use the main frame's view to convert from mainframe content coordinates to window coordinates while
2166         computing the drag location. As for the event position in window coordinates, this is currently unused by any codepath in WebKit,
2167         so we can just remove it altogether.
2168
2169         Since this bug only affects drag and drop in the macOS WebKit2 port, there's currently no way to test this. I'll be using
2170         <https://bugs.webkit.org/show_bug.cgi?id=181898> to track adding test support for drag and drop on macOS WebKit2. Manually tested
2171         dragging in both WebKit1 and WebKit2 on macOS. dragLocationInWindowCoordinates isn't used at all for iOS drag and drop.
2172
2173         * page/DragController.cpp:
2174         (WebCore::DragController::doSystemDrag):
2175         * platform/DragItem.h:
2176         (WebCore::DragItem::encode const):
2177         (WebCore::DragItem::decode):
2178
2179 2018-01-19  Ryan Haddad  <ryanhaddad@apple.com>
2180
2181         Unreviewed, rolling out r227235.
2182
2183         The test for this change consistently times out on High
2184         Sierra.
2185
2186         Reverted changeset:
2187
2188         "Support for preconnect Link headers"
2189         https://bugs.webkit.org/show_bug.cgi?id=181657
2190         https://trac.webkit.org/changeset/227235
2191
2192 2018-01-19  Youenn Fablet  <youenn@apple.com>
2193
2194         Cache storage errors like Quota should trigger console messages
2195         https://bugs.webkit.org/show_bug.cgi?id=181879
2196         <rdar://problem/36669048>
2197
2198         Reviewed by Chris Dumez.
2199
2200         Covered by rebased test.
2201
2202         * Modules/cache/DOMCache.cpp:
2203         (WebCore::DOMCache::retrieveRecords):
2204         (WebCore::DOMCache::batchDeleteOperation):
2205         (WebCore::DOMCache::batchPutOperation):
2206         * Modules/cache/DOMCacheEngine.cpp:
2207         (WebCore::DOMCacheEngine::errorToException):
2208         (WebCore::DOMCacheEngine::logErrorAndConvertToException):
2209         * Modules/cache/DOMCacheEngine.h:
2210         * Modules/cache/DOMCacheStorage.cpp:
2211         (WebCore::DOMCacheStorage::retrieveCaches):
2212         (WebCore::DOMCacheStorage::doOpen):
2213         (WebCore::DOMCacheStorage::doRemove):
2214
2215 2018-01-19  Youenn Fablet  <youenn@apple.com>
2216
2217         Do not go to the storage process when registering a service worker client if there is no service worker registered
2218         https://bugs.webkit.org/show_bug.cgi?id=181740
2219         <rdar://problem/36650400>
2220
2221         Reviewed by Chris Dumez.
2222
2223         Register a document as service worker client only if there is an existing service worker connection.
2224         This allows not creating any connection if no service worker is registered.
2225
2226         Add internals API to test whether a service worker connection was created or not.
2227         This is used by API tests that cover the changes.
2228
2229         * dom/Document.cpp:
2230         (WebCore::Document::privateBrowsingStateDidChange): No need to create a service worker connection if client is not registered yet.
2231         (WebCore::Document::setServiceWorkerConnection): No need to unregister/register if service worker connection is the same.
2232         Similarly, if Document is to be destroyed or suspended, we should not register it.
2233         * loader/DocumentLoader.cpp:
2234         (WebCore::DocumentLoader::commitData):
2235         * testing/Internals.cpp:
2236         (WebCore::Internals::hasServiceWorkerConnection):
2237         * testing/Internals.h:
2238         * testing/Internals.idl:
2239         * workers/service/ServiceWorkerProvider.cpp:
2240         (WebCore::ServiceWorkerProvider::registerServiceWorkerClients):
2241         * workers/service/ServiceWorkerProvider.h:
2242
2243 2018-01-19  Dean Jackson  <dino@apple.com>
2244
2245         REGRESSION (r221092): Swipe actions are hard to perform in FastMail app
2246         https://bugs.webkit.org/show_bug.cgi?id=181817
2247         <rdar://problem/35274055>
2248
2249         Add a setting for controlling whether touch listeners are passive
2250         by default on document/window/body.
2251
2252         Updated existing test.
2253
2254         * dom/EventTarget.cpp:
2255         (WebCore::EventTarget::addEventListener):
2256         * page/Settings.yaml:
2257
2258 2018-01-19  Daniel Bates  <dabates@apple.com>
2259
2260         Update frame-ancestor directive to match Content Security Policy Level 3
2261         https://bugs.webkit.org/show_bug.cgi?id=178891
2262         <rdar://problem/35209458>
2263
2264         Reviewed by Alex Christensen.
2265
2266         Derived from Blink e667cc2e501fabab3605b838e4ee0d642a9c4a59:
2267         <https://chromium.googlesource.com/chromium/src.git/+/e667cc2e501fabab3605b838e4ee0d642a9c4a59>
2268
2269         Update frame-ancestor directive to match against the origin of the ancestor document per the
2270         Content Security Policy Level 3 spec.: <https://w3c.github.io/webappsec-csp/> (15 January 2018).
2271         Specifically this change in behavior was made to CSP 3 in <https://github.com/w3c/webappsec/issues/311>.
2272         In earlier versions of the spec, the frame-ancestor directive matched against the URL of the
2273         ancestor document.
2274
2275         Disregarding allow-same-origin sandboxed iframes, a document with policy "frame-ancestor 'self'"
2276         will be blocked from loading in a sandboxed iframe as a result of this change.
2277
2278         Tests: http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-nested-cross-in-allow-same-origin-sandboxed-cross-url-allow.html
2279                http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-nested-cross-in-sandboxed-cross-url-block.html
2280
2281         * page/csp/ContentSecurityPolicyDirectiveList.cpp:
2282         (WebCore::checkFrameAncestors):
2283
2284 2018-01-19  Basuke Suzuki  <Basuke.Suzuki@sony.com>
2285
2286         [Curl] Add timeout support to XMLHttpRequest
2287         https://bugs.webkit.org/show_bug.cgi?id=181876
2288
2289         Reviewed by Alex Christensen 
2290
2291         * platform/network/ResourceRequestBase.cpp:
2292         * platform/network/curl/CurlContext.cpp:
2293         (WebCore::CurlHandle::setTimeout):
2294         * platform/network/curl/CurlContext.h:
2295         * platform/network/curl/CurlRequest.cpp:
2296         (WebCore::CurlRequest::setupTransfer):
2297         (WebCore::CurlRequest::didCompleteTransfer):
2298         * platform/network/curl/ResourceError.h:
2299         * platform/network/curl/ResourceErrorCurl.cpp:
2300         (WebCore::ResourceError::httpError):
2301
2302 2018-01-19  Yoav Weiss  <yoav@yoav.ws>
2303
2304         Support for preconnect Link headers
2305         https://bugs.webkit.org/show_bug.cgi?id=181657
2306
2307         Reviewed by Darin Adler.
2308
2309         Move the preconnect functionality into its own function, and
2310         also call this function when Link headers are processed.
2311
2312         Test: http/tests/preconnect/link-header-rel-preconnect-http.php
2313
2314         * loader/LinkLoader.cpp:
2315         (WebCore::LinkLoader::loadLinksFromHeader): Call preconnectIfNeeded.
2316         (WebCore::LinkLoader::preconnectIfNeeded): Preconnect to a host functionality moved here.
2317         (WebCore::LinkLoader::loadLink): Call preconnectIfNeeded.
2318         * loader/LinkLoader.h:
2319
2320 2018-01-19  Joseph Pecoraro  <pecoraro@apple.com>
2321
2322         AppCache: Log a Deprecation warning to the Console when AppCache is used
2323         https://bugs.webkit.org/show_bug.cgi?id=181778
2324
2325         Reviewed by Alex Christensen.
2326
2327         * html/HTMLHtmlElement.cpp:
2328         (WebCore::HTMLHtmlElement::insertedByParser):
2329
2330 2018-01-19  Chris Dumez  <cdumez@apple.com>
2331
2332         ASSERT(registration || isTerminating()) hit in SWServerWorker::skipWaiting()
2333         https://bugs.webkit.org/show_bug.cgi?id=181761
2334         <rdar://problem/36594564>
2335
2336         Reviewed by Youenn Fablet.
2337
2338         There is a short period of time, early in the registration process where a
2339         SWServerWorker object exists for a registration but is not in the registration's
2340         installing/waiting/active slots yet. As a result, if a registration is cleared
2341         during this period (for e.g. due to the user clearing all website data), that
2342         SWServerWorker will not be terminated. We then hit assertion later on when this
2343         worker is trying to do things (like call skipWaiting).
2344
2345         To address the issue, we now keep a reference this SWServerWorker on the
2346         registration, via a new SWServerRegistration::m_preInstallationWorker data member.
2347         When the registration is cleared, we now take care of terminating this worker.
2348
2349         No new tests, covered by existing tests that crash flakily in debug builds.
2350
2351         * workers/WorkerThread.cpp:
2352         (WebCore::WorkerThread::stop):
2353         if the mutex is locked, then the worker thread is still starting. We spin the
2354         runloop and try to stop again later. This avoids the deadlock shown in
2355         Bug 181763 as the worker thread may need to interact with the main thread
2356         during startup.
2357
2358         * workers/service/server/SWServer.cpp:
2359         (WebCore::SWServer::installContextData):
2360         * workers/service/server/SWServerJobQueue.cpp:
2361         (WebCore::SWServerJobQueue::scriptContextFailedToStart):
2362         (WebCore::SWServerJobQueue::install):
2363         * workers/service/server/SWServerRegistration.cpp:
2364         (WebCore::SWServerRegistration::~SWServerRegistration):
2365         (WebCore::SWServerRegistration::setPreInstallationWorker):
2366         (WebCore::SWServerRegistration::clear):
2367         * workers/service/server/SWServerRegistration.h:
2368         (WebCore::SWServerRegistration::preInstallationWorker const):
2369
2370 2018-01-19  Chris Dumez  <cdumez@apple.com>
2371
2372         Service worker registrations restored from disk may not be reused when the JS calls register() again
2373         https://bugs.webkit.org/show_bug.cgi?id=181810
2374         <rdar://problem/36591711>
2375
2376         Reviewed by Youenn Fablet.
2377
2378         The issue was that when restoring a registration from disk, we would not set its active worker right
2379         away. We only set it later in installContextData(). installContextData() is only called after we’ve
2380         launched the service worker process and established a connection to it.
2381
2382         However, we would start processing jobs (such as registrations) before we’ve established the connection
2383         to the service worker process. SWServerJobQueue::runRegisterJob(), in order to reuse an existing
2384         registration checks the registration’s active worker has the right script URL. The issue was that when
2385         this code would execute, we may not have set the registration’s active service worker yet, in which case,
2386         we would update the existing registration instead of reusing it as-is.
2387
2388         To address the issue, we now delay the processing of jobs until the connection to the service worker
2389         process has been established and we've installed all pending contexts via installContextData().
2390
2391         Changed is covered by new API test.
2392
2393         * workers/service/server/SWServer.cpp:
2394         (WebCore::SWServer::Connection::scheduleJobInServer):
2395         (WebCore::SWServer::scheduleJob):
2396         (WebCore::SWServer::serverToContextConnectionCreated):
2397         * workers/service/server/SWServer.h:
2398
2399 2018-01-19  James Craig  <jcraig@apple.com>
2400
2401         AX: when invert colors is on, double-invert image and picture elements in UserAgentStyleSheet
2402         https://bugs.webkit.org/show_bug.cgi?id=181281
2403         <rdar://problem/36291776>
2404
2405         Reviewed by Simon Fraser.
2406
2407         Updated "Smart Invert" to include img and picture element inversion and tests.
2408
2409         Tests: accessibility/smart-invert-reference.html
2410                accessibility/smart-invert.html
2411
2412         * css/html.css:
2413         (@media (inverted-colors)):
2414         (img:not(picture>img), picture, video):
2415
2416 2018-01-19  Chris Dumez  <cdumez@apple.com>
2417
2418         The WebContent process should not process incoming IPC while waiting for a sync IPC reply
2419         https://bugs.webkit.org/show_bug.cgi?id=181560
2420
2421         Reviewed by Ryosuke Niwa.
2422
2423         Add internals API for testing purposes.
2424
2425         Test: fast/misc/testIncomingSyncIPCMessageWhileWaitingForSyncReply.html
2426
2427         * page/ChromeClient.h:
2428         * testing/Internals.cpp:
2429         (WebCore::Internals::testIncomingSyncIPCMessageWhileWaitingForSyncReply):
2430         * testing/Internals.h:
2431         * testing/Internals.idl:
2432
2433 2018-01-19  Keith Miller  <keith_miller@apple.com>
2434
2435         HaveInternalSDK includes should be "#include?"
2436         https://bugs.webkit.org/show_bug.cgi?id=179670
2437
2438         Reviewed by Dan Bernstein.
2439
2440         * Configurations/Base.xcconfig:
2441
2442 2018-01-19  Daniel Bates  <dabates@apple.com>
2443
2444         Fix misspelling; substitute willDetachRenderer for willDetatchRenderer.
2445
2446         * html/HTMLPlugInImageElement.cpp:
2447         (WebCore::HTMLPlugInImageElement::willDetachRenderers):
2448         * plugins/PluginViewBase.h:
2449         (WebCore::PluginViewBase::willDetachRenderer):
2450         (WebCore::PluginViewBase::willDetatchRenderer): Deleted.
2451
2452 2018-01-19  Jonathan Bedard  <jbedard@apple.com>
2453
2454         Unreviewed build fix, remove unused lambda captures.
2455
2456         * dom/messageports/MessagePortChannel.cpp:
2457         (WebCore::MessagePortChannel::takeAllMessagesForPort):
2458         * dom/messageports/MessagePortChannelRegistry.cpp:
2459         (WebCore::MessagePortChannelRegistry::messagePortChannelCreated):
2460
2461 2018-01-19  Antoine Quint  <graouts@apple.com>
2462
2463         [Web Animations] Expose timing properties (delay, endDelay, fill, iterationStart, iterations, direction) and getComputedTiming()
2464         https://bugs.webkit.org/show_bug.cgi?id=181857
2465         <rdar://problem/36660081>
2466
2467         Reviewed by Dean Jackson.
2468
2469         We start the work to implement the rest of the Web Animations timing and animation model by exposing more properties on
2470         AnimationEffectTiming to control delay (delay, endDelay), looping (iterationStart, iterations), fill and direction.
2471         Additionally, we expose the getComputedTiming() method on AnimationEffect, although it currently lacks some computed
2472         properties that will come in later patch as we implement various processes defined by the spec. We also update the
2473         existing duration() method on AnimationEffectTiming to be called iterationDuration() to match the terms used in the
2474         specification.
2475
2476         Finally, we make all new properties, and update existing ones, that expose a time value go through the new utility
2477         function secondsToWebAnimationsAPITime() to guarantee rounded values with microseconds precision, as advised by
2478         the Web Animations specification.
2479
2480         * CMakeLists.txt:
2481         * DerivedSources.make:
2482         * Sources.txt:
2483         * WebCore.xcodeproj/project.pbxproj:
2484         * animation/AnimationEffect.cpp:
2485         (WebCore::AnimationEffect::localTime const):
2486         (WebCore::AnimationEffect::getComputedTiming):
2487         * animation/AnimationEffect.h:
2488         * animation/AnimationEffect.idl:
2489         * animation/AnimationEffectTiming.cpp:
2490         (WebCore::AnimationEffectTiming::AnimationEffectTiming):
2491         (WebCore::AnimationEffectTiming::setIterationStart):
2492         (WebCore::AnimationEffectTiming::setIterations):
2493         (WebCore::AnimationEffectTiming::bindingsDuration const):
2494         (WebCore::AnimationEffectTiming::setBindingsDuration):
2495         (WebCore::AnimationEffectTiming::endTime const):
2496         (WebCore::AnimationEffectTiming::activeDuration const):
2497         * animation/AnimationEffectTiming.h:
2498         * animation/AnimationEffectTiming.idl:
2499         * animation/AnimationPlaybackEvent.cpp:
2500         (WebCore::AnimationPlaybackEvent::bindingsCurrentTime const):
2501         (WebCore::AnimationPlaybackEvent::bindingsTimelineTime const):
2502         * animation/AnimationTimeline.cpp:
2503         (WebCore::AnimationTimeline::bindingsCurrentTime):
2504         * animation/ComputedTimingProperties.h: Added.
2505         * animation/ComputedTimingProperties.idl: Added. We set nullable double values to a default value of "null" since
2506         otherwise setting those properties to a null value would not set the properties in the converted JS dictionary.
2507         * animation/KeyframeEffect.cpp:
2508         (WebCore::KeyframeEffect::create): Handle new timing properties passed in the KeyframeEffectOptions dictionary.
2509         (WebCore::KeyframeEffect::applyAtLocalTime):
2510         (WebCore::KeyframeEffect::getAnimatedStyle):
2511         (WebCore::KeyframeEffect::startOrStopAccelerated):
2512         * animation/WebAnimation.cpp:
2513         (WebCore::WebAnimation::bindingsStartTime const):
2514         (WebCore::WebAnimation::bindingsCurrentTime const):
2515         (WebCore::WebAnimation::effectEndTime const):
2516         (WebCore::WebAnimation::timeToNextRequiredTick const):
2517         * animation/WebAnimationUtilities.h: Added.
2518         (WebCore::secondsToWebAnimationsAPITime):
2519
2520 2018-01-19  Alex Christensen  <achristensen@webkit.org>
2521
2522         Remove dead networking code
2523         https://bugs.webkit.org/show_bug.cgi?id=181813
2524
2525         Reviewed by Tim Horton.
2526
2527         CFURLConnection is only used on Windows.
2528
2529         * platform/network/cf/ResourceError.h:
2530         * platform/network/cf/ResourceRequest.h:
2531         (WebCore::ResourceRequest::encodingRequiresPlatformData const):
2532         * platform/network/cf/ResourceRequestCFNet.cpp:
2533         (WebCore::findCFURLRequestCopyContentDispositionEncodingFallbackArrayFunction):
2534         (WebCore::ResourceRequest::doUpdatePlatformRequest):
2535         (WebCore::ResourceRequest::doUpdatePlatformHTTPBody):
2536         (WebCore::ResourceRequest::doUpdateResourceRequest):
2537         (WebCore::ResourceRequest::setStorageSession):
2538         * platform/network/cf/ResourceResponse.h:
2539         (WebCore::ResourceResponse::ResourceResponse):
2540
2541 2018-01-19  Alex Christensen  <achristensen@webkit.org>
2542
2543         Remove unused WebViewPrivate _allowCookies
2544         https://bugs.webkit.org/show_bug.cgi?id=181812
2545
2546         Reviewed by Tim Horton.
2547
2548         This SPI was in the original iOS upstreaming and has not been used in many years.
2549
2550         * platform/network/ResourceRequestBase.cpp:
2551         (WebCore::ResourceRequestBase::setDefaultAllowCookies): Deleted.
2552         (WebCore::ResourceRequestBase::defaultAllowCookies): Deleted.
2553         * platform/network/ResourceRequestBase.h:
2554         (WebCore::ResourceRequestBase::ResourceRequestBase):
2555
2556 2018-01-18  Brady Eidson  <beidson@apple.com>
2557
2558         Make in-process MessagePorts be (mostly) asynchronous
2559         https://bugs.webkit.org/show_bug.cgi?id=181454
2560
2561         Reviewed by Alex Christensen.
2562
2563         No new tests (Covered *brutally* by existing tests)
2564
2565         Part of making MessagePorts be a thing we can pass across processes is making them work async.
2566         
2567         The existing "MessagePortChannel" method of abstraction was not cut out for this.
2568         This patch gets rid of MessagePortChannel and adds a new MessagePortChannelProvider abstraction.
2569         It then gets the new machinery working in-process (with some pieces of out-of-process in place)
2570
2571         One synchronous behavior this patch maintains is the hasPendingActivity() check used to support GC.
2572         That will (creatively) be made async in the next followup.
2573         
2574         More generally from MessagePorts, this patch also adds a "MessageWithMessagePorts" object to be used
2575         with all forms of postMessage(). Much better.
2576         
2577         * CMakeLists.txt:
2578         * Sources.txt:
2579         * WebCore.xcodeproj/project.pbxproj:
2580
2581         * dom/InProcessMessagePortChannel.cpp: Removed.
2582         * dom/InProcessMessagePortChannel.h: Removed.
2583         * dom/MessagePortChannel.cpp: Removed.
2584         * dom/MessagePortChannel.h: Removed.
2585
2586         * dom/MessageChannel.cpp:
2587         (WebCore::MessageChannel::create):
2588         (WebCore::MessageChannel::MessageChannel):
2589         (WebCore::m_port2): Deleted.
2590         * dom/MessageChannel.h:
2591         (WebCore::MessageChannel::create): Deleted.
2592
2593         * dom/MessagePort.cpp:
2594         (WebCore::MessagePort::create):
2595         (WebCore::MessagePort::MessagePort):
2596         (WebCore::MessagePort::~MessagePort):
2597         (WebCore::MessagePort::entangle):
2598         (WebCore::MessagePort::postMessage):
2599         (WebCore::MessagePort::disentangle):
2600         (WebCore::MessagePort::messageAvailable):
2601         (WebCore::MessagePort::start):
2602         (WebCore::MessagePort::close):
2603         (WebCore::MessagePort::contextDestroyed):
2604         (WebCore::MessagePort::dispatchMessages):
2605         (WebCore::MessagePort::hasPendingActivity const):
2606         (WebCore::MessagePort::locallyEntangledPort const):
2607         (WebCore::MessagePort::disentanglePorts):
2608         (WebCore::MessagePort::entanglePorts):
2609         (WebCore::MessagePort::entangleWithRemote): Deleted.
2610         * dom/MessagePort.h:
2611
2612         * dom/MessagePortIdentifier.h:
2613         (WebCore::MessagePortIdentifier::logString const):
2614
2615         * dom/ScriptExecutionContext.cpp:
2616         (WebCore::ScriptExecutionContext::processMessageWithMessagePortsSoon):
2617         (WebCore::ScriptExecutionContext::dispatchMessagePortEvents):
2618         (WebCore::ScriptExecutionContext::processMessagePortMessagesSoon): Deleted.
2619         * dom/ScriptExecutionContext.h:
2620
2621         Add a single object that represents two intertwined ports, tracks their pending
2622         messages, tracks which process they're in, etc etc:
2623         * dom/messageports/MessagePortChannel.cpp: Added.
2624         (WebCore::MessagePortChannel::create):
2625         (WebCore::MessagePortChannel::MessagePortChannel):
2626         (WebCore::MessagePortChannel::~MessagePortChannel):
2627         (WebCore::MessagePortChannel::includesPort):
2628         (WebCore::MessagePortChannel::entanglePortWithProcess):
2629         (WebCore::MessagePortChannel::disentanglePort):
2630         (WebCore::MessagePortChannel::closePort):
2631         (WebCore::MessagePortChannel::postMessageToRemote):
2632         (WebCore::MessagePortChannel::takeAllMessagesForPort):
2633         (WebCore::MessagePortChannel::hasAnyMessagesPendingOrInFlight const):
2634         * dom/messageports/MessagePortChannel.h: Added.
2635         (WebCore::MessagePortChannel::port1 const):
2636         (WebCore::MessagePortChannel::port2 const):
2637         (WebCore::MessagePortChannel::logString const):
2638
2639         Abstraction for creating and operating on MessagePorts in a potentially cross-process way:
2640         * dom/messageports/MessagePortChannelProvider.cpp: Added.
2641         (WebCore::MessagePortChannelProvider::singleton):
2642         (WebCore::MessagePortChannelProvider::setSharedProvider):
2643         * dom/messageports/MessagePortChannelProvider.h: Added.
2644         (WebCore::MessagePortChannelProvider::~MessagePortChannelProvider):
2645
2646         Adds a concrete implementation of that provider to be used in-process (e.g. WK1):
2647         * dom/messageports/MessagePortChannelProviderImpl.cpp: Added.
2648         (WebCore::MessagePortChannelProviderImpl::~MessagePortChannelProviderImpl):
2649         (WebCore::MessagePortChannelProviderImpl::performActionOnAppropriateThread):
2650         (WebCore::MessagePortChannelProviderImpl::createNewMessagePortChannel):
2651         (WebCore::MessagePortChannelProviderImpl::entangleLocalPortInThisProcessToRemote):
2652         (WebCore::MessagePortChannelProviderImpl::messagePortDisentangled):
2653         (WebCore::MessagePortChannelProviderImpl::messagePortClosed):
2654         (WebCore::MessagePortChannelProviderImpl::postMessageToRemote):
2655         (WebCore::MessagePortChannelProviderImpl::takeAllMessagesForPort):
2656         (WebCore::MessagePortChannelProviderImpl::hasMessagesForPorts_temporarySync):
2657         * dom/messageports/MessagePortChannelProviderImpl.h: Added.
2658
2659         Adds a main thread object to handle the set of all MessagePortChannels that are open.
2660         For now it lives in the WebProcess, but for out-of-process it will live in the UIProcess:
2661         * dom/messageports/MessagePortChannelRegistry.cpp: Added.
2662         (WebCore::MessagePortChannelRegistry::~MessagePortChannelRegistry):
2663         (WebCore::MessagePortChannelRegistry::didCreateMessagePortChannel):
2664         (WebCore::MessagePortChannelRegistry::messagePortChannelCreated):
2665         (WebCore::MessagePortChannelRegistry::messagePortChannelDestroyed):
2666         (WebCore::MessagePortChannelRegistry::didEntangleLocalToRemote):
2667         (WebCore::MessagePortChannelRegistry::didDisentangleMessagePort):
2668         (WebCore::MessagePortChannelRegistry::didCloseMessagePort):
2669         (WebCore::MessagePortChannelRegistry::didPostMessageToRemote):
2670         (WebCore::MessagePortChannelRegistry::takeAllMessagesForPort):
2671         (WebCore::MessagePortChannelRegistry::hasMessagesForPorts_temporarySync): This is named against style
2672           and weird on purpose - to call attention to how bad it is and how it's temporary.
2673         (WebCore::MessagePortChannelRegistry::existingChannelContainingPort):
2674         * dom/messageports/MessagePortChannelRegistry.h: Added.
2675
2676         Add an object that represents a "SerializedScriptValue for the message payload and the ports
2677         that are being transferred along with that payload". This is used in all forms of postMessage():
2678         * dom/messageports/MessageWithMessagePorts.cpp: Added.
2679         * dom/messageports/MessageWithMessagePorts.h: Added.
2680
2681         * page/DOMWindow.cpp:
2682         (WebCore::PostMessageTimer::PostMessageTimer):
2683         (WebCore::PostMessageTimer::event):
2684         (WebCore::DOMWindow::postMessage):
2685
2686         * platform/Logging.h:
2687
2688         * workers/DedicatedWorkerGlobalScope.cpp:
2689         (WebCore::DedicatedWorkerGlobalScope::postMessage):
2690
2691         * workers/Worker.cpp:
2692         (WebCore::Worker::postMessage):
2693
2694         * workers/WorkerGlobalScopeProxy.h:
2695
2696         * workers/WorkerMessagingProxy.cpp:
2697         (WebCore::WorkerMessagingProxy::postMessageToWorkerObject):
2698         (WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope):
2699         * workers/WorkerMessagingProxy.h:
2700
2701         * workers/WorkerObjectProxy.h:
2702
2703         * workers/service/ServiceWorker.cpp:
2704         (WebCore::ServiceWorker::postMessage):
2705
2706         * workers/service/ServiceWorkerClient.cpp:
2707         (WebCore::ServiceWorkerClient::postMessage):
2708
2709         * workers/service/context/SWContextManager.cpp:
2710         (WebCore::SWContextManager::postMessageToServiceWorker):
2711
2712         * workers/service/context/ServiceWorkerThread.cpp:
2713         (WebCore::fireMessageEvent):
2714         (WebCore::ServiceWorkerThread::postMessageToServiceWorker):
2715         * workers/service/context/ServiceWorkerThread.h:
2716
2717 2018-01-18  Ryan Haddad  <ryanhaddad@apple.com>
2718
2719         Unreviewed build fix, removed unused lambda capture.
2720
2721         * workers/service/context/SWContextManager.cpp:
2722         (WebCore::SWContextManager::ServiceWorkerTerminationRequest::ServiceWorkerTerminationRequest):
2723
2724 2018-01-18  Chris Dumez  <cdumez@apple.com>
2725
2726         We should be able to terminate service workers that are unresponsive
2727         https://bugs.webkit.org/show_bug.cgi?id=181563
2728         <rdar://problem/35280031>
2729
2730         Reviewed by Alex Christensen.
2731
2732         Test: http/tests/workers/service/postmessage-after-terminating-hung-worker.html
2733
2734         * workers/service/context/SWContextManager.cpp:
2735         (WebCore::SWContextManager::terminateWorker):
2736         Before calling WorkerThread::stop(), set a timer with the given timeout parameter.
2737         If the worker thread has not stopped when the timer fires, forcefully exit the
2738         service worker process. The StorageProcess will take care of relaunching the
2739         service worker process if it exits abruptly.
2740
2741         (WebCore::SWContextManager::serviceWorkerFailedToTerminate):
2742         Log error message if we failed to terminate a service worker and call exit().
2743
2744         (WebCore::SWContextManager::ServiceWorkerTerminationRequest::ServiceWorkerTerminationRequest):
2745
2746         * workers/service/context/SWContextManager.h:
2747
2748 2018-01-18  Youenn Fablet  <youenn@apple.com>
2749
2750         Do not go to the storage process when loading a main resource if there is no service worker registered
2751         https://bugs.webkit.org/show_bug.cgi?id=181395
2752
2753         Reviewed by Chris Dumez.
2754
2755         No observable behavior change.
2756         Instead of creating a connection to know whether there is a potential service worker,
2757         Ask the service worker provider that will use the connection if needed.
2758         Otherwise, it will use a default value provided by the UIProcess.
2759
2760         Tested by cleaning all service workers and checking the computed value of the default value,
2761         then observing whether pages registering service workers work well.
2762
2763         * loader/DocumentLoader.cpp:
2764         (WebCore::DocumentLoader::startLoadingMainResource):
2765         * workers/service/ServiceWorkerProvider.cpp:
2766         (WebCore::ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin):
2767         * workers/service/ServiceWorkerProvider.h:
2768
2769 2018-01-18  Dan Bernstein  <mitz@apple.com>
2770
2771         [Xcode] Streamline and future-proof target-macOS-version-dependent build setting definitions
2772         https://bugs.webkit.org/show_bug.cgi?id=181803
2773
2774         Reviewed by Tim Horton.
2775
2776         * Configurations/Base.xcconfig: Updated.
2777         * Configurations/DebugRelease.xcconfig: Ditto.
2778         * Configurations/FeatureDefines.xcconfig: Adopted macOSTargetConditionals helpers.
2779         * Configurations/Version.xcconfig: Updated.
2780         * Configurations/macOSTargetConditionals.xcconfig: Added. Defines helper build settings
2781           useful for defining settings that depend on the target macOS version.
2782
2783 2018-01-18  Chris Dumez  <cdumez@apple.com>
2784
2785         Service Workers restored from persistent storage have 'redundant' state
2786         https://bugs.webkit.org/show_bug.cgi?id=181749
2787         <rdar://problem/36556486>
2788
2789         Reviewed by Youenn Fablet.
2790
2791         Tested by new API test.
2792
2793         * workers/service/server/SWServer.cpp:
2794         (WebCore::SWServer::installContextData):
2795         Make sure the SWServerWorker's state is set to "activated" after it is assigned to
2796         the registrations' active slot. Otherwise, it stays in its default state (redundant).
2797
2798 2018-01-18  Antti Koivisto  <antti@apple.com>
2799
2800         REGRESSION(r225650): The scores of MotionMark tests Multiply and Leaves dropped by 8%
2801         https://bugs.webkit.org/show_bug.cgi?id=181460
2802         <rdar://problem/36379776>
2803
2804         Reviewed by Ryosuke Niwa.
2805
2806         * css/parser/CSSParser.cpp:
2807         (WebCore::CSSParserContext::CSSParserContext):
2808
2809         Don't do the expensive security origin test if the supplied sheet base URL is null. This
2810         is true for rules coming from the same document.
2811
2812 2018-01-18  Antti Koivisto  <antti@apple.com>
2813
2814         REGRESSION (r223604): Setting :before/after pseudo element on <noscript> asserts
2815         https://bugs.webkit.org/show_bug.cgi?id=181795
2816         <rdar://problem/36334524>
2817
2818         Reviewed by David Kilzer.
2819
2820         <noscript> disallows renderer generation outside CSS mechanisms, however we would still construct
2821         PseudoElements for them during style resolution. These were never removed properly because the
2822         pseudo element removal was tied to render tree teardown. Without proper removal the associated
2823         animations were also not canceled.
2824
2825         Test: fast/css-generated-content/noscript-pseudo-anim-crash.html
2826
2827         * dom/Element.cpp:
2828         (WebCore::Element::removedFromAncestor):
2829
2830         Take care to get rid of PseudoElements when the element is removed from the tree.
2831         This also cancels any associated animations.
2832
2833 2018-01-18  Chris Fleizach  <cfleizach@apple.com>
2834
2835         AX: Aria-activedescendant not supported
2836         https://bugs.webkit.org/show_bug.cgi?id=161734
2837         <rdar://problem/28202679>
2838
2839         Reviewed by Joanmarie Diggs.
2840
2841         When a combo-box owns/controls a list/listbox/grid/tree, the owned element needs to check the active-descendant of the combobox when
2842         checking if it has selected children. 
2843         The target of the selection change notification should also be the owned element in these cases.
2844
2845         Test: accessibility/aria-combobox-controlling-list.html
2846
2847         * accessibility/AccessibilityObject.cpp:
2848         (WebCore::AccessibilityObject::selectedListItem):
2849         * accessibility/AccessibilityObject.h:
2850         * accessibility/AccessibilityRenderObject.cpp:
2851         (WebCore::AccessibilityRenderObject::targetElementForActiveDescendant const):
2852         (WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
2853         (WebCore::AccessibilityRenderObject::canHaveSelectedChildren const):
2854         (WebCore::AccessibilityRenderObject::selectedChildren):
2855         * accessibility/AccessibilityRenderObject.h:
2856         * accessibility/mac/AXObjectCacheMac.mm:
2857         (WebCore::AXObjectCache::postPlatformNotification):
2858
2859 2018-01-17  Per Arne Vollan  <pvollan@apple.com>
2860
2861         REGRESSION (r224780): Text stroke not applied to video captions.
2862         https://bugs.webkit.org/show_bug.cgi?id=181743
2863         <rdar://problem/35874338>
2864
2865         Reviewed by Simon Fraser.
2866
2867         Tests: media/track/track-css-visible-stroke-expected.html
2868                media/track/track-css-visible-stroke.html
2869
2870         After r224780, it is no longer possible to mix text stroke styles with webkit
2871         legacy text stroke styles.
2872
2873         * css/StyleResolver.cpp:
2874         (WebCore::isValidCueStyleProperty):
2875         * page/CaptionUserPreferencesMediaAF.cpp:
2876         (WebCore::CaptionUserPreferencesMediaAF::captionsTextEdgeCSS const):
2877
2878 2018-01-18  Andy Estes  <aestes@apple.com>
2879
2880         [Payment Request] Support a default shipping address for Apple Pay
2881         https://bugs.webkit.org/show_bug.cgi?id=181754
2882         <rdar://problem/36009733>
2883
2884         Reviewed by Brady Eidson.
2885
2886         Move shippingContact from ApplePayPaymentRequest to ApplePayRequestBase. This allows
2887         merchants to specify a default shipping address when using Apple Pay with Payment Request.
2888
2889         This also fixes a bug found during testing where
2890         +[NSPersonNameComponentsFormatter localizedStringFromPersonNameComponents:style:options:]
2891         would throw an exception when passed a nil NSPersonNameComponents.
2892
2893         Test: http/tests/ssl/applepay/ApplePayRequestShippingContact.https.html
2894
2895         * Modules/applepay/ApplePayPaymentRequest.h:
2896         * Modules/applepay/ApplePayPaymentRequest.idl:
2897         * Modules/applepay/ApplePayRequestBase.cpp:
2898         (WebCore::convertAndValidate):
2899         * Modules/applepay/ApplePayRequestBase.h:
2900         * Modules/applepay/ApplePayRequestBase.idl:
2901         * Modules/applepay/ApplePaySession.cpp:
2902         (WebCore::convertAndValidate):
2903         * Modules/applepay/ApplePaySessionPaymentRequest.h:
2904         (WebCore::ApplePaySessionPaymentRequest::version const):
2905         (WebCore::ApplePaySessionPaymentRequest::setVersion):
2906         * Modules/applepay/cocoa/PaymentContactCocoa.mm:
2907         (WebCore::convert):
2908         * Modules/applepay/paymentrequest/ApplePayRequest.idl:
2909         * testing/MockPaymentCoordinator.cpp:
2910         (WebCore::MockPaymentCoordinator::showPaymentUI):
2911         (WebCore::MockPaymentCoordinator::completeMerchantValidation):
2912         * testing/MockPaymentCoordinator.h:
2913
2914 2018-01-18  Wenson Hsieh  <wenson_hsieh@apple.com>
2915
2916         [iOS] Specify -[NSURL _title] for the associated URL when copying an image element
2917         https://bugs.webkit.org/show_bug.cgi?id=181783
2918         <rdar://problem/35785445>
2919
2920         Reviewed by Ryosuke Niwa.
2921
2922         Always specify the -[NSURL _title] to be either the title specified in a PasteboardImage's inner PasteboardURL,
2923         or if no title is specified, fall back to the user-visible URL string. This is because at least one internal
2924         client always tries to use the -_title property to determine the title of a pasted URL, or if none is specified,
2925         the -suggestedName. Since we need to set suggestedName to the preferred file name of the copied image and we
2926         don't want the suggested name to become the title of the link, we need to explicitly set the link title.
2927
2928         In doing so, this patch also fixes a bug wherein we forget to set the _title of the NSURL we're registering to
2929         an NSItemProvider.
2930
2931         Tests:  ActionSheetTests.CopyImageElementWithHREFAndTitle (new)
2932                 ActionSheetTests.CopyImageElementWithHREF (modified)
2933
2934         * platform/ios/PlatformPasteboardIOS.mm:
2935         (WebCore::PlatformPasteboard::write):
2936
2937 2018-01-17  Jer Noble  <jer.noble@apple.com>
2938
2939         WebVTT served via HLS never results in cues
2940         https://bugs.webkit.org/show_bug.cgi?id=181773
2941
2942         Reviewed by Eric Carlson.
2943
2944         Test: http/tests/media/hls/hls-webvtt-tracks.html
2945
2946         Three independant errors conspired to keep in-band WebVTT samples from parsing:
2947
2948         - The definition of ISOWebVTTCue::boxTypeName() was incorrect.
2949         - ISOWebVTTCue::parse() didn't call it's superclass's parse() method (leading to an incorrect size and offset).
2950         - Use String::fromUTF8() rather than String.adopt(StringVector&&).
2951
2952         * platform/graphics/iso/ISOVTTCue.cpp:
2953         (WebCore::ISOWebVTTCue::parse):
2954         * platform/graphics/iso/ISOVTTCue.h:
2955         (WebCore::ISOWebVTTCue::boxTypeName):
2956
2957 2018-01-17  John Wilander  <wilander@apple.com>
2958
2959         Resource Load Statistics: Block cookies for prevalent resources without user interaction
2960         https://bugs.webkit.org/show_bug.cgi?id=177394
2961         <rdar://problem/34613960>
2962
2963         Reviewed by Alex Christensen.
2964
2965         Tests: http/tests/resourceLoadStatistics/add-blocking-to-redirect.html
2966                http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html
2967                http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html
2968                http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html
2969
2970         * platform/network/NetworkStorageSession.h:
2971             Now exports NetworkStorageSession::nsCookieStorage().
2972         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
2973         (WebCore::NetworkStorageSession::setPrevalentDomainsToPartitionOrBlockCookies):
2974             Fixes the FIXME.
2975
2976 2018-01-17  Dean Jackson  <dino@apple.com>
2977
2978         Remove linked-on test for Snow Leopard
2979         https://bugs.webkit.org/show_bug.cgi?id=181770
2980
2981         Reviewed by Eric Carlson.
2982
2983         Remove a very old linked-on-or-after test.
2984
2985         * platform/graphics/ca/GraphicsLayerCA.cpp:
2986
2987 2018-01-17  Matt Lewis  <jlewis3@apple.com>
2988
2989         Unreviewed, rolling out r227098.
2990
2991         This broke the build.
2992
2993         Reverted changeset:
2994
2995         "Remove linked-on test for Snow Leopard"
2996         https://bugs.webkit.org/show_bug.cgi?id=181770
2997         https://trac.webkit.org/changeset/227098
2998
2999 2018-01-17  Dean Jackson  <dino@apple.com>
3000
3001         Remove linked-on test for Snow Leopard
3002         https://bugs.webkit.org/show_bug.cgi?id=181770
3003
3004         Reviewed by Eric Carlson.
3005
3006         Remove a very old linked-on-or-after test.
3007
3008         * platform/graphics/ca/GraphicsLayerCA.cpp:
3009
3010 2018-01-17  Stephan Szabo  <stephan.szabo@sony.com>
3011
3012         [Curl] Use ResourceRequest::encodeWithPlatformData()
3013         https://bugs.webkit.org/show_bug.cgi?id=181768
3014
3015         Reviewed by Alex Christensen.
3016
3017         No new tests, assertion hit in downstream port, should be covered by
3018         existing tests.
3019
3020         * platform/network/curl/ResourceRequest.h:
3021         (WebCore::ResourceRequest::encodeWithPlatformData const):
3022         (WebCore::ResourceRequest::decodeWithPlatformData):
3023
3024 2018-01-17  Eric Carlson  <eric.carlson@apple.com>
3025
3026         Use existing RGB colorspace instead of creating a new one
3027         https://bugs.webkit.org/show_bug.cgi?id=181765
3028         <rdar://problem/36595753>
3029
3030         Reviewed by Dean Jackson.
3031
3032         * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
3033         (WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream): Use sRGBColorSpaceRef instead
3034         of creating a new static colorspace.
3035
3036 2018-01-17  Matt Lewis  <jlewis3@apple.com>
3037
3038         Unreviewed, rolling out r227076.
3039
3040         This breaks internal builds
3041
3042         Reverted changeset:
3043
3044         "Resource Load Statistics: Block cookies for prevalent
3045         resources without user interaction"
3046         https://bugs.webkit.org/show_bug.cgi?id=177394
3047         https://trac.webkit.org/changeset/227076
3048
3049 2018-01-17  Ryosuke Niwa  <rniwa@webkit.org>
3050
3051         input and textarea elements should reveal selection in setSelection when focused
3052         https://bugs.webkit.org/show_bug.cgi?id=181715
3053         <rdar://problem/36570546>
3054
3055         Reviewed by Zalan Bujtas.
3056
3057         Made input and textarea elements reveal selection in FrameSelection::setSelection instead of by directly
3058         invoking FrameSelection::revealSelection in their respective updateFocusAppearance to unify code paths.
3059
3060         Also added options to reveal selection up to the main frame to SetSelectionOption to be used in iOS.
3061
3062         * editing/FrameSelection.cpp:
3063         (WebCore::FrameSelection::FrameSelection):
3064         (WebCore::FrameSelection::moveWithoutValidationTo): Takes SelectionRevealMode as an argument and converts
3065         sets appropriate selection options.
3066         (WebCore::FrameSelection::setSelection): Reconstruct SelectionRevealMode out of selection option sets.
3067         (WebCore::FrameSelection::updateAndRevealSelection):
3068         * editing/FrameSelection.h:
3069         (WebCore::FrameSelection): Added RevealSelectionUpToMainFrame as a SelectionRevealMode and replaced
3070         m_shouldRevealSelection by m_selectionRevealMode.
3071         * html/HTMLInputElement.cpp:
3072         (WebCore::HTMLInputElement::updateFocusAppearance): Pass SelectionRevealMode to HTMLTextFormControlElement's
3073         select and restoreCachedSelection instead of directly invoking FrameSelection::revealSelection.
3074         * html/HTMLTextAreaElement.cpp:
3075         (WebCore::HTMLTextAreaElement::updateFocusAppearance): Ditto.
3076         * html/HTMLTextFormControlElement.cpp:
3077         (WebCore::HTMLTextFormControlElement::select):
3078         (WebCore::HTMLTextFormControlElement::setSelectionRange):
3079         (WebCore::HTMLTextFormControlElement::restoreCachedSelection):
3080         * html/HTMLTextFormControlElement.h:
3081
3082 2018-01-17  Michael Catanzaro  <mcatanzaro@igalia.com>
3083
3084         WEBKIT_FRAMEWORK should not modify file-global include directories
3085         https://bugs.webkit.org/show_bug.cgi?id=181656
3086
3087         Reviewed by Konstantin Tokarev.
3088
3089         * CMakeLists.txt:
3090         * PlatformWPE.cmake:
3091
3092 2018-01-17  Michael Catanzaro  <mcatanzaro@igalia.com>
3093
3094         [GTK] Try even harder not to static link WTF into libwebkit2gtk
3095         https://bugs.webkit.org/show_bug.cgi?id=181751
3096
3097         Reviewed by Alex Christensen.
3098
3099         We don't want two copies of WTF. It should only be in libjavascriptcoregtk.
3100
3101         * PlatformGTK.cmake:
3102
3103 2018-01-17  Zalan Bujtas  <zalan@apple.com>
3104
3105         Multicol: RenderMultiColumnFlow should not inherit the flow state
3106         https://bugs.webkit.org/show_bug.cgi?id=181762
3107         <rdar://problem/35448565>
3108
3109         Reviewed by Simon Fraser.
3110
3111         Do not compute the inherited flow state flag for RenderMultiColumnFlow.
3112         It is (by definition) always inside a fragmented flow.
3113
3114         Test: fast/multicol/crash-when-out-of-flow-positioned-becomes-in-flow.html
3115
3116         * rendering/RenderObject.cpp:
3117         (WebCore::RenderObject::computedFragmentedFlowState):
3118
3119 2018-01-17  Alex Christensen  <achristensen@webkit.org>
3120
3121         Deprecate Application Cache
3122         https://bugs.webkit.org/show_bug.cgi?id=181764
3123
3124         Reviewed by Geoffrey Garen.
3125
3126         * features.json:
3127
3128 2018-01-17  Wenson Hsieh  <wenson_hsieh@apple.com>
3129
3130         [iOS simulator] API test WKAttachmentTests.InjectedBundleReplaceURLWhenPastingImage is failing
3131         https://bugs.webkit.org/show_bug.cgi?id=181758
3132
3133         Reviewed by Tim Horton.
3134
3135         This test is failing because Editor::clientReplacementURLForResource expects a MIME type, but on iOS, the type
3136         paramter passed into WebContentReader::readImage is a UTI; subsequently, the bundle editing delegate receives
3137         a MIME type that's actually a UTI, which is incorrect. To address this, ensure that a MIME type is passed to
3138         bundle SPI by converting the type in WebContentReader::readImage to a MIME type.
3139
3140         * editing/cocoa/WebContentReaderCocoa.mm:
3141         (WebCore::WebContentReader::readImage):
3142
3143 2018-01-17  Antti Koivisto  <antti@apple.com>
3144
3145         REGRESSION (r226385?): Crash in com.apple.WebCore: WebCore::MediaQueryEvaluator::evaluate const + 32
3146         https://bugs.webkit.org/show_bug.cgi?id=181742
3147         <rdar://problem/36334726>
3148
3149         Reviewed by David Kilzer.
3150
3151         Test: fast/media/mediaqueryevaluator-crash.html
3152
3153         * css/MediaQueryEvaluator.cpp:
3154         (WebCore::MediaQueryEvaluator::MediaQueryEvaluator):
3155
3156         Use WeakPtr<Document> instead of a plain Frame pointer.
3157
3158         (WebCore::MediaQueryEvaluator::evaluate const):
3159
3160         Get the frame via document.
3161
3162         * css/MediaQueryEvaluator.h:
3163         * dom/Document.cpp:
3164         (WebCore::Document::prepareForDestruction):
3165
3166         Take care to clear style resolver.
3167
3168 2018-01-17  Youenn Fablet  <youenn@apple.com>
3169
3170         Put fetch request keepAlive behind a runtime flag
3171         https://bugs.webkit.org/show_bug.cgi?id=181592
3172
3173         Reviewed by Chris Dumez.
3174
3175         No change of behavior.
3176
3177         * Modules/fetch/FetchRequest.idl:
3178         * page/RuntimeEnabledFeatures.h:
3179         (WebCore::RuntimeEnabledFeatures::fetchAPIKeepAliveEnabled const):
3180         (WebCore::RuntimeEnabledFeatures::setFetchAPIKeepAliveEnabled):
3181
3182 2018-01-17  Per Arne Vollan  <pvollan@apple.com>
3183
3184         [Win] Use switch when converting from ResourceRequestCachePolicy to platform cache policy.
3185         https://bugs.webkit.org/show_bug.cgi?id=181686
3186
3187         Reviewed by Alex Christensen.
3188
3189         No new tests, covered by existing tests.
3190
3191         A switch will make the function easier on the eyes. Also, use the function in places where the ResourceRequestCachePolicy
3192         is just casted to a platform cache policy.
3193
3194         * platform/network/cf/ResourceRequestCFNet.cpp:
3195         (WebCore::toPlatformRequestCachePolicy):
3196
3197 2018-01-17  John Wilander  <wilander@apple.com>
3198
3199         Resource Load Statistics: Block cookies for prevalent resources without user interaction
3200         https://bugs.webkit.org/show_bug.cgi?id=177394
3201         <rdar://problem/34613960>
3202
3203         Reviewed by Alex Christensen.
3204
3205         Tests: http/tests/resourceLoadStatistics/add-blocking-to-redirect.html
3206                http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html
3207                http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html
3208                http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html
3209
3210         * platform/network/NetworkStorageSession.h:
3211             Now exports NetworkStorageSession::nsCookieStorage().
3212         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
3213         (WebCore::NetworkStorageSession::setPrevalentDomainsToPartitionOrBlockCookies):
3214             Fixes the FIXME.
3215
3216 2018-01-17  Daniel Bates  <dabates@apple.com>
3217
3218         REGRESSION (r222795): Cardiogram never signs in
3219         https://bugs.webkit.org/show_bug.cgi?id=181693
3220         <rdar://problem/36286293>
3221
3222         Reviewed by Ryosuke Niwa.
3223
3224         Exempt Cardiogram from the XHR header restrictions in r222795.
3225
3226         Following r222795 only Dashboard widgets are allowed to set arbitrary XHR headers.
3227         However Cardiogram also depends on such functionality.
3228
3229         Test: fast/xmlhttprequest/set-dangerous-headers-from-file-when-setting-enabled.html
3230
3231         * page/Settings.yaml:
3232         * platform/RuntimeApplicationChecks.h:
3233         * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
3234         (WebCore::IOSApplication::isCardiogram):
3235         * xml/XMLHttpRequest.cpp:
3236         (WebCore::XMLHttpRequest::setRequestHeader):
3237
3238 2018-01-17  Daniel Bates  <dabates@apple.com>
3239
3240         ASSERTION FAILED: !m_completionHandler in PingHandle::~PingHandle()
3241         https://bugs.webkit.org/show_bug.cgi?id=181746
3242         <rdar://problem/36586248>
3243
3244         Reviewed by Chris Dumez.
3245
3246         Call PingHandle::pingLoadComplete() with an error when NSURLConnection queries
3247         whether the ping is able to respond to an authentication request. (Pings do not
3248         respond to authenticate requests.) It will call the completion handler, nullify
3249         the completion handler, and deallocate the PingHandle. Nullifying the completion
3250         handler is necessary to avoid the assertion failure in ~PingHandle().
3251
3252         Test: http/tests/misc/before-unload-load-image.html
3253
3254         * platform/network/PingHandle.h:
3255
3256 2018-01-17  Daniel Bates  <dabates@apple.com>
3257
3258         WebCoreResourceHandleAsOperationQueueDelegate/ResourceHandleCFURLConnectionDelegateWithOperationQueue may
3259         be deleted in main thread callback
3260         https://bugs.webkit.org/show_bug.cgi?id=181747
3261         <rdar://problem/36588120>
3262
3263         Reviewed by Alex Christensen.
3264
3265         Retain the delegate (e.g. WebCoreResourceHandleAsOperationQueueDelegate) before scheduling
3266         a main thread callback and blocking on a semaphore for its reply because the main thread
3267         callback can do anything, including deleting the delegate, before the non-main thread
3268         has a chance to execute. For instance, a PingHandle will delete itself (and hence delete
3269         its resource handle delegate) in most of the code paths invoked by the delegate.
3270
3271         * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
3272         (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::willSendRequest):
3273         (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveResponse):
3274         (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse):
3275         (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::canRespondToProtectionSpace):
3276         * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
3277         (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]):
3278         (-[WebCoreResourceHandleAsOperationQueueDelegate connection:canAuthenticateAgainstProtectionSpace:]):
3279         (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]):
3280         (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willCacheResponse:]):
3281
3282 2018-01-17  Chris Dumez  <cdumez@apple.com>
3283
3284         'fetch' event may be sent to a service worker before its state is set to 'activated'
3285         https://bugs.webkit.org/show_bug.cgi?id=181698
3286         <rdar://problem/36554856>
3287
3288         Reviewed by Youenn Fablet.
3289
3290         'fetch' event may be sent to a service worker before its state is set to 'activated'.
3291         When the registration's active worker needs to intercept a load, and its state is 'activating',
3292         we queue the request to send the fetch event in SWServerWorker::m_whenActivatedHandlers.
3293         Once the SWServerWorker::setState() is called with 'activated' state, we then call the
3294         handlers in m_whenActivatedHandlers to make send the fetch event now that the worker is
3295         activated. The issue is that even though the worker is activated and its state was set to
3296         'activated' on Storage process side, we had not yet notified the ServiceWorker process
3297         of the service worker's new state yet.
3298
3299         To address the issue, we now make sure that SWServerWorker::m_whenActivatedHandlers are
3300         called *after* we've sent the IPC to the ServiceWorker process to update the worker's
3301         state to 'activated'. Also, we now call ServiceWorkerFetch::dispatchFetchEvent()
3302         asynchronously in a postTask() as the service worker's state is also updated asynchronously
3303         in a postTask. This is as per specification [1], which says to "queue a task" to fire
3304         the fetch event.
3305
3306         [1] https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm (step 18)
3307
3308         No new tests, covered by imported/w3c/web-platform-tests/service-workers/service-worker/fetch-waits-for-activate.https.html
3309         which hits the new assertion without the fix.
3310
3311         * workers/service/context/ServiceWorkerFetch.cpp:
3312         (WebCore::ServiceWorkerFetch::dispatchFetchEvent):
3313         Add assertions to make sure that we dispatch the fetch event on the right worker and
3314         that the worker is in 'activated' state.
3315
3316         * workers/service/context/ServiceWorkerThread.cpp:
3317         (WebCore::ServiceWorkerThread::postFetchTask):
3318         Queue a task to fire the fetch event as per:
3319         - https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm (step 18)
3320         We need to match the specification exactly here or things will happen in the wrong
3321         order. In particular, things like "update registration state" and "update worker state"
3322         might happen *after* firing the fetch event, even though the IPC for "update registration/worker
3323         state" was sent before the "fire fetch event" one, because the code for updating a registration/
3324         worker state already queues a task, as per the specification.
3325
3326         * workers/service/server/SWServerRegistration.cpp:
3327         (WebCore::SWServerRegistration::updateWorkerState):
3328         * workers/service/server/SWServerRegistration.h:
3329         * workers/service/server/SWServerWorker.cpp:
3330         (WebCore::SWServerWorker::setState):
3331         Move code to send the IPC to the Service Worker process whenever the service worker's state
3332         needs to be updated from SWServerRegistration::updateWorkerState() to SWServerWorker::setState().
3333         This way, we can make sure the IPC is sent *before* we call the m_whenActivatedHandlers handlers,
3334         as they may also send IPC to the Service Worker process, and we need to make sure this IPC happens
3335         after so that the service worker is in the right state.
3336
3337 2018-01-17  Stephan Szabo  <stephan.szabo@sony.com>
3338
3339         Page.cpp only sees forward declaration of ApplicationStateChangeListener when ENABLE(VIDEO) is off
3340         https://bugs.webkit.org/show_bug.cgi?id=181713
3341
3342         Reviewed by Darin Adler.
3343
3344         No new tests (build fix).
3345
3346         * page/Page.cpp: Add include for ApplicationStateChangeListener
3347
3348 2018-01-17  Wenson Hsieh  <wenson_hsieh@apple.com>
3349
3350         Add injected bundle SPI to replace subresource URLs when dropping or pasting rich content
3351         https://bugs.webkit.org/show_bug.cgi?id=181637
3352         <rdar://problem/36508471>
3353
3354         Reviewed by Tim Horton.
3355
3356         Before carrying out blob URL conversion for pasted or dropped rich content, let the editor client replace
3357         subresource URLs in WebKit2 by calling out to new injected bundle SPI. See comments below for more detail.
3358
3359         Tests:  WKAttachmentTests.InjectedBundleReplaceURLsWhenPastingAttributedString
3360                 WKAttachmentTests.InjectedBundleReplaceURLWhenPastingImage
3361
3362         * editing/Editor.cpp:
3363         (WebCore::Editor::clientReplacementURLForResource):
3364         * editing/Editor.h:
3365
3366         Add a new helper to call out to the editor client for a URL string to replace a given ArchiveResource. In
3367         WebKit2, this calls out to the injected bundle's new `replacementURLForResource` SPI hook.
3368
3369         * editing/cocoa/WebContentReaderCocoa.mm:
3370         (WebCore::shouldReplaceSubresourceURL):
3371         (WebCore::replaceRichContentWithAttachments):
3372         (WebCore::replaceSubresourceURLsWithURLsFromClient):
3373
3374         Add a new static helper to replace subresource URLs in the given DocumentFragment with URLs supplied by the
3375         editor client. Additionally builds a list of ArchiveResources that have not been replaced, for use at call sites
3376         so that we don't unnecessarily create more Blobs for ArchiveResources that have already been replaced.
3377
3378         (WebCore::createFragmentAndAddResources):
3379         (WebCore::sanitizeMarkupWithArchive):
3380
3381         Tweak web content reading codepaths to first replace subresource URLs with editor-client-supplied URLs.