Use WTF Locking primitives in WebThread and drop pthread_xxx use
[WebKit.git] / Source / WebCore / ChangeLog
1 2017-12-07  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3         Use WTF Locking primitives in WebThread and drop pthread_xxx use
4         https://bugs.webkit.org/show_bug.cgi?id=180445
5
6         Reviewed by Saam Barati.
7
8         We remove use of pthread locking primitives from WebThread implementation,
9         and use WTF Lock and Condition instead.
10
11         No behavior change.
12
13         * platform/ios/wak/WebCoreThread.mm:
14         (HandleDelegateSource):
15         (SendDelegateMessage):
16         (WebThreadRunOnMainThread):
17         (WebThreadAdoptAndRelease):
18         (WebCoreObjCDeallocOnWebThreadImpl):
19         (WebCoreObjCDeallocWithWebThreadLockImpl):
20         (HandleWebThreadReleaseSource):
21         (_WebThreadAutoLock):
22         (WebRunLoopLockInternal):
23         (CurrentThreadContext):
24         Use WTF::ThreadSpecific.
25
26         (StartWebThread):
27         (_WebThreadLock):
28         Remove `shouldTry` parameter since it is always `false`. We clean up code based on `shouldTry = false`,
29         and rename it from _WebTryThreadLock to _WebThreadLock since it does not try now.
30
31         (_WebThreadLockFromAnyThread):
32         (WebThreadUnlockFromAnyThread):
33         (_WebThreadUnlock):
34         (lockWebCoreReleaseLock): Deleted.
35         (unlockWebCoreReleaseLock): Deleted.
36         (WebTimedConditionLock): Deleted.
37         (_WebTryThreadLock): Deleted.
38
39 2017-12-07  Alex Christensen  <achristensen@webkit.org>
40
41         Fix API test after r225645.
42         https://bugs.webkit.org/show_bug.cgi?id=180544
43
44         * loader/FrameLoader.cpp:
45         (WebCore::FrameLoader::loadURL):
46         (WebCore::FrameLoader::loadWithDocumentLoader):
47         The API test WebKitLegacy.FragmentNavigation started failing after r225645.
48         It does call the completion handler with ignore to cancel fragment navigation.
49         To make this work and increase compatibility, only synchronously continue with
50         fragment navigations if we haven't received a synchronous answer to the
51         decidePolicyForNavigationAction callback.
52
53 2017-12-07  Oleksandr Skachkov  <gskachkov@gmail.com>
54
55         WebAssembly: sending module to iframe fails
56         https://bugs.webkit.org/show_bug.cgi?id=179263
57
58         Reviewed by JF Bastien.
59
60         Allow use WebAssembly.Module as input parameters for postMessage 
61         in window and iframe object.
62
63         Tests: wasm/iframe-postmessage.html
64                wasm/window-postmessage.html
65
66         * bindings/js/SerializedScriptValue.cpp:
67         (WebCore::CloneSerializer::dumpIfTerminal):
68         * bindings/js/SerializedScriptValue.h:
69         * page/DOMWindow.cpp:
70         (WebCore::DOMWindow::postMessage):
71
72 2017-12-07  Joseph Pecoraro  <pecoraro@apple.com>
73
74         Web Inspector: Fix style in remote inspector classes
75         https://bugs.webkit.org/show_bug.cgi?id=180545
76
77         Reviewed by Youenn Fablet.
78
79         * page/PageDebuggable.h:
80         * workers/service/context/ServiceWorkerDebuggable.h:
81
82 2017-12-07  Antti Koivisto  <antti@apple.com>
83
84         Move security origin filtering for getMatchedCSSRules out of StyleResolver
85         https://bugs.webkit.org/show_bug.cgi?id=180468
86
87         Reviewed by Zalan Bujtas.
88
89         The non-standard getMatchedCSSRules API should not return rules from stylesheets in different security origins.
90         To implement this we currently have lots of invasive code in StyleResolver, RuleSets and ElementRuleCollector
91         basically passing around a bit. This also makes RuleSets document specific blocking optimizations.
92
93         This patches replaces the mechanism with a bit in StyleRule which is much simpler.
94
95         * css/DocumentRuleSets.cpp:
96         (WebCore::makeRuleSet):
97         * css/ElementRuleCollector.cpp:
98         (WebCore::ElementRuleCollector::collectMatchingRulesForList):
99         * css/ElementRuleCollector.h:
100         (WebCore::ElementRuleCollector::setPseudoStyleRequest):
101         (WebCore::ElementRuleCollector::setSameOriginOnly): Deleted.
102         * css/RuleFeature.cpp:
103         (WebCore::RuleFeatureSet::collectFeatures):
104         * css/RuleFeature.h:
105         (WebCore::RuleFeature::RuleFeature):
106         * css/RuleSet.cpp:
107         (WebCore::RuleData::RuleData):
108         (WebCore::RuleSet::addRule):
109         (WebCore::RuleSet::addChildRules):
110         (WebCore::RuleSet::addRulesFromSheet):
111         (WebCore::RuleSet::addStyleRule):
112         * css/RuleSet.h:
113         (WebCore::RuleData::linkMatchType const):
114         (WebCore::RuleData::hasDocumentSecurityOrigin const): Deleted.
115         * css/StyleResolver.cpp:
116         (WebCore::StyleResolver::pseudoStyleRulesForElement):
117         * css/StyleResolver.h:
118         * css/StyleRule.cpp:
119         (WebCore::StyleRule::StyleRule):
120         (WebCore::StyleRule::createForSplitting):
121         (WebCore::StyleRule::splitIntoMultipleRulesWithMaximumSelectorComponentCount const):
122         (WebCore::StyleRule::create): Deleted.
123         * css/StyleRule.h:
124         (WebCore::StyleRuleBase::StyleRuleBase):
125         (WebCore::StyleRuleBase::hasDocumentSecurityOrigin const):
126
127             Add a bit.
128
129         * css/parser/CSSParser.cpp:
130         (WebCore::CSSParserContext::CSSParserContext):
131
132             Include hasDocumentSecurityOrigin bit to parser context. This means that a stylesheet data structures
133             can't be shared between a contexts where this differs. This likely very rare in practice.
134
135         (WebCore::operator==):
136         * css/parser/CSSParserImpl.cpp:
137         (WebCore::CSSParserImpl::consumeStyleRule):
138         * css/parser/CSSParserMode.h:
139         (WebCore::CSSParserContextHash::hash):
140         * editing/EditingStyle.cpp:
141         (WebCore::EditingStyle::mergeStyleFromRules):
142         * page/DOMWindow.cpp:
143         (WebCore::DOMWindow::getMatchedCSSRules const):
144
145             Filter out rules from different security origin after getting them from style resolver.
146
147 2017-12-07  Zalan Bujtas  <zalan@apple.com>
148
149         AX: Document::existingAXObjectCache() should always return the existing AXObjectCache.
150         https://bugs.webkit.org/show_bug.cgi?id=180548
151         <rdar://problem/35917755>
152
153         Reviewed by Chris Fleizach.
154
155         Currently the AX cache becomes unreachable through Document::existingAXObjectCache soon after the render tree is destroyed.
156         From this point, the Node objects can't deregister themselves from the AX cache anymore. In some cases, it's
157         redundant/not advised to notify the cache about certain changes when the document is being destroyed, but the
158         callsites should make that decision.
159
160         Covered by existing tests.
161
162         * dom/Document.cpp:
163         (WebCore::Document::existingAXObjectCacheSlow const):
164         * rendering/RenderElement.cpp:
165         (WebCore::RenderElement::takeChildInternal):
166
167 2017-12-07  Youenn Fablet  <youenn@apple.com>
168
169         Fix erroneous ASSERT in DocumentThreadableLoader::didFail
170         https://bugs.webkit.org/show_bug.cgi?id=180549
171
172         Reviewed by Alex Christensen.
173
174         * loader/DocumentThreadableLoader.cpp:
175         (WebCore::DocumentThreadableLoader::didFail): ASSERT was checking whether the optional was null.
176         This could never be the case since we move the value of the optional, not the optional itself.
177         Ensure that the optional value is null so that we are sure request is being loaded and make the optional null just after that.
178
179 2017-12-07  Ryosuke Niwa  <rniwa@webkit.org>
180
181         iOS: Many AMP pages crash inside Document::updateStyleIfNeeded
182         https://bugs.webkit.org/show_bug.cgi?id=180550
183         <rdar://problem/35410390>
184
185         Reviewed by Zalan Bujtas.
186
187         The crash was caused when updatign the layout of an non-flattened frame inside a flattened frame.
188         In those cases, isInChildFrameWithFrameFlattening is false on the inner frame.
189
190         No new tests for now.
191
192         * dom/NoEventDispatchAssertion.h:
193         * rendering/RenderFrameBase.cpp:
194         (WebCore::RenderFrameBase::performLayoutWithFlattening): Disable the assertion temporarily here.
195         In theory, we should be able to remove the check for isInChildFrameWithFrameFlattening but we err
196         on the safer side for now.
197
198 2017-12-07  Alex Christensen  <achristensen@webkit.org>
199
200         Always synchronously continue with fragment navigations
201         https://bugs.webkit.org/show_bug.cgi?id=180544
202         <rdar://problem/34815986> and <rdar://problem/35126690>
203
204         Reviewed by Geoffrey Garen.
205
206         Test: http/tests/dom/document-fragment.html
207
208         When a decidePolicyForNavigationAction completionHandler is called asynchronously,
209         the document's URL has not changed yet when JavaScript execution continues.  This causes
210         significant web incompatibility because all browsers change the document's URL immediately
211         during fragment navigations.  In order to make WebKit applications more web compatible,
212         we now immediately continue to have the state consistent.  To keep compatibility with any
213         WebView, UIWebView, or WKWebView applications that use these delegate callbacks to update
214         state, we still call decidePolicyForNavigationAction.  This would break a theoretical app
215         that would cancel fragment navigations, but it fixes apps that continue fragment navigations
216         asynchronously.
217
218         * loader/FrameLoader.cpp:
219         (WebCore::FrameLoader::loadURL):
220         (WebCore::FrameLoader::loadWithDocumentLoader):
221
222 2017-12-07  Youenn Fablet  <youenn@apple.com>
223
224         Activate IDB and WebSockets in service workers
225         https://bugs.webkit.org/show_bug.cgi?id=180534
226
227         Reviewed by Brady Eidson.
228
229         Tests: http/tests/workers/service/serviceworker-idb.https.html
230                http/tests/workers/service/serviceworker-websocket.https.html
231
232         Using the dummy document used for loading to also fuel IDB and WebSocket.
233
234         * workers/service/context/ServiceWorkerThread.cpp:
235         (WebCore::ServiceWorkerThread::ServiceWorkerThread):
236         * workers/service/context/ServiceWorkerThread.h:
237         * workers/service/context/ServiceWorkerThreadProxy.cpp:
238         (WebCore::idbConnectionProxy):
239         (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
240
241 2017-12-07  Matt Lewis  <jlewis3@apple.com>
242
243         Unreviewed, rolling out r225634.
244
245         This caused layout tests to time out.
246
247         Reverted changeset:
248
249         "Simplify log channel configuration UI"
250         https://bugs.webkit.org/show_bug.cgi?id=180527
251         https://trac.webkit.org/changeset/225634
252
253 2017-12-07  Jer Noble  <jer.noble@apple.com>
254
255         [EME] Support the 'encrypted' event for FPS encrypted streams
256         https://bugs.webkit.org/show_bug.cgi?id=180480
257
258         Reviewed by Eric Carlson.
259
260         Test: platform/mac/media/encrypted-media/fps-encrypted-event.html
261
262         Pass initData and initDataType up to HTMLMediaElement from SourceBufferPrivateAVFObjC.
263
264         Drive-by fix: initialize the initData and initDataType values of MediaEncryptedEvent from
265         values in its initializer struct.
266
267         * html/HTMLMediaElement.cpp:
268         (WebCore::HTMLMediaElement::mediaPlayerKeyNeeded):
269         (WebCore::HTMLMediaElement::mediaPlayerInitializationDataEncountered):
270         * html/MediaEncryptedEvent.cpp:
271         (WebCore::MediaEncryptedEvent::MediaEncryptedEvent):
272         (WebCore::MediaEncryptedEvent::initDataType): Deleted.
273         (WebCore::MediaEncryptedEvent::initData): Deleted.
274         * html/MediaEncryptedEvent.h:
275         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
276         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
277         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmInstanceAttached):
278         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
279         (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID):
280
281 2017-12-07  Myles C. Maxfield  <mmaxfield@apple.com>
282
283         [Cocoa] Add SPI to disallow user-installed fonts
284         https://bugs.webkit.org/show_bug.cgi?id=180062
285         <rdar://problem/35042408>
286
287         Reviewed by Simon Fraser.
288
289         This hooks up a WK2 preference, ShouldDisallowUserInstalledFonts, to our font selection
290         code. This preference works by specifying an attribute to our font selection code which
291         will prohibit user-installed fonts from ever being selected. This works both to disallow
292         newly installed fonts, as well as disallowing user-installed fonts which "shadow" (or
293         have the same name as) existing fonts, so that the existing font is selected instead.
294
295         The goal of this setting is to decrease the fingerprinting surface area which trackers
296         can use to identify users on the open Web.
297
298         Tests: fast/text/user-installed-font.html
299                fast/text/user-installed-fonts/disable.html
300                fast/text/user-installed-fonts/shadow-disable.html
301                fast/text/user-installed-fonts/shadow-family-disable.html
302                fast/text/user-installed-fonts/shadow-family.html
303                fast/text/user-installed-fonts/shadow-postscript-disable.html
304                fast/text/user-installed-fonts/shadow-postscript-family-disable.html
305                fast/text/user-installed-fonts/shadow-postscript-family.html
306                fast/text/user-installed-fonts/shadow-postscript.html
307                fast/text/user-installed-fonts/shadow.html
308
309         * css/CSSFontFaceSet.cpp:
310         (WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):
311         * css/StyleResolver.cpp:
312         (WebCore::StyleResolver::initializeFontStyle):
313         * page/Settings.yaml:
314         * platform/graphics/FontCache.h:
315         * platform/graphics/FontDescription.cpp:
316         (WebCore::FontDescription::FontDescription):
317         * platform/graphics/FontDescription.h:
318         (WebCore::FontDescription::mayRepresentUserInstalledFont const):
319         (WebCore::FontDescription::setMayRepresentUserInstalledFont):
320         (WebCore::FontDescription::operator== const):
321         * platform/graphics/cocoa/FontCacheCoreText.cpp:
322         (WebCore::FontDatabase::singleton):
323         (WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
324         (WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
325         (WebCore::FontDatabase::collectionForFamily):
326         (WebCore::FontDatabase::fontForPostScriptName):
327         (WebCore::FontDatabase::FontDatabase):
328         (WebCore::FontCache::getFontSelectionCapabilitiesInFamily):
329         (WebCore::platformFontLookupWithFamily):
330         (WebCore::invalidateFontCache):
331         (WebCore::fontWithFamily):
332         * style/StyleResolveForDocument.cpp:
333         (WebCore::Style::resolveForDocument):
334         * testing/InternalSettings.cpp:
335         (WebCore::InternalSettings::setShouldDisallowUserInstalledFonts):
336         * testing/InternalSettings.h:
337         * testing/InternalSettings.idl:
338
339 2017-12-07  David Quesada  <david_quesada@apple.com>
340
341         [Web App Manifest] Support display-mode media feature
342         https://bugs.webkit.org/show_bug.cgi?id=180376
343         rdar://problem/35837993
344
345         Reviewed by Geoffrey Garen.
346
347         Tests: applicationmanifest/display-mode-subframe.html
348                applicationmanifest/display-mode.html
349
350         * Modules/applicationmanifest/ApplicationManifest.h:
351         (WebCore::ApplicationManifest::encode const):
352         (WebCore::ApplicationManifest::decode):
353         * Modules/applicationmanifest/ApplicationManifestParser.cpp:
354         (WebCore::ApplicationManifestParser::parseManifest):
355         (WebCore::ApplicationManifestParser::parseDisplay):
356         * Modules/applicationmanifest/ApplicationManifestParser.h:
357             Add a 'display' property to ApplicationManifest and have ApplicationManifestParser
358             populate it by parsing the 'display' property from the raw manifest.
359
360         * css/CSSValueKeywords.in:
361         * css/MediaFeatureNames.h:
362         * css/MediaQueryEvaluator.cpp:
363         (WebCore::displayModeEvaluate):
364             To evaluate whether a display-mode query matches, compare the parameter to the
365             display mode of the manifest applied to the main frame. If there is no manifest,
366             use the fallback display mode 'browser' - the spec mandates that display-mode
367             must be exposed even if there is no applied manifest.
368         * css/MediaQueryExpression.cpp:
369         (WebCore::featureWithValidIdent):
370         (WebCore::isFeatureValidWithoutValue):
371
372 2017-12-07  Jer Noble  <jer.noble@apple.com>
373
374         Creating a second AVPlayerItemVideoOutput causes flakey failures
375         https://bugs.webkit.org/show_bug.cgi?id=177119
376         <rdar://problem/34507977>
377
378         Reviewed by Dean Jackson.
379
380         Rather than having two concurrent AVPlayerItemVideoOutputs when painting to OpenGL,
381         use only one, but with the OpenGL compatibility flags enabled, for both 3D and 2D
382         canvas painting.
383
384         Of course, once this is fixed, the test breaks again because VideoTextureCopierCV is
385         stomping on top of some WebGL state set by the test. Rather than expand the
386         VideoTextureCopierCV's GraphicsStateSaver, use a totally separate (but shared) GL context to
387         implement the texture copy, so that its own state will not affect the state of the WebGL
388         context.
389
390         This necessitates adding a new createShared() factory for GraphicsContext3D. Since this is only
391         used on Cocoa platforms (for now), make it platform specific, and modify the other implementations
392         only so far as to throw assertions if somehow a shared context pointer is passed into their
393         constructors.
394
395         Drive-by fixes: 
396
397         - These changes exposed some test failures, which were off-by-1-or-2 errors in the color
398         output of videos painted into WebGL contexts. The Y' parameter needs to be scaled by 16/255
399         for video-range conversions and the CbCr vales by 128/255 (rather than just 0.5). Make the
400         color transforms a full 4x4 matrix and do the scaling in the matrix rather than tracked by a
401         separate uniform.
402
403         - There was a slight error in WebCoreDecompressionSession that could cause seeks to never
404         complete because incoming frames would be skipped if their startTime was in the past
405         (rather than their startTime + duration being in the past).
406
407         - The matrix name comparison should use CFEqual rather than pointer equality to test.
408
409         - iOS currently has a bug where the red and green color channels will be reversed when
410         uploading BGRA pixel formatted data to a texture; work around this bug for now.
411
412         * platform/graphics/GraphicsContext3D.h:
413         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
414         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
415         (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyContextVideoRenderer):
416         (WebCore::MediaPlayerPrivateAVFoundationObjC::hasAvailableVideoFrame const):
417         (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastPixelBuffer):
418         (WebCore::MediaPlayerPrivateAVFoundationObjC::videoOutputHasAvailableFrame):
419         (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
420         (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput):
421         (WebCore::MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture):
422         (WebCore::MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime):
423         (WebCore::MediaPlayerPrivateAVFoundationObjC::waitForVideoOutputMediaDataWillChange):
424         * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
425         (WebCore::GraphicsContext3D::GraphicsContext3D):
426         * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
427         (WebCore::GraphicsContext3D::createShared):
428         (WebCore::GraphicsContext3D::GraphicsContext3D):
429         * platform/graphics/cv/VideoTextureCopierCV.cpp:
430         (WebCore::VideoTextureCopierCV::VideoTextureCopierCV):
431         (WebCore::VideoTextureCopierCV::~VideoTextureCopierCV):
432         (WebCore::transferFunctionFromString):
433         (WebCore::YCbCrToRGBMatrixForRangeAndTransferFunction):
434         (WebCore::VideoTextureCopierCV::initializeUVContextObjects):
435         (WebCore::VideoTextureCopierCV::copyImageToPlatformTexture):
436         (WebCore::VideoTextureCopierCV::copyVideoTextureToPlatformTexture):
437         * platform/graphics/cv/VideoTextureCopierCV.h:
438         (WebCore::VideoTextureCopierCV::context):
439         * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
440         (WebCore::GraphicsContext3D::GraphicsContext3D):
441
442 2017-12-07  Jer Noble  <jer.noble@apple.com>
443
444         [EME] Support generateRequest() in CDMFairPlayStreaming
445         https://bugs.webkit.org/show_bug.cgi?id=179752
446
447         Reviewed by Eric Carlson.
448
449         Tests: platform/mac/media/encrypted-media/fps-createSession.html
450                platform/mac/media/encrypted-media/fps-generateRequest.html
451
452         Add support for generating license requests from initialization data in
453         CDMFairPlayStreaming. To do so, add explicit checks for FairPlay Steraming requirements:
454         reqests will fail if no server certificate exists, and will fail if no content key id exists
455         in the initialization data.
456
457         * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
458         (WebCore::CDMPrivateFairPlayStreaming::extractKeyIDsSinf):
459         (WebCore::CDMPrivateFairPlayStreaming::sanitizeSinf):
460         (WebCore::CDMFactory::platformRegisterFactories):
461         * platform/graphics/avfoundation/CDMFairPlayStreaming.h:
462         * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
463         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::requestLicense):
464         (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest):
465
466 2017-12-07  Jer Noble  <jer.noble@apple.com>
467
468         [EME] Possible deadlock when aborting a SourceBufferPrivateAVFObjC append operation
469         https://bugs.webkit.org/show_bug.cgi?id=180486
470
471         Reviewed by Eric Carlson.
472
473         It's possible that an abort() operation which is blocked on the ongoing appendBuffer()
474         operation completing will deadlock forever, with either the willProvideContentKeyRequest
475         or didProvideContentKeyRequest callbacks blocking waiting to be run on the main thread
476         (which is itself blocked waiting for the append operation to complete).
477
478         To break this deadlock, add a new abortSemaphore which is signaled in the abort() method
479         and have the willProvide... and didProvide... methods block both on their own semaphores
480         as well as the abortSemaphore, allowing them to break out even if their main thread calls
481         never get a chance to execute.
482
483         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
484         (-[WebAVStreamDataParserListener streamDataParserWillProvideContentKeyRequestInitializationData:forTrackID:]):
485         (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]):
486         (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
487         (WebCore::SourceBufferPrivateAVFObjC::abort):
488
489 2017-12-07  Eric Carlson  <eric.carlson@apple.com>
490
491         Simplify log channel configuration UI
492         https://bugs.webkit.org/show_bug.cgi?id=180527
493         <rdar://problem/35908382>
494
495         Reviewed by Joseph Pecoraro.
496
497         No new tests -- no change in functionality.
498
499         * inspector/agents/WebConsoleAgent.cpp:
500         (WebCore::WebConsoleAgent::getLoggingChannels):
501         (WebCore::channelConfigurationForString):
502
503 2017-12-07  Joseph Pecoraro  <pecoraro@apple.com>
504
505         ServiceWorker Inspector: Use the SW's scope url for the remote inspection target metadata
506         https://bugs.webkit.org/show_bug.cgi?id=180519
507
508         Reviewed by Youenn Fablet.
509
510         * workers/service/context/ServiceWorkerDebuggable.cpp:
511         (WebCore::ServiceWorkerDebuggable::ServiceWorkerDebuggable):
512         * workers/service/context/ServiceWorkerDebuggable.h:
513         Switch to the scope URL for the remote inspector target info.
514
515 2017-12-07  Per Arne Vollan  <pvollan@apple.com>
516
517         Unreviewed Windows build fix.
518
519         * PlatformWin.cmake:
520
521 2017-12-07  Michael Catanzaro  <mcatanzaro@igalia.com>
522
523         [WPE][GTK] Freeze WebKit version in user agent
524         https://bugs.webkit.org/show_bug.cgi?id=180475
525
526         Reviewed by Carlos Garcia Campos.
527
528         Apple has frozen the WebKit version in its user agent, so we should too, at the same point.
529
530         * platform/glib/UserAgentGLib.cpp:
531         (WebCore::versionForUAString):
532
533 2017-12-07  Michael Catanzaro  <mcatanzaro@igalia.com>
534
535         [WPE][GTK] Update user agent quirk version strings
536         https://bugs.webkit.org/show_bug.cgi?id=180474
537
538         Reviewed by Carlos Garcia Campos.
539
540         * platform/UserAgentQuirks.cpp:
541         (WebCore::UserAgentQuirks::stringForQuirk):
542         * platform/glib/UserAgentGLib.cpp:
543         (WebCore::platformVersionForUAString):
544
545 2017-12-06  Chris Dumez  <cdumez@apple.com>
546
547         We should be able to recover after a Service Worker process crash
548         https://bugs.webkit.org/show_bug.cgi?id=180477
549
550         Reviewed by Brady Eidson and Youenn Fablet.
551
552         Test: http/tests/workers/service/postmessage-after-sw-process-crash.https.html
553
554         * workers/service/server/SWServer.cpp:
555         (WebCore::SWServer::serverToContextConnectionCreated):
556         Once the connection with the context process is established, process "run service worker"
557         requests that ocurred while establishing the connection.
558
559         (WebCore::SWServer::runServiceWorkerIfNecessary):
560         Take in a lambda function that gets called after the "run service worker" request
561         is processed. We used to assert that we had a connection to the context process.
562         We now wait for the connection to be established to process the request, thus
563         making the operation asynchronous.
564
565         (WebCore::SWServer::runServiceWorker):
566         Split some logic out of runServiceWorkerIfNecessary() to reuse in serverToContextConnectionCreated().
567
568         (WebCore::SWServer::markAllWorkersAsTerminated):
569         Add method to mark all service workers as terminated. This is called when the Service
570         Worker process crashes.
571
572         * workers/service/server/SWServer.h:
573
574 2017-12-06  Saam Barati  <sbarati@apple.com>
575
576         Unreviewed. Fix iOS (and maybe other platform) build
577
578         * workers/service/server/RegistrationDatabase.cpp:
579         (WebCore::RegistrationDatabase::openSQLiteDatabase):
580
581 2017-12-02  Darin Adler  <darin@apple.com>
582
583         Modernize some aspects of text codecs, eliminate WebKit use of strcasecmp
584         https://bugs.webkit.org/show_bug.cgi?id=180009
585
586         Reviewed by Alex Christensen.
587
588         * Modules/fetch/FetchBody.cpp:
589         (WebCore::FetchBody::consumeAsStream): Update to use size since the result of
590         encode is now Vector rather than CString. And for the new UnencodableHandling.
591         (WebCore::FetchBody::consumeText): Removed now-unneeded type cast. Ditto.
592         (WebCore::FetchBody::bodyAsFormData const): Ditto.
593         (WebCore::FetchBody::take): Pass result of encode directly to SharedBuffer::create.
594
595         * Modules/websockets/WebSocketDeflater.cpp: Removed include of StringExtras.h.
596         * bridge/IdentifierRep.h: Ditto.
597         * bridge/c/c_instance.cpp: Ditto.
598
599         * fileapi/BlobBuilder.cpp:
600         (WebCore::BlobBuilder::append): Updated for CString to Vector change and
601         for UnencodableHandling.
602
603         * html/parser/HTMLMetaCharsetParser.cpp:
604         (WebCore::HTMLMetaCharsetParser::checkForMetaCharset): Call the decode function
605         with all the arguments since there is only one decode function now.
606
607         * inspector/agents/InspectorDOMAgent.cpp:
608         (WebCore::computeContentSecurityPolicySHA256Hash): Updated for CString to Vector
609         change and for UnencodableHandling.
610
611         * loader/ResourceCryptographicDigest.cpp:
612         (WebCore::cryptographicDigestForBytes): Changed argument type to const void*.
613         * loader/ResourceCryptographicDigest.h: Ditto.
614
615         * loader/TextResourceDecoder.cpp:
616         (WebCore::TextResourceDecoder::TextResourceDecoder): Moved initialization of data
617         members to class definition.
618         (WebCore::TextResourceDecoder::create): Moved function body here from the header.
619         (WebCore::TextResourceDecoder::setEncoding): Use equalLettersIgnoringASCIICase.
620         (WebCore::TextResourceDecoder::shouldAutoDetect const): Updated for name change
621         to m_parentFrameAutoDetectedEncoding, which obviates a comment.
622         (WebCore::TextResourceDecoder::flush): Ditto.
623         * loader/TextResourceDecoder.h: Moved initialization here from constructor.
624         Moved function bodies out of the class. Renamed m_hintEncoding to
625         m_parentFrameAutoDetectedEncoding since that is a more accurate description.
626
627         * loader/appcache/ApplicationCacheStorage.cpp: Removed include of StringExtras.h.
628         * page/FrameTree.cpp: Ditto.
629         * page/PageSerializer.cpp: Ditto.
630         (WebCore::PageSerializer::serializeFrame): Pass result of encode directly to
631         StringBuffer::create and update for UnencodableHandling.
632         (WebCore::PageSerializer::serializeCSSStyleSheet): Ditto.
633         * page/csp/ContentSecurityPolicy.cpp:
634         (WebCore::ContentSecurityPolicy::findHashOfContentInPolicies const): Ditto.
635
636         * platform/FileHandle.cpp: Removed include of StringExtras.h.
637
638         * platform/SharedBuffer.cpp:
639         (WebCore::SharedBuffer::create): Added an overload that takes Vector<uint8_t>.
640         * platform/SharedBuffer.h: Ditto.
641
642         * platform/URLParser.cpp:
643         (WebCore::URLParser::encodeQuery): Updated since encode returns a Vector instead
644         of a CString now and for UnencodableHandling.
645         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
646         (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Ditto.
647
648         * platform/graphics/ca/PlatformCALayer.cpp: Removed include of StringExtras.h.
649
650         * platform/network/curl/ResourceHandleCurlDelegate.cpp:
651         (WebCore::ResourceHandleCurlDelegate::handleDataURL): Updated for Vector instead
652         of CString.
653
654         * platform/network/FormData.cpp:
655         (WebCore::FormData::create): Added new overload, and simplified some existing ones.
656         (WebCore::normalizeStringData): Changed return type to Vector<uint8_t> and updated
657         for UnencodableHandling.
658         (WebCore::FormData::appendMultiPartStringValue): Updated for change in type of
659         result of normalizeStringData.
660         * platform/network/FormData.h: Updated for the above and updated comments.
661
662         * platform/network/FormDataBuilder.cpp: Made this a namespace instead of a class.
663         (WebCore::FormDataBuilder::append): Added an overload for Vector<uint8_t>.
664         (WebCore::FormDataBuilder::appendQuoted): Renamed from appendQuotedString and
665         changed the argument type.
666         (WebCore::FormDataBuilder::appendFormURLEncoded): Moved logic up from the
667         encodeStringAsFormData function into a new separate helper.
668         (WebCore::FormDataBuilder::addFilenameToMultiPartHeader): Updated for change to
669         UnencodableHandling.
670         (WebCore::FormDataBuilder::beginMultiPartHeader): Changed argument type.
671         (WebCore::FormDataBuilder::addKeyValuePairAsFormData): Ditto.
672         (WebCore::FormDataBuilder::encodeStringAsFormData): Updated to call helper.
673         * platform/network/FormDataBuilder.h: Updated for the above.
674
675         * platform/text/DecodeEscapeSequences.h: Use Vector<uint8_t> instead of
676         Vector<char>, also updated the code that calls encode for the new return type
677         and updated for change to UnencodableHandler.
678
679         * platform/text/TextCodec.cpp:
680         (WebCore::TextCodec::getUnencodableReplacement): Updated since we are using
681         std::array now, so the out argument is easier to understand, also updated for
682         change to UnencodablaHandler.
683         * platform/text/TextCodec.h: Use std::array for the UnencodableReplacementArray
684         type, removed the overload of decode so there is only one decode function.
685
686         * platform/text/TextCodecICU.cpp:
687         (WebCore::ICUConverterWrapper::~ICUConverterWrapper): Deleted.
688         Not needed any more since we use ICUConverterPtr instead now.
689         (WebCore::cachedConverterICU): Deleted.
690         (WebCore::TextCodecICU::create): Deleted. Callers just use make_unique
691         directly now.
692         (WebCore::TextCodecICU::registerCodecs): Rewrote to use lambdas instead
693         of functions with void* pointers.
694         (WebCore::TextCodecICU::TextCodecICU): Moved initializers into the header.
695         (WebCore::TextCodecICU::~TextCodecICU): Moved the body of releaseICUConverter
696         in here. Also greatly simplified it now that ICUConverterPtr handles closing
697         it as needed.
698         (WebCore::TextCodecICU::releaseICUConverter const): Deleted.
699         (WebCore::TextCodecICU::createICUConverter const): Rewrote to simplfy now that
700         we can use ICUConverterPtr.
701         (WebCore::ErrorCallbackSetter::ErrorCallbackSetter): Take a reference instead
702         of a pointer.
703         (WebCore::ErrorCallbackSetter::~ErrorCallbackSetter): Ditto.
704         (WebCore::TextCodecICU::decode): Use equalLettersIgnoringASCIICase instead of
705         strcasecmp.
706         (WebCore::TextCodecICU::encode): Return a Vector instead of a CString.
707         Take a StringView instead of a pointer and length. Simplified
708         the backslash-as-currency-symbol code by using String::replace.
709         * platform/text/TextCodecICU.h: Updated for above. Fixed indentation.
710         Added a new ICUConverterPtr typedef that uses std::unique_ptr to close the
711         converter; combined with move semantics it simplifies things so we don't have
712         to be so careful about calling ucnv_close.
713
714         * platform/text/TextCodecLatin1.cpp: Renamed the Latin-1 to Unicode table from
715         "table" to latin1ConversionTable.
716         (WebCore::TextCodecLatin1::registerCodecs): Use a lambda.
717         (WebCore::encodeComplexWindowsLatin1): Return a Vector instad of CString.
718         Also use StringView::codePoints instead of our own U16_NEXT.
719         (WebCore::TextCodecLatin1::encode): More of the same.
720         * platform/text/TextCodecLatin1.h: Updated for the above.
721
722         * platform/text/TextCodecReplacement.cpp:
723         (WebCore::TextCodecReplacement::create): Deleted.
724         (WebCore::TextCodecReplacement::TextCodecReplacement): Deleted.
725         (WebCore::TextCodecReplacement::registerCodecs): Use a lambda.
726         * platform/text/TextCodecReplacement.h: Updated for the above.
727
728         * platform/text/TextCodecUTF16.cpp:
729         (WebCore::newStreamingTextDecoderUTF16LE): Deleted.
730         (WebCore::newStreamingTextDecoderUTF16BE): Deleted.
731         (WebCore::TextCodecUTF16::registerCodecs): Use lambdas.
732         (WebCore::TextCodecUTF16::encode): Return a Vector.
733         * platform/text/TextCodecUTF16.h: Updated for the above.
734
735         * platform/text/TextCodecUTF8.cpp:
736         (WebCore::TextCodecUTF8::registerCodecs): Use a lambda.
737         (WebCore::TextCodecUTF8::encode): Return a Vector.
738         * platform/text/TextCodecUTF8.h: Updated for the above.
739
740         * platform/text/TextCodecUserDefined.cpp:
741         (WebCore::newStreamingTextDecoderUserDefined): Deleted.
742         (WebCore::TextCodecUserDefined::registerCodecs): Use a lambda.
743         (WebCore::encodeComplexUserDefined): Return a Vector.
744         (WebCore::TextCodecUserDefined::encode): Ditto.
745         * platform/text/TextCodecUserDefined.h: Updated for the above.
746
747         * platform/text/TextEncoding.cpp: Changed TextCodecMap to just hold a
748         WTF::Function instead of holding a function and an additional data pointer.
749         (WebCore::TextEncoding::TextEncoding): Use equalLettersIgnoringASCIICase
750         instead of a special isReplacementEncoding function.
751         (WebCore::TextEncoding::encode const): Return a Vector instead of a CString.
752         Pass StringView instead of a pointer and length.
753         * platform/text/TextEncoding.h: Updated for the above.
754
755         * platform/text/TextEncodingRegistry.cpp:
756         (WebCore::addToTextCodecMap): Removed the additionalData pointer and used
757         WTFMove since NewTextCodecFunction is now a WTF::Function rather than a C
758         function pointer.
759         (WebCore::isReplacementEncoding): Deleted.
760         (WebCore::newTextCodec): Use find instead of get now that the fucntions in
761         the map are WTF::Function and can't be copied.
762         (WebCore::dumpTextEncodingNameMap): Deleted.
763         * platform/text/TextEncodingRegistry.h: Updated for the above.
764
765         * platform/text/win/TextCodecWin.cpp:
766         (WebCore::TextCodecWin::encode): Updated comment.
767
768         * xml/XMLHttpRequest.cpp:
769         (WebCore::XMLHttpRequest::send): Updated for change to UnencodableHandling.
770
771         * xml/XSLTUnicodeSort.cpp: Removed include of StringExtras.h.
772         * xml/parser/XMLDocumentParser.cpp: Ditto.
773         * xml/parser/XMLDocumentParserLibxml2.cpp: Ditto.
774
775 2017-12-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
776
777         Support the decoding="sync/async" syntax for image async attribute
778         https://bugs.webkit.org/show_bug.cgi?id=179432
779
780         Reviewed by Darin Adler.
781
782         Support the HTMLElementImage decoding attribute to allow controlling the
783         decoding of an image as per:
784                 https://github.com/whatwg/html/pull/3221
785                 https://whatpr.org/html/3221/images.html#decoding-images
786
787         Tests: fast/images/decode-decoding-attribute-async-large-image.html
788                fast/images/decoding-attribute-async-small-image.html
789                fast/images/decoding-attribute-dynamic-async-small-image.html
790                fast/images/decoding-attribute-sync-large-image.html
791
792         * html/HTMLAttributeNames.in:
793         * html/HTMLImageElement.cpp:
794         (WebCore::HTMLImageElement::decodingMode const):
795         * html/HTMLImageElement.h:
796         * html/HTMLImageElement.idl:
797         * platform/graphics/BitmapImage.cpp:
798         (WebCore::BitmapImage::draw):
799         (WebCore::BitmapImage::internalStartAnimation):
800         (WebCore::BitmapImage::advanceAnimation):
801         (WebCore::BitmapImage::internalAdvanceAnimation):
802         * platform/graphics/DecodingOptions.h:
803         (WebCore::DecodingOptions::DecodingOptions):
804         (WebCore::DecodingOptions::isAuto const):
805         (WebCore::DecodingOptions::isAsynchronousCompatibleWith const):
806         (WebCore::DecodingOptions::isNone const): Deleted.
807         * platform/graphics/ImageDecoder.h:
808         * platform/graphics/ImageFrame.cpp:
809         (WebCore::ImageFrame::clearImage):
810         * platform/graphics/ImageSource.cpp:
811         (WebCore::ImageSource::frameAtIndexCacheIfNeeded):
812         * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h:
813         * platform/graphics/cg/ImageDecoderCG.h:
814         * platform/graphics/win/ImageDecoderDirect2D.h:
815         * platform/image-decoders/ScalableImageDecoder.h:
816         * rendering/RenderBoxModelObject.cpp:
817         (WebCore::RenderBoxModelObject::decodingModeForImageDraw const):
818         The element attributes and the document settings should be checked before
819         checking our heuristics. And since the "decoding" attribute is per an image
820         and isLargeImageAsyncDecodingEnabledForTesting() is a global setting, the
821         decoding attribute should be checked first.
822
823 2017-12-06  David Quesada  <david_quesada@apple.com>
824
825         [Web App Manifest] Add SPI for applying a manifest to a top-level browsing context
826         https://bugs.webkit.org/show_bug.cgi?id=180368
827         rdar://problem/34748067
828
829         Reviewed by Geoffrey Garen.
830
831         Support applying a manifest to a top-level browsing context by adding a manifest
832         property on PageConfiguration to be stored on MainFrame instances created from the
833         configuration.
834
835         No new tests, no change in behavior.
836
837         * page/MainFrame.cpp:
838         (WebCore::MainFrame::MainFrame):
839         * page/MainFrame.h:
840         * page/PageConfiguration.h:
841
842 2017-12-06  Zalan Bujtas  <zalan@apple.com>
843
844         Remove nodes from AXObjectCache when the associated subframe document is getting destroyed.
845         https://bugs.webkit.org/show_bug.cgi?id=180503
846         <rdar://problem/35891328
847
848         Reviewed by Chris Fleizach.
849
850         While AXObjectCache lives on the mainframe's document, it caches nodes from every subframe document.
851         When a node is being destroyed, we deregister it from the AX cache through the Node's destructor.
852         Soon after the document is detached from the frame/frame is detached from the frame tree, this codepath
853         is no longer available (no access to the AXObjectCache object) and from this point we are unable to deregister
854         nodes associated with the current document.
855         In AXObjectCache::prepareForDocumentDestruction(), we preemptively remove all the cached nodes associated
856         with the about-to-be-destroyed document.
857
858         Covered by existing tests.
859
860         * accessibility/AXObjectCache.cpp:
861         (WebCore::AXObjectCache::remove):
862         (WebCore::filterForRemoval):
863         (WebCore::AXObjectCache::prepareForDocumentDestruction): Collecting the nodes and removing them later is
864         not the most performant way but in order to have a single code path for the de-registration (AXObjectCache::remove)
865         I think it's worth going down the slower path -which should not really be that slower anyway since those
866         lists tend to stay small.
867         (WebCore::AXObjectCache::clearTextMarkerNodesInUse): Deleted.
868         * accessibility/AXObjectCache.h:
869         (WebCore::AXObjectCache::removeNodeForUse):
870         (WebCore::AXObjectCache::remove):
871         * dom/Document.cpp:
872         (WebCore::Document::prepareForDestruction):
873         * dom/Node.cpp:
874         (WebCore::Node::willBeDeletedFrom):
875         (WebCore::Node::moveNodeToNewDocument):
876
877 2017-12-06  Brady Eidson  <beidson@apple.com>
878
879         Start writing ServiceWorker registrations to disk.
880         https://bugs.webkit.org/show_bug.cgi?id=180488
881
882         Reviewed by Chris Dumez.
883
884         No new tests (No observable behavior change).
885
886         As registrations changes occurs, we now write them to disk.
887         We don't re-read them in yet.
888
889         * Sources.txt:
890         * WebCore.xcodeproj/project.pbxproj:
891
892         * workers/service/ServiceWorkerRegistrationData.cpp:
893         (WebCore::ServiceWorkerRegistrationData::isolatedCopy const):
894         * workers/service/ServiceWorkerRegistrationData.h:
895         (WebCore::ServiceWorkerRegistrationData::encode const):
896         (WebCore::ServiceWorkerRegistrationData::decode):
897
898         * workers/service/ServiceWorkerRegistrationKey.cpp:
899         (WebCore::ServiceWorkerRegistrationKey::toDatabaseKey const):
900         * workers/service/ServiceWorkerRegistrationKey.h:
901
902         * workers/service/server/RegistrationDatabase.cpp: Added.
903         (WebCore::v1RecordsTableSchema):
904         (WebCore::v1RecordsTableSchemaAlternate):
905         (WebCore::databaseFilename):
906         (WebCore::RegistrationDatabase::RegistrationDatabase):
907         (WebCore::RegistrationDatabase::~RegistrationDatabase):
908         (WebCore::RegistrationDatabase::openSQLiteDatabase):
909         (WebCore::RegistrationDatabase::ensureValidRecordsTable):
910         (WebCore::updateViaCacheToString):
911         (WebCore::workerTypeToString):
912         (WebCore::RegistrationDatabase::pushChanges):
913         (WebCore::RegistrationDatabase::doPushChanges):
914         (WebCore::RegistrationDatabase::importRecords):
915         (WebCore::RegistrationDatabase::databaseFailedToOpen):
916         (WebCore::RegistrationDatabase::databaseOpenedAndRecordsImported):
917         * workers/service/server/RegistrationDatabase.h: Copied from Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp.
918         (WebCore::RegistrationDatabase::isClosed const):
919
920         * workers/service/server/RegistrationStore.cpp: Added.
921         (WebCore::RegistrationStore::RegistrationStore):
922         (WebCore::RegistrationStore::~RegistrationStore):
923         (WebCore::RegistrationStore::scheduleDatabasePushIfNecessary):
924         (WebCore::RegistrationStore::pushChangesToDatabase):
925         (WebCore::RegistrationStore::updateRegistration):
926         (WebCore::RegistrationStore::removeRegistration):
927         (WebCore::RegistrationStore::databaseFailedToOpen):
928         (WebCore::RegistrationStore::databaseOpenedAndRecordsImported):
929         * workers/service/server/RegistrationStore.h: Copied from Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp.
930
931         * workers/service/server/SWServer.cpp:
932         (WebCore::SWServer::removeRegistration):
933         (WebCore::SWServer::SWServer):
934         (WebCore::SWServer::updateWorker):
935         (WebCore::SWServer::installContextData):
936         * workers/service/server/SWServer.h:
937
938         * workers/service/server/SWServerRegistration.cpp:
939         (WebCore::SWServerRegistration::data const):
940         * workers/service/server/SWServerRegistration.h:
941         (WebCore::SWServerRegistration::setLastUpdateTime):
942
943 2017-12-06  Chris Dumez  <cdumez@apple.com>
944
945         Unreviewed, fix build after r225577.
946
947         * bindings/js/JSDOMGlobalObject.cpp:
948
949 2017-12-06  David Quesada  <david_quesada@apple.com>
950
951         [Web App Manifest] Add SPI for fetching the manifest
952         https://bugs.webkit.org/show_bug.cgi?id=180294
953         rdar://problem/34747968
954
955         Reviewed by Geoffrey Garen.
956
957         Test: applicationmanifest/developer-warnings.html
958
959         * Modules/applicationmanifest/ApplicationManifest.h:
960         (WebCore::ApplicationManifest::encode const):
961         (WebCore::ApplicationManifest::decode):
962         * Modules/applicationmanifest/ApplicationManifestParser.cpp:
963         (WebCore::ApplicationManifestParser::logManifestPropertyNotAString):
964         (WebCore::ApplicationManifestParser::logManifestPropertyInvalidURL):
965             Drive-by wording changes. Since the warning is prefixed with "parsing
966             application manifest:", remove a redundant use of "application manifest".
967
968 2017-12-06  Per Arne Vollan  <pvollan@apple.com>
969
970         The WebProcess should use the NSRunLoop runloop type.
971         https://bugs.webkit.org/show_bug.cgi?id=179804
972         <rdar://problem/14012823>
973
974         Reviewed by Brent Fulgham.
975
976         No new tests.
977
978         * platform/mac/EventLoopMac.mm:
979         (WebCore::EventLoop::cycle):
980
981 2017-12-06  Antti Koivisto  <antti@apple.com>
982
983         Prefer ids and classes over tag names in selector filter
984         https://bugs.webkit.org/show_bug.cgi?id=180433
985         <rdar://problem/35859103>
986
987         Reviewed by Zalan Bujtas.
988
989         There are only four slots in the filter and currently we just pick whatever identifiers we find traversing the selector
990         from right to left. More specific selector types are on average more valuable (id > class > tag) so we should prefer them.
991
992         This appears to be 4-5% StyleBench progression.
993
994         * css/RuleSet.cpp:
995         (WebCore::RuleData::RuleData):
996         * css/SelectorFilter.cpp:
997         (WebCore::collectSimpleSelectorHash):
998         (WebCore::collectSelectorHashes):
999
1000             This function collects all hashes from the selector.
1001
1002         (WebCore::chooseSelectorHashesForFilter):
1003
1004             This function chooses the most valuable hashes to use with the filter.
1005
1006         (WebCore::SelectorFilter::collectHashes):
1007
1008             Factor into two separate steps.
1009
1010         (WebCore::collectDescendantSelectorIdentifierHashes): Deleted.
1011         (WebCore::SelectorFilter::collectIdentifierHashes): Deleted.
1012         * css/SelectorFilter.h:
1013         (WebCore::SelectorFilter::fastRejectSelector const):
1014
1015 2017-12-06  Jer Noble  <jer.noble@apple.com>
1016
1017         [EME] Make CDMInstance& parameter passed through MediaPlayer non-const
1018         https://bugs.webkit.org/show_bug.cgi?id=180484
1019
1020         Reviewed by Jon Lee.
1021
1022         One can only call const methods on const references, and the obvious intent
1023         of these methods is for the callee to call non-const methods on the parameters.
1024
1025         * Modules/encryptedmedia/MediaKeys.h:
1026         (WebCore::MediaKeys::cdmInstance):
1027         * platform/graphics/MediaPlayer.cpp:
1028         (WebCore::MediaPlayer::cdmInstanceAttached):
1029         (WebCore::MediaPlayer::cdmInstanceDetached):
1030         (WebCore::MediaPlayer::attemptToDecryptWithInstance):
1031         * platform/graphics/MediaPlayer.h:
1032         * platform/graphics/MediaPlayerPrivate.h:
1033         (WebCore::MediaPlayerPrivateInterface::cdmInstanceAttached):
1034         (WebCore::MediaPlayerPrivateInterface::cdmInstanceDetached):
1035         (WebCore::MediaPlayerPrivateInterface::attemptToDecryptWithInstance):
1036         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
1037         (WebCore::MediaPlayerPrivateGStreamerBase::cdmInstanceAttached):
1038         (WebCore::MediaPlayerPrivateGStreamerBase::cdmInstanceDetached):
1039         (WebCore::MediaPlayerPrivateGStreamerBase::attemptToDecryptWithInstance):
1040         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
1041         * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
1042         (WebCore::MediaPlayerPrivateGStreamerMSE::attemptToDecryptWithInstance):
1043         * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
1044
1045 2017-12-06  Youenn Fablet  <youenn@apple.com>
1046
1047         Preflight should bypass service worker
1048         https://bugs.webkit.org/show_bug.cgi?id=180463
1049
1050         Reviewed by Alex Christensen.
1051
1052         Covered by updated test.
1053
1054         * loader/CrossOriginPreflightChecker.cpp:
1055         (WebCore::CrossOriginPreflightChecker::startPreflight): Ensure service worker is not used.
1056         * loader/DocumentThreadableLoader.cpp:
1057         (WebCore::DocumentThreadableLoader::didFail): Tighten check and clear resource proactively to not hit loadRequest ASSERT.
1058
1059 2017-12-06  John Wilander  <wilander@apple.com>
1060
1061         Storage Access API: Make document.hasStorageAccess a function and always allow access for same-origin iframes
1062         https://bugs.webkit.org/show_bug.cgi?id=176944
1063         <rdar://problem/34440658>
1064
1065         Reviewed by Brent Fulgham.
1066
1067         Test: http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-without-user-gesture.html
1068
1069         This change introduces document.hasStorageAccess() as a function which
1070         returns a promise instead of being a property. Since cookie access can
1071         be due to both a granted request and recent user interaction as first
1072         party, the WebKit::WebResourceLoadStatisticsStore needs to be consulted.
1073
1074         * dom/Document.cpp:
1075         (WebCore::Document::hasStorageAccess):
1076         (WebCore::Document::requestStorageAccess):
1077             Removed check of the previous m_hasStorageAccess member.
1078             Same-origin check done earlier. This was a request/suggestion
1079             from Mozilla.
1080         * dom/Document.h:
1081         (WebCore::Document::hasStorageAccess const): Deleted.
1082             Now uses a promise.
1083         * dom/Document.idl:
1084         * page/ChromeClient.h:
1085
1086 2017-12-06  Youenn Fablet  <youenn@apple.com>
1087
1088         REGRESSION (r225537): Crash in WebCore::SWServerWorker::setHasPendingEvents(bool) + 68
1089         https://bugs.webkit.org/show_bug.cgi?id=180481
1090
1091         Reviewed by Chris Dumez.
1092
1093         Replacing ASSERT by if null check since there is no strong guarantee right now that there is a registration
1094         in SWServer registration map associated to a SWServerWorker.
1095
1096         * workers/service/server/SWServerWorker.cpp:
1097         (WebCore::SWServerWorker::setHasPendingEvents):
1098
1099 2017-12-06  Chris Dumez  <cdumez@apple.com>
1100
1101         ServiceWorkers API should reject promises when calling objects inside detached frames
1102         https://bugs.webkit.org/show_bug.cgi?id=180444
1103
1104         Reviewed by Youenn Fablet.
1105
1106         ServiceWorkers API should reject promises when calling objects inside detached frames.
1107
1108         No new tests, rebaselined existing test.
1109
1110         * bindings/js/JSDOMPromiseDeferred.h:
1111         (WebCore::callPromiseFunction):
1112         Use the caller's globalObject instead of the lexicalGlobalObject when constructing the
1113         deferred promise. The bug became visible when working on this service worker bug since
1114         rejecting the promise when the frame is detached did not actually work. The issue is
1115         that since the promise was created with the detached frame's globalObject, then it was
1116         suspended and would not run script.
1117
1118         * bindings/js/JSDOMWindowBase.cpp:
1119         (WebCore::callerGlobalObject):
1120         (WebCore::incumbentDOMWindow):
1121         * bindings/js/JSDOMWindowBase.h:
1122         Add convenience function to get the caller's globalObject. It was carved out of
1123         incumbentDOMWindow().
1124
1125         * workers/service/ServiceWorker.cpp:
1126         (WebCore::ServiceWorker::postMessage):
1127         * workers/service/ServiceWorkerContainer.cpp:
1128         (WebCore::ServiceWorkerContainer::addRegistration):
1129         (WebCore::ServiceWorkerContainer::getRegistration):
1130         (WebCore::ServiceWorkerContainer::getRegistrations):
1131         * workers/service/ServiceWorkerRegistration.cpp:
1132         (WebCore::ServiceWorkerRegistration::update):
1133         (WebCore::ServiceWorkerRegistration::unregister):
1134         Reject the promise when m_isStopped flag is set (i.e. ActiveDOMObject::stop()
1135         has been called).
1136
1137 2017-12-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
1138
1139         [Mac] REGRESSION (r224527): Drawing a path with box-shadow takes double the blur-radius on Retina display
1140         https://bugs.webkit.org/show_bug.cgi?id=180460
1141         <rdar://problem/35869866>
1142
1143         Reviewed by Daniel Bates.
1144
1145         Disable using CGContextDrawPathDirect() for macOS High Sierra or earlier.
1146         This API has a bug when drawing a path with a shadow on Retina display.
1147         This bug is tracked internally by <rdar://problem/35620690>.
1148
1149
1150         * platform/graphics/cg/GraphicsContextCG.cpp:
1151
1152 2017-12-06  Youenn Fablet  <youenn@apple.com>
1153
1154         Service Worker fetch should filter HTTP headers that are added by CachedResourceLoader/CachedResource
1155         https://bugs.webkit.org/show_bug.cgi?id=180462
1156
1157         Reviewed by Geoffrey Garen.
1158
1159         Coved by rebased test.
1160
1161         * loader/CrossOriginAccessControl.cpp:
1162         (WebCore::cleanRedirectedRequestForAccessControl): Accept header is a safe header so it is fine to keep it.
1163         * workers/service/context/ServiceWorkerFetch.cpp:
1164         (WebCore::ServiceWorkerFetch::dispatchFetchEvent): Cleaning headers added by CachedResourceLoader/CachedResource.
1165
1166 2017-12-06  Zan Dobersek  <zdobersek@igalia.com>
1167
1168         [CoordGraphics] Introduce Nicosia::PaintingContext, add Cairo implementation
1169         https://bugs.webkit.org/show_bug.cgi?id=180239
1170
1171         Reviewed by Michael Catanzaro.
1172
1173         As the next step in the Nicosia abstraction formation, we introduce
1174         Nicosia::PaintingContext. Implementations of this class will leverage a
1175         chosen 2D graphics library to paint (through GraphicsContext) into the
1176         memory area that's specified by a given Nicosia::Buffer object.
1177
1178         Nicosia::Buffer is slimmed down to only control the memory that's
1179         required for rasterization of an RGBA32 painting output. It mimics the
1180         Cairo ImageBuffer implementation by using FastMalloc to allocate the
1181         necessary memory. In the future this class might become an interface of
1182         which different implementations will be providing memory that's
1183         allocated through different ways. For instance, when GLES3 is available,
1184         it would be possible to map GPU memory into the process memory space and
1185         rasterize into that, effectively eliminating need for GPU uploads.
1186
1187         Since the ImageBuffer use in Nicosia::Buffer is dropped, the context()
1188         and uploadImage() methods are also removed. The functionality of
1189         ImageBuffer that was leveraged for CoordinatedGraphics rasterization
1190         still remains used through the PaintingContextCairo implementation. In
1191         the constructor of that class, with the target Nicosia::Buffer provided,
1192         we construct the cairo_surface_t and cairo_t objects that are necessary
1193         to create a combination of PlatformContextCairo and GraphicsContext
1194         objects that we can then use for rasterization.
1195
1196         Reference of the passed-in Nicosia::Buffer object is increased for the
1197         lifetime of the cairo_surface_t object that will be drawing into that
1198         buffer's memory area. This ensures the memory area doesn't disappear
1199         from a live cairo_surface_t. Still, the expectation is that the
1200         cairo_surface_t object won't outlive the PaintingContextCairo object's
1201         lifetime, since the cairo_t object is also managed here and deleted in
1202         the destructor. To test that, we use a cairo_surface_t user data key
1203         that in its destroy callback dereferences the Nicosia::Buffer object and
1204         also marks the deletion process for the related PaintingContextCairo
1205         object as complete. This m_deletionComplete value is tested in the
1206         destructor of the class, once all the Cairo references are nulled out.
1207
1208         The PaintingContext objects should be limited to a single scope,
1209         enabling the implementation resources to assume that the lifetime of the
1210         implementation object won't extend outside of the scope where it was
1211         created. To ensure that, the PaintingContext::paint() static function is
1212         added that creates the PaintingContext object and then executes the
1213         passed-in functor, passing it the GraphicsContext that should be used
1214         for drawing. Drawing is thus limited to that functor only, and the
1215         PaintingContext's create() function and the virtual graphicsContext()
1216         are not made public in the class.
1217
1218         No new tests -- no change in functionality.
1219
1220         * platform/TextureMapper.cmake:
1221         * platform/graphics/nicosia/NicosiaBuffer.cpp:
1222         (Nicosia::Buffer::Buffer):
1223         (Nicosia::Buffer::context): Deleted.
1224         (Nicosia::Buffer::uploadImage): Deleted.
1225         * platform/graphics/nicosia/NicosiaBuffer.h:
1226         (Nicosia::Buffer::stride const):
1227         (Nicosia::Buffer::data const):
1228         * platform/graphics/nicosia/NicosiaPaintingContext.cpp: Copied from Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.cpp.
1229         (Nicosia::PaintingContext::create):
1230         * platform/graphics/nicosia/NicosiaPaintingContext.h: Copied from Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.cpp.
1231         (Nicosia::PaintingContext::paint):
1232         * platform/graphics/nicosia/NicosiaPaintingContextCairo.cpp: Added.
1233         (Nicosia::PaintingContextCairo::PaintingContextCairo):
1234         (Nicosia::PaintingContextCairo::~PaintingContextCairo):
1235         (Nicosia::PaintingContextCairo::graphicsContext):
1236         * platform/graphics/nicosia/NicosiaPaintingContextCairo.h: Copied from Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.h.
1237         * platform/graphics/nicosia/NicosiaPaintingEngineBasic.cpp:
1238         (Nicosia::PaintingEngineBasic::paint):
1239         * platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:
1240         (WebCore::CoordinatedImageBacking::update):
1241
1242 2017-12-05  Fujii Hironori  <Hironori.Fujii@sony.com>
1243
1244         [GTK] Layout test media/track/track-in-band-duplicate-tracks-when-source-changes.html crashes and times out
1245         https://bugs.webkit.org/show_bug.cgi?id=160131
1246
1247         Reviewed by Eric Carlson.
1248
1249         Null dereference can be happen if VideoTrack and AudioTrack are
1250         disconnected from its media element.
1251
1252         No new tests, no behavior change.
1253
1254         * html/track/AudioTrack.cpp:
1255         (WebCore::AudioTrack::willRemove): Null-check mediaElement.
1256         * html/track/VideoTrack.cpp:
1257         (WebCore::VideoTrack::setLanguage): Ditto.
1258
1259 2017-12-05  Chris Dumez  <cdumez@apple.com>
1260
1261         ServiceWorkerGlobalScope prototype chain should be immutable
1262         https://bugs.webkit.org/show_bug.cgi?id=180450
1263
1264         Reviewed by Youenn Fablet.
1265
1266         ServiceWorkerGlobalScope prototype chain should be immutable, similarly
1267         to what we do for DOMWindow. This is covered by a web-platform-test
1268         which was timing out because it was successfuly overwriting the
1269         ServiceWorkerGlobalScope prototype.
1270
1271         No new tests, rebaselined existing test.
1272
1273         * workers/DedicatedWorkerGlobalScope.idl:
1274         * workers/WorkerGlobalScope.idl:
1275         * workers/service/ServiceWorkerGlobalScope.idl:
1276
1277 2017-12-05  Basuke Suzuki  <Basuke.Suzuki@sony.com>
1278
1279         Fast binding generation by batching several files at once
1280         https://bugs.webkit.org/show_bug.cgi?id=179958
1281
1282         Reviewed by Alex Christensen.
1283
1284         Passing several files to the sub process at once and reducing the total cost of
1285         process generation. Especially Windows port has great speed improvement because
1286         its implementation of fork/exec is terrible.
1287
1288         * bindings/scripts/generate-bindings-all.pl:
1289         (spawnGenerateBindingsIfNeeded):
1290         * bindings/scripts/generate-bindings.pl:
1291         (generateBindings):
1292
1293 2017-12-05  David Quesada  <david_quesada@apple.com>
1294
1295         [Web App Manifest] Support fetching the app manifest 
1296         https://bugs.webkit.org/show_bug.cgi?id=180292
1297
1298         Reviewed by Geoffrey Garen.
1299
1300         Add support in WebCore for loading and parsing application manifests. This functionality
1301         is currently exposed with two methods: DocumentLoader::loadApplicationManifest() to call
1302         to start loading the manifest, and FrameLoaderClient::finishedLoadingApplicationManifest()
1303         for clients to override in order to be notified of the loaded manifest.
1304
1305         No new tests, since no functionality is exposed to web content or embedders yet. The
1306         needed SPI will be added in an upcoming patch.
1307
1308         * Sources.txt:
1309         * WebCore.xcodeproj/project.pbxproj:
1310             Added CachedApplicationManifest and ApplicationManifestLoader.
1311         * html/HTMLLinkElement.h:
1312         * html/LinkRelAttribute.cpp:
1313         (WebCore::LinkRelAttribute::LinkRelAttribute):
1314         (WebCore::LinkRelAttribute::isSupported):
1315             Add "manifest" as a supported 'rel' type for links.
1316         * html/LinkRelAttribute.h:
1317         * inspector/agents/InspectorPageAgent.cpp:
1318         (WebCore::InspectorPageAgent::resourceTypeJSON):
1319         (WebCore::InspectorPageAgent::inspectorResourceType):
1320         * inspector/agents/InspectorPageAgent.h:
1321         * loader/ApplicationManifestLoader.cpp: Added.
1322             Added a class ApplicationManifestLoader which handles creating a ResourceRequest,
1323             loading the resource from the CachedResourceLoader, and parsing the resulting text.
1324             This class and its relation to DocumentLoader are roughly based on that of IconLoader,
1325             which serves a similar purpose - requesting a resource on the page and ultimately
1326             providing it to the embedder.
1327         (WebCore::ApplicationManifestLoader::ApplicationManifestLoader):
1328         (WebCore::ApplicationManifestLoader::~ApplicationManifestLoader):
1329         (WebCore::ApplicationManifestLoader::startLoading):
1330         (WebCore::ApplicationManifestLoader::stopLoading):
1331         (WebCore::ApplicationManifestLoader::processManifest):
1332         (WebCore::ApplicationManifestLoader::notifyFinished):
1333         * loader/ApplicationManifestLoader.h: Copied from Source/WebCore/page/csp/ContentSecurityPolicyDirectiveNames.h.
1334         * loader/DocumentLoader.cpp:
1335         (WebCore::DocumentLoader::stopLoading):
1336         (WebCore::DocumentLoader::loadApplicationManifest):
1337         (WebCore::DocumentLoader::finishedLoadingApplicationManifest):
1338         (WebCore::DocumentLoader::notifyFinishedLoadingApplicationManifest):
1339         * loader/DocumentLoader.h:
1340         * loader/FrameLoaderClient.h:
1341         * loader/LinkLoader.cpp:
1342         (WebCore::createLinkPreloadResourceClient):
1343         (WebCore::LinkLoader::isSupportedType):
1344         * loader/ResourceLoadInfo.cpp:
1345         (WebCore::toResourceType):
1346         * loader/SubresourceLoader.cpp:
1347         (WebCore::logResourceLoaded):
1348         * loader/cache/CachedApplicationManifest.cpp: Added.
1349         (WebCore::CachedApplicationManifest::CachedApplicationManifest):
1350         (WebCore::CachedApplicationManifest::finishLoading):
1351         (WebCore::CachedApplicationManifest::setEncoding):
1352         (WebCore::CachedApplicationManifest::encoding const):
1353         (WebCore::CachedApplicationManifest::process):
1354             Add a method to process the fetched text into an ApplicationManifest. CachedApplicationManifest
1355             does not store the resulting ApplicationManifest because the text of an application
1356             manifest can yield a different ApplicationManifest depending on the URL of the document
1357             processing it.
1358         * loader/cache/CachedApplicationManifest.h: Copied from Source/WebCore/page/csp/ContentSecurityPolicyDirectiveNames.h.
1359         * loader/cache/CachedResource.cpp:
1360         (WebCore::CachedResource::defaultPriorityForResourceType):
1361         * loader/cache/CachedResource.h:
1362         * loader/cache/CachedResourceLoader.cpp:
1363         (WebCore::createResource):
1364         (WebCore::CachedResourceLoader::requestApplicationManifest):
1365         (WebCore::contentTypeFromResourceType):
1366         (WebCore::CachedResourceLoader::checkInsecureContent const):
1367         (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const):
1368         * loader/cache/CachedResourceLoader.h:
1369         * page/DiagnosticLoggingKeys.cpp:
1370         (WebCore::DiagnosticLoggingKeys::applicationManifestKey):
1371         * page/DiagnosticLoggingKeys.h:
1372         * page/csp/ContentSecurityPolicy.cpp:
1373         (WebCore::ContentSecurityPolicy::allowManifestFromSource const):
1374         * page/csp/ContentSecurityPolicy.h:
1375         * page/csp/ContentSecurityPolicyDirectiveList.cpp:
1376         (WebCore::ContentSecurityPolicyDirectiveList::violatedDirectiveForManifest const):
1377         (WebCore::ContentSecurityPolicyDirectiveList::addDirective):
1378         * page/csp/ContentSecurityPolicyDirectiveList.h:
1379         * page/csp/ContentSecurityPolicyDirectiveNames.cpp:
1380         * page/csp/ContentSecurityPolicyDirectiveNames.h:
1381
1382 2017-12-05  Stephan Szabo  <stephan.szabo@sony.com>
1383
1384         Switch windows build to Visual Studio 2017
1385         https://bugs.webkit.org/show_bug.cgi?id=172412
1386
1387         Reviewed by Per Arne Vollan.
1388
1389         Only changes proj file to update generator
1390
1391         * WebCore.vcxproj/WebCore.proj:
1392
1393 2017-12-05  Brent Fulgham  <bfulgham@apple.com>
1394
1395         Limit user agent versioning to an upper bound
1396         https://bugs.webkit.org/show_bug.cgi?id=180365
1397         <rdar://problem/34550617>
1398
1399         Reviewed by Joseph Pecoraro.
1400
1401         Freeze the version reported as User Agent to OS 10.13.4 (OS 11.3 on iOS) and WebKit 605.1.15
1402         for User Agent purposes.
1403
1404         Test: fast/dom/navigator-userAgent-frozen.html
1405
1406         * page/cocoa/UserAgent.h:
1407         * page/cocoa/UserAgent.mm:
1408         (WebCore::versionPredatesFreeze): Helper function. Returns true for Version 10.13.3 or older.
1409         (WebCore::systemMarketingVersionForUserAgentString):
1410         (WebCore::userAgentBundleVersion):
1411         (WebCore::userVisibleWebKitBundleVersionFromFullVersion): Deleted.
1412         (WebCore::userAgentBundleVersionFromFullVersionString): Deleted.
1413         * page/ios/UserAgentIOS.mm:
1414         (WebCore::standardUserAgentWithApplicationName): Don't take the WebKit bundle version
1415         as an argument, or pass it to the user agent string generator.
1416         * page/mac/UserAgentMac.mm:
1417         (WebCore::standardUserAgentWithApplicationName): Ditto. 
1418
1419 2017-12-05  Matt Lewis  <jlewis3@apple.com>
1420
1421         Unreviewed, rolling out r225430.
1422
1423         This caused an API failure on release.
1424
1425         Reverted changeset:
1426
1427         "Move DateComponents into WTF"
1428         https://bugs.webkit.org/show_bug.cgi?id=180211
1429         https://trac.webkit.org/changeset/225430
1430
1431 2017-12-05  Simon Fraser  <simon.fraser@apple.com>
1432
1433         Composited frames incorrectly get requestAnimationFrame throttled
1434         https://bugs.webkit.org/show_bug.cgi?id=178396
1435
1436         Reviewed by Zalan Bujtas.
1437
1438         If a composited iframe was inside overflow:scroll, and the overflow was scrolled to the left
1439         further than the window width, then RenderLayer::childrenClipRect() would return an empty rectangle
1440         and we'd incorrectly consider the iframe out of view, and thus throttle its requestAnimationFrame.
1441
1442         childrenClipRect() was taking unscaledDocumentRect(), applying the clip, and then mapping the result
1443         from local to absolute coordinates (which mapped it through the overflow scroll offset). This is incorrect
1444         because it considers the unscaledDocumentRect() to be in local coordinates, which it is not.
1445
1446         Instead, start with the infinite rect, which essentially tells us if we have any clipping, and then
1447         intersect that with the document rect at the end. Something similar is done in other places that call.
1448         calculateRects().
1449
1450         Test: fast/animation/request-animation-frame-throttle-inside-overflow-scroll.html
1451
1452         * rendering/RenderLayer.cpp:
1453         (WebCore::RenderLayer::calculateClipRects const):
1454
1455 2017-12-05  Michael Saboff  <msaboff@apple.com>
1456
1457         Make WebKit build for ARM64_32
1458         https://bugs.webkit.org/show_bug.cgi?id=180447
1459
1460         Reviewed by Mark Lam.
1461
1462         No new test as this isn't a change to functionality.
1463
1464         * platform/graphics/transforms/TransformationMatrix.cpp:
1465         (WebCore::TransformationMatrix::multiply): Fallback to the C++ version for
1466         ARM64_32.
1467
1468 2017-12-05  Chris Dumez  <cdumez@apple.com>
1469
1470         XMLHttpRequest should not be exposed to service workers
1471         https://bugs.webkit.org/show_bug.cgi?id=180446
1472
1473         Reviewed by Youenn Fablet.
1474
1475         Stop exposing XMLHttpRequest to service workers, as per:
1476         - https://xhr.spec.whatwg.org/#interface-xmlhttprequest
1477
1478         * xml/XMLHttpRequest.idl:
1479
1480 2017-12-05  Joseph Pecoraro  <pecoraro@apple.com>
1481
1482         Web Inspector: content views for resources loaded through XHR do not reflect declared mime-type
1483         https://bugs.webkit.org/show_bug.cgi?id=141389
1484         <rdar://problem/19767070>
1485
1486         Reviewed by Brian Burg.
1487
1488         Updated: http/tests/inspector/network/xhr-response-body.html:
1489                  http/tests/inspector/network/fetch-response-body.html:
1490
1491         * xml/XMLHttpRequest.cpp:
1492         (WebCore::XMLHttpRequest::didFinishLoading):
1493         * inspector/InspectorInstrumentation.cpp:
1494         (WebCore::InspectorInstrumentation::didFinishXHRLoadingImpl): Deleted.
1495         * inspector/InspectorInstrumentation.h:
1496         (WebCore::InspectorInstrumentation::didFinishXHRLoading): Deleted.
1497         Remove special handling of XHR content that decoded output as text.
1498
1499         * inspector/NetworkResourcesData.h:
1500         (WebCore::NetworkResourcesData::ResourceData::requestId const):
1501         (WebCore::NetworkResourcesData::ResourceData::loaderId const):
1502         (WebCore::NetworkResourcesData::ResourceData::frameId const):
1503         (WebCore::NetworkResourcesData::ResourceData::url const):
1504         (WebCore::NetworkResourcesData::ResourceData::content const):
1505         (WebCore::NetworkResourcesData::ResourceData::isContentEvicted const):
1506         (WebCore::NetworkResourcesData::ResourceData::textEncodingName const):
1507         * inspector/NetworkResourcesData.cpp:
1508         (WebCore::NetworkResourcesData::ResourceData::ResourceData):
1509         (WebCore::NetworkResourcesData::ResourceData::decodeDataToContent):
1510         (WebCore::NetworkResourcesData::responseReceived):
1511         (WebCore::NetworkResourcesData::setResourceContent):
1512         (WebCore::shouldBufferResourceData):
1513         (WebCore::NetworkResourcesData::maybeAddResourceData):
1514         (WebCore::NetworkResourcesData::maybeDecodeDataToContent):
1515
1516         Make NetworkResourcesData only create a text decoder for resources we
1517         really think are text, and buffer resource data if it is text data
1518         or if it is a resource that would otherwise not be buffered by WebCore
1519         (such as XHRs with a DoNotBufferData policy). This ensures that the
1520         Inspector will have data to show for resources that won't be cached.
1521
1522         * inspector/agents/InspectorPageAgent.cpp:
1523         (WebCore::InspectorPageAgent::resourceContent):
1524         (WebCore::InspectorPageAgent::sourceMapURLForResource):
1525         (WebCore::InspectorPageAgent::searchInResource):
1526         (WebCore::InspectorPageAgent::searchInResources):
1527         (WebCore::hasTextContent): Deleted.
1528         (WebCore::InspectorPageAgent::cachedResourceContent): Deleted.
1529         (WebCore::InspectorPageAgent::createTextDecoder): Deleted.
1530         (WebCore::textContentForCachedResource): Deleted.
1531         * inspector/agents/InspectorPageAgent.h:
1532         * inspector/agents/InspectorNetworkAgent.cpp:
1533         (WebCore::InspectorNetworkAgent::didReceiveData):
1534         (WebCore::InspectorNetworkAgent::willDestroyCachedResource):
1535         (WebCore::InspectorNetworkAgent::getResponseBody):
1536         (WebCore::InspectorNetworkAgent::shouldTreatAsText):
1537         (WebCore::InspectorNetworkAgent::createTextDecoder):
1538         (WebCore::InspectorNetworkAgent::textContentForCachedResource):
1539         (WebCore::InspectorNetworkAgent::cachedResourceContent):
1540         (WebCore::textContentForResourceData):
1541         (WebCore::InspectorNetworkAgent::searchOtherRequests):
1542         (WebCore::isErrorStatusCode): Deleted.
1543         (WebCore::InspectorNetworkAgent::didFinishXHRLoading): Deleted.
1544         * inspector/agents/InspectorNetworkAgent.h:
1545         Move static PageAgent functions related to the generic data tuple
1546         (content, base64Encoded) to NetworkAgent. Also generalize it to
1547         not rely on the CachedResourceType, but instead rely on the MIME type.
1548         This has a few changes in behavior:
1549
1550             - Images, may now be text if they have a text mime type (image/svg+xml).
1551             - XHR / Fetch / Other may be sent as text if they have a text mime type.
1552             - XHR / Fetch / Other are not assumed to be text, and may be sent as base64 encoded.
1553         
1554         For this to be useful the frontend should also check the mime type and
1555         display an appropriate ContentView.
1556
1557 2017-12-05  Youenn Fablet  <youenn@apple.com>
1558
1559         Implement https://w3c.github.io/ServiceWorker/#clients-claim
1560         https://bugs.webkit.org/show_bug.cgi?id=180261
1561
1562         Reviewed by Chris Dumez.
1563
1564         Test: http/tests/workers/service/serviceworkerclients-claim.https.html
1565
1566         Implement claim by going to the storage process and then iterate over clients to see whether active worker can be set.
1567         Update SWServerWorker to call registration tryClear/tryActivate whenever a service worker has no pending event.
1568
1569         * workers/service/ServiceWorkerClients.cpp:
1570         (WebCore::ServiceWorkerClients::claim):
1571         * workers/service/context/SWContextManager.h:
1572         * workers/service/server/SWServer.cpp:
1573         (WebCore::SWServer::claim):
1574         (WebCore::SWServer::doRegistrationMatching):
1575         (WebCore::SWServer::doRegistrationMatching const): Deleted.
1576         * workers/service/server/SWServer.h:
1577         (WebCore::SWServer::Connection::doRegistrationMatching):
1578         * workers/service/server/SWServerRegistration.cpp:
1579         (WebCore::SWServerRegistration::controlClient):
1580         * workers/service/server/SWServerRegistration.h:
1581         * workers/service/server/SWServerToContextConnection.cpp:
1582         (WebCore::SWServerToContextConnection::claim):
1583         * workers/service/server/SWServerToContextConnection.h:
1584         * workers/service/server/SWServerWorker.cpp:
1585         (WebCore::SWServerWorker::claim):
1586         * workers/service/server/SWServerWorker.h:
1587
1588 2017-12-05  Per Arne Vollan  <pvollan@apple.com>
1589
1590         [Win] Scrollbars are sometimes not rendered in accelerated compositing mode.
1591         https://bugs.webkit.org/show_bug.cgi?id=180431
1592         <rdar://problem/34531264>
1593
1594         Reviewed by Simon Fraser.
1595
1596         No new tests, covered by existing tests.
1597
1598         When a scroll layer is required, we will create an overflow control hosts layer.
1599         In this case the method RenderLayerCompositor::shouldCompositeOverflowControls()
1600         should return true, otherwise the scrollbars will not be rendered.
1601  
1602         * rendering/RenderLayerCompositor.cpp:
1603         (WebCore::RenderLayerCompositor::shouldCompositeOverflowControls const):
1604
1605 2017-12-05  Youenn Fablet  <youenn@apple.com>
1606
1607         Call "Terminate Service Worker" on all workers when all their clients are gone
1608         https://bugs.webkit.org/show_bug.cgi?id=179552
1609         <rdar://problem/35836323>
1610
1611         Unreviewed.
1612
1613         * workers/service/server/SWServer.cpp: Reducing from 60_s to 10_s based on bugzilla comment.
1614
1615 2017-12-05  Chris Dumez  <cdumez@apple.com>
1616
1617         Add support for ServiceWorkerContainer.prototype.ready
1618         https://bugs.webkit.org/show_bug.cgi?id=180383
1619
1620         Reviewed by Youenn Fablet.
1621
1622         Add support for ServiceWorkerContainer.prototype.ready:
1623         - https://w3c.github.io/ServiceWorker/#navigator-service-worker-ready
1624
1625         No new tests, rebaselined existing test.
1626
1627         * workers/service/SWClientConnection.h:
1628         * workers/service/ServiceWorkerContainer.cpp:
1629         (WebCore::ServiceWorkerContainer::ServiceWorkerContainer):
1630         (WebCore::ServiceWorkerContainer::ready):
1631         * workers/service/ServiceWorkerContainer.h:
1632         * workers/service/ServiceWorkerRegistrationKey.h:
1633         * workers/service/server/SWServer.cpp:
1634         (WebCore::SWServer::resolveRegistrationReadyRequests):
1635         * workers/service/server/SWServer.h:
1636         * workers/service/server/SWServerRegistration.cpp:
1637         (WebCore::SWServerRegistration::activate):
1638         (WebCore::SWServerRegistration::setIsUninstalling):
1639         * workers/service/server/SWServerRegistration.h:
1640
1641 2017-12-05  Yusuke Suzuki  <utatane.tea@gmail.com>
1642
1643         Modernize WebThread code for further refactoring
1644         https://bugs.webkit.org/show_bug.cgi?id=180344
1645
1646         Reviewed by Alex Christensen.
1647
1648         When touching Thread and its initialization component, we need to touch
1649         web thread initialization code too. However, since web thread code is old,
1650         it's style is not following to WebKit coding style guidelines.
1651
1652         This patch first modernizes WebThread code for further refactoring.
1653
1654         1. `Type*` instead of `Type *`.
1655         2. Use std::call_once instead of pthread_once.
1656         3. Use static_cast instead of C-cast.
1657         4. Use nullptr instead of NULL.
1658         5. Use `ret` or `!ret` instead of `ret != 0` or `ret == 0`.
1659         6. Do not use #pragma unused.
1660         7. if-else with one statement should not have braces.
1661
1662         In this patch, we do not change pthread_condition_t to WTF::Condition and
1663         pthread_mutex_t to WTF::Lock since web thread code requires extra care about
1664         threading.
1665
1666         No behavior change.
1667
1668         * platform/ios/wak/WebCoreThread.mm:
1669         (-[NSObject releaseOnMainThread]):
1670         (SendMessage):
1671         (HandleDelegateSource):
1672         (SendDelegateMessage):
1673         (WebThreadAdoptAndRelease):
1674         (lockWebCoreReleaseLock):
1675         (unlockWebCoreReleaseLock):
1676         (WebCoreObjCDeallocOnWebThreadImpl):
1677         (WebCoreObjCDeallocWithWebThreadLockImpl):
1678         (HandleWebThreadReleaseSource):
1679         (WebThreadCallDelegate):
1680         (WebThreadPostNotification):
1681         (WebThreadCallDelegateAsync):
1682         (WebThreadMakeNSInvocation):
1683         (MainRunLoopAutoUnlock):
1684         (_WebThreadAutoLock):
1685         (WebRunLoopLock):
1686         (WebRunLoopUnlock):
1687         (MainRunLoopUnlockGuard):
1688         (CurrentThreadContext):
1689         (RunWebThread):
1690         (StartWebThread):
1691         (WebTimedConditionLock):
1692         (_WebTryThreadLock):
1693         (WebThreadUnlockFromAnyThread):
1694         (WebThreadUnlockGuardForMail):
1695         (_WebThreadUnlock):
1696         (WebThreadIsLocked):
1697         (WebThreadLockPopModal):
1698         (WebThreadCurrentContext):
1699         (WebThreadEnable):
1700         (FreeThreadContext): Deleted.
1701         (InitThreadContextKey): Deleted.
1702
1703 2017-12-05  Alex Christensen  <achristensen@webkit.org>
1704
1705         Fix non-unified build after r225381
1706         https://bugs.webkit.org/show_bug.cgi?id=180434
1707
1708         Reviewed by Keith Miller.
1709
1710         * loader/ResourceTimingInformation.cpp:
1711         FrameLoader.h is included in other files that are combined with this file in unified builds,
1712         but we need to merge r225381 to a branch that doesn't use unified builds.  This build failure
1713         would've come up randomly in the future when we add files, too.
1714
1715 2017-12-05  Simon Fraser  <simon.fraser@apple.com>
1716
1717         Remove webkitGetImageDataHD and webkitPutImageDataHD from canvas API
1718         https://bugs.webkit.org/show_bug.cgi?id=180387
1719
1720         Reviewed by Dean Jackson.
1721
1722         CanvasRenderingContext2D.webkitGetImageDataHD and webkitPutImageDataHD were never standardized,
1723         and Blink removed support in 2014 (https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/FOPH5dloGG8).
1724
1725         Since our canvas backing store is always 1x, they have no use anyway, so remove them.
1726
1727         * html/canvas/CanvasRenderingContext2D.cpp:
1728         (WebCore::CanvasRenderingContext2D::putImageData):
1729         (WebCore::CanvasRenderingContext2D::webkitGetImageDataHD const): Deleted.
1730         (WebCore::CanvasRenderingContext2D::webkitPutImageDataHD): Deleted.
1731         * html/canvas/CanvasRenderingContext2D.h:
1732         * html/canvas/CanvasRenderingContext2D.idl:
1733
1734 2017-12-05  Youenn Fablet  <youenn@apple.com>
1735
1736         Implement setting of service worker to client in SWServer without going to WebProcess
1737         https://bugs.webkit.org/show_bug.cgi?id=180382
1738
1739         Reviewed by Chris Dumez.
1740
1741         No change of behavior.
1742
1743         This patch removes the notification of active worker setting from ScriptExecution/WebProcess up to SWServer/StorageProcess.
1744         Instead, active worker setting is fully done/controlled in SWServer.
1745         Whenever there is a change, SWServer notifies WebProcess and ScriptExecutionContext gets updated accordingly.
1746
1747         * dom/Document.cpp:
1748         (WebCore::Document::setServiceWorkerConnection):
1749         * dom/ScriptExecutionContext.cpp:
1750         (WebCore::ScriptExecutionContext::setActiveServiceWorker):
1751         * loader/DocumentLoader.cpp:
1752         (WebCore::DocumentLoader::commitData):
1753         * workers/service/SWClientConnection.h:
1754         * workers/service/server/SWServer.cpp:
1755         (WebCore::SWServer::setClientActiveWorker):
1756         (WebCore::SWServer::registerServiceWorkerClient):
1757         (WebCore::SWServer::registrationFromServiceWorkerIdentifier):
1758         (WebCore::SWServer::unregisterServiceWorkerClient):
1759         (WebCore::SWServer::Connection::serviceWorkerStartedControllingClient): Deleted.
1760         (WebCore::SWServer::Connection::serviceWorkerStoppedControllingClient): Deleted.
1761         (WebCore::SWServer::serviceWorkerStartedControllingClient): Deleted.
1762         (WebCore::SWServer::serviceWorkerStoppedControllingClient): Deleted.
1763         * workers/service/server/SWServer.h:
1764         * workers/service/server/SWServerRegistration.cpp:
1765         (WebCore::SWServerRegistration::activate):
1766
1767 2017-12-01  Filip Pizlo  <fpizlo@apple.com>
1768
1769         GC constraint solving should be parallel
1770         https://bugs.webkit.org/show_bug.cgi?id=179934
1771
1772         Reviewed by JF Bastien.
1773
1774         No new tests because no change in behavior. This change is best tested using DOM-GC-intensive
1775         benchmarks like Speedometer and Dromaeo.
1776         
1777         This parallelizes the DOM's output constraint, and makes some small changes to make this more
1778         scalable.
1779
1780         * ForwardingHeaders/heap/SimpleMarkingConstraint.h: Added.
1781         * ForwardingHeaders/heap/VisitingTimeout.h: Removed.
1782         * Sources.txt:
1783         * WebCore.xcodeproj/project.pbxproj:
1784         * bindings/js/DOMGCOutputConstraint.cpp: Added.
1785         (WebCore::DOMGCOutputConstraint::DOMGCOutputConstraint):
1786         (WebCore::DOMGCOutputConstraint::~DOMGCOutputConstraint):
1787         (WebCore::DOMGCOutputConstraint::executeImpl):
1788         (WebCore::DOMGCOutputConstraint::doParallelWorkImpl):
1789         (WebCore::DOMGCOutputConstraint::finishParallelWorkImpl):
1790         * bindings/js/DOMGCOutputConstraint.h: Added.
1791         * bindings/js/WebCoreJSClientData.cpp:
1792         (WebCore::JSVMClientData::initNormalWorld):
1793         * dom/Node.cpp:
1794         (WebCore::Node::eventTargetDataConcurrently):
1795         (WebCore::Node::ensureEventTargetData):
1796         (WebCore::Node::clearEventTargetData):
1797
1798 2017-12-05  Antoine Quint  <graouts@apple.com>
1799
1800         <video> and scale() transforms yield shrunk small or clipped controls
1801         https://bugs.webkit.org/show_bug.cgi?id=180358
1802         <rdar://problem/34436124>
1803
1804         Unreviewed.
1805
1806         Use DOMMatrix vs. WebKitCSSMatrix per Simon's post-commit review feedback.
1807
1808         * Modules/modern-media-controls/media/media-controller.js:
1809         (MediaController.prototype._updateControlsSize):
1810
1811 2017-12-04  Chris Dumez  <cdumez@apple.com>
1812
1813         Support container.getRegistration() / getRegistrations() inside service workers
1814         https://bugs.webkit.org/show_bug.cgi?id=180360
1815
1816         Reviewed by Youenn Fablet.
1817
1818         Support container.getRegistration() / getRegistrations() inside service workers
1819         by making sure we hop to the right thread when needed.
1820
1821         Test: http/tests/workers/service/ServiceWorkerGlobalScope_getRegistration.html
1822
1823         * dom/ScriptExecutionContext.cpp:
1824         (WebCore::ScriptExecutionContext::postTaskTo):
1825         * dom/ScriptExecutionContext.h:
1826         * workers/service/SWClientConnection.cpp:
1827         (WebCore::SWClientConnection::jobRejectedInServer):
1828         (WebCore::SWClientConnection::registrationJobResolvedInServer):
1829         (WebCore::SWClientConnection::unregistrationJobResolvedInServer):
1830         (WebCore::SWClientConnection::startScriptFetchForServer):
1831         (WebCore::SWClientConnection::clearPendingJobs):
1832         * workers/service/SWClientConnection.h:
1833         * workers/service/ServiceWorkerContainer.cpp:
1834         (WebCore::ServiceWorkerContainer::getRegistration):
1835         (WebCore::ServiceWorkerContainer::didFinishGetRegistrationRequest):
1836         (WebCore::ServiceWorkerContainer::getRegistrations):
1837         (WebCore::ServiceWorkerContainer::didFinishGetRegistrationsRequest):
1838         (WebCore::ServiceWorkerContainer::stop):
1839         * workers/service/ServiceWorkerContainer.h:
1840
1841 2017-12-04  Simon Fraser  <simon.fraser@apple.com>
1842
1843         Cleanup code that computes iframe content offsets in FrameView
1844         https://bugs.webkit.org/show_bug.cgi?id=180385
1845
1846         Reviewed by Zalan Bujtas.
1847
1848         The coordinate conversion functions in FrameView explicitly added borderLeft/paddingLeft
1849         and borderTop/paddingTop to compute the offset from the contents of a frame to its parent renderer.
1850         
1851         This is equivalent to the call to contextBoxRect() that RenderWidget::updateWidgetGeometry() does,
1852         which also takes left-side scrollbars into account.
1853         
1854         Coordinate offsets don't need height and width, so add RenderBox::contentBoxLocation() that just
1855         computes the top left, and use it in FrameView.
1856
1857         * page/FrameView.cpp:
1858         (WebCore::FrameView::invalidateRect):
1859         (WebCore::FrameView::convertToContainingView const):
1860         (WebCore::FrameView::convertFromContainingView const):
1861         * platform/graphics/FloatPoint.h:
1862         (WebCore::FloatPoint::scaled const):
1863         (WebCore::FloatPoint::scaled): Deleted.
1864         * rendering/RenderBox.cpp:
1865         (WebCore::RenderBox::contentBoxLocation const):
1866         * rendering/RenderBox.h:
1867
1868 2017-12-04  Nan Wang  <n_wang@apple.com>
1869
1870         AX: AOM: Implement relation type properties
1871         https://bugs.webkit.org/show_bug.cgi?id=179500
1872
1873         Reviewed by Ryosuke Niwa.
1874
1875         Accessibility Object Model
1876         Explainer: https://wicg.github.io/aom/explainer.html
1877         Spec: https://wicg.github.io/aom/spec/
1878
1879         Implemented the AOM support for activeDescendant, details and errorMessage.
1880         The corresponding ARIA attributes all take IDREFs, and the AOM properties
1881         take references to AccessibleNodes instead.
1882
1883         Test: accessibility/mac/AOM-relation-property.html
1884
1885         * accessibility/AccessibilityObject.cpp:
1886         (WebCore::AccessibilityObject::getAttribute const):
1887         (WebCore::AccessibilityObject::hasProperty const):
1888         (WebCore::AccessibilityObject::stringValueForProperty const):
1889         (WebCore::AccessibilityObject::boolValueForProperty const):
1890         (WebCore::AccessibilityObject::intValueForProperty const):
1891         (WebCore::AccessibilityObject::unsignedValueForProperty const):
1892         (WebCore::AccessibilityObject::doubleValueForProperty const):
1893         (WebCore::AccessibilityObject::elementValueForProperty const):
1894         (WebCore::AccessibilityObject::supportsARIAAttributes const):
1895         (WebCore::AccessibilityObject::elementsFromProperty const):
1896         (WebCore::AccessibilityObject::elementsReferencedByProperty const):
1897         (WebCore::AccessibilityObject::ariaActiveDescendantReferencingElements const):
1898         (WebCore::AccessibilityObject::ariaDetailsElements const):
1899         (WebCore::AccessibilityObject::ariaDetailsReferencingElements const):
1900         (WebCore::AccessibilityObject::ariaErrorMessageElements const):
1901         (WebCore::AccessibilityObject::ariaErrorMessageReferencingElements const):
1902         * accessibility/AccessibilityObject.h:
1903         * accessibility/AccessibilityRenderObject.cpp:
1904         (WebCore::AccessibilityRenderObject::activeDescendant const):
1905         * accessibility/AccessibleNode.cpp:
1906         (WebCore::ariaAttributeMap):
1907         (WebCore::isPropertyValueRelation):
1908         (WebCore::AccessibleNode::attributeFromAXPropertyName):
1909         (WebCore::AccessibleNode::setRelationProperty):
1910         (WebCore::AccessibleNode::singleRelationValueForProperty):
1911         (WebCore::AccessibleNode::activeDescendant const):
1912         (WebCore::AccessibleNode::setActiveDescendant):
1913         (WebCore::AccessibleNode::details const):
1914         (WebCore::AccessibleNode::setDetails):
1915         (WebCore::AccessibleNode::errorMessage const):
1916         (WebCore::AccessibleNode::setErrorMessage):
1917         * accessibility/AccessibleNode.h:
1918         * accessibility/AccessibleNode.idl:
1919         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
1920         (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
1921
1922 2017-12-04  Simon Fraser  <simon.fraser@apple.com>
1923
1924         Minor DisplayRefreshMonitor-related cleanup
1925         https://bugs.webkit.org/show_bug.cgi?id=179802
1926
1927         Reviewed by Sam Weinig.
1928
1929         New trace point for when the CVDisplayLink fires on its own thread.
1930
1931         Some #pragma once, and put all the WellKnownRunLoopOrders in one place.
1932
1933         * inspector/agents/InspectorTimelineAgent.cpp:
1934         (WebCore::InspectorTimelineAgent::internalStart):
1935         * platform/cf/RunLoopObserver.h:
1936         * platform/graphics/DisplayRefreshMonitor.cpp:
1937         (WebCore::DisplayRefreshMonitor::displayDidRefresh):
1938         * platform/graphics/ca/LayerFlushScheduler.h:
1939         * platform/graphics/ca/cocoa/LayerFlushSchedulerMac.cpp:
1940         (WebCore::LayerFlushScheduler::LayerFlushScheduler):
1941
1942 2017-12-04  David Quesada  <david_quesada@apple.com>
1943
1944         Add a class for parsing application manifests
1945         https://bugs.webkit.org/show_bug.cgi?id=177973
1946         rdar://problem/34747949
1947
1948         Reviewed by Geoffrey Garen.
1949
1950         Add a new struct ApplicationManifest, along with ApplicationManifestParser to initialize
1951         ApplicationManifests from JSON data, according to the App Manifest spec. Just a basic subset
1952         of the manifests's properties are implemented to start with.
1953
1954         ApplicationManifestParser is tested by new unit tests in TestWebKitAPI.
1955
1956         * Configurations/FeatureDefines.xcconfig: Add ENABLE_APPLICATION_MANIFEST feature flag.
1957         * Modules/applicationmanifest/ApplicationManifest.h: Added.
1958         * Modules/applicationmanifest/ApplicationManifestParser.cpp: Added.
1959         (WebCore::ApplicationManifestParser::parse):
1960         The main entry point for eventual clients (and currently the unit tests) to invoke
1961         ApplicationManifestParser. There is a variant that accepts a ScriptExecutionContext that
1962         uses the context exclusively for logging console warnings while parsing the manifest, and
1963         not for actually executing any scripts.
1964         (WebCore::ApplicationManifestParser::ApplicationManifestParser):
1965         (WebCore::ApplicationManifestParser::parseManifest):
1966         (WebCore::ApplicationManifestParser::logManifestPropertyNotAString):
1967         (WebCore::ApplicationManifestParser::logManifestPropertyInvalidURL):
1968         (WebCore::ApplicationManifestParser::logDeveloperWarning):
1969         (WebCore::ApplicationManifestParser::parseStartURL):
1970         (WebCore::ApplicationManifestParser::parseName):
1971         (WebCore::ApplicationManifestParser::parseDescription):
1972         (WebCore::ApplicationManifestParser::parseShortName):
1973         (WebCore::isInScope):
1974         (WebCore::ApplicationManifestParser::parseScope):
1975         (WebCore::ApplicationManifestParser::parseGenericString):
1976         * Modules/applicationmanifest/ApplicationManifestParser.h: Added.
1977         * Sources.txt:
1978         * WebCore.xcodeproj/project.pbxproj:
1979         * features.json: Change the Web App Manifest feature status to "In Development"
1980
1981 2017-12-04  Zalan Bujtas  <zalan@apple.com>
1982
1983         RenderMultiColumnFlow::fragmentedFlowDescendantInserted should not destroy incoming newDescendant
1984         https://bugs.webkit.org/show_bug.cgi?id=180181
1985
1986         Reviewed by Antti Koivisto.
1987
1988         This is in preparation for having all multicolumn related tree mutation in RenderTreeUpdaterMultiColumn.
1989
1990         Covered by fast/multicol/column-span-range-crash.html
1991
1992         * rendering/RenderMultiColumnFlow.cpp:
1993         (WebCore::RenderMultiColumnFlow::fragmentedFlowDescendantInserted):
1994         * rendering/RenderMultiColumnFlow.h:
1995         * style/RenderTreeUpdaterMultiColumn.cpp:
1996         (WebCore::RenderTreeUpdater::MultiColumn::destroyFragmentedFlow):
1997
1998 2017-12-04  JF Bastien  <jfbastien@apple.com>
1999
2000         Update std::expected to match libc++ coding style
2001         https://bugs.webkit.org/show_bug.cgi?id=180264
2002
2003         Reviewed by Alex Christensen.
2004
2005         Update various uses of Expected, mostly renaming valueOr and
2006         hasValue to the STL naming convention.
2007
2008         * Modules/cache/DOMCache.cpp:
2009         (WebCore::DOMCache::retrieveRecords):
2010         (WebCore::DOMCache::batchDeleteOperation):
2011         (WebCore::DOMCache::batchPutOperation):
2012         * Modules/cache/DOMCacheStorage.cpp:
2013         (WebCore::DOMCacheStorage::retrieveCaches):
2014         (WebCore::DOMCacheStorage::open):
2015         (WebCore::DOMCacheStorage::remove):
2016         * Modules/cache/WorkerCacheStorageConnection.cpp:
2017         (WebCore::WorkerCacheStorageConnection::doRemove):
2018         (WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
2019         (WebCore::recordsDataOrErrorFromRecords):
2020         (WebCore::recordsOrErrorFromRecordsData):
2021         * bindings/js/CachedScriptFetcher.cpp:
2022         (WebCore::CachedScriptFetcher::requestScriptWithCache const):
2023         * contentextensions/ContentExtensionCompiler.cpp:
2024         (WebCore::ContentExtensions::compileRuleList):
2025         * contentextensions/ContentExtensionParser.cpp:
2026         (WebCore::ContentExtensions::getDomainList):
2027         (WebCore::ContentExtensions::loadTrigger):
2028         (WebCore::ContentExtensions::loadRule):
2029         (WebCore::ContentExtensions::loadEncodedRules):
2030         (WebCore::ContentExtensions::parseRuleList):
2031         * css/CSSFontFaceSrcValue.cpp:
2032         (WebCore::CSSFontFaceSrcValue::cachedFont):
2033         * css/CSSImageSetValue.cpp:
2034         (WebCore::CSSImageSetValue::loadBestFitImage):
2035         * css/CSSImageValue.cpp:
2036         (WebCore::CSSImageValue::loadImage):
2037         * css/StyleRuleImport.cpp:
2038         (WebCore::StyleRuleImport::requestStyleSheet):
2039         * dom/CallbackResult.h:
2040         (WebCore::CallbackResult<ReturnType>::type const):
2041         (WebCore::CallbackResult<ReturnType>::releaseReturnValue):
2042         * dom/Element.cpp:
2043         (WebCore::Element::getIntegralAttribute const):
2044         (WebCore::Element::getUnsignedIntegralAttribute const):
2045         * dom/ExceptionOr.h:
2046         (WebCore::ExceptionOr<ReturnType>::hasException const):
2047         (WebCore::ExceptionOr<void>::hasException const):
2048         * dom/ProcessingInstruction.cpp:
2049         (WebCore::ProcessingInstruction::checkStyleSheet):
2050         * html/HTMLInputElement.cpp:
2051         (WebCore::HTMLInputElement::maxLengthAttributeChanged):
2052         (WebCore::HTMLInputElement::minLengthAttributeChanged):
2053         * html/HTMLLinkElement.cpp:
2054         (WebCore::HTMLLinkElement::process):
2055         * html/HTMLTextAreaElement.cpp:
2056         (WebCore::HTMLTextAreaElement::maxLengthAttributeChanged):
2057         (WebCore::HTMLTextAreaElement::minLengthAttributeChanged):
2058         * html/parser/HTMLParserIdioms.cpp:
2059         (WebCore::parseHTMLNonNegativeInteger):
2060         * html/parser/HTMLParserIdioms.h:
2061         (WebCore::limitToOnlyHTMLNonNegative):
2062         * loader/CrossOriginPreflightChecker.cpp:
2063         (WebCore::CrossOriginPreflightChecker::startPreflight):
2064         * loader/DocumentLoader.cpp:
2065         (WebCore::DocumentLoader::loadMainResource):
2066         * loader/DocumentThreadableLoader.cpp:
2067         (WebCore::DocumentThreadableLoader::loadRequest):
2068         * loader/ImageLoader.cpp:
2069         (WebCore::ImageLoader::updateFromElement):
2070         * loader/LinkLoader.cpp:
2071         (WebCore::LinkLoader::preloadIfNeeded):
2072         (WebCore::LinkLoader::loadLink):
2073         * loader/MediaResourceLoader.cpp:
2074         (WebCore::MediaResourceLoader::requestResource):
2075         * loader/TextTrackLoader.cpp:
2076         (WebCore::TextTrackLoader::load):
2077         * loader/cache/CachedSVGDocumentReference.cpp:
2078         (WebCore::CachedSVGDocumentReference::load):
2079         * loader/icon/IconLoader.cpp:
2080         (WebCore::IconLoader::startLoading):
2081         * platform/URLParser.cpp:
2082         (WebCore::URLParser::parseIPv4Host):
2083         * platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp:
2084         (WebCore::WebCoreAVCFResourceLoader::startLoading):
2085         * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
2086         (WebCore::WebCoreAVFResourceLoader::startLoading):
2087         * svg/SVGFEImageElement.cpp:
2088         (WebCore::SVGFEImageElement::requestImageResource):
2089         * svg/SVGFontFaceUriElement.cpp:
2090         (WebCore::SVGFontFaceUriElement::loadFont):
2091         * svg/SVGUseElement.cpp:
2092         (WebCore::SVGUseElement::updateExternalDocument):
2093         * xml/XSLImportRule.cpp:
2094         (WebCore::XSLImportRule::loadSheet):
2095
2096 2017-12-04  Zalan Bujtas  <zalan@apple.com>
2097
2098         REGRESSION (r211531): Text flow changes and overlaps other text after double-click selecting paragraph
2099         https://bugs.webkit.org/show_bug.cgi?id=180377
2100         <rdar://problem/34337967>
2101
2102         Reviewed by Antti Koivisto.
2103
2104         Take floats into account when computing the available width for a certain vertical position.
2105
2106         Test: fast/block/float/simple-line-layout-float-shrink-line.html
2107
2108         * rendering/SimpleLineLayout.cpp:
2109         (WebCore::SimpleLineLayout::updateLineConstrains):
2110
2111 2017-12-04  Antoine Quint  <graouts@apple.com>
2112
2113         <video> and scale() transforms yield shrunk small or clipped controls
2114         https://bugs.webkit.org/show_bug.cgi?id=180358
2115         <rdar://problem/34436124>
2116
2117         Reviewed by Dean Jackson.
2118
2119         To compute the bounds of the media controls, we would call getBoundingClientRect()
2120         on the root-most element in the shadow root, which is styled to have width and height
2121         set to 100%, which allows to match the metrics of the host media element, without
2122         the borders.
2123
2124         However, if the host media element has CSS transforms applied, these would be factored
2125         into calls to getBoundingClientRect() and the controls would be too large and clipped,
2126         in case the scale was more than 1, or shrunk, in case the scale was less than 1.
2127
2128         To obtain correct metrics, we computed the complete transformation matrix applied to
2129         the host media element, and apply its inverted matrix to each corner point of the
2130         bounds returned for the root-most container element in the shadow root.
2131
2132         Then we compute the width and height of this transformed rectangle and set those to
2133         be our media controls' metrics.
2134
2135         Test: media/modern-media-controls/css/transformed-media.html
2136
2137         * Modules/modern-media-controls/media/media-controller.js:
2138         (MediaController.prototype._updateControlsSize):
2139         (MediaController.prototype._controlsWidth): Deleted.
2140
2141 2017-12-04  Antoine Quint  <graouts@apple.com>
2142
2143         Cursor is not visible after exiting full screen video
2144         https://bugs.webkit.org/show_bug.cgi?id=180247
2145         <rdar://problem/33885922>
2146
2147         Reviewed by Dean Jackson.
2148
2149         There is a dedicated NSCursor method to temporarily hide the mouse cursor while the mouse is idle,
2150         so we use this platform functionality, already exposed through the page chrome, instead which
2151         implements the expected behavior. Now, the mouse cursor is hidden while the mouse is stationary
2152         when a <video> is fullscreen, as before, but as soon as the user exits fullscreen, the mouse cursor
2153         reappears.
2154
2155         No test provided as I don't believe this platform behavior can be tested, there is no API to query
2156         whether the cursor is visible.
2157
2158         * page/EventHandler.cpp:
2159         (WebCore::EventHandler::cancelAutoHideCursorTimer):
2160         (WebCore::EventHandler::autoHideCursorTimerFired):
2161
2162 2017-12-04  Chris Dumez  <cdumez@apple.com>
2163
2164         ServiceWorkerGlobalScope::skipWaiting(Ref<DeferredPromise>&&) is unsafe
2165         https://bugs.webkit.org/show_bug.cgi?id=180372
2166
2167         Reviewed by Youenn Fablet.
2168
2169         Ref the WorkerThread and capture it in the lambda. Keep the pending promises in
2170         a HashMap on the ServiceWorkerGlobalScope so that they stay on the worker thread.
2171
2172         * workers/service/ServiceWorkerGlobalScope.cpp:
2173         (WebCore::ServiceWorkerGlobalScope::skipWaiting):
2174         * workers/service/ServiceWorkerGlobalScope.h:
2175
2176 2017-12-04  Brady Eidson  <beidson@apple.com>
2177
2178         Get a directory path to SWServers for storing ServiceWorker registrations.
2179         https://bugs.webkit.org/show_bug.cgi?id=180362
2180
2181         Reviewed by Chris Dumez.
2182
2183         No new tests (No observable behavior change yet).
2184
2185         * workers/service/server/SWServer.cpp:
2186         (WebCore::SWServer::SWServer):
2187         * workers/service/server/SWServer.h:
2188
2189 2017-12-04  Devin Rousso  <webkit@devinrousso.com>
2190
2191         Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript
2192         https://bugs.webkit.org/show_bug.cgi?id=175166
2193         <rdar://problem/34040740>
2194
2195         Reviewed by Joseph Pecoraro.
2196
2197         No new tests, updated existing tests.
2198
2199         * inspector/InspectorCanvas.h:
2200         * inspector/InspectorCanvas.cpp:
2201         (WebCore::InspectorCanvas::resetRecordingData):
2202
2203         * inspector/InspectorCanvasAgent.h:
2204         * inspector/InspectorCanvasAgent.cpp:
2205         (WebCore::InspectorCanvasAgent::didFinishRecordingCanvasFrame):
2206         (WebCore::InspectorCanvasAgent::consoleStartRecordingCanvas):
2207
2208         * inspector/InspectorInstrumentation.h:
2209         * inspector/InspectorInstrumentation.cpp:
2210         (WebCore::InspectorInstrumentation::consoleStartRecordingCanvas):
2211         (WebCore::InspectorInstrumentation::consoleStartRecordingCanvasImpl):
2212
2213         * page/PageConsoleClient.h:
2214         * page/PageConsoleClient.cpp:
2215         (WebCore::PageConsoleClient::record):
2216         (WebCore::PageConsoleClient::recordEnd):
2217
2218         * workers/WorkerConsoleClient.h:
2219         * workers/WorkerConsoleClient.cpp:
2220         (WebCore::WorkerConsoleClient::record):
2221         (WebCore::WorkerConsoleClient::recordEnd):
2222
2223 2017-12-04  Youenn Fablet  <youenn@apple.com>
2224
2225         Call "Terminate Service Worker" on all workers when all their clients are gone
2226         https://bugs.webkit.org/show_bug.cgi?id=179552
2227
2228         Reviewed by Chris Dumez.
2229
2230         Tested manually.
2231
2232         When SWServer detects that there is no longer any client for a given client origin,
2233         it iterates through the running workers to terminate them if they have the given client origin.
2234         A timer of 60 seconds is used in case a user closes a tab or a window, and reopens one with the same origin shortly after.
2235
2236         * workers/service/server/SWServer.cpp:
2237         (WebCore::SWServer::findClientByIdentifier):
2238         (WebCore::SWServer::matchAll):
2239         (WebCore::SWServer::registerServiceWorkerClient):
2240         (WebCore::SWServer::unregisterServiceWorkerClient):
2241         * workers/service/server/SWServer.h:
2242
2243 2017-12-04  Antti Koivisto  <antti@apple.com>
2244
2245         Enable selector filtering for ::before and ::after pseudo element resolution
2246         https://bugs.webkit.org/show_bug.cgi?id=180364
2247
2248         Reviewed by Ryosuke Niwa.
2249
2250         Since these pseudo elements are now resolved by TreeResolver we can use selector filter for them.
2251
2252         This is 10%+ progression in StyleBench pseudo element subtest.
2253
2254         * css/StyleResolver.cpp:
2255         (WebCore::StyleResolver::pseudoStyleForElement):
2256         * css/StyleResolver.h:
2257         * style/StyleTreeResolver.cpp:
2258         (WebCore::Style::TreeResolver::resolvePseudoStyle):
2259
2260 2017-12-04  Youenn Fablet  <youenn@apple.com>
2261
2262         Add support https://w3c.github.io/ServiceWorker/#on-client-unload-algorithm
2263         https://bugs.webkit.org/show_bug.cgi?id=180359
2264
2265         Reviewed by Chris Dumez.
2266
2267         This algorithm is needed for implementation of claim.
2268         As per specification, it is run for every client unload, hence why this is put in removeClientUsingRegistration.
2269
2270         * workers/service/server/SWServerRegistration.cpp:
2271         (WebCore::SWServerRegistration::removeClientUsingRegistration):
2272         (WebCore::SWServerRegistration::handleClientUnload):
2273         * workers/service/server/SWServerRegistration.h:
2274
2275 2017-12-04  Antti Koivisto  <antti@apple.com>
2276
2277         Remove duplicates from selector filter hashes
2278         https://bugs.webkit.org/show_bug.cgi?id=180354
2279
2280         Reviewed by Simon Fraser.
2281
2282         We have only four slots for hashes in RuleSet and adding more regresses performance. To use the limited slots
2283         better we should eliminate duplicates.
2284
2285         This patch also switches to using std::array instead of a C array for the hashes.
2286
2287         The patch reduces the number of selectors passing through the selector filter in StyleBench by ~0.4%.
2288
2289         * css/ElementRuleCollector.cpp:
2290         (WebCore::ElementRuleCollector::collectMatchingRulesForList):
2291         * css/RuleSet.cpp:
2292         (WebCore::RuleData::RuleData):
2293         * css/RuleSet.h:
2294         (WebCore::RuleData::descendantSelectorIdentifierHashes const):
2295         * css/SelectorFilter.cpp:
2296         (WebCore::collectDescendantSelectorIdentifierHashes):
2297         (WebCore::SelectorFilter::collectIdentifierHashes):
2298         * css/SelectorFilter.h:
2299         (WebCore::SelectorFilter::fastRejectSelector const):
2300
2301 2017-12-04  Youenn Fablet  <youenn@apple.com>
2302
2303         WorkerCacheStorageConnection should handle the case of terminated workers
2304         https://bugs.webkit.org/show_bug.cgi?id=180304
2305
2306         Reviewed by Chris Dumez.
2307
2308         No web page observable change of behavior.
2309
2310         Reworked WorkerCacheStorageConnection hopping.
2311         Instead of refing/unrefing itself, it refs the worker thread and the main thread connection.
2312         This worker thread is then used on the way back from the main thread.
2313
2314         * Modules/cache/WorkerCacheStorageConnection.cpp:
2315         (WebCore::WorkerCacheStorageConnection::create):
2316         (WebCore::WorkerCacheStorageConnection::WorkerCacheStorageConnection):
2317         (WebCore::WorkerCacheStorageConnection::doOpen):
2318         (WebCore::WorkerCacheStorageConnection::doRemove):
2319         (WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
2320         (WebCore::WorkerCacheStorageConnection::reference):
2321         (WebCore::WorkerCacheStorageConnection::dereference):
2322         (WebCore::WorkerCacheStorageConnection::doRetrieveRecords):
2323         (WebCore::WorkerCacheStorageConnection::doBatchDeleteOperation):
2324         (WebCore::WorkerCacheStorageConnection::doBatchPutOperation):
2325         * Modules/cache/WorkerCacheStorageConnection.h:
2326         * workers/WorkerGlobalScope.cpp:
2327         (WebCore::WorkerGlobalScope::cacheStorageConnection):
2328         * workers/WorkerGlobalScope.h:
2329
2330 2017-12-04  Frederic Wang  <fwang@igalia.com>
2331
2332         Make ScrollingTreeNode::enclosingFrameNode return the node itself for frame nodes
2333         https://bugs.webkit.org/show_bug.cgi?id=180353
2334
2335         Reviewed by Antonio Gomes.
2336
2337         This function was introduced in bug 175135 to solve a rendering bug with fixed positioned
2338         nodes in overflow nodes. For a frame node, the reference frame to use for fixed nodes is
2339         actually the frame node itself or otherwise we will get the same rendering bug. This patch
2340         makes enclosingFrameNode return the node itself when it is a frame node and renames it to
2341         clarify this behavior. Currently, enclosingFrameNode is not used for frame nodes so the
2342         behavior is unchanged.
2343
2344         No new tests, behavior is unchanged.
2345
2346         * page/scrolling/ScrollingTreeNode.cpp:
2347         (WebCore::ScrollingTreeNode::enclosingFrameNodeIncludingSelf): Start the search from a frame
2348         scrolling node from the node itself. Renamed to make explicit that this function may include
2349         the node itself.
2350         * page/scrolling/ScrollingTreeNode.h: Renamed.
2351
2352 2017-12-04  Michael Catanzaro  <mcatanzaro@igalia.com>
2353
2354         [WPE][GTK] Implement PAL::SleepDisabler
2355         https://bugs.webkit.org/show_bug.cgi?id=178485
2356
2357         Reviewed by Carlos Garcia Campos.
2358
2359         Add a comment to warn about some odd use of SleepDisabler in HTMLMediaElement.
2360
2361         * html/HTMLMediaElement.cpp:
2362         (WebCore::HTMLMediaElement::shouldDisableSleep const):
2363
2364 2017-12-04  Frederic Wang  <fwang@igalia.com>
2365
2366         Bug 161300 - Move RenderMathMLRoot:RootType and RenderMathMLScripts:ScriptsType to element classes
2367         https://bugs.webkit.org/show_bug.cgi?id=161300
2368
2369         Reviewed by Darin Adler.
2370
2371         RenderMathMLRoot::m_kind and RenderMathMLScripts::m_scriptType are initialized in the
2372         constructors of the renderer classes from the tag name of the corresponding elements.
2373         This patch moves them into the corresponding element classes and makes them const members
2374         parsed in the constructors. It also introduces a MathMLRootElement class deriving from
2375         MathMLRowElement to store the new member. Finally, the types are redefined as enum classes.
2376
2377         No new tests, behavior unchanged and already covered by existing tests.
2378
2379         * Sources.txt: Add MathMLRootElement files.
2380         * WebCore.xcodeproj/project.pbxproj: Ditto.
2381         * mathml/MathMLAllInOne.cpp: Ditto.
2382         * mathml/MathMLRootElement.cpp:
2383         (WebCore::element): Override this function to downcast to MathMLRootElement.
2384         (WebCore::rootTypeOf): Helper function to parse the root type, moved from RenderMathMLRoot.
2385         (WebCore::MathMLRootElement::MathMLRootElement): Initialize the root type.
2386         (WebCore::MathMLRootElement::create):
2387         (WebCore::MathMLRootElement::createElementRenderer): Moved from MathMLRowElement.
2388         * mathml/MathMLRootElement.h: New class deriving from MathMLRowElement, with a RootType
2389         member exposed to the renderer class.
2390         * mathml/MathMLRowElement.cpp: Remove header for RenderMathMLRoot.h.
2391         (WebCore::MathMLRowElement::createElementRenderer): Moved to MathMLRootElement.
2392         * mathml/MathMLScriptsElement.cpp: Introduce a script type.
2393         (WebCore::scriptTypeOf): Helper function to parse the script type, moved from
2394         RenerMathMLScripts.
2395         (WebCore::MathMLScriptsElement::MathMLScriptsElement): Initialize the script type.
2396         * mathml/MathMLScriptsElement.h: Add new script type member.
2397         (WebCore::MathMLScriptsElement::scriptType const): Expose the script type to the renderer
2398         class.
2399         * mathml/mathtags.in: Map <msqrt> and <mroot> to MathMLRootElement.
2400         * rendering/mathml/RenderMathMLRoot.cpp:
2401         (WebCore::RenderMathMLRoot::RenderMathMLRoot): Use MathMLRootElement and remove parsing of
2402         the root type.
2403         (WebCore::RenderMathMLRoot::rootType const): Helper function to access the root type from
2404         the element class.
2405         (WebCore::RenderMathMLRoot::isValid const): Use rootType() and add prefix for enum class
2406         values.
2407         (WebCore::RenderMathMLRoot::getBase const): Ditto.
2408         (WebCore::RenderMathMLRoot::getIndex const): Ditto.
2409         (WebCore::RenderMathMLRoot::horizontalParameters): Ditto.
2410         (WebCore::RenderMathMLRoot::verticalParameters): Ditto.
2411         (WebCore::RenderMathMLRoot::computePreferredLogicalWidths): Ditto.
2412         (WebCore::RenderMathMLRoot::layoutBlock): Ditto.
2413         (WebCore::RenderMathMLRoot::paint): Ditto.
2414         * rendering/mathml/RenderMathMLRoot.h: Define root type as an enum class, replace
2415         MathMLRowElement with MathMLRootElement, declare and use new rootType() function and remove
2416         the m_kind member.
2417         * rendering/mathml/RenderMathMLScripts.cpp:
2418         (WebCore::RenderMathMLScripts::RenderMathMLScripts): Remove parsing of script type.
2419         (WebCore::RenderMathMLScripts::scriptType const): Helper function to access the script type
2420         from the element class.
2421         (WebCore::RenderMathMLScripts::validateAndGetReferenceChildren): Use scriptType() and add
2422         prefix for enum class values.
2423         (WebCore::RenderMathMLScripts::computePreferredLogicalWidths): Ditto.
2424         (WebCore::RenderMathMLScripts::verticalMetrics): Ditto.
2425         (WebCore::RenderMathMLScripts::layoutBlock): Ditto.
2426         * rendering/mathml/RenderMathMLScripts.h: Define root type as an enum class, declare the
2427         scriptType() function and remove the m_scriptType member.
2428         * rendering/mathml/RenderMathMLUnderOver.cpp:
2429         (WebCore::RenderMathMLUnderOver::isValid const): Use scriptType() and add prefix for enum
2430         class values.
2431         (WebCore::RenderMathMLUnderOver::under const): Ditto.
2432         (WebCore::RenderMathMLUnderOver::over const): Ditto.
2433         (WebCore::RenderMathMLUnderOver::computePreferredLogicalWidths): Ditto.
2434         (WebCore::RenderMathMLUnderOver::hasAccent const): Ditto.
2435         (WebCore::RenderMathMLUnderOver::layoutBlock): Ditto.
2436
2437 2017-12-04  Carlos Garcia Campos  <cgarcia@igalia.com>
2438
2439         [GStreamer] More leaks in TextCombinerGStreamer
2440         https://bugs.webkit.org/show_bug.cgi?id=180331
2441
2442         Reviewed by Michael Catanzaro.
2443
2444         I've noticed more leaks reading the code, but I couldn't check them with valgrind, because I don't know how to
2445         trigger that code path. This patch cleans up the file using smart pointer everywhere.
2446
2447         * platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
2448         (webkit_text_combiner_pad_init):
2449         (webkitTextCombinerPadEvent):
2450         (webkitTextCombinerReleasePad):
2451
2452 2017-12-04  Jer Noble  <jer.noble@apple.com>
2453
2454         Include 'video/*' in image request Accept header if browser supports video media in image contexts.
2455         https://bugs.webkit.org/show_bug.cgi?id=179178
2456
2457         Reviewed by Alex Christensen.
2458
2459         Test: http/tests/images/image-supports-video.html
2460
2461         Ensure that 'video/*' is included in the Accept header by asking the ImageDecoder whether "Video"
2462         media is supported. The ImageDecoder will ask all it's constituent decoders, which aside from
2463         ImageDecoderAVFObjC will say only support the "Image" media type.
2464
2465         Drive-by fix: Make sure the MIMETypeRegistry includes all the types supported by AVFoundation when
2466         ImageDecoderAVFObjC is enabled. Also, now that Image reports it can support video mime types, check
2467         whether MediaDocument can support a given mime type before asking ImageDocument.
2468
2469         * html/HTMLImageElement.cpp:
2470         (WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
2471         * loader/LinkLoader.cpp:
2472         (WebCore::LinkLoader::isSupportedType):
2473         * loader/cache/CachedResourceRequest.cpp:
2474         (WebCore::acceptHeaderValueFromType):
2475         * platform/MIMETypeRegistry.cpp:
2476         (WebCore::MIMETypeRegistry::isSupportedImageVideoOrSVGMIMEType):
2477         (WebCore::MIMETypeRegistry::isSupportedImageOrSVGMIMEType): Deleted.
2478         * platform/MIMETypeRegistry.h:
2479         * platform/graphics/ImageDecoder.cpp:
2480         (WebCore::ImageDecoder::supportsMediaType):
2481         * platform/graphics/ImageDecoder.h:
2482         * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h:
2483         (WebCore::ImageDecoderAVFObjC::supportsMediaType):
2484         * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
2485         (WebCore::ImageDecoderAVFObjC::supportsContentType):
2486         * platform/graphics/cg/ImageDecoderCG.h:
2487         * platform/graphics/win/ImageDecoderDirect2D.h:
2488         * platform/image-decoders/ScalableImageDecoder.h:
2489         (WebCore::ScalableImageDecoder::supportsMediaType):
2490         * html/parser/HTMLPreloadScanner.cpp:
2491         (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
2492
2493 2017-12-03  Yusuke Suzuki  <utatane.tea@gmail.com>
2494
2495         WTF shouldn't have both Thread and ThreadIdentifier
2496         https://bugs.webkit.org/show_bug.cgi?id=180308
2497
2498         Reviewed by Darin Adler.
2499
2500         No behavior change.
2501
2502         * Modules/indexeddb/IDBActiveDOMObject.h:
2503         (WebCore::IDBActiveDOMObject::originThread const):
2504         (WebCore::IDBActiveDOMObject::performCallbackOnOriginThread):
2505         (WebCore::IDBActiveDOMObject::callFunctionOnOriginThread):
2506         (WebCore::IDBActiveDOMObject::originThreadID const): Deleted.
2507         * Modules/indexeddb/IDBCursor.cpp:
2508         (WebCore::IDBCursor::IDBCursor):
2509         (WebCore::IDBCursor::~IDBCursor):
2510         (WebCore::IDBCursor::sourcesDeleted const):
2511         (WebCore::IDBCursor::transaction const):
2512         (WebCore::IDBCursor::update):
2513         (WebCore::IDBCursor::advance):
2514         (WebCore::IDBCursor::continueFunction):
2515         (WebCore::IDBCursor::uncheckedIterateCursor):
2516         (WebCore::IDBCursor::deleteFunction):
2517         (WebCore::IDBCursor::setGetResult):
2518         * Modules/indexeddb/IDBDatabase.cpp:
2519         (WebCore::IDBDatabase::~IDBDatabase):
2520         (WebCore::IDBDatabase::hasPendingActivity const):
2521         (WebCore::IDBDatabase::name const):
2522         (WebCore::IDBDatabase::version const):
2523         (WebCore::IDBDatabase::objectStoreNames const):
2524         (WebCore::IDBDatabase::renameObjectStore):
2525         (WebCore::IDBDatabase::renameIndex):
2526         (WebCore::IDBDatabase::createObjectStore):
2527         (WebCore::IDBDatabase::transaction):
2528         (WebCore::IDBDatabase::deleteObjectStore):
2529         (WebCore::IDBDatabase::close):
2530         (WebCore::IDBDatabase::connectionToServerLost):
2531         (WebCore::IDBDatabase::maybeCloseInServer):
2532         (WebCore::IDBDatabase::activeDOMObjectName const):
2533         (WebCore::IDBDatabase::canSuspendForDocumentSuspension const):
2534         (WebCore::IDBDatabase::stop):
2535         (WebCore::IDBDatabase::startVersionChangeTransaction):
2536         (WebCore::IDBDatabase::didStartTransaction):
2537         (WebCore::IDBDatabase::willCommitTransaction):
2538         (WebCore::IDBDatabase::didCommitTransaction):
2539         (WebCore::IDBDatabase::willAbortTransaction):
2540         (WebCore::IDBDatabase::didAbortTransaction):
2541         (WebCore::IDBDatabase::didCommitOrAbortTransaction):
2542         (WebCore::IDBDatabase::fireVersionChangeEvent):
2543         (WebCore::IDBDatabase::dispatchEvent):
2544         (WebCore::IDBDatabase::didCreateIndexInfo):
2545         (WebCore::IDBDatabase::didDeleteIndexInfo):
2546         * Modules/indexeddb/IDBIndex.cpp:
2547         (WebCore::IDBIndex::IDBIndex):
2548         (WebCore::IDBIndex::~IDBIndex):
2549         (WebCore::IDBIndex::name const):
2550         (WebCore::IDBIndex::setName):
2551         (WebCore::IDBIndex::objectStore):
2552         (WebCore::IDBIndex::keyPath const):
2553         (WebCore::IDBIndex::unique const):
2554         (WebCore::IDBIndex::multiEntry const):
2555         (WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):
2556         (WebCore::IDBIndex::openCursor):
2557         (WebCore::IDBIndex::openKeyCursor):
2558         (WebCore::IDBIndex::doCount):
2559         (WebCore::IDBIndex::doGet):
2560         (WebCore::IDBIndex::doGetKey):
2561         (WebCore::IDBIndex::getAll):
2562         (WebCore::IDBIndex::getAllKeys):
2563         (WebCore::IDBIndex::markAsDeleted):
2564         * Modules/indexeddb/IDBObjectStore.cpp:
2565         (WebCore::IDBObjectStore::IDBObjectStore):
2566         (WebCore::IDBObjectStore::~IDBObjectStore):
2567         (WebCore::IDBObjectStore::name const):
2568         (WebCore::IDBObjectStore::setName):
2569         (WebCore::IDBObjectStore::keyPath const):
2570         (WebCore::IDBObjectStore::indexNames const):
2571         (WebCore::IDBObjectStore::transaction):
2572         (WebCore::IDBObjectStore::autoIncrement const):
2573         (WebCore::IDBObjectStore::openCursor):
2574         (WebCore::IDBObjectStore::openKeyCursor):
2575         (WebCore::IDBObjectStore::get):
2576         (WebCore::IDBObjectStore::getKey):
2577         (WebCore::IDBObjectStore::putOrAdd):
2578         (WebCore::IDBObjectStore::doDelete):
2579         (WebCore::IDBObjectStore::clear):
2580         (WebCore::IDBObjectStore::createIndex):
2581         (WebCore::IDBObjectStore::index):
2582         (WebCore::IDBObjectStore::deleteIndex):
2583         (WebCore::IDBObjectStore::doCount):
2584         (WebCore::IDBObjectStore::getAll):
2585         (WebCore::IDBObjectStore::getAllKeys):
2586         (WebCore::IDBObjectStore::markAsDeleted):
2587         (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
2588         * Modules/indexeddb/IDBOpenDBRequest.cpp:
2589         (WebCore::IDBOpenDBRequest::~IDBOpenDBRequest):
2590         (WebCore::IDBOpenDBRequest::onError):
2591         (WebCore::IDBOpenDBRequest::versionChangeTransactionDidFinish):
2592         (WebCore::IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit):
2593         (WebCore::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
2594         (WebCore::IDBOpenDBRequest::dispatchEvent):
2595         (WebCore::IDBOpenDBRequest::onSuccess):
2596         (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
2597         (WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
2598         (WebCore::IDBOpenDBRequest::requestCompleted):
2599         (WebCore::IDBOpenDBRequest::requestBlocked):
2600         * Modules/indexeddb/IDBRequest.cpp:
2601         (WebCore::IDBRequest::~IDBRequest):
2602         (WebCore:: const):
2603         (WebCore::IDBRequest::setSource):
2604         (WebCore::IDBRequest::setVersionChangeTransaction):
2605         (WebCore::IDBRequest::transaction const):
2606         (WebCore::IDBRequest::sourceObjectStoreIdentifier const):
2607         (WebCore::IDBRequest::sourceIndexIdentifier const):
2608         (WebCore::IDBRequest::requestedObjectStoreRecordType const):
2609         (WebCore::IDBRequest::requestedIndexRecordType const):
2610         (WebCore::IDBRequest::eventTargetInterface const):
2611         (WebCore::IDBRequest::activeDOMObjectName const):
2612         (WebCore::IDBRequest::canSuspendForDocumentSuspension const):
2613         (WebCore::IDBRequest::hasPendingActivity const):
2614         (WebCore::IDBRequest::stop):
2615         (WebCore::IDBRequest::enqueueEvent):
2616         (WebCore::IDBRequest::dispatchEvent):
2617         (WebCore::IDBRequest::uncaughtExceptionInEventHandler):
2618         (WebCore::IDBRequest::setResult):
2619         (WebCore::IDBRequest::setResultToStructuredClone):
2620         (WebCore::IDBRequest::setResultToUndefined):
2621         (WebCore::IDBRequest::resultCursor):
2622         (WebCore::IDBRequest::willIterateCursor):
2623         (WebCore::IDBRequest::didOpenOrIterateCursor):
2624         (WebCore::IDBRequest::completeRequestAndDispatchEvent):
2625         (WebCore::IDBRequest::onError):
2626         (WebCore::IDBRequest::onSuccess):
2627         * Modules/indexeddb/IDBTransaction.cpp:
2628         (WebCore::IDBTransaction::IDBTransaction):
2629         (WebCore::IDBTransaction::~IDBTransaction):
2630         (WebCore::IDBTransaction::objectStoreNames const):
2631         (WebCore::IDBTransaction::db):
2632         (WebCore::IDBTransaction::error const):
2633         (WebCore::IDBTransaction::objectStore):
2634         (WebCore::IDBTransaction::abortDueToFailedRequest):
2635         (WebCore::IDBTransaction::transitionedToFinishing):
2636         (WebCore::IDBTransaction::abort):
2637         (WebCore::IDBTransaction::internalAbort):
2638         (WebCore::IDBTransaction::abortOnServerAndCancelRequests):
2639         (WebCore::IDBTransaction::activeDOMObjectName const):
2640         (WebCore::IDBTransaction::canSuspendForDocumentSuspension const):
2641         (WebCore::IDBTransaction::hasPendingActivity const):
2642         (WebCore::IDBTransaction::stop):
2643         (WebCore::IDBTransaction::isActive const):
2644         (WebCore::IDBTransaction::isFinishedOrFinishing const):
2645         (WebCore::IDBTransaction::addRequest):
2646         (WebCore::IDBTransaction::removeRequest):
2647         (WebCore::IDBTransaction::scheduleOperation):
2648         (WebCore::IDBTransaction::schedulePendingOperationTimer):
2649         (WebCore::IDBTransaction::pendingOperationTimerFired):
2650         (WebCore::IDBTransaction::operationCompletedOnServer):
2651         (WebCore::IDBTransaction::scheduleCompletedOperationTimer):
2652         (WebCore::IDBTransaction::completedOperationTimerFired):
2653         (WebCore::IDBTransaction::commit):
2654         (WebCore::IDBTransaction::commitOnServer):
2655         (WebCore::IDBTransaction::finishAbortOrCommit):
2656         (WebCore::IDBTransaction::didStart):
2657         (WebCore::IDBTransaction::notifyDidAbort):
2658         (WebCore::IDBTransaction::didAbort):
2659         (WebCore::IDBTransaction::didCommit):
2660         (WebCore::IDBTransaction::fireOnComplete):
2661         (WebCore::IDBTransaction::fireOnAbort):
2662         (WebCore::IDBTransaction::enqueueEvent):
2663         (WebCore::IDBTransaction::dispatchEvent):
2664         (WebCore::IDBTransaction::createObjectStore):
2665         (WebCore::IDBTransaction::createObjectStoreOnServer):
2666         (WebCore::IDBTransaction::didCreateObjectStoreOnServer):
2667         (WebCore::IDBTransaction::renameObjectStore):
2668         (WebCore::IDBTransaction::renameObjectStoreOnServer):
2669         (WebCore::IDBTransaction::didRenameObjectStoreOnServer):
2670         (WebCore::IDBTransaction::createIndex):
2671         (WebCore::IDBTransaction::createIndexOnServer):
2672         (WebCore::IDBTransaction::didCreateIndexOnServer):
2673         (WebCore::IDBTransaction::renameIndex):
2674         (WebCore::IDBTransaction::renameIndexOnServer):
2675         (WebCore::IDBTransaction::didRenameIndexOnServer):
2676         (WebCore::IDBTransaction::requestOpenCursor):
2677         (WebCore::IDBTransaction::doRequestOpenCursor):
2678         (WebCore::IDBTransaction::openCursorOnServer):
2679         (WebCore::IDBTransaction::didOpenCursorOnServer):
2680         (WebCore::IDBTransaction::iterateCursor):
2681         (WebCore::IDBTransaction::iterateCursorOnServer):
2682         (WebCore::IDBTransaction::didIterateCursorOnServer):
2683         (WebCore::IDBTransaction::requestGetAllObjectStoreRecords):
2684         (WebCore::IDBTransaction::requestGetAllIndexRecords):
2685         (WebCore::IDBTransaction::getAllRecordsOnServer):
2686         (WebCore::IDBTransaction::didGetAllRecordsOnServer):
2687         (WebCore::IDBTransaction::requestGetRecord):
2688         (WebCore::IDBTransaction::requestGetValue):
2689         (WebCore::IDBTransaction::requestGetKey):
2690         (WebCore::IDBTransaction::requestIndexRecord):
2691         (WebCore::IDBTransaction::getRecordOnServer):
2692         (WebCore::IDBTransaction::didGetRecordOnServer):
2693         (WebCore::IDBTransaction::requestCount):
2694         (WebCore::IDBTransaction::getCountOnServer):
2695         (WebCore::IDBTransaction::didGetCountOnServer):
2696         (WebCore::IDBTransaction::requestDeleteRecord):
2697         (WebCore::IDBTransaction::deleteRecordOnServer):
2698         (WebCore::IDBTransaction::didDeleteRecordOnServer):
2699         (WebCore::IDBTransaction::requestClearObjectStore):
2700         (WebCore::IDBTransaction::clearObjectStoreOnServer):
2701         (WebCore::IDBTransaction::didClearObjectStoreOnServer):
2702         (WebCore::IDBTransaction::requestPutOrAdd):
2703         (WebCore::IDBTransaction::putOrAddOnServer):
2704         (WebCore::IDBTransaction::didPutOrAddOnServer):
2705         (WebCore::IDBTransaction::deleteObjectStore):
2706         (WebCore::IDBTransaction::deleteObjectStoreOnServer):
2707         (WebCore::IDBTransaction::didDeleteObjectStoreOnServer):
2708         (WebCore::IDBTransaction::deleteIndex):
2709         (WebCore::IDBTransaction::deleteIndexOnServer):
2710         (WebCore::IDBTransaction::didDeleteIndexOnServer):
2711         (WebCore::IDBTransaction::operationCompletedOnClient):
2712         (WebCore::IDBTransaction::establishOnServer):
2713         (WebCore::IDBTransaction::activate):
2714         (WebCore::IDBTransaction::deactivate):
2715         * Modules/indexeddb/client/IDBConnectionProxy.cpp:
2716         (WebCore::IDBClient::removeItemsMatchingCurrentThread):
2717         * Modules/indexeddb/client/TransactionOperation.h:
2718         (WebCore::IDBClient::TransactionOperation::~TransactionOperation):
2719         (WebCore::IDBClient::TransactionOperation::perform):
2720         (WebCore::IDBClient::TransactionOperation::transitionToCompleteOnThisThread):
2721         (WebCore::IDBClient::TransactionOperation::transitionToComplete):
2722         (WebCore::IDBClient::TransactionOperation::doComplete):
2723         (WebCore::IDBClient::TransactionOperation::originThread const):
2724         (WebCore::IDBClient::TransactionOperation::originThreadID const): Deleted.
2725         * Modules/webaudio/AudioContext.cpp:
2726         (WebCore::AudioContext::AudioContext):
2727         (WebCore::AudioContext::lock):
2728         (WebCore::AudioContext::tryLock):
2729         (WebCore::AudioContext::unlock):
2730         (WebCore::AudioContext::isAudioThread const):
2731         (WebCore::AudioContext::isGraphOwner const):
2732         * Modules/webaudio/AudioContext.h:
2733         (WebCore::AudioContext::setAudioThread):
2734         (WebCore::AudioContext::audioThread const):
2735         * Modules/webaudio/AudioDestinationNode.cpp:
2736         (WebCore::AudioDestinationNode::render):
2737         * Modules/webdatabase/Database.cpp:
2738         (WebCore::Database::performClose):
2739         (WebCore::Database::securityOrigin):
2740         * Modules/webdatabase/DatabaseDetails.h:
2741         (WebCore::DatabaseDetails::DatabaseDetails):
2742         (WebCore::DatabaseDetails::operator=):
2743         (WebCore::DatabaseDetails::thread const):
2744         (WebCore::DatabaseDetails::threadID const): Deleted.
2745         * Modules/webdatabase/DatabaseManager.cpp:
2746         (WebCore::DatabaseManager::detailsForNameAndOrigin):
2747         * Modules/webdatabase/DatabaseThread.cpp:
2748         (WebCore::DatabaseThread::databaseThread):
2749         (WebCore::DatabaseThread::recordDatabaseOpen):
2750         (WebCore::DatabaseThread::recordDatabaseClosed):
2751         * Modules/webdatabase/DatabaseThread.h:
2752         (WebCore::DatabaseThread::getThread):
2753         (WebCore::DatabaseThread::getThreadID): Deleted.
2754         * Modules/webdatabase/SQLTransaction.cpp:
2755         (WebCore::SQLTransaction::checkAndHandleClosedDatabase):
2756         * Modules/webdatabase/SQLTransactionBackend.cpp:
2757         (WebCore::SQLTransactionBackend::doCleanup):
2758         (WebCore::SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown):
2759         * bindings/js/JSCallbackData.h:
2760         (WebCore::JSCallbackData::JSCallbackData):
2761         (WebCore::JSCallbackData::~JSCallbackData):
2762         * bindings/js/ScheduledAction.cpp:
2763         (WebCore::ScheduledAction::execute):
2764         * dom/ScriptExecutionContext.cpp:
2765         (WebCore::ScriptExecutionContext::createdMessagePort):
2766         (WebCore::ScriptExecutionContext::destroyedMessagePort):
2767         * page/ResourceUsageOverlay.h:
2768         * page/scrolling/ScrollingThread.cpp:
2769         (WebCore::ScrollingThread::isCurrentThread):
2770         * platform/Supplementable.h:
2771         (WebCore::Supplementable::provideSupplement):
2772         (WebCore::Supplementable::removeSupplement):
2773         (WebCore::Supplementable::requireSupplement):
2774         (WebCore::Supplementable::Supplementable): Deleted.
2775         * platform/Timer.cpp:
2776         (WebCore::TimerBase::TimerBase):
2777         (WebCore::TimerBase::start):
2778         (WebCore::TimerBase::stop):
2779         (WebCore::TimerBase::setNextFireTime):
2780         * platform/Timer.h:
2781         (WebCore::TimerBase::isActive const):
2782         * platform/graphics/cocoa/FontCacheCoreText.cpp:
2783         (WebCore::shouldAutoActivateFontIfNeeded):
2784         * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
2785         (WebCore::TextureMapperPlatformLayerProxy::activateOnCompositingThread):
2786         (WebCore::TextureMapperPlatformLayerProxy::invalidate):
2787         (WebCore::TextureMapperPlatformLayerProxy::getAvailableBuffer):
2788         (WebCore::TextureMapperPlatformLayerProxy::appendToUnusedBuffers):
2789         (WebCore::TextureMapperPlatformLayerProxy::swapBuffer):
2790         * platform/graphics/texmap/TextureMapperPlatformLayerProxy.h:
2791         (): Deleted.
2792         * platform/ios/wak/WebCoreThread.mm:
2793         (RunWebThread):
2794         (StartWebThread):
2795         * platform/sql/SQLiteDatabase.cpp:
2796         (WebCore::SQLiteDatabase::open):
2797         (WebCore::SQLiteDatabase::close):
2798         * platform/sql/SQLiteDatabase.h:
2799         (WebCore::SQLiteDatabase::sqlite3Handle const):
2800         * workers/WorkerGlobalScope.cpp:
2801         (WebCore::WorkerGlobalScope::~WorkerGlobalScope):
2802         (WebCore::WorkerGlobalScope::isContextThread const):
2803         * workers/WorkerMessagingProxy.cpp:
2804         (WebCore::WorkerMessagingProxy::WorkerMessagingProxy):
2805         (WebCore::WorkerMessagingProxy::~WorkerMessagingProxy):
2806         * workers/WorkerRunLoop.cpp:
2807         (WebCore::WorkerRunLoop::runInMode):
2808         (WebCore::WorkerRunLoop::runCleanupTasks):
2809         * workers/WorkerThread.h:
2810         (WebCore::WorkerThread::thread const):
2811         (WebCore::WorkerThread::threadID const): Deleted.
2812         * workers/service/ServiceWorkerContainer.cpp:
2813         (WebCore::ServiceWorkerContainer::~ServiceWorkerContainer):
2814         (WebCore::ServiceWorkerContainer::scheduleJob):
2815         (WebCore::ServiceWorkerContainer::jobFailedWithException):
2816         (WebCore::ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent):
2817         (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
2818         (WebCore::ServiceWorkerContainer::jobResolvedWithUnregistrationResult):
2819         (WebCore::ServiceWorkerContainer::startScriptFetchForJob):
2820         (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
2821         (WebCore::ServiceWorkerContainer::jobFailedLoadingScript):
2822         (WebCore::ServiceWorkerContainer::jobDidFinish):
2823         (WebCore::ServiceWorkerContainer::addRegistration):
2824         (WebCore::ServiceWorkerContainer::removeRegistration):
2825         (WebCore::ServiceWorkerContainer::scheduleTaskToFireControllerChangeEvent):
2826         (WebCore::ServiceWorkerContainer::contextIdentifier):
2827         * workers/service/ServiceWorkerContainer.h:
2828         * workers/service/ServiceWorkerJob.cpp:
2829         (WebCore::ServiceWorkerJob::~ServiceWorkerJob):
2830         (WebCore::ServiceWorkerJob::failedWithException):
2831         (WebCore::ServiceWorkerJob::resolvedWithRegistration):
2832         (WebCore::ServiceWorkerJob::resolvedWithUnregistrationResult):
2833         (WebCore::ServiceWorkerJob::startScriptFetch):
2834         (WebCore::ServiceWorkerJob::fetchScriptWithContext):
2835         (WebCore::ServiceWorkerJob::didReceiveResponse):
2836         (WebCore::ServiceWorkerJob::notifyFinished):
2837         * workers/service/ServiceWorkerJob.h:
2838         * xml/parser/XMLDocumentParserLibxml2.cpp:
2839         (WebCore::matchFunc):
2840         (WebCore::openFunc):
2841         (WebCore::initializeXMLParser):
2842         (WebCore::XMLParserContext::createStringParser):
2843         (WebCore::XMLParserContext::createMemoryParser):
2844
2845 2017-12-03  Youenn Fablet  <youenn@apple.com>
2846
2847         WebSocketChannel should ensure its client is live when calling it in error case
2848         https://bugs.webkit.org/show_bug.cgi?id=180285
2849
2850         Reviewed by Darin Adler.
2851
2852         No observable change of behavior.
2853         This makes it consistent with other calls of didReceiveMessageError.
2854
2855         * Modules/websockets/WebSocketChannel.cpp:
2856         (WebCore::WebSocketChannel::fail):
2857
2858 2017-12-03  Alexey Proskuryakov  <ap@apple.com>
2859
2860         WebArchiveResourceWebResourceHandler leaks when pasting
2861         https://bugs.webkit.org/show_bug.cgi?id=180339
2862
2863         Reviewed by Joseph Pecoraro.
2864
2865         * editing/cocoa/WebContentReaderCocoa.mm:
2866         (WebCore::attributesForAttributedStringConversion):
2867
2868 2017-12-03  Chris Dumez  <cdumez@apple.com>
2869
2870         Support serviceWorker.postMessage() inside service workers
2871         https://bugs.webkit.org/show_bug.cgi?id=180328
2872
2873         Reviewed by Darin Adler.
2874
2875         Support serviceWorker.postMessage() inside service workers.
2876
2877         No new tests, unskipped and rebaselined existing test that is
2878         now passing.
2879
2880         * workers/service/SWClientConnection.h:
2881         * workers/service/ServiceWorker.cpp:
2882         (WebCore::ServiceWorker::postMessage):
2883         * workers/service/context/SWContextManager.cpp:
2884         (WebCore::SWContextManager::postMessageToServiceWorker):
2885         * workers/service/context/SWContextManager.h:
2886         * workers/service/context/ServiceWorkerThread.cpp:
2887         (WebCore::fireMessageEvent):
2888         (WebCore::ServiceWorkerThread::postMessageToServiceWorker):
2889         * workers/service/context/ServiceWorkerThread.h:
2890
2891 2017-12-03  Chris Dumez  <cdumez@apple.com>
2892
2893         Implement self.skipWaiting() inside service workers
2894         https://bugs.webkit.org/show_bug.cgi?id=180329
2895
2896         Reviewed by Darin Adler.
2897
2898         Implement self.skipWaiting() inside service workers:
2899         - https://w3c.github.io/ServiceWorker/#service-worker-global-scope-skipwaiting
2900
2901         Also fixes a bug where tryActivate() was calling activate() even though the
2902         registration's active worker was "in use":
2903         - https://w3c.github.io/ServiceWorker/#try-activate-algorithm
2904
2905         No new tests, rebaselined existing tests.
2906
2907         * workers/service/ServiceWorkerGlobalScope.cpp:
2908         (WebCore::ServiceWorkerGlobalScope::skipWaiting):
2909         * workers/service/context/SWContextManager.h:
2910         * workers/service/server/SWServerRegistration.cpp:
2911         (WebCore::SWServerRegistration::tryActivate):
2912         * workers/service/server/SWServerToContextConnection.cpp:
2913         (WebCore::SWServerToContextConnection::skipWaiting):
2914         * workers/service/server/SWServerToContextConnection.h:
2915         * workers/service/server/SWServerWorker.cpp:
2916         (WebCore::SWServerWorker::skipWaiting):
2917         * workers/service/server/SWServerWorker.h:
2918         (WebCore::SWServerWorker::isSkipWaitingFlagSet const):
2919
2920 2017-12-03  Carlos Garcia Campos  <cgarcia@igalia.com>
2921
2922         [GStreamer] GstPad leaked in WebKitTextCombiner
2923         https://bugs.webkit.org/show_bug.cgi?id=180314
2924
2925         Reviewed by Michael Catanzaro.
2926
2927         gst_element_get_static_pad() returns a full reference that si never freed, because gst_ghost_pad_new doesn't
2928         take the ownership of the given pad.
2929
2930         * platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
2931         (webkit_text_combiner_init):
2932
2933 2017-12-03  Carlos Garcia Campos  <cgarcia@igalia.com>
2934
2935         [GStreamer] GstCaps leaked in MediaPlayerPrivateGStreamer::createGSTPlayBin
2936         https://bugs.webkit.org/show_bug.cgi?id=180311
2937
2938         Reviewed by Michael Catanzaro.
2939
2940         gst_caps_new_empty_simple() is passed directly to g_object_set(). The returned caps should be freed with
2941         gst_caps_unref().
2942
2943         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
2944         (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
2945
2946 2017-12-02  Youenn Fablet  <youenn@apple.com>
2947
2948         Move registration activation and clearing from SWServerJobQueue to SWServerRegistration
2949         https://bugs.webkit.org/show_bug.cgi?id=180325
2950
2951         Reviewed by Chris Dumez.
2952
2953         No change of behavior.
2954
2955         These algorithms fit naturally in SWServerRegistration and will be used as part of clients.claim.
2956
2957         * workers/service/server/SWServer.cpp:
2958         (WebCore::SWServer::clearAll):
2959         (WebCore::SWServer::didFinishActivation):
2960         * workers/service/server/SWServerJobQueue.cpp:
2961         (WebCore::SWServerJobQueue::scriptFetchFinished):
2962         (WebCore::SWServerJobQueue::scriptContextFailedToStart):
2963         (WebCore::SWServerJobQueue::didFinishInstall):
2964         (WebCore::SWServerJobQueue::runUnregisterJob):
2965         (WebCore::SWServerJobQueue::tryActivate): Deleted.
2966         (WebCore::SWServerJobQueue::activate): Deleted.
2967         (WebCore::SWServerJobQueue::didFinishActivation): Deleted.
2968         (WebCore::SWServerJobQueue::tryClearRegistration): Deleted.
2969         (WebCore::clearRegistrationWorker): Deleted.
2970         (WebCore::SWServerJobQueue::clearRegistration): Deleted.
2971         * workers/service/server/SWServerJobQueue.h:
2972         * workers/service/server/SWServerRegistration.cpp:
2973         (WebCore::SWServerRegistration::tryClear):
2974         (WebCore::clearRegistrationWorker):
2975         (WebCore::SWServerRegistration::clear):
2976         (WebCore::SWServerRegistration::tryActivate):
2977         (WebCore::SWServerRegistration::activate):
2978         (WebCore::SWServerRegistration::didFinishActivation):
2979         * workers/service/server/SWServerRegistration.h:
2980
2981 2017-12-02  Chris Dumez  <cdumez@apple.com>
2982
2983         Support container.register() / registration.unregister() /  inside service workers
2984         https://bugs.webkit.org/show_bug.cgi?id=180326
2985
2986         Reviewed by Youenn Fablet.
2987
2988         Support container.register() / registration.unregister() /  inside service workers.
2989         This is mostly about removing the is<Document>() checks and adding testing given
2990         that most of the work was done in r225455.
2991
2992         Test: http/tests/workers/service/ServiceWorkerGlobalScope_register.html
2993
2994         * workers/service/ServiceWorkerContainer.cpp:
2995         (WebCore::ServiceWorkerContainer::addRegistration):
2996         * workers/service/ServiceWorkerRegistration.cpp:
2997         (WebCore::ServiceWorkerRegistration::update):
2998         (WebCore::ServiceWorkerRegistration::unregister):
2999
3000 2017-12-02  Chris Dumez  <cdumez@apple.com>
3001
3002         Support serviceWorkerRegistration.update() inside service workers
3003         https://bugs.webkit.org/show_bug.cgi?id=180215
3004
3005         Reviewed by Darin Adler.
3006
3007         Support serviceWorkerRegistration.update() inside service workers. The code paths
3008         for job scheduling and resolution have been made thread safe by hopping to the right
3009         thread when necessary. In particular, ServiceWorkerContainer always makes sure to to
3010         a callOnMainThread() before calling methods on the SWClientConnection. Also, the
3011         SWClientConnection relies on a new postTaskTo() method before calling methods on the
3012         job.
3013
3014         Test: http/tests/workers/service/self_registration_update.html
3015
3016         * workers/service/SWClientConnection.cpp:
3017         (WebCore::SWClientConnection::scheduleJob):
3018         (WebCore::SWClientConnection::finishedFetchingScript):
3019         (WebCore::SWClientConnection::failedFetchingScript):
3020         (WebCore::SWClientConnection::jobRejectedInServer):
3021         (WebCore::SWClientConnection::registrationJobResolvedInServer):
3022         (WebCore::SWClientConnection::unregistrationJobResolvedInServer):
3023         (WebCore::SWClientConnection::startScriptFetchForServer):
3024         (WebCore::SWClientConnection::postMessageToServiceWorkerClient):
3025         (WebCore::SWClientConnection::updateRegistrationState):
3026         (WebCore::SWClientConnection::updateWorkerState):
3027         (WebCore::SWClientConnection::fireUpdateFoundEvent):
3028         (WebCore::SWClientConnection::notifyClientsOfControllerChange):
3029         (WebCore::SWClientConnection::clearPendingJobs):
3030         (WebCore::SWClientConnection::postTaskTo):
3031         * workers/service/SWClientConnection.h:
3032         * workers/service/ServiceWorkerContainer.cpp:
3033         (WebCore::ServiceWorkerContainer::scheduleJob):
3034         (WebCore::ServiceWorkerContainer::jobFailedWithException):
3035         (WebCore::ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent):
3036         (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
3037         (WebCore::ServiceWorkerContainer::jobResolvedWithUnregistrationResult):
3038         (WebCore::ServiceWorkerContainer::startScriptFetchForJob):
3039         (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
3040         (WebCore::ServiceWorkerContainer::jobFailedLoadingScript):
3041         (WebCore::ServiceWorkerContainer::jobDidFinish):
3042         (WebCore::ServiceWorkerContainer::addRegistration):
3043         (WebCore::ServiceWorkerContainer::removeRegistration):
3044         (WebCore::ServiceWorkerContainer::scheduleTaskToFireControllerChangeEvent):
3045         (WebCore::ServiceWorkerContainer::contextIdentifier):
3046         * workers/service/ServiceWorkerContainer.h:
3047         * workers/service/ServiceWorkerJob.cpp:
3048         (WebCore::ServiceWorkerJob::ServiceWorkerJob):
3049         * workers/service/ServiceWorkerJob.h:
3050         (WebCore::ServiceWorkerJob::contextIdentifier):
3051         * workers/service/ServiceWorkerJobClient.h:
3052         * workers/service/ServiceWorkerRegistration.cpp:
3053         (WebCore::ServiceWorkerRegistration::update):
3054         * workers/service/ServiceWorkerTypes.h:
3055
3056 2017-12-02  Simon Fraser  <simon.fraser@apple.com>
3057
3058         Make IOSurface::Locker and use it in ImageBufferDataCG
3059         https://bugs.webkit.org/show_bug.cgi?id=180317
3060
3061         Reviewed by Zalan Bujtas.
3062
3063         Add an RAII IOSurface::Locker which can lock readonly or readwrite. Access
3064         to the IOSurface base address is through the locker.
3065         
3066         Add IOSurface::bytesPerRow() to wrap IOSurfaceGetBytesPerRow().
3067         
3068         After this, there is only one location where we access the IOSurfaceRef
3069         directly, in WebGL code.
3070
3071         * platform/graphics/cg/ImageBufferDataCG.cpp:
3072         (WebCore::ImageBufferData::toBGRAData const):
3073         (WebCore::ImageBufferData::getData const):
3074         (WebCore::ImageBufferData::putData):
3075         * platform/graphics/cocoa/IOSurface.h:
3076         * platform/graphics/cocoa/IOSurface.mm:
3077         (WebCore::IOSurface::bytesPerRow const):
3078
3079 2017-12-02  Simon Fraser  <simon.fraser@apple.com>
3080
3081         Add an AlphaPremultiplication enum and use it consistently
3082         https://bugs.webkit.org/show_bug.cgi?id=180316
3083
3084         Reviewed by Zalan Bujtas.
3085
3086         ImageBuffer-related code sometimes used the 'Multiply' enum, and sometimes
3087         a bool to represent alpha premultiplication. Make an enum class and use it
3088         everywhere. Re-order and rename some parameters to clarify the meaning of this
3089         argument.
3090
3091         * html/canvas/CanvasRenderingContext2D.cpp:
3092         (WebCore::CanvasRenderingContext2D::putImageData):
3093         * platform/graphics/GraphicsTypes.cpp:
3094         (WebCore::operator<<):
3095         * platform/graphics/GraphicsTypes.h:
3096         * platform/graphics/ImageBuffer.cpp:
3097         (WebCore::ImageBuffer::genericConvertToLuminanceMask):
3098         * platform/graphics/ImageBuffer.h:
3099         * platform/graphics/ShadowBlur.cpp:
3100         (WebCore::ShadowBlur::blurShadowBuffer):
3101         * platform/graphics/cairo/ImageBufferCairo.cpp:
3102         (WebCore::getImageData):
3103         (WebCore::ImageBuffer::getUnmultipliedImageData const):
3104         (WebCore::ImageBuffer::getPremultipliedImageData const):
3105         (WebCore::ImageBuffer::putByteArray):
3106         * platform/graphics/cg/ImageBufferCG.cpp:
3107         (WebCore::ImageBuffer::getUnmultipliedImageData const):
3108         (WebCore::ImageBuffer::getPremultipliedImageData const):
3109         (WebCore::ImageBuffer::putByteArray):
3110         * platform/graphics/cg/ImageBufferDataCG.cpp:
3111         (WebCore::ImageBufferData::getData const):
3112         (WebCore::ImageBufferData::putData):
3113         * platform/graphics/cg/ImageBufferDataCG.h:
3114         * platform/graphics/filters/FEColorMatrix.cpp:
3115         (WebCore::FEColorMatrix::platformApplySoftware):
3116         * platform/graphics/filters/FEDropShadow.cpp:
3117         (WebCore::FEDropShadow::platformApplySoftware):
3118         * platform/graphics/filters/FilterEffect.cpp:
3119         (WebCore::FilterEffect::imageBufferResult):
3120         * platform/graphics/win/ImageBufferDataDirect2D.cpp:
3121         (WebCore::ImageBufferData::getData const):
3122         (WebCore::ImageBufferData::putData):
3123         * platform/graphics/win/ImageBufferDataDirect2D.h:
3124         * platform/graphics/win/ImageBufferDirect2D.cpp:
3125         (WebCore::ImageBuffer::getUnmultipliedImageData const):
3126         (WebCore::ImageBuffer::getPremultipliedImageData const):
3127         (WebCore::ImageBuffer::putByteArray):
3128
3129 2017-12-02  Youenn Fablet  <youenn@apple.com>
3130
3131         Implement https://w3c.github.io/ServiceWorker/#clients-getall
3132         https://bugs.webkit.org/show_bug.cgi?id=180276
3133
3134         Reviewed by Chris Dumez.
3135
3136         Test: http/tests/workers/service/serviceworkerclients-matchAll.https.html
3137
3138         Move Clients QueryOptions to its own class since it is used by various parties.
3139         Add encoder/decoder routines.
3140
3141         Add a ServieWorkerClientInformation which replaces SWServer::ClientInformation structure.
3142         This is what is sent back as a result to matchAll requests.
3143         Add encoder/decoder routines.
3144
3145         Implement matchAll by hopping to the main thread, making IPC to the storage process.
3146         SWServer in storage process then iterates through the relevant service workers and does some filtering.
3147         Additional filtering and information should be gathered in future patches to fully implement the algorithm.
3148
3149         Add to SWServer a HashMap to easily identify by which service worker a client is controlled, if any.
3150         This map is updated at the same time registrations are updated.
3151
3152         matchAll is given a callback as in the future, window client information will be retrieved asynchronously.
3153
3154         * WebCore.xcodeproj/project.pbxproj:
3155         * workers/service/ServiceWorkerClientInformation.h: Added.
3156         (WebCore::ServiceWorkerClientInformation::isolatedCopy const):
3157         (WebCore::ServiceWorkerClientInformation::encode const):
3158         (WebCore::ServiceWorkerClientInformation::decode):
3159         * workers/service/ServiceWorkerClientQueryOptions.h: Added.
3160         (WebCore::ServiceWorkerClientQueryOptions::encode const):
3161         (WebCore::ServiceWorkerClientQueryOptions::decode):
3162         * workers/service/ServiceWorkerClients.cpp:
3163         (WebCore::ServiceWorkerClients::matchAll):
3164         * workers/service/ServiceWorkerClients.h:
3165         * workers/service/context/SWContextManager.h:
3166         * workers/service/server/SWServer.cpp:
3167         (WebCore::SWServer::matchAll):
3168         (WebCore::SWServer::registerServiceWorkerClient):
3169         * workers/service/server/SWServer.h:
3170         * workers/service/server/SWServerToContextConnection.cpp:
3171         (WebCore::SWServerToContextConnection::matchAll):
3172         * workers/service/server/SWServerToContextConnection.h:
3173         * workers/service/server/SWServerWorker.cpp:
3174         (WebCore::SWServerWorker::matchAll):
3175         * workers/service/server/SWServerWorker.h:
3176
3177 2017-12-02  Brady Eidson  <beidson@apple.com>
3178
3179         Factor out the "databaseTaskQueue" parts of IDBServer into something reusable.
3180         https://bugs.webkit.org/show_bug.cgi?id=180298
3181
3182         Reviewed by Chris Dumez.
3183
3184         No new tests (Refactor only).
3185
3186         * Modules/indexeddb/server/IDBServer.cpp:
3187         (WebCore::IDBServer::IDBServer::IDBServer):
3188         (WebCore::IDBServer::IDBServer::postDatabaseTask):
3189         (WebCore::IDBServer::IDBServer::postDatabaseTaskReply):
3190         (WebCore::IDBServer::IDBServer::databaseRunLoop): Deleted.
3191         (WebCore::IDBServer::IDBServer::handleTaskRepliesOnMainThread): Deleted.
3192         * Modules/indexeddb/server/IDBServer.h:
3193         (): Deleted.
3194
3195 2017-12-02  Simon Fraser  <simon.fraser@apple.com>
3196
3197         Add a log channel for viewports
3198         https://bugs.webkit.org/show_bug.cgi?id=180295
3199
3200         Reviewed by Zalan Bujtas.
3201
3202         Add a "Viewports" log channel to log viewport scaling information, and enhance the
3203         WebKit "VisibleRects" channel to log additional data for the same reason.
3204
3205         * dom/Document.cpp:
3206         (WebCore::Document::processViewport):
3207         * loader/FrameLoader.cpp:
3208         (WebCore::FrameLoader::finishedParsing):
3209         (WebCore::FrameLoader::completed):
3210         * page/FrameView.cpp:
3211         (WebCore::FrameView::resetScrollbarsAndClearContentsSize):
3212         (WebCore::FrameView::scrollToAnchor):
3213         (WebCore::FrameView::maintainScrollPositionAtAnchor):
3214         (WebCore::FrameView::setScrollPosition):
3215         (WebCore::FrameView::autoSizeIfEnabled):
3216         (WebCore::FrameView::setWasScrolledByUser):
3217         * page/LayoutContext.cpp:
3218         (WebCore::LayoutContext::layout):
3219         * page/Page.cpp:
3220         (WebCore::Page::setPageScaleFactor):
3221         * page/ViewportConfiguration.cpp:
3222         (WebCore::ViewportConfiguration::setContentsSize):
3223         (WebCore::ViewportConfiguration::setViewportArguments):
3224         (WebCore::ViewportConfiguration::updateConfiguration):
3225         (WebCore::operator<<):
3226         (WebCore::ViewportConfiguration::description const):
3227         (WebCore::ViewportConfiguration::dump const):
3228         * page/ViewportConfiguration.h:
3229         * platform/Logging.h:
3230         * platform/ScrollView.cpp:
3231         (WebCore::ScrollView::setFixedLayoutSize):
3232
3233 2017-12-01  Alicia Boya GarcĂ­a  <aboya@igalia.com>
3234
3235         [MSE] Use correct range end checks in sourceBufferPrivateDidReceiveSample()
3236         https://bugs.webkit.org/show_bug.cgi?id=179690
3237
3238         Reviewed by Jer Noble.
3239
3240         The Coded Frame Processing algorithm as defined in
3241         https://www.w3.org/TR/media-source/#sourcebuffer-coded-frame-processing states:
3242
3243         1.14. Remove existing coded frames in track buffer:
3244          -> If highest end timestamp for track buffer is not set:
3245                [...]
3246          -> If highest end timestamp for track buffer is set and less than or
3247             equal to presentation timestamp:
3248                Remove all coded frames from track buffer that have a
3249                presentation timestamp greater than or equal to highest end
3250                timestamp and less than frame end timestamp.
3251
3252         Note the removal range is closed-open [a, b). WebKit is actually removing
3253         frames using an open-closed range (a, b], which causes frames not to be removed
3254         in situations where they should and frames to be removed in situations when
3255         they should not.
3256
3257         Tests: media/media-source/media-source-range-end-frame-not-removed.html
3258                media/media-source/media-source-range-start-frame-replaced.html
3259
3260         * Modules/mediasource/SampleMap.cpp:
3261         (WebCore::PresentationOrderSampleMap::findSamplesBetweenPresentationTimesFromEnd):
3262         * Modules/mediasource/SampleMap.h:
3263         * Modules/mediasource/SourceBuffer.cpp:
3264         (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
3265
3266 2017-12-01  Simon Fraser  <simon.fraser@apple.com>
3267
3268         Reduce the number of calls to ViewportConfiguration::updateConfiguration()
3269         https://bugs.webkit.org/show_bug.cgi?id=180299
3270
3271         Reviewed by Zalan Bujtas.
3272
3273         There are several calls to ViewportConfiguration::setDefaultConfiguration() during loading
3274         with the same arguments. We can avoid unnecessary calls to updateConfiguration() by returning
3275         early if the configuration hasn't changed.
3276
3277         * page/ViewportConfiguration.cpp:
3278         (WebCore::ViewportConfiguration::setDefaultConfiguration):
3279         * page/ViewportConfiguration.h:
3280         (WebCore::ViewportConfiguration::Parameters::operator== const):
3281
3282 2017-12-01  Aishwarya Nirmal  <anirmal@apple.com>
3283
3284         [Touch Bar Web API] Object representing Touch Bar Menu to send between Web and UI Processes
3285         https://bugs.webkit.org/show_bug.cgi?id=179714
3286
3287         Reviewed by Wenson Hsieh.
3288
3289         These changes allow the HTMLMenuElement and HTMLMenuItemElement to parse attributes relating
3290         to the touch bar and convey changes to the elements that will eventually be propogated to the
3291         UI process.
3292
3293         No new tests at this point because the changes to HTMLMenuElement and HTMLMenuItemElement are
3294         new properties, which might not be worth testing, and overriden methods for insertedIntoAncestor
3295         and removedFromAncestor, which are involved in sending a message to a UI process but might be
3296         difficult to test at this point since the UI process only receives (and does not yet process)
3297         the message.
3298
3299         * html/HTMLMenuElement.cpp:
3300         (WebCore::HTMLMenuElement::insertedIntoAncestor):
3301         (WebCore::HTMLMenuElement::removedFromAncestor):
3302         (WebCore::HTMLMenuElement::parseAttribute):
3303         * html/HTMLMenuElement.h:
3304         * html/HTMLMenuItemElement.cpp:
3305         (WebCore::HTMLMenuItemElement::insertedIntoAncestor):
3306         (WebCore::HTMLMenuItemElement::removedFromAncestor):
3307         * html/HTMLMenuItemElement.h:
3308         * page/ChromeClient.h:
3309
3310 2017-12-01  Daniel Bates  <dabates@apple.com>
3311
3312         AlternativePresentationButtonSubstitution::unapply() may not undo substitution
3313         https://bugs.webkit.org/show_bug.cgi?id=180279
3314         <rdar://problem/35800599>
3315
3316         Reviewed by Simon Fraser.
3317
3318         Fixes an issue where removing an alternative presentation button substituted for a non-HTML input
3319         element did not restore the original appearance of the element before the substitution.
3320
3321         To substitute the alternative presentation button for a non-HTML input element we attach a
3322         user-agent shadow root to it. Adding a shadow root, including a user-agent shadow root,
3323         tears down the existing renderers for the element. Currently when we unapply such a substitution
3324         we ultimately just remove the shadow root and do not create new renderers for the subtree
3325         that the shadow root was removed from. We need to create new renderers for this subtree
3326         to restore the original appearance of the element before the substitution.
3327
3328         * editing/cocoa/AlternativePresentationButtonSubstitution.cpp:
3329         (WebCore::AlternativePresentationButtonSubstitution::unapply):
3330
3331 2017-12-01  Christopher Reid  <chris.reid@sony.com>
3332
3333         Move DateComponents into WTF
3334         https://bugs.webkit.org/show_bug.cgi?id=180211
3335
3336         Reviewed by Myles C. Maxfield.
3337
3338         No new tests no change in behavior.
3339
3340         Moved DateComponents from platform into WTF.
3341
3342         * Sources.txt: Removed DateComponents
3343         * WebCore.xcodeproj/project.pbxproj: Removed DateComponents
3344         * dom/Document.cpp:
3345         * html/BaseDateAndTimeInputType.h:
3346         * html/DateTimeInputType.h: Fixed a call to the wrong parent constructor
3347         * html/HTMLInputElement.h:
3348         * html/InputType.cpp:
3349         * html/InputType.h:
3350         * platform/text/PlatformLocale.cpp:
3351         * platform/text/PlatformLocale.h:
3352         * platform/text/ios/LocalizedDateCache.h:
3353         * platform/text/mac/LocaleMac.h:
3354         * platform/text/win/LocaleWin.cpp:
3355         * platform/text/win/LocaleWin.h:
3356         * rendering/RenderThemeIOS.mm:
3357
3358 2017-12-01  Daniel Bates  <dabates@apple.com>
3359
3360         Alternative Presentation Button: Provide a way to query for the replaced elements
3361         https://bugs.webkit.org/show_bug.cgi?id=180114
3362         <rdar://problem/35710539>
3363
3364         Reviewed by Tim Horton.
3365
3366         Add SPI to query for the elements that were replaced by an Alternative Presentation Button.
3367
3368         Test: fast/forms/alternative-presentation-button/replaced-elements.html
3369
3370         * editing/Editor.cpp:
3371         (WebCore::Editor::elementsReplacedByAlternativePresentationButton): Added.
3372         * editing/Editor.h:
3373         * editing/cocoa/AlternativePresentationButtonSubstitution.cpp:
3374         (WebCore::AlternativePresentationButtonSubstitution::replacedElements): Added.
3375         * editing/cocoa/AlternativePresentationButtonSubstitution.h:
3376         * testing/Internals.cpp:
3377         (WebCore::Internals::elementsReplacedByAlternativePresentationButton): Added.
3378         * testing/Internals.h:
3379         * testing/Internals.idl: Expose internals function elementsReplacedByAlternativePresentationButton()
3380         so as to test Editor::elementsReplacedByAlternativePresentationButton().
3381
3382 2017-12-01  Said Abou-Hallawa  <sabouhallawa@apple.com>
3383
3384         Rename ImageFrameCache to ImageSource
3385         https://bugs.webkit.org/show_bug.cgi?id=180172
3386
3387         Reviewed by Per Arne Vollan.
3388
3389         This is a follow-up for r225300. ImageSource is the intended name after
3390         merging ImageFrameCache and ImageSource.
3391
3392         * Sources.txt:
3393         * WebCore.xcodeproj/project.pbxproj:
3394         * platform/graphics/BitmapImage.cpp:
3395         (WebCore::BitmapImage::BitmapImage):
3396         * platform/graphics/BitmapImage.h:
3397         * platform/graphics/ImageFrame.h:
3398         * platform/graphics/ImageFrameCache.cpp: Removed.
3399         * platform/graphics/ImageFrameCache.h: Removed.
3400         * platform/graphics/ImageSource.cpp: Added.
3401         (WebCore::ImageSource::ImageSource):
3402         (WebCore::ImageSource::~ImageSource):
3403         (WebCore::ImageSource::ensureDecoderAvailable):
3404         (WebCore::ImageSource::setData):
3405         (WebCore::ImageSource::resetData):
3406         (WebCore::ImageSource::dataChanged):
3407         (WebCore::ImageSource::isAllDataReceived):
3408         (WebCore::ImageSource::destroyDecodedData):
3409         (WebCore::ImageSource::destroyIncompleteDecodedData):
3410         (WebCore::ImageSource::clearFrameBufferCache):
3411         (WebCore::ImageSource::decodedSizeChanged):
3412         (WebCore::ImageSource::decodedSizeIncreased):
3413         (WebCore::ImageSource::decodedSizeDecreased):
3414         (WebCore::ImageSource::decodedSizeReset):
3415         (WebCore::ImageSource::didDecodeProperties):
3416         (WebCore::ImageSource::growFrames):
3417         (WebCore::ImageSource::setNativeImage):
3418         (WebCore::ImageSource::cacheMetadataAtIndex):
3419         (WebCore::ImageSource::cacheNativeImageAtIndex):
3420         (WebCore::ImageSource::cacheNativeImageAtIndexAsync):
3421         (WebCore::ImageSource::decodingQueue):
3422         (WebCore::ImageSource::frameRequestQueue):
3423         (WebCore::ImageSource::canUseAsyncDecoding):
3424         (WebCore::ImageSource::startAsyncDecodingQueue):
3425         (WebCore::ImageSource::requestFrameAsyncDecodingAtIndex):
3426         (WebCore::ImageSource::isAsyncDecodingQueueIdle const):
3427         (WebCore::ImageSource::stopAsyncDecodingQueue):
3428         (WebCore::ImageSource::frameAtIndexCacheIfNeeded):
3429         (WebCore::ImageSource::clearMetadata):
3430         (WebCore::ImageSource::sourceURL const):
3431         (WebCore::ImageSource::mimeType const):
3432         (WebCore::ImageSource::expectedContentLength const):
3433         (WebCore::ImageSource::metadata):
3434         (WebCore::ImageSource::frameMetadataAtIndex):
3435         (WebCore::ImageSource::frameMetadataAtIndexCacheIfNeeded):
3436         (WebCore::ImageSource::encodedDataStatus):
3437         (WebCore::ImageSource::frameCount):
3438         (WebCore::ImageSource::repetitionCount):
3439         (WebCore::ImageSource::uti):
3440         (WebCore::ImageSource::filenameExtension):
3441         (WebCore::ImageSource::hotSpot):
3442         (WebCore::ImageSource::size):
3443         (WebCore::ImageSource::sizeRespectingOrientation):
3444         (WebCore::ImageSource::singlePixelSolidColor):
3445         (WebCore::ImageSource::maximumSubsamplingLevel):
3446         (WebCore::ImageSource::frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex):
3447         (WebCore::ImageSource::frameDecodingStatusAtIndex):
3448         (WebCore::ImageSource::frameHasAlphaAtIndex):
3449         (WebCore::ImageSource::frameHasFullSizeNativeImageAtIndex):
3450         (WebCore::ImageSource::frameHasDecodedNativeImageCompatibleWithOptionsAtIndex):
3451         (WebCore::ImageSource::frameSubsamplingLevelAtIndex):
3452         (WebCore::ImageSource::frameSizeAtIndex):
3453         (WebCore::ImageSource::frameBytesAtIndex):
3454         (WebCore::ImageSource::frameDurationAtIndex):
3455         (WebCore::ImageSource::frameOrientationAtIndex):
3456         (WebCore::ImageSource::setTargetContext):
3457         (WebCore::ImageSource::createFrameImageAtIndex):
3458         (WebCore::ImageSource::frameImageAtIndex):
3459         (WebCore::ImageSource::frameImageAtIndexCacheIfNeeded):
3460         (WebCore::ImageSource::dump):
3461         * platform/graphics/ImageSource.h: Added.
3462         (WebCore::ImageSource::create):
3463         (WebCore::ImageSource::decodedSize const):
3464         (WebCore::ImageSource::destroyAllDecodedData):
3465         (WebCore::ImageSource::destroyAllDecodedDataExcludeFrame):
3466         (WebCore::ImageSource::destroyDecodedDataBeforeFrame):
3467         (WebCore::ImageSource::clearImage):
3468         (WebCore::ImageSource::requestFrameAsyncDecodingAtIndex):
3469         (WebCore::ImageSource::hasAsyncDecodingQueue const):
3470         (WebCore::ImageSource::isSizeAvailable):
3471         (WebCore::ImageSource::isDecoderAvailable const):
3472         (WebCore::ImageSource::frameAtIndexCacheIfNeeded):
3473         (WebCore::ImageSource::ImageFrameRequest::operator== const):
3474         * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
3475         (WebCore::GraphicsContext3D::ImageExtractor::extractImage):
3476         * platform/graphics/cg/GraphicsContext3DCG.cpp: