b8ac6ac49bdfd6b4c5dd93476114a4da1c193749
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
2
3         Try to normalize variation ranges
4         https://bugs.webkit.org/show_bug.cgi?id=170119
5
6         Reviewed by Simon Fraser.
7
8         TrueType GX-style variation fonts use one particular scale for values on their
9         weight/width/slope axes - usually the values lie between -1 and 1 on that scale.
10         However, OpenType 1.8-style fonts use the CSS scale for values on these axes.
11         For the purposes of font selection, these values need to lie on the same scale.
12         However, when font selection is completed and the variation values are actually
13         being applied to the fonts, values which lie on the font's actual scale need to
14         be applied. This patch adds normalize*() and denormalize*() functions to perform
15         both of these operations. 
16
17         The conversion itself between the two scales isn't an exact mapping. Mapping
18         slope is just a linear relationship with 0deg <=> 0 and 20deg <=> 1 (as per the
19         CSS Fonts spec). Mapping widths is similar, it uses a 2-component piecewise
20         linear relationship which includes the values given in the Microsoft OpenType
21         spec for the OS/2 table's usWidthClass field. Weights are more difficult, so I
22         plotted the CSS weights and the GX-style weights for every style of San
23         Francisco, saw that the relationship appears to be linear, and ran a linear
24         regression to compute the line equation.
25
26         As for the actual discrimination of determining whether a font is a GX-style
27         font or not, we can use the presence of the 'STAT' table. This table didn't
28         exist when GX fonts were being created, and OpenType 1.8 variable fonts are
29         required to have this table.
30
31         Facebook uses the string ".SFNSText" in their @font-face blocks. This font is
32         a variation font, but uses the GX-style values. Facebook asks us to create
33         this font with a weight of 700, and because the values in the font are around
34         1.0, we were erroneously thinking that the font wasn't bold, so we were then
35         applying synthetic bold. This was causing text on facebook to look fuzzy and
36         ugly.
37
38         Test: fast/text/variations/font-selection-properties-expected.html
39
40         * platform/graphics/cocoa/FontCacheCoreText.cpp:
41         (WebCore::isGXVariableFont):
42         (WebCore::normalizeWeight):
43         (WebCore::normalizeSlope):
44         (WebCore::denormalizeWeight):
45         (WebCore::denormalizeWidth):
46         (WebCore::denormalizeSlope):
47         (WebCore::normalizeWidth):
48         (WebCore::preparePlatformFont): Instead of using FontSelectionValues for the
49         intermediate values, we should use floats instead. This is because
50         FontSelectionValues are fixed-point numbers with the denominator having 2 bits.
51         When using this data type to represent values on the GX scale, which are usually
52         between 0 and 1, you lose a lot of fidelity. Instead, our intermediate
53         calculations should be done with floats, and converted to FontSelectionValues at
54         the end when they are representative of values on the CSS scale.
55         (WebCore::stretchFromCoreTextTraits):
56         (WebCore::fontWeightFromCoreText):
57         (WebCore::extractVariationBounds):
58         (WebCore::variationCapabilitiesForFontDescriptor):
59         (WebCore::capabilitiesForFontDescriptor):
60
61 2017-03-29  Saam Barati  <sbarati@apple.com>
62
63         LinkBuffer and ExecutableAllocator shouldn't have anything to do with VM
64         https://bugs.webkit.org/show_bug.cgi?id=170210
65
66         Reviewed by Mark Lam.
67
68         * cssjit/SelectorCompiler.cpp:
69         (WebCore::SelectorCompiler::compileSelector):
70         (WebCore::SelectorCompiler::SelectorCodeGenerator::compile):
71
72 2017-03-29  Javier Fernandez  <jfernandez@igalia.com>
73
74         [css-align] Adapt self-alignment properties to the new baseline syntax
75         https://bugs.webkit.org/show_bug.cgi?id=170235
76
77         Reviewed by David Hyatt.
78
79         The baseline-position syntax has changed recently, so we need to update
80         the CSS properties using the old syntax. This patch address only the
81         self-alignment (align-self and justify-self) and default-alignment
82         (align-items and justify-items).
83
84         The content-distribution properties (align-content and justify-content)
85         will be updated in a follow up patch.
86
87         The new baseline syntax is "[first | last ]? baseline" which implies
88         modifying the parsing and computed value logic.
89
90         There are several layout tests affected by this change, so I'll update
91         them accordingly.
92
93         No new tests, just added/modified some cases to the tests we already have using the new baseline values.
94
95         * css/CSSComputedStyleDeclaration.cpp:
96         (WebCore::valueForItemPositionWithOverflowAlignment):
97         * css/CSSValueKeywords.in:
98         * css/StyleBuilderConverter.h:
99         (WebCore::StyleBuilderConverter::convertSelfOrDefaultAlignmentData):
100         * css/parser/CSSPropertyParser.cpp:
101         (WebCore::consumeBaselineKeyword):
102         (WebCore::consumeSelfPositionOverflowPosition):
103
104 2017-03-29  Chris Dumez  <cdumez@apple.com>
105
106         Animated SVG images are not paused in pages loaded in the background
107         https://bugs.webkit.org/show_bug.cgi?id=170043
108         <rdar://problem/31234412>
109
110         Reviewed by Simon Fraser.
111
112         Animated SVG images are not paused in pages loaded in the background. We rely
113         on FrameView::isOffscreen() to stop images animations in background tab (See
114         logic in RenderElement's shouldRepaintForImageAnimation()). This works fine
115         if a tab is visble and then becomes hidden (i.e. by switching to another
116         tab). However, in the case where the tab gets loaded while in the background
117         (e.g. opening link in new background tab, or session restore), then the
118         animations would not be paused, due to FrameView::isOffscreen() erroneously
119         returning false in this case.
120
121         Normally, the following chain of events happens:
122         - Page is visible, we construct a main frame and its FrameView for loading
123           the page. When a FrameView is constructed, we call FrameView::show() to
124           make it visible. Then, if the page becomes non-visible, we call
125           Page::setIsVisibleInternal(false) which calls FrameView::hide(). After
126           that, FrameView::isOffscreen() correctly returns true because we properly
127           called FrameView::hide().
128
129         However, when doing a load while the Page is hidden, the following was
130         happening:
131         - Page is not visible, we call Page::setIsVisibleInternal(false) which tries
132           to call FrameView::hide() for the main frame but it does not have a FrameView
133           yet (because the load has not started). We start the load and end up creating
134           a FrameView. The FrameView constructor was calling FrameView::show()
135           unconditionally, thus making the FrameView think is visible, even though its
136           page isn't. At this point, FrameView::isOffscreen() was returning false
137           and animations would keep running, even though the page is not visible.
138
139         To address the issue, we now call FrameView::show() in FrameView::create() only
140         if the Page is actually visible, instead of calling it unconditionally. If the
141         page ever becomes visible, Page::setIsVisibleInternal(true) will be called and
142         it will take care of calling FrameView::show() then.
143
144         Tests: svg/animations/animations-paused-in-background-page-iframe.html
145                svg/animations/animations-paused-in-background-page.html
146
147         * page/FrameView.cpp:
148         (WebCore::FrameView::create):
149
150 2017-03-29  Wenson Hsieh  <wenson_hsieh@apple.com>
151
152         Links with empty hrefs should not be drag sources
153         https://bugs.webkit.org/show_bug.cgi?id=170241
154         <rdar://problem/31305505>
155
156         Reviewed by Tim Horton.
157
158         The m_dragSouceAction member of DragController represents the drag source actions that are available to the
159         document, rather than the available actions given the dragging element. Thus, it is not correct to only check
160         that (m_dragSourceAction & DragSourceActionAttachment) before proceeding down the attachment dragging codepath.
161         This should be additionally guarded with a check that the element being dragged is, in fact, an attachment
162         element.
163
164         New API test (see Tools/ChangeLog).
165
166         * page/DragController.cpp:
167         (WebCore::DragController::startDrag):
168
169 2017-03-29  Jeremy Jones  <jeremyj@apple.com>
170
171         WebVideoFullscreenInterfaceAVKit needs a strong self ref before dispatching to the main thread.
172         https://bugs.webkit.org/show_bug.cgi?id=170129
173
174         Reviewed by David Kilzer.
175
176         No new tests becuase no new behavior.
177
178         Hold a strong reference to WebVideoFullscreenInterfaceAVKit when dispatching to the main thread.
179         Make WebVideoFullscreenInterfaceAVKit safe to retain from non-main thread.
180
181         * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
182         * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
183         (WebVideoFullscreenInterfaceAVKit::exitFullscreen):
184
185 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
186
187         [GCrypt] Add a Handle<> class to help with GCrypt object lifetime control
188         https://bugs.webkit.org/show_bug.cgi?id=170238
189
190         Reviewed by Michael Catanzaro.
191
192         The platform-specific CryptoAlgorithmHMAC implementation is modified
193         to showcase the GCrypt::Handle<> use. HandleDeleter<gcry_mac_hd_t>
194         is added accordingly.
195
196         * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
197         (WebCore::calculateSignature):
198
199 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
200
201         Variation fonts: Make sure that feature detection and preprocessor macros are right
202         https://bugs.webkit.org/show_bug.cgi?id=169518
203
204         Reviewed by Simon Fraser.
205
206         When I added variable fonts support, I made all OSes parse the newly accepted values,
207         instead of just the OSes which support variable fonts.
208
209         Test: fast/text/font-variations-feature-detection.html
210
211         * css/parser/CSSPropertyParser.cpp:
212         (WebCore::consumeFontStretch):
213         (WebCore::consumeFontStyle):
214         * css/parser/CSSPropertyParserHelpers.cpp:
215         (WebCore::CSSPropertyParserHelpers::divisibleBy100):
216         (WebCore::CSSPropertyParserHelpers::consumeFontWeightNumber):
217
218 2017-03-29  Antoine Quint  <graouts@apple.com>
219
220         [Modern Media Controls] Controls bar may disappear while captions menu is visible (redux)
221         https://bugs.webkit.org/show_bug.cgi?id=170239
222         <rdar://problem/31320685>
223
224         Reviewed by Dean Jackson.
225
226         We did some work in webkit.org/b/168751 to prevent the controls bar from disappearing while the
227         captions menu is visible. But there were two cases where the behavior was not as intended:
228
229             1. the controls bar would hide upon exiting the video.
230             2. clicking on the controls bar while the caption panel is up would hide the controls bar
231                as well as the captions panel.
232
233         Instead of determining that the "userInteractionEnabled" property being set to "false" is indicative
234         of secondary UI, such as the tracks panel, being attached to the controls bar, we now have an
235         explicit property to specify this. Now, when "hasSecondaryUIAttached" is "true", we prevent the
236         controls bar from fading when exiting the media.
237
238         Additionally, when dismissing the tracks panel, we check whether a mouse event lead to this and check
239         if the mouse was positioned over the controls bar. If that is the case, we no longer hide the controls
240         bar and only dismiss the tracks panel.
241
242         Test: media/modern-media-controls/tracks-panel/tracks-panel-controls-bar-remains-visible-after-clicking-over-it.html
243
244         * Modules/modern-media-controls/controls/controls-bar.js:
245         (ControlsBar.prototype.set userInteractionEnabled):
246         (ControlsBar.prototype.handleEvent):
247         (ControlsBar.prototype._autoHideTimerFired):
248         * Modules/modern-media-controls/controls/macos-media-controls.js:
249         (MacOSMediaControls.prototype.showTracksPanel):
250         (MacOSMediaControls.prototype.hideTracksPanel):
251
252 2017-03-29  Antoine Quint  <graouts@apple.com>
253
254         [Modern Media Controls] Volume slider is initially empty
255         https://bugs.webkit.org/show_bug.cgi?id=170237
256         <rdar://problem/31319077>
257
258         Reviewed by Dean Jackson.
259
260         Fixing fallout from https://bugs.webkit.org/show_bug.cgi?id=167935 where we changed the behavior
261         of layout() to happen prior to a commit. In this one instance, we were overriding layout() to run
262         after a commit, so we now override commit(). Otherwise, the <canvas> that we draw the volume slider
263         into would have its "width" and "height" properties set after we drew, which would clear the <canvas>.
264
265         * Modules/modern-media-controls/controls/slider.js:
266         (Slider.prototype.commit):
267         (Slider.prototype.layout): Deleted.
268
269 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
270
271         [GCrypt] Move over empty GnuTLS-based SUBTLE_CRYPTO implementation files
272         https://bugs.webkit.org/show_bug.cgi?id=170232
273
274         Reviewed by Michael Catanzaro.
275
276         Migrate the GnuTLS SUBTLE_CRYPTO implementation files to the gcrypt/
277         directory. The implementation files themselves are no-op, so this is
278         a simple move-and-rename operation that will enable proceeding with
279         the libgcrypt-based implementation of SUBTLE_CRYPTO functionality.
280
281         No change in behavior. The SUBTLE_CRYPTO feature should build as it
282         did before, and the implementations are empty anyway.
283
284         * PlatformGTK.cmake:
285         * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp.
286         * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CFBGnuTLS.cpp.
287         * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_GCMGnuTLS.cpp.
288         * crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_KWGnuTLS.cpp.
289         * crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmECDHGnuTLS.cpp.
290         * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmPBKDF2GnuTLS.cpp.
291         * crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp.
292         * crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp: This one already exists.
293         * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp.
294         * crypto/gcrypt/CryptoAlgorithmRegistryGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRegistryGnuTLS.cpp.
295         * crypto/gcrypt/CryptoKeyECGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp.
296         * crypto/gcrypt/CryptoKeyRSAGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp.
297         * crypto/gcrypt/SerializedCryptoKeyWrapGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/SerializedCryptoKeyWrapGnuTLS.cpp.
298         * crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp: Removed.
299
300 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
301
302         [GnuTLS] Remove unused CryptoDigestGnuTLS, CryptoAlgorithmHMACGnuTLS implementation files
303         https://bugs.webkit.org/show_bug.cgi?id=170231
304
305         Reviewed by Michael Catanzaro.
306
307         * crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp: Removed. The GCrypt counterpart
308         is already in use, and this file wasn't even being built.
309
310 2017-03-29  Youenn Fablet  <youenn@apple.com>
311
312         Move DTMF WebRTC extension behind its own compile flag
313         https://bugs.webkit.org/show_bug.cgi?id=170226
314
315         Reviewed by Eric Carlson.
316
317         Moving RTCDTMFSender and RTCDTMFToneChangeEvent behinf a WEB_RTC_DTMF compile flag.
318         This compile flag is not set on any supported platform yet.
319         Disabling related test and updated test expectations.
320
321         * Modules/mediastream/RTCDTMFSender.cpp:
322         * Modules/mediastream/RTCDTMFSender.h:
323         * Modules/mediastream/RTCDTMFSender.idl:
324         * Modules/mediastream/RTCDTMFToneChangeEvent.cpp:
325         * Modules/mediastream/RTCDTMFToneChangeEvent.h:
326         * Modules/mediastream/RTCDTMFToneChangeEvent.idl:
327         * dom/EventNames.in:
328         * dom/EventTargetFactory.in:
329         * platform/mediastream/RTCDTMFSenderHandler.h:
330         * platform/mediastream/RTCDTMFSenderHandlerClient.h:
331
332 2017-03-29  Antoine Quint  <graouts@apple.com>
333
334         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
335         https://bugs.webkit.org/show_bug.cgi?id=168409
336         <rdar://problem/30799198>
337
338         Reviewed by Dean Jackson.
339
340         Add a new internals setting to opt into ScriptedAnimationController logging through DOM events dispatched
341         through the document. This should allow this flaky test to get information as to why the frame isn't
342         firing when it times out.
343
344         * dom/ScriptedAnimationController.cpp:
345         (WebCore::ScriptedAnimationController::suspend):
346         (WebCore::ScriptedAnimationController::resume):
347         (WebCore::ScriptedAnimationController::addThrottlingReason):
348         (WebCore::ScriptedAnimationController::removeThrottlingReason):
349         (WebCore::ScriptedAnimationController::registerCallback):
350         (WebCore::ScriptedAnimationController::cancelCallback):
351         (WebCore::ScriptedAnimationController::serviceScriptedAnimations):
352         (WebCore::ScriptedAnimationController::scheduleAnimation):
353         (WebCore::ScriptedAnimationController::dispatchLoggingEventIfRequired):
354         * dom/ScriptedAnimationController.h:
355         * page/Settings.in:
356         * testing/InternalSettings.cpp:
357         (WebCore::InternalSettings::resetToConsistentState):
358         (WebCore::InternalSettings::shouldDispatchRequestAnimationFrameEvents):
359         (WebCore::InternalSettings::setShouldDispatchRequestAnimationFrameEvents):
360         * testing/InternalSettings.h:
361         * testing/InternalSettings.idl:
362
363 2017-03-28  Youenn Fablet  <youenn@apple.com>
364
365         [WebRTC] After r214441 addIceCandidate no longer accepts an RTCIceCandidateInit dictionary
366         https://bugs.webkit.org/show_bug.cgi?id=170192
367
368         Reviewed by Jon Lee.
369
370         Covered by updated tests.
371
372         * Modules/mediastream/RTCIceCandidate.idl: Candidate is no longer a required field in RTCIceCandidateInit.
373         * Modules/mediastream/RTCPeerConnectionInternals.js: Reworking defaultsToNull to handle both undefined and null cases.
374
375 2017-03-28  Youenn Fablet  <youenn@apple.com>
376
377         LibWebRTCProvider should allow setting encoder and decoder factories
378         https://bugs.webkit.org/show_bug.cgi?id=170212
379
380         Reviewed by Eric Carlson.
381
382         No change of behavior.
383         Adding the ability to set encoder/decoder libwebrtc factory getters.
384         Setting default cocoa factory getters.
385
386         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
387         (WebCore::staticFactoryAndThreads):
388         (WebCore::initializePeerConnectionFactoryAndThreads):
389         (WebCore::LibWebRTCProvider::setDecoderFactoryGetter):
390         (WebCore::LibWebRTCProvider::setEncoderFactoryGetter):
391         (WebCore::LibWebRTCProvider::setPeerConnectionFactory):
392         * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
393
394 2017-03-27  Brent Fulgham  <bfulgham@apple.com>
395
396         Only attach Attributes to a given element one time
397         https://bugs.webkit.org/show_bug.cgi?id=170125
398         <rdar://problem/31279676>
399
400         Reviewed by Chris Dumez.
401
402         Attach the attribute node to the Element before calling 'setAttributeInternal', since that method may cause
403         arbitrary JavaScript events to fire. 
404
405         Test: fast/dom/Attr/only-attach-attr-once.html
406
407         * dom/Element.cpp:
408         (WebCore::Element::attachAttributeNodeIfNeeded): Added.
409         (WebCore::Element::setAttributeNode): Use new method. Revise to attach attribute before calling 'setAttributeInternal'. 
410         (WebCore::Element::setAttributeNodeNS): Ditto.
411         * dom/Element.h:
412
413 2017-03-28  Youenn Fablet  <youenn@apple.com>
414
415         Stop RTCDataChannel when closing page
416         https://bugs.webkit.org/show_bug.cgi?id=170166
417
418         Reviewed by Eric Carlson.
419
420         Test: webrtc/datachannel/datachannel-gc.html
421
422         Making RTCDataChannel an ActiveDOMObject.
423         Closing the data channel backend and freeing upon close and stop.
424
425         * Modules/mediastream/RTCDataChannel.cpp:
426         (WebCore::RTCDataChannel::create):
427         (WebCore::RTCDataChannel::RTCDataChannel):
428         (WebCore::RTCDataChannel::close):
429         (WebCore::RTCDataChannel::stop):
430         * Modules/mediastream/RTCDataChannel.h:
431         * Modules/mediastream/RTCDataChannel.idl:
432         * Modules/mediastream/RTCPeerConnection.h:
433
434 2017-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
435
436         Ranges for variation font properties are not enforced
437         https://bugs.webkit.org/show_bug.cgi?id=169979
438
439         Reviewed by David Hyatt.
440
441         The spec specifies that:
442         - Font weights less than or equal to 0, or greater than or equal to 1000 are parse errors
443         - Font stretch values less than or equal to 0% are parse errors
444         - Font style values less than or equal to -90deg or greater than or equal to 90deg are parse errors
445
446         Test: fast/text/variations/out-of-bounds-selection-properties.html
447
448         * css/parser/CSSPropertyParser.cpp:
449         (WebCore::consumeFontWeightRange):
450         (WebCore::fontStretchIsWithinRange):
451         (WebCore::consumeFontStretch):
452         (WebCore::consumeFontStretchRange):
453         (WebCore::fontStyleIsWithinRange):
454         (WebCore::consumeFontStyle):
455         (WebCore::consumeFontStyleRange):
456
457 2017-03-28  Andy Estes  <aestes@apple.com>
458
459         [iOS] Crash in -[WebPreviewLoader failed] when running http/tests/multipart/policy-ignore-crash.php
460         https://bugs.webkit.org/show_bug.cgi?id=170197
461         <rdar://problem/30314067>
462
463         Reviewed by Brady Eidson.
464
465         If QuickLook conversion fails, we call ResourceLoader::didFail() with the NSError from
466         QuickLook, which will call back into PreviewLoader::didFail(). We only care about network
467         failures in PreviewLoader, not conversion failures, so check if
468         m_finishedLoadingDataIntoConverter is set before continuing (like we do in
469         PreviewLoader::didFinishLoading()).
470
471         Fixes crash in http/tests/multipart/policy-ignore-crash.php.
472
473         * loader/ios/PreviewLoader.mm:
474         (WebCore::PreviewLoader::didFail):
475
476 2017-03-28  Chris Dumez  <cdumez@apple.com>
477
478         Audio indicator is visible on uni-watch.com but there is no audible audio
479         https://bugs.webkit.org/show_bug.cgi?id=170200
480         <rdar://problem/31289132>
481
482         Reviewed by Eric Carlson.
483
484         Cherry-pick the following patch from Blink by <rtoy@chromium.org>:
485         - https://chromium.googlesource.com/chromium/src.git/+/439de5bb2a31384666db1a0e2dadb2b97d2f3ce4
486
487         When the gain of a GainNode is 0 or 1, the operation of the node can
488         be optimized.  When gain = 1, just copy the input to the output.  When
489         gain = 0; just zero out the output.  Currently, the input is
490         multiplied by the gain to produce the output.  This just optimizes the
491         multiplication away for the two special cases.
492
493         Also, have the GainNode set the silence hint if the gain is 0.
494
495         And fix a bug in processIfNecessary when unsilenceOutputs was causing the
496         silence hint to be cleared after the node's process method was finished
497         and may have set the silence hint.  The processing should come after
498         unsilenceOutputs to preserve any hints from processing the node.
499
500         * Modules/webaudio/AudioNode.cpp:
501         (WebCore::AudioNode::processIfNecessary):
502         * Modules/webaudio/GainNode.cpp:
503         (WebCore::GainNode::process):
504         * platform/audio/AudioBus.cpp:
505         (WebCore::AudioBus::copyWithGainFrom):
506
507 2017-03-28  Chris Dumez  <cdumez@apple.com>
508
509         Animated SVG images are not paused when outside viewport
510         https://bugs.webkit.org/show_bug.cgi?id=170155
511         <rdar://problem/31288893>
512
513         Reviewed by Antti Koivisto.
514
515         Make sure animated SVG images get paused when outside the viewport,
516         similarly to what was already done for animated GIF images. Also
517         make sure they are paused when they no longer have any renderers
518         using them.
519
520         Tests: svg/animations/animated-svg-image-outside-viewport-paused.html
521                svg/animations/animated-svg-image-removed-from-document-paused.html
522
523         * loader/cache/CachedImage.cpp:
524         (WebCore::CachedImage::didAddClient):
525         Restart the animation whenever a new CachedImage client is added. This
526         will cause us the re-evaluate if the animation should run. The animation
527         will pause again if the new renderer is not inside the viewport.
528
529         (WebCore::CachedImage::animationAdvanced):
530         Add a flag to newImageAnimationFrameAvailable() so that the renderers can
531         let us know if we can pause the animation. Pause the animation if all no
532         renderer requires it (i.e. they are all outside the viewport, or there
533         are no renderers).
534
535         * loader/cache/CachedImageClient.h:
536         (WebCore::CachedImageClient::newImageAnimationFrameAvailable):
537         By default, the CachedImageClients allow pausing. Only renderer will
538         potentially prevent pausing if they are inside the viewport.
539
540         * platform/graphics/BitmapImage.cpp:
541         (WebCore::BitmapImage::isAnimating):
542         * platform/graphics/BitmapImage.h:
543         * platform/graphics/Image.h:
544         (WebCore::Image::isAnimating):
545         Add isAnimating() flag on Image for layout testing purposes.
546
547         * rendering/RenderElement.cpp:
548         (WebCore::RenderElement::newImageAnimationFrameAvailable):
549         Set canPause flag to true if the renderer is not inside the viewport.
550
551         (WebCore::RenderElement::repaintForPausedImageAnimationsIfNeeded):
552         Call startAnimation() if the renderer is now visible to resume SVG
553         animations. Repainting is enough for GIF animations but not for SVG
554         animations, we have to explicitly resume them.
555
556         * rendering/RenderElement.h:
557         * rendering/RenderView.cpp:
558         (WebCore::RenderView::addRendererWithPausedImageAnimations):
559         (WebCore::RenderView::removeRendererWithPausedImageAnimations):
560         (WebCore::RenderView::resumePausedImageAnimationsIfNeeded):
561         * rendering/RenderView.h:
562         Store CachedImages with the renderers that have paused animations.
563         This is required for SVG where we need to explicitly resume the
564         animation on the CachedImage when the renderer becomes visible
565         again. Having access to the Image will also allow us to do smarter
566         visibility checks in RenderElement's shouldRepaintForImageAnimation(),
567         in the future.
568
569         * svg/SVGSVGElement.cpp:
570         (WebCore::SVGSVGElement::hasActiveAnimation):
571         * svg/SVGSVGElement.h:
572         Add hasActiveAnimation() method.
573
574         * svg/graphics/SVGImage.cpp:
575         (WebCore::SVGImage::startAnimation):
576         Check that animations are paused before starting them. This avoid
577         jumping due to unnecessary calls to rootElement->setCurrentTime(0).
578
579         (WebCore::SVGImage::isAnimating):
580         Add isAnimating() method for layout tests purposes.
581
582         * svg/graphics/SVGImage.h:
583         * svg/graphics/SVGImageClients.h:
584         Call animationAdvanced() on the observer instead of the generic
585         changedInRect() when the SVGImage is animating. This way, we go
586         through the same code path as GIF animations and we end up calling
587         CachedImage::animationAdvanced() which calls newImageAnimationFrameAvailable()
588         on RenderElement, which determines if the animation should keep
589         running or not.
590
591         * testing/Internals.cpp:
592         (WebCore::Internals::isImageAnimating):
593         * testing/Internals.h:
594         * testing/Internals.idl:
595         Add layout testing infrastructure.
596
597 2017-03-28  Antti Koivisto  <antti@apple.com>
598
599         Missing render tree position invalidation when tearing down renderers for display:contents subtree
600         https://bugs.webkit.org/show_bug.cgi?id=170199
601         <rdar://problem/31260856>
602
603         Reviewed by Zalan Bujtas.
604
605         Test: fast/shadow-dom/slot-renderer-teardown.html
606
607         * style/RenderTreeUpdater.cpp:
608         (WebCore::RenderTreeUpdater::updateElementRenderer):
609
610             Invalidate the render tree position in case we do a teardown for an element without renderer.
611
612 2017-03-28  Ryan Haddad  <ryanhaddad@apple.com>
613
614         Unreviewed, rolling out r214485.
615
616         This change caused LayoutTest crashes.
617
618         Reverted changeset:
619
620         "Stop RTCDataChannel when closing page"
621         https://bugs.webkit.org/show_bug.cgi?id=170166
622         http://trac.webkit.org/changeset/214485
623
624 2017-03-28  Anders Carlsson  <andersca@apple.com>
625
626         ApplePayShippingContactUpdate.idl shouldn't have status field
627         https://bugs.webkit.org/show_bug.cgi?id=170202
628         rdar://problem/31307106
629
630         Reviewed by Beth Dakin.
631
632         * Modules/applepay/ApplePaySession.cpp:
633         (WebCore::convertAndValidate):
634         If status isn't set, infer it based on whether there are errors present or not.
635
636         * Modules/applepay/ApplePayShippingContactUpdate.h:
637         Make status optional here; it's still used by the old code path.
638
639         * Modules/applepay/ApplePayShippingContactUpdate.idl:
640         Remove status here.
641
642 2017-03-28  Brian Burg  <bburg@apple.com>
643
644         Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
645         https://bugs.webkit.org/show_bug.cgi?id=169865
646         <rdar://problem/31250573>
647
648         Reviewed by Joseph Pecoraro.
649
650         Rewrite the network agent's command for disabling resource caching to use Page::setResourceCachingEnabled.
651         The old implementation was doing weird stuff like setting no-cache headers and evicting the
652         contents of the memory cache, neither of which is correct. The new approach has no side effects
653         on the network, disk, or memory cache so it can be turned on temporarily without causing problems.
654
655         New tests:
656         - http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html
657         - http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html
658
659         * inspector/InspectorNetworkAgent.h:
660         * inspector/InspectorNetworkAgent.cpp:
661         (WebCore::InspectorNetworkAgent::setCacheDisabled): Deleted.
662         (WebCore::InspectorNetworkAgent::setResourceCachingDisabled): Added.
663         Implement new command.
664
665         (WebCore::InspectorNetworkAgent::willSendRequest):
666         (WebCore::InspectorNetworkAgent::mainFrameNavigated):
667         Remove crufty attempts to break caches. I believe these are intended to defeat caching
668         proxies and similar middlemen, but this is just as likely to cause unusual loading behavior.
669
670         * page/Page.h:
671         (WebCore::Page::isResourceCachingDisabled):
672         (WebCore::Page::setResourceCachingDisabledOverride):
673         Add an override setting so that Web Inspector's override does not mess up the value
674         of isResourceCachingDisabled that may have been set by a WebKit API client.
675
676 2017-03-28  Youenn Fablet  <youenn@apple.com>
677
678         Fix addIceCandidate after r214441
679         https://bugs.webkit.org/show_bug.cgi?id=170146
680
681         Reviewed by Chris Dumez.
682
683         Covered by rebased test.
684
685         * Modules/mediastream/RTCPeerConnection.js:
686         (addIceCandidate): Setting function length to 1 and throwing if no parameter is passed.
687
688 2017-03-28  Youenn Fablet  <youenn@apple.com>
689
690         Stop RTCDataChannel when closing page
691         https://bugs.webkit.org/show_bug.cgi?id=170166
692
693         Reviewed by Eric Carlson.
694
695         Test: webrtc/datachannel/datachannel-gc.html
696
697         Making RTCDataChannel an ActiveDOMObject.
698         Closing the data channel backend and freeing upon close and stop.
699
700         * Modules/mediastream/RTCDataChannel.cpp:
701         (WebCore::RTCDataChannel::create):
702         (WebCore::RTCDataChannel::RTCDataChannel):
703         (WebCore::RTCDataChannel::close):
704         (WebCore::RTCDataChannel::stop):
705         * Modules/mediastream/RTCDataChannel.h:
706         * Modules/mediastream/RTCDataChannel.idl:
707         * Modules/mediastream/RTCPeerConnection.h:
708
709 2017-03-27  Simon Fraser  <simon.fraser@apple.com>
710
711         Enhance the touch region debug overlay to show regions for the different events
712         https://bugs.webkit.org/show_bug.cgi?id=170162
713
714         Reviewed by Tim Horton.
715
716         Have NonFastScrollableRegionOverlay use a different color for each region in EventTrackingRegions,
717         and to draw a legend showing what the colors mean.
718         
719         On Mac, this overlay displays the non-fast scrollable region (which we don't keep separate from the wheel event
720         region).
721
722         * page/DebugPageOverlays.cpp:
723         (WebCore::NonFastScrollableRegionOverlay::updateRegion):
724         (WebCore::touchEventRegionColors):
725         (WebCore::drawRightAlignedText):
726         (WebCore::NonFastScrollableRegionOverlay::drawRect):
727         (WebCore::RegionOverlay::drawRect):
728         (WebCore::RegionOverlay::drawRegion):
729
730 2017-03-27  Simon Fraser  <simon.fraser@apple.com>
731
732         Make sure the non-fast scrolling debug overlay is correctly updated
733         https://bugs.webkit.org/show_bug.cgi?id=170142
734
735         Reviewed by Tim Horton.
736
737         AsyncScrollingCoordinator::frameViewEventTrackingRegionsChanged() is called on a timer
738         from Document code, so the existing DebugPageOverlays::didLayout() call at the end
739         of FrameView::layout() wasn't sufficient to keep the non-fast scrollable region up-to-date
740         on iOS.
741
742         * page/scrolling/AsyncScrollingCoordinator.cpp:
743         (WebCore::AsyncScrollingCoordinator::frameViewEventTrackingRegionsChanged):
744
745 2017-03-28  Antoine Quint  <graouts@apple.com>
746
747         [Modern Media Controls] AirPlay placard text looks bad on 1x displays
748         https://bugs.webkit.org/show_bug.cgi?id=170183
749         <rdar://problem/30663416>
750
751         Reviewed by Dean Jackson.
752
753         Use subpixel antialiasing for all text in modern media controls.
754
755         * Modules/modern-media-controls/controls/media-controls.css:
756         (.media-controls-container,):
757
758 2017-03-28  Antoine Quint  <graouts@apple.com>
759
760         [Modern Media Controls] Improve appearance of tracks panel on macOS
761         https://bugs.webkit.org/show_bug.cgi?id=168929
762         <rdar://problem/30741589>
763
764         Reviewed by Eric Carlson.
765
766         We use a solid color for the focus state that matches the style used on macOS
767         and blend the titles the same way we blend other non-solid labels in the controls bar.
768
769         * Modules/modern-media-controls/controls/tracks-panel.css:
770         (.tracks-panel section):
771         (.tracks-panel section > h3):
772         (.tracks-panel section > ul > li:focus):
773
774 2017-03-28  Yoav Weiss  <yoav@yoav.ws>
775
776         Add a warning for unused link preloads.
777         https://bugs.webkit.org/show_bug.cgi?id=165670
778
779         Reviewed by Youenn Fablet.
780
781         Tests: http/tests/preload/single_download_preload_headers_charset.php
782                http/tests/preload/unused_preload_warning.html
783
784         * dom/Document.cpp:
785         (WebCore::Document::prepareForDestruction): Stop the timer once the document is destructed.
786         * loader/LinkPreloadResourceClients.h: Add shouldMarkAsReferenced overides for the LinkPreloadResourceClient classes.
787         * loader/cache/CachedResource.cpp:
788         (WebCore::CachedResource::addClientToSet): Make sure LinkPreloadResourceClients don't set resource to be referenced.
789         * loader/cache/CachedResourceClient.h:
790         (WebCore::CachedResourceClient::shouldMarkAsReferenced): Make sure that ResourceClients mark preloads as referenced by default.
791         * loader/cache/CachedResourceLoader.cpp:
792         (WebCore::CachedResourceLoader::CachedResourceLoader): Initialize timer.
793         (WebCore::CachedResourceLoader::~CachedResourceLoader): Stop timer.
794         (WebCore::CachedResourceLoader::documentDidFinishLoadEvent): Trigger a timer if preloads weren't cleared at load time.
795         (WebCore::CachedResourceLoader::stopUnusedPreloadsTimer): Stop the timer.
796         (WebCore::CachedResourceLoader::warnUnusedPreloads): Iterate over m_preloads and issue a warning for non-referenced preloads.
797         * loader/cache/CachedResourceLoader.h:
798         * page/DOMWindow.cpp:
799         (WebCore::DOMWindow::willDetachDocumentFromFrame): Clear Resource Timing buffer when document detaches, to avoid test flakiness.
800
801 2017-03-28  Antoine Quint  <graouts@apple.com>
802
803         REGRESSION: Double-clicking the captions button while the captions popover is open prevents the popover from being opened again
804         https://bugs.webkit.org/show_bug.cgi?id=170171
805         <rdar://problem/31095500>
806
807         Reviewed by Dean Jackson.
808
809         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
810         transition to complete before actually removing the panel from the node hierarchy, consecutive calls to hide then present
811         would fail to present the panel. We now use a private instance variable to track the presented state which is set immediately
812         as presentInParent() and hide() are called.
813
814         Test: media/modern-media-controls/tracks-support/tracks-support-show-panel-then-double-click-on-tracks-button.html
815
816         * Modules/modern-media-controls/controls/tracks-panel.js:
817         (TracksPanel.prototype.get presented):
818         (TracksPanel.prototype.presentInParent):
819         (TracksPanel.prototype.hide):
820
821 2017-03-28  Aaron Chu  <aaron_chu@apple.com>
822
823         AX: Media controls should be able to be re-activated after faded away
824         https://bugs.webkit.org/show_bug.cgi?id=170048
825         <rdar://problem/30157179>
826
827         Reviewed by Antoine Quint.
828
829         Added a "foucsin" listener for the controls bar so that when an element
830         within fires a "focusin" event, the controls bar reappears if it is faded.
831
832         Test: media/modern-media-controls/media-controls/media-controls-appear-when-focus.html
833
834         * Modules/modern-media-controls/controls/controls-bar.js:
835         (ControlsBar.prototype.handleEvent):
836
837 2017-03-28  Antoine Quint  <graouts@apple.com>
838
839         [Modern Media Controls] Improve media documents across macOS, iPhone and iPad
840         https://bugs.webkit.org/show_bug.cgi?id=169145
841         <rdar://problem/17048858>
842
843         Reviewed by Dean Jackson.
844
845         There were a variety of issues with media documents, some longstanding, and some specifically
846         about modern media controls.
847
848         One issue was that fullscreen and picture-in-picture buttons would show for audio media documents,
849         due to using a <video> element to load the audio file. We now have additional logic in MediaController
850         to identify if the loaded media is really an audio file, and using this information to hide the
851         fullscreen and picture-in-picture buttons.
852
853         Another issue was that we would inject style in MediaDocument.cpp that was specific to modern media
854         controls when we could have the modern-media-controls module injected CSS handle this styling. We now
855         use the injected style in the shadow root to size media documents based on the device characteristics
856         and ensuring that page styles are overridden.
857
858         We also simplify how MediaDocument.cpp sets the source of the media element to simply use the "src"
859         attribute and not a <source> element.
860
861         Finally, we introduce a MediaDocumentController class that is instantiated when we're dealing with
862         a media document to hide the controls while we determine the type of media we're loading (audio vs.
863         video) in order to apply the appropriate styling without flashes.
864
865         As a result of the new styles applied by the modern-media-controls module, media documents have a
866         similar behavior on macOS and iPad, where we only enforce a min-width for video allowing them
867         to play at their natural size otherwise, and enforcing a fixed width for audio. On iPhone however,
868         we want to always play the media at full width, with some padding in the case of audio.
869
870         Tests: media/modern-media-controls/fullscreen-support/fullscreen-support-disabled-video-with-audio-tracks-only.html
871                media/modern-media-controls/media-documents/ipad/media-document-audio-ios-sizing.html
872                media/modern-media-controls/media-documents/ipad/media-document-video-ios-sizing.html
873                media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html
874                media/modern-media-controls/media-documents/media-document-audio-mac-sizing.html
875                media/modern-media-controls/media-documents/media-document-video-ios-sizing.html
876                media/modern-media-controls/media-documents/media-document-video-mac-sizing.html
877                media/modern-media-controls/pip-support/pip-support-disabled-video-with-audio-tracks-only.html
878
879         * Modules/modern-media-controls/controls/ios-inline-media-controls.css:
880         (:host(audio) .media-controls.ios.inline > .controls-bar:before,):
881         (:host(audio) .media-controls.ios.inline > .controls-bar:before): Deleted.
882         * Modules/modern-media-controls/controls/macos-media-controls.css:
883         (:host(audio) .media-controls.mac.inline > .controls-bar,):
884         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint,):
885         (:host(audio) .media-controls.mac.inline > .controls-bar): Deleted.
886         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint): Deleted.
887         * Modules/modern-media-controls/controls/media-document.css: Copied from Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.css.
888         (:host(.media-document)):
889         (:host(.media-document.ready)):
890         (:host(.media-document.audio.mac)):
891         (:host(.media-document.audio.ipad)):
892         (:host(.media-document.audio.iphone)):
893         (:host(.media-document.video.mac)):
894         (:host(.media-document.video.ipad)):
895         (:host(.media-document.video.iphone)):
896         * Modules/modern-media-controls/js-files:
897         * Modules/modern-media-controls/media/fullscreen-support.js:
898         (FullscreenSupport.prototype.syncControl):
899         (FullscreenSupport):
900         * Modules/modern-media-controls/media/media-controller.js:
901         (MediaController):
902         (MediaController.prototype.get isAudio):
903         * Modules/modern-media-controls/media/media-document-controller.js: Copied from Source/WebCore/Modules/modern-media-controls/media/fullscreen-support.js.
904         (MediaDocumentController):
905         (MediaDocumentController.prototype.handleEvent):
906         (MediaDocumentController.prototype._mediaDocumentHasMetadata):
907         (MediaDocumentController.prototype._mediaDocumentHasSize):
908         * Modules/modern-media-controls/media/pip-support.js:
909         (PiPSupport.prototype.syncControl):
910         (PiPSupport):
911         * html/MediaDocument.cpp:
912         (WebCore::MediaDocumentParser::createDocumentStructure):
913
914 2017-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
915
916         Follow-up patch after r214364.
917         https://bugs.webkit.org/show_bug.cgi?id=168895
918
919         Unreviewed.
920
921         * platform/graphics/FontDescription.cpp:
922         (WebCore::FontDescription::FontDescription):
923
924 2017-03-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
925
926         REGRESSION(213764): Large images should not be decoded asynchronously when they are drawn on a canvas
927         https://bugs.webkit.org/show_bug.cgi?id=169771
928
929         Reviewed by Simon Fraser.
930
931         Sometimes we have to draw the image immediately like when a canvas calls  
932         drawImage. In this case we have to decode the image synchronously to guarantee
933         the drawing. Other times we need to decode with the native size of the image.
934         The animated images have to be decoded with native size always. Otherwise
935         the frame cache will be messed up if the same image is animated with different
936         sizes. Currently we always decode asynchronously with sizeForDrawing. We need
937         to decouple the decoding mode from the sizeForDrawing.
938
939         This patch introduce the DecodingOptions class which can store and compare the
940         following four cases:
941             -- Synchronous: The frame has be decoded with native size only.
942             -- Asynchronous + anySize: This is passed from the Image::draw() callers.
943             -- Asynchronous + fullSize: The image has to be decoded with its full size.
944             -- Asynchronous + sizeForDrawing: The image can be decoded with sizeForDrawing unless
945             it was decoded with either a full size or sizeForDrawing which is larger than the
946             requested sizeForDrawing.
947             
948         A new argument of type DecodingMode will be added to Image::draw() function.
949         Only when the drawing comes from the render tree, it will be Asynchronous.
950         Otherwise it will be Synchronous.
951
952         Tests: fast/images/animated-image-different-dest-size.html
953                fast/images/async-image-background-image.html
954                fast/images/async-image-canvas-draw-image.html
955
956         * WebCore.xcodeproj/project.pbxproj:
957         * platform/graphics/BitmapImage.cpp:
958         (WebCore::BitmapImage::frameImageAtIndexCacheIfNeeded): Gets the frame image, cache it synchronously if
959         the current one is invalid. frameImageAtIndex() returns whatever stored in the cache.
960         (WebCore::BitmapImage::nativeImage): Call frameImageAtIndexCacheIfNeeded() instead of frameImageAtIndex().
961         (WebCore::BitmapImage::nativeImageForCurrentFrame): Ditto.
962         (WebCore::BitmapImage::nativeImageOfSize): Ditto.
963         (WebCore::BitmapImage::framesNativeImages): Ditto.
964         (WebCore::BitmapImage::draw): Change the logic to do the following:
965         -- The animated image has to be decoded with its full size.
966         -- The animated image expects the current frame to be ready for drawing.
967         -- The large image decoding does not need to call internalStartAnimation().
968         -- The large image has to request async image decoding but draw the current one if it exists.
969         (WebCore::BitmapImage::drawPattern): Draw the pattern synchronously.
970         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImages): Delete the call to shouldUseAsyncDecodingForTesting()
971         since it is only applied for animated images.
972         (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages): Call shouldUseAsyncDecodingForAnimatedImageForTesting().
973         (WebCore::BitmapImage::internalStartAnimation): Request decoding with the full size.
974         (WebCore::BitmapImage::advanceAnimation): Call shouldUseAsyncDecodingForAnimatedImageForTesting().
975         (WebCore::BitmapImage::internalAdvanceAnimation): Assert the current frame is not being decoding asynchronously for any size.
976         (WebCore::BitmapImage::frameImageAtIndex): Deleted. Moved to the header file but with a new purpose: return
977         the current frame from the frame cache as is; do not cache a new one.
978         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImage): Deleted. Function was renamed to shouldUseAsyncDecodingForLargeImages.
979         (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImage): Deleted. Function was renamed to shouldUseAsyncDecodingForAnimatedImages.
980         * platform/graphics/BitmapImage.h:
981         * platform/graphics/CrossfadeGeneratedImage.cpp:
982         (WebCore::CrossfadeGeneratedImage::draw): Add a new argument of type DecodingMode.
983         * platform/graphics/CrossfadeGeneratedImage.h:
984         * platform/graphics/DecodingOptions.h: Added.
985         (WebCore::DecodingOptions::DecodingOptions): Default constructor: Synchronous mode.
986         (WebCore::DecodingOptions::operator==): Compares two DecodingOptions for equality.
987         (WebCore::DecodingOptions::isSynchronous): Is the frame decoded synchronously?
988         (WebCore::DecodingOptions::isAsynchronous): Is the frame decoded asynchronously?
989         (WebCore::DecodingOptions::isAsynchronousCompatibleWith): Is this DecodingOptions compatible with another one?
990         (WebCore::DecodingOptions::hasFullSize): Is the decoding mode asynchronous but for the image full size?
991         (WebCore::DecodingOptions::hasSizeForDrawing): Is this decoding mode asynchronous but for a sizeForDrawing?
992         (WebCore::DecodingOptions::sizeForDrawing): Returns the sizeForDrawing. m_decodingModeOrSize has to hold an IntSize.
993         (WebCore::DecodingOptions::maxDimension): Moved form ImageFrame.cpp.
994         (WebCore::DecodingOptions::has): A helper function.
995         (WebCore::DecodingOptions::hasDecodingMode): Does m_decodingModeOrSize a DecodingMode?
996         (WebCore::DecodingOptions::hasSize): Does m_decodingModeOrSize an IntSize?
997         * platform/graphics/GeneratedImage.h: Add a new argument of type DecodingMode.
998         * platform/graphics/GradientImage.cpp:
999         (WebCore::GradientImage::draw): Ditto.
1000         * platform/graphics/GradientImage.h: Ditto.
1001         * platform/graphics/GraphicsContext.cpp:
1002         (WebCore::GraphicsContext::drawImage): Pass the ImagePaintingOptions::m_DecodingMode to Image::draw().
1003         * platform/graphics/GraphicsContext.h:
1004         (WebCore::ImagePaintingOptions::ImagePaintingOptions): Add a new member of type DecodingMode to ImagePaintingOptions.
1005         * platform/graphics/Image.cpp:
1006         (WebCore::Image::drawTiled): Pass DecodingMode::Synchronous to Image::draw().
1007         * platform/graphics/Image.h: Add a new argument of type DecodingMode to Image::draw().
1008         * platform/graphics/ImageFrame.cpp:
1009         (WebCore::ImageFrame::operator=): Replace m_sizeForDrawing by m_decodingOptions.
1010         (WebCore::ImageFrame::hasNativeImage): Check if m_nativeImage is valid and the subsamplingLevels match.
1011         (WebCore::ImageFrame::hasFullSizeNativeImage): Checks hasNativeImage() and whether the image frame was
1012         decoded for the image full size.
1013         (WebCore::ImageFrame::hasDecodedNativeImageCompatibleWithOptions): Checks hasNativeImage() and the DecodingOptions match.
1014         (WebCore::maxDimension): Deleted. Moved to DecodingOptions.h.
1015         (WebCore::ImageFrame::isBeingDecoded): Deleted. The check for having an ImageFrame being decoded is
1016         moved to ImageFrameCache.
1017         (WebCore::ImageFrame::hasValidNativeImage): Deleted. No need to this function.
1018         * platform/graphics/ImageFrame.h:
1019         (WebCore::ImageFrame::hasNativeImage): Add an std::optional<SubsamplingLevel> argument.
1020         (WebCore::ImageFrame::hasFullSizeNativeImage): Checks whether the ImageFrame was decoded for the image full size.
1021         (WebCore::ImageFrame::enqueueSizeForDecoding): Deleted.
1022         (WebCore::ImageFrame::dequeueSizeForDecoding): Deleted.
1023         (WebCore::ImageFrame::clearSizeForDecoding): Deleted.
1024         (WebCore::ImageFrame::isBeingDecoded): Deleted.
1025         (WebCore::ImageFrame::sizeForDrawing): Deleted.
1026         (WebCore::ImageFrame::hasDecodedNativeImage): Deleted.
1027         The logic of knowing whether an ImageFrame is being decoded is moved to ImageFrameCache.
1028         * platform/graphics/ImageFrameCache.cpp:
1029         (WebCore::ImageFrameCache::cacheFrameMetadataAtIndex): Caches the metadata of an ImageFrame. If the NativeImage
1030         was decoded for a sizeForDrawing, the size of the ImageFrame will be the nativeImageSize(). Otherwise, the
1031         frameSizeAtIndex() will be called.
1032         (WebCore::ImageFrameCache::cacheFrameNativeImageAtIndex): Cache a new NativeImage which involves caching new
1033         metadata and updating the memory cache. No need to check if the existing native image is valid or not for the
1034         DecodingOptions. Actually it would be a bug if it happens. This is why cacheNativeImageForFrameRequest() asserts
1035         !frame.hasAsyncNativeImage() before calling cacheFrameNativeImageAtIndex().
1036         (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex): Cache new NativeImage which was decoded asynchronously.
1037         (WebCore::ImageFrameCache::startAsyncDecodingQueue): Call cacheAsyncFrameNativeImageAtIndex() instead of
1038         cacheNativeImageForFrameRequest() for clarity.
1039         (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Call hasAsyncNativeImage() instead of hasValidNativeImage()
1040         Call frameIsDecodingCompatibleWithOptionsAtIndex() instead of frame.isBeingDecoded(). Replace the call to enqueueSizeForDecoding()
1041         by appending the same ImageFrameRequest to m_frameCommitQueue.
1042         (WebCore::ImageFrameCache::isAsyncDecodingQueueIdle): Use m_frameCommitQueue to answer the question whether the decodingQueue is idle.
1043         (WebCore::ImageFrameCache::stopAsyncDecodingQueue): Use m_frameCommitQueue to loop through all the ImageFrames which are currently being decoded.
1044         (WebCore::ImageFrameCache::frameAtIndexCacheIfNeeded): For getting the metadata, this function needs a valid frame. If it is requested
1045         to decode the nativeImage, it has to do it synchronously.
1046         (WebCore::ImageFrameCache::singlePixelSolidColor): Don't cache the frame if it is an animated image or the size is not a single pixel.
1047         (WebCore::ImageFrameCache::frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex): Use m_frameCommitQueue to answer the question whether an ImageFrame
1048         is being decoded and is compatible with DecodingOptions.
1049         (WebCore::ImageFrameCache::frameHasFullSizeNativeImageAtIndex): Calls ImageFrame::hasFullNativeImage() for a frame. 
1050         (WebCore::ImageFrameCache::frameHasDecodedNativeImageCompatibleWithOptionsAtIndex): Calls ImageFrame::hasDecodedNativeImageCompatibleWithOptions() for a frame.
1051         (WebCore::ImageFrameCache::frameImageAtIndex): Returns the current NativeImage without caching.
1052         (WebCore::ImageFrameCache::frameImageAtIndexCacheIfNeeded): Returns the current NativeImage but cache it synchronously if needed.
1053         (WebCore::ImageFrameCache::setFrameNativeImageAtIndex): Deleted.
1054         (WebCore::ImageFrameCache::setFrameMetadataAtIndex): Deleted.
1055         (WebCore::ImageFrameCache::replaceFrameNativeImageAtIndex): Deleted.
1056         (WebCore::ImageFrameCache::frameIsBeingDecodedAtIndex): Deleted.
1057         (WebCore::ImageFrameCache::frameHasImageAtIndex): Deleted.
1058         (WebCore::ImageFrameCache::frameHasValidNativeImageAtIndex): Deleted.
1059         (WebCore::ImageFrameCache::frameHasDecodedNativeImage): Deleted.
1060         * platform/graphics/ImageFrameCache.h: Two ImageFrameRequest queues will be used.
1061         -- The existing one m_frameRequestQueue which is shared between the main thread and decoding thread. The requests will be
1062         dequeued from it before starting the decoding. The decoded NativeImage will be cached only on the main thread. The decoding
1063         thread is not blocked by the callOnMainThread(). This means there might be multiple ImageFrameRequests which were dequeued
1064         while their NativeImages have not been cached yet.
1065         -- A new one m_frameCommitQueue which is track all the ImageFrameRequests whose NativeImages have not been cached yet.
1066         (WebCore::ImageFrameCache::frameAtIndexCacheIfNeeded): Be explicit about caching the image frame. frameImageAtIndex()
1067         returns the current image frame without caching. frameAtIndexCacheIfNeeded(). returns the current image frame but cache
1068         it if needed.
1069         (WebCore::ImageFrameCache::ImageFrameRequest::operator==): Compares two ImageFrameRequests for equality.
1070         * platform/graphics/ImageSource.cpp:
1071         (WebCore::ImageSource::frameImageAtIndexCacheIfNeeded): 
1072         (WebCore::ImageSource::frameImageAtIndex): Deleted.
1073         * platform/graphics/ImageSource.h:
1074         (WebCore::ImageSource::requestFrameAsyncDecodingAtIndex): Change the type of the argument from IntSize to be const std::optional<IntSize>.
1075         (WebCore::ImageSource::frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex): Rename of frameIsBeingDecodedAtIndex(). Replace the argument of type
1076         std::optional<IntSize> by an argument of type DecodingOptions.
1077         (WebCore::ImageSource::frameHasFullSizeNativeImageAtIndex): A wrapper around the ImageFrameCache function.
1078         (WebCore::ImageSource::frameHasDecodedNativeImageCompatibleWithOptionsAtIndex): Ditto.
1079         (WebCore::ImageSource::frameImageAtIndex): Ditto.
1080         (WebCore::ImageSource::frameIsBeingDecodedAtIndex): Deleted.
1081         (WebCore::ImageSource::frameHasValidNativeImageAtIndex): Deleted.
1082         (WebCore::ImageSource::frameHasDecodedNativeImage): Deleted.
1083         * platform/graphics/NamedImageGeneratedImage.cpp:
1084         (WebCore::NamedImageGeneratedImage::draw): Add a new argument of type DecodingMode.
1085         * platform/graphics/NamedImageGeneratedImage.h: Ditto.
1086         * platform/graphics/cairo/ImageBufferCairo.cpp:
1087         (WebCore::ImageBuffer::draw): Add a new argument of type DecodingMode.
1088         * platform/graphics/cg/ImageDecoderCG.cpp:
1089         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument. Add a new handling
1090         for decoding asynchronously for the image full size.
1091         * platform/graphics/cg/ImageDecoderCG.h: Change the prototype of the function.
1092         * platform/graphics/cg/PDFDocumentImage.cpp:
1093         (WebCore::PDFDocumentImage::draw): Add a new argument of type DecodingMode.
1094         * platform/graphics/cg/PDFDocumentImage.h:
1095         * platform/graphics/win/ImageCGWin.cpp:
1096         (WebCore::BitmapImage::getHBITMAPOfSize): Pass DecodingMode::Synchronous to Image::draw().
1097         (WebCore::BitmapImage::drawFrameMatchingSourceSize): Ditto.
1098         * platform/graphics/win/ImageDecoderDirect2D.cpp:
1099         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument.
1100         * platform/graphics/win/ImageDecoderDirect2D.h: Change the prototype of the function.
1101         * platform/image-decoders/ImageDecoder.cpp: 
1102         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument.
1103         * platform/image-decoders/ImageDecoder.h: Change the prototype of the function.
1104         * rendering/RenderBoxModelObject.cpp:
1105         (WebCore::RenderBoxModelObject::paintFillLayerExtended): Draw the background image asynchronously if the image size is large.
1106         * rendering/RenderImage.cpp:
1107         (WebCore::RenderImage::paintIntoRect): Draw the background image element asynchronously if the image size is large.
1108         * svg/graphics/SVGImage.cpp:
1109         (WebCore::SVGImage::drawForContainer): Pass DecodingMode::Synchronous to draw().
1110         (WebCore::SVGImage::nativeImageForCurrentFrame): Ditto.
1111         (WebCore::SVGImage::nativeImage): Ditto.
1112         (WebCore::SVGImage::draw): Add a new argument of type DecodingMode.
1113         * svg/graphics/SVGImage.h: Change the prototype of the function.
1114         * svg/graphics/SVGImageForContainer.cpp:
1115         (WebCore::SVGImageForContainer::draw): Add a new argument of type DecodingMode.
1116         * svg/graphics/SVGImageForContainer.h: Change the prototype of the function.
1117
1118 2017-03-27  Youenn Fablet  <youenn@apple.com>
1119
1120         Activate release libwebrtc logging when WebRTC log channel is on
1121         https://bugs.webkit.org/show_bug.cgi?id=169659
1122
1123         Reviewed by Alex Christensen.
1124
1125         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
1126         (WebCore::initializePeerConnectionFactoryAndThreads):
1127
1128 2017-03-27  Antti Koivisto  <antti@apple.com>
1129
1130         Move visibleInViewportStateChanged callback from Element to render tree
1131         https://bugs.webkit.org/show_bug.cgi?id=170039
1132
1133         Reviewed by Zalan Bujtas.
1134
1135         Make it easier to use from the render tree.
1136
1137         Also for simplicity move the bits from RenderObject rare data to RenderElement.
1138         There is plenty of space there.
1139
1140         * dom/Element.h:
1141         (WebCore::Element::isVisibleInViewportChanged): Deleted.
1142         * html/HTMLMediaElement.h:
1143         * rendering/RenderElement.cpp:
1144         (WebCore::RenderElement::RenderElement):
1145         (WebCore::RenderElement::willBeDestroyed):
1146         (WebCore::RenderElement::registerForVisibleInViewportCallback):
1147         (WebCore::RenderElement::unregisterForVisibleInViewportCallback):
1148         (WebCore::RenderElement::setVisibleInViewportState):
1149         (WebCore::RenderElement::visibleInViewportStateChanged):
1150         * rendering/RenderElement.h:
1151         (WebCore::RenderElement::visibleInViewportState):
1152         * rendering/RenderObject.cpp:
1153         (WebCore::RenderObject::setIsRegisteredForVisibleInViewportCallback): Deleted.
1154         (WebCore::RenderObject::setVisibleInViewportState): Deleted.
1155         * rendering/RenderObject.h:
1156         (WebCore::RenderObject::hasOutlineAutoAncestor):
1157         (WebCore::RenderObject::RenderObjectRareData::RenderObjectRareData):
1158         (WebCore::RenderObject::isRegisteredForVisibleInViewportCallback): Deleted.
1159         (WebCore::RenderObject::visibleInViewportState): Deleted.
1160         * rendering/RenderVideo.cpp:
1161         (WebCore::RenderVideo::visibleInViewportStateChanged):
1162         * rendering/RenderVideo.h:
1163         * rendering/RenderView.cpp:
1164         (WebCore::RenderView::updateVisibleViewportRect):
1165
1166 2017-03-27  Youenn Fablet  <youenn@apple.com>
1167
1168         addIceCandidate should not throw if passed null or undefined
1169         https://bugs.webkit.org/show_bug.cgi?id=170118
1170
1171         Reviewed by Eric Carlson.
1172
1173         Covered by updated test.
1174
1175         A null/undefined candidate passed to addIceCandidate means end of Ice candidate..
1176
1177         * Modules/mediastream/PeerConnectionBackend.cpp:
1178         (WebCore::PeerConnectionBackend::addIceCandidate):
1179         * Modules/mediastream/PeerConnectionBackend.h:
1180         (WebCore::PeerConnectionBackend::endOfIceCandidates):
1181         * Modules/mediastream/RTCPeerConnection.cpp:
1182         (WebCore::RTCPeerConnection::queuedAddIceCandidate):
1183         * Modules/mediastream/RTCPeerConnection.h:
1184         * Modules/mediastream/RTCPeerConnection.idl:
1185         * Modules/mediastream/RTCPeerConnection.js:
1186         (addIceCandidate):
1187
1188 2017-03-27  Antti Koivisto  <antti@apple.com>
1189
1190         Allow the page to render before <link> stylesheet tags in body
1191         https://bugs.webkit.org/show_bug.cgi?id=149157
1192         <rdar://problem/24658830>
1193
1194         Reviewed by Simon Fraser.
1195
1196         Currently we block style and renderer building completely if document has any loading
1197         stylesheets. In case a script queries something layout dependent we construct the render
1198         tree with whatever style we have but block painting in it.
1199
1200         This patch changes behavior so that a loading stylesheet in body only blocks rendering for elements
1201         that are after it. The expectation is that such stylesheets rarely affect elements before them
1202         and the elements can be rendered without causing ugly visible styling changes.
1203
1204         The patch replaces the old flash-of-unstyled-content (FOUC) preventation mechanism with a more
1205         fine-grained one. Paint blocking is now done on per-renderer basis with based on isNonFinal flag in
1206         RenderStyle.
1207
1208         For stylesheets in head the behavior should be largely unchanged.
1209
1210         Test: http/tests/incremental/stylesheet-body-incremental-rendering.html
1211
1212         * css/StyleResolver.cpp:
1213         (WebCore::StyleResolver::pseudoStyleRulesForElement):
1214         * dom/Document.cpp:
1215         (WebCore::Document::Document):
1216         (WebCore::Document::resolveStyle):
1217         (WebCore::Document::updateLayoutIgnorePendingStylesheets):
1218
1219             Remove the old FOUC preventation state tracking.
1220
1221         (WebCore::Document::shouldScheduleLayout):
1222         (WebCore::Document::didRemoveAllPendingStylesheet):
1223
1224             Repaints will now get triggered by the normal style mechanism.
1225
1226         * dom/Document.h:
1227         (WebCore::Document::hasNodesWithNonFinalStyle):
1228         (WebCore::Document::setHasNodesWithNonFinalStyle):
1229
1230             Track if we need to recompute the style later because non-final or unstyled elements.
1231
1232         (WebCore::Document::didLayoutWithPendingStylesheets): Deleted.
1233         (WebCore::Document::hasNodesWithPlaceholderStyle): Deleted.
1234         (WebCore::Document::setHasNodesWithPlaceholderStyle): Deleted.
1235         * html/HTMLFrameSetElement.cpp:
1236         (WebCore::HTMLFrameSetElement::rendererIsNeeded):
1237         * page/FrameView.cpp:
1238         (WebCore::FrameView::qualifiesAsVisuallyNonEmpty):
1239
1240             Don't qualify as visually non-empty if we have loading stylesheets in head (even if there is
1241             a fouc-prevented render tree).
1242
1243         (WebCore::FrameView::fireLayoutRelatedMilestonesIfNeeded):
1244         * rendering/RenderBlock.cpp:
1245         (WebCore::RenderBlock::paintContents):
1246
1247             Instead of a global test, block painting if isNonFinal is set in the renderer's style.
1248
1249         * rendering/RenderLayer.cpp:
1250         (WebCore::shouldSuppressPaintingLayer):
1251         * rendering/style/RenderStyle.cpp:
1252         (WebCore::RenderStyle::changeRequiresRepaint):
1253
1254             The isNonFinal flag prevents painting so we need to trigger repaint when it gets cleared.
1255
1256         * rendering/style/RenderStyle.h:
1257         (WebCore::RenderStyle::isNotFinal):
1258         (WebCore::RenderStyle::setIsNotFinal):
1259         (WebCore::RenderStyle::isPlaceholderStyle): Deleted.
1260         (WebCore::RenderStyle::setIsPlaceholderStyle): Deleted.
1261
1262             There is no need for placeholder styles anymore. Reuse the bit for isNotFinal.
1263
1264         * rendering/style/StyleRareNonInheritedData.cpp:
1265         (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
1266         (WebCore::StyleRareNonInheritedData::operator==):
1267         * rendering/style/StyleRareNonInheritedData.h:
1268         * style/StyleScope.cpp:
1269         (WebCore::Style::Scope::analyzeStyleSheetChange):
1270         (WebCore::Style::Scope::updateActiveStyleSheets):
1271         * style/StyleTreeResolver.cpp:
1272         (WebCore::Style::TreeResolver::styleForElement):
1273         (WebCore::Style::TreeResolver::resolveElement):
1274
1275             If we have seens a loading stylesheet and don't have a renderer yet don't style the element.
1276             In case there is a renderer or we are ignoring pending sheets, resolve the style normally
1277             but mark it as non-final.
1278
1279         (WebCore::Style::makePlaceholderStyle): Deleted.
1280
1281 2017-03-27  Myles C. Maxfield  <mmaxfield@apple.com>
1282
1283         Test variation font ranges in the CSS Font Loading API
1284         https://bugs.webkit.org/show_bug.cgi?id=170022
1285
1286         Reviewed by Dean Jackson.
1287
1288         Test: fast/text/variations/font-loading-api-parse-ranges.html
1289
1290         Don't use keywords when reporting font variation range values.
1291
1292         * css/CSSComputedStyleDeclaration.cpp:
1293         (WebCore::ComputedStyleExtractor::fontNonKeywordWeightFromStyleValue):
1294         (WebCore::ComputedStyleExtractor::fontWeightFromStyleValue):
1295         (WebCore::ComputedStyleExtractor::fontNonKeywordStretchFromStyleValue):
1296         (WebCore::ComputedStyleExtractor::fontStretchFromStyleValue):
1297         (WebCore::ComputedStyleExtractor::fontNonKeywordStyleFromStyleValue):
1298         (WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
1299         * css/CSSComputedStyleDeclaration.h:
1300         * css/FontFace.cpp:
1301         (WebCore::FontFace::style):
1302         (WebCore::FontFace::weight):
1303         (WebCore::FontFace::stretch):
1304
1305 2017-03-27  Anders Carlsson  <andersca@apple.com>
1306
1307         Propagate shipping contact update errors
1308         https://bugs.webkit.org/show_bug.cgi?id=170141
1309         rdar://problem/31276576
1310
1311         Reviewed by Tim Horton.
1312
1313         * Modules/applepay/ApplePaySession.cpp:
1314         (WebCore::convertAndValidate):
1315
1316 2017-03-27  Ryan Haddad  <ryanhaddad@apple.com>
1317
1318         Unreviewed, rolling out r214411.
1319
1320         Two of the LayoutTests for this change time out on ios-
1321         simulator.
1322
1323         Reverted changeset:
1324
1325         "[Modern Media Controls] Improve media documents across macOS,
1326         iPhone and iPad"
1327         https://bugs.webkit.org/show_bug.cgi?id=169145
1328         http://trac.webkit.org/changeset/214411
1329
1330 2017-03-27  Antoine Quint  <graouts@apple.com>
1331
1332         [Modern Media Controls] Clicking on the tracks button when the tracks panel is up in a media document pauses the video
1333         https://bugs.webkit.org/show_bug.cgi?id=168517
1334         <rdar://problem/30577636>
1335
1336         Reviewed by Dean Jackson.
1337
1338         We completely turn off default event handling in MediaDocument.cpp since we're implementing the
1339         behavior we expect to pause and resume the video in the modern-media-controls module already. This
1340         gets rid of this odd case where the content would not see the "click" event while the C++ side would
1341         handle it and pause the video.
1342
1343         * Modules/modern-media-controls/media/media-controller.js:
1344         (MediaController):
1345         (MediaController.prototype.handleEvent):
1346         (MediaController.prototype._containerWasClicked): Deleted.
1347         * html/MediaDocument.cpp:
1348         (WebCore::MediaDocument::defaultEventHandler):
1349
1350 2017-03-27  Youenn Fablet  <youenn@apple.com>
1351
1352         Tighten RTCDatachannel creation and parameter getters
1353         https://bugs.webkit.org/show_bug.cgi?id=170081
1354
1355         Reviewed by Eric Carlson.
1356
1357         Covered by updated tests.
1358
1359         Adding some parameter checks when creating data channels.
1360         Making some getters nullable as per the spec.
1361
1362         * Modules/mediastream/RTCDataChannel.h:
1363         * Modules/mediastream/RTCDataChannel.idl:
1364         * Modules/mediastream/RTCPeerConnection.cpp:
1365         (WebCore::RTCPeerConnection::createDataChannel):
1366         * Modules/mediastream/RTCPeerConnection.idl:
1367         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
1368         (WebCore::LibWebRTCMediaEndpoint::createDataChannel):
1369         (WebCore::LibWebRTCMediaEndpoint::addDataChannel):
1370         * platform/mediastream/RTCDataChannelHandler.h:
1371         (): Deleted.
1372
1373 2017-03-27  Youenn Fablet  <youenn@apple.com>
1374
1375         Add support for RTCRtpReceiver/RTCRtpSender getParameters
1376         https://bugs.webkit.org/show_bug.cgi?id=170057
1377
1378         Reviewed by Alex Christensen.
1379
1380         Test: webrtc/video-getParameters.html
1381
1382         getParameters returns a dictionary of values taken from libwebrtc RtpReceiverInterface/RtpSenderInrterface objects.
1383         Added a direct link between WebCore RTCRtpReceiver and libwebrtc RtpReceiverInterface object.
1384         Making the link between WebCore RTCRtpSender and libwebrtc RtpSenderInrterface object through
1385         PeerConnectionBackend to keep the current architecture shared with OpenWebRTC.
1386         In the future, we should try to make the link more direct.
1387
1388         Added routines to support the conversion from libwebrtc to WebCore.
1389         Ensured that RTCRtpReceiver is cleaning its backend when being stopped.
1390
1391         * CMakeLists.txt:
1392         * DerivedSources.make:
1393         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
1394         (WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask):
1395         * Modules/mediastream/PeerConnectionBackend.h:
1396         (WebCore::PeerConnectionBackend::getParameters):
1397         * Modules/mediastream/RTCPeerConnection.cpp:
1398         (WebCore::RTCPeerConnection::doClose):
1399         (WebCore::RTCPeerConnection::getParameters):
1400         * Modules/mediastream/RTCPeerConnection.h:
1401         * Modules/mediastream/RTCRtpParameters.h: Added.
1402         * Modules/mediastream/RTCRtpParameters.idl: Added.
1403         * Modules/mediastream/RTCRtpReceiver.cpp:
1404         (WebCore::RTCRtpReceiver::RTCRtpReceiver):
1405         * Modules/mediastream/RTCRtpReceiver.h:
1406         (WebCore::RTCRtpReceiver::Backend::~Backend):
1407         (WebCore::RTCRtpReceiver::Backend::getParameters):
1408         (WebCore::RTCRtpReceiver::create):
1409         (WebCore::RTCRtpReceiver::stop):
1410         (WebCore::RTCRtpReceiver::setBackend):
1411         (WebCore::RTCRtpReceiver::getParameters):
1412         * Modules/mediastream/RTCRtpReceiver.idl:
1413         * Modules/mediastream/RTCRtpSender.cpp:
1414         (WebCore::RTCRtpSender::create):
1415         (WebCore::RTCRtpSender::RTCRtpSender):
1416         (WebCore::RTCRtpSender::replaceTrack):
1417         (WebCore::RTCRtpSender::getParameters):
1418         * Modules/mediastream/RTCRtpSender.h:
1419         (WebCore::RTCRtpSender::Backend::~Backend):
1420         (WebCore::RTCRtpSender::isStopped):
1421         (WebCore::RTCRtpSender::stop):
1422         * Modules/mediastream/RTCRtpSender.idl:
1423         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
1424         (WebCore::LibWebRTCMediaEndpoint::addTrack):
1425         (WebCore::LibWebRTCMediaEndpoint::addRemoteTrack):
1426         (WebCore::LibWebRTCMediaEndpoint::OnAddTrack):
1427         (WebCore::LibWebRTCMediaEndpoint::stop):
1428         (WebCore::fillEncodingParameters):
1429         (WebCore::fillHeaderExtensionParameters):
1430         (WebCore::fillCodecParameters):
1431         (WebCore::fillRtpParameters):
1432         (WebCore::RTCRtpReceiverBackend::getParameters):
1433         (WebCore::LibWebRTCMediaEndpoint::getRTCRtpSenderParameters):
1434         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
1435         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
1436         (WebCore::LibWebRTCPeerConnectionBackend::notifyAddedTrack):
1437         (WebCore::LibWebRTCPeerConnectionBackend::getParameters):
1438         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
1439         * WebCore.xcodeproj/project.pbxproj:
1440         * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
1441
1442 2017-03-27  Myles C. Maxfield  <mmaxfield@apple.com>
1443
1444         font variation properties don't need to accept numbers
1445         https://bugs.webkit.org/show_bug.cgi?id=169357
1446
1447         Reviewed by Antti Koivisto.
1448
1449         The CSS Fonts level 4 spec stabilized the grammar accepted by font-weight,
1450         font-style, and font-stretch. The changes are that font-style and
1451         font-stretch no longer accept raw numbers, and the @font-face descriptor
1452         ranges are now separated by spaces instead of slashes.
1453
1454         Tests: fast/text/font-selection-font-face-parse.html
1455                fast/text/font-selection-font-loading-api-parse.html
1456                fast/text/font-stretch-parse.html
1457                fast/text/font-style-parse.html
1458                fast/text/variations/font-selection-properties.html
1459
1460         * css/CSSComputedStyleDeclaration.cpp:
1461         (WebCore::ComputedStyleExtractor::fontWeightFromStyleValue):
1462         (WebCore::fontWeightFromStyle):
1463         (WebCore::ComputedStyleExtractor::fontStretchFromStyleValue):
1464         (WebCore::fontStretchFromStyle):
1465         (WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
1466         (WebCore::fontStyleFromStyle):
1467         * css/CSSComputedStyleDeclaration.h:
1468         * css/FontFace.cpp:
1469         (WebCore::FontFace::style):
1470         (WebCore::FontFace::weight):
1471         (WebCore::FontFace::stretch):
1472         (WebCore::rangeIsSingleValue): Deleted.
1473         * css/StyleBuilderConverter.h:
1474         (WebCore::StyleBuilderConverter::convertFontStretchFromValue):
1475         * css/parser/CSSPropertyParser.cpp:
1476         (WebCore::consumeFontWeightRange):
1477         (WebCore::consumeFontStretch):
1478         (WebCore::consumeFontStretchRange):
1479         (WebCore::consumeFontStyle):
1480         (WebCore::consumeFontStyleRange):
1481
1482 2017-03-27  Youenn Fablet  <youenn@apple.com>
1483
1484         Further optimize checkWebRTCAvailability
1485         https://bugs.webkit.org/show_bug.cgi?id=169147
1486
1487         Reviewed by Alex Christensen.
1488
1489         Tested locally by removing libwebrtc.dylib.
1490         Replacing dlopen check by checking an exported symbol, rtc::LogMessage::LogToDebug.
1491         This check is more efficient and accurate. It should work in more configurations than the previous one.
1492
1493         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
1494         (WebCore::isNullFunctionPointer):
1495         (WebCore::LibWebRTCProvider::webRTCAvailable):
1496
1497 2017-03-27  Myles C. Maxfield  <mmaxfield@apple.com>
1498
1499         Implement format specifier for variation fonts
1500         https://bugs.webkit.org/show_bug.cgi?id=169327
1501
1502         Reviewed by Simon Fraser.
1503
1504         Variation fonts require the format("woff-variations"), format("truetype-variations"),
1505         and format("opentype-variations") format specifies in @font-face rules.
1506
1507         Test: fast/text/variations/font-face-format.html
1508
1509         * platform/graphics/mac/FontCustomPlatformData.cpp:
1510         (WebCore::FontCustomPlatformData::supportsFormat):
1511
1512 2017-03-27  Myles C. Maxfield  <mmaxfield@apple.com>
1513
1514         Make sure animation works for font-weight, font-stretch, and font-style
1515         https://bugs.webkit.org/show_bug.cgi?id=169683
1516
1517         Reviewed by Simon Fraser.
1518
1519         Hook up animation code for FontSelectionValues.
1520
1521         Tests: animations/font-variations/font-stretch.html
1522                animations/font-variations/font-style.html
1523                animations/font-variations/font-weight.html
1524
1525         * page/animation/CSSPropertyAnimation.cpp:
1526         (WebCore::blendFunc):
1527         (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
1528         * rendering/style/RenderStyle.cpp:
1529         (WebCore::RenderStyle::setFontWeight):
1530         (WebCore::RenderStyle::setFontStretch):
1531         (WebCore::RenderStyle::setFontItalic):
1532         * rendering/style/RenderStyle.h:
1533         (WebCore::RenderStyle::fontWeight):
1534         (WebCore::RenderStyle::fontStretch):
1535         (WebCore::RenderStyle::fontItalic):
1536
1537 2017-03-27  Alex Christensen  <achristensen@webkit.org>
1538
1539         Make WebSockets work in network process
1540         https://bugs.webkit.org/show_bug.cgi?id=169930
1541
1542         Reviewed by Youenn Fablet.
1543
1544         Covered by 136 existing tests in http/tests/websocket/tests/hybi
1545         This also does fine with the 544 websocket tests in the web-platform-tests which we have not yet imported.
1546         Also added http/tests/websocket/tests/hybi/network-process-crash-error.html
1547         to test a new condition that couldn't happen before this move: the NetworkProcess crashing.
1548
1549         * Modules/websockets/WebSocketChannel.cpp:
1550         (WebCore::WebSocketChannel::fail):
1551         We were asserting that didCloseSocketStream was called.  It is still called,
1552         but not synchronously like it used to.  This assertion is now invalid, but tests
1553         that would hit it still pass.
1554         * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
1555         (WebCore::SocketStreamHandleImpl::platformSendInternal):
1556         CFWriteStreamCanAcceptBytes crashes if you give it a null parameter, and that can happen now.
1557         If we have no write stream, then we cannot write.  Tests that hit this pass still.
1558
1559 2017-03-27  Antoine Quint  <graouts@apple.com>
1560
1561         [Modern Media Controls] Improve media documents across macOS, iPhone and iPad
1562         https://bugs.webkit.org/show_bug.cgi?id=169145
1563         <rdar://problem/17048858>
1564
1565         Reviewed by Dean Jackson.
1566
1567         There were a variety of issues with media documents, some longstanding, and some specifically
1568         about modern media controls.
1569
1570         One issue was that fullscreen and picture-in-picture buttons would show for audio media documents,
1571         due to using a <video> element to load the audio file. We now have additional logic in MediaController
1572         to identify if the loaded media is really an audio file, and using this information to hide the
1573         fullscreen and picture-in-picture buttons.
1574
1575         Another issue was that we would inject style in MediaDocument.cpp that was specific to modern media
1576         controls when we could have the modern-media-controls module injected CSS handle this styling. We now
1577         use the injected style in the shadow root to size media documents based on the device characteristics
1578         and ensuring that page styles are overridden.
1579
1580         We also simplify how MediaDocument.cpp sets the source of the media element to simply use the "src"
1581         attribute and not a <source> element.
1582
1583         Finally, we introduce a MediaDocumentController class that is instantiated when we're dealing with
1584         a media document to hide the controls while we determine the type of media we're loading (audio vs.
1585         video) in order to apply the appropriate styling without flashes.
1586
1587         As a result of the new styles applied by the modern-media-controls module, media documents have a
1588         similar behavior on macOS and iPad, where we only enforce a min-width for video allowing them
1589         to play at their natural size otherwise, and enforcing a fixed width for audio. On iPhone however,
1590         we want to always play the media at full width, with some padding in the case of audio.
1591
1592         Tests: media/modern-media-controls/fullscreen-support/fullscreen-support-disabled-video-with-audio-tracks-only.html
1593                media/modern-media-controls/media-documents/ipad/media-document-audio-ios-sizing.html
1594                media/modern-media-controls/media-documents/ipad/media-document-video-ios-sizing.html
1595                media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html
1596                media/modern-media-controls/media-documents/media-document-audio-mac-sizing.html
1597                media/modern-media-controls/media-documents/media-document-video-ios-sizing.html
1598                media/modern-media-controls/media-documents/media-document-video-mac-sizing.html
1599                media/modern-media-controls/pip-support/pip-support-disabled-video-with-audio-tracks-only.html
1600
1601         * Modules/modern-media-controls/controls/ios-inline-media-controls.css:
1602         (:host(audio) .media-controls.ios.inline > .controls-bar:before,):
1603         (:host(audio) .media-controls.ios.inline > .controls-bar:before): Deleted.
1604         * Modules/modern-media-controls/controls/macos-media-controls.css:
1605         (:host(audio) .media-controls.mac.inline > .controls-bar,):
1606         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint,):
1607         (:host(audio) .media-controls.mac.inline > .controls-bar): Deleted.
1608         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint): Deleted.
1609         * Modules/modern-media-controls/controls/media-document.css: Added.
1610         (:host(.media-document)):
1611         (:host(.media-document.ready)):
1612         (:host(.media-document.audio.mac)):
1613         (:host(.media-document.audio.ipad)):
1614         (:host(.media-document.audio.iphone)):
1615         (:host(.media-document.video.mac)):
1616         (:host(.media-document.video.ipad)):
1617         (:host(.media-document.video.iphone)):
1618         * Modules/modern-media-controls/js-files:
1619         * Modules/modern-media-controls/media/fullscreen-support.js:
1620         (FullscreenSupport.prototype.syncControl):
1621         (FullscreenSupport):
1622         * Modules/modern-media-controls/media/media-controller.js:
1623         (MediaController):
1624         (MediaController.prototype.get isAudio):
1625         * Modules/modern-media-controls/media/media-document-controller.js: Added.
1626         (MediaDocumentController):
1627         (MediaDocumentController.prototype.handleEvent):
1628         (MediaDocumentController.prototype._mediaDocumentHasMetadata):
1629         (MediaDocumentController.prototype._mediaDocumentHasSize):
1630         * Modules/modern-media-controls/media/pip-support.js:
1631         (PiPSupport.prototype.syncControl):
1632         (PiPSupport):
1633         * html/MediaDocument.cpp:
1634         (WebCore::MediaDocumentParser::createDocumentStructure):
1635
1636 2017-03-25  Chris Dumez  <cdumez@apple.com>
1637
1638         REGRESSION(r214195): zillow.com header video doesn't resume when switching to another tab and back
1639         https://bugs.webkit.org/show_bug.cgi?id=170080
1640         <rdar://problem/31252522>
1641
1642         Reviewed by Eric Carlson.
1643
1644         The video header on zillow.com would pause when switching to another tab after r214195. On
1645         switching back to the zillow.com tab, we would resume the video but fail to take the poster
1646         away, making it look like the video is still paused.
1647
1648         We normally take the poster away when HTMLMediaElement::mediaPlayerFirstVideoFrameAvailable()
1649         is called. However, mediaPlayerFirstVideoFrameAvailable() was only ever called once because of
1650         the m_haveReportedFirstVideoFrame flag in MediaPlayerPrivateAVFoundation::updateStates().
1651         We now reset m_haveReportedFirstVideoFrame to false in updateStates() if hasAvailableVideoFrame()
1652         return false, so that we call mediaPlayerFirstVideoFrameAvailable() again when the return
1653         value of asAvailableVideoFrame() becomes true again (e.g. after the media session interruption
1654         has ended).
1655
1656         * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
1657         (WebCore::MediaPlayerPrivateAVFoundation::updateStates):
1658
1659 2017-03-24  Wenson Hsieh  <wenson_hsieh@apple.com>
1660
1661         [WK2] Add a UI delegate SPI hook to enable or disable navigation on drop
1662         https://bugs.webkit.org/show_bug.cgi?id=169168
1663         <rdar://problem/30688374>
1664
1665         Reviewed by Tim Horton.
1666
1667         Refactor client hooks for the drag destination action in WebCore to ask for the drag destination action mask
1668         upon initializing the DragData. In DragController, rather than setting m_dragDestinationAction to the result of
1669         m_client.actionMaskForDrag, we instead set it to the DragData's destination action.
1670
1671         Tests to come in a future patch.
1672
1673         * loader/EmptyClients.cpp:
1674         * page/DragClient.h:
1675
1676         Rather than pass in a DragData, pass in only the platform data that we need to hand to the delegate. This is
1677         because we now ask for drag destination actions prior to creating the DragData.
1678
1679         * page/DragController.cpp:
1680         (WebCore::DragController::dragEnteredOrUpdated):
1681
1682         Update the available drag destination actions in WebCore using the destination actions stored in DragData rather
1683         than calling out to the client delegate.
1684
1685         * loader/EmptyClients.cpp:
1686         * platform/DragData.cpp:
1687         (WebCore::DragData::DragData):
1688         * platform/DragData.h:
1689         (WebCore::DragData::dragDestinationAction):
1690         (WebCore::DragData::operator =):
1691         * platform/mac/DragDataMac.mm:
1692         (WebCore::DragData::DragData):
1693
1694 2017-03-25  Aaron Chu  <aaron_chu@apple.com>
1695
1696         AX: Media controls are unlabeled
1697         https://bugs.webkit.org/show_bug.cgi?id=169947
1698         <rdar://problem/30153323>
1699
1700         Reviewed by Antoine Quint.
1701
1702         Added a "label" property for Icons, which are used to set
1703         the aria-label for the controls in modern media controls.
1704
1705         Test: Addition to all existing modern media controls tests.
1706
1707         * English.lproj/modern-media-controls-localized-strings.js:
1708         * Modules/modern-media-controls/controls/icon-button.js:
1709         (IconButton.prototype.set iconName):
1710         (IconButton.prototype.handleEvent):
1711         (IconButton.prototype._loadImage):
1712         * Modules/modern-media-controls/controls/icon-service.js:
1713         * Modules/modern-media-controls/controls/start-button.js:
1714         (StartButton):
1715         * Modules/modern-media-controls/js-files:
1716
1717 2017-03-25  Carlos Garcia Campos  <cgarcia@igalia.com>
1718
1719         [XDG] MIMETypeRegistry::getMIMETypeForExtension should return a null/empty string when mime type is unknown
1720         https://bugs.webkit.org/show_bug.cgi?id=170050
1721
1722         Reviewed by Michael Catanzaro.
1723
1724         That's what the callers expect, but we alre always returning XDG_MIME_TYPE_UNKNOWN which is
1725         application/octet-stream.
1726
1727         Fixes: plugins/no-mime-with-valid-extension.html
1728
1729         * platform/xdg/MIMETypeRegistryXdg.cpp:
1730         (WebCore::MIMETypeRegistry::getMIMETypeForExtension):
1731
1732 2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
1733
1734         Add font-optical-sizing to CSSComputedStyleDeclaration
1735         https://bugs.webkit.org/show_bug.cgi?id=170083
1736
1737         Reviewed by Joseph Pecoraro.
1738
1739         Covered by existing tests.
1740
1741         * css/CSSComputedStyleDeclaration.cpp:
1742
1743 2017-03-24  Daniel Bates  <dabates@apple.com>
1744
1745         media/restore-from-page-cache.html causes NoEventDispatchAssertion::isEventAllowedInMainThread() assertion failure
1746         https://bugs.webkit.org/show_bug.cgi?id=170087
1747         <rdar://problem/31254822>
1748
1749         Reviewed by Simon Fraser.
1750
1751         Reduce the scope of code that should never dispatch DOM events so as to allow updating contents size
1752         after restoring a page from the page cache.
1753
1754         In r214014 we instantiate a NoEventDispatchAssertion in FrameLoader::commitProvisionalLoad()
1755         around the call to CachedPage::restore() to assert when a DOM event is dispatched during
1756         page restoration as such events can cause re-entrancy into the page cache. As it turns out
1757         it is sufficient to ensure that no DOM events are dispatched after restoring all cached frames
1758         as opposed to after CachedPage::restore() returns.
1759
1760         Also rename Document::enqueue{Pageshow, Popstate}Event() to dispatch{Pageshow, Popstate}Event(),
1761         respectively, since they synchronously dispatch events :(. We hope in the future to make them
1762         asynchronously dispatch events.
1763
1764         * dom/Document.cpp:
1765         (WebCore::Document::implicitClose): Update for renaming.
1766         (WebCore::Document::statePopped): Ditto.
1767         (WebCore::Document::dispatchPageshowEvent): Renamed; formerly named enqueuePageshowEvent().
1768         (WebCore::Document::dispatchPopstateEvent): Renamed; formerly named enqueuePopstateEvent().
1769         (WebCore::Document::enqueuePageshowEvent): Deleted.
1770         (WebCore::Document::enqueuePopstateEvent): Deleted.
1771         * dom/Document.h:
1772         * history/CachedPage.cpp:
1773         (WebCore::firePageShowAndPopStateEvents): Moved logic from FrameLoader::didRestoreFromCachedPage() to here.
1774         (WebCore::CachedPage::restore): Modified to call firePageShowAndPopStateEvents().
1775         * loader/FrameLoader.cpp:
1776         (WebCore::FrameLoader::commitProvisionalLoad): Removed use of NoEventDispatchAssertion RAII object. We
1777         will instantiate it in CachedPage::restore() with a smaller scope.
1778         (WebCore::FrameLoader::didRestoreFromCachedPage): Deleted; moved logic from here to WebCore::firePageShowAndPopStateEvents().
1779         * loader/FrameLoader.h:
1780
1781 2017-03-24  Ryan Haddad  <ryanhaddad@apple.com>
1782
1783         Unreviewed, rolling out r214361.
1784
1785         This change caused flakiness in http/tests/preload tests.
1786
1787         Reverted changeset:
1788
1789         "Add a warning for unused link preloads."
1790         https://bugs.webkit.org/show_bug.cgi?id=165670
1791         http://trac.webkit.org/changeset/214361
1792
1793 2017-03-24  Antoine Quint  <graouts@webkit.org>
1794
1795         [Modern Media Controls] Remove placard icon if height is compressed
1796         https://bugs.webkit.org/show_bug.cgi?id=167935
1797         <rdar://problem/30397128>
1798
1799         Reviewed by Dean Jackson.
1800
1801         We make the addition of certain Placard children conditional on the placard's metrics. Whenever the
1802         media controls metrics changes, the placard, if any, is set to have the same metrics and layout() is
1803         called where we ensure that there is enough space, per designs, to have the icon, description and even
1804         the title visible. We also make some CSS improvements to guarantee that the description is laid out on
1805         two lines at most and that both text labels are trimmed elegantly with an ellipsis shold the width be
1806         insufficient to display the whole text.
1807
1808         Since we would have needed to have more width/height setter overrides to trigger layout, we now make
1809         LayoutNode trigger layout() directly and remove the need for subclasses to do this on a per-class basis.
1810         We also make layout() a method that can be called safely anytime as it's now no longer part of the DOM
1811         commit step, a new commit() method is used instead of that.
1812
1813         Tests: media/modern-media-controls/layout-node/node-made-dirty-during-commit.html
1814                media/modern-media-controls/media-controls/media-controls-placard-compressed-metrics.html
1815
1816         * Modules/modern-media-controls/controls/layout-node.js:
1817         (LayoutNode.prototype.set width):
1818         (LayoutNode.prototype.set height):
1819         Trigger a call to layout() anytime "width" or "height" is set on any LayoutNode.
1820
1821         (LayoutNode.prototype.layout):
1822         (LayoutNode.prototype.commit):
1823         (performScheduledLayout):
1824         Make layout() an empty method that subclasses can override easily outside of the DOM commit cycle,
1825         its previous implementation is now called "commit()" which is a more accurate name.
1826
1827         * Modules/modern-media-controls/controls/media-controls.js:
1828         (MediaControls.prototype.get placard):
1829         (MediaControls.prototype.get showsPlacard):
1830         (MediaControls.prototype.showPlacard):
1831         (MediaControls.prototype.hidePlacard):
1832         (MediaControls.prototype.layout):
1833         (MediaControls.prototype.get width): Deleted.
1834         (MediaControls.prototype.set width): Deleted.
1835         Add a "placard" property to make it simpler to reference the placard instead of making assumptions in
1836         several places in that class on the children order. Anytime we run a layout or show the placard, ensure
1837         that the placard metrics are synced with the media controls metrics.
1838
1839         * Modules/modern-media-controls/controls/placard.css:
1840         (.placard .container):
1841         (.placard .title,):
1842         (.placard .description):
1843         We now ensure that both the title and description are trimmed with an ellipsis when we run out of space
1844         to display them fully.
1845
1846         * Modules/modern-media-controls/controls/placard.js:
1847         (Placard.):
1848         (Placard.prototype.layout):
1849         We add new constraints to only show the icon, title and description if the placard is tall and wide enough.
1850
1851         * Modules/modern-media-controls/controls/slider.js:
1852         (Slider.prototype.get width): Deleted.
1853         (Slider.prototype.set width): Deleted.
1854         Removed custom "width" getters and setters now we can just override layout() in case node metrics change.
1855
1856         * Modules/modern-media-controls/controls/time-control.js:
1857         (TimeControl.prototype.set useSixDigitsForTimeLabels):
1858         (TimeControl.prototype.layout):
1859         (TimeControl.prototype.get width): Deleted.
1860         (TimeControl.prototype.set width): Deleted.
1861         (TimeControl.prototype._availableWidthHasChanged): Deleted.
1862         Removed custom "width" getters and setters now we can just override layout() in case node metrics change.
1863
1864         * Modules/modern-media-controls/media/media-controller.js:
1865         (MediaController):
1866         Ensure we flush pending updates at construction time so that we match the size of the media controls right
1867         at the first media layout.
1868
1869 2017-03-24  Eric Carlson  <eric.carlson@apple.com>
1870
1871         [MediaStream] "ideal" constraints passed to getUserMedia should affect fitness score
1872         https://bugs.webkit.org/show_bug.cgi?id=170056
1873
1874         Reviewed by Youenn Fablet.
1875
1876         Include the fitness score calculated for ideal constraints in the calculation of a capture
1877         overall device fitness score. 
1878
1879         No new tests, existing tests updated.
1880
1881         * platform/mediastream/MediaConstraints.cpp:
1882         (WebCore::StringConstraint::fitnessDistance): Drive-by fix: return early if ideal is empty,
1883         not exact.
1884
1885         * platform/mediastream/RealtimeMediaSource.cpp:
1886         (WebCore::RealtimeMediaSource::supportsSizeAndFrameRate): Return fitness distance.
1887         (WebCore::RealtimeMediaSource::selectSettings): Include the fitness distance of supported
1888         ideal constraints.
1889         (WebCore::RealtimeMediaSource::supportsConstraint): New.
1890         (WebCore::RealtimeMediaSource::applyConstraints):
1891         * platform/mediastream/RealtimeMediaSource.h:
1892
1893         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
1894         (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints): Sort candidate sources
1895         by their fitness score.
1896
1897         * platform/mock/MockRealtimeVideoSource.cpp:
1898         (WebCore::MockRealtimeVideoSource::initializeCapabilities): Each video source should support
1899         one facing mode, not both.
1900
1901 2017-03-24  Dean Jackson  <dino@apple.com>
1902
1903         Serialization of custom props in longhand should be "" not value of shorthand
1904         https://bugs.webkit.org/show_bug.cgi?id=167699
1905         <rdar://problem/30324200>
1906
1907         Reviewed by Sam Weinig.
1908
1909         https://www.w3.org/TR/css-variables/#variables-in-shorthands says
1910         "Pending-substitution values must be serialized as the empty string, if
1911         an API allows them to be observed."
1912
1913         We were returning the cssText instead.
1914
1915         Test: fast/css/variables/rule-property-get.html has been updated.
1916
1917         * css/StyleProperties.cpp:
1918         (WebCore::StyleProperties::getPropertyValue): Return the empty string
1919         if we're a pending substitution value.
1920
1921 2017-03-24  Wenson Hsieh  <wenson_hsieh@apple.com>
1922
1923         Unreviewed, fix the ToT build on the latest SDK.
1924
1925         Add deprecated declaration guards around two synchronous UIItemProvider methods in WebItemProviderPasteboard.
1926         <rdar://problem/30451096> tracks adoption of the asynchronous versions of these methods.
1927
1928         * platform/ios/WebItemProviderPasteboard.mm:
1929         (-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
1930         (-[WebItemProviderPasteboard _tryToCreateAndAppendObjectOfClass:toArray:usingProvider:]):
1931
1932 2017-03-24  Antoine Quint  <graouts@webkit.org>
1933
1934         [Modern Media Controls] Captions don't move with the appearance of the inline controls
1935         https://bugs.webkit.org/show_bug.cgi?id=170051
1936         <rdar://problem/30754428>
1937
1938         Reviewed by Dean Jackson.
1939
1940         We now size the captions container to account for the controls bar height when visible. To do this,
1941         we use CSS variables to specify the height of the controls bar in default inline mode, compact inline
1942         mode and fullscreen mode.
1943
1944         Test: media/modern-media-controls/tracks-support/tracks-support-captions-offset-with-controls-bar.html
1945
1946         * Modules/modern-media-controls/controls/controls-bar.js:
1947         (ControlsBar.prototype.set faded):
1948         Notify the hosting MediaControls that the "faded" property changed.
1949
1950         * Modules/modern-media-controls/controls/ios-inline-media-controls.css:
1951         (.media-controls.ios.inline > .controls-bar):
1952         Use the new --inline-controls-bar-height CSS variable to specify the inline bar height.
1953
1954         * Modules/modern-media-controls/controls/macos-compact-inline-media-controls.css:
1955         (.media-controls.mac.inline.compact > .controls-bar):
1956         Use the new --inline-compact-controls-bar-height CSS variable to specify the inline bar height.
1957
1958         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.css:
1959         (.media-controls.mac.fullscreen > .controls-bar):
1960         Use the new --fullscreen-controls-bar-height CSS variable to specify the inline bar height.
1961
1962         * Modules/modern-media-controls/controls/macos-inline-media-controls.css:
1963         (.media-controls.mac.inline > .controls-bar):
1964         Use the new --inline-controls-bar-height CSS variable to specify the inline bar height.
1965
1966         * Modules/modern-media-controls/controls/media-controls.css:
1967         (*):
1968         Specify new CSS variables for the various controls bar heights.
1969
1970         * Modules/modern-media-controls/controls/media-controls.js:
1971         (MediaControls.prototype.controlsBarFadedStateDidChange):
1972         Notify the delegate of a controls bar "faded" property change. 
1973
1974         * Modules/modern-media-controls/controls/text-tracks.css:
1975         (video::-webkit-media-text-track-container):
1976         (video::-webkit-media-text-track-container.visible-controls-bar):
1977         (video::-webkit-media-text-track-container.visible-controls-bar.compact-controls-bar):
1978         (video::-webkit-media-text-track-display):
1979         Shorten the height of the captions container when the controls bar is visible. We also
1980         fix a couple of prefixed properties that didn't need to be.
1981
1982         * Modules/modern-media-controls/media/media-controller.js:
1983         (MediaController.prototype.controlsBarFadedStateDidChange):
1984         (MediaController.prototype._updateControlsIfNeeded):
1985         (MediaController.prototype._updateTextTracksClassList):
1986         (MediaController):
1987         Ensure we reflect the "faded" state of the controls bar on the captions container using
1988         a CSS class, as well as whether the controls bar mode is compact.
1989
1990 2017-03-24  Brent Fulgham  <bfulgham@apple.com>
1991
1992         Handle recursive calls to ProcessingInstruction::checkStyleSheet
1993         https://bugs.webkit.org/show_bug.cgi?id=169982
1994         <rdar://problem/31083051>
1995
1996         Reviewed by Antti Koivisto.
1997
1998        See if we triggered a recursive load of the stylesheet during the 'beforeload'
1999        event handler. If so, reset to a valid state before completing the load.
2000
2001        We should also check after 'beforeload' that we were not disconnected from (or
2002        moved to a new) document.
2003
2004        I also looked for other cases of this pattern and fixed them, too.
2005
2006        Tests: fast/dom/beforeload/image-removed-during-before-load.html
2007                fast/dom/beforeload/recursive-css-pi-before-load.html
2008                fast/dom/beforeload/recursive-link-before-load.html
2009                fast/dom/beforeload/recursive-xsl-pi-before-load.html
2010
2011         * dom/ProcessingInstruction.cpp:
2012         (WebCore::ProcessingInstruction::clearExistingCachedSheet): Added.
2013         (WebCore::ProcessingInstruction::checkStyleSheet): Prevent recursive calls into
2014         this function during 'beforeload' handling. Also, safely handle the case where
2015         the element was disconnected in the 'beforeload' handler (similar to what
2016         we do in HTMLLinkElement).
2017         (WebCore::ProcessingInstruction::setCSSStyleSheet): Drive-by Fix: Protect the
2018         current document to match what we do in setXSLStyleSheet.
2019         * dom/ProcessingInstruction.h:
2020         * html/HTMLLinkElement.cpp:
2021         (WebCore::HTMLLinkElement::process): Prevent recursive calls into
2022         this function during 'beforeload' handling.
2023         * html/HTMLLinkElement.h:
2024         * loader/ImageLoader.cpp:
2025         (WebCore::ImageLoader::dispatchPendingBeforeLoadEvent): safely handle the case where
2026         the element was disconnected in the 'beforeload' handler (similar to what
2027         we do in HTMLLinkElement).
2028         * style/StyleScope.cpp:
2029         (WebCore::Style::Scope::hasPendingSheet): Added.
2030         * style/StyleScope.h:
2031
2032 2017-03-24  Brady Eidson  <beidson@apple.com>
2033
2034         A null compound index value crashes the Databases process.
2035         <rdar://problem/30499831> and https://bugs.webkit.org/show_bug.cgi?id=170000
2036
2037         Reviewed by Alex Christensen.
2038
2039         Test: storage/indexeddb/modern/single-entry-index-invalid-key-crash.html
2040
2041         * bindings/js/IDBBindingUtilities.cpp:
2042         (WebCore::createKeyPathArray): Fix the bug by rejecting arrays with any invalid keys in them.
2043         
2044         Add some logging:
2045         * Modules/indexeddb/IDBKeyPath.cpp:
2046         (WebCore::loggingString):
2047         * Modules/indexeddb/IDBKeyPath.h:
2048         * Modules/indexeddb/IDBObjectStore.cpp:
2049         (WebCore::IDBObjectStore::createIndex):
2050         * Modules/indexeddb/shared/IDBIndexInfo.cpp:
2051         (WebCore::IDBIndexInfo::loggingString):
2052
2053 2017-03-24  Ryan Haddad  <ryanhaddad@apple.com>
2054
2055         Unreviewed, rolling out r214360.
2056
2057         This change caused 20+ LayoutTest failures.
2058
2059         Reverted changeset:
2060
2061         "Handle recursive calls to
2062         ProcessingInstruction::checkStyleSheet"
2063         https://bugs.webkit.org/show_bug.cgi?id=169982
2064         http://trac.webkit.org/changeset/214360
2065
2066 2017-03-24  Youenn Fablet  <youenn@apple.com>
2067
2068         Add support for qpSum in WebRTC stats
2069         https://bugs.webkit.org/show_bug.cgi?id=170060
2070
2071         Reviewed by Eric Carlson.
2072
2073         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
2074         (WebCore::fillRTCRTPStreamStats): exposing libwebrtc qpSum value.
2075
2076 2017-03-24  Daniel Bates  <dabates@apple.com>
2077
2078         Prevent new navigations during document unload
2079         https://bugs.webkit.org/show_bug.cgi?id=169934
2080         <rdar://problem/31247584>
2081
2082         Reviewed by Chris Dumez.
2083
2084         Similar to our policy of preventing new navigations from onbeforeunload handlers
2085         we should prevent new navigations that are initiated during the document unload
2086         process.
2087
2088         The significant part of this change is the instantiation of the RAII object NavigationDisabler
2089         in Document::prepareForDestruction(). The rest of this change just renames class
2090         NavigationDisablerForBeforeUnload to NavigationDisabler now that this RAII class is
2091         used to prevent navigation from both onbeforeunload event handlers and when unloading
2092         a document.
2093
2094         Test: fast/frames/frame-unload-navigate-and-setTimeout-assert-fail.html
2095
2096         * dom/Document.cpp:
2097         (WebCore::Document::prepareForDestruction): Disable new navigations when disconnecting
2098         subframes. Also assert that the document is not in the page cache before we fall off
2099         the end of the function.
2100         * loader/FrameLoader.cpp:
2101         (WebCore::FrameLoader::isNavigationAllowed): Update for renaming below.
2102         (WebCore::FrameLoader::shouldClose): Ditto.
2103         * loader/NavigationScheduler.cpp:
2104         (WebCore::NavigationScheduler::shouldScheduleNavigation): Ditto.
2105         * loader/NavigationScheduler.h:
2106         (WebCore::NavigationDisabler::NavigationDisabler): Renamed class; formerly named NavigationDisablerForBeforeUnload.
2107         (WebCore::NavigationDisabler::~NavigationDisabler): Ditto.
2108         (WebCore::NavigationDisabler::isNavigationAllowed): Ditto.
2109         (WebCore::NavigationDisablerForBeforeUnload::NavigationDisablerForBeforeUnload): Deleted.
2110         (WebCore::NavigationDisablerForBeforeUnload::~NavigationDisablerForBeforeUnload): Deleted.
2111         (WebCore::NavigationDisablerForBeforeUnload::isNavigationAllowed): Deleted.
2112
2113 2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
2114
2115         Implement font-optical-sizing
2116         https://bugs.webkit.org/show_bug.cgi?id=168895
2117
2118         Reviewed by Dean Jackson.
2119
2120         Upon advice from Microsoft, the only input to optical sizing is just the
2121         font-size computed value. It is implemented by setting the 'opsz' font
2122         variation axis. Because the propery has such a simple grammar, the
2123         implementation is quite straightforward.
2124
2125         Test: fast/text/variations/optical-sizing.html
2126
2127         * css/CSSComputedStyleDeclaration.cpp:
2128         (WebCore::ComputedStyleExtractor::propertyValue):
2129         * css/CSSPrimitiveValueMappings.h:
2130         (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
2131         (WebCore::CSSPrimitiveValue::operator FontOpticalSizing):
2132         * css/CSSProperties.json:
2133         * css/parser/CSSParserFastPaths.cpp:
2134         (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
2135         (WebCore::CSSParserFastPaths::isKeywordPropertyID):
2136         * platform/graphics/FontCache.h:
2137         (WebCore::FontDescriptionKey::makeFlagsKey):
2138         * platform/graphics/FontDescription.h:
2139         (WebCore::FontDescription::opticalSizing):
2140         (WebCore::FontDescription::setOpticalSizing):
2141         (WebCore::FontDescription::operator==):
2142         (WebCore::FontCascadeDescription::initialOpticalSizing):
2143         * platform/graphics/cocoa/FontCacheCoreText.cpp:
2144         (WebCore::preparePlatformFont):
2145         (WebCore::fontWithFamily):
2146         (WebCore::FontCache::createFontPlatformData):
2147         (WebCore::FontCache::systemFallbackForCharacters):
2148         * platform/graphics/mac/FontCustomPlatformData.cpp:
2149         (WebCore::FontCustomPlatformData::fontPlatformData):
2150         * platform/text/TextFlags.h:
2151
2152 2017-03-24  Chris Dumez  <cdumez@apple.com>
2153
2154         Unreviewed, rolling out r214329.
2155
2156         Significantly regressed Speedometer
2157
2158         Reverted changeset:
2159
2160         "window.crypto.getRandomValues() uses the insecure RC4 RNG"
2161         https://bugs.webkit.org/show_bug.cgi?id=169623
2162         http://trac.webkit.org/changeset/214329
2163
2164 2017-03-24  Yoav Weiss  <yoav@yoav.ws>
2165
2166         Add a warning for unused link preloads.
2167         https://bugs.webkit.org/show_bug.cgi?id=165670
2168
2169         Reviewed by Youenn Fablet.
2170
2171         This patch adds a warning message, to warn developers that are using
2172         link preloads in cases where the downloaded resource is likely to
2173         remain unused.
2174
2175         Test: http/tests/preload/unused_preload_warning.html
2176
2177         * dom/Document.cpp:
2178         (WebCore::Document::prepareForDestruction): Stop the timer once the document is destructed.
2179         * loader/LinkPreloadResourceClients.h: Add shouldMarkAsReferenced overides for the LinkPreloadResourceClient classes.
2180         * loader/cache/CachedResource.cpp:
2181         (WebCore::CachedResource::addClientToSet): Make sure LinkPreloadResourceClients don't set resource to be referenced.
2182         * loader/cache/CachedResourceClient.h:
2183         (WebCore::CachedResourceClient::shouldMarkAsReferenced): Make sure that ResourceClients mark preloads as referenced by default.
2184         * loader/cache/CachedResourceLoader.cpp:
2185         (WebCore::CachedResourceLoader::CachedResourceLoader): Initialize timer.
2186         (WebCore::CachedResourceLoader::~CachedResourceLoader): Stop timer.
2187         (WebCore::CachedResourceLoader::warnUnusedPreloads): Iterate over m_preloads and issue a warning for non-referenced preloads.
2188         (WebCore::CachedResourceLoader::documentDidFinishLoadEvent): Trigger a timer if preloads weren't cleared at load time.
2189         (WebCore::CachedResourceLoader::warnUnusedPreloads): Triggered by the timer, and called CachedResourceLoader::warnUnusedPreloads.
2190         (WebCore::CachedResourceLoader::stopUnusedPreloadsTimer): Stop the timer.
2191
2192 2017-03-24  Brent Fulgham  <bfulgham@apple.com>
2193
2194         Handle recursive calls to ProcessingInstruction::checkStyleSheet
2195         https://bugs.webkit.org/show_bug.cgi?id=169982
2196         <rdar://problem/31083051>
2197
2198         Reviewed by Antti Koivisto.
2199
2200         See if we triggered a recursive load of the stylesheet during the 'beforeload'
2201         event handler. If so, reset to a valid state before completing the load.
2202
2203         We should also check after 'beforeload' that we were not disconnected from (or
2204         moved to a new) document.
2205
2206         I also looked for other cases of this pattern and fixed them.
2207
2208         Tests: fast/dom/beforeload/image-removed-during-before-load.html
2209                fast/dom/beforeload/recursive-css-pi-before-load.html
2210                fast/dom/beforeload/recursive-link-before-load.html
2211                fast/dom/beforeload/recursive-xsl-pi-before-load.html
2212
2213         * dom/ProcessingInstruction.cpp:
2214         (WebCore::ProcessingInstruction::clearExistingCachedSheet): Added.
2215         (WebCore::ProcessingInstruction::checkStyleSheet): Reset to valid state
2216         if necessary after the 'beforeload' handler. Also, safely handle the case where
2217         the element was disconnected in the 'beforeload' handler (similar to what
2218         we do in HTMLLinkElement).
2219         (WebCore::ProcessingInstruction::setCSSStyleSheet): Drive-by Fix: Protect the
2220         current document to match what we do in setXSLStyleSheet.
2221         * dom/ProcessingInstruction.h:
2222         * html/HTMLMediaElement.cpp:
2223         (WebCore::HTMLMediaElement::selectMediaResource): Safely handle the case where
2224         the element was disconnected in the 'beforeload' handler.
2225         (WebCore::HTMLMediaElement::selectNextSourceChild): Ditto.
2226         * loader/ImageLoader.cpp:
2227         (WebCore::ImageLoader::dispatchPendingBeforeLoadEvent): Ditto.
2228
2229 2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
2230
2231         font-style needs a new CSSValue to make CSSRule.cssText work correctly
2232         https://bugs.webkit.org/show_bug.cgi?id=169258
2233
2234         Reviewed by David Hyatt.
2235
2236         With variation fonts, font-style's value can't be captured in a CSSPrimitiveValue (nor any other subclass
2237         off CSSValue) any more. Instead, we need to create two new CSSValues which represent the grammar that font-
2238         style and it's associated @font-face descriptor accept.
2239
2240         The grammar of the font-style property is "normal | italic | oblique [ <<angle>> ]?"
2241         The grammar of the font-style descriptor is "normal | italic | oblique [ <<angle>> | <<angle>> <<angle>> ]?"
2242
2243         We currently still support numbers in place of the <<angle>> value (contrary to the spec). We will remove
2244         this support in https://bugs.webkit.org/show_bug.cgi?id=169357.
2245
2246         Tests: fast/text/font-selection-font-face-parse.html:
2247                fast/text/font-style-parse.html:
2248
2249         * CMakeLists.txt:
2250         * WebCore.xcodeproj/project.pbxproj:
2251         * css/CSSAllInOne.cpp:
2252         * css/CSSComputedStyleDeclaration.cpp:
2253         (WebCore::fontStyleFromStyle):
2254         (WebCore::fontShorthandValueForSelectionProperties):
2255         * css/CSSFontFace.cpp:
2256         (WebCore::calculateWeightRange):
2257         (WebCore::calculateStretchRange):
2258         (WebCore::calculateItalicRange):
2259         * css/CSSFontFaceSet.cpp:
2260         (WebCore::computeFontSelectionRequest):
2261         (WebCore::CSSFontFaceSet::matchingFaces):
2262         (WebCore::calculateWeightValue): Deleted.
2263         (WebCore::calculateStretchValue): Deleted.
2264         (WebCore::calculateStyleValue): Deleted.
2265         * css/CSSFontFaceSet.h:
2266         * css/CSSFontSelector.cpp:
2267         (WebCore::CSSFontSelector::addFontFaceRule):
2268         * css/CSSFontStyleRangeValue.cpp: Added.
2269         (WebCore::CSSFontStyleRangeValue::customCSSText):
2270         (WebCore::CSSFontStyleRangeValue::equals):
2271         * css/CSSFontStyleRangeValue.h: Added.
2272         * css/CSSFontStyleValue.cpp: Added.
2273         (WebCore::CSSFontStyleValue::customCSSText):
2274         (WebCore::CSSFontStyleValue::equals):
2275         * css/CSSFontStyleValue.h: Added.
2276         * css/CSSFontValue.cpp:
2277         (WebCore::CSSFontValue::customCSSText):
2278         * css/CSSFontValue.h:
2279         * css/CSSValue.cpp:
2280         (WebCore::CSSValue::equals):
2281         (WebCore::CSSValue::cssText):
2282         (WebCore::CSSValue::destroy):
2283         * css/CSSValue.h:
2284         (WebCore::CSSValue::isFontStyleValue):
2285         (WebCore::CSSValue::isFontStyleRangeValue):
2286         * css/FontFace.cpp:
2287         (WebCore::FontFace::style):
2288         (WebCore::FontFace::weight):
2289         (WebCore::FontFace::stretch):
2290         * css/StyleBuilderConverter.h:
2291         (WebCore::StyleBuilderConverter::convertFontWeightFromValue):
2292         (WebCore::StyleBuilderConverter::convertFontStretchFromValue):
2293         (WebCore::StyleBuilderConverter::convertFontStyleFromValue):
2294         (WebCore::StyleBuilderConverter::convertFontWeight):
2295         (WebCore::StyleBuilderConverter::convertFontStretch):
2296         (WebCore::StyleBuilderConverter::convertFontStyle):
2297         * css/parser/CSSPropertyParser.cpp:
2298         (WebCore::consumeFontStyle):
2299         (WebCore::consumeFontStyleRange):
2300         (WebCore::CSSPropertyParser::consumeSystemFont):
2301         (WebCore::CSSPropertyParser::consumeFont):
2302         * svg/SVGFontFaceElement.cpp:
2303         (WebCore::SVGFontFaceElement::parseAttribute):
2304
2305 2017-03-24  Alex Christensen  <achristensen@webkit.org>
2306
2307         REGRESSION: Content Blocker: Blocking "a[href*=randomString]" doesn't work
2308         https://bugs.webkit.org/show_bug.cgi?id=169167
2309
2310         Reviewed by Simon Fraser.
2311
2312         When testing content extensions, we have always called an API function that internally
2313         has called AtomicString::init somewhere before we start compiling the content extension.
2314         On iOS, though, we call [_WKUserContentExtensionStore compileContentExtensionForIdentifier:...]
2315         without having already called anything that calls AtomicString::init.  The new CSS parser is now
2316         failing to parse some selectors because CSSSelectorParser::defaultNamespace is returning starAtom,
2317         which is a null atomic string before AtomicString::init is called.
2318
2319         Covered by a new API test.
2320
2321         * contentextensions/ContentExtensionParser.cpp:
2322         (WebCore::ContentExtensions::isValidCSSSelector):
2323         (WebCore::ContentExtensions::loadAction):
2324         (WebCore::ContentExtensions::isValidSelector): Deleted.
2325         * contentextensions/ContentExtensionParser.h:
2326         Call AtomicString::init before checking if a css selector is valid.
2327
2328 2017-03-24  Youenn Fablet  <youenn@apple.com>
2329
2330         Add libwebrtc backend support for RTCRtpSender::replaceTrack
2331         https://bugs.webkit.org/show_bug.cgi?id=169841
2332
2333         Reviewed by Alex Christensen.
2334
2335         Tests: webrtc/audio-replace-track.html
2336                webrtc/video-replace-track.html
2337
2338         Adding support for replaceTrack for audio and video sources.
2339         Replacing tracks will always succeed for audio sources.
2340         For video tracks, it will only succeed if the video resolution is not greater.
2341         LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track.
2342
2343         Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution.
2344
2345         * Modules/mediastream/RTCRtpSender.cpp:
2346         (WebCore::RTCRtpSender::replaceTrack):
2347         * Modules/mediastream/RTCRtpSender.h:
2348         * Modules/mediastream/RTCRtpSender.idl:
2349         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
2350         (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack):
2351         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
2352         * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
2353         (WebCore::RealtimeOutgoingAudioSource::setSource):
2354         * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
2355         * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
2356         (WebCore::RealtimeOutgoingVideoSource::setSource):
2357         * platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
2358         * platform/mock/MockRealtimeVideoSource.cpp:
2359         (WebCore::MockRealtimeVideoSource::drawText):
2360         (WebCore::MockRealtimeVideoSource::generateFrame):
2361
2362 2017-03-24  Jon Lee  <jonlee@apple.com>
2363
2364         Remove comment from RTCStatsReport.idl to convert ssrc to DOMString.
2365         Unreviewed.
2366
2367         Latest available Editor's Draft of WebRTC Statistics API is from 14 December 2016,
2368         but since then, in https://github.com/w3c/webrtc-stats/pull/157, it was changed to become
2369         unsigned long.
2370
2371         * Modules/mediastream/RTCStatsReport.idl:
2372
2373 2017-03-24  Youenn Fablet  <youenn@apple.com>
2374
2375         Add support for DataChannel and MediaStreamTrack stats
2376         https://bugs.webkit.org/show_bug.cgi?id=170031
2377
2378         Reviewed by Eric Carlson.
2379
2380         Tests: webrtc/datachannel/datachannel-stats.html
2381                webrtc/video-mediastreamtrack-stats.html
2382
2383         Exposing libwebrtc stats through WebRTC stats API, gathered for data channel and media stream tracks.
2384
2385         * Modules/mediastream/RTCStatsReport.h:
2386         (WebCore::RTCStatsReport::MediaStreamTrackStats::MediaStreamTrackStats):
2387         (WebCore::RTCStatsReport::DataChannelStats::DataChannelStats):
2388         * Modules/mediastream/RTCStatsReport.idl:
2389         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
2390         (WebCore::fillRTCMediaStreamTrackStats):
2391         (WebCore::fillRTCDataChannelStats):
2392         (WebCore::LibWebRTCMediaEndpoint::StatsCollector::OnStatsDelivered):
2393
2394 2017-03-24  Youenn Fablet  <youenn@apple.com>
2395
2396         Fix framesEncoded/framesDecoded RTC stats
2397         https://bugs.webkit.org/show_bug.cgi?id=170024
2398
2399         Reviewed by Eric Carlson.
2400
2401         Test: webrtc/video-stats.html
2402
2403         Adding access to these fields now that they are available.
2404
2405         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
2406         (WebCore::fillInboundRTPStreamStats):
2407         (WebCore::fillOutboundRTPStreamStats):
2408
2409 2017-03-24  Carlos Garcia Campos  <cgarcia@igalia.com>
2410
2411         Unreviewed. Fix GTK+ test /webkit2/WebKitWebView/default-menu after r214244.
2412
2413         Fix mnemonic string of contextMenuItemTagOpenAudioInNewWindow() that I copy pasted from
2414         contextMenuItemTagOpenVideoInNewWindow().
2415
2416         * platform/LocalizedStrings.cpp:
2417         (WebCore::contextMenuItemTagOpenAudioInNewWindow):
2418
2419 2017-03-24  Carlos Garcia Campos  <cgarcia@igalia.com>
2420
2421         [GStreamer] MediaPlayerPrivateGStreamerOwr shouldn't be the default engine
2422         https://bugs.webkit.org/show_bug.cgi?id=170049
2423
2424         Reviewed by Žan Doberšek.
2425
2426         This is causing several media tests to fail after r214338. When trying to load something like this:
2427
2428         http://127.0.0.1:8000/media/resources/serve-video.php?name=../../../../media/content/silence.wav&type=audio/wav&content-length=no&icy-data=yes
2429
2430         since r214338, the content type is known and inferred from the extension in this case, what ends up calling
2431         nextMediaEngine() in MediaPlayer::loadWithNextMediaEngine. That returns the first registered media engine, that
2432         is Owr that doesn't know how to load that and fails.
2433
2434         Fixes: http/tests/media/media-play-stream-chunked-icy.html
2435                http/tests/media/media-seeking-no-ranges-server.html
2436                http/tests/media/video-auth.html
2437                http/tests/media/video-play-stall-before-meta-data.html
2438                http/tests/security/contentSecurityPolicy/audio-redirect-allowed.html
2439                http/tests/security/contentSecurityPolicy/audio-redirect-allowed2.html
2440                http/tests/security/contentSecurityPolicy/audio-redirect-blocked.html
2441                http/tests/security/contentSecurityPolicy/video-redirect-allowed.html
2442                http/tests/security/contentSecurityPolicy/video-redirect-allowed2.html
2443                http/tests/security/contentSecurityPolicy/video-redirect-blocked.html
2444
2445         * platform/graphics/MediaPlayer.cpp:
2446         (WebCore::buildMediaEnginesVector):
2447
2448 2017-03-24  Per Arne Vollan  <pvollan@apple.com>
2449
2450         Text stroke is sometimes clipped on video captions.
2451         https://bugs.webkit.org/show_bug.cgi?id=170006
2452
2453         Reviewed by Eric Carlson.
2454
2455         Set 'overflow' property to 'visible' on cue element to avoid clipping of text stroke.
2456
2457         Updated test media/track/track-css-stroke-cues.html.
2458
2459         * html/track/TextTrackCueGeneric.cpp:
2460         (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
2461         * html/track/VTTCue.cpp:
2462         (WebCore::VTTCueBox::applyCSSProperties):
2463
2464 2017-03-24  Carlos Garcia Campos  <cgarcia@igalia.com>
2465
2466         [GTK] Add MIMETypeRegistry implementation using xdgmime and remove the GTK+ one
2467         https://bugs.webkit.org/show_bug.cgi?id=170001
2468
2469         Reviewed by Michael Catanzaro.
2470
2471         The XDG implementation could be used by any port where shared-mime-info is expected to be available. It also
2472         improves the current GTK+ implementation that is based on a very small map of mime types and extensions.
2473
2474         * CMakeLists.txt:
2475         * PlatformGTK.cmake:
2476         * platform/xdg/MIMETypeRegistryXdg.cpp: Renamed from Source/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp.
2477         (WebCore::MIMETypeRegistry::getMIMETypeForExtension):
2478         (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType):
2479
2480 2017-03-23  Jon Lee  <jonlee@apple.com>
2481
2482         Update createDataChannel on RTCPeerConnection
2483         https://bugs.webkit.org/show_bug.cgi?id=170044
2484
2485         Reviewed by Youenn Fablet.
2486
2487         * Modules/mediastream/RTCPeerConnection.idl: Change label to USVString.
2488
2489 2017-03-23  Antti Koivisto  <antti@apple.com>
2490
2491         Revert r213712, caused iPad PLT regression
2492         https://bugs.webkit.org/show_bug.cgi?id=170040
2493
2494         Unreviewed.
2495
2496         A few subtests have big regressions.
2497
2498         * css/StyleResolver.cpp:
2499         (WebCore::StyleResolver::pseudoStyleRulesForElement):
2500         * dom/Document.cpp:
2501         (WebCore::Document::resolveStyle):
2502         (WebCore::Document::updateLayoutIgnorePendingStylesheets):
2503         (WebCore::Document::shouldScheduleLayout):
2504         (WebCore::Document::didRemoveAllPendingStylesheet):
2505         * dom/Document.h:
2506         (WebCore::Document::didLayoutWithPendingStylesheets):
2507         (WebCore::Document::hasNodesWithPlaceholderStyle):
2508         (WebCore::Document::setHasNodesWithPlaceholderStyle):
2509         (WebCore::Document::hasNodesWithNonFinalStyle): Deleted.
2510         (WebCore::Document::setHasNodesWithNonFinalStyle): Deleted.
2511         * html/HTMLFrameSetElement.cpp:
2512         (WebCore::HTMLFrameSetElement::rendererIsNeeded):
2513         * page/FrameView.cpp:
2514         (WebCore::FrameView::qualifiesAsVisuallyNonEmpty):
2515         (WebCore::FrameView::fireLayoutRelatedMilestonesIfNeeded):
2516         * rendering/RenderBlock.cpp:
2517         (WebCore::RenderBlock::paintContents):
2518         * rendering/RenderLayer.cpp:
2519         (WebCore::shouldSuppressPaintingLayer):
2520         * rendering/style/RenderStyle.cpp:
2521         (WebCore::RenderStyle::changeRequiresRepaint):
2522         * rendering/style/RenderStyle.h:
2523         (WebCore::RenderStyle::isPlaceholderStyle):
2524         (WebCore::RenderStyle::setIsPlaceholderStyle):
2525         (WebCore::RenderStyle::isNotFinal): Deleted.
2526         (WebCore::RenderStyle::setIsNotFinal): Deleted.
2527         * rendering/style/StyleRareNonInheritedData.cpp:
2528         (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
2529         (WebCore::StyleRareNonInheritedData::operator==):
2530         * rendering/style/StyleRareNonInheritedData.h:
2531         * style/StyleScope.cpp:
2532         (WebCore::Style::Scope::analyzeStyleSheetChange):
2533         (WebCore::Style::Scope::updateActiveStyleSheets):
2534         * style/StyleTreeResolver.cpp:
2535         (WebCore::Style::makePlaceholderStyle):
2536         (WebCore::Style::TreeResolver::styleForElement):
2537         (WebCore::Style::TreeResolver::resolveElement):
2538
2539 2017-03-23  Wenson Hsieh  <wenson_hsieh@apple.com>
2540
2541         Dragging on a large image should not revert to a file icon if data interaction is enabled
2542         https://bugs.webkit.org/show_bug.cgi?id=170018
2543         <rdar://problem/31184508>
2544
2545         Reviewed by Tim Horton.
2546
2547         If data interaction is enabled, don't fall back to showing a file icon when initiating a drag on an image element.
2548
2549         New API tests:  DataInteractionTests.LargeImageToTargetDiv
2550                         DataInteractionTests.AttachmentElementItemProviders
2551
2552         * page/DragController.cpp:
2553         (WebCore::DragController::doImageDrag):
2554         (WebCore::DragController::shouldUseCachedImageForDragImage):
2555         * page/DragController.h:
2556
2557 2017-03-23  Youenn Fablet  <youenn@apple.com>
2558
2559         Rename RTCIceCandidateEvent to RTCPeerConnectionIceEvent
2560         https://bugs.webkit.org/show_bug.cgi?id=169981
2561
2562         Reviewed by Eric Carlson.
2563
2564         * CMakeLists.txt:
2565         * DerivedSources.make:
2566         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
2567         * Modules/mediastream/PeerConnectionBackend.cpp:
2568         (WebCore::PeerConnectionBackend::fireICECandidateEvent):
2569         (WebCore::PeerConnectionBackend::doneGatheringCandidates):
2570         * Modules/mediastream/RTCPeerConnection.cpp:
2571         * Modules/mediastream/RTCPeerConnectionIceEvent.cpp: Renamed from Source/WebCore/Modules/mediastream/RTCIceCandidateEvent.cpp.
2572         (WebCore::RTCPeerConnectionIceEvent::create):
2573         (WebCore::RTCPeerConnectionIceEvent::RTCPeerConnectionIceEvent):
2574         (WebCore::RTCPeerConnectionIceEvent::~RTCPeerConnectionIceEvent):
2575         (WebCore::RTCPeerConnectionIceEvent::candidate):
2576         (WebCore::RTCPeerConnectionIceEvent::eventInterface):
2577         * Modules/mediastream/RTCPeerConnectionIceEvent.h: Renamed from Source/WebCore/Modules/mediastream/RTCIceCandidateEvent.h.
2578         * Modules/mediastream/RTCPeerConnectionIceEvent.idl: Renamed from Source/WebCore/Modules/mediastream/RTCIceCandidateEvent.idl.
2579         * WebCore.xcodeproj/project.pbxproj:
2580         * dom/EventNames.in:
2581
2582 2017-03-23  Michael Catanzaro  <mcatanzaro@igalia.com>
2583
2584         window.crypto.getRandomValues() uses the insecure RC4 RNG
2585         https://bugs.webkit.org/show_bug.cgi?id=169623
2586
2587         Reviewed by Alex Christensen.
2588
2589         * PlatformMac.cmake:
2590         * WebCore.xcodeproj/project.pbxproj:
2591         * crypto/CryptoKey.cpp:
2592         (WebCore::CryptoKey::randomData): Use this on Mac now.
2593         * crypto/mac/CryptoKeyMac.cpp: Removed.
2594         * page/Crypto.cpp:
2595         (WebCore::Crypto::getRandomValues): Rollout r214188.
2596
2597 2017-03-23  Chris Dumez  <cdumez@apple.com>
2598
2599         SVG animations are not paused when their <svg> element is removed from the document
2600         https://bugs.webkit.org/show_bug.cgi?id=170030
2601         <rdar://problem/31230252>
2602
2603         Reviewed by Dean Jackson.
2604
2605         SVG animations were not paused when their <svg> element was removed from the document.
2606         This patch fixes the issue.
2607
2608         Test: svg/animations/animations-paused-when-removed-from-document.html
2609
2610         * svg/SVGSVGElement.cpp:
2611         (WebCore::SVGSVGElement::insertedInto):
2612         (WebCore::SVGSVGElement::removedFrom):
2613
2614 2017-03-22  Myles C. Maxfield  <mmaxfield@apple.com>
2615
2616         font shorthand should accept variation values
2617         https://bugs.webkit.org/show_bug.cgi?id=168998
2618
2619         Reviewed by Simon Fraser.
2620
2621         The CSS Fonts 4 spec has stabilized as to which variation values are allowed in
2622         the font shorthand property. Weights are allowed because a 0 weight is considered
2623         as a parse error, so there is no conflict with a unitless font-size of 0.
2624         font-style accepts angles, so there is no conflict there. However, font-stretch
2625         accepts percentages, which are also accepted by font-size, which means the newly
2626         extended grammar for font-stretch can't be accepted in the shorthand.
2627
2628         Tests: fast/text/font-style-parse.html
2629                fast/text/font-weight-parse.html
2630
2631         * css/parser/CSSPropertyParser.cpp:
2632         (WebCore::consumeFontWeight):
2633         (WebCore::consumeFontStyle):
2634         (WebCore::CSSPropertyParser::consumeFont):
2635         (WebCore::consumeFontWeightCSS21): Deleted.
2636         * css/parser/CSSPropertyParserHelpers.cpp:
2637         (WebCore::CSSPropertyParserHelpers::consumeFontWeightNumber):
2638         * css/parser/CSSPropertyParserHelpers.h:
2639
2640 2017-03-23  Chris Dumez  <cdumez@apple.com>
2641
2642         SVG animations are not paused when inserted into a hidden page
2643         https://bugs.webkit.org/show_bug.cgi?id=170026
2644         <rdar://problem/31228704>
2645
2646         Reviewed by Andreas Kling.
2647
2648         SVG animations were not paused when inserted into a hidden page. We would pause
2649         animations in a page when the page becomes hidden. However, new animations
2650         inserted in the page after this point would start, despite the page being
2651         hidden.
2652
2653         Tests:
2654         - svg/animations/animations-paused-when-inserted-in-hidden-document.html
2655         - svg/animations/animations-paused-when-inserted-in-hidden-document2.html
2656
2657         * dom/Document.cpp:
2658         (WebCore::Document::accessSVGExtensions):
2659         * svg/SVGDocumentExtensions.cpp:
2660         (WebCore::SVGDocumentExtensions::SVGDocumentExtensions):
2661         (WebCore::SVGDocumentExtensions::addTimeContainer):
2662         (WebCore::reportMessage):
2663         * svg/SVGDocumentExtensions.h:
2664         * testing/Internals.cpp:
2665         (WebCore::Internals::areSVGAnimationsPaused):
2666         * testing/Internals.h:
2667         * testing/Internals.idl:
2668
2669 == Rolled over to ChangeLog-2017-03-23 ==