[WebIDL] Support callbacks with arbitrary return types
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-05-22  Sam Weinig  <sam@webkit.org>
2
3         [WebIDL] Support callbacks with arbitrary return types
4         https://bugs.webkit.org/show_bug.cgi?id=172407
5
6         Reviewed by Chris Dumez.
7
8         - Adds and adopts CallbackResult<> template class that encapsulates a return value
9           and status from a javascript callback.
10         - Updates NodeIterator/TreeWalker to explicitly propagate exceptions thrown from
11           a JSNodeFilter, rather than relying on the JSNodeFilter to catch them (seemingly
12           accidentally).
13
14         * CMakeLists.txt:
15         * WebCore.xcodeproj/project.pbxproj:
16         * bindings/js/JSBindingsAllInOne.cpp:
17         Update file lists.
18
19         * Modules/geolocation/PositionCallback.h:
20         * Modules/geolocation/PositionErrorCallback.h:
21         * Modules/notifications/NotificationPermissionCallback.h:
22         * Modules/webaudio/AudioBufferCallback.h:
23         * Modules/webdatabase/DatabaseCallback.h:
24         * dom/RequestAnimationFrameCallback.h:
25         * dom/StringCallback.h:
26         * dom/Traversal.cpp:
27         * fileapi/BlobCallback.h:
28         * html/VoidCallback.h:
29         * page/IntersectionObserverCallback.h:
30         * page/PerformanceObserverCallback.h:
31         * css/MediaQueryListListener.h:
32         * Modules/webdatabase/SQLStatement.h:
33         * Modules/webdatabase/SQLStatementCallback.h:
34         * Modules/webdatabase/SQLStatementErrorCallback.h:
35         * Modules/webdatabase/SQLTransaction.cpp:
36         * Modules/webdatabase/SQLTransactionCallback.h:
37         * Modules/webdatabase/SQLTransactionErrorCallback.h:
38         * inspector/InspectorDatabaseAgent.cpp:
39         Adopt CallbackResult.
40
41         * Modules/webdatabase/SQLStatementErrorCallback.idl:
42         Remove Custom extended attribute annotation.
43
44         * Modules/webdatabase/SQLStatement.cpp:
45         (WebCore::SQLStatement::performCallback):
46         Adopt CallbackResult, migrating logic from JSSQLStatementErrorCallbackCustom
47         into the implementation, by way of the status enum.
48
49         * bindings/IDLTypes.h:
50         Add IDLVoid type.
51
52         * bindings/js/JSNodeFilterCustom.cpp: Removed.
53         * bindings/js/JSSQLStatementErrorCallbackCustom.cpp: Removed.
54         Remove now unneeded custom bindings.
55
56         * bindings/scripts/CodeGeneratorJS.pm:
57         (GenerateIndexedGetter):
58         (GenerateNamedGetter):
59         (GenerateImplementation):
60         (GenerateImplementationFunctionCall):
61         Update for new NativeToJSValue arguments.
62
63         (GenerateCallbackHeaderContent):
64         (GenerateCallbackImplementationContent):
65         Remove requirement of only void return types and update return type to use CallbackFunction.
66         Also adds necessary conversion of return value.
67
68         (GetBaseIDLType):
69         Add void IDL type mapping.
70
71         (IsValidContextForJSValueToNative):
72         Add operation as valid context, as that is what the callback return type's context is.
73
74         (NativeToJSValueUsingReferences):
75         (NativeToJSValueUsingPointers):
76         (NativeToJSValue):
77         Rework NativeToJSValueUsingReferences/NativeToJSValueUsingPointers to take a global object reference
78         accessor rather than a thisObject accessor, as a thisObject is not always available, and what the function
79         actually wants is the global object.
80
81         * bindings/scripts/IDLAttributes.json:
82         Add new RethrowException attribute to instruct the callback function to re-throw, rather than
83         just report, exceptions thrown in the callback and SkipCallbackInvokeCheck which instructs the
84         callback function to not check canInvokeCallback() before calling. These will both be needed to retain
85         the behavior of NodeFilter, and should be investigated further.
86
87         * bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
88         * bindings/scripts/test/JS/JSTestCallbackFunction.h:
89         * bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.cpp: Added.
90         * bindings/scripts/test/JS/JSTestCallbackFunctionRethrow.h: Added.
91         * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp:
92         * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h:
93         * bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
94         * bindings/scripts/test/JS/JSTestCallbackInterface.h:
95         * bindings/scripts/test/JS/JSTestVoidCallbackFunction.cpp: Added.
96         * bindings/scripts/test/JS/JSTestVoidCallbackFunction.h: Added.
97         * bindings/scripts/test/TestCallbackFunction.idl:
98         * bindings/scripts/test/TestCallbackInterface.idl:
99         * bindings/scripts/test/TestVoidCallbackFunction.idl: Copied from Source/WebCore/bindings/scripts/test/TestCallbackFunction.idl.
100         Update test results and add some additional test cases for callback functions and callback interface functions that return
101         non-void and use the RethrowExceptions.
102
103         * dom/CallbackResult.h: Added.
104         (WebCore::CallbackResult<ReturnType>::CallbackResult):
105         (WebCore::CallbackResult<ReturnType>::type):
106         (WebCore::CallbackResult<void>::CallbackResult):
107         (WebCore::CallbackResult<void>::type):
108         New class to encapsulate the return value and status of a callback function. Modeled loosely on
109         ExceptionOr, but is simpler since it does not need to handle complex exception objects.
110
111         * dom/NativeNodeFilter.cpp:
112         * dom/NativeNodeFilter.h:
113         Adopt CallbackResult, matching other NodeFiltering code by using
114         unsigned short rather than short, remove unused functions, and convert 
115         condition member to a Ref, allowing us to get rid of the branch acceptNode.
116
117         * dom/NodeFilter.h:
118         Adopt CallbackResult.
119
120         * dom/NodeFilter.idl:
121         Replace Custom extended attribute with SkipCallbackInvokeCheck and RethrowException.
122
123         * dom/NodeFilterCondition.cpp:
124         * dom/NodeFilterCondition.h:
125         Modernize to take a Node reference and match other filtering code
126         by returning an unsigned short.
127
128         * dom/Traversal.cpp:
129         * dom/Traversal.h:
130         Adopt CallbackResult and match other node filtering code by using unsigned short 
131         rather than short.
132
133         * dom/NodeIterator.cpp:
134         * dom/NodeIterator.h:
135         * dom/NodeIterator.idl:
136         * dom/TreeWalker.cpp:
137         * dom/TreeWalker.h:
138         * dom/TreeWalker.idl:
139         Change functions that callout to javascript via the NodeFilter to 
140         return ExceptionOr<Node>. Check the result of CallbackResult for a
141         thrown exception, and bail, returning Exception { ExistingExceptionError }
142         which acts as an indicator to the bindings that an exception was thrown.
143         (In actuality, the specific exception code does not matter. All that matters
144         is that an ExceptionOr<> is returned, which triggers, via overload, a path
145         in toJS() that calls propagateException(), which in turn, checks to see if
146         an exception is on the stack. But, having an explicit code here helps debugging).
147
148 2017-05-22  Simon Fraser  <simon.fraser@apple.com>
149
150         Support transform-box to switch sizing box in SVG
151         https://bugs.webkit.org/show_bug.cgi?id=145783
152
153         Reviewed by Dean Jackson.
154
155         Add support for the CSS "transform-box" property, as described at
156         <https://drafts.csswg.org/css-transforms/#transform-box>.
157         
158         This changes the behavior of percentage values in transform-origin in SVG.
159         When these were added in r110532, percentage values in transform-origin were made
160         relative to the bounding box, but absolute values relative to the view box.
161         <https://github.com/w3c/csswg-drafts/issues/895> has concluded that this behavior
162         is confusing. The new behavior is that, for SVG elements, both absolute and
163         percentage values are relative to the reference box, which is specified by the
164         new transform-box property.
165
166         The initial value for transform-box is border-box, with the svg.css UA stylesheet
167         supplying a default of view-box for the relevant SVG elements per
168         <https://www.w3.org/TR/SVG2/styling.html#UAStyleSheet>.
169
170         For non-SVG elements, the used value is always border-box, so there is no change
171         in behavior.
172
173         Tests: fast/css/transform-box-parsing.html
174                svg/transforms/svg-transform-box.html
175
176         * css/CSSComputedStyleDeclaration.cpp:
177         (WebCore::ComputedStyleExtractor::propertyValue):
178         * css/CSSPrimitiveValueMappings.h:
179         (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
180         (WebCore::CSSPrimitiveValue::operator TransformBox):
181         * css/CSSProperties.json:
182         * css/CSSValueKeywords.in:
183         * css/parser/CSSPropertyParser.cpp:
184         (WebCore::CSSPropertyParser::parseSingleValue):
185         * css/svg.css:
186         (*:not(svg),):
187         (*): Deleted.
188         (html|* > svg): Deleted.
189         * page/animation/AnimationBase.cpp:
190         (WebCore::AnimationBase::computeTransformedExtentViaTransformList):
191         * rendering/style/RenderStyle.cpp:
192         (WebCore::RenderStyle::applyTransform): The transformOriginX().isPercent() tests
193         were added to support the weird "% values are relative to bounding box" in SVG. Now
194         it's up to the caller to pass a non-zero origin when that matters, and
195         SVGGraphicsElement::animatedLocalTransform() is the only caller that does so.
196         * rendering/style/RenderStyle.h:
197         (WebCore::RenderStyle::hasTransform):
198         (WebCore::RenderStyle::transformBox):
199         (WebCore::RenderStyle::setTransformBox):
200         (WebCore::RenderStyle::initialTransformBox):
201         * rendering/style/RenderStyleConstants.h:
202         * rendering/style/StyleTransformData.cpp:
203         (WebCore::StyleTransformData::StyleTransformData):
204         (WebCore::StyleTransformData::operator==):
205         * rendering/style/StyleTransformData.h:
206         * svg/SVGGraphicsElement.cpp:
207         (WebCore::SVGGraphicsElement::animatedLocalTransform): Consult the transform-box
208         style to compute the reference box as the bounding box, or the view box.
209
210 2017-05-22  Chris Dumez  <cdumez@apple.com>
211
212         Add support for [LegacyWindowAlias] IDL extended attribute
213         https://bugs.webkit.org/show_bug.cgi?id=172451
214
215         Reviewed by Sam Weinig.
216
217         Add support for [LegacyWindowAlias] IDL extended attribute as per:
218         - https://heycam.github.io/webidl/#LegacyWindowAlias
219
220         Use it for our legacy window aliases, such as webKitURL.
221
222         No new tests, there should be no Web-exposed behavior change.
223
224         * bindings/scripts/IDLAttributes.json:
225         * bindings/scripts/preprocess-idls.pl:
226         (GenerateConstructorAttributes):
227         * css/DOMMatrix.idl:
228         * dom/MutationObserver.idl:
229         * dom/XMLDocument.idl:
230         * html/DOMURL.idl:
231         * page/DOMWindow.idl:
232
233 2017-05-22  Jer Noble  <jer.noble@apple.com>
234
235         ASSERTION FAILED: m_boundThread == currentThread() in WTF::WeakReference<WebCore::WebCoreDecompressionSession>::clear()
236         https://bugs.webkit.org/show_bug.cgi?id=172457
237         <rdar://problem/32329436>
238
239         Reviewed by Eric Carlson.
240
241         Remove vestigal WeakPtrFactory that was entirely unused.
242
243         * platform/graphics/cocoa/WebCoreDecompressionSession.h:
244         (WebCore::WebCoreDecompressionSession::createWeakPtr): Deleted.
245         * platform/graphics/cocoa/WebCoreDecompressionSession.mm:
246         (WebCore::WebCoreDecompressionSession::WebCoreDecompressionSession):
247
248 2017-05-22  Antti Koivisto  <antti@apple.com>
249
250         Crash in WebCore::StyleRuleKeyframes::findKeyframeIndex
251         https://bugs.webkit.org/show_bug.cgi?id=170756
252         <rdar://problem/31573157>
253
254         Reviewed by Andreas Kling.
255
256         Using a malformed key with CSSKeyframesRule.findRule crashes because
257         CSSParser::parseKeyframeKeyList returns null which is then dereferenced.
258
259         * css/CSSKeyframesRule.cpp:
260         (WebCore::StyleRuleKeyframes::findKeyframeIndex): Null test.
261
262 2017-05-22  Wenson Hsieh  <wenson_hsieh@apple.com>
263
264         Remove unused documentIsHandlingNonDefaultDrag plumbing for WebKit2
265         https://bugs.webkit.org/show_bug.cgi?id=172453
266
267         Reviewed by Tim Horton.
268
269         Removes unused plumbing that was originally added to support file uploads. No new tests, since there is no
270         change in behavior.
271
272         * page/DragController.h:
273         (WebCore::DragController::documentIsHandlingNonDefaultDrag): Deleted.
274
275 2017-05-22  Jer Noble  <jer.noble@apple.com>
276
277         Media element thinks its hidden when in PiP mode and tab is backgrounded.
278         https://bugs.webkit.org/show_bug.cgi?id=172221
279
280         Reviewed by Eric Carlson.
281
282         The element should not be considered hidden when in legacy fullscreen mode or PiP mode.
283
284         * html/HTMLMediaElement.cpp:
285         (WebCore::HTMLMediaElement::visibilityStateChanged):
286         (WebCore::HTMLMediaElement::fullscreenModeChanged):
287
288 2017-05-22  Zan Dobersek  <zdobersek@igalia.com>
289
290         NavigatorEME: null RefPtr<> dereference due to different calling conventions
291         https://bugs.webkit.org/show_bug.cgi?id=172352
292
293         Reviewed by Carlos Garcia Campos.
294
295         * Modules/encryptedmedia/NavigatorEME.cpp:
296         (WebCore::tryNextSupportedConfiguration): Avoid crashes when constructing
297         the MediaKeySystemAccess::create() arguments that can occur for targets with
298         calling conventions that might release the implementation RefPtr<> before it's
299         dereferenced to retrieve the key system string. Simply acquire the reference
300         to the key system String object before the MediaKeySystem::create() call
301         expression that releases the problematic RefPtr<>.
302
303 2017-05-22  Gwang Yoon Hwang  <yoon@igalia.com>
304
305         [CoordinatedGraphics] Clear UpdateAtlases for each tests
306         https://bugs.webkit.org/show_bug.cgi?id=172119
307
308         Reviewed by Carlos Garcia Campos.
309
310         * loader/EmptyClients.h:
311         * page/ChromeClient.h:
312         * testing/Internals.cpp:
313         (WebCore::Internals::resetToConsistentState): Clears update atlases
314         while resetting states of the test runner.
315
316 2017-05-22  Gwang Yoon Hwang  <yoon@igalia.com>
317
318         [CoordinatedGraphics] BitmapTexturePool does not release textures properly
319         https://bugs.webkit.org/show_bug.cgi?id=172428
320
321         Reviewed by Žan Doberšek.
322
323         No new tests because no behavior change.
324
325         * platform/graphics/texmap/BitmapTexturePool.cpp:
326         (WebCore::BitmapTexturePool::BitmapTexturePool):
327         Use the RunLoopTimer instead of Timer, because BitmapTexturePool would
328         run on the compositing thread in Coordinated Graphics case.
329         (WebCore::BitmapTexturePool::releaseUnusedTexturesTimerFired):
330         We should check not only the last used time but also the refcounts of the
331         texture when selecting textures to remove.
332         * platform/graphics/texmap/BitmapTexturePool.h:
333         (WebCore::BitmapTexturePool::Entry::canBeReleased): Added.
334
335 2017-05-21  Carlos Garcia Campos  <cgarcia@igalia.com>
336
337         [WPE] Use surfaceless context for sharing and offscreen context if available
338         https://bugs.webkit.org/show_bug.cgi?id=172268
339
340         Reviewed by Žan Doberšek.
341
342         Like GTK+ port does, WPE should use surfaceless contexts when possible, and only create a native offscreen
343         context as a fallback. We don't need to do anything special in WPE port, just to make it consistent with the
344         Wayland and X11 implementations. We should also avoid including EGL.h in headers, we added
345         GLContextEGLWayland.cpp and GLContextEGLX11.cpp to avoid that. PlatformDisplayWPE::EGLOffscreenTarget is quite
346         simple and only used by GLContextEGLWPE, so we could move it there like we do for Wayland and X11.
347
348         * platform/graphics/GLContext.h: Remove EGL header includes.
349         * platform/graphics/egl/GLContextEGL.cpp:
350         (WebCore::GLContextEGL::createWindowContext): Use createWindowSurfaceWPE() in WPE.
351         (WebCore::GLContextEGL::createContext): Use createWPEContext in WPE.
352         (WebCore::GLContextEGL::createSharingContext): Move the WPE code below to ensure we try
353         createSurfacelessContext() first.
354         * platform/graphics/egl/GLContextEGL.h:
355         * platform/graphics/egl/GLContextEGLWPE.cpp:
356         (WebCore::GLContextEGL::GLContextEGL): Add constructor for WPE that receives a struct wpe_renderer_backend_egl_offscreen_target*
357         (WebCore::GLContextEGL::createWindowSurfaceWPE): Added implementation here because eglCreateWindowSurface needs
358         the platform specific EGL includes and definitions.
359         (WebCore::GLContextEGL::createWPEContext): Create a GLContext using WPE backend API directly here.
360         (WebCore::GLContextEGL::destroyWPETarget): Add null check.
361         * platform/graphics/wpe/PlatformDisplayWPE.cpp: Remove EGLOffscreenTarget.
362         * platform/graphics/wpe/PlatformDisplayWPE.h:
363
364 2017-05-21  Michael Catanzaro  <mcatanzaro@igalia.com>
365
366         [GTK] Remove Firefox user agent quirk for Google domains
367         https://bugs.webkit.org/show_bug.cgi?id=171941
368
369         Reviewed by Carlos Garcia Campos.
370
371         * platform/UserAgentQuirks.cpp:
372         (WebCore::UserAgentQuirks::quirksForURL):
373         (WebCore::UserAgentQuirks::stringForQuirk):
374         (WebCore::urlRequiresFirefoxBrowser): Deleted.
375         (WebCore::UserAgentQuirks::firefoxRevisionString): Deleted.
376         * platform/UserAgentQuirks.h:
377         * platform/gtk/UserAgentGtk.cpp:
378         (WebCore::buildUserAgentString):
379
380 2017-05-21  Antti Koivisto  <antti@apple.com>
381
382         matchMedia('print').addListener() fires in WK1 but never in WK2 when printing (breaks printing Google maps, QuickLooks)
383         https://bugs.webkit.org/show_bug.cgi?id=172361
384         <rdar://problem/28777408>
385
386         Reviewed by Sam Weinig.
387
388         Test: fast/media/matchMedia-print.html
389
390         * page/FrameView.cpp:
391         (WebCore::FrameView::layout):
392
393             Evaluate matchMedia queries unconditionally. No idea why it wasn't like that.
394
395         * testing/Internals.cpp:
396         (WebCore::Internals::setPrinting):
397
398             Add testing support. The existing ways to do printing testing were unable to hit this bug as
399             they had too much additional gunk.
400
401         * testing/Internals.h:
402         * testing/Internals.idl:
403
404 2017-05-21  Zalan Bujtas  <zalan@apple.com>
405
406         Remove redundant FrameView ref in FrameView::performPostLayoutTasks
407         https://bugs.webkit.org/show_bug.cgi?id=172422
408
409         Reviewed by Antti Koivisto.
410
411         This was added to protect FrameView from getting destroyed in updateEmbeddedObjects(), but r169475 changed
412         the embedded object update to be asynchronous.  
413
414         * page/FrameView.cpp:
415         (WebCore::FrameView::performPostLayoutTasks):
416
417 2017-05-20  Chris Dumez  <cdumez@apple.com>
418
419         Drop [NoInterfaceObject] from RTCDTMFSender and RTCStatsReport
420         https://bugs.webkit.org/show_bug.cgi?id=172418
421
422         Reviewed by Youenn Fablet.
423
424         Drop [NoInterfaceObject] from RTCDTMFSender and RTCStatsReport to match the specification:
425         - https://www.w3.org/TR/webrtc/#rtcdtmfsender
426         - https://www.w3.org/TR/webrtc/#rtcstatsreport-object
427
428         Firefox exposes both RTCDTMFSender and RTCStatsReport. Chrome exposes RTCStatsReport only.
429         RTCDTMFSender seems to be currently disabled at build time currently so the change to
430         its interface does not currently impact Web-exposed behavior, only the change to the
431         RTCStatsReport interface currently does.
432
433         No new tests, rebaselined existing test.
434
435         * Modules/mediastream/RTCDTMFSender.idl:
436         * Modules/mediastream/RTCStatsReport.idl:
437         Drop [NoInterfaceObject].
438
439         * Modules/mediastream/RTCIceCandidateEvent.cpp: Removed.
440         * Modules/mediastream/RTCIceCandidateEvent.h: Removed.
441         * Modules/mediastream/RTCIceCandidateEvent.idl: Removed.
442         Drop class and IDL that are no longer used. They were not even part of any project files.
443         RTCIceCandidateEvent has been renamed to RTCPeerConnectionIceEvent, which we support.
444
445 2017-05-20  Chris Dumez  <cdumez@apple.com>
446
447         Value for iterator property is wrong for maplike interfaces
448         https://bugs.webkit.org/show_bug.cgi?id=172410
449
450         Reviewed by Sam Weinig.
451
452         Value for iterator property was wrong for maplike interfaces. The iterator property is
453         supposed to have the same value as the 'entries' property but we were using the value
454         of the 'values' property.
455
456         Specification:
457         - https://heycam.github.io/webidl/#es-map-entries
458         - https://heycam.github.io/webidl/#es-iterator
459
460         This impacts the iterator of the RTCStatsReport interface.
461
462         No new tests, updated existing test.
463
464         * bindings/scripts/CodeGeneratorJS.pm:
465         (GenerateImplementation):
466         * bindings/scripts/test/JS/JSMapLike.cpp:
467         (WebCore::JSMapLikePrototype::finishCreation):
468         * bindings/scripts/test/JS/JSReadOnlyMapLike.cpp:
469         (WebCore::JSReadOnlyMapLikePrototype::finishCreation):
470
471 2017-05-20  Chris Dumez  <cdumez@apple.com>
472
473         Drop superfluous iterator property setting in addValueIterableMethods()
474         https://bugs.webkit.org/show_bug.cgi?id=172409
475
476         Reviewed by Youenn Fablet.
477
478         Drop superfluous iterator setting in addValueIterableMethods(). The bindings already take care of
479         adding the iterator property before calling addValueIterableMethods().
480
481         No new tests, no Web-facing behavior change.
482
483         * bindings/js/JSDOMIterator.cpp:
484         (WebCore::addValueIterableMethods):
485
486 2017-05-20  Jer Noble  <jer.noble@apple.com>
487
488         [MSE][Mac] Support painting MSE video-element to canvas
489         https://bugs.webkit.org/show_bug.cgi?id=125157
490         <rdar://problem/23062016>
491
492         Reviewed by Eric Carlson.
493
494         Test: media/media-source/media-source-paint-to-canvas.html
495
496         In order to have access to decoded video data for painting, decode the encoded samples manually
497         instead of adding them to the AVSampleBufferDisplayLayer. To facilitate doing so, add a new
498         utility class WebCoreDecompressionSession, which can decode samples and store them.
499
500         For the purposes of this patch, to avoid double-decoding of video data and to avoid severe complication
501         of our sample delivery pipeline, we will only support painting of decoded video samples when the video is
502         not displayed in the DOM.
503
504         * Modules/mediasource/MediaSource.cpp:
505         (WebCore::MediaSource::seekToTime): Always send waitForSeekCompleted() to give private a chance to delay seek completion.
506         * Modules/mediasource/SourceBuffer.cpp:
507         (WebCore::SourceBuffer::sourceBufferPrivateReenqueSamples): Added.
508         * Modules/mediasource/SourceBuffer.h:
509         * WebCore.xcodeproj/project.pbxproj:
510         * platform/cf/CoreMediaSoftLink.cpp: Added new soft link macros.
511         * platform/cf/CoreMediaSoftLink.h: Ditto.
512         * platform/cocoa/CoreVideoSoftLink.cpp: Ditto.
513         * platform/cocoa/CoreVideoSoftLink.h: Ditto.
514         * platform/graphics/SourceBufferPrivateClient.h:
515         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
516         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::sampleBufferDisplayLayer): Simple accessor.
517         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::decompressionSession): Ditto.
518         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
519         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
520         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load): Update whether we should be displaying in a layer or decompression session..
521         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVisible): Ditto.
522         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::waitForSeekCompleted): m_seeking is now an enum.
523         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seeking): Ditto.
524         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekCompleted): Ditto. If waiting for a video frame, delay completing seek.
525         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::nativeImageForCurrentTime): Call updateLastImage() and return result.
526         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastImage): Fetch the image for the current time.
527         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paint): Pass to paintCurrentFrameInCanvas.
528         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext): Get a native image, and render it.
529         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged): Create or destroy a layer or decompression session as appropriate.
530         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer): Creates a layer.
531         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::destroyLayer): Destroys a layer.
532         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureDecompressionSession): Creates a decompression session.
533         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::destroyDecompressionSession): Destroys a decompression session.
534         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableVideoFrame): If seek completion delayed, complete now. Ditto for ready state change.
535         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setReadyState): If waiting for a video frame, delay ready state change.
536         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer): Deleted.
537         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer): Deleted.
538         * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
539         * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
540         (WebCore::MediaSourcePrivateAVFObjC::hasVideo): Promote to a class function.
541         (WebCore::MediaSourcePrivateAVFObjC::hasSelectedVideo): Return whether any of the active source buffers have video and are selected.
542         (WebCore::MediaSourcePrivateAVFObjC::hasSelectedVideoChanged): Call setSourceBufferWithSelectedVideo().
543         (WebCore::MediaSourcePrivateAVFObjC::setVideoLayer): Set (or clear) the layer on the selected buffer.
544         (WebCore::MediaSourcePrivateAVFObjC::setDecompressionSession): Ditto for decompression session.
545         (WebCore::MediaSourcePrivateAVFObjC::setSourceBufferWithSelectedVideo): Remove the layer and decompression session from the unselected
546
547                 buffer and add the decompression session or layer to the newly selected buffer.
548         (WebCore::MediaSourcePrivateAVFObjCHasVideo): Deleted.
549         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
550         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
551         (WebCore::SourceBufferPrivateAVFObjC::destroyRenderers): Clear the videoLayer and decompressionSession.
552         (WebCore::SourceBufferPrivateAVFObjC::hasSelectedVideo): Return whether the buffer has a selected video track.
553         (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled): The media player now manages the video layer and decompression session lifetimes.
554         (WebCore::SourceBufferPrivateAVFObjC::flush): Flush the decompression session, if it exists.
555         (WebCore::SourceBufferPrivateAVFObjC::enqueueSample): Enqueue to the decompression session, if it exists.
556         (WebCore::SourceBufferPrivateAVFObjC::isReadyForMoreSamples): As the decompression session, if it exists.
557         (WebCore::SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples): Tell the decompression session to stop requesting data, if it exists.
558         (WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples): Request media data from the decompression session, if it exists.
559         (WebCore::SourceBufferPrivateAVFObjC::setVideoLayer): Added.
560         (WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Added.
561         * platform/graphics/cocoa/WebCoreDecompressionSession.h: Added.
562         (WebCore::WebCoreDecompressionSession::create):
563         (WebCore::WebCoreDecompressionSession::isInvalidated):
564         (WebCore::WebCoreDecompressionSession::createWeakPtr):
565         * platform/graphics/cocoa/WebCoreDecompressionSession.mm: Added.
566         (WebCore::WebCoreDecompressionSession::WebCoreDecompressionSession): Register for media data requests.
567         (WebCore::WebCoreDecompressionSession::invalidate):  Unregister for same.
568         (WebCore::WebCoreDecompressionSession::maybeBecomeReadyForMoreMediaDataCallback): Pass to maybeBecomeReadyForMoreMediaData.
569         (WebCore::WebCoreDecompressionSession::maybeBecomeReadyForMoreMediaData): Check in-flight decodes, and decoded frame counts.
570         (WebCore::WebCoreDecompressionSession::enqueueSample): Pass the sample to be decoded on a background queue.
571         (WebCore::WebCoreDecompressionSession::decodeSample): Decode the sample.
572         (WebCore::WebCoreDecompressionSession::decompressionOutputCallback): Call handleDecompressionOutput.
573         (WebCore::WebCoreDecompressionSession::handleDecompressionOutput): Pass decoded sample to be enqueued on the main thread.
574         (WebCore::WebCoreDecompressionSession::getFirstVideoFrame):
575         (WebCore::WebCoreDecompressionSession::enqueueDecodedSample): Enqueue the frame (if it's a displayed frame).
576         (WebCore::WebCoreDecompressionSession::isReadyForMoreMediaData): Return whether we've hit our high water sample count.
577         (WebCore::WebCoreDecompressionSession::requestMediaDataWhenReady):
578         (WebCore::WebCoreDecompressionSession::stopRequestingMediaData): Unset the same.
579         (WebCore::WebCoreDecompressionSession::notifyWhenHasAvailableVideoFrame): Set a callback to notify when a decoded frame has been enqueued.
580         (WebCore::WebCoreDecompressionSession::imageForTime): Successively dequeue images until reaching one at or beyond the requested time.
581         (WebCore::WebCoreDecompressionSession::flush): Synchronously empty the producer and consumer queues.
582         (WebCore::WebCoreDecompressionSession::getDecodeTime): Utility method.
583         (WebCore::WebCoreDecompressionSession::getPresentationTime): Ditto.
584         (WebCore::WebCoreDecompressionSession::getDuration): Ditto.
585         (WebCore::WebCoreDecompressionSession::compareBuffers): Ditto.
586         * platform/cocoa/VideoToolboxSoftLink.cpp: Added.
587         * platform/cocoa/VideoToolboxSoftLink.h: Added.
588
589 2017-05-19  Joseph Pecoraro  <pecoraro@apple.com>
590
591         WebAVStreamDataParserListener String leak
592         https://bugs.webkit.org/show_bug.cgi?id=172395
593
594         Reviewed by Chris Dumez.
595
596         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
597         (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]):
598         (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]):
599         Use an isolated String in a lambda used across threads.
600
601 2017-05-19  Chris Dumez  <cdumez@apple.com>
602
603         Consider not exposing webkitURL in workers
604         https://bugs.webkit.org/show_bug.cgi?id=172166
605
606         Reviewed by Geoffrey Garen.
607
608         Drop webkitURL alias for URL in workers, to match other browsers. The risk should
609         be low given that this only impacts workers, we expose URL to workers and Blink
610         does not have this alias. We still support the webkitURL alias for URL on Window.
611
612         No new tests, rebaselined existing test.
613
614         * workers/WorkerGlobalScope.idl:
615
616 2017-05-19  Youenn Fablet  <youenn@apple.com>
617
618         Add RTCPeerConnection connection state change logging
619         https://bugs.webkit.org/show_bug.cgi?id=172314
620
621         Reviewed by Eric Carlson.
622
623         No change of behavior.
624         Adding some release logging of connection state changes.
625
626         * Modules/mediastream/RTCPeerConnection.cpp:
627         (WebCore::rtcIceGatheringStateToString):
628         (WebCore::RTCPeerConnection::updateIceGatheringState):
629         (WebCore::rtcIceConnectionStateToString):
630         (WebCore::RTCPeerConnection::updateIceConnectionState):
631
632 2017-05-19  Jeremy Jones  <jeremyj@apple.com>
633
634         webkitSupportsFullscreen and webkitSupportsPresentationMode('fullscreen') disagree.
635         https://bugs.webkit.org/show_bug.cgi?id=172329
636         rdar://problem/32260891
637
638         Reviewed by Darin Adler.
639
640         Updated tests:
641         * media/media-fullscreen-inline-expected.txt:
642         * media/media-fullscreen-not-in-document-expected.txt:
643         * media/media-fullscreen.js:
644
645         webkitSupportsPresentationMode('fullscreen') should delegate to webkitSupportsFullscreen.
646         The additional mediaSession().fullscreenPermitted() check causes it to return false when
647         not handling a user gesture, which isn't helpful to deciding to show a button in controls
648         or not.
649
650         * html/HTMLVideoElement.cpp:
651         (WebCore::HTMLVideoElement::webkitSupportsPresentationMode):
652
653 2017-05-19  Jeremy Jones  <jeremyj@apple.com>
654
655         Prevent javascript interface from activating picture-in-picture for video elements that are showing capture camera on ios.
656         https://bugs.webkit.org/show_bug.cgi?id=172328
657
658         Reviewed by Eric Carlson.
659
660         This change allows MediaPlayers to decide if they support pictureInPicture.
661         And check this from supportsFullscreen().
662
663         In MediaPlayerPrivateMediaStreamAVFObjC disable pip if there is a capture video track.
664         Elsewhere, leave it enabled.
665
666         * html/HTMLVideoElement.cpp:
667         (WebCore::HTMLVideoElement::supportsFullscreen): Added Check.
668         * platform/graphics/MediaPlayer.cpp:
669         (WebCore::MediaPlayer::supportsPictureInPicture): Added.
670         * platform/graphics/MediaPlayer.h:
671         * platform/graphics/MediaPlayerPrivate.h:
672         (WebCore::MediaPlayerPrivateInterface::supportsPictureInPicture): Added.
673         * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
674         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
675         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
676         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
677         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsPictureInPicture): Added
678         * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
679         * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
680         (WebCore::MediaPlayerPrivateQTKit::supportsFullscreen): Deleted. Moved inline.
681
682 2017-05-19  Chris Dumez  <cdumez@apple.com>
683
684         Do not fire load event for SVGElements that are detached or in frameless documents
685         https://bugs.webkit.org/show_bug.cgi?id=172289
686         <rdar://problem/32275689>
687
688         Reviewed by Ryosuke Niwa.
689
690         We should not fire load event for SVGElements that are detached or in frameless
691         documents.
692
693         Test: svg/load-event-detached.html
694
695         * svg/SVGElement.cpp:
696         (WebCore::SVGElement::sendSVGLoadEventIfPossible):
697
698 2017-05-19  Chris Dumez  <cdumez@apple.com>
699
700         Option() named constructor is not per spec
701         https://bugs.webkit.org/show_bug.cgi?id=172185
702
703         Reviewed by Sam Weinig.
704
705         Align the behavior of the Option() named constructor with the HTML specification:
706         - https://html.spec.whatwg.org/#dom-option
707
708         In particular, we no longer create an empty Text child node if the input text is the empty string.
709         This also aligns our behavior with Firefox.
710
711         Test: imported/w3c/web-platform-tests/html/semantics/forms/the-option-element/option-element-constructor.html
712
713         * html/HTMLOptionElement.cpp:
714         (WebCore::HTMLOptionElement::createForJSConstructor):
715         * html/HTMLOptionElement.h:
716         * html/HTMLOptionElement.idl:
717
718 2017-05-19  Chris Dumez  <cdumez@apple.com>
719
720         URLSearchParams / Headers objects @@iterator is not as per Web IDL spec
721         https://bugs.webkit.org/show_bug.cgi?id=172218
722
723         Reviewed by Youenn Fablet.
724
725         Both URLSearchParams and Headers interfaces are iterable as per their
726         respective specification, and they both have a pair iterator:
727         - https://url.spec.whatwg.org/#interface-urlsearchparams
728         - https://fetch.spec.whatwg.org/#headers-class
729
730         As per the WebIDL specification for 'entries'[1], "If the interface has a pair
731         iterator, then the Function object is the value of the @@iterator property",
732         the value of @@iterator being defined at [2]. In WebKit, we were using
733         different values/functions for 'entries' and @@iterator, although those
734         functions were doing the same thing (and the right thing).
735
736         Also, as per [2], the name of the @@iterator function should be "entries",
737         which I also implemented in this patch. Previously, we were using
738         "[Symbol.Iterator]" as function name.
739
740         [1] https://heycam.github.io/webidl/#es-iterable-entries
741         [2] https://heycam.github.io/webidl/#es-iterator
742
743         No new tests, rebaselined existing tests.
744
745         * bindings/scripts/CodeGeneratorJS.pm:
746         (GenerateImplementation):
747         (GenerateImplementationIterableFunctions):
748         * bindings/scripts/test/JS/JSMapLike.cpp:
749         * bindings/scripts/test/JS/JSReadOnlyMapLike.cpp:
750         * bindings/scripts/test/JS/JSTestIterable.cpp:
751         (WebCore::JSTestIterablePrototype::finishCreation):
752         (WebCore::jsTestIterablePrototypeFunctionEntriesCaller):
753         * bindings/scripts/test/JS/JSTestNode.cpp:
754         (WebCore::JSTestNodePrototype::finishCreation):
755         (WebCore::jsTestNodePrototypeFunctionEntriesCaller):
756
757 2017-05-19  Zalan Bujtas  <zalan@apple.com>
758
759         Redundant ellipsis box triggers ASSERT_WITH_SECURITY_IMPLICATION in InlineBox::parent().
760         https://bugs.webkit.org/show_bug.cgi?id=172309
761         <rdar://problem/32262357>
762
763         Reviewed by Simon Fraser.
764
765         This patch stops the redundant ellipsis box trigger ASSERT_WITH_SECURITY_IMPLICATION.
766
767         In RootInlineBox::placeEllipsis we construct an ellipsis box and append it to a static HashMap which
768         keeps track of the ellipsis boxes on each line. However when the line already has an ellipsis, we
769         re-use the existing one and this newly constructed (but redundant) box gets destroyed as we return from this function.
770         In InlineBox's d'tor, we let the parent know that now it has a dangling child and we assert on it
771         later, while accessing the children list. However this redundant ellipsis box was never added to the line,
772         so the assertion hits incorrectly.
773
774         Test: fast/inline/redundant-ellipsis-triggers-assert-incorrectly.html
775
776         * rendering/EllipsisBox.cpp:
777         (WebCore::EllipsisBox::EllipsisBox):
778         * rendering/InlineBox.cpp: This needs 32bits padding.
779         (WebCore::InlineBox::invalidateParentChildList):
780         * rendering/InlineBox.h:
781         * rendering/RootInlineBox.cpp:
782         (WebCore::RootInlineBox::placeEllipsis):
783
784 2017-05-19  Matt Rajca  <mrajca@apple.com>
785
786         Inherit media user gestures from the top document when autoplay quirks are allowed.
787         https://bugs.webkit.org/show_bug.cgi?id=172375
788
789         Reviewed by Eric Carlson.
790
791         Added API test.
792
793         * dom/Document.cpp:
794         (WebCore::Document::processingUserGestureForMedia):
795
796 2017-05-19  Youenn Fablet  <youenn@apple.com>
797
798         Align MockRealtimeMediaSourceCenter with RealtimeMediaSourceCenter
799         https://bugs.webkit.org/show_bug.cgi?id=172324
800
801         Reviewed by Eric Carlson.
802
803         No change of behavior.
804         Remove most of MockRealtimeMediaSourceCenter implementation.
805         Next step should be to remove it entirely and use the factory setters instead.
806
807         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
808         (WebCore::RealtimeMediaSourceCenter::RealtimeMediaSourceCenter):
809         (WebCore::RealtimeMediaSourceCenter::createMediaStream):
810         (WebCore::RealtimeMediaSourceCenter::getMediaStreamDevices):
811         (WebCore::RealtimeMediaSourceCenter::setDeviceEnabled):
812         * platform/mediastream/RealtimeMediaSourceCenter.h:
813         (WebCore::RealtimeMediaSourceCenter::supportedConstraints):
814         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
815         (WebCore::RealtimeMediaSourceCenterMac::RealtimeMediaSourceCenterMac):
816         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:
817         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
818         (WebCore::MockRealtimeMediaSourceCenter::MockCaptureDeviceManager::captureDevices):
819         * platform/mock/MockRealtimeMediaSourceCenter.h:
820
821 2017-05-19  Zalan Bujtas  <zalan@apple.com>
822
823         Update SameSizeAsInlineBox with the correct InlineBoxBitfields bits.
824         https://bugs.webkit.org/show_bug.cgi?id=172377
825
826         Reviewed by Tim Horton.
827
828         * rendering/InlineBox.cpp:
829
830 2017-05-19  Daniel Bates  <dabates@apple.com>
831
832         Bindings: Support runtime-enabled features in specific worlds
833         https://bugs.webkit.org/show_bug.cgi?id=172235
834
835         Reviewed by Chris Dumez.
836
837         Currently a function, attribute, or interface can be annotated with either EnabledAtRuntime
838         or EnabledForWorld (not both) to expose/conceal it depending on the state of a runtime
839         feature flag or the DOM world associated with the running JavaScript code, respectively.
840         Even though we do not have any functions, attributes, or interfaces that are annotated
841         with both EnabledAtRuntime and EnabledForWorld at the time of writing, it seems reasonable
842         to support such a combination of annotations. This also has the benefit of making it
843         straightforward to support the extended attribute SecureContext by generalizing the logic
844         that generates the code to expose/conceal a function, attribute, or interface.
845
846         * bindings/scripts/CodeGeneratorJS.pm:
847         (GenerateRuntimeEnableConditionalString): Use an array to build up all the conjuncts in
848         the conditional expression.
849         (GenerateImplementation): Substitute GenerateRuntimeEnableConditionalString() and $runtimeEnableConditionalString
850         for GetRuntimeEnableFunctionName() and $enable_function_result, respectively.
851         (GetRuntimeEnableFunctionName): Deleted.
852
853         * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
854          (WebCore::JSTestGlobalObject::finishCreation):
855          (WebCore::jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabled):
856          (WebCore::jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabledCaller):
857          (WebCore::jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeaturesEnabled):
858          (WebCore::jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeaturesEnabledCaller):
859          Update expected results.
860
861          * bindings/scripts/test/JS/JSTestObj.cpp:
862          (WebCore::JSTestObjPrototype::finishCreation):
863          (WebCore::jsTestObjPrototypeFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabled):
864          (WebCore::jsTestObjPrototypeFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabledCaller):
865          Ditto.
866
867          * bindings/scripts/test/TestGlobalObject.idl: Added test cases.
868          * bindings/scripts/test/TestObj.idl: Added test case.
869
870 2017-05-19  Jeremy Jones  <jeremyj@apple.com>
871
872         Fix macos build after r217143
873         https://bugs.webkit.org/show_bug.cgi?id=172380
874
875         unreviewed.
876
877         Remove reference to WebVideoFullscreenInterface for mac build.
878
879         * html/HTMLMediaElement.cpp:
880         * platform/mac/WebVideoFullscreenInterfaceMac.h:
881
882 2017-05-19  Jeremy Jones  <jeremyj@apple.com>
883
884         Remove defunct WebVideoFullscreenInterface
885         https://bugs.webkit.org/show_bug.cgi?id=172254
886
887         Reviewed by Jon Lee.
888
889         No new tests because no behavior change.
890
891         WebVideoFullscreenInterface has long since been replaced by WebVideoFullscreenModelClient.
892
893         * WebCore.xcodeproj/project.pbxproj:
894         * html/HTMLMediaElement.cpp:
895         * html/HTMLVideoElement.cpp:
896         * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
897         * platform/cocoa/WebVideoFullscreenInterface.h: Removed.
898         * platform/cocoa/WebVideoFullscreenModel.h:
899         * platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
900         * platform/ios/WebVideoFullscreenControllerAVKit.mm:
901         * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
902         * platform/mac/WebVideoFullscreenInterfaceMac.h:
903
904 2017-05-19  Jeremy Jones  <jeremyj@apple.com>
905
906         HTMLVideoElement::webkitSupportsPresentationMode allowsPictureInPicture() check is redundant.
907         https://bugs.webkit.org/show_bug.cgi?id=172330
908         rdar://problem/32285443
909
910         Reviewed by Eric Carlson.
911
912         No new tests because no behavior change.
913
914         This removes a redundant call to allowsPictureInPicture() to make it
915         more clear that webkitSupportsPresentationMode gives the same result as 
916         webkitSupportsFullscreen(pipMode)
917
918         * html/HTMLVideoElement.cpp:
919         (WebCore::HTMLVideoElement::webkitSupportsPresentationMode):
920
921 2017-05-19  Jeremy Jones  <jeremyj@apple.com>
922
923         [WebRTC] Remove PiP support for video elements that are showing camera capture
924         https://bugs.webkit.org/show_bug.cgi?id=172336
925
926         Reviewed by Eric Carlson.
927
928         No new tests because no effect on the DOM. This just changes a value sent to the platform interface layer.
929
930         Ask video element if it supports picture-in-picture instead of asking the mediaSession directly.
931         This allows the video element to give a more robust answer.
932
933         * html/HTMLVideoElement.h:
934         * platform/ios/WebVideoFullscreenControllerAVKit.mm:
935         (WebVideoFullscreenControllerContext::setUpFullscreen):
936
937 2017-05-18  Sam Weinig  <sam@webkit.org>
938
939         [WebIDL] Remove the need for the generator to know about native type mapping
940         https://bugs.webkit.org/show_bug.cgi?id=172310
941
942         Reviewed by Darin Adler.
943
944         Replace the use of explicit typename to native type mappings in CodeGeneratorJS.pm
945         with use of IDLTypes and Converter, which already need the mapping. This allows us
946         to have the information in only one spot.
947
948         Also, callback generation to account for nullability and update the IDLs to correctly
949         annotate only the types that need to be nullable. 
950
951         * Modules/geolocation/GeoNotifier.cpp:
952         * Modules/geolocation/GeoNotifier.h:
953         * Modules/geolocation/Geolocation.cpp:
954         * Modules/geolocation/Geolocation.h:
955         * Modules/geolocation/PositionCallback.idl:
956         * Modules/geolocation/PositionErrorCallback.h:
957         Use references where possible in the Geolocation code. It was almost possible
958         to make PositionCallback take a non-nullable position, but some odd logic in
959         Geolocation::makeCachedPositionCallbacks() implies that there is a path where
960         passing null is possible, though it would assert. Added FIXME's to return to
961         this in a follow up.
962
963         * Modules/webaudio/AudioBufferCallback.idl:
964         Add nullable annotation and FIXME explaining that the latest spec splits the callback
965         into two separate ones.
966
967         * Modules/webdatabase/Database.cpp:
968         (WebCore::Database::runTransaction):
969         * Modules/webdatabase/DatabaseCallback.h:
970         * Modules/webdatabase/DatabaseManager.cpp:
971         (WebCore::DatabaseManager::openDatabase):
972         * Modules/webdatabase/SQLStatement.cpp:
973         (WebCore::SQLStatement::performCallback):
974         * Modules/webdatabase/SQLStatementCallback.h:
975         * Modules/webdatabase/SQLStatementErrorCallback.h:
976         * Modules/webdatabase/SQLTransaction.cpp:
977         (WebCore::SQLTransaction::deliverTransactionCallback):
978         (WebCore::SQLTransaction::deliverTransactionErrorCallback):
979         * Modules/webdatabase/SQLTransactionCallback.h:
980         * Modules/webdatabase/SQLTransactionErrorCallback.h:
981         * inspector/InspectorDatabaseAgent.cpp:
982         * bindings/js/JSSQLStatementErrorCallbackCustom.cpp:
983         (WebCore::JSSQLStatementErrorCallback::handleEvent):
984         Update to pass callback parameters as references, since they are never null.
985
986         * bindings/IDLTypes.h:
987         Add NullableParameterType to allow customization of nullable parameters (in much
988         the same way we allow customization of the nullable implementation type).
989
990         * bindings/scripts/CodeGeneratorJS.pm:
991         (GenerateDefaultValue):
992         Use Converter<>::ReturnType{ } for default values rather than ${GetNativeType..}().
993
994         (GenerateHeader):
995         Remove use of GetNativeType for toWrapped by using the impl type, since this will never
996         be a complex type.
997
998         (GenerateImplementation):
999         Simplify DOMJIT UnsafeToNative by merging two identical paths and using auto.
1000
1001         (GenerateParametersCheck):
1002         Rework parameter checks to use more specific variable names, make branches more clear,
1003         and use Converter<>::ReturnType rather than GetNativeType.
1004
1005         (GenerateCallbackHeaderContent):
1006         (GenerateCallbackImplementationContent):
1007         Switch to using typename ${IDLType}::ParameterType as the parameters for callback functions. Also
1008         add final and override to make sure the generated function matches the user provided base class.
1009         (GetNativeType): Deleted.
1010         (GetNativeInnerType): Deleted.
1011         (GetNativeTypeForCallbacks): Deleted.
1012         Remove native type mappings.
1013
1014         * css/MediaQueryListListener.h:
1015         * css/MediaQueryListListener.idl:
1016         * css/MediaQueryMatcher.cpp:
1017         Update MediaQueryListListener to take a non-nullable MediaQueryList.
1018         
1019         * dom/NativeNodeFilter.cpp:
1020         * dom/NativeNodeFilter.h:
1021         * dom/NodeFilter.h:
1022         * dom/NodeFilter.idl:
1023         * dom/NodeIterator.cpp:
1024         * dom/Traversal.cpp:
1025         * dom/Traversal.h:
1026         * dom/TreeWalker.cpp:
1027         * bindings/js/JSNodeFilterCustom.cpp:
1028         Update acceptNode to be non-nullable and pass the Node by reference.
1029
1030         * dom/StringCallback.cpp:
1031         * dom/StringCallback.h:
1032         Pass the ScriptExecutionContext by reference.
1033
1034         * page/IntersectionObserverCallback.h:
1035         Update to match new parameter types and pass IntersectionObserver by reference.
1036
1037         * page/PerformanceObserver.cpp:
1038         * page/PerformanceObserverCallback.h:
1039         Update to pass PerformanceObserverEntryList and PerformanceObserver by reference.
1040
1041         * bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
1042         * bindings/scripts/test/JS/JSTestCallbackFunction.h:
1043         * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp:
1044         * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h:
1045         * bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
1046         * bindings/scripts/test/JS/JSTestCallbackInterface.h:
1047         * bindings/scripts/test/JS/JSTestObj.cpp:
1048         * bindings/scripts/test/JS/JSTestTypedefs.cpp:
1049         Update test results.
1050
1051         * bindings/scripts/test/TestCallbackInterface.idl:
1052         Update test to refer to actual interfaces as we now do lookup on these parameter 
1053         types rather than blindly assuming they are interfaces.
1054
1055 2017-05-19  Commit Queue  <commit-queue@webkit.org>
1056
1057         Unreviewed, rolling out r217098, r217111, r217113, and
1058         r217114.
1059         https://bugs.webkit.org/show_bug.cgi?id=172367
1060
1061         These changes broke the Windows build and introduced
1062         LayoutTest failures (Requested by ryanhaddad on #webkit).
1063
1064         Reverted changesets:
1065
1066         "[MSE][Mac] Support painting MSE video-element to canvas"
1067         https://bugs.webkit.org/show_bug.cgi?id=125157
1068         http://trac.webkit.org/changeset/217098
1069
1070         "[MSE][Mac] Support painting MSE video-element to canvas"
1071         https://bugs.webkit.org/show_bug.cgi?id=125157
1072         http://trac.webkit.org/changeset/217111
1073
1074         "Unreviewed build fix; add undefined functions and constants
1075         to the CoreMediaSoftLink.h, and use the"
1076         http://trac.webkit.org/changeset/217113
1077
1078         "[MSE][Mac] Support painting MSE video-element to canvas"
1079         https://bugs.webkit.org/show_bug.cgi?id=125157
1080         http://trac.webkit.org/changeset/217114
1081
1082 2017-05-19  Andy Estes  <aestes@apple.com>
1083
1084         REGRESSION (r217078): window.ApplePaySession is undefined on macOS Sierra
1085         https://bugs.webkit.org/show_bug.cgi?id=172344
1086
1087         Reviewed by Tim Horton.
1088
1089         r213673 mistakenly changed the ApplePaySession interface from being conditional on
1090         APPLE_PAY to being conditional on APPLE_PAY_DELEGATE, so when r217078 disabled
1091         APPLE_PAY_DELEGATE on Sierra and earlier it disabled ApplePaySession.
1092
1093         Fix this by reverting ApplePaySession to being conditional on APPLE_PAY.
1094
1095         Fixes http/tests/ssl/applepay/ApplePaySession.html
1096
1097         * Modules/applepay/ApplePaySession.idl:
1098
1099 2017-05-19  Chris Dumez  <cdumez@apple.com>
1100
1101         CSSOM insertRule() index argument is optional with default 0
1102         https://bugs.webkit.org/show_bug.cgi?id=172219
1103
1104         Reviewed by Sam Weinig.
1105
1106         Index parameter to CSSSupportsRule.insertRule() and CSSStyleSheet.insertRule() should
1107         be optional with a default value of 0, as per the latest specification:
1108         - https://github.com/w3c/csswg-drafts/commit/7949d41a2d86107f8ad4624c055b4b0c9c28ad0d
1109         - https://www.w3.org/Bugs/Public/show_bug.cgi?id=27384
1110
1111         Tests: imported/w3c/web-platform-tests/cssom/insertRule-charset-no-index.html
1112                imported/w3c/web-platform-tests/cssom/insertRule-import-no-index.html
1113                imported/w3c/web-platform-tests/cssom/insertRule-namespace-no-index.html
1114                imported/w3c/web-platform-tests/cssom/insertRule-no-index.html
1115
1116         * css/CSSStyleSheet.cpp:
1117         * css/CSSStyleSheet.h:
1118         * css/CSSStyleSheet.idl:
1119         * css/CSSSupportsRule.idl:
1120
1121 2017-05-19  Carlos Garcia Campos  <cgarcia@igalia.com>
1122
1123         [Threaded Compositor] Remove platform ifdefs from threaded compositor implementation
1124         https://bugs.webkit.org/show_bug.cgi?id=172265
1125
1126         Reviewed by Žan Doberšek.
1127
1128         Remove PlatformDisplayWPE::EGLTarget.
1129
1130         * platform/graphics/wpe/PlatformDisplayWPE.cpp:
1131         * platform/graphics/wpe/PlatformDisplayWPE.h:
1132
1133 2017-05-19  Jer Noble  <jer.noble@apple.com>
1134
1135         Unreviewed build fix; add undefined functions and constants to the CoreMediaSoftLink.h, and use the
1136         correct (and previously soft-linked) method in WebCoreDecompressionSession.
1137
1138         * platform/cf/CoreMediaSoftLink.cpp:
1139         * platform/cf/CoreMediaSoftLink.h:
1140         * platform/graphics/cocoa/WebCoreDecompressionSession.mm:
1141         (WebCore::WebCoreDecompressionSession::imageForTime):
1142
1143 2017-05-19  Yusuke Suzuki  <utatane.tea@gmail.com>
1144
1145         [JSC][DFG][DOMJIT] Extend CheckDOM to CheckSubClass
1146         https://bugs.webkit.org/show_bug.cgi?id=172098
1147
1148         Reviewed by Saam Barati.
1149
1150         Add DOMJIT interface IDL attribute. Which allows us to define checkSubClassPatchpointFor${className}
1151         function for that ClassInfo. And we move CheckSubClass patchpoint implementation to ClassInfo's member
1152
1153         * CMakeLists.txt:
1154         * WebCore.xcodeproj/project.pbxproj:
1155         * bindings/js/JSDOMGlobalObject.cpp:
1156         * bindings/js/JSDOMWindowBase.cpp:
1157         * bindings/js/JSDOMWindowProperties.cpp:
1158         * bindings/js/JSDOMWindowShell.cpp:
1159         * bindings/js/JSReadableStreamPrivateConstructors.cpp:
1160         * bindings/js/JSWorkerGlobalScopeBase.cpp:
1161         * bindings/scripts/CodeGeneratorJS.pm:
1162         (GenerateHeader):
1163         (GenerateImplementation):
1164         (GenerateImplementationIterableFunctions):
1165         (GenerateConstructorHelperMethods):
1166         * bindings/scripts/IDLAttributes.json:
1167         * bindings/scripts/test/JS/JSInterfaceName.cpp:
1168         * bindings/scripts/test/JS/JSMapLike.cpp:
1169         * bindings/scripts/test/JS/JSReadOnlyMapLike.cpp:
1170         * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
1171         * bindings/scripts/test/JS/JSTestCEReactions.cpp:
1172         * bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp:
1173         * bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
1174         * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.cpp:
1175         * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp:
1176         * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
1177         * bindings/scripts/test/JS/JSTestDOMJIT.cpp:
1178         * bindings/scripts/test/JS/JSTestDOMJIT.h:
1179         * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
1180         * bindings/scripts/test/JS/JSTestEventTarget.cpp:
1181         * bindings/scripts/test/JS/JSTestException.cpp:
1182         * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
1183         * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
1184         * bindings/scripts/test/JS/JSTestInterface.cpp:
1185         * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.cpp:
1186         * bindings/scripts/test/JS/JSTestIterable.cpp:
1187         * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp:
1188         * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
1189         * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
1190         * bindings/scripts/test/JS/JSTestNode.cpp:
1191         * bindings/scripts/test/JS/JSTestObj.cpp:
1192         * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
1193         * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
1194         * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp:
1195         * bindings/scripts/test/JS/JSTestPromiseRejectionEvent.cpp:
1196         * bindings/scripts/test/JS/JSTestSerialization.cpp:
1197         * bindings/scripts/test/JS/JSTestSerializationInherit.cpp:
1198         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp:
1199         * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
1200         * bindings/scripts/test/JS/JSTestTypedefs.cpp:
1201         * bridge/c/CRuntimeObject.cpp:
1202         * bridge/c/c_instance.cpp:
1203         * bridge/objc/ObjCRuntimeObject.mm:
1204         * bridge/objc/objc_instance.mm:
1205         * bridge/objc/objc_runtime.mm:
1206         * bridge/runtime_array.cpp:
1207         * bridge/runtime_method.cpp:
1208         * bridge/runtime_object.cpp:
1209         * dom/Document.idl:
1210         * dom/DocumentFragment.idl:
1211         * dom/Element.idl:
1212         * dom/Event.idl:
1213         * dom/Node.idl:
1214         * domjit/JSDocumentDOMJIT.cpp:
1215         (WebCore::checkSubClassPatchpointForJSDocument):
1216         (WebCore::DocumentDocumentElementDOMJIT::checkDOM): Deleted.
1217         (WebCore::DocumentBodyDOMJIT::checkDOM): Deleted.
1218         * domjit/JSDocumentFragmentDOMJIT.cpp: Copied from Source/JavaScriptCore/runtime/JSMap.cpp.
1219         (WebCore::checkSubClassPatchpointForJSDocumentFragment):
1220         * domjit/JSElementDOMJIT.cpp: Copied from Source/JavaScriptCore/tools/JSDollarVM.cpp.
1221         (WebCore::checkSubClassPatchpointForJSElement):
1222         * domjit/JSEventDOMJIT.cpp: Copied from Source/JavaScriptCore/tools/JSDollarVM.cpp.
1223         (WebCore::checkSubClassPatchpointForJSEvent):
1224         * domjit/JSNodeDOMJIT.cpp:
1225         (WebCore::checkSubClassPatchpointForJSNode):
1226         (WebCore::NodeFirstChildDOMJIT::checkDOM): Deleted.
1227         (WebCore::NodeLastChildDOMJIT::checkDOM): Deleted.
1228         (WebCore::NodeNextSiblingDOMJIT::checkDOM): Deleted.
1229         (WebCore::NodePreviousSiblingDOMJIT::checkDOM): Deleted.
1230         (WebCore::NodeParentNodeDOMJIT::checkDOM): Deleted.
1231         (WebCore::NodeNodeTypeDOMJIT::checkDOM): Deleted.
1232         (WebCore::NodeOwnerDocumentDOMJIT::checkDOM): Deleted.
1233
1234 2017-05-18  Jer Noble  <jer.noble@apple.com>
1235
1236         [MSE][Mac] Support painting MSE video-element to canvas
1237         https://bugs.webkit.org/show_bug.cgi?id=125157
1238         <rdar://problem/23062016>
1239
1240         Reviewed by Eric Carlson.
1241
1242         Test: media/media-source/media-source-paint-to-canvas.html
1243
1244         In order to have access to decoded video data for painting, decode the encoded samples manually
1245         instead of adding them to the AVSampleBufferDisplayLayer. To facilitate doing so, add a new
1246         utility class WebCoreDecompressionSession, which can decode samples and store them.
1247
1248         For the purposes of this patch, to avoid double-decoding of video data and to avoid severe complication
1249         of our sample delivery pipeline, we will only support painting of decoded video samples when the video is
1250         not displayed in the DOM.
1251
1252         * Modules/mediasource/MediaSource.cpp:
1253         (WebCore::MediaSource::seekToTime): Always send waitForSeekCompleted() to give private a chance to delay seek completion.
1254         * Modules/mediasource/SourceBuffer.cpp:
1255         (WebCore::SourceBuffer::sourceBufferPrivateReenqueSamples): Added.
1256         * Modules/mediasource/SourceBuffer.h:
1257         * WebCore.xcodeproj/project.pbxproj:
1258         * platform/cf/CoreMediaSoftLink.cpp: Added new soft link macros.
1259         * platform/cf/CoreMediaSoftLink.h: Ditto.
1260         * platform/cocoa/CoreVideoSoftLink.cpp: Ditto.
1261         * platform/cocoa/CoreVideoSoftLink.h: Ditto.
1262         * platform/graphics/SourceBufferPrivateClient.h:
1263         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
1264         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::sampleBufferDisplayLayer): Simple accessor.
1265         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::decompressionSession): Ditto.
1266         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
1267         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
1268         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load): Update whether we should be displaying in a layer or decompression session..
1269         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVisible): Ditto.
1270         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::waitForSeekCompleted): m_seeking is now an enum.
1271         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seeking): Ditto.
1272         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekCompleted): Ditto. If waiting for a video frame, delay completing seek.
1273         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::nativeImageForCurrentTime): Call updateLastImage() and return result.
1274         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastImage): Fetch the image for the current time.
1275         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paint): Pass to paintCurrentFrameInCanvas.
1276         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext): Get a native image, and render it.
1277         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged): Create or destroy a layer or decompression session as appropriate.
1278         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer): Creates a layer.
1279         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::destroyLayer): Destroys a layer.
1280         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureDecompressionSession): Creates a decompression session.
1281         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::destroyDecompressionSession): Destroys a decompression session.
1282         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableVideoFrame): If seek completion delayed, complete now. Ditto for ready state change.
1283         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setReadyState): If waiting for a video frame, delay ready state change.
1284         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer): Deleted.
1285         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer): Deleted.
1286         * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
1287         * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
1288         (WebCore::MediaSourcePrivateAVFObjC::hasVideo): Promote to a class function.
1289         (WebCore::MediaSourcePrivateAVFObjC::hasSelectedVideo): Return whether any of the active source buffers have video and are selected.
1290         (WebCore::MediaSourcePrivateAVFObjC::hasSelectedVideoChanged): Call setSourceBufferWithSelectedVideo().
1291         (WebCore::MediaSourcePrivateAVFObjC::setVideoLayer): Set (or clear) the layer on the selected buffer.
1292         (WebCore::MediaSourcePrivateAVFObjC::setDecompressionSession): Ditto for decompression session.
1293         (WebCore::MediaSourcePrivateAVFObjC::setSourceBufferWithSelectedVideo): Remove the layer and decompression session from the unselected
1294
1295                 buffer and add the decompression session or layer to the newly selected buffer.
1296         (WebCore::MediaSourcePrivateAVFObjCHasVideo): Deleted.
1297         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
1298         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
1299         (WebCore::SourceBufferPrivateAVFObjC::destroyRenderers): Clear the videoLayer and decompressionSession.
1300         (WebCore::SourceBufferPrivateAVFObjC::hasSelectedVideo): Return whether the buffer has a selected video track.
1301         (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled): The media player now manages the video layer and decompression session lifetimes.
1302         (WebCore::SourceBufferPrivateAVFObjC::flush): Flush the decompression session, if it exists.
1303         (WebCore::SourceBufferPrivateAVFObjC::enqueueSample): Enqueue to the decompression session, if it exists.
1304         (WebCore::SourceBufferPrivateAVFObjC::isReadyForMoreSamples): As the decompression session, if it exists.
1305         (WebCore::SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples): Tell the decompression session to stop requesting data, if it exists.
1306         (WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples): Request media data from the decompression session, if it exists.
1307         (WebCore::SourceBufferPrivateAVFObjC::setVideoLayer): Added.
1308         (WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Added.
1309         * platform/graphics/cocoa/WebCoreDecompressionSession.h: Added.
1310         (WebCore::WebCoreDecompressionSession::create):
1311         (WebCore::WebCoreDecompressionSession::isInvalidated):
1312         (WebCore::WebCoreDecompressionSession::createWeakPtr):
1313         * platform/graphics/cocoa/WebCoreDecompressionSession.mm: Added.
1314         (WebCore::WebCoreDecompressionSession::WebCoreDecompressionSession): Register for media data requests.
1315         (WebCore::WebCoreDecompressionSession::invalidate):  Unregister for same.
1316         (WebCore::WebCoreDecompressionSession::maybeBecomeReadyForMoreMediaDataCallback): Pass to maybeBecomeReadyForMoreMediaData.
1317         (WebCore::WebCoreDecompressionSession::maybeBecomeReadyForMoreMediaData): Check in-flight decodes, and decoded frame counts.
1318         (WebCore::WebCoreDecompressionSession::enqueueSample): Pass the sample to be decoded on a background queue.
1319         (WebCore::WebCoreDecompressionSession::decodeSample): Decode the sample.
1320         (WebCore::WebCoreDecompressionSession::decompressionOutputCallback): Call handleDecompressionOutput.
1321         (WebCore::WebCoreDecompressionSession::handleDecompressionOutput): Pass decoded sample to be enqueued on the main thread.
1322         (WebCore::WebCoreDecompressionSession::getFirstVideoFrame):
1323         (WebCore::WebCoreDecompressionSession::enqueueDecodedSample): Enqueue the frame (if it's a displayed frame).
1324         (WebCore::WebCoreDecompressionSession::isReadyForMoreMediaData): Return whether we've hit our high water sample count.
1325         (WebCore::WebCoreDecompressionSession::requestMediaDataWhenReady):
1326         (WebCore::WebCoreDecompressionSession::stopRequestingMediaData): Unset the same.
1327         (WebCore::WebCoreDecompressionSession::notifyWhenHasAvailableVideoFrame): Set a callback to notify when a decoded frame has been enqueued.
1328         (WebCore::WebCoreDecompressionSession::imageForTime): Successively dequeue images until reaching one at or beyond the requested time.
1329         (WebCore::WebCoreDecompressionSession::flush): Synchronously empty the producer and consumer queues.
1330         (WebCore::WebCoreDecompressionSession::getDecodeTime): Utility method.
1331         (WebCore::WebCoreDecompressionSession::getPresentationTime): Ditto.
1332         (WebCore::WebCoreDecompressionSession::getDuration): Ditto.
1333         (WebCore::WebCoreDecompressionSession::compareBuffers): Ditto.
1334         * platform/cocoa/VideoToolboxSoftLink.cpp: Added.
1335         * platform/cocoa/VideoToolboxSoftLink.h: Added.
1336
1337 2017-05-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
1338
1339         [REGRESSION](r216901): Delete ImageDecoder if BitmapImage::destroyDecodedData() was called to destroy all the decoded frames
1340         https://bugs.webkit.org/show_bug.cgi?id=172325
1341
1342         Reviewed by Simon Fraser.
1343
1344         When calling BitmapImage::destroyDecodedData() with destroyAll = true, the
1345         current ImageDecoder has to be deleted regardless the current frame needs
1346         to be cached or not. This is true except when the image is animating.
1347         Creating a new ImageDecoder for the animated image will lead to decoding
1348         all the frames from frame-zero till the current frame.
1349
1350         Deleting the current ImageDecoder has the benefit of releasing its raster
1351         data. We also must delete the current ImageDecoder when the CachedImage
1352         switched its data SharedBuffer.
1353
1354         The fix is return the condition in BitmapImage::destroyDecodedData() to 
1355         be as it was before r216901.
1356
1357         * platform/graphics/BitmapImage.cpp:
1358         (WebCore::BitmapImage::destroyDecodedData):
1359
1360 2017-05-18  Ryan Haddad  <ryanhaddad@apple.com>
1361
1362         Unreviewed, rolling out r217079.
1363
1364         This change broke internal builds.
1365
1366         Reverted changeset:
1367
1368         "Redundant ellipsis box triggers
1369         ASSERT_WITH_SECURITY_IMPLICATION in InlineBox::parent()."
1370         https://bugs.webkit.org/show_bug.cgi?id=172309
1371         http://trac.webkit.org/changeset/217079
1372
1373 2017-05-18  Joseph Pecoraro  <pecoraro@apple.com>
1374
1375         Web Inspector: Release InjectedScripts when frontends close
1376         https://bugs.webkit.org/show_bug.cgi?id=172313
1377
1378         Reviewed by Andreas Kling.
1379
1380         * inspector/InspectorController.cpp:
1381         (WebCore::InspectorController::disconnectFrontend):
1382         Release inspector resources together, including discarding injected
1383         scripts so that they may be collected.
1384
1385         (WebCore::InspectorController::inspectedPageDestroyed):
1386         (WebCore::InspectorController::disconnectAllFrontends):
1387         Move the disconnect call inside of disconnectAllFrontends to establish
1388         a pattern of releasing web inspector resources together.
1389
1390 2017-05-18  Simon Fraser  <simon.fraser@apple.com>
1391
1392         Add a newline after the URL in showLayerTree output.
1393
1394         Reviewed by Zalan Bujtas.
1395
1396         * rendering/RenderLayer.cpp:
1397         (WebCore::showLayerTree):
1398
1399 2017-05-18  Wenson Hsieh  <wenson_hsieh@apple.com>
1400
1401         Attachment drag preview should not have the attachment outline
1402         https://bugs.webkit.org/show_bug.cgi?id=172327
1403         <rdar://problem/32282831>
1404
1405         Reviewed by Tim Horton.
1406
1407         When creating a drag image for an attachment element, don't include borders around the attachment.
1408
1409         * page/DragController.cpp:
1410         (WebCore::DragController::startDrag):
1411         * rendering/RenderAttachment.h:
1412         * rendering/RenderThemeIOS.mm:
1413         (WebCore::RenderThemeIOS::paintAttachment):
1414
1415 2017-05-18  Youenn Fablet  <youenn@apple.com>
1416
1417         Make WebRTC logging happen in Release
1418         https://bugs.webkit.org/show_bug.cgi?id=172307
1419
1420         Reviewed by Eric Carlson.
1421
1422         No change of behavior.
1423         Move from LOG(WebRTC...) to RELEASE_LOG(WebRTC...).
1424
1425         * Modules/mediastream/PeerConnectionBackend.cpp:
1426         (WebCore::PeerConnectionBackend::createOfferSucceeded):
1427         (WebCore::PeerConnectionBackend::createOfferFailed):
1428         (WebCore::PeerConnectionBackend::createAnswerSucceeded):
1429         (WebCore::PeerConnectionBackend::createAnswerFailed):
1430         (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded):
1431         (WebCore::PeerConnectionBackend::setLocalDescriptionFailed):
1432         (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded):
1433         (WebCore::PeerConnectionBackend::setRemoteDescriptionFailed):
1434         (WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
1435         (WebCore::PeerConnectionBackend::addIceCandidateFailed):
1436         (WebCore::PeerConnectionBackend::newICECandidate):
1437         (WebCore::PeerConnectionBackend::doneGatheringCandidates):
1438         * Modules/mediastream/RTCPeerConnection.cpp:
1439         (WebCore::RTCPeerConnection::queuedCreateOffer):
1440         (WebCore::RTCPeerConnection::queuedCreateAnswer):
1441         (WebCore::RTCPeerConnection::queuedSetLocalDescription):
1442         (WebCore::RTCPeerConnection::queuedSetRemoteDescription):
1443         (WebCore::RTCPeerConnection::queuedAddIceCandidate):
1444
1445 2017-05-18  Eric Carlson  <eric.carlson@apple.com>
1446
1447         [MediaStream] do not cache gUM permissions
1448         https://bugs.webkit.org/show_bug.cgi?id=172245
1449
1450         Reviewed by Youenn Fablet.
1451
1452         No new tests, updated fast/mediastream/MediaDevices-getUserMedia.html.
1453
1454         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
1455         (WebCore::RealtimeMediaSourceCenter::validateRequestConstraints): Add salt parameter.
1456         * platform/mediastream/RealtimeMediaSourceCenter.h:
1457
1458 2017-05-18  Zalan Bujtas  <zalan@apple.com>
1459
1460         Redundant ellipsis box triggers ASSERT_WITH_SECURITY_IMPLICATION in InlineBox::parent().
1461         https://bugs.webkit.org/show_bug.cgi?id=172309
1462         <rdar://problem/32262357>
1463
1464         Reviewed by Simon Fraser.
1465
1466         This patch stops the redundant ellipsis box trigger ASSERT_WITH_SECURITY_IMPLICATION.
1467
1468         In RootInlineBox::placeEllipsis we construct an ellipsis box and append it to a static HashMap which
1469         keeps track of the ellipsis boxes on each line. However when the line already has an ellipsis, we
1470         re-use the existing one and this newly constructed (but redundant) box gets destroyed as we return from this function.
1471         In InlineBox's d'tor, we let the parent know that now it has a dangling child and we assert on it
1472         later, while accessing the children list. However this redundant ellipsis box was never added to the line,
1473         so the assertion hits incorrectly.
1474
1475         Test: fast/inline/redundant-ellipsis-triggers-assert-incorrectly.html
1476
1477         * rendering/EllipsisBox.cpp:
1478         (WebCore::EllipsisBox::EllipsisBox):
1479         * rendering/InlineBox.cpp:
1480         (WebCore::InlineBox::invalidateParentChildList):
1481         * rendering/InlineBox.h:
1482         * rendering/RootInlineBox.cpp:
1483         (WebCore::RootInlineBox::placeEllipsis): Use the newly created ellipsis box instead.
1484
1485 2017-05-18  Andy Estes  <aestes@apple.com>
1486
1487         ENABLE(APPLE_PAY_DELEGATE) should be NO on macOS Sierra and earlier
1488         https://bugs.webkit.org/show_bug.cgi?id=172305
1489
1490         Reviewed by Anders Carlsson.
1491
1492         * Configurations/FeatureDefines.xcconfig:
1493
1494 2017-05-18  Dean Jackson  <dino@apple.com>
1495
1496         Transform misplaces element 50% of the time
1497         https://bugs.webkit.org/show_bug.cgi?id=172300
1498
1499         Reviewed by Simon Fraser.
1500
1501         A hardware-accelerated animation of the transform property
1502         requires layout to happen if it contains a translate operation
1503         using percentages, otherwise it may create an incorrect
1504         animation. The "50% of the time" comes in to play because
1505         the layout timer may sometimes fire before the animation
1506         timer. The test case contains a example that is much more
1507         likely to fail without this fix.
1508
1509         Test: animations/needs-layout.html
1510
1511         * page/animation/CSSAnimationController.cpp:
1512         (WebCore::CSSAnimationControllerPrivate::animationTimerFired): If
1513         we've been told that we need a layout, and we have one pending, then
1514         force it before doing the rest of the animation logic.
1515         (WebCore::CSSAnimationController::updateAnimations): Check if the
1516         CompositeAnimation depends on layout, and tell the private controller
1517         that it should check for the necessity of a layout as the animation
1518         timer fires.
1519
1520         * page/animation/CompositeAnimation.cpp:
1521         (WebCore::CompositeAnimation::animate): Ask the keyframes if this
1522         animation depends on layout.
1523
1524         * page/animation/CompositeAnimation.h:
1525         (WebCore::CompositeAnimation::hasAnimationThatDependsOnLayout):
1526         * page/animation/KeyframeAnimation.cpp:
1527         (WebCore::KeyframeAnimation::KeyframeAnimation):
1528         (WebCore::KeyframeAnimation::computeLayoutDependency): Look at all
1529         the keyframe properties for something that is a translation using
1530         percentages.
1531
1532         * page/animation/KeyframeAnimation.h:
1533
1534 2017-05-18  Wenson Hsieh  <wenson_hsieh@apple.com>
1535
1536         Selection around attachment elements should not persist when beginning a drag
1537         https://bugs.webkit.org/show_bug.cgi?id=172319
1538         <rdar://problem/32283008>
1539
1540         Reviewed by Tim Horton.
1541
1542         When beginning to drag an attachment element, save and restore the visible selection when calling out to the
1543         injected bundle for additional data, and when creating the drag image.
1544
1545         Augmented an existing API test: DataInteractionTests.AttachmentElementItemProviders.
1546
1547         * page/DragController.cpp:
1548         (WebCore::DragController::startDrag):
1549
1550 2017-05-18  Daniel Bates  <dabates@apple.com>
1551
1552         Cleanup: Remove unused functions from RuntimeEnabledFeatures
1553         https://bugs.webkit.org/show_bug.cgi?id=172315
1554
1555         Reviewed by Jer Noble.
1556
1557         * page/RuntimeEnabledFeatures.cpp:
1558         (WebCore::RuntimeEnabledFeatures::htmlMediaElementEnabled): Deleted.
1559         (WebCore::RuntimeEnabledFeatures::htmlVideoElementEnabled): Deleted.
1560         (WebCore::RuntimeEnabledFeatures::htmlSourceElementEnabled): Deleted.
1561         (WebCore::RuntimeEnabledFeatures::mediaControllerEnabled): Deleted.
1562         (WebCore::RuntimeEnabledFeatures::mediaErrorEnabled): Deleted.
1563         (WebCore::RuntimeEnabledFeatures::timeRangesEnabled): Deleted.
1564         * page/RuntimeEnabledFeatures.h:
1565         (WebCore::RuntimeEnabledFeatures::setDOMIteratorEnabled): Deleted.
1566         (WebCore::RuntimeEnabledFeatures::domIteratorEnabled): Deleted.
1567         (WebCore::RuntimeEnabledFeatures::setGeolocationEnabled): Deleted.
1568         (WebCore::RuntimeEnabledFeatures::geolocationEnabled): Deleted.
1569
1570 2017-05-18  Daniel Bates  <dabates@apple.com>
1571
1572         Improve error message for Access-Control-Allow-Origin violation due to misconfigured server
1573         https://bugs.webkit.org/show_bug.cgi?id=162819
1574         <rdar://problem/28575938>
1575
1576         Reviewed by Joseph Pecoraro.
1577
1578         Inspired by Blink change:
1579         <https://src.chromium.org/viewvc/blink?view=revision&revision=163406>
1580
1581         At most one Access-Control-Allow-Origin header may be in an HTTP response. Improve the
1582         error message emitted on a CORS failure when Access-Control-Allow-Origin contains more
1583         than one origin, indicated by the presence of a ',', as a way to help web developers/server
1584         administrators differentiate between a misconfigured Access-Control-Allow-Origin header
1585         and a misconfigured server.
1586
1587         * loader/CrossOriginAccessControl.cpp:
1588         (WebCore::passesAccessControlCheck): Defined a local variable to hold the value of securityOrigin.toString()
1589         and referenced this variable throughout the code to avoid computing the stringified security
1590         origin more than once. Switched to using makeString() to concatenate error message when the
1591         origin of the page does not match the value of the Access-Control-Allow-Origin header.
1592
1593 2017-05-18  John Wilander  <wilander@apple.com>
1594
1595         Resource Load Statistics: Grandfather domains for existing data records
1596         https://bugs.webkit.org/show_bug.cgi?id=172155
1597         <rdar://problem/24913532>
1598
1599         Reviewed by Alex Christensen.
1600
1601         Test: http/tests/loading/resourceLoadStatistics/grandfathering.html
1602
1603         * loader/ResourceLoadObserver.cpp:
1604         (WebCore::ResourceLoadObserver::setGrandfathered):
1605         (WebCore::ResourceLoadObserver::isGrandfathered):
1606         (WebCore::ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval):
1607         (WebCore::ResourceLoadObserver::setGrandfatheringTime):
1608             Functions for testing and configuration.
1609             ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval() changed as a result of moving
1610             WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval() here.
1611         * loader/ResourceLoadObserver.h:
1612         * loader/ResourceLoadStatisticsStore.cpp:
1613         (WebCore::ResourceLoadStatisticsStore::createEncoderFromData):
1614         (WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
1615             Now contains endOfGrandfatheringTimestamp.
1616         (WebCore::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
1617             Now makes a call to m_grandfatherExistingWebsiteDataHandler().
1618         (WebCore::ResourceLoadStatisticsStore::setGrandfatherExistingWebsiteDataCallback):
1619         (WebCore::ResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval):
1620             Changed as a result of moving
1621             WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval() here.
1622         (WebCore::ResourceLoadStatisticsStore::setGrandfatheringTime):
1623         (WebCore::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
1624             Renamed since it now also takes grandfathering into account.
1625         (WebCore::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
1626             Fixed typo in local variable name.
1627         (WebCore::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
1628         (WebCore::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
1629             Convenience function added.
1630         (WebCore::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
1631             Convenience function added.
1632         (WebCore::ResourceLoadStatisticsStore::dataRecordsWereRemoved):
1633             Convenience function added.
1634         (WebCore::ResourceLoadStatisticsStore::prevalentResourceDomainsWithoutUserInteraction): Deleted.
1635             Replaced by ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor().
1636         * loader/ResourceLoadStatisticsStore.h:
1637
1638 2017-05-18  Daniel Bates  <dabates@apple.com>
1639
1640         Bindings: Require value for extended attributes EnabledAtRuntime and EnabledForWorld
1641         https://bugs.webkit.org/show_bug.cgi?id=172252
1642
1643         Reviewed by Sam Weinig.
1644
1645         According to Sam Weinig it is an anti-feature that EnabledAtRuntime can be specified
1646         without a value. We should make it require a value for the name of the RuntimeEnabledFeatures
1647         function to use in the generated code. For similar reasons we should also require
1648         a value for the extended attribute EnabledForWorld.
1649
1650         * Modules/websockets/WebSocket.idl: Substitute EnabledAtRuntime=WebSocket for EnabledAtRuntime.
1651         * bindings/scripts/CodeGeneratorJS.pm:
1652         (GetRuntimeEnableFunctionName):
1653         * html/HTMLAudioElement.idl: Substitute EnabledAtRuntime=Audio for EnabledAtRuntime.
1654         * page/RuntimeEnabledFeatures.cpp:
1655         (WebCore::RuntimeEnabledFeatures::audioEnabled):
1656         (WebCore::RuntimeEnabledFeatures::htmlAudioElementEnabled): Deleted. This function duplicated
1657         the functionality of RuntimeEnabledFeatures::audioEnabled(). Instead we explicitly
1658         write EnabledAtRuntime=Audio in HTMLAudioElement.idl to use RuntimeEnabledFeatures::audioEnabled()
1659         to determine whether to expose/conceal the HTMLAudioElement global constructor at runtime.
1660         * page/RuntimeEnabledFeatures.h:
1661
1662 2017-05-18  Jer Noble  <jer.noble@apple.com>
1663
1664         Allow nested timers to propagate user gestures so long as the total nested interval is less than 1s.
1665         https://bugs.webkit.org/show_bug.cgi?id=172173
1666
1667         Reviewed by Andy Estes.
1668
1669         Test: media/restricted-audio-playback-with-multiple-settimeouts.html
1670
1671         Store the current nested timer interval in DOMTimerFireState, and use that value to propagate the
1672         nested interval through multiple invocations of setTimeout().
1673
1674         Drive-by fix: instead of manually resetting the nesting level in DOMTimer::fired(), add the
1675         nesting level to the DOMTimerFireState, and reset the nesting level on the state's destruction.
1676         This fixes one place in DOMTimer::fire() where an early return lead to the timer's nesting level
1677         not being reset.
1678
1679         * page/DOMTimer.cpp:
1680         (WebCore::DOMTimerFireState::DOMTimerFireState):
1681         (WebCore::DOMTimerFireState::~DOMTimerFireState):
1682         (WebCore::DOMTimerFireState::nestedTimerInterval):
1683         (WebCore::shouldForwardUserGesture):
1684         (WebCore::userGestureTokenToForward):
1685         (WebCore::currentNestedTimerInterval):
1686         (WebCore::DOMTimer::DOMTimer):
1687         (WebCore::DOMTimer::fired):
1688         * page/DOMTimer.h:
1689
1690 2017-05-18  Youenn Fablet  <youenn@apple.com>
1691
1692         RealtimeOutgoingAudioSource should use the source sample rate
1693         https://bugs.webkit.org/show_bug.cgi?id=172297
1694
1695         Reviewed by Eric Carlson.
1696
1697         Covered by manual tests.
1698
1699         * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
1700         (WebCore::RealtimeOutgoingAudioSource::audioSamplesAvailable): Using the audio source sample rate so that the converter does the right conversion.
1701
1702 2017-05-18  Andy Estes  <aestes@apple.com>
1703
1704         Add "countryCode" to ApplePayErrorContactField
1705         https://bugs.webkit.org/show_bug.cgi?id=172264
1706         <rdar://problem/32004909>
1707
1708         Reviewed by Anders Carlsson.
1709
1710         Added ApplePayError tests to http/tests/ssl/applepay/ApplePaySession.html
1711
1712         * Modules/applepay/ApplePayError.idl:
1713         * Modules/applepay/PaymentRequest.h:
1714
1715 2017-05-18  Daniel Bates  <dabates@apple.com>
1716
1717         Cleanup: Remove unnecessary call to AddToImplIncludes("RuntimeEnabledFeatures.h") in GenerateImplementation()
1718         https://bugs.webkit.org/show_bug.cgi?id=172236
1719
1720         Reviewed by Chris Dumez.
1721
1722         It is unnecessary for GenerateImplementation() to explicitly call AddToImplIncludes("RuntimeEnabledFeatures.h")
1723         to add the header RuntimeEnabledFeatures.h to the list of headers in the generated implementation
1724         as this header is added when GetRuntimeEnableFunctionName() is called. And GenerateImplementation()
1725         calls GetRuntimeEnableFunctionName().
1726
1727         No functionality changed. So, no new tests.
1728
1729         * bindings/scripts/CodeGeneratorJS.pm:
1730         (GenerateImplementation):
1731
1732 2017-05-18  Daniel Bates  <dabates@apple.com>
1733
1734         REGRESSION (r209608): Cross-origin plugin document opened in child window blocked by parent
1735         window CSP when object-src 'none' is set
1736         https://bugs.webkit.org/show_bug.cgi?id=172038
1737         <rdar://problem/32258262>
1738
1739         Reviewed by Andy Estes.
1740
1741         Fixes an issue where a cross-origin plugin document opened in a child window would inherit
1742         the Content Security Policy (CSP) of its opener. In particular, a cross-origin plugin
1743         document opened in a child window would be blocked when the CSP of its opener disallows
1744         plugins (e.g. object-source 'none').
1745
1746         Prior to r209608 a document opened in a child window never inherited the CSP from its opener
1747         and a plugin document loaded in a subframe would unconditionally inherit the CSP from its
1748         parent frame. So, a plugin document opened in a child window would be allowed to load
1749         regardless of whether its opener had a CSP that prevented plugins. Following r209608 a
1750         document opened in a child window would inherit its CSP from its opener if and only if it
1751         would inherit the security origin from its opener (e.g. about:blank) or was a plugin
1752         document. The latter condition makes plugin documents opened in a child window unconditionally
1753         inherit the CSP from their opener and is the cause of this bug. It seems reasonable to exempt
1754         cross-origin plugin documents opened in a child window from the CSP inheritance rule because
1755         such documents cannot compromise the origin of their opener. Same-origin plugin documents
1756         opened in a child window will continue to inherit the CSP from their opener because such
1757         documents can compromise the origin of their opener.
1758
1759         Tests: http/tests/security/contentSecurityPolicy/cross-origin-plugin-document-allowed-in-child-window.html
1760                http/tests/security/contentSecurityPolicy/plugin-blocked-in-about-blank-window.html
1761                http/tests/security/contentSecurityPolicy/same-origin-plugin-document-blocked-in-child-window.html
1762
1763         * dom/Document.cpp:
1764         (WebCore::Document::shouldInheritContentSecurityPolicyFromOwner): Added.
1765         (WebCore::Document::initContentSecurityPolicy):
1766         * dom/Document.h:
1767
1768 2017-05-18  Keith Miller  <keith_miller@apple.com>
1769
1770         WebAssembly API: test with neutered inputs
1771         https://bugs.webkit.org/show_bug.cgi?id=163899
1772
1773         Reviewed by JF Bastien.
1774
1775         Make it not possible to transfer an ArrayBuffer that is backed by a
1776         wasm memory.
1777
1778         Test: workers/wasm-mem-post-message.html
1779
1780         * bindings/js/SerializedScriptValue.cpp:
1781         (WebCore::SerializedScriptValue::create):
1782
1783 2017-05-18  Commit Queue  <commit-queue@webkit.org>
1784
1785         Unreviewed, rolling out r217031, r217032, and r217037.
1786         https://bugs.webkit.org/show_bug.cgi?id=172293
1787
1788         cause linking errors in Windows (Requested by yusukesuzuki on
1789         #webkit).
1790
1791         Reverted changesets:
1792
1793         "[JSC][DFG][DOMJIT] Extend CheckDOM to CheckSubClass"
1794         https://bugs.webkit.org/show_bug.cgi?id=172098
1795         http://trac.webkit.org/changeset/217031
1796
1797         "Unreviewed, rebaseline for newly added ClassInfo"
1798         https://bugs.webkit.org/show_bug.cgi?id=172098
1799         http://trac.webkit.org/changeset/217032
1800
1801         "Unreviewed, fix debug and non-JIT build"
1802         https://bugs.webkit.org/show_bug.cgi?id=172098
1803         http://trac.webkit.org/changeset/217037
1804
1805 2017-05-18  Per Arne Vollan  <pvollan@apple.com>
1806
1807         Protect MediaDeviceRequest instance during context destruction.
1808         https://bugs.webkit.org/show_bug.cgi?id=172285
1809         <rdar://problem/30369017>
1810
1811         Reviewed by Brent Fulgham.
1812
1813         In MediaDevicesRequest::contextDestroyed(), the call to m_enumerationRequest->cancel() might
1814         end up deleting itself (MediaDevicesRequest). The std::function member m_completionHandler
1815         in MediaDevicesEnumerationRequest contains a captured variable of type
1816         RefPtr<MediaDevicesRequest>. When m_completionHandler is set to null in the cancel() method,
1817         the MediaDevicesRequest object will be deleted if the m_completionHandler member is holding
1818         the last reference.
1819
1820         No new tests, since I am unable to reproduce.
1821
1822         * Modules/mediastream/MediaDevicesRequest.cpp:
1823         (WebCore::MediaDevicesRequest::contextDestroyed):
1824
1825 2017-05-18  Antti Koivisto  <antti@apple.com>
1826
1827         Design mode should not affect UA shadow trees
1828         https://bugs.webkit.org/show_bug.cgi?id=171854
1829         <rdar://problem/32071037>
1830
1831         Reviewed by Zalan Bujtas.
1832
1833         Test: editing/deleting/search-shadow-tree-delete.html
1834
1835         * html/HTMLElement.cpp:
1836         (WebCore::HTMLElement::editabilityFromContentEditableAttr):
1837
1838             Ignore design mode for UA shadow trees.
1839
1840         * html/SearchInputType.cpp:
1841         (WebCore::SearchInputType::~SearchInputType):
1842         (WebCore::SearchInputType::createShadowSubtree):
1843         (WebCore::SearchInputType::resultsButtonElement):
1844         (WebCore::SearchInputType::cancelButtonElement):
1845         * html/SearchInputType.h:
1846
1847             Use RefPtr.
1848
1849 2017-05-18  Vanessa Chipirrás Navalón  <vchipirras@igalia.com>
1850
1851         [GTK][GStreamer][MSE] Crash on youtube when MSE is enabled but gstreamer cant find the decoder element.
1852         https://bugs.webkit.org/show_bug.cgi?id=167120
1853
1854         Reviewed by Žan Doberšek.
1855
1856         This is because supportCodecs() doesn't check in runtime which plugins the player has.
1857         So, a static function which returns a map with the plugins has been created. That map is later
1858         used in the supportsCodecs() method to check if the requested codec matches any of the map.
1859
1860         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
1861         (WebCore::MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements):
1862         The declaration is moved into this class.
1863         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
1864         (WebCore::MediaPlayerPrivateGStreamer::isAvailable): This function calls the implementation of
1865         initializeGstreamerAndRegisterWebKitElements function.
1866         (WebCore::MediaPlayerPrivateGStreamer::load): Ditto
1867         (WebCore::mimeTypeSet): Ditto
1868         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h: It is static type to expose
1869         initializeGStreamerAndRegisterWebKitElements() function to be called from internal function
1870         "which runs before MediaPlayerPrivateGStreamerBase initialization but needs to have GStreamer initialized".
1871         * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
1872         (WebCore::codecSet): It returns a map with the plugins has been created.
1873         (WebCore::MediaPlayerPrivateGStreamerMSE::supportsCodecs): To check if the requested codec
1874         matches any of the map from codecSet().
1875
1876 2017-05-18  Romain Bellessort  <romain.bellessort@crf.canon.fr>
1877
1878         [Readable Streams API] Align getDesiredSize with spec
1879         https://bugs.webkit.org/show_bug.cgi?id=172220
1880
1881         Reviewed by Chris Dumez.
1882
1883         Aligned implementation of getDesiredSize operation for both controllers:
1884         - https://streams.spec.whatwg.org/#readable-stream-default-controller-get-desired-size
1885         - https://streams.spec.whatwg.org/#readable-byte-stream-controller-get-desired-size
1886
1887         Implementation slightly differs from spec as queueTotalSize refactoring is not
1888         yet implemented, but behavior is now similar.
1889
1890         No new tests (already covered by WPT tests, corresponding expectations have been updated).
1891
1892         * Modules/streams/ReadableByteStreamInternals.js:
1893         (readableByteStreamControllerGetDesiredSize): Updated.
1894         * Modules/streams/ReadableStreamInternals.js:
1895         (readableStreamDefaultControllerGetDesiredSize): Updated.
1896
1897 2017-05-18  Tim Horton  <timothy_horton@apple.com>
1898
1899         More WebKit2 header cleanup
1900         https://bugs.webkit.org/show_bug.cgi?id=172214
1901
1902         Reviewed by Simon Fraser.
1903
1904         * Modules/mediastream/UserMediaController.cpp:
1905         * Modules/mediastream/UserMediaController.h:
1906
1907 2017-05-16  Yusuke Suzuki  <utatane.tea@gmail.com>
1908
1909         [JSC][DFG][DOMJIT] Extend CheckDOM to CheckSubClass
1910         https://bugs.webkit.org/show_bug.cgi?id=172098
1911
1912         Reviewed by Saam Barati.
1913
1914         Add DOMJIT interface IDL attribute. Which allows us to define checkSubClassPatchpoint function
1915         for that ClassInfo. And we move CheckSubClass patchpoint implementation to ClassInfo's member.
1916
1917         * CMakeLists.txt:
1918         * WebCore.xcodeproj/project.pbxproj:
1919         * bindings/js/JSDOMGlobalObject.cpp:
1920         * bindings/js/JSDOMWindowBase.cpp:
1921         * bindings/js/JSDOMWindowProperties.cpp:
1922         * bindings/js/JSDOMWindowShell.cpp:
1923         * bindings/js/JSReadableStreamPrivateConstructors.cpp:
1924         * bindings/js/JSWorkerGlobalScopeBase.cpp:
1925         * bindings/scripts/CodeGeneratorJS.pm:
1926         (GenerateHeader):
1927         (GenerateImplementation):
1928         (GenerateImplementationIterableFunctions):
1929         (GenerateConstructorHelperMethods):
1930         * bindings/scripts/IDLAttributes.json:
1931         * bindings/scripts/test/JS/JSInterfaceName.cpp:
1932         * bindings/scripts/test/JS/JSMapLike.cpp:
1933         * bindings/scripts/test/JS/JSReadOnlyMapLike.cpp:
1934         * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
1935         * bindings/scripts/test/JS/JSTestCEReactions.cpp:
1936         * bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp:
1937         * bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
1938         * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.cpp:
1939         * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp:
1940         * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
1941         * bindings/scripts/test/JS/JSTestDOMJIT.cpp:
1942         * bindings/scripts/test/JS/JSTestDOMJIT.h:
1943         * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
1944         * bindings/scripts/test/JS/JSTestEventTarget.cpp:
1945         * bindings/scripts/test/JS/JSTestException.cpp:
1946         * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
1947         * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
1948         * bindings/scripts/test/JS/JSTestInterface.cpp:
1949         * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.cpp:
1950         * bindings/scripts/test/JS/JSTestIterable.cpp:
1951         * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp:
1952         * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
1953         * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
1954         * bindings/scripts/test/JS/JSTestNode.cpp:
1955         * bindings/scripts/test/JS/JSTestObj.cpp:
1956         * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
1957         * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
1958         * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp:
1959         * bindings/scripts/test/JS/JSTestPromiseRejectionEvent.cpp:
1960         * bindings/scripts/test/JS/JSTestSerialization.cpp:
1961         * bindings/scripts/test/JS/JSTestSerializationInherit.cpp:
1962         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp:
1963         * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
1964         * bindings/scripts/test/JS/JSTestTypedefs.cpp:
1965         * bridge/c/CRuntimeObject.cpp:
1966         * bridge/c/c_instance.cpp:
1967         * bridge/objc/ObjCRuntimeObject.mm:
1968         * bridge/objc/objc_instance.mm:
1969         * bridge/objc/objc_runtime.mm:
1970         * bridge/runtime_array.cpp:
1971         * bridge/runtime_method.cpp:
1972         * bridge/runtime_object.cpp:
1973         * dom/Document.idl:
1974         * dom/DocumentFragment.idl:
1975         * dom/Element.idl:
1976         * dom/Event.idl:
1977         * dom/Node.idl:
1978         * domjit/JSDocumentDOMJIT.cpp:
1979         (WebCore::JSDocument::checkSubClassPatchpoint):
1980         (WebCore::DocumentDocumentElementDOMJIT::checkDOM): Deleted.
1981         (WebCore::DocumentBodyDOMJIT::checkDOM): Deleted.
1982         * domjit/JSDocumentFragmentDOMJIT.cpp: Copied from Source/JavaScriptCore/runtime/JSMap.cpp.
1983         (WebCore::JSDocumentFragment::checkSubClassPatchpoint):
1984         * domjit/JSElementDOMJIT.cpp: Copied from Source/JavaScriptCore/tools/JSDollarVM.cpp.
1985         (WebCore::JSElement::checkSubClassPatchpoint):
1986         * domjit/JSEventDOMJIT.cpp: Copied from Source/JavaScriptCore/tools/JSDollarVM.cpp.
1987         (WebCore::JSEvent::checkSubClassPatchpoint):
1988         * domjit/JSNodeDOMJIT.cpp:
1989         (WebCore::JSNode::checkSubClassPatchpoint):
1990         (WebCore::NodeFirstChildDOMJIT::checkDOM): Deleted.
1991         (WebCore::NodeLastChildDOMJIT::checkDOM): Deleted.
1992         (WebCore::NodeNextSiblingDOMJIT::checkDOM): Deleted.
1993         (WebCore::NodePreviousSiblingDOMJIT::checkDOM): Deleted.
1994         (WebCore::NodeParentNodeDOMJIT::checkDOM): Deleted.
1995         (WebCore::NodeNodeTypeDOMJIT::checkDOM): Deleted.
1996         (WebCore::NodeOwnerDocumentDOMJIT::checkDOM): Deleted.
1997
1998 2017-05-17  Youenn Fablet  <youenn@apple.com>
1999
2000         r216999 broke win build
2001         https://bugs.webkit.org/show_bug.cgi?id=172257
2002
2003         Unreviewed.
2004
2005         * testing/Internals.cpp:
2006         (WebCore::Internals::setPageVisibility): Moving setPageVisibility out of MEDIA_STREAM compilation flag.
2007
2008 2017-05-17  Andy Estes  <aestes@apple.com>
2009
2010         [Cocoa] errors are not propagated to PassKit when calling ApplePaySession.completePayment()
2011         https://bugs.webkit.org/show_bug.cgi?id=172253
2012         <rdar://problem/32258020>
2013
2014         Reviewed by Dan Bernstein.
2015
2016         In ApplePaySession::completePayment(), releaseReturnValue() was being called twice on the
2017         same convertedResult. Since the first call moved the errors vector out of convertedResult,
2018         the vector is empty in the second call. It's the second call that sends the result to the
2019         UI process, so we end up with an empty arary when we call PassKit's delegate completion
2020         handler.
2021
2022         * Modules/applepay/ApplePaySession.cpp:
2023         (WebCore::ApplePaySession::completePayment):
2024
2025 2017-05-17  Ryan Haddad  <ryanhaddad@apple.com>
2026
2027         Unreviewed, rolling out r217014.
2028
2029         This change caused mac-wk2 LayoutTests to exit early due to
2030         crashes.
2031
2032         Reverted changeset:
2033
2034         "Resource Load Statistics: Grandfather domains for existing
2035         data records"
2036         https://bugs.webkit.org/show_bug.cgi?id=172155
2037         http://trac.webkit.org/changeset/217014
2038
2039 2017-05-17  Zalan Bujtas  <zalan@apple.com>
2040
2041         Tighten TextIterator::handleTextNode run-renderer mapping logic.
2042         https://bugs.webkit.org/show_bug.cgi?id=172174
2043
2044         Reviewed by Antti Koivisto.
2045
2046         This patch ensure that when runs and renderers are getting out of sync
2047         we don't run into problems like webkit.org/b/172113 (where we end up
2048         using incorrect content start/end positions).
2049
2050         * editing/TextIterator.cpp:
2051         (WebCore::TextIterator::handleTextNode):
2052
2053 2017-05-17  John Wilander  <wilander@apple.com>
2054
2055         Resource Load Statistics: Grandfather domains for existing data records
2056         https://bugs.webkit.org/show_bug.cgi?id=172155
2057         <rdar://problem/24913532>
2058
2059         Reviewed by Alex Christensen.
2060
2061         Test: http/tests/loading/resourceLoadStatistics/grandfathering.html
2062
2063         * loader/ResourceLoadObserver.cpp:
2064         (WebCore::ResourceLoadObserver::setGrandfathered):
2065         (WebCore::ResourceLoadObserver::isGrandfathered):
2066         (WebCore::ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval):
2067         (WebCore::ResourceLoadObserver::setGrandfatheringTime):
2068             Functions for testing and configuration.
2069             ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval() changed as a result of moving
2070             WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval() here.
2071         * loader/ResourceLoadObserver.h:
2072         * loader/ResourceLoadStatisticsStore.cpp:
2073         (WebCore::ResourceLoadStatisticsStore::createEncoderFromData):
2074         (WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
2075             Now contains endOfGrandfatheringTimestamp.
2076         (WebCore::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
2077             Now makes a call to m_grandfatherExistingWebsiteDataHandler().
2078         (WebCore::ResourceLoadStatisticsStore::setGrandfatherExistingWebsiteDataCallback):
2079         (WebCore::ResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval):
2080             Changed as a result of moving
2081             WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval() here.
2082         (WebCore::ResourceLoadStatisticsStore::setGrandfatheringTime):
2083         (WebCore::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
2084             Renamed since it now also takes grandfathering into account.
2085         (WebCore::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
2086             Fixed typo in local variable name.
2087         (WebCore::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
2088         (WebCore::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
2089             Convenience function added.
2090         (WebCore::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
2091             Convenience function added.
2092         (WebCore::ResourceLoadStatisticsStore::dataRecordsWereRemoved):
2093             Convenience function added.
2094         (WebCore::ResourceLoadStatisticsStore::prevalentResourceDomainsWithoutUserInteraction): Deleted.
2095             Replaced by ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor().
2096         * loader/ResourceLoadStatisticsStore.h:
2097
2098 2017-05-17  Zalan Bujtas  <zalan@apple.com>
2099
2100         Debug ASSERT: WebCore::RenderImageResource::shutdown
2101         https://bugs.webkit.org/show_bug.cgi?id=172238
2102         <rdar://problem/30064601>
2103
2104         Reviewed by Simon Fraser.
2105
2106         While constructing new renderers, as part of the render tree update, we check if the insertion point is valid for them. 
2107         When this newly constructed child renderer can't be injected to a specific place, we destroy it right away.
2108         This assert was added with the assumption that the image resource object gets initialized
2109         (through RenderObject::initializeStyle) even when the renderer turns out to be invalid.
2110
2111         Test: fast/images/assert-when-insertion-point-is-incorrect.html
2112
2113         * rendering/RenderImageResource.cpp:
2114         (WebCore::RenderImageResource::RenderImageResource):
2115         (WebCore::RenderImageResource::shutdown):
2116         * rendering/RenderImageResource.h:
2117
2118 2017-05-17  Per Arne Vollan  <pvollan@apple.com>
2119
2120         Crash under WebCore::AudioSourceProviderAVFObjC::process().
2121         https://bugs.webkit.org/show_bug.cgi?id=172101
2122         rdar://problem/27446589
2123
2124         Reviewed by Jer Noble.
2125
2126         Calling the function MTAudioProcessingTapGetSourceAudio when the value of the
2127         MTAudioProcessingTapRef parameter is null, will lead to a null dereference.
2128         This can for example happen if MediaPlayerPrivateAVFoundationObjC::cancelLoad()
2129         is called on the main thread while MediaToolbox is calling the
2130         WebCore::AudioSourceProviderAVFObjC::processCallback function on a secondary
2131         thread. MediaPlayerPrivateAVFoundationObjC::cancelLoad() will then call
2132         AudioSourceProviderAVFObjC::setPlayerItem(nullptr), which will call
2133         AudioSourceProviderAVFObjC::destroyMix(), which will set m_tap to null. When
2134         AudioSourceProviderAVFObjC::process is called on the secondary thread, using
2135         the m_tap member in the call to MTAudioProcessingTapGetSourceAudio, the process
2136         will crash.
2137
2138         No new tests since I am not able to reproduce.
2139
2140         * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
2141         (WebCore::AudioSourceProviderAVFObjC::initCallback):
2142         (WebCore::AudioSourceProviderAVFObjC::process):
2143
2144 2017-05-17  Chris Dumez  <cdumez@apple.com>
2145
2146         Setting URL.search to '' results in a stringified URL ending in '?'
2147         https://bugs.webkit.org/show_bug.cgi?id=162345
2148         <rdar://problem/31800441>
2149
2150         Reviewed by Alex Christensen.
2151
2152         As per the specification for the URL.search setter [1], if the given value is
2153         the empty string, then we should set the URL's query to null. We would
2154         previously set the URL's query to the empty string in this case. This aligns
2155         our behavior with Firefox and Chrome.
2156
2157         [1] https://url.spec.whatwg.org/#dom-url-search
2158
2159         No new tests, updated existing tests.
2160
2161         * html/URLUtils.h:
2162         (WebCore::URLUtils<T>::setSearch):
2163
2164 2017-05-17  Eric Carlson  <eric.carlson@apple.com>
2165
2166         [MediaStream] videoWidth and videoHeight should be set when 'loadedmetadata' event fires
2167         https://bugs.webkit.org/show_bug.cgi?id=172223
2168         <rdar://problem/31899755>
2169
2170         Reviewed by Jer Noble.
2171
2172         Test: fast/mediastream/get-user-media-on-loadedmetadata.html
2173
2174         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
2175         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::currentReadyState): If a stream has
2176         a video track, return HaveNothing until we have a sample.
2177        
2178         * platform/mediastream/RealtimeMediaSource.h:
2179         * platform/mock/MockRealtimeAudioSource.cpp:
2180         (WebCore::MockRealtimeAudioSource::tick): Optionally delay the next sample.
2181         (WebCore::MockRealtimeAudioSource::delaySamples):
2182         * platform/mock/MockRealtimeAudioSource.h:
2183
2184         * platform/mock/MockRealtimeVideoSource.cpp:
2185         (WebCore::MockRealtimeVideoSource::delaySamples):
2186         (WebCore::MockRealtimeVideoSource::generateFrame): Optionally delay the next sample.
2187         * platform/mock/MockRealtimeVideoSource.h:
2188
2189         * testing/Internals.cpp:
2190         (WebCore::Internals::delayMediaStreamTrackSamples):
2191         * testing/Internals.h:
2192         * testing/Internals.idl:
2193
2194 2017-05-17  Youenn Fablet  <youenn@apple.com>
2195
2196         iOS WebRTC Media Capture should not allow camera capture from background tab
2197         https://bugs.webkit.org/show_bug.cgi?id=172200
2198
2199         Reviewed by Eric Carlson.
2200
2201         Test: platform/ios/mediastream/getUserMedia-disabled-in-background-tabs.html and manual tests.
2202
2203         Making Video Capture Factory aware of Document visibility changes.
2204         On iOS, muting/unmuting the current video source according Document visibility.
2205         Not using Document visibility change observer as factories are platform and cannot implement
2206         the visibility observer interface without moving the visibility observer interface.
2207
2208         Introducing internals API to switch on/off the page visibility.
2209
2210         * dom/Document.cpp:
2211         (WebCore::Document::visibilityStateChanged):
2212         (WebCore::Document::notifyVisibilityChangedToMediaCapture):
2213         * dom/Document.h:
2214         * platform/mediastream/RealtimeMediaSource.h:
2215         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
2216         (WebCore::RealtimeMediaSourceCenter::setVisibility):
2217         * platform/mediastream/RealtimeMediaSourceCenter.h:
2218         * platform/mediastream/mac/AVVideoCaptureSource.mm:
2219         (WebCore::AVVideoCaptureSourceFactory::setVisibility):
2220         * testing/Internals.cpp:
2221         (WebCore::Internals::setPageVisibility):
2222         * testing/Internals.h:
2223         * testing/Internals.idl:
2224
2225 2017-05-17  Said Abou-Hallawa  <sabouhallawa@apple.com>
2226
2227         When the image decoding thread makes a callOnMainThread(), ensure all the objects it needs are protected
2228         https://bugs.webkit.org/show_bug.cgi?id=171614
2229
2230         Reviewed by David Kilzer.
2231
2232         The asynchronous image decoding was designed to not block the main thread if
2233         the image is deleted. To achieve that we allow decoding the current frame
2234         even if it is not going to be used after closing the decoding queue. We 
2235         protect all the objects which the decoding thread uses. But when a frame
2236         finishes decoding the native image frame is cached on the main thread. Not
2237         all of the objects are protected when the callOnMainThread() is dispatched.
2238         The ImageFrameCache and the ImageDecoder objects are not protected.
2239
2240         This might lead to two kinds of crashes:
2241         1. A segfault inside the ImageDecoder trying to access one of its member
2242         2. A segfault inside the ImageFrameCache trying to access one of its frames
2243
2244         The fix is to protect the ImageFrameCache and the ImageDecoder when the
2245         decoding thread makes a callOnMainThread(). Also switch all the pointers
2246         the decoding threads protect to be ThreadSafeRefCounted.
2247
2248         * platform/graphics/ImageFrameCache.cpp:
2249         (WebCore::ImageFrameCache::startAsyncDecodingQueue):
2250         * platform/graphics/ImageFrameCache.h:
2251         * platform/graphics/cg/ImageDecoderCG.h:
2252         * platform/graphics/win/ImageDecoderDirect2D.h:
2253         * platform/image-decoders/ImageDecoder.h:
2254
2255 2017-05-17  Wenson Hsieh  <wenson_hsieh@apple.com>
2256
2257         A URL type is vended for a non-URL plain text string when starting data interaction
2258         https://bugs.webkit.org/show_bug.cgi?id=172228
2259         <rdar://problem/32166729>
2260
2261         Reviewed by Andy Estes.
2262
2263         Previously, when writing a plain text string to WebItemProviderPasteboard, we would write an NSString directly
2264         to the item provider by using built-in functionality in NSString+UIItemProvider. However, this causes plain
2265         strings such as "apple" to be considered URLs, since -[NSURL URLWithString:] creates a non-null NSURL. To fix
2266         this, we instead write the string as UTF8 data, for the UTI kUTTypeUTF8PlainText, if the plain text is not a
2267         URL. If the plain text is clearly a URL (determined by constructing a new WebCore URL with no base URL and the
2268         plaintext string as the absolute URL) then we additionally write an NSURL to the pasteboard.
2269
2270         2 new API tests:
2271         DataInteractionTests.SinglePlainTextWordTypeIdentifiers
2272         DataInteractionTests.SinglePlainTextURLTypeIdentifiers
2273
2274         * platform/ios/PlatformPasteboardIOS.mm:
2275         (WebCore::addRepresentationsForPlainText):
2276         (WebCore::PlatformPasteboard::writeObjectRepresentations):
2277
2278 2017-05-15  Jiewen Tan  <jiewen_tan@apple.com>
2279
2280         Replace CryptoOperationData with BufferSource for WebKitSubtleCrypto
2281         https://bugs.webkit.org/show_bug.cgi?id=172146
2282         <rdar://problem/32122256>
2283
2284         Reviewed by Brent Fulgham.
2285
2286         In this patch, we replaces CryptoOperationData with BufferSource for WebKitSubtleCrypto in
2287         the custom binding codes.
2288
2289         Test: crypto/webkitSubtle/import-export-raw-key-leak.html
2290
2291         * bindings/js/JSWebKitSubtleCryptoCustom.cpp:
2292         (WebCore::JSWebKitSubtleCrypto::encrypt):
2293         (WebCore::JSWebKitSubtleCrypto::decrypt):
2294         (WebCore::JSWebKitSubtleCrypto::sign):
2295         (WebCore::JSWebKitSubtleCrypto::verify):
2296         (WebCore::JSWebKitSubtleCrypto::digest):
2297         (WebCore::JSWebKitSubtleCrypto::importKey):
2298         (WebCore::JSWebKitSubtleCrypto::unwrapKey):
2299         * crypto/WebKitSubtleCrypto.idl:
2300
2301 2017-05-17  Youenn Fablet  <youenn@apple.com>
2302
2303         Move-related refactoring on UserMediaPermissionRequestProxy
2304         https://bugs.webkit.org/show_bug.cgi?id=172195
2305
2306         Reviewed by Alex Christensen.
2307
2308         No behavioral change.
2309
2310         * platform/mediastream/RealtimeMediaSourceCenter.h: Cleaning the function definition.
2311
2312 2017-05-17  David Kilzer  <ddkilzer@apple.com>
2313
2314         BlobDataFileReference::generateReplacementFile() should use mkstemp()
2315         <https://webkit.org/b/172192>
2316
2317         Reviewed by Brent Fulgham.
2318
2319         * platform/network/mac/BlobDataFileReferenceMac.mm:
2320         (WebCore::BlobDataFileReference::generateReplacementFile): Use
2321         mkstemp().
2322
2323 2017-05-17  Matt Lewis  <jlewis3@apple.com>
2324
2325         Unreviewed, rolling out r216974.
2326
2327         Revision caused consistent timeouts on all platforms.
2328
2329         Reverted changeset:
2330
2331         "Add a RuntimeEnabledFeature for display: contents, defaulted
2332         to false."
2333         https://bugs.webkit.org/show_bug.cgi?id=171984
2334         http://trac.webkit.org/changeset/216974
2335
2336 2017-05-17  Nan Wang  <n_wang@apple.com>
2337
2338         ASSERTION FAILED in WebCore::AccessibilityNodeObject::insertChild()
2339         https://bugs.webkit.org/show_bug.cgi?id=171927
2340         <rdar://problem/32109781>
2341
2342         Reviewed by Chris Fleizach.
2343
2344         The nextSibling() logic might include the continuation sibling that's not
2345         the child of the current renderer. Make sure we only insert the valid child.
2346
2347         Test: accessibility/insert-children-assert.html
2348
2349         * accessibility/AccessibilityObject.cpp:
2350         (WebCore::AccessibilityObject::setIsIgnoredFromParentDataForChild):
2351         * accessibility/AccessibilityRenderObject.cpp:
2352         (WebCore::AccessibilityRenderObject::nextSibling):
2353
2354 2017-05-17  Ryosuke Niwa  <rniwa@webkit.org>
2355
2356         getElementById can return a wrong elemnt when a matching element is removed during beforeload event
2357         https://bugs.webkit.org/show_bug.cgi?id=171374
2358
2359         Reviewed by Brent Fulgham.
2360
2361         The bug was caused by HTMLLinkElement firing beforeload event inside insertedInto before the tree state is updated.
2362         Delay the event dispatch to the post insertion callback.
2363
2364         Test: fast/html/link-element-removal-during-beforeload.html
2365
2366         * html/HTMLLinkElement.cpp:
2367         (WebCore::HTMLLinkElement::insertedInto):
2368         (WebCore::HTMLLinkElement::finishedInsertingSubtree):
2369         * html/HTMLLinkElement.h:
2370
2371 2017-05-17  Alex Christensen  <achristensen@webkit.org>
2372
2373         Interacting with WKHTTPCookieStores before creating WKWebViews and WKProcessPools should affect cookies used
2374         https://bugs.webkit.org/show_bug.cgi?id=171987
2375
2376         Reviewed by Brady Eidson.
2377
2378         Covered by new API tests.
2379
2380         * CMakeLists.txt:
2381         * platform/Cookie.h:
2382         (WebCore::Cookie::Cookie):
2383         (WebCore::Cookie::isNull):
2384         (WebCore::CookieHash::hash):
2385         (WebCore::CookieHash::equal):
2386         (WTF::HashTraits<WebCore::Cookie>::emptyValue):
2387         (WTF::HashTraits<WebCore::Cookie>::constructDeletedValue):
2388         (WTF::HashTraits<WebCore::Cookie>::isDeletedValue):
2389         * platform/network/Cookie.cpp: Added.
2390         (WebCore::Cookie::operator==):
2391         (WebCore::Cookie::hash):
2392         * platform/network/cocoa/CookieCocoa.mm:
2393         (WebCore::Cookie::operator NSHTTPCookie *):
2394         (WebCore::Cookie::operator==):
2395         (WebCore::Cookie::hash):
2396         * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
2397         (WebCore::NetworkStorageSession::setCookies):
2398         Use NSHTTPCookie's hash and equality comparison to more closely match the NSHTTPCookie behavior.
2399
2400 2017-05-17  Emilio Cobos Álvarez  <ecobos@igalia.com>
2401
2402         Add a RuntimeEnabledFeature for display: contents, defaulted to false.
2403         https://bugs.webkit.org/show_bug.cgi?id=171984
2404
2405         Reviewed by Antti Koivisto.
2406
2407         The "defaulted to false" is not only because there are spec issues,
2408         but because I ran the WPT suite, and there was a fair amount of
2409         crashes and messed render trees.
2410
2411         * css/StyleResolver.cpp:
2412         (WebCore::StyleResolver::adjustRenderStyle):
2413         * page/RuntimeEnabledFeatures.h:
2414         (WebCore::RuntimeEnabledFeatures::setDisplayContentsEnabled):
2415         (WebCore::RuntimeEnabledFeatures::displayContentsEnabled):
2416
2417 2017-05-17  Antti Koivisto  <antti@apple.com>
2418
2419         Regression (198943): <marquee> shouldn't wrap text
2420         https://bugs.webkit.org/show_bug.cgi?id=172217
2421
2422         Reviewed by Andreas Kling.
2423
2424         RenderMarquee::updateMarqueeStyle mutated the style and then expected it to inherit to children.
2425         This doesn't work anymore because render tree construction is now separated from style resolution
2426         where inheritance happens.
2427
2428         Test: fast/html/marquee-child-wrap.html
2429
2430         * css/StyleResolver.cpp:
2431         (WebCore::StyleResolver::adjustRenderStyle):
2432
2433             Implement marquee hacks in adjustRenderStyle instead. This can't do the childrenInline check
2434             the previous code had but it wasn't working anyway (there are no children when updateMarqueeStyle
2435             gets called).
2436
2437         * rendering/RenderMarquee.cpp:
2438         (WebCore::RenderMarquee::updateMarqueeStyle):
2439
2440             This no longer needs mutable style.
2441
2442 2017-05-16  David Kilzer  <ddkilzer@apple.com>
2443
2444         Remove C-style casts by using xmlDocPtr instead of void*
2445         <https://webkit.org/b/172189>
2446
2447         Reviewed by Alex Christensen.
2448
2449         * dom/TransformSource.h: Fix whitespace indentation.
2450         (typedef PlatformTransformSource): Use xmlDocPtr not void*.
2451         * dom/TransformSourceLibxslt.cpp:
2452         (WebCore::TransformSource::~TransformSource): Remove cast.
2453         * xml/XSLStyleSheetLibxslt.cpp:
2454         (WebCore::XSLStyleSheet::document): Remove cast.
2455         * xml/XSLTProcessorLibxslt.cpp:
2456         (WebCore::xmlDocPtrFromNode): Remove casts.
2457         * xml/parser/XMLDocumentParser.h:
2458         (WebCore::xmlDocPtrForString): Update declaration to return
2459         xmlDocPtr not void*.
2460         * xml/parser/XMLDocumentParserLibxml2.cpp:
2461         (WebCore::XMLDocumentParser::doEnd): Change type of local
2462         variable from void* to xmlDocPtr.
2463         (WebCore::xmlDocPtrForString): Update to return xmlDocPtr
2464         not void*.
2465
2466 2017-05-16  Sam Weinig  <sam@webkit.org>
2467
2468         Bring Notification.idl up to spec
2469         https://bugs.webkit.org/show_bug.cgi?id=172156
2470
2471         Reviewed by Chris Dumez.
2472
2473         Test: http/tests/notifications/notification.html
2474
2475         * CMakeLists.txt:
2476         * DerivedSources.make:
2477         * WebCore.xcodeproj/project.pbxproj:
2478         Add new files.
2479
2480         * Modules/notifications/Notification.cpp:
2481         (WebCore::Notification::create):
2482         (WebCore::Notification::Notification):
2483         (WebCore::Notification::show):
2484         (WebCore::directionString): Deleted.
2485         (WebCore::Notification::permission): Deleted.
2486         (WebCore::Notification::permissionString): Deleted.
2487         * Modules/notifications/Notification.h:
2488         * Modules/notifications/Notification.idl:
2489         * Modules/notifications/NotificationClient.h:
2490         * Modules/notifications/NotificationDirection.h: Added.
2491         * Modules/notifications/NotificationPermission.h: Added.
2492         * Modules/notifications/NotificationPermission.idl: Added.
2493         * Modules/notifications/NotificationPermissionCallback.h:
2494         * Modules/notifications/NotificationPermissionCallback.idl:
2495         Bring up to spec, replacing DOMStrings with enums where appropriate and adding
2496         additional readonly properties to Notification to mirror options provided
2497         in construction.
2498
2499 2017-05-16  Zalan Bujtas  <zalan@apple.com>
2500
2501         Do not skip <slot> children when collecting content for innerText.
2502         https://bugs.webkit.org/show_bug.cgi?id=172113
2503         <rdar://problem/30362324>
2504
2505         Reviewed by Ryosuke Niwa and Brent Fulgham.
2506
2507         "display: contents" elements do not generate renderers but their children might.
2508         This patch ensure that we don't skip them while collecting text content.  
2509
2510         Test: fast/text/inner-text-should-include-slot-subtree.html
2511
2512         * editing/TextIterator.cpp:
2513         (WebCore::TextIterator::advance):
2514
2515 2017-05-16  Filip Pizlo  <fpizlo@apple.com>
2516
2517         GCController::garbageCollectNowIfNotDoneRecently should request Async Full GCs
2518         https://bugs.webkit.org/show_bug.cgi?id=172204
2519
2520         Reviewed by Saam Barati.
2521
2522         No new tests because existing tests will tell us if there is a problem.
2523         
2524         The goal of this change is to reduce the likelihood that we block for a GC. We want it to be
2525         benchmark-neutral.
2526         
2527         It's a 0.14% speed-up on JetStream with 24% probability.
2528         
2529         It's a 0.12% slow-down on PLT3 with 43% probability.
2530         
2531         So it's neutral on my machine.
2532
2533         * bindings/js/GCController.cpp:
2534         (WebCore::GCController::garbageCollectNowIfNotDoneRecently):
2535
2536 2017-05-16  Tim Horton  <timothy_horton@apple.com>
2537
2538         [macOS] REGRESSION: Drag images for links with right-to-left titles are incorrect (172006)
2539         https://bugs.webkit.org/show_bug.cgi?id=172006
2540         <rdar://problem/32165137>
2541
2542         Reviewed by Dean Jackson.
2543
2544         * platform/mac/DragImageMac.mm:
2545         (WebCore::LinkImageLayout::LinkImageLayout):
2546         (WebCore::createDragImageForLink):
2547         (WebCore::LinkImageLayout::addLine): Deleted.
2548         * platform/spi/cocoa/CoreTextSPI.h:
2549         Set and paint the entire frame as a single unit, making use of the
2550         CTFrameMaximumNumberOfLines attribute to limit the number of lines.
2551         This gives CoreText power over text alignment and makes RTL text lay
2552         out correctly.
2553
2554 2017-05-16  Chris Dumez  <cdumez@apple.com>
2555
2556         Implement DOMMatrix / DOMMatrixReadOnly
2557         https://bugs.webkit.org/show_bug.cgi?id=110001
2558
2559         Reviewed by Sam Weinig and Simon Fraser.
2560
2561         Implement DOMMatrix / DOMMatrixReadOnly as per:
2562         - https://drafts.fxtf.org/geometry/#DOMMatrix
2563
2564         For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future,
2565         WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix.
2566
2567         Most of it has been implemented. What remaining to be implemented is:
2568         - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix
2569         - DOMMatrix.fromFloat32Array() / fromFloat64Array()
2570         - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array()
2571         - DOMMatrixReadOnly.transformPoint().
2572
2573         Tests: imported/w3c/web-platform-tests/css/geometry-1/*
2574
2575         * CMakeLists.txt:
2576         * DerivedSources.make:
2577         * WebCore.xcodeproj/project.pbxproj:
2578
2579         * bindings/scripts/CodeGeneratorJS.pm:
2580         * bindings/scripts/test/JS/JSTestObj.cpp:
2581         Fix a bug in the bindings generator causing the generator code for
2582         "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong
2583         and not build.
2584
2585         * css/DOMMatrix.cpp: Added.
2586         (WebCore::DOMMatrix::DOMMatrix):
2587         (WebCore::DOMMatrix::fromMatrix):
2588         (WebCore::DOMMatrix::multiplySelf):
2589         (WebCore::DOMMatrix::preMultiplySelf):
2590         (WebCore::DOMMatrix::translateSelf):
2591         (WebCore::DOMMatrix::scaleSelf):
2592         (WebCore::DOMMatrix::scale3dSelf):
2593         (WebCore::DOMMatrix::rotateSelf):
2594         (WebCore::DOMMatrix::rotateFromVectorSelf):
2595         (WebCore::DOMMatrix::rotateAxisAngleSelf):
2596         (WebCore::DOMMatrix::skewXSelf):
2597         (WebCore::DOMMatrix::skewYSelf):
2598         (WebCore::DOMMatrix::invertSelf):
2599         (WebCore::DOMMatrix::setMatrixValueForBindings):
2600         * css/DOMMatrix.h: Added.
2601         (WebCore::DOMMatrix::create):
2602         (WebCore::DOMMatrix::setA):
2603         (WebCore::DOMMatrix::setB):
2604         (WebCore::DOMMatrix::setC):
2605         (WebCore::DOMMatrix::setD):
2606         (WebCore::DOMMatrix::setE):
2607         (WebCore::DOMMatrix::setF):
2608         (WebCore::DOMMatrix::setM11):
2609         (WebCore::DOMMatrix::setM12):
2610         (WebCore::DOMMatrix::setM13):
2611         (WebCore::DOMMatrix::setM14):
2612         (WebCore::DOMMatrix::setM21):
2613         (WebCore::DOMMatrix::setM22):
2614         (WebCore::DOMMatrix::setM23):
2615         (WebCore::DOMMatrix::setM24):
2616         (WebCore::DOMMatrix::setM31):
2617         (WebCore::DOMMatrix::setM32):
2618         (WebCore::DOMMatrix::setM33):
2619         (WebCore::DOMMatrix::setM34):
2620         (WebCore::DOMMatrix::setM41):
2621         (WebCore::DOMMatrix::setM42):
2622         (WebCore::DOMMatrix::setM43):
2623         (WebCore::DOMMatrix::setM44):
2624         * css/DOMMatrix.idl: Added.
2625         * css/DOMMatrixInit.h: Added.
2626         * css/DOMMatrixInit.idl: Added.
2627         * css/DOMMatrixReadOnly.cpp: Added.
2628         (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly):
2629         (WebCore::DOMMatrixReadOnly::validateAndFixup):
2630         (WebCore::DOMMatrixReadOnly::fromMatrix):
2631         (WebCore::DOMMatrixReadOnly::isIdentity):
2632         (WebCore::DOMMatrixReadOnly::setMatrixValue):
2633         (WebCore::DOMMatrixReadOnly::translate):
2634         (WebCore::DOMMatrixReadOnly::flipX):
2635         (WebCore::DOMMatrixReadOnly::flipY):
2636         (WebCore::DOMMatrixReadOnly::multiply):
2637         (WebCore::DOMMatrixReadOnly::scale):
2638         (WebCore::DOMMatrixReadOnly::scale3d):
2639         (WebCore::DOMMatrixReadOnly::rotate):
2640         (WebCore::DOMMatrixReadOnly::rotateFromVector):
2641         (WebCore::DOMMatrixReadOnly::rotateAxisAngle):
2642         (WebCore::DOMMatrixReadOnly::skewX):
2643         (WebCore::DOMMatrixReadOnly::skewY):
2644         (WebCore::DOMMatrixReadOnly::inverse):
2645         (WebCore::DOMMatrixReadOnly::toString):
2646         * css/DOMMatrixReadOnly.h: Added.
2647         (WebCore::DOMMatrixReadOnly::create):
2648         (WebCore::DOMMatrixReadOnly::a):
2649         (WebCore::DOMMatrixReadOnly::b):
2650         (WebCore::DOMMatrixReadOnly::c):
2651         (WebCore::DOMMatrixReadOnly::d):
2652         (WebCore::DOMMatrixReadOnly::e):
2653         (WebCore::DOMMatrixReadOnly::f):
2654         (WebCore::DOMMatrixReadOnly::m11):
2655         (WebCore::DOMMatrixReadOnly::m12):
2656         (WebCore::DOMMatrixReadOnly::m13):
2657         (WebCore::DOMMatrixReadOnly::m14):
2658         (WebCore::DOMMatrixReadOnly::m21):
2659         (WebCore::DOMMatrixReadOnly::m22):
2660         (WebCore::DOMMatrixReadOnly::m23):
2661         (WebCore::DOMMatrixReadOnly::m24):
2662         (WebCore::DOMMatrixReadOnly::m31):
2663         (WebCore::DOMMatrixReadOnly::m32):
2664         (WebCore::DOMMatrixReadOnly::m33):
2665         (WebCore::DOMMatrixReadOnly::m34):
2666         (WebCore::DOMMatrixReadOnly::m41):
2667         (WebCore::DOMMatrixReadOnly::m42):
2668         (WebCore::DOMMatrixReadOnly::m43):
2669         (WebCore::DOMMatrixReadOnly::m44):
2670         (WebCore::DOMMatrixReadOnly::is2D):
2671         (WebCore::DOMMatrixReadOnly::fromMatrixHelper):
2672         * css/DOMMatrixReadOnly.idl: Added.
2673         * css/WebKitCSSMatrix.h:
2674         * css/WebKitCSSMatrix.idl:
2675         * svg/SVGMatrix.h:
2676         * svg/SVGMatrix.idl:
2677
2678 2017-05-16  Eric Carlson  <eric.carlson@apple.com>
2679
2680         [MediaStream] AudioSampleBufferList::zeroABL takes byte count, not sample count
2681         https://bugs.webkit.org/show_bug.cgi?id=172194
2682         <rdar://problem/32233799>
2683
2684         Reviewed by Jer Noble.
2685
2686         * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp:
2687         (WebCore::AudioTrackPrivateMediaStreamCocoa::render): Pass number of bytes to zero,
2688         not number of samples.
2689
2690 2017-05-16  Mark Lam  <mark.lam@apple.com>
2691
2692         WorkerRunLoop::Task::performTask() needs to null check context->script() before use.
2693         https://bugs.webkit.org/show_bug.cgi?id=172193
2694         <rdar://problem/32225346>
2695
2696         Reviewed by Filip Pizlo.
2697
2698         According to https://build-safari.apple.com/results/Trunk%20Fuji%20GuardMalloc%20Production%20WK2%20Tests/r216929_459760e0918316187c8e52c6585a3a9ba9181204%20(12066)/results.html,
2699         we see a crash with this crash trace:
2700
2701         Thread 13 Crashed:: WebCore: Worker
2702         0 com.apple.WebCore        0x00000001099607b2 WebCore::WorkerScriptController::isTerminatingExecution() const + 18
2703         1 com.apple.WebCore        0x000000010995ebbf WebCore::WorkerRunLoop::runCleanupTasks(WebCore::WorkerGlobalScope*) + 143
2704         2 com.apple.WebCore        0x000000010995e80f WebCore::WorkerRunLoop::run(WebCore::WorkerGlobalScope*) + 111
2705         3 com.apple.WebCore        0x00000001099621b6 WebCore::WorkerThread::workerThread() + 742
2706         4 com.apple.JavaScriptCore 0x000000010a964b92 WTF::threadEntryPoint(void*) + 178
2707         5 com.apple.JavaScriptCore 0x000000010a964a69 WTF::wtfThreadEntryPoint(void*) + 121
2708         6 libsystem_pthread.dylib  0x00007fffbdb5caab _pthread_body + 180
2709         7 libsystem_pthread.dylib  0x00007fffbdb5c9f7 _pthread_start + 286
2710         8 libsystem_pthread.dylib  0x00007fffbdb5c1fd thread_start + 13
2711
2712         ... and the crashing address is:
2713
2714         Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000022
2715
2716         0x0000000000000022 is the offset of m_scheduledTerminationMutex in the
2717         WorkerScriptController.  This means that WorkerScriptController::isTerminatingExecution()
2718         is passed a NULL this pointer.  This means that it's possible to have a race
2719         where a WorkerRunLoop::Task gets enqueued beyond the Cleanup task that deletes the
2720         context->script().  As a result, WorkerRunLoop::Task::performTask() (called by
2721         runCleanupTasks()) may see a null context->script().
2722
2723         Hence, WorkerRunLoop::Task::performTask() should null check context->script()
2724         before invoking the isTerminatingExecution() query on it.
2725
2726         No new tests because this is already covered by existing tests.
2727
2728         * workers/WorkerRunLoop.cpp:
2729         (WebCore::WorkerRunLoop::Task::performTask):
2730
2731 2017-05-16  Youenn Fablet  <youenn@apple.com>
2732
2733         Modernize WebKit2 getUserMedia passing of parameters
2734         https://bugs.webkit.org/show_bug.cgi?id=172161
2735
2736         Reviewed by Eric Carlson.
2737
2738         No change of behavior.
2739
2740         * platform/mediastream/RealtimeMediaSourceCenter.h: Using WTF::Function to enable capture Ref<>.
2741
2742 2017-05-16  Jeremy Jones  <jeremyj@apple.com>
2743
2744         Captions and subtitles not showing up in picture-in-picture for MSE content.
2745         https://bugs.webkit.org/show_bug.cgi?id=172145
2746
2747         Reviewed by Eric Carlson.
2748
2749         No new tests as this has no affect on the DOM.
2750
2751         Add TextTrackRepresentation code from MediaPlayerPrivateAVFoundationObj to MediaPlayerPrivateMediaSourceAVFObjc.
2752         This moves the TextTrackRepresentation platfrom layer into the fullscreen container layer when going into
2753         pip for fullscreen, allowing the captions to be visible.
2754
2755         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
2756         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
2757         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
2758         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer):
2759         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenFrame):
2760         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::requiresTextTrackRepresentation):
2761         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::syncTextTrackBounds):
2762         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setTextTrackRepresentation):
2763
2764 2017-05-16  David Kilzer  <ddkilzer@apple.com>
2765
2766         WebCore::leakCGColor() needs CF_RETURNS_RETAINED annotation
2767         <https://webkit.org/b/172190>
2768
2769         Reviewed by Simon Fraser.
2770
2771         * platform/graphics/cg/ColorCG.cpp:
2772         (WebCore::leakCGColor): Annotate with CF_RETURNS_RETAINED since
2773         it does not follow the CF naming convention, which means the
2774         expected behavior can't be inferred by the clang static
2775         analyzer.
2776
2777 2017-05-16  Youenn Fablet  <youenn@apple.com>
2778
2779         RealtimeOutgoingVideoSource should support sinkWants for rotation
2780         https://bugs.webkit.org/show_bug.cgi?id=172123
2781         <rdar://problem/32200017>
2782
2783         Reviewed by Eric Carlson.
2784
2785         Covered by manual testing.
2786
2787         * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
2788         (WebCore::RealtimeOutgoingVideoSource::AddOrUpdateSink): Triggering pixel rotation based on sink.
2789         (WebCore::RealtimeOutgoingVideoSource::sendFrame): Doing the rotation using libwebrtc API.
2790         * platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
2791
2792 2017-05-16  Myles C. Maxfield  <mmaxfield@apple.com>
2793
2794         REGRESSION(r212513): LastResort is platform-dependent, so its semantics should not be required to perform font loading correctly.
2795         https://bugs.webkit.org/show_bug.cgi?id=168487
2796
2797         Reviewed by Antti Koivisto.
2798
2799         There are three ways a Web author can chain multiple font files together:
2800         1. Multiple entries in the "src" descriptor in an @font-face rule
2801         2. Multiple @font-face rules with the same "font-family" descriptor
2802         3. Multiple entries in the "font-family" property on an element
2803
2804         Before r212513, the code which iterated across #2 and #3 above could have
2805         triggered each item in the chain to download. r212513 tried to solve this
2806         by using LastResort as the interstitial font used during downloads, because
2807         LastResort supports every character and therefore solves #3 above. However,
2808         this change had a few problems:
2809
2810         1. Previously, our code would try to avoid using the interstitial font for
2811         layout or rendering whenever possible (because one of the chains above may
2812         have named a local font which would be better to use). In order to use the
2813         benefits of LastResort, I had to remove this avoidance logic and make
2814         WebKit try to use the interstitial font as often as possible. However, due
2815         to the large metrics of LastResort, this means that offsetWidth queries
2816         during font loading would be wildly inaccurate, causing Google Docs to break.
2817         2. It also means that canvas drawing during font loading would actually draw
2818         LastResort, causing Bing maps to break.
2819         3. LastResort is platform-specific, so only platforms which have it would
2820         actually be able to load fonts correctly.
2821
2822         Instead, we should keep the older logic about avoiding using the
2823         interstitial font so that loading has a better experience for the user.
2824         We solve the unnecessary download problem by giving our loading code a
2825         downloading policy enum, which has two values: allow downloads or forbid
2826         downloads. Whenever our loading code returns the interstitial font, we
2827         continue our search, but we change the policy to forbid downloads.
2828
2829         There is one piece of subtlety, though: It is more common for web authors
2830         to put good fallbacks in the "font-family" property than in the "src"
2831         descriptor inside @font-face. This means that we shouldn't exhaustively
2832         search through the @font-face src list first. Instead, we should look
2833         through the src list until we hit a non-local font, and then immediately
2834         start looking through the other other chains.
2835
2836         Tests: fast/text/font-download-font-face-src-list.html
2837                fast/text/font-download-font-family-property.html
2838                fast/text/font-download-remote-fallback-all.html
2839                fast/text/font-interstitial-invisible-width-while-loading.html
2840                fast/text/font-weight-download-3.html
2841                fast/text/web-font-load-fallback-during-loading-2.html
2842                fast/text/web-font-load-invisible-during-loading.html
2843
2844         * css/CSSFontFace.cpp:
2845         (WebCore::CSSFontFace::fontLoadEventOccurred): Implement support for
2846         the font download policy.
2847         (WebCore::CSSFontFace::setStatus): After 3 seconds of loading, we
2848         will start drawing the fallback font. However, for testing, we have an
2849         internal setting to make this switch happen immediately. This patch now
2850         requires that this internal switch happen synchronously.
2851         (WebCore::CSSFontFace::pump): Implement support for the font download
2852         policy.
2853         (WebCore::CSSFontFace::load): Ditto.
2854         (WebCore::CSSFontFace::font): Ditto.
2855         * css/CSSFontFace.h: Ditto.
2856         * css/CSSFontSelector.cpp:
2857         (WebCore::CSSFontSelector::beginLoadingFontSoon): Implement support for
2858         synchronous font download timeouts.
2859         * css/CSSSegmentedFontFace.cpp:
2860         (WebCore::CSSSegmentedFontFace::fontRanges): Implement support for the
2861         font download policy.
2862         * platform/graphics/Font.cpp: Add new flag which represents if the
2863         interstitial font was created after the 3 second timeout or before.
2864         Previously, we would distinguish between these two cases by knowing
2865         that one font was LastResort and the other font was a fallback. Now that
2866         we're using fallback fonts on both sides of the 3 second timeout, we
2867         now no longer know which one should be invisible. This new enum solves
2868         this problem.
2869         (WebCore::Font::Font):
2870         (WebCore::Font::verticalRightOrientationFont):
2871         (WebCore::Font::uprightOrientationFont):
2872         * platform/graphics/Font.h: Ditto.
2873         (WebCore::Font::create):
2874         (WebCore::Font::origin):
2875         (WebCore::Font::visibility):
2876         * platform/graphics/FontCache.h:
2877         * platform/graphics/FontCascade.cpp: We try to fall back to a local() font
2878         during downloads, but there might not be one that we can use. Therefore, we
2879         can't use the presence of the interstitial font to detect if we should paint
2880         invisibly. Instead, we can move this logic into the font-specific part of
2881         painting, and consult with the specific font to know if it was created from
2882         a timed-out @font-face rule or not.
2883         (WebCore::FontCascade::drawText):
2884         (WebCore::shouldDrawIfLoading):
2885         (WebCore::FontCascade::drawGlyphBuffer):
2886         (WebCore::FontCascade::drawEmphasisMarks):
2887         * platform/graphics/FontCascade.h:
2888         * platform/graphics/FontCascadeFonts.cpp:
2889         (WebCore::FontCascadeFonts::glyphDataForVariant): Implement the logic
2890         described above where we switch the policy if we encounter the intestitial
2891         font.
2892         (WebCore::FontCascadeFonts::glyphDataForNormalVariant): Ditto.
2893         (WebCore::glyphPageFromFontRanges): Ditto.
2894         * platform/graphics/FontRanges.cpp: Implement support for the font download
2895         policy.
2896         (WebCore::FontRanges::Range::font):
2897         (WebCore::FontRanges::glyphDataForCharacter):
2898         (WebCore::FontRanges::fontForCharacter):
2899         (WebCore::FontRanges::fontForFirstRange):
2900         * platform/graphics/FontRanges.h:
2901         * platform/graphics/FontSelector.h:
2902         * platform/graphics/freetype/FontCacheFreeType.cpp:
2903         (WebCore::FontCache::lastResortFallbackFontForEveryCharacter): Deleted.
2904         * platform/graphics/mac/FontCacheMac.mm:
2905         (WebCore::FontCache::lastResortFallbackFontForEveryCharacter): Deleted.
2906         * platform/graphics/win/FontCacheWin.cpp:
2907         (WebCore::FontCache::lastResortFallbackFontForEveryCharacter): Deleted.
2908
2909 2017-05-16  Zalan Bujtas  <zalan@apple.com>
2910
2911         Simple line layout: Move setCollapedWhitespaceWidth call to updateLineConstrains.
2912         https://bugs.webkit.org/show_bug.cgi?id=172178
2913
2914         Reviewed by Antti Koivisto.
2915
2916         No change in functionality.
2917
2918         * rendering/SimpleLineLayout.cpp:
2919         (WebCore::SimpleLineLayout::updateLineConstrains):
2920         (WebCore::SimpleLineLayout::createLineRuns):
2921
2922 2017-05-16  Eric Carlson  <eric.carlson@apple.com>
2923
2924         [MediaStream] Return default device list until user gives permission to capture
2925         https://bugs.webkit.org/show_bug.cgi?id=172168
2926         <rdar://problem/31816884>
2927
2928         Reviewed by Youenn Fablet.
2929
2930         Test: fast/mediastream/media-devices-enumerate-devices.html
2931
2932         * Modules/mediastream/MediaDevicesRequest.cpp:
2933         (WebCore::MediaDevicesRequest::filterDeviceList): Remove all but the "default" number of
2934         devices of each type.
2935         (WebCore::MediaDevicesRequest::start): Call filterDeviceList.
2936         * Modules/mediastream/MediaDevicesRequest.h:
2937
2938 2017-05-16  Claudio Saavedra  <csaavedra@igalia.com>
2939
2940         Silent a few warnings about unused parameters
2941         https://bugs.webkit.org/show_bug.cgi?id=172169
2942
2943         Reviewed by Sam Weinig.
2944
2945         * page/Page.cpp:
2946         (WebCore::Page::mainFrameLoadStarted):
2947         * platform/graphics/cairo/ImageBufferCairo.cpp:
2948         (WebCore::ImageBuffer::toData):
2949         * platform/network/ResourceRequestBase.cpp:
2950         (WebCore::ResourceRequestBase::partitionName):
2951
2952 2017-05-16  Wenson Hsieh  <wenson_hsieh@apple.com>
2953
2954         WebItemProviderPasteboard should be robust when temporary files are missing path extensions
2955         https://bugs.webkit.org/show_bug.cgi?id=172170
2956
2957         Reviewed by Tim Horton.
2958
2959         Makes a slight adjustment to the temporary file URLs are handled when using WebItemProviderPasteboard to load
2960         data off of item providers. Previously, we would bail early and not load any data if the temporary URL is
2961         missing an extension. Since the switch to NSItemProviders from UIItemProviders, some types of temporary files
2962         generated by item providers are missing extensions, so this extra check is meaningless.
2963
2964         Covered by existing data interaction unit tests.
2965
2966         * platform/ios/WebItemProviderPasteboard.mm:
2967         (temporaryFileURLForDataInteractionContent):
2968         (-[WebItemProviderPasteboard doAfterLoadingProvidedContentIntoFileURLs:synchronousTimeout:]):
2969
2970 2017-05-16  Zan Dobersek  <zdobersek@igalia.com>
2971
2972         [WPE] GLContextEGL::createWPEContext() should fall back to pbuffer-based contexts when offscreen target provides no native window
2973         https://bugs.webkit.org/show_bug.cgi?id=172162
2974
2975         Reviewed by Carlos Garcia Campos.
2976
2977         When creating an offscreen GLContext, the underlying implementation might
2978         provide a mock native window that's to be used as the window target upon
2979         which a window-based GLContext should be created. But we should also support
2980         falling back to pbuffer-based GLContexts when the underlying implementation
2981         can't provide such mock targets.
2982
2983         * platform/graphics/egl/GLContextEGLWPE.cpp:
2984         (WebCore::GLContextEGL::createWPEContext):
2985
2986 2017-05-16  Zan Dobersek  <zdobersek@igalia.com>
2987
2988         [GLib] Name more GSource-based RunLoop::Timers
2989         https://bugs.webkit.org/show_bug.cgi?id=172158
2990
2991         Reviewed by Carlos Garcia Campos.
2992
2993         * platform/glib/MainThreadSharedTimerGLib.cpp:
2994         (WebCore::MainThreadSharedTimer::MainThreadSharedTimer):
2995         Specify 'MainThreadSharedTimer' as the name of this GSource-based RunLoop::Timer.
2996
2997 2017-05-16  Romain Bellessort  <romain.bellessort@crf.canon.fr>
2998
2999         [Readable Streams API] Implement ReadableStreamBYOBReader releaseLock()
3000         https://bugs.webkit.org/show_bug.cgi?id=172111
3001
3002         Reviewed by Chris Dumez.
3003
3004         Implemented ReadableStreamBYOBReader releaseLock():
3005         - https://streams.spec.whatwg.org/#byob-reader-release-lock;
3006         - https://streams.spec.whatwg.org/#readable-stream-reader-generic-release.
3007
3008         Added tests to check releaseLock behavior.
3009
3010         * Modules/streams/ReadableStreamBYOBReader.js:
3011         (releaseLock): Implemented.
3012         * Modules/streams/ReadableStreamInternals.js:
3013         (readableStreamReaderGenericRelease): Aligned with spec.
3014
3015 2017-05-16  Carlos Garcia Campos  <cgarcia@igalia.com>
3016
3017         Unreviewed. Try to fix GTK+ build with MEDIA_STREAM enabled after r216918.
3018
3019         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
3020         (WebCore::RealtimeMediaSourceCenterOwr::validateRequestConstraints):
3021
3022 2017-05-16  Youenn Fablet  <youenn@apple.com>
3023
3024         Remove MediaConstraintsData and MediaConstraintsImpl
3025         https://bugs.webkit.org/show_bug.cgi?id=172132
3026
3027         Reviewed by Eric Carlson.
3028
3029         No observable change of behavior.
3030
3031         Removing MediaConstraintsData and MediaConstraintsImpl allows simplifying the code.
3032         Further simplified the code by making MediaConstraints no longer ref counted and now a struct.
3033         Simplified some RealtimeMediaSource subclasses by removing unused MediaConstraints class members.
3034
3035         * CMakeLists.txt: Removing MediaConstraintsImpl.cpp.
3036         * Modules/mediastream/MediaConstraintsImpl.cpp: Removed.
3037         * Modules/mediastream/MediaConstraintsImpl.h: Removed.
3038         * Modules/mediastream/MediaDevices.cpp:
3039         (WebCore::createMediaConstraints):
3040         (WebCore::MediaDevices::getUserMedia):
3041         (WebCore::createMediaConstraintsImpl): Deleted.
3042         * Modules/mediastream/MediaStreamTrack.cpp:
3043         (WebCore::createMediaConstraints):
3044         (WebCore::MediaStreamTrack::applyConstraints):
3045         (WebCore::createMediaConstraintsImpl): Deleted.
3046         * Modules/mediastream/MediaTrackConstraints.cpp:
3047         (WebCore::createMediaConstraints):
3048         (WebCore::createMediaConstraintsImpl): Deleted.
3049         * Modules/mediastream/MediaTrackConstraints.h:
3050         * Modules/mediastream/UserMediaRequest.cpp:
3051         (WebCore::UserMediaRequest::start):
3052         (WebCore::UserMediaRequest::UserMediaRequest):
3053         (WebCore::UserMediaRequest::allow):
3054         * Modules/mediastream/UserMediaRequest.h:
3055         (WebCore::UserMediaRequest::audioConstraints):
3056         (WebCore::UserMediaRequest::videoConstraints):
3057         * WebCore.xcodeproj/project.pbxproj:
3058         * platform/mediastream/MediaConstraints.cpp:
3059         (WebCore::addDefaultVideoConstraints):
3060         (WebCore::MediaConstraints::isConstraintSet):
3061         (WebCore::MediaConstraints::setDefaultVideoConstraints):
3062         * platform/mediastream/MediaConstraints.h:
3063         (WebCore::MediaConstraints::~MediaConstraints): Deleted.
3064         (WebCore::MediaConstraints::MediaConstraints): Deleted.
3065         * platform/mediastream/MediaStreamConstraintsValidationClient.h:
3066         * platform/mediastream/RealtimeMediaSource.cpp:
3067         (WebCore::RealtimeMediaSource::selectSettings):
3068         (WebCore::RealtimeMediaSource::supportsConstraints):
3069         (WebCore::RealtimeMediaSource::applyConstraints):
3070         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
3071         (WebCore::RealtimeMediaSourceCenter::validateRequestConstraints):
3072         * platform/mediastream/RealtimeMediaSourceCenter.h:
3073         * platform/mediastream/mac/RealtimeIncomingAudioSource.cpp:
3074         (WebCore::RealtimeIncomingAudioSource::supportedConstraints): Deleted.
3075         * platform/mediastream/mac/RealtimeIncomingAudioSource.h:
3076         * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
3077         (WebCore::RealtimeIncomingVideoSource::supportedConstraints): Deleted.
3078         * platform/mediastream/mac/RealtimeIncomingVideoSource.h:
3079         * platform/mock/MockRealtimeMediaSource.h:
3080         (WebCore::MockRealtimeMediaSource::constraints): Deleted.
3081
3082 2017-05-16  Andy Estes  <aestes@apple.com>
3083
3084         [Cocoa] Tell NEFilterSource about the presenting app's PID
3085         https://bugs.webkit.org/show_bug.cgi?id=172152
3086         <rdar://problem/32197740>
3087
3088         Reviewed by Dan Bernstein.
3089
3090         * platform/cocoa/NetworkExtensionContentFilter.mm:
3091         (WebCore::NetworkExtensionContentFilter::initialize):
3092         * platform/spi/cocoa/NEFilterSourceSPI.h:
3093
3094 2017-05-16  Manuel Rego Casasnovas  <rego@igalia.com>
3095
3096         [css-grid] Fix static position of positioned grid items
3097         https://bugs.webkit.org/show_bug.cgi?id=172108
3098
3099         Reviewed by Sergio Villar Senin.
3100
3101         This patch makes us follow the text on the spec
3102         (https://drafts.csswg.org/css-grid/#static-position):
3103         "The static position of an absolutely-positioned child
3104          of a grid container is determined as if it were the sole grid item
3105          in a grid area whose edges coincide with the padding edges
3106          of the grid container."
3107
3108         Test: fast/css-grid-layout/absolute-positioning-grid-container-parent.html
3109
3110         * rendering/RenderGrid.cpp:
3111         (WebCore::RenderGrid::prepareChildForPositionedLayout): Modified to avoid
3112         including padding to match the spec behavior.
3113
3114 2017-05-16  Per Arne Vollan  <pvollan@apple.com>
3115
3116         Compile error, include file is not found.
3117         https://bugs.webkit.org/show_bug.cgi?id=172105
3118
3119         Reviewed by Brent Fulgham.
3120
3121         Use __has_include to detect if include file exists.
3122
3123         * platform/mediastream/libwebrtc/H264VideoToolBoxEncoder.mm:
3124
3125 2017-05-15  Andy Estes  <aestes@apple.com>
3126
3127         Make the application PID available to WebCore
3128         https://bugs.webkit.org/show_bug.cgi?id=172133
3129
3130         Reviewed by Andreas Kling.
3131
3132         * CMakeLists.txt:
3133         * PlatformMac.cmake:
3134         * WebCore.xcodeproj/project.pbxproj:
3135         * platform/RuntimeApplicationChecks.cpp: Added.
3136         (WebCore::presentingApplicationPIDOverride):
3137         (WebCore::presentingApplicationPID): Returns the override PID if set, or getCurrentProcessID()
3138         otherwise.
3139         (WebCore::setPresentingApplicationPID):
3140         * platform/RuntimeApplicationChecks.h:
3141         * platform/cocoa/RuntimeApplicationChecksCocoa.mm: Renamed from Source/WebCore/platform/RuntimeApplicationChecks.mm.
3142
3143 2017-05-15  Antti Koivisto  <antti@apple.com>
3144
3145         RenderTheme does not need to be per-page
3146         https://bugs.webkit.org/show_bug.cgi?id=172116
3147         <rdar://problem/30426457>
3148
3149         Reviewed by Zalan Bujtas.
3150
3151         There are no implementations of RenderTheme::themeForPage that actually care about the page.
3152         It can be replaced with a singleton, simplifying a bunch of code.
3153
3154         * Modules/mediacontrols/MediaControlsHost.cpp:
3155         (WebCore::MediaControlsHost::shadowRootCSSText):
3156         (WebCore::MediaControlsHost::base64StringForIconNameAndType):
3157         * css/CSSDefaultStyleSheets.cpp:
3158         (WebCore::CSSDefaultStyleSheets::loadFullDefaultStyle):
3159         (WebCore::CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement):
3160
3161             Fix a potential crash if we get here when page is null (though it doesn't appear to repro on trunk).
3162
3163         * css/StyleColor.cpp:
3164         (WebCore::StyleColor::colorFromKeyword):
3165         * css/StyleResolver.cpp:
3166         (WebCore::StyleResolver::adjustRenderStyle):
3167         * css/parser/CSSParser.cpp:
3168         (WebCore::CSSParser::parseSystemColor):
3169         * css/parser/CSSParser.h:
3170         * css/parser/CSSPropertyParser.cpp:
3171         (WebCore::CSSPropertyParser::consumeSystemFont):
3172         * editing/FrameSelection.cpp:
3173         (WebCore::FrameSelection::updateAppearance):
3174         * html/HTMLMediaElement.cpp:
3175         (WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript):
3176         * html/HTMLMeterElement.cpp:
3177         (WebCore::HTMLMeterElement::createElementRenderer):
3178         * html/HTMLSelectElement.cpp:
3179         (WebCore::HTMLSelectElement::usesMenuList):
3180         (WebCore::HTMLSelectElement::platformHandleKeydownEvent):
3181         (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
3182         * html/HTMLTextFormControlElement.cpp:
3183         (WebCore::HTMLTextFormControlElement::adjustInnerTextStyle):
3184         * html/InputType.cpp:
3185         (WebCore::InputType::themeSupportsDataListUI):
3186         * html/TextFieldInputType.cpp:
3187         (WebCore::TextFieldInputType::shouldHaveSpinButton):
3188         (WebCore::TextFieldInputType::shouldHaveCapsLockIndicator):
3189         * html/canvas/CanvasRenderingContext2D.cpp:
3190         (WebCore::CanvasRenderingContext2D::setStrokeColor):
3191         (WebCore::CanvasRenderingContext2D::setFillColor):
3192         * html/canvas/CanvasStyle.cpp:
3193         (WebCore::parseColor):
3194         (WebCore::parseColorOrCurrentColor):
3195         (WebCore::CanvasStyle::createFromString):
3196         * html/canvas/CanvasStyle.h:
3197         * html/shadow/MediaControlElements.cpp:
3198         (WebCore::MediaControlPanelElement::startTimer):
3199         (WebCore::MediaControlPanelElement::makeOpaque):
3200         (WebCore::MediaControlPanelElement::makeTransparent):
3201         * html/shadow/MediaControls.cpp:
3202         (WebCore::MediaControls::reset):
3203         (WebCore::MediaControls::reportedError):
3204         (WebCore::MediaControls::updateCurrentTimeDisplay):
3205         * html/shadow/mac/ImageControlsButtonElementMac.cpp:
3206         (WebCore::ImageControlsButtonElementMac::tryCreate):
3207         * page/MemoryRelease.cpp:
3208         (WebCore::releaseNoncriticalMemory):
3209         * page/Page.cpp:
3210         (WebCore::Page::Page):
3211         * page/Page.h:
3212         (WebCore::Page::theme): Deleted.
3213         * platform/wpe/RenderThemeWPE.cpp:
3214         (WebCore::RenderTheme::singleton):
3215         (WebCore::RenderTheme::themeForPage): Deleted.
3216         * rendering/RenderEmbeddedObject.cpp:
3217         (WebCore::RenderEmbeddedObject::getReplacementTextGeometry):
3218         * rendering/RenderObject.cpp:
3219         (WebCore::RenderObject::theme):
3220         * rendering/RenderTheme.cpp:
3221         (WebCore::RenderTheme::focusRingColor):
3222         * rendering/RenderTheme.h:
3223         (WebCore::RenderTheme::defaultTheme): Deleted.
3224         * rendering/RenderThemeGtk.cpp:
3225         (WebCore::RenderTheme::singleton):
3226         (WebCore::RenderTheme::themeForPage): Deleted.
3227         * rendering/RenderThemeIOS.mm:
3228         (WebCore::RenderTheme::singleton):
3229         (WebCore::RenderTheme::themeForPage): Deleted.
3230         * rendering/RenderThemeMac.mm:
3231         (WebCore::RenderTheme::singleton):
3232         (WebCore::RenderTheme::themeForPage): Deleted.
3233         * rendering/RenderThemeWin.cpp:
3234         (WebCore::RenderTheme::singleton):
3235         (WebCore::RenderTheme::themeForPage): Deleted.
3236         * rendering/TextPaintStyle.cpp:
3237         (WebCore::computeTextPaintStyle):
3238
3239 2017-05-15  Said Abou-Hallawa  <sabouhallawa@apple.com>
3240
3241         Do not delete asynchronously decoded frames for large images if their clients are in the viewport
3242         https://bugs.webkit.org/show_bug.cgi?id=170640
3243
3244         Reviewed by Simon Fraser.
3245
3246         The image flickering problem happens when a large image is visible in the
3247         view port and for some reason, the decoded frame gets destroyed. When this
3248         image is repainted, BitmapImage::draw() does not find a valid decoded frame
3249         for that image. It then requests an async decoding for the image and just
3250         draws nothing in the image rectangle. Drawing no content between two drawing
3251         phases in which the image is drawn causes the unwanted flickering.
3252
3253         To fix this issue we need to protect the decoded frames of all the images
3254         in the view port from being destroyed. When BitmapImage::destroyDecodedData()
3255         is called, it is going to check, through the ImageObserver, whether any
3256         of its clients is visible. And if so, the current decoded frame won't be
3257         destroyed.
3258
3259         Tests: Modifying existing tests.
3260
3261         * loader/cache/CachedImage.cpp:
3262         (WebCore::CachedImage::CachedImageObserver::decodedSizeChanged):
3263         (WebCore::CachedImage::CachedImageObserver::didDraw):
3264         (WebCore::CachedImage::CachedImageObserver::canDestroyDecodedData):
3265         (WebCore::CachedImage::CachedImageObserver::imageFrameAvailable):
3266         (WebCore::CachedImage::CachedImageObserver::changedInRect):
3267         (WebCore::CachedImage::decodedSizeChanged):
3268         (WebCore::CachedImage::didDraw):
3269         (WebCore::CachedImage::canDestroyDecodedData): Finds out whether it's okay
3270         to discard the image decoded data or not.
3271         (WebCore::CachedImage::imageFrameAvailable):
3272         (WebCore::CachedImage::changedInRect):
3273         * loader/cache/CachedImage.h:
3274         * loader/cache/CachedImageClient.h:
3275         (WebCore::CachedImageClient::canDestroyDecodedData):
3276         * loader/cache/MemoryCache.cpp:
3277         (WebCore::MemoryCache::destroyDecodedDataForAllImages): This function is
3278         currently not used. Use in the internal destroyDecodedDataForAllImages()
3279         but unlike what CachedImage::destroyDecodedData() does, make it destroy
3280         the decoded frames without deleting the image itself.
3281         * loader/cache/MemoryCache.h:
3282         * platform/graphics/BitmapImage.cpp:
3283         (WebCore::BitmapImage::destroyDecodedData):
3284         (WebCore::BitmapImage::draw):
3285         (WebCore::BitmapImage::canDestroyCurrentFrameDecodedData): 
3286         (WebCore::BitmapImage::advanceAnimation):
3287         (WebCore::BitmapImage::internalAdvanceAnimation):
3288         (WebCore::BitmapImage::imageFrameAvailableAtIndex):
3289         * platform/graphics/BitmapImage.h:
3290         * platform/graphics/GraphicsContext3D.cpp:
3291         (WebCore::GraphicsContext3D::packImageData):
3292         * platform/graphics/ImageFrameCache.cpp:
3293         (WebCore::ImageFrameCache::decodedSizeChanged):
3294         (ImageFrameCache::cacheAsyncFrameNativeImageAtIndex): The assertion in this
3295         function is wrong. frameIsCompleteAtIndex() can be false when the an image
3296         decoding is requested but can be true when the decoding finishes.
3297         * platform/graphics/ImageObserver.h:
3298         * platform/graphics/cairo/ImageCairo.cpp:
3299         (WebCore::Image::drawPattern):
3300         * platform/graphics/cg/ImageCG.cpp:
3301         (WebCore::Image::drawPattern):
3302         * platform/graphics/cg/ImageDecoderCG.cpp:
3303         (WebCore::ImageDecoder::frameIsCompleteAtIndex):
3304         * platform/graphics/cg/PDFDocumentImage.cpp:
3305         (WebCore::PDFDocumentImage::decodedSizeChanged):
3306         (WebCore::PDFDocumentImage::draw):
3307         * platform/graphics/texmap/TextureMapperTiledBackingStore.cpp:
3308         (WebCore::TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded):
3309         * platform/graphics/win/ImageDirect2D.cpp:
3310         (WebCore::Image::drawPattern):
3311         * rendering/RenderElement.cpp:
3312         (WebCore::RenderElement::isVisibleInDocumentRect):
3313         (WebCore::RenderElement::isVisibleInViewport):
3314         (WebCore::RenderElement::imageFrameAvailable):
3315         (WebCore::RenderElement::repaintForPausedImageAnimationsIfNeeded):
3316         (WebCore::RenderElement::shouldRepaintInVisibleRect): Deleted. Function
3317         is renamed to isVisibleInViewport() for better readability.
3318         * rendering/RenderElement.h:
3319         * svg/graphics/SVGImage.cpp:
3320         (WebCore::SVGImage::draw):
3321         * svg/graphics/SVGImageClients.h:
3322         * testing/Internals.cpp:
3323         (WebCore::Internals::destroyDecodedDataForAllImages):
3324         * testing/Internals.h:
3325         * testing/Internals.idl:
3326
3327 2017-05-15  Youenn Fablet  <youenn@apple.com>
3328
3329         Simplify RealtimeMediaSource data production and state
3330         https://bugs.webkit.org/show_bug.cgi?id=171999
3331
3332         Reviewed by Eric Carlson.
3333
3334         RealtimeMediaSource takes 3 booleans:
3335         - m_isProducingData tells whether data is produced or not. In the case of capturing, it tells whether capture
3336           happens.
3337         - m_muted/m_enabled allows JS or WebKit level to start/stop the source.
3338
3339         Changed MediaStream capture state computation so that capture is reported as follows:
3340         - m_isProducing is true, capture is happenning and is active
3341         - m_muted is true, capture is happening but is inactive.
3342
3343         Except in the case of WebRTC incoming sources, for which sources may be created as muted as per the spec,
3344         all sources are unmuted, enabled and not producing data when created.
3345
3346         RealtimeMediaSource is now activable either by calling start/stop or by calling setMuted/setEnabled.
3347         This in turns will set the boolean values accordingly and will call the underlying
3348         startProducingData/stopProducingData methods doing the actual stuff.
3349
3350         Removing from all RealtimeMediaSource subclasses the handling of producing data.
3351         Making more methods non-virtual/member fields private to simplify the model.
3352
3353         * Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
3354         (WebCore::CanvasCaptureMediaStreamTrack::Source::create):
3355         (WebCore::CanvasCaptureMediaStreamTrack::Source::startProducingData):
3356         (WebCore::CanvasCaptureMediaStreamTrack::Source::stopProducingData):
3357         (WebCore::CanvasCaptureMediaStreamTrack::Source::canvasDestroyed):
3358         (WebCore::CanvasCaptureMediaStreamTrack::Source::captureCanvas):
3359         * Modules/mediastream/CanvasCaptureMediaStreamTrack.h:
3360         * Modules/mediastream/MediaStream.cpp:
3361         (WebCore::MediaStream::mediaState):
3362         * platform/mediastream/MediaStreamTrackPrivate.h:
3363         (WebCore::MediaStreamTrackPrivate::startProducingData):
3364         (WebCore::MediaStreamTrackPrivate::stopProducingData):
3365         * platform/mediastream/RealtimeMediaSource.cpp:
3366         (WebCore::RealtimeMediaSource::setMuted):
3367         (WebCore::RealtimeMediaSource::notifyMutedChange):
3368         (WebCore::RealtimeMediaSource::setEnabled):
3369         (WebCore::RealtimeMediaSource::start):
3370         (WebCore::RealtimeMediaSource::stop):
3371         (WebCore::RealtimeMediaSource::requestStop):
3372         (WebCore::RealtimeMediaSource::reset): Deleted.
3373         * platform/mediastream/RealtimeMediaSource.h:
3374         * platform/mediastream/mac/AVMediaCaptureSource.h:
3375         * platform/mediastream/mac/AVMediaCaptureSource.mm:
3376         (WebCore::AVMediaCaptureSource::AVMediaCaptureSource):
3377         (WebCore::AVMediaCaptureSource::captureSessionIsRunningDidChange):
3378         (WebCore::AVMediaCaptureSource::reset): Deleted.
3379         (WebCore::AVMediaCaptureSource::isProducingData): Deleted.
3380         * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
3381         (WebCore::CoreAudioCaptureSource::CoreAudioCaptureSource):
3382         (WebCore::CoreAudioCaptureSource::startProducingData):
3383         (WebCore::CoreAudioCaptureSource::stopProducingData):
3384         (WebCore::CoreAudioCaptureSource::audioSourceProvider):
3385         * platform/mediastream/mac/CoreAudioCaptureSource.h:
3386         * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
3387         (WebCore::MockRealtimeAudioSourceMac::render):