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