Add missing text styles
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-04-01  Jon Lee  <jonlee@apple.com>
2
3         Add missing text styles
4         https://bugs.webkit.org/show_bug.cgi?id=170295
5         rdar://problem/30219503
6
7         Reviewed by Dean Jackson.
8
9         Updated existing test to include new text styles.
10
11         * css/CSSValueKeywords.in: Add title0 and title4.
12         * platform/spi/cocoa/CoreTextSPI.h:
13         * rendering/RenderThemeIOS.mm:
14         (WebCore::RenderThemeIOS::cachedSystemFontDescription):
15         (WebCore::RenderThemeIOS::updateCachedSystemFontDescription):
16
17 2017-04-01  Dan Bernstein  <mitz@apple.com>
18
19         [iOS] <input type=file> label should be specified using plural rules
20         https://bugs.webkit.org/show_bug.cgi?id=170388
21
22         Reviewed by Alexey Proskuryakov.
23
24         * English.lproj/Localizable.strings: Updated using update-webkit-localizable-strings.
25
26         * English.lproj/Localizable.stringsdict: Added an entry for the new key "%lu photo(s) and
27           %lu video(s)", with plural rules covering all the different combinations in English.
28           Other localizations may specify additional combinations as needed.
29
30 2017-04-01  Alexey Proskuryakov  <ap@apple.com>
31
32         Rolling back <https://trac.webkit.org/r214697>, as it made WebKit2.DataDetectionReferenceDate time out.
33
34         Was REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
35         https://bugs.webkit.org/show_bug.cgi?id=170365
36
37         * editing/cocoa/DataDetection.mm:
38         (WebCore::searchForLinkRemovingExistingDDLinks):
39
40 2017-04-01  Chris Dumez  <cdumez@apple.com>
41
42         We should pause silent WebAudio rendering in background tabs
43         https://bugs.webkit.org/show_bug.cgi?id=170299
44         <rdar://problem/31289132>
45
46         Reviewed by Eric Carlson.
47
48         We should pause silent WebAudio rendering in background tabs since it uses CPU and is
49         not observable by the user. Such silent WebAudio rendering seems to be used by
50         doubleclick ads.
51
52         Test: webaudio/silent-audio-interrupted-in-background.html
53
54         * Modules/webaudio/AudioContext.cpp:
55         (WebCore::AudioContext::lazyInitialize):
56         (WebCore::AudioContext::uninitialize):
57         Have AudioContext register / unregister itself with the Document to get
58         visibility change notifications, similarly to what HTMLMediaElement was
59         already doing.
60
61         (WebCore::AudioContext::visibilityStateChanged):
62         Begin / End session interruption whenever the page visiblity changes.
63
64         * Modules/webaudio/AudioContext.h:
65         * WebCore.xcodeproj/project.pbxproj:
66
67         * dom/Document.cpp:
68         (WebCore::Document::registerForVisibilityStateChangedCallbacks):
69         (WebCore::Document::unregisterForVisibilityStateChangedCallbacks):
70         (WebCore::Document::visibilityStateChanged):
71         * dom/Document.h:
72         * dom/Element.h:
73         * dom/VisibilityChangeClient.h: Added.
74         (WebCore::VisibilityChangeClient::~VisibilityChangeClient):
75         * html/HTMLMediaElement.h:
76         Introduce a new VisibilityChangeClient interface and have both AudioContext
77         and HTMLMediaElement subclass it. Previously, the visibilityStateChanged()
78         function was on Element but this prevented AudioContext from registering
79         itself since AudioContext is not an Element.
80
81 2017-04-01  Dan Bernstein  <mitz@apple.com>
82
83         [Cocoa] A couple of UI strings use three periods instead of an ellipsis
84         https://bugs.webkit.org/show_bug.cgi?id=170386
85
86         Reviewed by Tim Horton.
87
88         * English.lproj/Localizable.strings: Updated using update-webkit-localizable-strings.
89
90         * platform/LocalizedStrings.cpp:
91         (WebCore::mediaElementLoadingStateText): Changed "Loading..." to "Loading…".
92
93         * platform/cocoa/LocalizedStringsCocoa.mm:
94         (WebCore::contextMenuItemTagStyles): Changed "Styles..." to "Styles…".
95
96 2017-04-01  Dan Bernstein  <mitz@apple.com>
97
98         Localizable strings files are out of date
99         https://bugs.webkit.org/show_bug.cgi?id=170383
100
101         Reviewed by Tim Horton.
102
103         Ran update-webkit-localizable-strings.
104
105         * English.lproj/Localizable.strings:
106
107 2017-04-01  Dan Bernstein  <mitz@apple.com>
108
109         [Xcode] In engineering builds, linker warns about libwebrtc.dylib’s install name being invalid
110         https://bugs.webkit.org/show_bug.cgi?id=170385
111
112         Reviewed by Tim Horton.
113
114         * Configurations/DebugRelease.xcconfig: Set WK_RELOCATABLE_FRAMEWORKS to YES like we do
115           in some other projects’ DebugRelease.xcconfig. Engineering builds are always relocatable.
116         * Configurations/WebCore.xcconfig: When WebCore is relocatable, tell the linker that it’s
117           not going to be in the shared cache, even if its install name implies that it might be.
118
119 2017-04-01  Alexey Proskuryakov  <ap@apple.com>
120
121         Rolling back http://trac.webkit.org/r214663 - memory corruption
122
123         * Modules/streams/ReadableByteStreamInternals.js:
124         (cloneArrayBuffer):
125         * bindings/js/JSDOMGlobalObject.cpp:
126         (WebCore::JSDOMGlobalObject::addBuiltinGlobals):
127         * bindings/js/StructuredClone.cpp:
128         (WebCore::structuredCloneArrayBuffer):
129         (WebCore::cloneArrayBufferImpl): Deleted.
130         (WebCore::cloneArrayBuffer): Deleted.
131         * bindings/js/StructuredClone.h:
132         * bindings/js/WebCoreBuiltinNames.h:
133         * testing/Internals.cpp:
134         (WebCore::markerTypeFrom):
135         (WebCore::Internals::resetToConsistentState):
136         (WebCore::Internals::isLoadingFromMemoryCache):
137         (WebCore::Internals::setImageFrameDecodingDuration):
138         (WebCore::deferredStyleRulesCountForList):
139         (WebCore::deferredGroupRulesCountForList):
140         (WebCore::deferredKeyframesRulesCountForList):
141         (WebCore::Internals::eventThrottlingBehaviorOverride):
142         (WebCore::Internals::enableMockSpeechSynthesizer):
143         (WebCore::Internals::rangeForDictionaryLookupAtLocation):
144         (WebCore::Internals::nodesFromRect):
145         (WebCore::Internals::layerIDForElement):
146         (WebCore::Internals::setElementUsesDisplayListDrawing):
147         (WebCore::Internals::setElementTracksDisplayListReplay):
148         (WebCore::Internals::styleRecalcCount):
149         (WebCore::Internals::compositingUpdateCount):
150         (WebCore::Internals::setCaptionDisplayMode):
151         (WebCore::Internals::endMediaSessionInterruption):
152         (WebCore::Internals::postRemoteControlCommand):
153         (WebCore::appendOffsets):
154         (WebCore::Internals::scrollSnapOffsets):
155         (WebCore::Internals::setShowAllPlugins):
156         (WebCore::Internals::cloneArrayBuffer): Deleted.
157         * testing/Internals.h:
158         * testing/Internals.idl:
159
160 2017-03-31  Zalan Bujtas  <zalan@apple.com>
161
162         <table>: Including <caption>, <thead> or <tbody> causes clipping across page breaks
163         https://bugs.webkit.org/show_bug.cgi?id=170348
164         <rdar://problem/24727151>
165
166         Reviewed by David Hyatt.
167
168         1. In RenderFlowThread::offsetFromLogicalTopOfFirstRegion() we need to take table section offset into account (they are skipped
169         during the containing block traversal).
170         2. Trigger paginated relayout when body is moved vertically due to caption/thead etc.
171
172         Test: fast/multicol/table-section-page-break.html
173
174         * rendering/RenderFlowThread.cpp:
175         (WebCore::RenderFlowThread::offsetFromLogicalTopOfFirstRegion):
176         * rendering/RenderTable.cpp:
177         (WebCore::RenderTable::layout):
178
179 2017-03-31  Simon Fraser  <simon.fraser@apple.com>
180
181         Rename DOMWindow's m_touchEventListenerCount to m_touchAndGestureEventListenerCount
182         https://bugs.webkit.org/show_bug.cgi?id=170371
183
184         Reviewed by Tim Horton.
185
186         This count tracks touch and gesture event listeners, so name it appropriately.
187
188         * page/DOMWindow.cpp:
189         (WebCore::DOMWindow::addEventListener):
190         (WebCore::DOMWindow::removeEventListener):
191         (WebCore::DOMWindow::removeAllEventListeners):
192         * page/DOMWindow.h:
193
194 2017-03-31  Simon Fraser  <simon.fraser@apple.com>
195
196         When destroying a Node, assert that it's been removed from all the touch handler maps
197         https://bugs.webkit.org/show_bug.cgi?id=170363
198         rdar://problem/31377469
199
200         Reviewed by Tim Horton.
201
202         Assert that the Node has been removed from the touch handler maps in all documents on destruction.
203
204         * dom/Document.h:
205         (WebCore::Document::hasTouchEventHandlers):
206         (WebCore::Document::touchEventTargetsContain):
207         * dom/Node.cpp:
208         (WebCore::Node::~Node):
209
210 2017-03-31  Alexey Proskuryakov  <ap@apple.com>
211
212         Rolling back https://trac.webkit.org/r214689, as it caused many crashes.
213
214         Was:
215         Fix memory leak in CreateSessionDescriptionObserver::OnSuccess
216         https://bugs.webkit.org/show_bug.cgi?id=170357
217
218         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
219         (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionSucceeded):
220
221 2017-03-31  Youenn Fablet  <youenn@apple.com>
222
223         Fix memory leak in RealtimeVideoIncomingSource
224         https://bugs.webkit.org/show_bug.cgi?id=170356
225
226         Reviewed by Eric Carlson.
227
228         No change of behavior.
229
230         * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
231         (WebCore::RealtimeIncomingVideoSource::OnFrame): Adopting the newly created pointer.
232
233 2017-03-31  Andy Estes  <aestes@apple.com>
234
235         REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
236         https://bugs.webkit.org/show_bug.cgi?id=170365
237         <rdar://problem/29205721>
238
239         Reviewed by Tim Horton.
240
241         r202472 changed the node traversal in searchForLinkRemovingExistingDDLinks() to only
242         consider nodes that are descendants of startNode, but we need to traverse all nodes between
243         startNode and endNode to find existing non-DD links.
244
245         As a result, we'd add a Data Detector link to the following snippet and make the original
246         links un-clickable:
247
248             <a href='#'>tomorrow</a> <a href='#'>night</a>
249
250         Fix this by not specifying a stayWithin node when calling NodeTraversal::next(). The loop
251         will terminate when we reach endNode.
252
253         Updated WebKit2.DataDetectionReferenceDate API test.
254
255         * editing/cocoa/DataDetection.mm:
256         (WebCore::searchForLinkRemovingExistingDDLinks):
257
258 2017-03-31  Eric Carlson  <eric.carlson@apple.com>
259
260         Incoming video source doesn't propogate frame rotation
261         https://bugs.webkit.org/show_bug.cgi?id=170364
262
263         Reviewed by Youenn Fablet.
264
265         No new tests, the mock video source doesn't support rotation. Test will be added when
266         this is fixed in https://bugs.webkit.org/show_bug.cgi?id=169822. The changes were 
267         verified manually.
268
269         * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
270         (WebCore::RealtimeIncomingVideoSource::OnFrame): Convert frame rotation to sample
271         orientation and swap width and height when necessary.
272         (WebCore::RealtimeIncomingVideoSource::processNewSample):
273         * platform/mediastream/mac/RealtimeIncomingVideoSource.h:
274
275 2017-03-31  Chris Dumez  <cdumez@apple.com>
276
277         Possible null dereference under SourceBuffer::sourceBufferPrivateDidReceiveSample()
278         https://bugs.webkit.org/show_bug.cgi?id=159639
279
280         Reviewed by Eric Carlson.
281
282         Add a null check for trackBuffer.description before dereferencing as it seems
283         it can be null.
284
285         * Modules/mediasource/SourceBuffer.cpp:
286         (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
287
288 2017-03-31  Youenn Fablet  <youenn@apple.com>
289
290         Fix memory leak in CreateSessionDescriptionObserver::OnSuccess
291         https://bugs.webkit.org/show_bug.cgi?id=170357
292
293         Reviewed by Geoffrey Garen.
294
295         No change of behavior.
296
297         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
298         (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionSucceeded): Adopting the raw pointer parameter.
299
300 2017-03-31  Fujii Hironori  <Hironori.Fujii@sony.com>
301
302         [WinCairo] WebCore::PlatformDisplay::terminateEGLDisplay causes a crash in libGLESv2.dll while processing atexit
303         https://bugs.webkit.org/show_bug.cgi?id=170331
304
305         Reviewed by Michael Catanzaro.
306
307         WebCore::PlatformDisplay uses atexit to destruct EGL displays
308         while exiting process. But, when the atexit will be processed,
309         heap of libGLESv2.dll would be already destructed and causing a
310         crash on Windows. Do not use atexit for Windows.
311
312         AppleWin port does not use PlatformDisplay. Thus, it does not have
313         this bug.
314
315         * platform/graphics/PlatformDisplay.cpp:
316         (WebCore::PlatformDisplay::initializeEGLDisplay): Do not use atexit for Windows.
317         (WebCore::PlatformDisplay::shutDownEglDisplays): Added.
318         * platform/graphics/PlatformDisplay.h: Added a declaration of shutDownEglDisplays.
319
320 2017-03-31  Yoav Weiss  <yoav@yoav.ws>
321
322         Remove PRELOAD_DEBUG related code.
323         https://bugs.webkit.org/show_bug.cgi?id=170352
324
325         Reviewed by Youenn Fablet.
326
327         As the PRELOAD_DEBUG related code stopped building and it seems like no one noticed,
328         it seems safe to assume that we can remove that code. This patch removes it.
329
330         No new tests as there's no functional change.
331
332         * loader/cache/CachedResourceLoader.cpp:
333         (WebCore::CachedResourceLoader::preload):
334         (WebCore::CachedResourceLoader::clearPreloads):
335         (WebCore::CachedResourceLoader::printPreloadStats): Deleted.
336
337 2017-03-31  Brady Eidson  <beidson@apple.com>
338
339         Clean up the "StorageType" enum.
340         https://bugs.webkit.org/show_bug.cgi?id=170349
341
342         Reviewed by Tim Horton.
343
344         - Make this `enum` into an `enum class`
345         - Add a new type specific for "transient local storage"
346
347         No new tests (No behavior change).
348
349         * WebCore.xcodeproj/project.pbxproj:
350         
351         * inspector/InspectorDOMStorageAgent.cpp:
352         (WebCore::InspectorDOMStorageAgent::didDispatchDOMStorageEvent):
353         
354         * inspector/InspectorInstrumentation.h:
355         
356         * loader/EmptyClients.cpp:
357         
358         * storage/Storage.cpp:
359         (WebCore::Storage::isDisabledByPrivateBrowsing):
360         
361         * storage/StorageArea.h:
362         (): Deleted.
363         
364         * storage/StorageEventDispatcher.cpp:
365         (WebCore::StorageEventDispatcher::dispatchSessionStorageEventsToFrames):
366         (WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames):
367         
368         * storage/StorageType.h:
369         (WebCore::isLocalStorage):
370
371 2017-03-31  Chris Dumez  <cdumez@apple.com>
372
373         Unreviewed, Mark "HTML interactive form validation" as done.
374
375         It is shipping in Safari 10.1.
376  
377         * features.json:
378
379 2017-03-31  Csaba Osztrogonác  <ossy@webkit.org>
380
381         Mac cmake buildfix after r214666
382         https://bugs.webkit.org/show_bug.cgi?id=170342
383
384         Unreviewed buildfix.
385
386         * PlatformMac.cmake:
387         * testing/MockPreviewLoaderClient.h:
388
389 2017-03-31  Sam Weinig  <sam@webkit.org>
390
391         Remove unneeded custom constructors include.
392
393         * WebCore.xcodeproj/project.pbxproj:
394         * bindings/js/ios: Removed.
395         * bindings/js/ios/TouchConstructors.cpp: Removed.
396
397 2017-03-31  John Wilander  <wilander@apple.com>
398
399         Resource Load Statistics: Check if the store exists before clearing it
400         https://bugs.webkit.org/show_bug.cgi?id=170324
401         <rdar://problem/31258505>
402
403         Reviewed by Brent Fulgham.
404
405         No new tests. Added a null check.
406
407         * loader/ResourceLoadObserver.cpp:
408         (WebCore::ResourceLoadObserver::clearInMemoryAndPersistentStore):
409             Added a null check.
410
411 2017-03-31  Romain Bellessort  <romain.bellessort@crf.canon.fr>
412
413         [Readable Streams API] Implement cloneArrayBuffer in WebCore
414         https://bugs.webkit.org/show_bug.cgi?id=170008
415
416         Reviewed by Youenn Fablet.
417
418         Implemented cloneArrayBuffer based on existing structuredCloneArrayBuffer
419         implementation. The code has been factorized so that both cloneArrayBuffer
420         and structuredCloneArrayBuffer rely on the same code (which is basically
421         the previous implementation of structuredCloneArrayBuffer + the ability
422         to clone only a part of considered buffer).
423
424         Added test to check cloneArrayBuffer behaviour.
425
426         * Modules/streams/ReadableByteStreamInternals.js: Deleted cloneArrayBuffer JS implementation.
427         * bindings/js/JSDOMGlobalObject.cpp:
428         (WebCore::JSDOMGlobalObject::addBuiltinGlobals): Add cloneArrayBuffer private declaration.
429         * bindings/js/StructuredClone.cpp:
430         (WebCore::cloneArrayBufferImpl): Added (mostly based on previous structuredCloneArrayBuffer).
431         (WebCore::cloneArrayBuffer): Added.
432         (WebCore::structuredCloneArrayBuffer): Updated.
433         * bindings/js/StructuredClone.h: Added cloneArrayBuffer declaration.
434         * bindings/js/WebCoreBuiltinNames.h: Added cloneArrayBuffer declaration.
435         * testing/Internals.cpp: Added support for testing cloneArrayBuffer.
436         * testing/Internals.h: Added support for testing cloneArrayBuffer.
437         * testing/Internals.idl: Added support for testing cloneArrayBuffer.
438
439 2017-03-31  Antoine Quint  <graouts@apple.com>
440
441         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
442         https://bugs.webkit.org/show_bug.cgi?id=168409
443         <rdar://problem/30799198>
444
445         Unreviewed. Yet more logging to determine under what circumstance ScriptedAnimationController gets suspended.
446
447         * dom/Document.cpp:
448         (WebCore::Document::requestAnimationFrame):
449
450 2017-03-30  Zan Dobersek  <zdobersek@igalia.com>
451
452         Unreviewed GTK+ build fix. Add missing ANGLE build targets
453         to the build.
454
455         * CMakeLists.txt:
456
457 2017-03-30  Simon Fraser  <simon.fraser@apple.com>
458
459         Ensure that Node::willBeDeletedFrom() always removes touch event handlers from the document
460         https://bugs.webkit.org/show_bug.cgi?id=170323
461         rdar://problem/23647630
462
463         Reviewed by Chris Dumez.
464
465         There are two instances where nodes are registered as touch event handlers without
466         having normal touch event listeners: slider thumb elements, and elements with overflow scrolling,
467         on iOS.
468
469         For such nodes, hasEventTargetData() will be false, but we want to ensure
470         that they are removed from the Document's touchEventHandler set, so move the
471         call to document.removeTouchEventHandler() outside of the conditional block.
472
473         This should be cheap in most cases when the touchEventHandler is empty.
474
475         * dom/Node.cpp:
476         (WebCore::Node::willBeDeletedFrom):
477
478 2017-03-30  Simon Fraser  <simon.fraser@apple.com>
479
480         Minor cleanup checking for gesture event names
481         https://bugs.webkit.org/show_bug.cgi?id=170319
482
483         Reviewed by Tim Horton.
484
485         Just use isGestureEventType() in a couple of places.
486
487         * dom/Node.cpp:
488         (WebCore::tryAddEventListener):
489         (WebCore::tryRemoveEventListener):
490
491 2017-03-30  Simon Fraser  <simon.fraser@apple.com>
492
493         Rename a touch event function, and new touch region test results
494         https://bugs.webkit.org/show_bug.cgi?id=170309
495         rdar://problem/31329520
496
497         Reviewed by Chris Dumez.
498
499         Adapt to a naming change in WebKitAdditions.
500
501         * dom/Document.cpp:
502         (WebCore::Document::removeAllEventListeners):
503         * page/FrameView.cpp:
504         (WebCore::FrameView::layout):
505         * rendering/RenderElement.cpp:
506         (WebCore::RenderElement::styleWillChange):
507         * rendering/RenderLayer.cpp:
508         (WebCore::RenderLayer::scrollTo):
509         (WebCore::RenderLayer::calculateClipRects):
510
511 2017-03-30  Matt Rajca  <mrajca@apple.com>
512
513         YouTube sometimes does not respect "user gesture" restriction for videos.
514         https://bugs.webkit.org/show_bug.cgi?id=170297
515
516         I discovered a code path that does not honor the "user gesture" requirement and playback is able to begin
517         even though we have a restriction in place. When using Media Source Extensions, which YouTube does, we transition
518         from a "Have Metadata" to a "Future Data" state that causes playback to begin, however, we never check
519         if we have a playback restriction in place.
520
521         Reviewed by Eric Carlson.
522
523         * html/HTMLMediaElement.cpp:
524         (WebCore::HTMLMediaElement::setReadyState):
525
526 2017-03-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
527
528         REGRESSION (r213764): Background image from sprite sheet incorrectly scaled
529         https://bugs.webkit.org/show_bug.cgi?id=169547
530
531         Reviewed by Simon Fraser.
532
533         The bug happens when drawing only a rectangle of an image not the whole
534         image. In BitmapImage::draw(), sizeForDrawing was calculated as the destRect
535         scaled by the transformation which is applied to the GraphicsContext. Two
536         problems with this approach. The first one is destRect can be only part of
537         the image. The second problem is, the ratio destRect / srcRect is another
538         scaling that needs to be considered.
539
540         To fix this issue, first the base size has to be size of the image and not
541         destRect.size(). Secondly, we need to scale this base size with the context
542         transformation multiplied by the ratio destRect / srcRect. This scaling is
543         exactly the same scaling which is calculated in subsamplingScale(). Finally
544         we use this scaled size as the sizeForDrawing to send to the ImageDecoder.
545
546         Test: fast/images/sprite-sheet-image-draw.html
547
548         * platform/graphics/BitmapImage.cpp:
549         (WebCore::BitmapImage::draw): Fix the bug.
550         (WebCore::BitmapImage::stopAnimation): Stops the async image decoding for animated images only.
551         The decoding for large images will be stopped when BitmapImage::newFrameNativeImageAvailableAtIndex()
552         is called and the decoding queue is idle.
553         (WebCore::BitmapImage::newFrameNativeImageAvailableAtIndex): Add image logging.
554         * platform/graphics/BitmapImage.h: Move sourceURL() to the Image class.
555         * platform/graphics/GraphicsContext.cpp: Pass imagePaintingOptions.m_decodingMode to Image::drawTiled().
556         (WebCore::GraphicsContext::drawTiledImage): Pass imagePaintingOptions.m_decodingMode) to Image::drawTiled().
557         * platform/graphics/Image.cpp:
558         (WebCore::Image::sourceURL): Moved from BitmapImage.
559         (WebCore::Image::drawTiled): Add a DecodingMode argument instead of calling always with DecodingMode::Synchronous.
560         * platform/graphics/Image.h:
561         * platform/graphics/ImageFrameCache.cpp:
562         (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex): Add image logging.
563         (WebCore::ImageFrameCache::startAsyncDecodingQueue): Ditto,
564         (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Ditto.
565         (WebCore::ImageFrameCache::stopAsyncDecodingQueue): Ditto.
566         (WebCore::ImageFrameCache::sourceURL): A helper function to avoid checking the value of m_image.
567         * platform/graphics/ImageFrameCache.h:
568         * platform/graphics/NativeImage.h: Rename subsamplingScale() to nativeImageDrawingScale() and return image scaling instead.
569         * platform/graphics/cairo/NativeImageCairo.cpp:
570         (WebCore::nativeImageDrawingScale): Ditto.
571         (WebCore::subsamplingScale): Deleted.
572         * platform/graphics/cg/NativeImageCG.cpp:
573         (WebCore::nativeImageDrawingScale): Ditto.
574         (WebCore::subsamplingScale): Deleted.
575         * platform/graphics/win/NativeImageDirect2D.cpp:
576         (WebCore::nativeImageDrawingScale): Ditto.
577         (WebCore::subsamplingScale): Deleted.
578
579 2017-03-30  Matt Baker  <mattbaker@apple.com>
580
581         Web Inspector: Assertion failure in InspectorStyleProperty::setRawTextFromStyleDeclaration
582         https://bugs.webkit.org/show_bug.cgi?id=170279
583         <rdar://problem/30200492>
584
585         Reviewed by David Hyatt.
586
587         The SourceRange for a CSSPropertySourceData should be relative to the start
588         of the declaration body, not the start of the StyleSheetHandler’s parsed
589         text. This only affected the ranges of unparsed (parsedOK == false) properties
590         lacking a trailing semi-colon.
591
592         This patch doesn't change the behavior of InspectorStyleSheet other than
593         silencing an irksome assert, as String::substring does a safety check on
594         the passed in length.
595
596         * inspector/InspectorStyleSheet.cpp:
597         (WebCore::fixUnparsedProperties):
598
599 2017-03-30  Youenn Fablet  <youenn@apple.com> and Jon Lee <jonlee@apple.com>
600
601         Clean up RTCDataChannel
602         https://bugs.webkit.org/show_bug.cgi?id=169732
603
604         Reviewed by Chris Dumez.
605
606         Test: webrtc/datachannel/datachannel-event.html
607               webrtc/datachannel/bufferedAmountLowThreshold.html
608
609         Making RTCDataChannel interface closer to the spec updating implementation accordingly.
610         See https://w3c.github.io/webrtc-pc/#rtcdatachannel.
611         In particular adding RTCDataChannelEvent constructor, and missing bufferedAmount related attributes.
612         Doing some additional cleaning refactoring.
613
614         Making bufferedAmountIsDecreasing take a bufferedAmount argument so that we get the actual value passed by
615         libwebrtc without needing to get it from the libwebrtc network thread again.
616         In the future, we should store the bufferedAmount value in RTCDataChannel and update its value on each libwebrtc
617         OnBufferedAmountChange. Special treatment may be needed when the data channel is closed, in which case the bufferedAmount should just be
618         updated to increase in the send method.
619
620         Added some FIXMEs as RTCDataChannel is not aligned with the spec related to send and bufferedAmount.
621
622         * Modules/mediastream/RTCDataChannel.cpp:
623         (WebCore::RTCDataChannel::send):
624         (WebCore::RTCDataChannel::close):
625         (WebCore::RTCDataChannel::didChangeReadyState):
626         (WebCore::RTCDataChannel::bufferedAmountIsDecreasing):
627         * Modules/mediastream/RTCDataChannel.h:
628         * Modules/mediastream/RTCDataChannel.idl:
629         * Modules/mediastream/RTCDataChannelEvent.cpp:
630         (WebCore::RTCDataChannelEvent::create):
631         (WebCore::RTCDataChannelEvent::RTCDataChannelEvent):
632         (WebCore::RTCDataChannelEvent::channel):
633         * Modules/mediastream/RTCDataChannelEvent.h:
634         * Modules/mediastream/RTCDataChannelEvent.idl:
635         * Modules/mediastream/RTCPeerConnection.idl:
636         * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
637         (WebCore::LibWebRTCDataChannelHandler::OnStateChange):
638         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
639         (WebCore::LibWebRTCMediaEndpoint::addDataChannel):
640         * WebCore.xcodeproj/project.pbxproj:
641         * dom/EventNames.h:
642         * platform/mediastream/RTCDataChannelHandler.h:
643         * platform/mediastream/RTCDataChannelHandlerClient.h:
644         * platform/mediastream/RTCDataChannelState.h: Added.
645         * platform/mediastream/RTCPeerConnectionHandlerClient.h:
646         * platform/mock/RTCDataChannelHandlerMock.cpp:
647         (WebCore::RTCDataChannelHandlerMock::setClient):
648         (WebCore::RTCDataChannelHandlerMock::close):
649         * platform/mock/RTCNotifiersMock.cpp:
650         (WebCore::IceConnectionNotifier::IceConnectionNotifier):
651         (WebCore::SignalingStateNotifier::SignalingStateNotifier):
652         (WebCore::DataChannelStateNotifier::DataChannelStateNotifier):
653         * platform/mock/RTCNotifiersMock.h:
654
655 2017-03-30  Javier Fernandez  <jfernandez@igalia.com>
656
657         [css-align] Adapt content-alignment properties to the new baseline syntax
658         https://bugs.webkit.org/show_bug.cgi?id=170262
659
660         Reviewed by David Hyatt.
661
662         The baseline-position syntax has changed recently, so we need to update
663         the CSS properties using the old syntax. This patch address only the
664         content-alignment (align-content and justify-content).
665
666         I used this patch to adapt the implementation of the parsing logic for
667         these properties to the new Blink's CSS Parsing Design.
668
669         The new baseline syntax is "[first | last ]? baseline" which implies
670         modifying the parsing and computed value logic.
671
672         There are several layout tests affected by this change, so I'll update
673         them accordingly.
674
675         No new tests, just added/modified some cases to the tests we
676         already have using the new baseline values.
677
678         * css/CSSComputedStyleDeclaration.cpp:
679         (WebCore::valueForContentPositionAndDistributionWithOverflowAlignment):
680         * css/CSSContentDistributionValue.cpp:
681         (WebCore::CSSContentDistributionValue::customCSSText):
682         * css/CSSPrimitiveValueMappings.h:
683         (WebCore::CSSPrimitiveValue::operator ItemPosition):
684         (WebCore::CSSPrimitiveValue::operator ContentPosition):
685         * css/CSSValueKeywords.in:
686         * css/parser/CSSPropertyParser.cpp:
687         (WebCore::isBaselineKeyword):
688         (WebCore::consumeBaselineKeyword):
689         (WebCore::consumeContentDistributionOverflowPosition):
690         (WebCore::consumeSelfPositionOverflowPosition):
691
692 2017-03-30  James Craig  <jcraig@apple.com>
693
694         AX: Expose a new AXSubrole for explicit ARIA "group" role
695         https://bugs.webkit.org/show_bug.cgi?id=169810
696         <rdar://problem/31039693>
697
698         Reviewed by Chris Fleizach.
699
700         Split GroupRole into generics (GroupRole) and explicit groups 
701         (ApplicationGroupRole) so we can expose a subrole on the explicit 
702         groups. Account for the change in ARIA Tree and Menu hierachies. 
703         Update the computedRoleValue for WebKit Inspector usage, too.
704
705         Updated existing tests.
706
707         Test: accessibility/list-detection2.html:
708         Test: accessibility/roles-computedRoleString.html:
709         Test: inspector/dom/getAccessibilityPropertiesForNode.html:
710         Test: inspector/dom/highlightFrame.html:
711         Test: inspector/dom/highlightSelector.html:
712
713         * accessibility/AccessibilityNodeObject.cpp:
714         (WebCore::AccessibilityNodeObject::helpText):
715         (WebCore::AccessibilityNodeObject::hierarchicalLevel):
716         (WebCore::AccessibilityNodeObject::remapAriaRoleDueToParent):
717         * accessibility/AccessibilityObject.cpp:
718         (WebCore::AccessibilityObject::accessibleNameDerivesFromContent):
719         (WebCore::AccessibilityObject::ariaTreeItemContent):
720         (WebCore::initializeRoleMap):
721         (WebCore::AccessibilityObject::computedRoleString):
722         * accessibility/AccessibilityObject.h:
723         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
724         (atkRole):
725         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
726         (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
727         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
728         (createAccessibilityRoleMap):
729         (-[WebAccessibilityObjectWrapper subrole]):
730
731 2017-03-30  Chris Dumez  <cdumez@apple.com>
732
733         We are spending a lot of time bzero'ing AudioChannel buffers on uni-watch.com
734         https://bugs.webkit.org/show_bug.cgi?id=170288
735         <rdar://problem/31289132>
736
737         Reviewed by Eric Carlson.
738
739         We are spending a lot of time bzero'ing AudioChannel buffers on uni-watch.com due
740         to doubleclick ads using WebAudio with a 0-gain GainNode. We should optimize the
741         0-gain case as much as possible.
742
743         No new tests, only an optimization.
744
745         * Modules/webaudio/AudioNode.cpp:
746         (WebCore::AudioNode::processIfNecessary):
747         Drop call to unsilenceOutputs() before calling AudioNode::process(). The AudioChannel
748         API already takes care of clearing its 'silent' flag whenever its buffer changes so
749         there should be no need to explicitly clearing the 'silent' flag before calling
750         process(). This was causing us to zero out buffers that were already filled with
751         zeros because AudioChannel::zero() would no longer return early, not knowing the
752         channel is already silent. This reduces the number of bzero() calls by ~3.5x on
753         uni-watch.com (from 100 calls every ~20ms to 100 calls every ~70ms.
754
755         * Modules/webaudio/AudioNode.h:
756         * platform/audio/mac/AudioDestinationMac.cpp:
757         (WebCore::AudioDestinationMac::render):
758         Avoid clamping the values in the channel buffer if the channel is silent since this
759         will have no effect (given that the buffer only contains zeros).
760
761 2017-03-30  Eric Carlson  <eric.carlson@apple.com>
762
763         [Crash] WebCore::AudioBuffer::AudioBuffer don't checking illegal value
764         https://bugs.webkit.org/show_bug.cgi?id=169956
765
766         Reviewed by Youenn Fablet.
767
768         Test: webaudio/audiobuffer-crash.html
769
770         * Modules/webaudio/AudioBuffer.cpp:
771         (WebCore::AudioBuffer::AudioBuffer): Invalidate the object and return early if the channel 
772         array allocation fails.
773         (WebCore::AudioBuffer::AudioBuffer): Ditto.
774         (WebCore::AudioBuffer::invalidate): Invalidate the object.
775         * Modules/webaudio/AudioBuffer.h:
776
777 2017-03-30  Antoine Quint  <graouts@apple.com>
778
779         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
780         https://bugs.webkit.org/show_bug.cgi?id=168409
781         <rdar://problem/30799198>
782
783         Unreview. Print the backtrace when we suspend scripted animations.
784
785         * page/Page.cpp:
786         (WebCore::Page::suspendScriptedAnimations):
787
788 2017-03-30  Antoine Quint  <graouts@apple.com>
789
790         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
791         https://bugs.webkit.org/show_bug.cgi?id=168409
792         <rdar://problem/30799198>
793
794         Unreview. Pring the backtrace when we suspend ScriptedAnimationController.
795
796         * dom/ScriptedAnimationController.cpp:
797         (WebCore::ScriptedAnimationController::suspend):
798
799 2017-03-30  Antoine Quint  <graouts@apple.com>
800
801         [Modern Media Controls] Invalid placard icon is not visible for short video
802         https://bugs.webkit.org/show_bug.cgi?id=170277
803         <rdar://problem/31327955>
804
805         Reviewed by Eric Carlson.
806
807         Make the minimum dimension needed to display a placard icon configurable and let the
808         invalid placard use a 50pt dimension. We also make a drive-by fix to reset "text-align"
809         for media controls as having a "text-align: center" inherited value would mess up
810         positioning of the placard icon and make it flush to the right of the placard.
811
812         Test: media/modern-media-controls/invalid-placard/invalid-placard-constrained-metrics.html
813
814         * Modules/modern-media-controls/controls/invalid-placard.js:
815         (InvalidPlacard):
816         * Modules/modern-media-controls/controls/media-controls.css:
817         (.media-controls):
818         * Modules/modern-media-controls/controls/placard.js:
819         (Placard.prototype.layout):
820
821 2017-03-30  Zan Dobersek  <zdobersek@igalia.com>
822
823         [GCrypt] Register missing algorithms in CryptoAlgorithmRegistry::platformRegisterAlgoritmhs()
824         https://bugs.webkit.org/show_bug.cgi?id=170273
825
826         Reviewed by Michael Catanzaro.
827
828         * crypto/gcrypt/CryptoAlgorithmRegistryGCrypt.cpp:
829         (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
830         Add registerAlgorithm<> calls for AES_CFB, AES_GCM, ECDH and
831         PBKDF2 algorithms.
832
833 2017-03-30  Brent Fulgham  <bfulgham@apple.com>
834
835         Remove unused MediaControlsApple implementation
836         https://bugs.webkit.org/show_bug.cgi?id=170258
837         <rdar://problem/31331056>
838
839         Reviewed by Eric Carlson.
840
841         Remove dead code related to old media controls. We switched to HTML5-based media controls
842         several years ago.
843
844         No new tests. Removing this dead code should have no change in behavior.
845
846         * WebCore.xcodeproj/project.pbxproj: Remove unused files.
847         * dom/EventListener.h: Remove unused event type.
848         * html/shadow/MediaControlsApple.cpp: Removed.
849         * html/shadow/MediaControlsApple.h: Removed.
850
851 2017-03-30  Fujii Hironori  <Hironori.Fujii@sony.com>
852
853         [WinCairo] ImageCairoWin.cpp: error C2660: 'WebCore::BitmapImage::draw': function does not take 6 arguments
854         https://bugs.webkit.org/show_bug.cgi?id=170275
855
856         Reviewed by Said Abou-Hallawa.
857
858         Apply the similar change of ImageCGWin.cpp of r214450 to ImageCairoWin.cpp.
859
860         * platform/graphics/win/ImageCairoWin.cpp:
861         (WebCore::BitmapImage::getHBITMAPOfSize): Pass DecodingMode::Synchronous to Image::draw().
862         (WebCore::BitmapImage::drawFrameMatchingSourceSize): Ditto.
863
864 2017-03-27  Sergio Villar Senin  <svillar@igalia.com>
865
866         [css-grid] Clamp the number of autorepeat tracks
867         https://bugs.webkit.org/show_bug.cgi?id=170120
868
869         Reviewed by Manuel Rego Casasnovas.
870
871         As suggested by the specs we do clamp the maximum number of tracks per grid in order to
872         minimize potential OOM situations. However we were not considering the case of the recently
873         added auto repeat syntax. Abnormally huge values for the width/height on the grid container
874         could lead to a number of auto repeat tracks higher than the maximum.
875
876         A new API was added to Internals in order to test limits without having to create huge
877         grids. This new API allows clients to set an arbitrary limit to the number of tracks. The
878         addition of this new API forced us to add GridPosition.cpp to the project to define the
879         global variable we use for testing. We took the chance to move part of the implementation
880         from the header file to the source file.
881
882         Last but not least, several new ASSERTs were added to Grid.cpp implementation to ensure that
883         we do not surpass the grid track limits.
884
885         Test: fast/css-grid-layout/grid-auto-repeat-huge-grid.html
886
887         * CMakeLists.txt:
888         * WebCore.xcodeproj/project.pbxproj:
889         * css/parser/CSSPropertyParser.cpp:
890         (WebCore::consumeGridTrackRepeatFunction):
891         * rendering/Grid.cpp:
892         (WebCore::Grid::ensureGridSize): Added ASSERT.
893         (WebCore::Grid::setSmallestTracksStart): Ditto.
894         (WebCore::Grid::setAutoRepeatTracks): Ditto.
895         (WebCore::Grid::setAutoRepeatEmptyColumns): Ditto.
896         (WebCore::Grid::setAutoRepeatEmptyRows): Ditto.
897         * rendering/RenderGrid.cpp:
898         (WebCore::RenderGrid::clampAutoRepeatTracks): New method.
899         (WebCore::RenderGrid::placeItemsOnGrid): Clamp the number of auto repeat tracks before
900         passing them to the Grid.
901         * rendering/RenderGrid.h:
902         * rendering/style/GridArea.h:
903         (WebCore::GridSpan::GridSpan):
904         * rendering/style/GridPosition.cpp: Added.
905         (WebCore::GridPosition::setExplicitPosition):
906         (WebCore::GridPosition::setAutoPosition):
907         (WebCore::GridPosition::setSpanPosition):
908         (WebCore::GridPosition::setNamedGridArea):
909         (WebCore::GridPosition::integerPosition):
910         (WebCore::GridPosition::namedGridLine):
911         (WebCore::GridPosition::spanPosition):
912         (WebCore::GridPosition::operator==):
913         * rendering/style/GridPosition.h:
914         (WebCore::GridPosition::shouldBeResolvedAgainstOppositePosition):
915         (WebCore::GridPosition::max):
916         (WebCore::GridPosition::min):
917         (WebCore::GridPosition::setMaxPositionForTesting):
918         (WebCore::GridPosition::setExplicitPosition): Deleted.
919         (WebCore::GridPosition::setAutoPosition): Deleted.
920         (WebCore::GridPosition::setSpanPosition): Deleted.
921         (WebCore::GridPosition::setNamedGridArea): Deleted.
922         (WebCore::GridPosition::integerPosition): Deleted.
923         (WebCore::GridPosition::namedGridLine): Deleted.
924         (WebCore::GridPosition::spanPosition): Deleted.
925         (WebCore::GridPosition::operator==): Deleted.
926         * rendering/style/GridPositionsResolver.cpp:
927         (WebCore::GridPositionsResolver::explicitGridColumnCount):
928         (WebCore::GridPositionsResolver::explicitGridRowCount):
929         * testing/Internals.cpp:
930         (WebCore::Internals::setGridMaxTracksLimit):
931         * testing/Internals.h:
932         * testing/Internals.idl:
933
934 2017-03-29  Ryosuke Niwa  <rniwa@webkit.org>
935
936         Disconnecting a HTMLObjectElement does not always unload its content document
937         https://bugs.webkit.org/show_bug.cgi?id=169606
938
939         Reviewed by Andy Estes.
940
941         When removing a node, we first disconnect all subframes then update the focused element as we remove each child.
942         However, when the removed element is a focused object element with a content document, removeFocusedNodeOfSubtree
943         can update the style tree synchronously inside Document::setFocusedElement, and reload the document.
944
945         Avoid this by instantiating a SubframeLoadingDisabler on the parent of the focused element.
946
947         Test: fast/dom/removing-focused-object-element.html
948
949         * dom/Document.cpp:
950         (WebCore::Document::removeFocusedNodeOfSubtree):
951
952 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
953
954         Migrate to kCTFontCSSWidthAttribute
955         https://bugs.webkit.org/show_bug.cgi?id=170265
956
957         Reviewed by Darin Adler.
958
959         Previously, we were mapping from Core Text widths to CSS widths in WebKit.
960         However, on some OSes, Core Text can directly tell us what the CSS width
961         value is.
962
963         No new tests because there is no behavior change.
964
965         * platform/graphics/cocoa/FontCacheCoreText.cpp:
966         (WebCore::getCSSAttribute):
967         (WebCore::capabilitiesForFontDescriptor):
968         * platform/spi/cocoa/CoreTextSPI.h:
969
970 2017-03-28  Simon Fraser  <simon.fraser@apple.com>
971
972         Make it possible to dump touch event regions for testing
973         https://bugs.webkit.org/show_bug.cgi?id=170209
974         <rdar://problem/31309258>
975
976         Reviewed by Tim Horton.
977
978         Expose internals.touchEventRectsForEvent() and internals.passiveTouchEventListenerRects(), which
979         fetch data via Page.
980
981         Because the regions are normally updated on a timer, we have to force an eager update via Document::updateTouchEventRegions().
982
983         Test: fast/events/touch/ios/touch-event-regions.html
984
985         * page/Page.cpp:
986         (WebCore::Page::nonFastScrollableRects):
987         (WebCore::Page::touchEventRectsForEvent):
988         (WebCore::Page::passiveTouchEventListenerRects):
989         * page/Page.h:
990         * testing/Internals.cpp:
991         (WebCore::Internals::touchEventRectsForEvent):
992         (WebCore::Internals::passiveTouchEventListenerRects):
993         * testing/Internals.h:
994         * testing/Internals.idl:
995
996 2017-03-29  Zalan Bujtas  <zalan@apple.com>
997
998         RenderBlockFlow::addFloatsToNewParent should check if float is already added to the object list.
999         https://bugs.webkit.org/show_bug.cgi?id=170259
1000         <rdar://problem/31300584>
1001
1002         Reviewed by Simon Fraser.
1003
1004         r210145 assumed that m_floatingObjects would simply ignore the floating box if it was already in the list.  
1005
1006         Test: fast/block/float/placing-multiple-floats-crash.html
1007
1008         * rendering/RenderBlockFlow.cpp:
1009         (WebCore::RenderBlockFlow::addFloatsToNewParent):
1010
1011 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
1012
1013         Try to normalize variation ranges
1014         https://bugs.webkit.org/show_bug.cgi?id=170119
1015
1016         Unreviewed.
1017
1018         Addressing post-review comment.
1019
1020         * platform/graphics/cocoa/FontCacheCoreText.cpp:
1021         (WebCore::isGXVariableFont):
1022
1023 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
1024
1025         Try to normalize variation ranges
1026         https://bugs.webkit.org/show_bug.cgi?id=170119
1027
1028         Reviewed by Simon Fraser.
1029
1030         TrueType GX-style variation fonts use one particular scale for values on their
1031         weight/width/slope axes - usually the values lie between -1 and 1 on that scale.
1032         However, OpenType 1.8-style fonts use the CSS scale for values on these axes.
1033         For the purposes of font selection, these values need to lie on the same scale.
1034         However, when font selection is completed and the variation values are actually
1035         being applied to the fonts, values which lie on the font's actual scale need to
1036         be applied. This patch adds normalize*() and denormalize*() functions to perform
1037         both of these operations. 
1038
1039         The conversion itself between the two scales isn't an exact mapping. Mapping
1040         slope is just a linear relationship with 0deg <=> 0 and 20deg <=> 1 (as per the
1041         CSS Fonts spec). Mapping widths is similar, it uses a 2-component piecewise
1042         linear relationship which includes the values given in the Microsoft OpenType
1043         spec for the OS/2 table's usWidthClass field. Weights are more difficult, so I
1044         plotted the CSS weights and the GX-style weights for every style of San
1045         Francisco, saw that the relationship appears to be linear, and ran a linear
1046         regression to compute the line equation.
1047
1048         As for the actual discrimination of determining whether a font is a GX-style
1049         font or not, we can use the presence of the 'STAT' table. This table didn't
1050         exist when GX fonts were being created, and OpenType 1.8 variable fonts are
1051         required to have this table.
1052
1053         Facebook uses the string ".SFNSText" in their @font-face blocks. This font is
1054         a variation font, but uses the GX-style values. Facebook asks us to create
1055         this font with a weight of 700, and because the values in the font are around
1056         1.0, we were erroneously thinking that the font wasn't bold, so we were then
1057         applying synthetic bold. This was causing text on facebook to look fuzzy and
1058         ugly.
1059
1060         Test: fast/text/variations/font-selection-properties-expected.html
1061
1062         * platform/graphics/cocoa/FontCacheCoreText.cpp:
1063         (WebCore::isGXVariableFont):
1064         (WebCore::normalizeWeight):
1065         (WebCore::normalizeSlope):
1066         (WebCore::denormalizeWeight):
1067         (WebCore::denormalizeWidth):
1068         (WebCore::denormalizeSlope):
1069         (WebCore::normalizeWidth):
1070         (WebCore::preparePlatformFont): Instead of using FontSelectionValues for the
1071         intermediate values, we should use floats instead. This is because
1072         FontSelectionValues are fixed-point numbers with the denominator having 2 bits.
1073         When using this data type to represent values on the GX scale, which are usually
1074         between 0 and 1, you lose a lot of fidelity. Instead, our intermediate
1075         calculations should be done with floats, and converted to FontSelectionValues at
1076         the end when they are representative of values on the CSS scale.
1077         (WebCore::stretchFromCoreTextTraits):
1078         (WebCore::fontWeightFromCoreText):
1079         (WebCore::extractVariationBounds):
1080         (WebCore::variationCapabilitiesForFontDescriptor):
1081         (WebCore::capabilitiesForFontDescriptor):
1082
1083 2017-03-29  Saam Barati  <sbarati@apple.com>
1084
1085         LinkBuffer and ExecutableAllocator shouldn't have anything to do with VM
1086         https://bugs.webkit.org/show_bug.cgi?id=170210
1087
1088         Reviewed by Mark Lam.
1089
1090         * cssjit/SelectorCompiler.cpp:
1091         (WebCore::SelectorCompiler::compileSelector):
1092         (WebCore::SelectorCompiler::SelectorCodeGenerator::compile):
1093
1094 2017-03-29  Javier Fernandez  <jfernandez@igalia.com>
1095
1096         [css-align] Adapt self-alignment properties to the new baseline syntax
1097         https://bugs.webkit.org/show_bug.cgi?id=170235
1098
1099         Reviewed by David Hyatt.
1100
1101         The baseline-position syntax has changed recently, so we need to update
1102         the CSS properties using the old syntax. This patch address only the
1103         self-alignment (align-self and justify-self) and default-alignment
1104         (align-items and justify-items).
1105
1106         The content-distribution properties (align-content and justify-content)
1107         will be updated in a follow up patch.
1108
1109         The new baseline syntax is "[first | last ]? baseline" which implies
1110         modifying the parsing and computed value logic.
1111
1112         There are several layout tests affected by this change, so I'll update
1113         them accordingly.
1114
1115         No new tests, just added/modified some cases to the tests we already have using the new baseline values.
1116
1117         * css/CSSComputedStyleDeclaration.cpp:
1118         (WebCore::valueForItemPositionWithOverflowAlignment):
1119         * css/CSSValueKeywords.in:
1120         * css/StyleBuilderConverter.h:
1121         (WebCore::StyleBuilderConverter::convertSelfOrDefaultAlignmentData):
1122         * css/parser/CSSPropertyParser.cpp:
1123         (WebCore::consumeBaselineKeyword):
1124         (WebCore::consumeSelfPositionOverflowPosition):
1125
1126 2017-03-29  Chris Dumez  <cdumez@apple.com>
1127
1128         Animated SVG images are not paused in pages loaded in the background
1129         https://bugs.webkit.org/show_bug.cgi?id=170043
1130         <rdar://problem/31234412>
1131
1132         Reviewed by Simon Fraser.
1133
1134         Animated SVG images are not paused in pages loaded in the background. We rely
1135         on FrameView::isOffscreen() to stop images animations in background tab (See
1136         logic in RenderElement's shouldRepaintForImageAnimation()). This works fine
1137         if a tab is visble and then becomes hidden (i.e. by switching to another
1138         tab). However, in the case where the tab gets loaded while in the background
1139         (e.g. opening link in new background tab, or session restore), then the
1140         animations would not be paused, due to FrameView::isOffscreen() erroneously
1141         returning false in this case.
1142
1143         Normally, the following chain of events happens:
1144         - Page is visible, we construct a main frame and its FrameView for loading
1145           the page. When a FrameView is constructed, we call FrameView::show() to
1146           make it visible. Then, if the page becomes non-visible, we call
1147           Page::setIsVisibleInternal(false) which calls FrameView::hide(). After
1148           that, FrameView::isOffscreen() correctly returns true because we properly
1149           called FrameView::hide().
1150
1151         However, when doing a load while the Page is hidden, the following was
1152         happening:
1153         - Page is not visible, we call Page::setIsVisibleInternal(false) which tries
1154           to call FrameView::hide() for the main frame but it does not have a FrameView
1155           yet (because the load has not started). We start the load and end up creating
1156           a FrameView. The FrameView constructor was calling FrameView::show()
1157           unconditionally, thus making the FrameView think is visible, even though its
1158           page isn't. At this point, FrameView::isOffscreen() was returning false
1159           and animations would keep running, even though the page is not visible.
1160
1161         To address the issue, we now call FrameView::show() in FrameView::create() only
1162         if the Page is actually visible, instead of calling it unconditionally. If the
1163         page ever becomes visible, Page::setIsVisibleInternal(true) will be called and
1164         it will take care of calling FrameView::show() then.
1165
1166         Tests: svg/animations/animations-paused-in-background-page-iframe.html
1167                svg/animations/animations-paused-in-background-page.html
1168
1169         * page/FrameView.cpp:
1170         (WebCore::FrameView::create):
1171
1172 2017-03-29  Wenson Hsieh  <wenson_hsieh@apple.com>
1173
1174         Links with empty hrefs should not be drag sources
1175         https://bugs.webkit.org/show_bug.cgi?id=170241
1176         <rdar://problem/31305505>
1177
1178         Reviewed by Tim Horton.
1179
1180         The m_dragSouceAction member of DragController represents the drag source actions that are available to the
1181         document, rather than the available actions given the dragging element. Thus, it is not correct to only check
1182         that (m_dragSourceAction & DragSourceActionAttachment) before proceeding down the attachment dragging codepath.
1183         This should be additionally guarded with a check that the element being dragged is, in fact, an attachment
1184         element.
1185
1186         New API test (see Tools/ChangeLog).
1187
1188         * page/DragController.cpp:
1189         (WebCore::DragController::startDrag):
1190
1191 2017-03-29  Jeremy Jones  <jeremyj@apple.com>
1192
1193         WebVideoFullscreenInterfaceAVKit needs a strong self ref before dispatching to the main thread.
1194         https://bugs.webkit.org/show_bug.cgi?id=170129
1195
1196         Reviewed by David Kilzer.
1197
1198         No new tests becuase no new behavior.
1199
1200         Hold a strong reference to WebVideoFullscreenInterfaceAVKit when dispatching to the main thread.
1201         Make WebVideoFullscreenInterfaceAVKit safe to retain from non-main thread.
1202
1203         * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
1204         * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
1205         (WebVideoFullscreenInterfaceAVKit::exitFullscreen):
1206
1207 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
1208
1209         [GCrypt] Add a Handle<> class to help with GCrypt object lifetime control
1210         https://bugs.webkit.org/show_bug.cgi?id=170238
1211
1212         Reviewed by Michael Catanzaro.
1213
1214         The platform-specific CryptoAlgorithmHMAC implementation is modified
1215         to showcase the GCrypt::Handle<> use. HandleDeleter<gcry_mac_hd_t>
1216         is added accordingly.
1217
1218         * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
1219         (WebCore::calculateSignature):
1220
1221 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
1222
1223         Variation fonts: Make sure that feature detection and preprocessor macros are right
1224         https://bugs.webkit.org/show_bug.cgi?id=169518
1225
1226         Reviewed by Simon Fraser.
1227
1228         When I added variable fonts support, I made all OSes parse the newly accepted values,
1229         instead of just the OSes which support variable fonts.
1230
1231         Test: fast/text/font-variations-feature-detection.html
1232
1233         * css/parser/CSSPropertyParser.cpp:
1234         (WebCore::consumeFontStretch):
1235         (WebCore::consumeFontStyle):
1236         * css/parser/CSSPropertyParserHelpers.cpp:
1237         (WebCore::CSSPropertyParserHelpers::divisibleBy100):
1238         (WebCore::CSSPropertyParserHelpers::consumeFontWeightNumber):
1239
1240 2017-03-29  Antoine Quint  <graouts@apple.com>
1241
1242         [Modern Media Controls] Controls bar may disappear while captions menu is visible (redux)
1243         https://bugs.webkit.org/show_bug.cgi?id=170239
1244         <rdar://problem/31320685>
1245
1246         Reviewed by Dean Jackson.
1247
1248         We did some work in webkit.org/b/168751 to prevent the controls bar from disappearing while the
1249         captions menu is visible. But there were two cases where the behavior was not as intended:
1250
1251             1. the controls bar would hide upon exiting the video.
1252             2. clicking on the controls bar while the caption panel is up would hide the controls bar
1253                as well as the captions panel.
1254
1255         Instead of determining that the "userInteractionEnabled" property being set to "false" is indicative
1256         of secondary UI, such as the tracks panel, being attached to the controls bar, we now have an
1257         explicit property to specify this. Now, when "hasSecondaryUIAttached" is "true", we prevent the
1258         controls bar from fading when exiting the media.
1259
1260         Additionally, when dismissing the tracks panel, we check whether a mouse event lead to this and check
1261         if the mouse was positioned over the controls bar. If that is the case, we no longer hide the controls
1262         bar and only dismiss the tracks panel.
1263
1264         Test: media/modern-media-controls/tracks-panel/tracks-panel-controls-bar-remains-visible-after-clicking-over-it.html
1265
1266         * Modules/modern-media-controls/controls/controls-bar.js:
1267         (ControlsBar.prototype.set userInteractionEnabled):
1268         (ControlsBar.prototype.handleEvent):
1269         (ControlsBar.prototype._autoHideTimerFired):
1270         * Modules/modern-media-controls/controls/macos-media-controls.js:
1271         (MacOSMediaControls.prototype.showTracksPanel):
1272         (MacOSMediaControls.prototype.hideTracksPanel):
1273
1274 2017-03-29  Antoine Quint  <graouts@apple.com>
1275
1276         [Modern Media Controls] Volume slider is initially empty
1277         https://bugs.webkit.org/show_bug.cgi?id=170237
1278         <rdar://problem/31319077>
1279
1280         Reviewed by Dean Jackson.
1281
1282         Fixing fallout from https://bugs.webkit.org/show_bug.cgi?id=167935 where we changed the behavior
1283         of layout() to happen prior to a commit. In this one instance, we were overriding layout() to run
1284         after a commit, so we now override commit(). Otherwise, the <canvas> that we draw the volume slider
1285         into would have its "width" and "height" properties set after we drew, which would clear the <canvas>.
1286
1287         * Modules/modern-media-controls/controls/slider.js:
1288         (Slider.prototype.commit):
1289         (Slider.prototype.layout): Deleted.
1290
1291 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
1292
1293         [GCrypt] Move over empty GnuTLS-based SUBTLE_CRYPTO implementation files
1294         https://bugs.webkit.org/show_bug.cgi?id=170232
1295
1296         Reviewed by Michael Catanzaro.
1297
1298         Migrate the GnuTLS SUBTLE_CRYPTO implementation files to the gcrypt/
1299         directory. The implementation files themselves are no-op, so this is
1300         a simple move-and-rename operation that will enable proceeding with
1301         the libgcrypt-based implementation of SUBTLE_CRYPTO functionality.
1302
1303         No change in behavior. The SUBTLE_CRYPTO feature should build as it
1304         did before, and the implementations are empty anyway.
1305
1306         * PlatformGTK.cmake:
1307         * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp.
1308         * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CFBGnuTLS.cpp.
1309         * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_GCMGnuTLS.cpp.
1310         * crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_KWGnuTLS.cpp.
1311         * crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmECDHGnuTLS.cpp.
1312         * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmPBKDF2GnuTLS.cpp.
1313         * crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp.
1314         * crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp: This one already exists.
1315         * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp.
1316         * crypto/gcrypt/CryptoAlgorithmRegistryGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRegistryGnuTLS.cpp.
1317         * crypto/gcrypt/CryptoKeyECGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp.
1318         * crypto/gcrypt/CryptoKeyRSAGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp.
1319         * crypto/gcrypt/SerializedCryptoKeyWrapGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/SerializedCryptoKeyWrapGnuTLS.cpp.
1320         * crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp: Removed.
1321
1322 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
1323
1324         [GnuTLS] Remove unused CryptoDigestGnuTLS, CryptoAlgorithmHMACGnuTLS implementation files
1325         https://bugs.webkit.org/show_bug.cgi?id=170231
1326
1327         Reviewed by Michael Catanzaro.
1328
1329         * crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp: Removed. The GCrypt counterpart
1330         is already in use, and this file wasn't even being built.
1331
1332 2017-03-29  Youenn Fablet  <youenn@apple.com>
1333
1334         Move DTMF WebRTC extension behind its own compile flag
1335         https://bugs.webkit.org/show_bug.cgi?id=170226
1336
1337         Reviewed by Eric Carlson.
1338
1339         Moving RTCDTMFSender and RTCDTMFToneChangeEvent behinf a WEB_RTC_DTMF compile flag.
1340         This compile flag is not set on any supported platform yet.
1341         Disabling related test and updated test expectations.
1342
1343         * Modules/mediastream/RTCDTMFSender.cpp:
1344         * Modules/mediastream/RTCDTMFSender.h:
1345         * Modules/mediastream/RTCDTMFSender.idl:
1346         * Modules/mediastream/RTCDTMFToneChangeEvent.cpp:
1347         * Modules/mediastream/RTCDTMFToneChangeEvent.h:
1348         * Modules/mediastream/RTCDTMFToneChangeEvent.idl:
1349         * dom/EventNames.in:
1350         * dom/EventTargetFactory.in:
1351         * platform/mediastream/RTCDTMFSenderHandler.h:
1352         * platform/mediastream/RTCDTMFSenderHandlerClient.h:
1353
1354 2017-03-29  Antoine Quint  <graouts@apple.com>
1355
1356         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
1357         https://bugs.webkit.org/show_bug.cgi?id=168409
1358         <rdar://problem/30799198>
1359
1360         Reviewed by Dean Jackson.
1361
1362         Add a new internals setting to opt into ScriptedAnimationController logging through DOM events dispatched
1363         through the document. This should allow this flaky test to get information as to why the frame isn't
1364         firing when it times out.
1365
1366         * dom/ScriptedAnimationController.cpp:
1367         (WebCore::ScriptedAnimationController::suspend):
1368         (WebCore::ScriptedAnimationController::resume):
1369         (WebCore::ScriptedAnimationController::addThrottlingReason):
1370         (WebCore::ScriptedAnimationController::removeThrottlingReason):
1371         (WebCore::ScriptedAnimationController::registerCallback):
1372         (WebCore::ScriptedAnimationController::cancelCallback):
1373         (WebCore::ScriptedAnimationController::serviceScriptedAnimations):
1374         (WebCore::ScriptedAnimationController::scheduleAnimation):
1375         (WebCore::ScriptedAnimationController::dispatchLoggingEventIfRequired):
1376         * dom/ScriptedAnimationController.h:
1377         * page/Settings.in:
1378         * testing/InternalSettings.cpp:
1379         (WebCore::InternalSettings::resetToConsistentState):
1380         (WebCore::InternalSettings::shouldDispatchRequestAnimationFrameEvents):
1381         (WebCore::InternalSettings::setShouldDispatchRequestAnimationFrameEvents):
1382         * testing/InternalSettings.h:
1383         * testing/InternalSettings.idl:
1384
1385 2017-03-28  Youenn Fablet  <youenn@apple.com>
1386
1387         [WebRTC] After r214441 addIceCandidate no longer accepts an RTCIceCandidateInit dictionary
1388         https://bugs.webkit.org/show_bug.cgi?id=170192
1389
1390         Reviewed by Jon Lee.
1391
1392         Covered by updated tests.
1393
1394         * Modules/mediastream/RTCIceCandidate.idl: Candidate is no longer a required field in RTCIceCandidateInit.
1395         * Modules/mediastream/RTCPeerConnectionInternals.js: Reworking defaultsToNull to handle both undefined and null cases.
1396
1397 2017-03-28  Youenn Fablet  <youenn@apple.com>
1398
1399         LibWebRTCProvider should allow setting encoder and decoder factories
1400         https://bugs.webkit.org/show_bug.cgi?id=170212
1401
1402         Reviewed by Eric Carlson.
1403
1404         No change of behavior.
1405         Adding the ability to set encoder/decoder libwebrtc factory getters.
1406         Setting default cocoa factory getters.
1407
1408         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
1409         (WebCore::staticFactoryAndThreads):
1410         (WebCore::initializePeerConnectionFactoryAndThreads):
1411         (WebCore::LibWebRTCProvider::setDecoderFactoryGetter):
1412         (WebCore::LibWebRTCProvider::setEncoderFactoryGetter):
1413         (WebCore::LibWebRTCProvider::setPeerConnectionFactory):
1414         * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
1415
1416 2017-03-27  Brent Fulgham  <bfulgham@apple.com>
1417
1418         Only attach Attributes to a given element one time
1419         https://bugs.webkit.org/show_bug.cgi?id=170125
1420         <rdar://problem/31279676>
1421
1422         Reviewed by Chris Dumez.
1423
1424         Attach the attribute node to the Element before calling 'setAttributeInternal', since that method may cause
1425         arbitrary JavaScript events to fire. 
1426
1427         Test: fast/dom/Attr/only-attach-attr-once.html
1428
1429         * dom/Element.cpp:
1430         (WebCore::Element::attachAttributeNodeIfNeeded): Added.
1431         (WebCore::Element::setAttributeNode): Use new method. Revise to attach attribute before calling 'setAttributeInternal'. 
1432         (WebCore::Element::setAttributeNodeNS): Ditto.
1433         * dom/Element.h:
1434
1435 2017-03-28  Youenn Fablet  <youenn@apple.com>
1436
1437         Stop RTCDataChannel when closing page
1438         https://bugs.webkit.org/show_bug.cgi?id=170166
1439
1440         Reviewed by Eric Carlson.
1441
1442         Test: webrtc/datachannel/datachannel-gc.html
1443
1444         Making RTCDataChannel an ActiveDOMObject.
1445         Closing the data channel backend and freeing upon close and stop.
1446
1447         * Modules/mediastream/RTCDataChannel.cpp:
1448         (WebCore::RTCDataChannel::create):
1449         (WebCore::RTCDataChannel::RTCDataChannel):
1450         (WebCore::RTCDataChannel::close):
1451         (WebCore::RTCDataChannel::stop):
1452         * Modules/mediastream/RTCDataChannel.h:
1453         * Modules/mediastream/RTCDataChannel.idl:
1454         * Modules/mediastream/RTCPeerConnection.h:
1455
1456 2017-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
1457
1458         Ranges for variation font properties are not enforced
1459         https://bugs.webkit.org/show_bug.cgi?id=169979
1460
1461         Reviewed by David Hyatt.
1462
1463         The spec specifies that:
1464         - Font weights less than or equal to 0, or greater than or equal to 1000 are parse errors
1465         - Font stretch values less than or equal to 0% are parse errors
1466         - Font style values less than or equal to -90deg or greater than or equal to 90deg are parse errors
1467
1468         Test: fast/text/variations/out-of-bounds-selection-properties.html
1469
1470         * css/parser/CSSPropertyParser.cpp:
1471         (WebCore::consumeFontWeightRange):
1472         (WebCore::fontStretchIsWithinRange):
1473         (WebCore::consumeFontStretch):
1474         (WebCore::consumeFontStretchRange):
1475         (WebCore::fontStyleIsWithinRange):
1476         (WebCore::consumeFontStyle):
1477         (WebCore::consumeFontStyleRange):
1478
1479 2017-03-28  Andy Estes  <aestes@apple.com>
1480
1481         [iOS] Crash in -[WebPreviewLoader failed] when running http/tests/multipart/policy-ignore-crash.php
1482         https://bugs.webkit.org/show_bug.cgi?id=170197
1483         <rdar://problem/30314067>
1484
1485         Reviewed by Brady Eidson.
1486
1487         If QuickLook conversion fails, we call ResourceLoader::didFail() with the NSError from
1488         QuickLook, which will call back into PreviewLoader::didFail(). We only care about network
1489         failures in PreviewLoader, not conversion failures, so check if
1490         m_finishedLoadingDataIntoConverter is set before continuing (like we do in
1491         PreviewLoader::didFinishLoading()).
1492
1493         Fixes crash in http/tests/multipart/policy-ignore-crash.php.
1494
1495         * loader/ios/PreviewLoader.mm:
1496         (WebCore::PreviewLoader::didFail):
1497
1498 2017-03-28  Chris Dumez  <cdumez@apple.com>
1499
1500         Audio indicator is visible on uni-watch.com but there is no audible audio
1501         https://bugs.webkit.org/show_bug.cgi?id=170200
1502         <rdar://problem/31289132>
1503
1504         Reviewed by Eric Carlson.
1505
1506         Cherry-pick the following patch from Blink by <rtoy@chromium.org>:
1507         - https://chromium.googlesource.com/chromium/src.git/+/439de5bb2a31384666db1a0e2dadb2b97d2f3ce4
1508
1509         When the gain of a GainNode is 0 or 1, the operation of the node can
1510         be optimized.  When gain = 1, just copy the input to the output.  When
1511         gain = 0; just zero out the output.  Currently, the input is
1512         multiplied by the gain to produce the output.  This just optimizes the
1513         multiplication away for the two special cases.
1514
1515         Also, have the GainNode set the silence hint if the gain is 0.
1516
1517         And fix a bug in processIfNecessary when unsilenceOutputs was causing the
1518         silence hint to be cleared after the node's process method was finished
1519         and may have set the silence hint.  The processing should come after
1520         unsilenceOutputs to preserve any hints from processing the node.
1521
1522         * Modules/webaudio/AudioNode.cpp:
1523         (WebCore::AudioNode::processIfNecessary):
1524         * Modules/webaudio/GainNode.cpp:
1525         (WebCore::GainNode::process):
1526         * platform/audio/AudioBus.cpp:
1527         (WebCore::AudioBus::copyWithGainFrom):
1528
1529 2017-03-28  Chris Dumez  <cdumez@apple.com>
1530
1531         Animated SVG images are not paused when outside viewport
1532         https://bugs.webkit.org/show_bug.cgi?id=170155
1533         <rdar://problem/31288893>
1534
1535         Reviewed by Antti Koivisto.
1536
1537         Make sure animated SVG images get paused when outside the viewport,
1538         similarly to what was already done for animated GIF images. Also
1539         make sure they are paused when they no longer have any renderers
1540         using them.
1541
1542         Tests: svg/animations/animated-svg-image-outside-viewport-paused.html
1543                svg/animations/animated-svg-image-removed-from-document-paused.html
1544
1545         * loader/cache/CachedImage.cpp:
1546         (WebCore::CachedImage::didAddClient):
1547         Restart the animation whenever a new CachedImage client is added. This
1548         will cause us the re-evaluate if the animation should run. The animation
1549         will pause again if the new renderer is not inside the viewport.
1550
1551         (WebCore::CachedImage::animationAdvanced):
1552         Add a flag to newImageAnimationFrameAvailable() so that the renderers can
1553         let us know if we can pause the animation. Pause the animation if all no
1554         renderer requires it (i.e. they are all outside the viewport, or there
1555         are no renderers).
1556
1557         * loader/cache/CachedImageClient.h:
1558         (WebCore::CachedImageClient::newImageAnimationFrameAvailable):
1559         By default, the CachedImageClients allow pausing. Only renderer will
1560         potentially prevent pausing if they are inside the viewport.
1561
1562         * platform/graphics/BitmapImage.cpp:
1563         (WebCore::BitmapImage::isAnimating):
1564         * platform/graphics/BitmapImage.h:
1565         * platform/graphics/Image.h:
1566         (WebCore::Image::isAnimating):
1567         Add isAnimating() flag on Image for layout testing purposes.
1568
1569         * rendering/RenderElement.cpp:
1570         (WebCore::RenderElement::newImageAnimationFrameAvailable):
1571         Set canPause flag to true if the renderer is not inside the viewport.
1572
1573         (WebCore::RenderElement::repaintForPausedImageAnimationsIfNeeded):
1574         Call startAnimation() if the renderer is now visible to resume SVG
1575         animations. Repainting is enough for GIF animations but not for SVG
1576         animations, we have to explicitly resume them.
1577
1578         * rendering/RenderElement.h:
1579         * rendering/RenderView.cpp:
1580         (WebCore::RenderView::addRendererWithPausedImageAnimations):
1581         (WebCore::RenderView::removeRendererWithPausedImageAnimations):
1582         (WebCore::RenderView::resumePausedImageAnimationsIfNeeded):
1583         * rendering/RenderView.h:
1584         Store CachedImages with the renderers that have paused animations.
1585         This is required for SVG where we need to explicitly resume the
1586         animation on the CachedImage when the renderer becomes visible
1587         again. Having access to the Image will also allow us to do smarter
1588         visibility checks in RenderElement's shouldRepaintForImageAnimation(),
1589         in the future.
1590
1591         * svg/SVGSVGElement.cpp:
1592         (WebCore::SVGSVGElement::hasActiveAnimation):
1593         * svg/SVGSVGElement.h:
1594         Add hasActiveAnimation() method.
1595
1596         * svg/graphics/SVGImage.cpp:
1597         (WebCore::SVGImage::startAnimation):
1598         Check that animations are paused before starting them. This avoid
1599         jumping due to unnecessary calls to rootElement->setCurrentTime(0).
1600
1601         (WebCore::SVGImage::isAnimating):
1602         Add isAnimating() method for layout tests purposes.
1603
1604         * svg/graphics/SVGImage.h:
1605         * svg/graphics/SVGImageClients.h:
1606         Call animationAdvanced() on the observer instead of the generic
1607         changedInRect() when the SVGImage is animating. This way, we go
1608         through the same code path as GIF animations and we end up calling
1609         CachedImage::animationAdvanced() which calls newImageAnimationFrameAvailable()
1610         on RenderElement, which determines if the animation should keep
1611         running or not.
1612
1613         * testing/Internals.cpp:
1614         (WebCore::Internals::isImageAnimating):
1615         * testing/Internals.h:
1616         * testing/Internals.idl:
1617         Add layout testing infrastructure.
1618
1619 2017-03-28  Antti Koivisto  <antti@apple.com>
1620
1621         Missing render tree position invalidation when tearing down renderers for display:contents subtree
1622         https://bugs.webkit.org/show_bug.cgi?id=170199
1623         <rdar://problem/31260856>
1624
1625         Reviewed by Zalan Bujtas.
1626
1627         Test: fast/shadow-dom/slot-renderer-teardown.html
1628
1629         * style/RenderTreeUpdater.cpp:
1630         (WebCore::RenderTreeUpdater::updateElementRenderer):
1631
1632             Invalidate the render tree position in case we do a teardown for an element without renderer.
1633
1634 2017-03-28  Ryan Haddad  <ryanhaddad@apple.com>
1635
1636         Unreviewed, rolling out r214485.
1637
1638         This change caused LayoutTest crashes.
1639
1640         Reverted changeset:
1641
1642         "Stop RTCDataChannel when closing page"
1643         https://bugs.webkit.org/show_bug.cgi?id=170166
1644         http://trac.webkit.org/changeset/214485
1645
1646 2017-03-28  Anders Carlsson  <andersca@apple.com>
1647
1648         ApplePayShippingContactUpdate.idl shouldn't have status field
1649         https://bugs.webkit.org/show_bug.cgi?id=170202
1650         rdar://problem/31307106
1651
1652         Reviewed by Beth Dakin.
1653
1654         * Modules/applepay/ApplePaySession.cpp:
1655         (WebCore::convertAndValidate):
1656         If status isn't set, infer it based on whether there are errors present or not.
1657
1658         * Modules/applepay/ApplePayShippingContactUpdate.h:
1659         Make status optional here; it's still used by the old code path.
1660
1661         * Modules/applepay/ApplePayShippingContactUpdate.idl:
1662         Remove status here.
1663
1664 2017-03-28  Brian Burg  <bburg@apple.com>
1665
1666         Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
1667         https://bugs.webkit.org/show_bug.cgi?id=169865
1668         <rdar://problem/31250573>
1669
1670         Reviewed by Joseph Pecoraro.
1671
1672         Rewrite the network agent's command for disabling resource caching to use Page::setResourceCachingEnabled.
1673         The old implementation was doing weird stuff like setting no-cache headers and evicting the
1674         contents of the memory cache, neither of which is correct. The new approach has no side effects
1675         on the network, disk, or memory cache so it can be turned on temporarily without causing problems.
1676
1677         New tests:
1678         - http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html
1679         - http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html
1680
1681         * inspector/InspectorNetworkAgent.h:
1682         * inspector/InspectorNetworkAgent.cpp:
1683         (WebCore::InspectorNetworkAgent::setCacheDisabled): Deleted.
1684         (WebCore::InspectorNetworkAgent::setResourceCachingDisabled): Added.
1685         Implement new command.
1686
1687         (WebCore::InspectorNetworkAgent::willSendRequest):
1688         (WebCore::InspectorNetworkAgent::mainFrameNavigated):
1689         Remove crufty attempts to break caches. I believe these are intended to defeat caching
1690         proxies and similar middlemen, but this is just as likely to cause unusual loading behavior.
1691
1692         * page/Page.h:
1693         (WebCore::Page::isResourceCachingDisabled):
1694         (WebCore::Page::setResourceCachingDisabledOverride):
1695         Add an override setting so that Web Inspector's override does not mess up the value
1696         of isResourceCachingDisabled that may have been set by a WebKit API client.
1697
1698 2017-03-28  Youenn Fablet  <youenn@apple.com>
1699
1700         Fix addIceCandidate after r214441
1701         https://bugs.webkit.org/show_bug.cgi?id=170146
1702
1703         Reviewed by Chris Dumez.
1704
1705         Covered by rebased test.
1706
1707         * Modules/mediastream/RTCPeerConnection.js:
1708         (addIceCandidate): Setting function length to 1 and throwing if no parameter is passed.
1709
1710 2017-03-28  Youenn Fablet  <youenn@apple.com>
1711
1712         Stop RTCDataChannel when closing page
1713         https://bugs.webkit.org/show_bug.cgi?id=170166
1714
1715         Reviewed by Eric Carlson.
1716
1717         Test: webrtc/datachannel/datachannel-gc.html
1718
1719         Making RTCDataChannel an ActiveDOMObject.
1720         Closing the data channel backend and freeing upon close and stop.
1721
1722         * Modules/mediastream/RTCDataChannel.cpp:
1723         (WebCore::RTCDataChannel::create):
1724         (WebCore::RTCDataChannel::RTCDataChannel):
1725         (WebCore::RTCDataChannel::close):
1726         (WebCore::RTCDataChannel::stop):
1727         * Modules/mediastream/RTCDataChannel.h:
1728         * Modules/mediastream/RTCDataChannel.idl:
1729         * Modules/mediastream/RTCPeerConnection.h:
1730
1731 2017-03-27  Simon Fraser  <simon.fraser@apple.com>
1732
1733         Enhance the touch region debug overlay to show regions for the different events
1734         https://bugs.webkit.org/show_bug.cgi?id=170162
1735
1736         Reviewed by Tim Horton.
1737
1738         Have NonFastScrollableRegionOverlay use a different color for each region in EventTrackingRegions,
1739         and to draw a legend showing what the colors mean.
1740         
1741         On Mac, this overlay displays the non-fast scrollable region (which we don't keep separate from the wheel event
1742         region).
1743
1744         * page/DebugPageOverlays.cpp:
1745         (WebCore::NonFastScrollableRegionOverlay::updateRegion):
1746         (WebCore::touchEventRegionColors):
1747         (WebCore::drawRightAlignedText):
1748         (WebCore::NonFastScrollableRegionOverlay::drawRect):
1749         (WebCore::RegionOverlay::drawRect):
1750         (WebCore::RegionOverlay::drawRegion):
1751
1752 2017-03-27  Simon Fraser  <simon.fraser@apple.com>
1753
1754         Make sure the non-fast scrolling debug overlay is correctly updated
1755         https://bugs.webkit.org/show_bug.cgi?id=170142
1756
1757         Reviewed by Tim Horton.
1758
1759         AsyncScrollingCoordinator::frameViewEventTrackingRegionsChanged() is called on a timer
1760         from Document code, so the existing DebugPageOverlays::didLayout() call at the end
1761         of FrameView::layout() wasn't sufficient to keep the non-fast scrollable region up-to-date
1762         on iOS.
1763
1764         * page/scrolling/AsyncScrollingCoordinator.cpp:
1765         (WebCore::AsyncScrollingCoordinator::frameViewEventTrackingRegionsChanged):
1766
1767 2017-03-28  Antoine Quint  <graouts@apple.com>
1768
1769         [Modern Media Controls] AirPlay placard text looks bad on 1x displays
1770         https://bugs.webkit.org/show_bug.cgi?id=170183
1771         <rdar://problem/30663416>
1772
1773         Reviewed by Dean Jackson.
1774
1775         Use subpixel antialiasing for all text in modern media controls.
1776
1777         * Modules/modern-media-controls/controls/media-controls.css:
1778         (.media-controls-container,):
1779
1780 2017-03-28  Antoine Quint  <graouts@apple.com>
1781
1782         [Modern Media Controls] Improve appearance of tracks panel on macOS
1783         https://bugs.webkit.org/show_bug.cgi?id=168929
1784         <rdar://problem/30741589>
1785
1786         Reviewed by Eric Carlson.
1787
1788         We use a solid color for the focus state that matches the style used on macOS
1789         and blend the titles the same way we blend other non-solid labels in the controls bar.
1790
1791         * Modules/modern-media-controls/controls/tracks-panel.css:
1792         (.tracks-panel section):
1793         (.tracks-panel section > h3):
1794         (.tracks-panel section > ul > li:focus):
1795
1796 2017-03-28  Yoav Weiss  <yoav@yoav.ws>
1797
1798         Add a warning for unused link preloads.
1799         https://bugs.webkit.org/show_bug.cgi?id=165670
1800
1801         Reviewed by Youenn Fablet.
1802
1803         Tests: http/tests/preload/single_download_preload_headers_charset.php
1804                http/tests/preload/unused_preload_warning.html
1805
1806         * dom/Document.cpp:
1807         (WebCore::Document::prepareForDestruction): Stop the timer once the document is destructed.
1808         * loader/LinkPreloadResourceClients.h: Add shouldMarkAsReferenced overides for the LinkPreloadResourceClient classes.
1809         * loader/cache/CachedResource.cpp:
1810         (WebCore::CachedResource::addClientToSet): Make sure LinkPreloadResourceClients don't set resource to be referenced.
1811         * loader/cache/CachedResourceClient.h:
1812         (WebCore::CachedResourceClient::shouldMarkAsReferenced): Make sure that ResourceClients mark preloads as referenced by default.
1813         * loader/cache/CachedResourceLoader.cpp:
1814         (WebCore::CachedResourceLoader::CachedResourceLoader): Initialize timer.
1815         (WebCore::CachedResourceLoader::~CachedResourceLoader): Stop timer.
1816         (WebCore::CachedResourceLoader::documentDidFinishLoadEvent): Trigger a timer if preloads weren't cleared at load time.
1817         (WebCore::CachedResourceLoader::stopUnusedPreloadsTimer): Stop the timer.
1818         (WebCore::CachedResourceLoader::warnUnusedPreloads): Iterate over m_preloads and issue a warning for non-referenced preloads.
1819         * loader/cache/CachedResourceLoader.h:
1820         * page/DOMWindow.cpp:
1821         (WebCore::DOMWindow::willDetachDocumentFromFrame): Clear Resource Timing buffer when document detaches, to avoid test flakiness.
1822
1823 2017-03-28  Antoine Quint  <graouts@apple.com>
1824
1825         REGRESSION: Double-clicking the captions button while the captions popover is open prevents the popover from being opened again
1826         https://bugs.webkit.org/show_bug.cgi?id=170171
1827         <rdar://problem/31095500>
1828
1829         Reviewed by Dean Jackson.
1830
1831         We used to consider that the tracks panel was presented as long as it had a parent, but since we were using for the animated
1832         transition to complete before actually removing the panel from the node hierarchy, consecutive calls to hide then present
1833         would fail to present the panel. We now use a private instance variable to track the presented state which is set immediately
1834         as presentInParent() and hide() are called.
1835
1836         Test: media/modern-media-controls/tracks-support/tracks-support-show-panel-then-double-click-on-tracks-button.html
1837
1838         * Modules/modern-media-controls/controls/tracks-panel.js:
1839         (TracksPanel.prototype.get presented):
1840         (TracksPanel.prototype.presentInParent):
1841         (TracksPanel.prototype.hide):
1842
1843 2017-03-28  Aaron Chu  <aaron_chu@apple.com>
1844
1845         AX: Media controls should be able to be re-activated after faded away
1846         https://bugs.webkit.org/show_bug.cgi?id=170048
1847         <rdar://problem/30157179>
1848
1849         Reviewed by Antoine Quint.
1850
1851         Added a "foucsin" listener for the controls bar so that when an element
1852         within fires a "focusin" event, the controls bar reappears if it is faded.
1853
1854         Test: media/modern-media-controls/media-controls/media-controls-appear-when-focus.html
1855
1856         * Modules/modern-media-controls/controls/controls-bar.js:
1857         (ControlsBar.prototype.handleEvent):
1858
1859 2017-03-28  Antoine Quint  <graouts@apple.com>
1860
1861         [Modern Media Controls] Improve media documents across macOS, iPhone and iPad
1862         https://bugs.webkit.org/show_bug.cgi?id=169145
1863         <rdar://problem/17048858>
1864
1865         Reviewed by Dean Jackson.
1866
1867         There were a variety of issues with media documents, some longstanding, and some specifically
1868         about modern media controls.
1869
1870         One issue was that fullscreen and picture-in-picture buttons would show for audio media documents,
1871         due to using a <video> element to load the audio file. We now have additional logic in MediaController
1872         to identify if the loaded media is really an audio file, and using this information to hide the
1873         fullscreen and picture-in-picture buttons.
1874
1875         Another issue was that we would inject style in MediaDocument.cpp that was specific to modern media
1876         controls when we could have the modern-media-controls module injected CSS handle this styling. We now
1877         use the injected style in the shadow root to size media documents based on the device characteristics
1878         and ensuring that page styles are overridden.
1879
1880         We also simplify how MediaDocument.cpp sets the source of the media element to simply use the "src"
1881         attribute and not a <source> element.
1882
1883         Finally, we introduce a MediaDocumentController class that is instantiated when we're dealing with
1884         a media document to hide the controls while we determine the type of media we're loading (audio vs.
1885         video) in order to apply the appropriate styling without flashes.
1886
1887         As a result of the new styles applied by the modern-media-controls module, media documents have a
1888         similar behavior on macOS and iPad, where we only enforce a min-width for video allowing them
1889         to play at their natural size otherwise, and enforcing a fixed width for audio. On iPhone however,
1890         we want to always play the media at full width, with some padding in the case of audio.
1891
1892         Tests: media/modern-media-controls/fullscreen-support/fullscreen-support-disabled-video-with-audio-tracks-only.html
1893                media/modern-media-controls/media-documents/ipad/media-document-audio-ios-sizing.html
1894                media/modern-media-controls/media-documents/ipad/media-document-video-ios-sizing.html
1895                media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html
1896                media/modern-media-controls/media-documents/media-document-audio-mac-sizing.html
1897                media/modern-media-controls/media-documents/media-document-video-ios-sizing.html
1898                media/modern-media-controls/media-documents/media-document-video-mac-sizing.html
1899                media/modern-media-controls/pip-support/pip-support-disabled-video-with-audio-tracks-only.html
1900
1901         * Modules/modern-media-controls/controls/ios-inline-media-controls.css:
1902         (:host(audio) .media-controls.ios.inline > .controls-bar:before,):
1903         (:host(audio) .media-controls.ios.inline > .controls-bar:before): Deleted.
1904         * Modules/modern-media-controls/controls/macos-media-controls.css:
1905         (:host(audio) .media-controls.mac.inline > .controls-bar,):
1906         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint,):
1907         (:host(audio) .media-controls.mac.inline > .controls-bar): Deleted.
1908         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint): Deleted.
1909         * Modules/modern-media-controls/controls/media-document.css: Copied from Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.css.
1910         (:host(.media-document)):
1911         (:host(.media-document.ready)):
1912         (:host(.media-document.audio.mac)):
1913         (:host(.media-document.audio.ipad)):
1914         (:host(.media-document.audio.iphone)):
1915         (:host(.media-document.video.mac)):
1916         (:host(.media-document.video.ipad)):
1917         (:host(.media-document.video.iphone)):
1918         * Modules/modern-media-controls/js-files:
1919         * Modules/modern-media-controls/media/fullscreen-support.js:
1920         (FullscreenSupport.prototype.syncControl):
1921         (FullscreenSupport):
1922         * Modules/modern-media-controls/media/media-controller.js:
1923         (MediaController):
1924         (MediaController.prototype.get isAudio):
1925         * Modules/modern-media-controls/media/media-document-controller.js: Copied from Source/WebCore/Modules/modern-media-controls/media/fullscreen-support.js.
1926         (MediaDocumentController):
1927         (MediaDocumentController.prototype.handleEvent):
1928         (MediaDocumentController.prototype._mediaDocumentHasMetadata):
1929         (MediaDocumentController.prototype._mediaDocumentHasSize):
1930         * Modules/modern-media-controls/media/pip-support.js:
1931         (PiPSupport.prototype.syncControl):
1932         (PiPSupport):
1933         * html/MediaDocument.cpp:
1934         (WebCore::MediaDocumentParser::createDocumentStructure):
1935
1936 2017-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
1937
1938         Follow-up patch after r214364.
1939         https://bugs.webkit.org/show_bug.cgi?id=168895
1940
1941         Unreviewed.
1942
1943         * platform/graphics/FontDescription.cpp:
1944         (WebCore::FontDescription::FontDescription):
1945
1946 2017-03-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
1947
1948         REGRESSION(213764): Large images should not be decoded asynchronously when they are drawn on a canvas
1949         https://bugs.webkit.org/show_bug.cgi?id=169771
1950
1951         Reviewed by Simon Fraser.
1952
1953         Sometimes we have to draw the image immediately like when a canvas calls  
1954         drawImage. In this case we have to decode the image synchronously to guarantee
1955         the drawing. Other times we need to decode with the native size of the image.
1956         The animated images have to be decoded with native size always. Otherwise
1957         the frame cache will be messed up if the same image is animated with different
1958         sizes. Currently we always decode asynchronously with sizeForDrawing. We need
1959         to decouple the decoding mode from the sizeForDrawing.
1960
1961         This patch introduce the DecodingOptions class which can store and compare the
1962         following four cases:
1963             -- Synchronous: The frame has be decoded with native size only.
1964             -- Asynchronous + anySize: This is passed from the Image::draw() callers.
1965             -- Asynchronous + fullSize: The image has to be decoded with its full size.
1966             -- Asynchronous + sizeForDrawing: The image can be decoded with sizeForDrawing unless
1967             it was decoded with either a full size or sizeForDrawing which is larger than the
1968             requested sizeForDrawing.
1969             
1970         A new argument of type DecodingMode will be added to Image::draw() function.
1971         Only when the drawing comes from the render tree, it will be Asynchronous.
1972         Otherwise it will be Synchronous.
1973
1974         Tests: fast/images/animated-image-different-dest-size.html
1975                fast/images/async-image-background-image.html
1976                fast/images/async-image-canvas-draw-image.html
1977
1978         * WebCore.xcodeproj/project.pbxproj:
1979         * platform/graphics/BitmapImage.cpp:
1980         (WebCore::BitmapImage::frameImageAtIndexCacheIfNeeded): Gets the frame image, cache it synchronously if
1981         the current one is invalid. frameImageAtIndex() returns whatever stored in the cache.
1982         (WebCore::BitmapImage::nativeImage): Call frameImageAtIndexCacheIfNeeded() instead of frameImageAtIndex().
1983         (WebCore::BitmapImage::nativeImageForCurrentFrame): Ditto.
1984         (WebCore::BitmapImage::nativeImageOfSize): Ditto.
1985         (WebCore::BitmapImage::framesNativeImages): Ditto.
1986         (WebCore::BitmapImage::draw): Change the logic to do the following:
1987         -- The animated image has to be decoded with its full size.
1988         -- The animated image expects the current frame to be ready for drawing.
1989         -- The large image decoding does not need to call internalStartAnimation().
1990         -- The large image has to request async image decoding but draw the current one if it exists.
1991         (WebCore::BitmapImage::drawPattern): Draw the pattern synchronously.
1992         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImages): Delete the call to shouldUseAsyncDecodingForTesting()
1993         since it is only applied for animated images.
1994         (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages): Call shouldUseAsyncDecodingForAnimatedImageForTesting().
1995         (WebCore::BitmapImage::internalStartAnimation): Request decoding with the full size.
1996         (WebCore::BitmapImage::advanceAnimation): Call shouldUseAsyncDecodingForAnimatedImageForTesting().
1997         (WebCore::BitmapImage::internalAdvanceAnimation): Assert the current frame is not being decoding asynchronously for any size.
1998         (WebCore::BitmapImage::frameImageAtIndex): Deleted. Moved to the header file but with a new purpose: return
1999         the current frame from the frame cache as is; do not cache a new one.
2000         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImage): Deleted. Function was renamed to shouldUseAsyncDecodingForLargeImages.
2001         (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImage): Deleted. Function was renamed to shouldUseAsyncDecodingForAnimatedImages.
2002         * platform/graphics/BitmapImage.h:
2003         * platform/graphics/CrossfadeGeneratedImage.cpp:
2004         (WebCore::CrossfadeGeneratedImage::draw): Add a new argument of type DecodingMode.
2005         * platform/graphics/CrossfadeGeneratedImage.h:
2006         * platform/graphics/DecodingOptions.h: Added.
2007         (WebCore::DecodingOptions::DecodingOptions): Default constructor: Synchronous mode.
2008         (WebCore::DecodingOptions::operator==): Compares two DecodingOptions for equality.
2009         (WebCore::DecodingOptions::isSynchronous): Is the frame decoded synchronously?
2010         (WebCore::DecodingOptions::isAsynchronous): Is the frame decoded asynchronously?
2011         (WebCore::DecodingOptions::isAsynchronousCompatibleWith): Is this DecodingOptions compatible with another one?
2012         (WebCore::DecodingOptions::hasFullSize): Is the decoding mode asynchronous but for the image full size?
2013         (WebCore::DecodingOptions::hasSizeForDrawing): Is this decoding mode asynchronous but for a sizeForDrawing?
2014         (WebCore::DecodingOptions::sizeForDrawing): Returns the sizeForDrawing. m_decodingModeOrSize has to hold an IntSize.
2015         (WebCore::DecodingOptions::maxDimension): Moved form ImageFrame.cpp.
2016         (WebCore::DecodingOptions::has): A helper function.
2017         (WebCore::DecodingOptions::hasDecodingMode): Does m_decodingModeOrSize a DecodingMode?
2018         (WebCore::DecodingOptions::hasSize): Does m_decodingModeOrSize an IntSize?
2019         * platform/graphics/GeneratedImage.h: Add a new argument of type DecodingMode.
2020         * platform/graphics/GradientImage.cpp:
2021         (WebCore::GradientImage::draw): Ditto.
2022         * platform/graphics/GradientImage.h: Ditto.
2023         * platform/graphics/GraphicsContext.cpp:
2024         (WebCore::GraphicsContext::drawImage): Pass the ImagePaintingOptions::m_DecodingMode to Image::draw().
2025         * platform/graphics/GraphicsContext.h:
2026         (WebCore::ImagePaintingOptions::ImagePaintingOptions): Add a new member of type DecodingMode to ImagePaintingOptions.
2027         * platform/graphics/Image.cpp:
2028         (WebCore::Image::drawTiled): Pass DecodingMode::Synchronous to Image::draw().
2029         * platform/graphics/Image.h: Add a new argument of type DecodingMode to Image::draw().
2030         * platform/graphics/ImageFrame.cpp:
2031         (WebCore::ImageFrame::operator=): Replace m_sizeForDrawing by m_decodingOptions.
2032         (WebCore::ImageFrame::hasNativeImage): Check if m_nativeImage is valid and the subsamplingLevels match.
2033         (WebCore::ImageFrame::hasFullSizeNativeImage): Checks hasNativeImage() and whether the image frame was
2034         decoded for the image full size.
2035         (WebCore::ImageFrame::hasDecodedNativeImageCompatibleWithOptions): Checks hasNativeImage() and the DecodingOptions match.
2036         (WebCore::maxDimension): Deleted. Moved to DecodingOptions.h.
2037         (WebCore::ImageFrame::isBeingDecoded): Deleted. The check for having an ImageFrame being decoded is
2038         moved to ImageFrameCache.
2039         (WebCore::ImageFrame::hasValidNativeImage): Deleted. No need to this function.
2040         * platform/graphics/ImageFrame.h:
2041         (WebCore::ImageFrame::hasNativeImage): Add an std::optional<SubsamplingLevel> argument.
2042         (WebCore::ImageFrame::hasFullSizeNativeImage): Checks whether the ImageFrame was decoded for the image full size.
2043         (WebCore::ImageFrame::enqueueSizeForDecoding): Deleted.
2044         (WebCore::ImageFrame::dequeueSizeForDecoding): Deleted.
2045         (WebCore::ImageFrame::clearSizeForDecoding): Deleted.
2046         (WebCore::ImageFrame::isBeingDecoded): Deleted.
2047         (WebCore::ImageFrame::sizeForDrawing): Deleted.
2048         (WebCore::ImageFrame::hasDecodedNativeImage): Deleted.
2049         The logic of knowing whether an ImageFrame is being decoded is moved to ImageFrameCache.
2050         * platform/graphics/ImageFrameCache.cpp:
2051         (WebCore::ImageFrameCache::cacheFrameMetadataAtIndex): Caches the metadata of an ImageFrame. If the NativeImage
2052         was decoded for a sizeForDrawing, the size of the ImageFrame will be the nativeImageSize(). Otherwise, the
2053         frameSizeAtIndex() will be called.
2054         (WebCore::ImageFrameCache::cacheFrameNativeImageAtIndex): Cache a new NativeImage which involves caching new
2055         metadata and updating the memory cache. No need to check if the existing native image is valid or not for the
2056         DecodingOptions. Actually it would be a bug if it happens. This is why cacheNativeImageForFrameRequest() asserts
2057         !frame.hasAsyncNativeImage() before calling cacheFrameNativeImageAtIndex().
2058         (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex): Cache new NativeImage which was decoded asynchronously.
2059         (WebCore::ImageFrameCache::startAsyncDecodingQueue): Call cacheAsyncFrameNativeImageAtIndex() instead of
2060         cacheNativeImageForFrameRequest() for clarity.
2061         (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Call hasAsyncNativeImage() instead of hasValidNativeImage()
2062         Call frameIsDecodingCompatibleWithOptionsAtIndex() instead of frame.isBeingDecoded(). Replace the call to enqueueSizeForDecoding()
2063         by appending the same ImageFrameRequest to m_frameCommitQueue.
2064         (WebCore::ImageFrameCache::isAsyncDecodingQueueIdle): Use m_frameCommitQueue to answer the question whether the decodingQueue is idle.
2065         (WebCore::ImageFrameCache::stopAsyncDecodingQueue): Use m_frameCommitQueue to loop through all the ImageFrames which are currently being decoded.
2066         (WebCore::ImageFrameCache::frameAtIndexCacheIfNeeded): For getting the metadata, this function needs a valid frame. If it is requested
2067         to decode the nativeImage, it has to do it synchronously.
2068         (WebCore::ImageFrameCache::singlePixelSolidColor): Don't cache the frame if it is an animated image or the size is not a single pixel.
2069         (WebCore::ImageFrameCache::frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex): Use m_frameCommitQueue to answer the question whether an ImageFrame
2070         is being decoded and is compatible with DecodingOptions.
2071         (WebCore::ImageFrameCache::frameHasFullSizeNativeImageAtIndex): Calls ImageFrame::hasFullNativeImage() for a frame. 
2072         (WebCore::ImageFrameCache::frameHasDecodedNativeImageCompatibleWithOptionsAtIndex): Calls ImageFrame::hasDecodedNativeImageCompatibleWithOptions() for a frame.
2073         (WebCore::ImageFrameCache::frameImageAtIndex): Returns the current NativeImage without caching.
2074         (WebCore::ImageFrameCache::frameImageAtIndexCacheIfNeeded): Returns the current NativeImage but cache it synchronously if needed.
2075         (WebCore::ImageFrameCache::setFrameNativeImageAtIndex): Deleted.
2076         (WebCore::ImageFrameCache::setFrameMetadataAtIndex): Deleted.
2077         (WebCore::ImageFrameCache::replaceFrameNativeImageAtIndex): Deleted.
2078         (WebCore::ImageFrameCache::frameIsBeingDecodedAtIndex): Deleted.
2079         (WebCore::ImageFrameCache::frameHasImageAtIndex): Deleted.
2080         (WebCore::ImageFrameCache::frameHasValidNativeImageAtIndex): Deleted.
2081         (WebCore::ImageFrameCache::frameHasDecodedNativeImage): Deleted.
2082         * platform/graphics/ImageFrameCache.h: Two ImageFrameRequest queues will be used.
2083         -- The existing one m_frameRequestQueue which is shared between the main thread and decoding thread. The requests will be
2084         dequeued from it before starting the decoding. The decoded NativeImage will be cached only on the main thread. The decoding
2085         thread is not blocked by the callOnMainThread(). This means there might be multiple ImageFrameRequests which were dequeued
2086         while their NativeImages have not been cached yet.
2087         -- A new one m_frameCommitQueue which is track all the ImageFrameRequests whose NativeImages have not been cached yet.
2088         (WebCore::ImageFrameCache::frameAtIndexCacheIfNeeded): Be explicit about caching the image frame. frameImageAtIndex()
2089         returns the current image frame without caching. frameAtIndexCacheIfNeeded(). returns the current image frame but cache
2090         it if needed.
2091         (WebCore::ImageFrameCache::ImageFrameRequest::operator==): Compares two ImageFrameRequests for equality.
2092         * platform/graphics/ImageSource.cpp:
2093         (WebCore::ImageSource::frameImageAtIndexCacheIfNeeded): 
2094         (WebCore::ImageSource::frameImageAtIndex): Deleted.
2095         * platform/graphics/ImageSource.h:
2096         (WebCore::ImageSource::requestFrameAsyncDecodingAtIndex): Change the type of the argument from IntSize to be const std::optional<IntSize>.
2097         (WebCore::ImageSource::frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex): Rename of frameIsBeingDecodedAtIndex(). Replace the argument of type
2098         std::optional<IntSize> by an argument of type DecodingOptions.
2099         (WebCore::ImageSource::frameHasFullSizeNativeImageAtIndex): A wrapper around the ImageFrameCache function.
2100         (WebCore::ImageSource::frameHasDecodedNativeImageCompatibleWithOptionsAtIndex): Ditto.
2101         (WebCore::ImageSource::frameImageAtIndex): Ditto.
2102         (WebCore::ImageSource::frameIsBeingDecodedAtIndex): Deleted.
2103         (WebCore::ImageSource::frameHasValidNativeImageAtIndex): Deleted.
2104         (WebCore::ImageSource::frameHasDecodedNativeImage): Deleted.
2105         * platform/graphics/NamedImageGeneratedImage.cpp:
2106         (WebCore::NamedImageGeneratedImage::draw): Add a new argument of type DecodingMode.
2107         * platform/graphics/NamedImageGeneratedImage.h: Ditto.
2108         * platform/graphics/cairo/ImageBufferCairo.cpp:
2109         (WebCore::ImageBuffer::draw): Add a new argument of type DecodingMode.
2110         * platform/graphics/cg/ImageDecoderCG.cpp:
2111         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument. Add a new handling
2112         for decoding asynchronously for the image full size.
2113         * platform/graphics/cg/ImageDecoderCG.h: Change the prototype of the function.
2114         * platform/graphics/cg/PDFDocumentImage.cpp:
2115         (WebCore::PDFDocumentImage::draw): Add a new argument of type DecodingMode.
2116         * platform/graphics/cg/PDFDocumentImage.h:
2117         * platform/graphics/win/ImageCGWin.cpp:
2118         (WebCore::BitmapImage::getHBITMAPOfSize): Pass DecodingMode::Synchronous to Image::draw().
2119         (WebCore::BitmapImage::drawFrameMatchingSourceSize): Ditto.
2120         * platform/graphics/win/ImageDecoderDirect2D.cpp:
2121         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument.
2122         * platform/graphics/win/ImageDecoderDirect2D.h: Change the prototype of the function.
2123         * platform/image-decoders/ImageDecoder.cpp: 
2124         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument.
2125         * platform/image-decoders/ImageDecoder.h: Change the prototype of the function.
2126         * rendering/RenderBoxModelObject.cpp:
2127         (WebCore::RenderBoxModelObject::paintFillLayerExtended): Draw the background image asynchronously if the image size is large.
2128         * rendering/RenderImage.cpp:
2129         (WebCore::RenderImage::paintIntoRect): Draw the background image element asynchronously if the image size is large.
2130         * svg/graphics/SVGImage.cpp:
2131         (WebCore::SVGImage::drawForContainer): Pass DecodingMode::Synchronous to draw().
2132         (WebCore::SVGImage::nativeImageForCurrentFrame): Ditto.
2133         (WebCore::SVGImage::nativeImage): Ditto.
2134         (WebCore::SVGImage::draw): Add a new argument of type DecodingMode.
2135         * svg/graphics/SVGImage.h: Change the prototype of the function.
2136         * svg/graphics/SVGImageForContainer.cpp:
2137         (WebCore::SVGImageForContainer::draw): Add a new argument of type DecodingMode.
2138         * svg/graphics/SVGImageForContainer.h: Change the prototype of the function.
2139
2140 2017-03-27  Youenn Fablet  <youenn@apple.com>
2141
2142         Activate release libwebrtc logging when WebRTC log channel is on
2143         https://bugs.webkit.org/show_bug.cgi?id=169659
2144
2145         Reviewed by Alex Christensen.
2146
2147         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
2148         (WebCore::initializePeerConnectionFactoryAndThreads):
2149
2150 2017-03-27  Antti Koivisto  <antti@apple.com>
2151
2152         Move visibleInViewportStateChanged callback from Element to render tree
2153         https://bugs.webkit.org/show_bug.cgi?id=170039
2154
2155         Reviewed by Zalan Bujtas.
2156
2157         Make it easier to use from the render tree.
2158
2159         Also for simplicity move the bits from RenderObject rare data to RenderElement.
2160         There is plenty of space there.
2161
2162         * dom/Element.h:
2163         (WebCore::Element::isVisibleInViewportChanged): Deleted.
2164         * html/HTMLMediaElement.h:
2165         * rendering/RenderElement.cpp:
2166         (WebCore::RenderElement::RenderElement):
2167         (WebCore::RenderElement::willBeDestroyed):
2168         (WebCore::RenderElement::registerForVisibleInViewportCallback):
2169         (WebCore::RenderElement::unregisterForVisibleInViewportCallback):
2170         (WebCore::RenderElement::setVisibleInViewportState):
2171         (WebCore::RenderElement::visibleInViewportStateChanged):
2172         * rendering/RenderElement.h:
2173         (WebCore::RenderElement::visibleInViewportState):
2174         * rendering/RenderObject.cpp:
2175         (WebCore::RenderObject::setIsRegisteredForVisibleInViewportCallback): Deleted.
2176         (WebCore::RenderObject::setVisibleInViewportState): Deleted.
2177         * rendering/RenderObject.h:
2178         (WebCore::RenderObject::hasOutlineAutoAncestor):
2179         (WebCore::RenderObject::RenderObjectRareData::RenderObjectRareData):
2180         (WebCore::RenderObject::isRegisteredForVisibleInViewportCallback): Deleted.
2181         (WebCore::RenderObject::visibleInViewportState): Deleted.
2182         * rendering/RenderVideo.cpp:
2183         (WebCore::RenderVideo::visibleInViewportStateChanged):
2184         * rendering/RenderVideo.h:
2185         * rendering/RenderView.cpp:
2186         (WebCore::RenderView::updateVisibleViewportRect):
2187
2188 2017-03-27  Youenn Fablet  <youenn@apple.com>
2189
2190         addIceCandidate should not throw if passed null or undefined
2191         https://bugs.webkit.org/show_bug.cgi?id=170118
2192
2193         Reviewed by Eric Carlson.
2194
2195         Covered by updated test.
2196
2197         A null/undefined candidate passed to addIceCandidate means end of Ice candidate..
2198
2199         * Modules/mediastream/PeerConnectionBackend.cpp:
2200         (WebCore::PeerConnectionBackend::addIceCandidate):
2201         * Modules/mediastream/PeerConnectionBackend.h:
2202         (WebCore::PeerConnectionBackend::endOfIceCandidates):
2203         * Modules/mediastream/RTCPeerConnection.cpp:
2204         (WebCore::RTCPeerConnection::queuedAddIceCandidate):
2205         * Modules/mediastream/RTCPeerConnection.h:
2206         * Modules/mediastream/RTCPeerConnection.idl:
2207         * Modules/mediastream/RTCPeerConnection.js:
2208         (addIceCandidate):
2209
2210 2017-03-27  Antti Koivisto  <antti@apple.com>
2211
2212         Allow the page to render before <link> stylesheet tags in body
2213         https://bugs.webkit.org/show_bug.cgi?id=149157
2214         <rdar://problem/24658830>
2215
2216         Reviewed by Simon Fraser.
2217
2218         Currently we block style and renderer building completely if document has any loading
2219         stylesheets. In case a script queries something layout dependent we construct the render
2220         tree with whatever style we have but block painting in it.
2221
2222         This patch changes behavior so that a loading stylesheet in body only blocks rendering for elements
2223         that are after it. The expectation is that such stylesheets rarely affect elements before them
2224         and the elements can be rendered without causing ugly visible styling changes.
2225
2226         The patch replaces the old flash-of-unstyled-content (FOUC) preventation mechanism with a more
2227         fine-grained one. Paint blocking is now done on per-renderer basis with based on isNonFinal flag in
2228         RenderStyle.
2229
2230         For stylesheets in head the behavior should be largely unchanged.
2231
2232         Test: http/tests/incremental/stylesheet-body-incremental-rendering.html
2233
2234         * css/StyleResolver.cpp:
2235         (WebCore::StyleResolver::pseudoStyleRulesForElement):
2236         * dom/Document.cpp:
2237         (WebCore::Document::Document):
2238         (WebCore::Document::resolveStyle):
2239         (WebCore::Document::updateLayoutIgnorePendingStylesheets):
2240
2241             Remove the old FOUC preventation state tracking.
2242
2243         (WebCore::Document::shouldScheduleLayout):
2244         (WebCore::Document::didRemoveAllPendingStylesheet):
2245
2246             Repaints will now get triggered by the normal style mechanism.
2247
2248         * dom/Document.h:
2249         (WebCore::Document::hasNodesWithNonFinalStyle):
2250         (WebCore::Document::setHasNodesWithNonFinalStyle):
2251
2252             Track if we need to recompute the style later because non-final or unstyled elements.
2253
2254         (WebCore::Document::didLayoutWithPendingStylesheets): Deleted.
2255         (WebCore::Document::hasNodesWithPlaceholderStyle): Deleted.
2256         (WebCore::Document::setHasNodesWithPlaceholderStyle): Deleted.
2257         * html/HTMLFrameSetElement.cpp:
2258         (WebCore::HTMLFrameSetElement::rendererIsNeeded):
2259         * page/FrameView.cpp:
2260         (WebCore::FrameView::qualifiesAsVisuallyNonEmpty):
2261
2262             Don't qualify as visually non-empty if we have loading stylesheets in head (even if there is
2263             a fouc-prevented render tree).
2264
2265         (WebCore::FrameView::fireLayoutRelatedMilestonesIfNeeded):
2266         * rendering/RenderBlock.cpp:
2267         (WebCore::RenderBlock::paintContents):
2268
2269             Instead of a global test, block painting if isNonFinal is set in the renderer's style.
2270
2271         * rendering/RenderLayer.cpp:
2272         (WebCore::shouldSuppressPaintingLayer):
2273         * rendering/style/RenderStyle.cpp:
2274         (WebCore::RenderStyle::changeRequiresRepaint):
2275
2276             The isNonFinal flag prevents painting so we need to trigger repaint when it gets cleared.
2277
2278         * rendering/style/RenderStyle.h:
2279         (WebCore::RenderStyle::isNotFinal):
2280         (WebCore::RenderStyle::setIsNotFinal):
2281         (WebCore::RenderStyle::isPlaceholderStyle): Deleted.
2282         (WebCore::RenderStyle::setIsPlaceholderStyle): Deleted.
2283
2284             There is no need for placeholder styles anymore. Reuse the bit for isNotFinal.
2285
2286         * rendering/style/StyleRareNonInheritedData.cpp:
2287         (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
2288         (WebCore::StyleRareNonInheritedData::operator==):
2289         * rendering/style/StyleRareNonInheritedData.h:
2290         * style/StyleScope.cpp:
2291         (WebCore::Style::Scope::analyzeStyleSheetChange):
2292         (WebCore::Style::Scope::updateActiveStyleSheets):
2293         * style/StyleTreeResolver.cpp:
2294         (WebCore::Style::TreeResolver::styleForElement):
2295         (WebCore::Style::TreeResolver::resolveElement):
2296
2297             If we have seens a loading stylesheet and don't have a renderer yet don't style the element.
2298             In case there is a renderer or we are ignoring pending sheets, resolve the style normally
2299             but mark it as non-final.
2300
2301         (WebCore::Style::makePlaceholderStyle): Deleted.
2302
2303 2017-03-27  Myles C. Maxfield  <mmaxfield@apple.com>
2304
2305         Test variation font ranges in the CSS Font Loading API
2306         https://bugs.webkit.org/show_bug.cgi?id=170022
2307
2308         Reviewed by Dean Jackson.
2309
2310         Test: fast/text/variations/font-loading-api-parse-ranges.html
2311
2312         Don't use keywords when reporting font variation range values.
2313
2314         * css/CSSComputedStyleDeclaration.cpp:
2315         (WebCore::ComputedStyleExtractor::fontNonKeywordWeightFromStyleValue):
2316         (WebCore::ComputedStyleExtractor::fontWeightFromStyleValue):
2317         (WebCore::ComputedStyleExtractor::fontNonKeywordStretchFromStyleValue):
2318         (WebCore::ComputedStyleExtractor::fontStretchFromStyleValue):
2319         (WebCore::ComputedStyleExtractor::fontNonKeywordStyleFromStyleValue):
2320         (WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
2321         * css/CSSComputedStyleDeclaration.h:
2322         * css/FontFace.cpp:
2323         (WebCore::FontFace::style):
2324         (WebCore::FontFace::weight):
2325         (WebCore::FontFace::stretch):
2326
2327 2017-03-27  Anders Carlsson  <andersca@apple.com>
2328
2329         Propagate shipping contact update errors
2330         https://bugs.webkit.org/show_bug.cgi?id=170141
2331         rdar://problem/31276576
2332
2333         Reviewed by Tim Horton.
2334
2335         * Modules/applepay/ApplePaySession.cpp:
2336         (WebCore::convertAndValidate):
2337
2338 2017-03-27  Ryan Haddad  <ryanhaddad@apple.com>
2339
2340         Unreviewed, rolling out r214411.
2341
2342         Two of the LayoutTests for this change time out on ios-
2343         simulator.
2344
2345         Reverted changeset:
2346
2347         "[Modern Media Controls] Improve media documents across macOS,
2348         iPhone and iPad"
2349         https://bugs.webkit.org/show_bug.cgi?id=169145
2350         http://trac.webkit.org/changeset/214411
2351
2352 2017-03-27  Antoine Quint  <graouts@apple.com>
2353
2354         [Modern Media Controls] Clicking on the tracks button when the tracks panel is up in a media document pauses the video
2355         https://bugs.webkit.org/show_bug.cgi?id=168517
2356         <rdar://problem/30577636>
2357
2358         Reviewed by Dean Jackson.
2359
2360         We completely turn off default event handling in MediaDocument.cpp since we're implementing the
2361         behavior we expect to pause and resume the video in the modern-media-controls module already. This
2362         gets rid of this odd case where the content would not see the "click" event while the C++ side would
2363         handle it and pause the video.
2364
2365         * Modules/modern-media-controls/media/media-controller.js:
2366         (MediaController):
2367         (MediaController.prototype.handleEvent):
2368         (MediaController.prototype._containerWasClicked): Deleted.
2369         * html/MediaDocument.cpp:
2370         (WebCore::MediaDocument::defaultEventHandler):
2371
2372 2017-03-27  Youenn Fablet  <youenn@apple.com>
2373
2374         Tighten RTCDatachannel creation and parameter getters
2375         https://bugs.webkit.org/show_bug.cgi?id=170081
2376
2377         Reviewed by Eric Carlson.
2378
2379         Covered by updated tests.
2380
2381         Adding some parameter checks when creating data channels.
2382         Making some getters nullable as per the spec.
2383
2384         * Modules/mediastream/RTCDataChannel.h:
2385         * Modules/mediastream/RTCDataChannel.idl:
2386         * Modules/mediastream/RTCPeerConnection.cpp:
2387         (WebCore::RTCPeerConnection::createDataChannel):
2388         * Modules/mediastream/RTCPeerConnection.idl:
2389         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
2390         (WebCore::LibWebRTCMediaEndpoint::createDataChannel):
2391         (WebCore::LibWebRTCMediaEndpoint::addDataChannel):
2392         * platform/mediastream/RTCDataChannelHandler.h:
2393         (): Deleted.
2394
2395 2017-03-27  Youenn Fablet  <youenn@apple.com>
2396
2397         Add support for RTCRtpReceiver/RTCRtpSender getParameters
2398         https://bugs.webkit.org/show_bug.cgi?id=170057
2399
2400         Reviewed by Alex Christensen.
2401
2402         Test: webrtc/video-getParameters.html
2403
2404         getParameters returns a dictionary of values taken from libwebrtc RtpReceiverInterface/RtpSenderInrterface objects.
2405         Added a direct link between WebCore RTCRtpReceiver and libwebrtc RtpReceiverInterface object.
2406         Making the link between WebCore RTCRtpSender and libwebrtc RtpSenderInrterface object through
2407         PeerConnectionBackend to keep the current architecture shared with OpenWebRTC.
2408         In the future, we should try to make the link more direct.
2409
2410         Added routines to support the conversion from libwebrtc to WebCore.
2411         Ensured that RTCRtpReceiver is cleaning its backend when being stopped.
2412
2413         * CMakeLists.txt:
2414         * DerivedSources.make:
2415         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
2416         (WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask):
2417         * Modules/mediastream/PeerConnectionBackend.h:
2418         (WebCore::PeerConnectionBackend::getParameters):
2419         * Modules/mediastream/RTCPeerConnection.cpp:
2420         (WebCore::RTCPeerConnection::doClose):
2421         (WebCore::RTCPeerConnection::getParameters):
2422         * Modules/mediastream/RTCPeerConnection.h:
2423         * Modules/mediastream/RTCRtpParameters.h: Added.
2424         * Modules/mediastream/RTCRtpParameters.idl: Added.
2425         * Modules/mediastream/RTCRtpReceiver.cpp:
2426         (WebCore::RTCRtpReceiver::RTCRtpReceiver):
2427         * Modules/mediastream/RTCRtpReceiver.h:
2428         (WebCore::RTCRtpReceiver::Backend::~Backend):
2429         (WebCore::RTCRtpReceiver::Backend::getParameters):
2430         (WebCore::RTCRtpReceiver::create):
2431         (WebCore::RTCRtpReceiver::stop):
2432         (WebCore::RTCRtpReceiver::setBackend):
2433         (WebCore::RTCRtpReceiver::getParameters):
2434         * Modules/mediastream/RTCRtpReceiver.idl:
2435         * Modules/mediastream/RTCRtpSender.cpp:
2436         (WebCore::RTCRtpSender::create):
2437         (WebCore::RTCRtpSender::RTCRtpSender):
2438         (WebCore::RTCRtpSender::replaceTrack):
2439         (WebCore::RTCRtpSender::getParameters):
2440         * Modules/mediastream/RTCRtpSender.h:
2441         (WebCore::RTCRtpSender::Backend::~Backend):
2442         (WebCore::RTCRtpSender::isStopped):
2443         (WebCore::RTCRtpSender::stop):
2444         * Modules/mediastream/RTCRtpSender.idl:
2445         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
2446         (WebCore::LibWebRTCMediaEndpoint::addTrack):
2447         (WebCore::LibWebRTCMediaEndpoint::addRemoteTrack):
2448         (WebCore::LibWebRTCMediaEndpoint::OnAddTrack):
2449         (WebCore::LibWebRTCMediaEndpoint::stop):
2450         (WebCore::fillEncodingParameters):
2451         (WebCore::fillHeaderExtensionParameters):
2452         (WebCore::fillCodecParameters):
2453         (WebCore::fillRtpParameters):
2454         (WebCore::RTCRtpReceiverBackend::getParameters):
2455         (WebCore::LibWebRTCMediaEndpoint::getRTCRtpSenderParameters):
2456         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
2457         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
2458         (WebCore::LibWebRTCPeerConnectionBackend::notifyAddedTrack):
2459         (WebCore::LibWebRTCPeerConnectionBackend::getParameters):
2460         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
2461         * WebCore.xcodeproj/project.pbxproj:
2462         * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
2463
2464 2017-03-27  Myles C. Maxfield  <mmaxfield@apple.com>
2465
2466         font variation properties don't need to accept numbers
2467         https://bugs.webkit.org/show_bug.cgi?id=169357
2468
2469         Reviewed by Antti Koivisto.
2470
2471         The CSS Fonts level 4 spec stabilized the grammar accepted by font-weight,
2472         font-style, and font-stretch. The changes are that font-style and
2473         font-stretch no longer accept raw numbers, and the @font-face descriptor
2474         ranges are now separated by spaces instead of slashes.
2475
2476         Tests: fast/text/font-selection-font-face-parse.html
2477                fast/text/font-selection-font-loading-api-parse.html
2478                fast/text/font-stretch-parse.html
2479                fast/text/font-style-parse.html
2480                fast/text/variations/font-selection-properties.html
2481
2482         * css/CSSComputedStyleDeclaration.cpp:
2483         (WebCore::ComputedStyleExtractor::fontWeightFromStyleValue):
2484         (WebCore::fontWeightFromStyle):
2485         (WebCore::ComputedStyleExtractor::fontStretchFromStyleValue):
2486         (WebCore::fontStretchFromStyle):
2487         (WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
2488         (WebCore::fontStyleFromStyle):
2489         * css/CSSComputedStyleDeclaration.h:
2490         * css/FontFace.cpp:
2491         (WebCore::FontFace::style):
2492         (WebCore::FontFace::weight):
2493         (WebCore::FontFace::stretch):
2494         (WebCore::rangeIsSingleValue): Deleted.
2495         * css/StyleBuilderConverter.h:
2496         (WebCore::StyleBuilderConverter::convertFontStretchFromValue):
2497         * css/parser/CSSPropertyParser.cpp:
2498         (WebCore::consumeFontWeightRange):
2499         (WebCore::consumeFontStretch):
2500         (WebCore::consumeFontStretchRange):
2501         (WebCore::consumeFontStyle):
2502         (WebCore::consumeFontStyleRange):
2503
2504 2017-03-27  Youenn Fablet  <youenn@apple.com>
2505
2506         Further optimize checkWebRTCAvailability
2507         https://bugs.webkit.org/show_bug.cgi?id=169147
2508
2509         Reviewed by Alex Christensen.
2510
2511         Tested locally by removing libwebrtc.dylib.
2512         Replacing dlopen check by checking an exported symbol, rtc::LogMessage::LogToDebug.
2513         This check is more efficient and accurate. It should work in more configurations than the previous one.
2514
2515         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
2516         (WebCore::isNullFunctionPointer):
2517         (WebCore::LibWebRTCProvider::webRTCAvailable):
2518
2519 2017-03-27  Myles C. Maxfield  <mmaxfield@apple.com>
2520
2521         Implement format specifier for variation fonts
2522         https://bugs.webkit.org/show_bug.cgi?id=169327
2523
2524         Reviewed by Simon Fraser.
2525
2526         Variation fonts require the format("woff-variations"), format("truetype-variations"),
2527         and format("opentype-variations") format specifies in @font-face rules.
2528
2529         Test: fast/text/variations/font-face-format.html
2530
2531         * platform/graphics/mac/FontCustomPlatformData.cpp:
2532         (WebCore::FontCustomPlatformData::supportsFormat):
2533
2534 2017-03-27  Myles C. Maxfield  <mmaxfield@apple.com>
2535
2536         Make sure animation works for font-weight, font-stretch, and font-style
2537         https://bugs.webkit.org/show_bug.cgi?id=169683
2538
2539         Reviewed by Simon Fraser.
2540
2541         Hook up animation code for FontSelectionValues.
2542
2543         Tests: animations/font-variations/font-stretch.html
2544                animations/font-variations/font-style.html
2545                animations/font-variations/font-weight.html
2546
2547         * page/animation/CSSPropertyAnimation.cpp:
2548         (WebCore::blendFunc):
2549         (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
2550         * rendering/style/RenderStyle.cpp:
2551         (WebCore::RenderStyle::setFontWeight):
2552         (WebCore::RenderStyle::setFontStretch):
2553         (WebCore::RenderStyle::setFontItalic):
2554         * rendering/style/RenderStyle.h:
2555         (WebCore::RenderStyle::fontWeight):
2556         (WebCore::RenderStyle::fontStretch):
2557         (WebCore::RenderStyle::fontItalic):
2558
2559 2017-03-27  Alex Christensen  <achristensen@webkit.org>
2560
2561         Make WebSockets work in network process
2562         https://bugs.webkit.org/show_bug.cgi?id=169930
2563
2564         Reviewed by Youenn Fablet.
2565
2566         Covered by 136 existing tests in http/tests/websocket/tests/hybi
2567         This also does fine with the 544 websocket tests in the web-platform-tests which we have not yet imported.
2568         Also added http/tests/websocket/tests/hybi/network-process-crash-error.html
2569         to test a new condition that couldn't happen before this move: the NetworkProcess crashing.
2570
2571         * Modules/websockets/WebSocketChannel.cpp:
2572         (WebCore::WebSocketChannel::fail):
2573         We were asserting that didCloseSocketStream was called.  It is still called,
2574         but not synchronously like it used to.  This assertion is now invalid, but tests
2575         that would hit it still pass.
2576         * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
2577         (WebCore::SocketStreamHandleImpl::platformSendInternal):
2578         CFWriteStreamCanAcceptBytes crashes if you give it a null parameter, and that can happen now.
2579         If we have no write stream, then we cannot write.  Tests that hit this pass still.
2580
2581 2017-03-27  Antoine Quint  <graouts@apple.com>
2582
2583         [Modern Media Controls] Improve media documents across macOS, iPhone and iPad
2584         https://bugs.webkit.org/show_bug.cgi?id=169145
2585         <rdar://problem/17048858>
2586
2587         Reviewed by Dean Jackson.
2588
2589         There were a variety of issues with media documents, some longstanding, and some specifically
2590         about modern media controls.
2591
2592         One issue was that fullscreen and picture-in-picture buttons would show for audio media documents,
2593         due to using a <video> element to load the audio file. We now have additional logic in MediaController
2594         to identify if the loaded media is really an audio file, and using this information to hide the
2595         fullscreen and picture-in-picture buttons.
2596
2597         Another issue was that we would inject style in MediaDocument.cpp that was specific to modern media
2598         controls when we could have the modern-media-controls module injected CSS handle this styling. We now
2599         use the injected style in the shadow root to size media documents based on the device characteristics
2600         and ensuring that page styles are overridden.
2601
2602         We also simplify how MediaDocument.cpp sets the source of the media element to simply use the "src"
2603         attribute and not a <source> element.
2604
2605         Finally, we introduce a MediaDocumentController class that is instantiated when we're dealing with
2606         a media document to hide the controls while we determine the type of media we're loading (audio vs.
2607         video) in order to apply the appropriate styling without flashes.
2608
2609         As a result of the new styles applied by the modern-media-controls module, media documents have a
2610         similar behavior on macOS and iPad, where we only enforce a min-width for video allowing them
2611         to play at their natural size otherwise, and enforcing a fixed width for audio. On iPhone however,
2612         we want to always play the media at full width, with some padding in the case of audio.
2613
2614         Tests: media/modern-media-controls/fullscreen-support/fullscreen-support-disabled-video-with-audio-tracks-only.html
2615                media/modern-media-controls/media-documents/ipad/media-document-audio-ios-sizing.html
2616                media/modern-media-controls/media-documents/ipad/media-document-video-ios-sizing.html
2617                media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html
2618                media/modern-media-controls/media-documents/media-document-audio-mac-sizing.html
2619                media/modern-media-controls/media-documents/media-document-video-ios-sizing.html
2620                media/modern-media-controls/media-documents/media-document-video-mac-sizing.html
2621                media/modern-media-controls/pip-support/pip-support-disabled-video-with-audio-tracks-only.html
2622
2623         * Modules/modern-media-controls/controls/ios-inline-media-controls.css:
2624         (:host(audio) .media-controls.ios.inline > .controls-bar:before,):
2625         (:host(audio) .media-controls.ios.inline > .controls-bar:before): Deleted.
2626         * Modules/modern-media-controls/controls/macos-media-controls.css:
2627         (:host(audio) .media-controls.mac.inline > .controls-bar,):
2628         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint,):
2629         (:host(audio) .media-controls.mac.inline > .controls-bar): Deleted.
2630         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint): Deleted.
2631         * Modules/modern-media-controls/controls/media-document.css: Added.
2632         (:host(.media-document)):
2633         (:host(.media-document.ready)):
2634         (:host(.media-document.audio.mac)):
2635         (:host(.media-document.audio.ipad)):
2636         (:host(.media-document.audio.iphone)):
2637         (:host(.media-document.video.mac)):
2638         (:host(.media-document.video.ipad)):
2639         (:host(.media-document.video.iphone)):
2640         * Modules/modern-media-controls/js-files:
2641         * Modules/modern-media-controls/media/fullscreen-support.js:
2642         (FullscreenSupport.prototype.syncControl):
2643         (FullscreenSupport):
2644         * Modules/modern-media-controls/media/media-controller.js:
2645         (MediaController):
2646         (MediaController.prototype.get isAudio):
2647         * Modules/modern-media-controls/media/media-document-controller.js: Added.
2648         (MediaDocumentController):
2649         (MediaDocumentController.prototype.handleEvent):
2650         (MediaDocumentController.prototype._mediaDocumentHasMetadata):
2651         (MediaDocumentController.prototype._mediaDocumentHasSize):
2652         * Modules/modern-media-controls/media/pip-support.js:
2653         (PiPSupport.prototype.syncControl):
2654         (PiPSupport):
2655         * html/MediaDocument.cpp:
2656         (WebCore::MediaDocumentParser::createDocumentStructure):
2657
2658 2017-03-25  Chris Dumez  <cdumez@apple.com>
2659
2660         REGRESSION(r214195): zillow.com header video doesn't resume when switching to another tab and back
2661         https://bugs.webkit.org/show_bug.cgi?id=170080
2662         <rdar://problem/31252522>
2663
2664         Reviewed by Eric Carlson.
2665
2666         The video header on zillow.com would pause when switching to another tab after r214195. On
2667         switching back to the zillow.com tab, we would resume the video but fail to take the poster
2668         away, making it look like the video is still paused.
2669
2670         We normally take the poster away when HTMLMediaElement::mediaPlayerFirstVideoFrameAvailable()
2671         is called. However, mediaPlayerFirstVideoFrameAvailable() was only ever called once because of
2672         the m_haveReportedFirstVideoFrame flag in MediaPlayerPrivateAVFoundation::updateStates().
2673         We now reset m_haveReportedFirstVideoFrame to false in updateStates() if hasAvailableVideoFrame()
2674         return false, so that we call mediaPlayerFirstVideoFrameAvailable() again when the return
2675         value of asAvailableVideoFrame() becomes true again (e.g. after the media session interruption
2676         has ended).
2677
2678         * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
2679         (WebCore::MediaPlayerPrivateAVFoundation::updateStates):
2680
2681 2017-03-24  Wenson Hsieh  <wenson_hsieh@apple.com>
2682
2683         [WK2] Add a UI delegate SPI hook to enable or disable navigation on drop
2684         https://bugs.webkit.org/show_bug.cgi?id=169168
2685         <rdar://problem/30688374>
2686
2687         Reviewed by Tim Horton.
2688
2689         Refactor client hooks for the drag destination action in WebCore to ask for the drag destination action mask
2690         upon initializing the DragData. In DragController, rather than setting m_dragDestinationAction to the result of
2691         m_client.actionMaskForDrag, we instead set it to the DragData's destination action.
2692
2693         Tests to come in a future patch.
2694
2695         * loader/EmptyClients.cpp:
2696         * page/DragClient.h:
2697
2698         Rather than pass in a DragData, pass in only the platform data that we need to hand to the delegate. This is
2699         because we now ask for drag destination actions prior to creating the DragData.
2700
2701         * page/DragController.cpp:
2702         (WebCore::DragController::dragEnteredOrUpdated):
2703
2704         Update the available drag destination actions in WebCore using the destination actions stored in DragData rather
2705         than calling out to the client delegate.
2706
2707         * loader/EmptyClients.cpp:
2708         * platform/DragData.cpp:
2709         (WebCore::DragData::DragData):
2710         * platform/DragData.h:
2711         (WebCore::DragData::dragDestinationAction):
2712         (WebCore::DragData::operator =):
2713         * platform/mac/DragDataMac.mm:
2714         (WebCore::DragData::DragData):
2715
2716 2017-03-25  Aaron Chu  <aaron_chu@apple.com>
2717
2718         AX: Media controls are unlabeled
2719         https://bugs.webkit.org/show_bug.cgi?id=169947
2720         <rdar://problem/30153323>
2721
2722         Reviewed by Antoine Quint.
2723
2724         Added a "label" property for Icons, which are used to set
2725         the aria-label for the controls in modern media controls.
2726
2727         Test: Addition to all existing modern media controls tests.
2728
2729         * English.lproj/modern-media-controls-localized-strings.js:
2730         * Modules/modern-media-controls/controls/icon-button.js:
2731         (IconButton.prototype.set iconName):
2732         (IconButton.prototype.handleEvent):
2733         (IconButton.prototype._loadImage):
2734         * Modules/modern-media-controls/controls/icon-service.js:
2735         * Modules/modern-media-controls/controls/start-button.js:
2736         (StartButton):
2737         * Modules/modern-media-controls/js-files:
2738
2739 2017-03-25  Carlos Garcia Campos  <cgarcia@igalia.com>
2740
2741         [XDG] MIMETypeRegistry::getMIMETypeForExtension should return a null/empty string when mime type is unknown
2742         https://bugs.webkit.org/show_bug.cgi?id=170050
2743
2744         Reviewed by Michael Catanzaro.
2745
2746         That's what the callers expect, but we alre always returning XDG_MIME_TYPE_UNKNOWN which is
2747         application/octet-stream.
2748
2749         Fixes: plugins/no-mime-with-valid-extension.html
2750
2751         * platform/xdg/MIMETypeRegistryXdg.cpp:
2752         (WebCore::MIMETypeRegistry::getMIMETypeForExtension):
2753
2754 2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
2755
2756         Add font-optical-sizing to CSSComputedStyleDeclaration
2757         https://bugs.webkit.org/show_bug.cgi?id=170083
2758
2759         Reviewed by Joseph Pecoraro.
2760
2761         Covered by existing tests.
2762
2763         * css/CSSComputedStyleDeclaration.cpp:
2764
2765 2017-03-24  Daniel Bates  <dabates@apple.com>
2766
2767         media/restore-from-page-cache.html causes NoEventDispatchAssertion::isEventAllowedInMainThread() assertion failure
2768         https://bugs.webkit.org/show_bug.cgi?id=170087
2769         <rdar://problem/31254822>
2770
2771         Reviewed by Simon Fraser.
2772
2773         Reduce the scope of code that should never dispatch DOM events so as to allow updating contents size
2774         after restoring a page from the page cache.
2775
2776         In r214014 we instantiate a NoEventDispatchAssertion in FrameLoader::commitProvisionalLoad()
2777         around the call to CachedPage::restore() to assert when a DOM event is dispatched during
2778         page restoration as such events can cause re-entrancy into the page cache. As it turns out
2779         it is sufficient to ensure that no DOM events are dispatched after restoring all cached frames
2780         as opposed to after CachedPage::restore() returns.
2781
2782         Also rename Document::enqueue{Pageshow, Popstate}Event() to dispatch{Pageshow, Popstate}Event(),
2783         respectively, since they synchronously dispatch events :(. We hope in the future to make them
2784         asynchronously dispatch events.
2785
2786         * dom/Document.cpp:
2787         (WebCore::Document::implicitClose): Update for renaming.
2788         (WebCore::Document::statePopped): Ditto.
2789         (WebCore::Document::dispatchPageshowEvent): Renamed; formerly named enqueuePageshowEvent().
2790         (WebCore::Document::dispatchPopstateEvent): Renamed; formerly named enqueuePopstateEvent().
2791         (WebCore::Document::enqueuePageshowEvent): Deleted.
2792         (WebCore::Document::enqueuePopstateEvent): Deleted.
2793         * dom/Document.h:
2794         * history/CachedPage.cpp:
2795         (WebCore::firePageShowAndPopStateEvents): Moved logic from FrameLoader::didRestoreFromCachedPage() to here.
2796         (WebCore::CachedPage::restore): Modified to call firePageShowAndPopStateEvents().
2797         * loader/FrameLoader.cpp:
2798         (WebCore::FrameLoader::commitProvisionalLoad): Removed use of NoEventDispatchAssertion RAII object. We
2799         will instantiate it in CachedPage::restore() with a smaller scope.
2800         (WebCore::FrameLoader::didRestoreFromCachedPage): Deleted; moved logic from here to WebCore::firePageShowAndPopStateEvents().
2801         * loader/FrameLoader.h:
2802
2803 2017-03-24  Ryan Haddad  <ryanhaddad@apple.com>
2804
2805         Unreviewed, rolling out r214361.
2806
2807         This change caused flakiness in http/tests/preload tests.
2808
2809         Reverted changeset:
2810
2811         "Add a warning for unused link preloads."
2812         https://bugs.webkit.org/show_bug.cgi?id=165670
2813         http://trac.webkit.org/changeset/214361
2814
2815 2017-03-24  Antoine Quint  <graouts@webkit.org>
2816
2817         [Modern Media Controls] Remove placard icon if height is compressed
2818         https://bugs.webkit.org/show_bug.cgi?id=167935
2819         <rdar://problem/30397128>
2820
2821         Reviewed by Dean Jackson.
2822
2823         We make the addition of certain Placard children conditional on the placard's metrics. Whenever the
2824         media controls metrics changes, the placard, if any, is set to have the same metrics and layout() is
2825         called where we ensure that there is enough space, per designs, to have the icon, description and even
2826         the title visible. We also make some CSS improvements to guarantee that the description is laid out on
2827         two lines at most and that both text labels are trimmed elegantly with an ellipsis shold the width be
2828         insufficient to display the whole text.
2829
2830         Since we would have needed to have more width/height setter overrides to trigger layout, we now make
2831         LayoutNode trigger layout() directly and remove the need for subclasses to do this on a per-class basis.
2832         We also make layout() a method that can be called safely anytime as it's now no longer part of the DOM
2833         commit step, a new commit() method is used instead of that.
2834
2835         Tests: media/modern-media-controls/layout-node/node-made-dirty-during-commit.html
2836                media/modern-media-controls/media-controls/media-controls-placard-compressed-metrics.html
2837
2838         * Modules/modern-media-controls/controls/layout-node.js:
2839         (LayoutNode.prototype.set width):
2840         (LayoutNode.prototype.set height):
2841         Trigger a call to layout() anytime "width" or "height" is set on any LayoutNode.
2842
2843         (LayoutNode.prototype.layout):
2844         (LayoutNode.prototype.commit):
2845         (performScheduledLayout):
2846         Make layout() an empty method that subclasses can override easily outside of the DOM commit cycle,
2847         its previous implementation is now called "commit()" which is a more accurate name.
2848
2849         * Modules/modern-media-controls/controls/media-controls.js:
2850         (MediaControls.prototype.get placard):
2851         (MediaControls.prototype.get showsPlacard):
2852         (MediaControls.prototype.showPlacard):
2853         (MediaControls.prototype.hidePlacard):
2854         (MediaControls.prototype.layout):
2855         (MediaControls.prototype.get width): Deleted.
2856         (MediaControls.prototype.set width): Deleted.
2857         Add a "placard" property to make it simpler to reference the placard instead of making assumptions in
2858         several places in that class on the children order. Anytime we run a layout or show the placard, ensure
2859         that the placard metrics are synced with the media controls metrics.
2860
2861         * Modules/modern-media-controls/controls/placard.css:
2862         (.placard .container):
2863         (.placard .title,):
2864         (.placard .description):
2865         We now ensure that both the title and description are trimmed with an ellipsis when we run out of space
2866         to display them fully.
2867
2868         * Modules/modern-media-controls/controls/placard.js:
2869         (Placard.):
2870         (Placard.prototype.layout):
2871         We add new constraints to only show the icon, title and description if the placard is tall and wide enough.
2872
2873         * Modules/modern-media-controls/controls/slider.js:
2874         (Slider.prototype.get width): Deleted.
2875         (Slider.prototype.set width): Deleted.
2876         Removed custom "width" getters and setters now we can just override layout() in case node metrics change.
2877
2878         * Modules/modern-media-controls/controls/time-control.js:
2879         (TimeControl.prototype.set useSixDigitsForTimeLabels):
2880         (TimeControl.prototype.layout):
2881         (TimeControl.prototype.get width): Deleted.
2882         (TimeControl.prototype.set width): Deleted.
2883         (TimeControl.prototype._availableWidthHasChanged): Deleted.
2884         Removed custom "width" getters and setters now we can just override layout() in case node metrics change.
2885
2886         * Modules/modern-media-controls/media/media-controller.js:
2887         (MediaController):
2888         Ensure we flush pending updates at construction time so that we match the size of the media controls right
2889         at the first media layout.
2890
2891 2017-03-24  Eric Carlson  <eric.carlson@apple.com>
2892
2893         [MediaStream] "ideal" constraints passed to getUserMedia should affect fitness score
2894         https://bugs.webkit.org/show_bug.cgi?id=170056
2895
2896         Reviewed by Youenn Fablet.
2897
2898         Include the fitness score calculated for ideal constraints in the calculation of a capture
2899         overall device fitness score. 
2900
2901         No new tests, existing tests updated.
2902
2903         * platform/mediastream/MediaConstraints.cpp:
2904         (WebCore::StringConstraint::fitnessDistance): Drive-by fix: return early if ideal is empty,
2905         not exact.
2906
2907         * platform/mediastream/RealtimeMediaSource.cpp:
2908         (WebCore::RealtimeMediaSource::supportsSizeAndFrameRate): Return fitness distance.
2909         (WebCore::RealtimeMediaSource::selectSettings): Include the fitness distance of supported
2910         ideal constraints.
2911         (WebCore::RealtimeMediaSource::supportsConstraint): New.
2912         (WebCore::RealtimeMediaSource::applyConstraints):
2913         * platform/mediastream/RealtimeMediaSource.h:
2914
2915         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
2916         (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints): Sort candidate sources
2917         by their fitness score.
2918
2919         * platform/mock/MockRealtimeVideoSource.cpp:
2920         (WebCore::MockRealtimeVideoSource::initializeCapabilities): Each video source should support
2921         one facing mode, not both.
2922
2923 2017-03-24  Dean Jackson  <dino@apple.com>
2924
2925         Serialization of custom props in longhand should be "" not value of shorthand
2926         https://bugs.webkit.org/show_bug.cgi?id=167699
2927         <rdar://problem/30324200>
2928
2929         Reviewed by Sam Weinig.
2930
2931         https://www.w3.org/TR/css-variables/#variables-in-shorthands says
2932         "Pending-substitution values must be serialized as the empty string, if
2933         an API allows them to be observed."
2934
2935         We were returning the cssText instead.
2936
2937         Test: fast/css/variables/rule-property-get.html has been updated.
2938
2939         * css/StyleProperties.cpp:
2940         (WebCore::StyleProperties::getPropertyValue): Return the empty string
2941         if we're a pending substitution value.
2942
2943 2017-03-24  Wenson Hsieh  <wenson_hsieh@apple.com>
2944
2945         Unreviewed, fix the ToT build on the latest SDK.
2946
2947         Add deprecated declaration guards around two synchronous UIItemProvider methods in WebItemProviderPasteboard.
2948         <rdar://problem/30451096> tracks adoption of the asynchronous versions of these methods.
2949
2950         * platform/ios/WebItemProviderPasteboard.mm:
2951         (-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
2952         (-[WebItemProviderPasteboard _tryToCreateAndAppendObjectOfClass:toArray:usingProvider:]):
2953
2954 2017-03-24  Antoine Quint  <graouts@webkit.org>
2955
2956         [Modern Media Controls] Captions don't move with the appearance of the inline controls
2957         https://bugs.webkit.org/show_bug.cgi?id=170051
2958         <rdar://problem/30754428>
2959
2960         Reviewed by Dean Jackson.
2961
2962         We now size the captions container to account for the controls bar height when visible. To do this,
2963         we use CSS variables to specify the height of the controls bar in default inline mode, compact inline
2964         mode and fullscreen mode.
2965
2966         Test: media/modern-media-controls/tracks-support/tracks-support-captions-offset-with-controls-bar.html
2967
2968         * Modules/modern-media-controls/controls/controls-bar.js:
2969         (ControlsBar.prototype.set faded):
2970         Notify the hosting MediaControls that the "faded" property changed.
2971
2972         * Modules/modern-media-controls/controls/ios-inline-media-controls.css:
2973         (.media-controls.ios.inline > .controls-bar):
2974         Use the new --inline-controls-bar-height CSS variable to specify the inline bar height.
2975
2976         * Modules/modern-media-controls/controls/macos-compact-inline-media-controls.css:
2977         (.media-controls.mac.inline.compact > .controls-bar):
2978         Use the new --inline-compact-controls-bar-height CSS variable to specify the inline bar height.
2979
2980         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.css:
2981         (.media-controls.mac.fullscreen > .controls-bar):
2982         Use the new --fullscreen-controls-bar-height CSS variable to specify the inline bar height.
2983
2984         * Modules/modern-media-controls/controls/macos-inline-media-controls.css:
2985         (.media-controls.mac.inline > .controls-bar):
2986         Use the new --inline-controls-bar-height CSS variable to specify the inline bar height.
2987
2988         * Modules/modern-media-controls/controls/media-controls.css:
2989         (*):
2990         Specify new CSS variables for the various controls bar heights.
2991
2992         * Modules/modern-media-controls/controls/media-controls.js:
2993         (MediaControls.prototype.controlsBarFadedStateDidChange):
2994         Notify the delegate of a controls bar "faded" property change. 
2995
2996         * Modules/modern-media-controls/controls/text-tracks.css:
2997         (video::-webkit-media-text-track-container):
2998         (video::-webkit-media-text-track-container.visible-controls-bar):
2999         (video::-webkit-media-text-track-container.visible-controls-bar.compact-controls-bar):
3000         (video::-webkit-media-text-track-display):
3001         Shorten the height of the captions container when the controls bar is visible. We also
3002         fix a couple of prefixed properties that didn't need to be.
3003
3004         * Modules/modern-media-controls/media/media-controller.js:
3005         (MediaController.prototype.controlsBarFadedStateDidChange):
3006         (MediaController.prototype._updateControlsIfNeeded):
3007         (MediaController.prototype._updateTextTracksClassList):
3008         (MediaController):
3009         Ensure we reflect the "faded" state of the controls bar on the captions container using
3010         a CSS class, as well as whether the controls bar mode is compact.
3011
3012 2017-03-24  Brent Fulgham  <bfulgham@apple.com>
3013
3014         Handle recursive calls to ProcessingInstruction::checkStyleSheet
3015         https://bugs.webkit.org/show_bug.cgi?id=169982
3016         <rdar://problem/31083051>
3017
3018         Reviewed by Antti Koivisto.
3019
3020        See if we triggered a recursive load of the stylesheet during the 'beforeload'
3021        event handler. If so, reset to a valid state before completing the load.
3022
3023        We should also check after 'beforeload' that we were not disconnected from (or
3024        moved to a new) document.
3025
3026        I also looked for other cases of this pattern and fixed them, too.
3027
3028        Tests: fast/dom/beforeload/image-removed-during-before-load.html
3029                fast/dom/beforeload/recursive-css-pi-before-load.html
3030                fast/dom/beforeload/recursive-link-before-load.html
3031                fast/dom/beforeload/recursive-xsl-pi-before-load.html
3032
3033         * dom/ProcessingInstruction.cpp:
3034         (WebCore::ProcessingInstruction::clearExistingCachedSheet): Added.
3035         (WebCore::ProcessingInstruction::checkStyleSheet): Prevent recursive calls into
3036         this function during 'beforeload' handling. Also, safely handle the case where
3037         the element was disconnected in the 'beforeload' handler (similar to what
3038         we do in HTMLLinkElement).
3039         (WebCore::ProcessingInstruction::setCSSStyleSheet): Drive-by Fix: Protect the
3040         current document to match what we do in setXSLStyleSheet.
3041         * dom/ProcessingInstruction.h:
3042         * html/HTMLLinkElement.cpp:
3043         (WebCore::HTMLLinkElement::process): Prevent recursive calls into
3044         this function during 'beforeload' handling.
3045         * html/HTMLLinkElement.h:
3046         * loader/ImageLoader.cpp:
3047         (WebCore::ImageLoader::dispatchPendingBeforeLoadEvent): safely handle the case where
3048         the element was disconnected in the 'beforeload' handler (similar to what
3049         we do in HTMLLinkElement).
3050         * style/StyleScope.cpp:
3051         (WebCore::Style::Scope::hasPendingSheet): Added.
3052         * style/StyleScope.h:
3053
3054 2017-03-24  Brady Eidson  <beidson@apple.com>
3055
3056         A null compound index value crashes the Databases process.
3057         <rdar://problem/30499831> and https://bugs.webkit.org/show_bug.cgi?id=170000
3058
3059         Reviewed by Alex Christensen.
3060
3061         Test: storage/indexeddb/modern/single-entry-index-invalid-key-crash.html
3062
3063         * bindings/js/IDBBindingUtilities.cpp:
3064         (WebCore::createKeyPathArray): Fix the bug by rejecting arrays with any invalid keys in them.
3065         
3066         Add some logging:
3067         * Modules/indexeddb/IDBKeyPath.cpp:
3068         (WebCore::loggingString):
3069         * Modules/indexeddb/IDBKeyPath.h:
3070         * Modules/indexeddb/IDBObjectStore.cpp:
3071         (WebCore::IDBObjectStore::createIndex):
3072         * Modules/indexeddb/shared/IDBIndexInfo.cpp:
3073         (WebCore::IDBIndexInfo::loggingString):
3074
3075 2017-03-24  Ryan Haddad  <ryanhaddad@apple.com>
3076
3077         Unreviewed, rolling out r214360.
3078
3079         This change caused 20+ LayoutTest failures.
3080
3081         Reverted changeset:
3082
3083         "Handle recursive calls to
3084         ProcessingInstruction::checkStyleSheet"
3085         https://bugs.webkit.org/show_bug.cgi?id=169982
3086         http://trac.webkit.org/changeset/214360
3087
3088 2017-03-24  Youenn Fablet  <youenn@apple.com>
3089
3090         Add support for qpSum in WebRTC stats
3091         https://bugs.webkit.org/show_bug.cgi?id=170060
3092
3093         Reviewed by Eric Carlson.
3094
3095         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
3096         (WebCore::fillRTCRTPStreamStats): exposing libwebrtc qpSum value.
3097
3098 2017-03-24  Daniel Bates  <dabates@apple.com>
3099
3100         Prevent new navigations during document unload
3101         https://bugs.webkit.org/show_bug.cgi?id=169934
3102         <rdar://problem/31247584>
3103
3104         Reviewed by Chris Dumez.
3105
3106         Similar to our policy of preventing new navigations from onbeforeunload handlers
3107         we should prevent new navigations that are initiated during the document unload
3108         process.
3109
3110         The significant part of this change is the instantiation of the RAII object NavigationDisabler
3111         in Document::prepareForDestruction(). The rest of this change just renames class
3112         NavigationDisablerForBeforeUnload to NavigationDisabler now that this RAII class is
3113         used to prevent navigation from both onbeforeunload event handlers and when unloading
3114         a document.
3115
3116         Test: fast/frames/frame-unload-navigate-and-setTimeout-assert-fail.html
3117
3118         * dom/Document.cpp:
3119         (WebCore::Document::prepareForDestruction): Disable new navigations when disconnecting
3120         subframes. Also assert that the document is not in the page cache before we fall off
3121         the end of the function.
3122         * loader/FrameLoader.cpp:
3123         (WebCore::FrameLoader::isNavigationAllowed): Update for renaming below.
3124         (WebCore::FrameLoader::shouldClose): Ditto.
3125         * loader/NavigationScheduler.cpp:
3126         (WebCore::NavigationScheduler::shouldScheduleNavigation): Ditto.
3127         * loader/NavigationScheduler.h:
3128         (WebCore::NavigationDisabler::NavigationDisabler): Renamed class; formerly named NavigationDisablerForBeforeUnload.
3129         (WebCore::NavigationDisabler::~NavigationDisabler): Ditto.
3130         (WebCore::NavigationDisabler::isNavigationAllowed): Ditto.
3131         (WebCore::NavigationDisablerForBeforeUnload::NavigationDisablerForBeforeUnload): Deleted.
3132         (WebCore::NavigationDisablerForBeforeUnload::~NavigationDisablerForBeforeUnload): Deleted.
3133         (WebCore::NavigationDisablerForBeforeUnload::isNavigationAllowed): Deleted.
3134
3135 2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
3136
3137         Implement font-optical-sizing
3138         https://bugs.webkit.org/show_bug.cgi?id=168895
3139
3140         Reviewed by Dean Jackson.
3141
3142         Upon advice from Microsoft, the only input to optical sizing is just the
3143         font-size computed value. It is implemented by setting the 'opsz' font
3144         variation axis. Because the propery has such a simple grammar, the
3145         implementation is quite straightforward.
3146
3147         Test: fast/text/variations/optical-sizing.html
3148
3149         * css/CSSComputedStyleDeclaration.cpp:
3150         (WebCore::ComputedStyleExtractor::propertyValue):
3151         * css/CSSPrimitiveValueMappings.h:
3152         (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
3153         (WebCore::CSSPrimitiveValue::operator FontOpticalSizing):
3154         * css/CSSProperties.json:
3155         * css/parser/CSSParserFastPaths.cpp:
3156         (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
3157         (WebCore::CSSParserFastPaths::isKeywordPropertyID):
3158         * platform/graphics/FontCache.h:
3159         (WebCore::FontDescriptionKey::makeFlagsKey):
3160         * platform/graphics/FontDescription.h:
3161         (WebCore::FontDescription::opticalSizing):
3162         (WebCore::FontDescription::setOpticalSizing):
3163         (WebCore::FontDescription::operator==):
3164         (WebCore::FontCascadeDescription::initialOpticalSizing):
3165         * platform/graphics/cocoa/FontCacheCoreText.cpp:
3166         (WebCore::preparePlatformFont):
3167         (WebCore::fontWithFamily):
3168         (WebCore::FontCache::createFontPlatformData):
3169         (WebCore::FontCache::systemFallbackForCharacters):
3170         * platform/graphics/mac/FontCustomPlatformData.cpp:
3171         (WebCore::FontCustomPlatformData::fontPlatformData):
3172         * platform/text/TextFlags.h:
3173
3174 2017-03-24  Chris Dumez  <cdumez@apple.com>
3175
3176         Unreviewed, rolling out r214329.
3177
3178         Significantly regressed Speedometer
3179
3180         Reverted changeset:
3181
3182         "window.crypto.getRandomValues() uses the insecure RC4 RNG"
3183         https://bugs.webkit.org/show_bug.cgi?id=169623
3184         http://trac.webkit.org/changeset/214329
3185
3186 2017-03-24  Yoav Weiss  <yoav@yoav.ws>
3187
3188         Add a warning for unused link preloads.
3189         https://bugs.webkit.org/show_bug.cgi?id=165670
3190
3191         Reviewed by Youenn Fablet.
3192
3193         This patch adds a warning message, to warn developers that are using
3194         link preloads in cases where the downloaded resource is likely to
3195         remain unused.
3196
3197         Test: http/tests/preload/unused_preload_warning.html
3198
3199         * dom/Document.cpp:
3200         (WebCore::Document::prepareForDestruction): Stop the timer once the document is destructed.
3201         * loader/LinkPreloadResourceClients.h: Add shouldMarkAsReferenced overides for the LinkPreloadResourceClient classes.
3202         * loader/cache/CachedResource.cpp:
3203         (WebCore::CachedResource::addClientToSet): Make sure LinkPreloadResourceClients don't set resource to be referenced.
3204         * loader/cache/CachedResourceClient.h:
3205         (WebCore::CachedResourceClient::shouldMarkAsReferenced): Make sure that ResourceClients mark preloads as referenced by default.
3206         * loader/cache/CachedResourceLoader.cpp:
3207         (WebCore::CachedResourceLoader::CachedResourceLoader): Initialize timer.
3208         (WebCore::CachedResourceLoader::~CachedResourceLoader): Stop timer.
3209         (WebCore::CachedResourceLoader::warnUnusedPreloads): Iterate over m_preloads and issue a warning for non-referenced preloads.
3210         (WebCore::CachedResourceLoader::documentDidFinishLoadEvent): Trigger a timer if preloads weren't cleared at load time.
3211         (WebCore::CachedResourceLoader::warnUnusedPreloads): Triggered by the timer, and called CachedResourceLoader::warnUnusedPreloads.
3212         (WebCore::CachedResourceLoader::stopUnusedPreloadsTimer): Stop the timer.
3213
3214 2017-03-24  Brent Fulgham  <bfulgham@apple.com>
3215
3216         Handle recursive calls to ProcessingInstruction::checkStyleSheet
3217         https://bugs.webkit.org/show_bug.cgi?id=169982
3218         <rdar://problem/31083051>
3219
3220         Reviewed by Antti Koivisto.
3221
3222         See if we triggered a recursive load of the stylesheet during the 'beforeload'
3223         event handler. If so, reset to a valid state before completing the load.
3224
3225         We should also check after 'beforeload' that we were not disconnected from (or
3226         moved to a new) document.
3227
3228         I also looked for other cases of this pattern and fixed them.
3229
3230         Tests: fast/dom/beforeload/image-removed-during-before-load.html
3231                fast/dom/beforeload/recursive-css-pi-before-load.html
3232                fast/dom/beforeload/recursive-link-before-load.html
3233                fast/dom/beforeload/recursive-xsl-pi-before-load.html
3234
3235         * dom/ProcessingInstruction.cpp:
3236         (WebCore::ProcessingInstruction::clearExistingCachedSheet): Added.
3237         (WebCore::ProcessingInstruction::checkStyleSheet): Reset to valid state
3238         if necessary after the 'beforeload' handler. Also, safely handle the case where
3239         the element was disconnected in the 'beforeload' handler (similar to what
3240         we do in HTMLLinkElement).
3241         (WebCore::ProcessingInstruction::setCSSStyleSheet): Drive-by Fix: Protect the
3242         current document to match what we do in setXSLStyleSheet.
3243         * dom/ProcessingInstruction.h:
3244         * html/HTMLMediaElement.cpp:
3245         (WebCore::HTMLMediaElement::selectMediaResource): Safely handle the case where
3246         the element was disconnected in the 'beforeload' handler.
3247         (WebCore::HTMLMediaElement::selectNextSourceChild): Ditto.
3248         * loader/ImageLoader.cpp:
3249         (WebCore::ImageLoader::dispatchPendingBeforeLoadEvent): Ditto.
3250
3251 2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
3252
3253         font-style needs a new CSSValue to make CSSRule.cssText work correctly
3254         https://bugs.webkit.org/show_bug.cgi?id=169258
3255
3256         Reviewed by David Hyatt.
3257
3258         With variation fonts, font-style's value can't be captured in a CSSPrimitiveValue (nor any other subclass
3259         off CSSValue) any more. Instead, we need to create two new CSSValues which represent the grammar that font-
3260         style and it's associated @font-face descriptor accept.
3261
3262         The grammar of the font-style property is "normal | italic | oblique [ <<angle>> ]?"
3263         The grammar of the font-style descriptor is "normal | italic | oblique [ <<angle>> | <<angle>> <<angle>> ]?"
3264
3265         We currently still support numbers in place of the <<angle>> value (contrary to the spec). We will remove
3266         this support in https://bugs.webkit.org/show_bug.cgi?id=169357.
3267
3268         Tests: fast/text/font-selection-font-face-parse.html:
3269                fast/text/font-style-parse.html:
3270
3271         * CMakeLists.txt:
3272         * WebCore.xcodeproj/project.pbxproj:
3273         * css/CSSAllInOne.cpp:
3274         * css/CSSComputedStyleDeclaration.cpp:
3275         (WebCore::fontStyleFromStyle):
3276         (WebCore::fontShorthandValueForSelectionProperties):
3277         * css/CSSFontFace.cpp:
3278         (WebCore::calculateWeightRange):
3279         (WebCore::calculateStretchRange):
3280         (WebCore::calculateItalicRange):
3281         * css/CSSFontFaceSet.cpp:
3282         (WebCore::computeFontSelectionRequest):
3283         (WebCore::CSSFontFaceSet::matchingFaces):
3284         (WebCore::calculateWeightValue): Deleted.
3285         (WebCore::calculateStretchValue): Deleted.
3286         (WebCore::calculateStyleValue): Deleted.
3287         * css/CSSFontFaceSet.h:
3288         * css/CSSFontSelector.cpp:
3289         (WebCore::CSSFontSelector::addFontFaceRule):
3290         * css/CSSFontStyleRangeValue.cpp: Added.
3291         (WebCore::CSSFontStyleRangeValue::customCSSText):
3292         (WebCore::CSSFontStyleRangeValue::equals):
3293         * css/CSSFontStyleRangeValue.h: Added.
3294         * css/CSSFontStyleValue.cpp: Added.
3295         (WebCore::CSSFontStyleValue::customCSSText):
3296         (WebCore::CSSFontStyleValue::equals):
3297         * css/CSSFontStyleValue.h: Added.
3298         * css/CSSFontValue.cpp:
3299         (WebCore::CSSFontValue::customCSSText):
3300         * css/CSSFontValue.h:
3301         * css/CSSValue.cpp:
3302         (WebCore::CSSValue::equals):
3303         (WebCore::CSSValue::cssText):
3304         (WebCore::CSSValue::destroy):
3305         * css/CSSValue.h:
3306         (WebCore::CSSValue::isFontStyleValue):
3307         (WebCore::CSSValue::isFontStyleRangeValue):
3308         * css/FontFace.cpp:
3309         (WebCore::FontFace::style):
3310         (WebCore::FontFace::weight):
3311         (WebCore::FontFace::stretch):
3312         * css/StyleBuilderConverter.h:
3313         (WebCore::StyleBuilderConverter::convertFontWeightFromValue):
3314         (WebCore::StyleBuilderConverter::convertFontStretchFromValue):
3315         (WebCore::StyleBuilderConverter::convertFontStyleFromValue):
3316         (WebCore::StyleBuilderConverter::convertFontWeight):
3317         (WebCore::StyleBuilderConverter::convertFontStretch):
3318         (WebCore::StyleBuilderConverter::convertFontStyle):
3319         * css/parser/CSSPropertyParser.cpp:
3320         (WebCore::consumeFontStyle):
3321         (WebCore::consumeFontStyleRange):
3322         (WebCore::CSSPropertyParser::consumeSystemFont):
3323         (WebCore::CSSPropertyParser::consumeFont):
3324         * svg/SVGFontFaceElement.cpp:
3325         (WebCore::SVGFontFaceElement::parseAttribute):
3326
3327 2017-03-24  Alex Christensen  <achristensen@webkit.org>
3328
3329         REGRESSION: Content Blocker: Blocking "a[href*=randomString]" doesn't work
3330         https://bugs.webkit.org/show_bug.cgi?id=169167
3331
3332         Reviewed by Simon Fraser.
3333
3334         When testing content extensions, we have always called an API function that internally
3335         has called AtomicString::init somewhere before we start compiling the content extension.
3336         On iOS, though, we call [_WKUserContentExtensionStore compileContentExtensionForIdentifier:...]
3337         without having already called anything that calls AtomicString::init.  The new CSS parser is now
3338         failing to parse some selectors because CSSSelectorParser::defaultNamespace is returning starAtom,
3339         which is a null atomic string before AtomicString::init is called.
3340
3341         Covered by a new API test.
3342
3343         * contentextensions/ContentExtensionParser.cpp:
3344         (WebCore::ContentExtensions::isValidCSSSelector):
3345         (WebCore::ContentExtensions::loadAction):
3346         (WebCore::ContentExtensions::isValidSelector): Deleted.
3347         * contentextensions/ContentExtensionParser.h:
3348         Call AtomicString::init before checking if a css selector is valid.
3349
3350 2017-03-24  Youenn Fablet  <youenn@apple.com>
3351
3352         Add libwebrtc backend support for RTCRtpSender::replaceTrack
3353         https://bugs.webkit.org/show_bug.cgi?id=169841
3354
3355         Reviewed by Alex Christensen.
3356
3357         Tests: webrtc/audio-replace-track.html
3358                webrtc/video-replace-track.html
3359
3360         Adding support for replaceTrack for audio and video sources.
3361         Replacing tracks will always succeed for audio sources.
3362         For video tracks, it will only succeed if the video resolution is not greater.
3363         LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track.
3364
3365         Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution.
3366
3367         * Modules/mediastream/RTCRtpSender.cpp:
3368         (WebCore::RTCRtpSender::replaceTrack):
3369         * Modules/mediastream/RTCRtpSender.h:
3370         * Modules/mediastream/RTCRtpSender.idl:
3371         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
3372         (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack):
3373         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
3374         * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
3375         (WebCore::RealtimeOutgoingAudioSource::setSource):
3376         * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
3377     &n