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