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