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