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