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