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