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