App crashing: Dispatch queue: com.apple.root.user-interactive-qos / vBoxConvolve...
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-04-28  Dean Jackson  <dino@apple.com>
2
3         App crashing: Dispatch queue: com.apple.root.user-interactive-qos / vBoxConvolve / WebCore::FEGaussianBlur::platformApplySoftware()
4         https://bugs.webkit.org/show_bug.cgi?id=171461
5         <rdar://problem/30534722>
6
7         Reviewed by Eric Carlson.
8
9         We're getting reports of crashes in this function, caused by null or empty data being
10         passed to vImage. Guard against this, in a way that will ASSERT in debug builds if
11         anyone comes across it.
12
13         Test: css3/filters/blur-various-radii.html
14
15         * platform/graphics/filters/FEGaussianBlur.cpp:
16         (WebCore::accelerateBoxBlur): Return early if things don't look good.
17
18 2017-04-28  Chris Dumez  <cdumez@apple.com>
19
20         Stop using legacy ClientRect / ClientRectList in Internals
21         https://bugs.webkit.org/show_bug.cgi?id=171412
22
23         Reviewed by Simon Fraser.
24
25         Stop using legacy ClientRect / ClientRectList in Internals amd use the
26         newer DOMRect instead.
27
28         * dom/DOMRect.idl:
29         * page/Page.cpp:
30         (WebCore::Page::nonFastScrollableRects):
31         (WebCore::Page::touchEventRectsForEvent):
32         (WebCore::Page::passiveTouchEventListenerRects):
33         * page/Page.h:
34         * testing/Internals.cpp:
35         (WebCore::Internals::absoluteCaretBounds):
36         (WebCore::Internals::boundingBox):
37         (WebCore::Internals::inspectorHighlightRects):
38         (WebCore::Internals::layoutViewportRect):
39         (WebCore::Internals::visualViewportRect):
40         (WebCore::Internals::touchEventRectsForEvent):
41         (WebCore::Internals::passiveTouchEventListenerRects):
42         (WebCore::Internals::nonFastScrollableRects):
43         (WebCore::Internals::selectionBounds):
44         * testing/Internals.h:
45         * testing/Internals.idl:
46
47 2017-04-28  Youenn Fablet  <youenn@apple.com>
48
49         getUserMedia video streams should follow device orientation
50         https://bugs.webkit.org/show_bug.cgi?id=171284
51
52         Reviewed by Eric Carlson.
53
54         Only really affects AVVideoCaptureSource on iOS. Manually testing the following cases:
55         - Mac: no change of behavior
56         - iOS: page loaded in portrait, video is portrait. page loaded in landscape, video is landscape
57         - iOS: changing the device orientation makes the video samples to be moved to landscape/portrait.
58         - Same tests as above with peer connection.
59
60         Making Document having an OrientationNotifier that AVVideoCaptureSources get registered to.
61         Making AVVideoCaptureSource an OrientationNotifier::Observer so that it can changes width/height if needed.
62
63         Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory.
64         Refactoring to return a CaptureSourceOrError instead of passing an out parameter plus returning a RefPtr.
65
66         * Modules/mediastream/UserMediaRequest.cpp:
67         (WebCore::UserMediaRequest::allow):
68         * WebCore.xcodeproj/project.pbxproj:
69         * dom/Document.cpp:
70         (WebCore::Document::orientationChanged):
71         * dom/Document.h:
72         * page/Frame.cpp:
73         (WebCore::Frame::orientationChanged):
74         * platform/OrientationNotifer.h: Copied from Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h.
75         (WebCore::OrientationNotifier::Observer::setNotifier):
76         (WebCore::OrientationNotifier::Observer::~Observer):
77         (WebCore::OrientationNotifier::orientationChanged):
78         (WebCore::OrientationNotifier::addObserver):
79         (WebCore::OrientationNotifier::removeObserver):
80         * platform/mediastream/MediaStreamPrivate.cpp:
81         (WebCore::MediaStreamPrivate::monitorOrientation):
82         * platform/mediastream/MediaStreamPrivate.h:
83         * platform/mediastream/RealtimeMediaSource.h:
84         (WebCore::CaptureSourceOrError::CaptureSourceOrError):
85         (WebCore::CaptureSourceOrError::operator bool):
86         (WebCore::CaptureSourceOrError::source):
87         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
88         (WebCore::RealtimeMediaSourceCenter::setAudioFactory):
89         (WebCore::RealtimeMediaSourceCenter::unsetAudioFactory):
90         (WebCore::RealtimeMediaSourceCenter::setVideoFactory):
91         (WebCore::RealtimeMediaSourceCenter::unsetVideoFactory):
92         * platform/mediastream/RealtimeMediaSourceCenter.h:
93         (WebCore::RealtimeMediaSourceCenter::defaultAudioFactory):
94         (WebCore::RealtimeMediaSourceCenter::defaultVideoFactory):
95         (WebCore::RealtimeMediaSourceCenter::audioFactory):
96         (WebCore::RealtimeMediaSourceCenter::videoFactory):
97         * platform/mediastream/mac/AVAudioCaptureSource.h:
98         * platform/mediastream/mac/AVAudioCaptureSource.mm:
99         (WebCore::AVAudioCaptureSource::create):
100         (WebCore::AVAudioCaptureSource::factory):
101         * platform/mediastream/mac/AVVideoCaptureSource.h:
102         * platform/mediastream/mac/AVVideoCaptureSource.mm:
103         (WebCore::AVVideoCaptureSource::create):
104         (WebCore::AVVideoCaptureSource::factory):
105         (WebCore::AVVideoCaptureSource::monitorOrientation):
106         (WebCore::AVVideoCaptureSource::orientationChanged):
107         (WebCore::AVVideoCaptureSource::processNewFrame):
108         * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
109         (WebCore::CoreAudioCaptureSource::create):
110         (WebCore::CoreAudioCaptureSource::factory):
111         * platform/mediastream/mac/CoreAudioCaptureSource.h:
112         * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
113         (WebCore::MockRealtimeAudioSource::create):
114         * platform/mediastream/mac/MockRealtimeVideoSourceMac.h:
115         * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
116         (WebCore::MockRealtimeVideoSource::create):
117         (WebCore::MockRealtimeVideoSourceMac::orientationChanged):
118         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
119         (WebCore::RealtimeMediaSourceCenterMac::createMediaStream):
120         (WebCore::RealtimeMediaSourceCenterMac::bestSourcesForTypeAndConstraints):
121         (WebCore::RealtimeMediaSourceCenterMac::defaultAudioFactory):
122         (WebCore::RealtimeMediaSourceCenterMac::defaultVideoFactory):
123         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:
124         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
125         (WebCore::RealtimeMediaSourceCenterOwr::createMediaStream):
126         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.h:
127         * platform/mock/MockRealtimeAudioSource.cpp:
128         (WebCore::MockRealtimeAudioSource::create):
129         (WebCore::MockRealtimeAudioSource::factory):
130         * platform/mock/MockRealtimeAudioSource.h:
131         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
132         (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints):
133         (WebCore::MockRealtimeMediaSourceCenter::createMediaStream):
134         (WebCore::MockRealtimeMediaSourceCenter::defaultAudioFactory):
135         (WebCore::MockRealtimeMediaSourceCenter::defaultVideoFactory):
136         * platform/mock/MockRealtimeMediaSourceCenter.h:
137         * platform/mock/MockRealtimeVideoSource.cpp:
138         (WebCore::MockRealtimeVideoSource::create):
139         (WebCore::MockRealtimeVideoSource::factory):
140         * platform/mock/MockRealtimeVideoSource.h:
141
142 2017-04-28  Said Abou-Hallawa  <sabouhallawa@apple.com>
143
144         Unify how BitmapImage handles the availability of a decoded for large and animated images
145         https://bugs.webkit.org/show_bug.cgi?id=171410
146
147         Reviewed by Simon Fraser.
148
149         Rename some functions which are related to animation frame availability.
150         Make BitmapImage call ImageObserver::imageFrameAvailable() whenever a 
151         frame is available regardless it is for an animated or for a large image.
152
153         * html/HTMLMediaElement.cpp:
154         (WebCore::HTMLMediaElement::isVisibleInViewport):
155         * html/MediaElementSession.cpp:
156         (WebCore::MediaElementSession::autoplayPermitted):
157         (WebCore::isMainContentForPurposesOfAutoplay):
158         * loader/cache/CachedImage.cpp:
159         (WebCore::CachedImage::CachedImageObserver::imageFrameAvailable):
160         (WebCore::CachedImage::imageFrameAvailable):
161         (WebCore::CachedImage::usesImageContainerSize): Deleted.
162         (WebCore::CachedImage::imageHasRelativeWidth): Deleted.
163         (WebCore::CachedImage::imageHasRelativeHeight): Deleted.
164         (WebCore::CachedImage::CachedImageObserver::animationAdvanced): Deleted.
165         (WebCore::CachedImage::animationAdvanced): Deleted.
166         * loader/cache/CachedImage.h:
167         * loader/cache/CachedImageClient.h:
168         (WebCore::CachedImageClient::imageFrameAvailable):
169         (WebCore::CachedImageClient::newImageAnimationFrameAvailable): Deleted.
170         * platform/graphics/BitmapImage.cpp:
171         (WebCore::BitmapImage::internalAdvanceAnimation):
172         (WebCore::BitmapImage::imageFrameAvailableAtIndex):
173         (WebCore::BitmapImage::newFrameNativeImageAvailableAtIndex): Deleted.
174         * platform/graphics/BitmapImage.h:
175         * platform/graphics/Image.h:
176         (WebCore::Image::imageFrameAvailableAtIndex):
177         (WebCore::Image::newFrameNativeImageAvailableAtIndex): Deleted.
178         * platform/graphics/ImageFrameCache.cpp:
179         (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex):
180         * platform/graphics/ImageObserver.h:
181         * platform/graphics/ImageTypes.h:
182         * rendering/RenderElement.cpp:
183         (WebCore::RenderElement::RenderElement):
184         (WebCore::RenderElement::shouldRepaintInVisibleRect):
185         (WebCore::RenderElement::imageFrameAvailable):
186         (WebCore::RenderElement::repaintForPausedImageAnimationsIfNeeded):
187         (WebCore::shouldRepaintForImageAnimation): Deleted.
188         (WebCore::RenderElement::newImageAnimationFrameAvailable): Deleted.
189         * rendering/RenderElement.h:
190         * rendering/RenderView.cpp:
191         (WebCore::RenderView::updateVisibleViewportRect):
192         * svg/graphics/SVGImageClients.h:
193
194 2017-04-28  Jeremy Jones  <jeremyj@apple.com>
195
196         ARGUMENT BAD: time, time >= 0
197         https://bugs.webkit.org/show_bug.cgi?id=164336
198         rdar://problem/29314891
199
200         Reviewed by Eric Carlson.
201
202         Handle invalid duration and current time when calculating remaining time.
203
204         Test media/modern-media-controls/pip-support/pip-support-click.html now works without a workaround
205         in media/modern-media-controls/pip-support/pip-support-enabled.html
206
207         * platform/mac/WebVideoFullscreenHUDWindowController.mm:
208         (-[WebVideoFullscreenHUDWindowController remainingTimeText]):
209
210 2017-04-28  Daniel Bates  <dabates@apple.com>
211
212         Add WebCore::protocolIsJavaScript(StringView)
213         https://bugs.webkit.org/show_bug.cgi?id=171396
214
215         Reviewed by Alex Christensen.
216
217         Add an overload of WebCore::protocolIsJavaScript() that takes a StringView to
218         avoid the need for a caller to allocate a new String object when converting
219         from a StringView to a String. We are not using this functionality at the moment,
220         but we will in the patch for <https://bugs.webkit.org/show_bug.cgi?id=170925>.
221
222         No functionality has changed. So, no new tests.
223
224         * platform/URL.cpp: Remove an outdated comment about protocolIs(StringView, const char*).
225         This overload was removed in r212508.
226         (WebCore::protocolIsInternal): Added.
227         (WebCore::protocolIs): Implemented in terms of WebCore::protocolIsInternal().
228         (WebCore::URL::protocolIs): Ditto.
229         (WebCore::protocolIsJavaScript): Added; overload that takes a StringView.
230         (WebCore::mimeTypeFromDataURL): Modified to use WebCore::protocolIsInternal().
231         * platform/URL.h:
232
233 2017-04-28  Andy Estes  <aestes@apple.com>
234
235         [macOS] WebPlaybackControlsManager needs to know when the selected text or audio track changes
236         https://bugs.webkit.org/show_bug.cgi?id=171434
237         <rdar://problem/31887922>
238
239         Reviewed by Eric Carlson.
240
241         * dom/GenericEventQueue.cpp:
242         (WebCore::GenericEventQueue::hasPendingEventsOfType): Added to check if a pending event
243         exists of a certain type.
244         * dom/GenericEventQueue.h:
245         * html/HTMLMediaElement.cpp:
246         (WebCore::HTMLMediaElement::setSelectedTextTrack): Even if no track modes change, fire a
247         change event when the track to select is off or automatic so that
248         WebPlaybackSessionModelMediaElement detects the change.
249         * html/track/TrackListBase.cpp:
250         (TrackListBase::isChangeEventScheduled): Returns true if m_asyncEventQueue has a pending
251         change event.
252         * html/track/TrackListBase.h:
253         * platform/cocoa/WebPlaybackSessionModel.h:
254         (WebCore::WebPlaybackSessionModelClient::audioMediaSelectionIndexChanged):
255         (WebCore::WebPlaybackSessionModelClient::legibleMediaSelectionIndexChanged):
256         * platform/cocoa/WebPlaybackSessionModelMediaElement.h:
257         * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
258         (WebCore::WebPlaybackSessionModelMediaElement::setMediaElement): Registered/unregistered for
259         the change event on the audio and text tracks.
260         (WebCore::WebPlaybackSessionModelMediaElement::updateForEventName): Called
261         updateMediaSelectionIndices() when the change event fires.
262         (WebCore::WebPlaybackSessionModelMediaElement::updateMediaSelectionOptions): Renamed from
263         updateLegibleOptions().
264         (WebCore::WebPlaybackSessionModelMediaElement::updateMediaSelectionIndices): Called
265         audioMediaSelectionIndexChanged() and legibleMediaSelectionIndexChanged() on m_clients with
266         the updated indices.
267         (WebCore::WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex): Fixed a bug
268         where selectedIndex would never be set to offIndex if offIndex is 0 (which it usually is).
269         (WebCore::WebPlaybackSessionModelMediaElement::updateLegibleOptions): Renamed to
270         updateMediaSelectionOptions().
271         * platform/mac/WebPlaybackControlsManager.h:
272         * platform/mac/WebPlaybackControlsManager.mm:
273         (-[WebPlaybackControlsManager setAudioMediaSelectionIndex:]): Set
274         _currentAudioTouchBarMediaSelectionOption to the object at selectedIndex and manually
275         triggered a KVO notification. We can't call -setCurrentAudioTouchBarMediaSelectionOption:
276         here since that will send a message back to the Web process.
277         (-[WebPlaybackControlsManager setLegibleMediaSelectionIndex:]): Ditto for
278         _currentLegibleTouchBarMediaSelectionOption.
279         * platform/mac/WebPlaybackSessionInterfaceMac.h:
280         * platform/mac/WebPlaybackSessionInterfaceMac.mm:
281         (WebCore::WebPlaybackSessionInterfaceMac::audioMediaSelectionIndexChanged): Called
282         -[WebPlaybackControlsManager setAudioMediaSelectionIndex:].
283         (WebCore::WebPlaybackSessionInterfaceMac::legibleMediaSelectionIndexChanged): Called
284         -[WebPlaybackControlsManager setLegibleMediaSelectionIndex:].
285
286 2017-04-28  Chris Dumez  <cdumez@apple.com>
287
288         Range.getClientRects() / getBoundingClientRect() should return DOMRect types
289         https://bugs.webkit.org/show_bug.cgi?id=171393
290
291         Reviewed by Simon Fraser.
292
293         Range.getClientRects() / getBoundingClientRect() should return DOMRect types:
294         - https://drafts.csswg.org/cssom-view/#extensions-to-the-range-interface
295
296         Test: fast/dom/Range/getBoundingClientRect-getClientRects-return-type.html
297
298         * CMakeLists.txt:
299         * WebCore.xcodeproj/project.pbxproj:
300         * dom/DOMRect.cpp: Copied from Source/WebCore/dom/DOMRect.h.
301         (WebCore::createDOMRectVector):
302         * dom/DOMRect.h:
303         * dom/Element.cpp:
304         (WebCore::Element::getClientRects):
305         * dom/Range.cpp:
306         (WebCore::Range::getClientRects):
307         (WebCore::Range::getBoundingClientRect):
308         * dom/Range.h:
309         * dom/Range.idl:
310
311 2017-04-28  Chris Dumez  <cdumez@apple.com>
312
313         Tweak window.open features argument tokenizer to match HTML standard and Edge
314         https://bugs.webkit.org/show_bug.cgi?id=170548
315
316         Reviewed by Geoffrey Garen.
317
318         Update window.open() features argument tokenizer to match HTML standard:
319         - https://html.spec.whatwg.org/#concept-window-open-features-tokenize
320
321         Also update window.open() to return null instead of the window when
322         the 'noopener' feature is activated, as per:
323         - https://html.spec.whatwg.org/#dom-open (Step 10)
324
325         No new tests, rebaselined existing test.
326
327         * page/DOMWindow.cpp:
328         (WebCore::DOMWindow::createWindow):
329         Update window.open() to return null instead of the window when
330         the 'noopener' feature is activated, as per:
331         - https://html.spec.whatwg.org/#dom-open (Step 10)
332
333         * page/WindowFeatures.cpp:
334         (WebCore::isSeparator):
335         Treat all ASCII spaces as feature separators, as per:
336         - https://html.spec.whatwg.org/#feature-separator
337         This has the effect of adding U+000C (FormFeed) as a separator.
338
339         (WebCore::processFeaturesString):
340         Align tokenizing code with the specification:
341         - https://html.spec.whatwg.org/#concept-window-open-features-tokenize
342         In particular, the following changes were made:
343         - After the key, skip to first '=', but don't skip past a ',' or a non-separator.
344           The "or a non-separator" part is new in the spec (step 3.6.1) and is now implemented.
345         - After looking for the '=', only treat what follows as a value if the current character
346           is a separator. This is as per step 7 in the spec.
347         These changes now cause us to parse 'foo noopener=1' as ('foo', ''), ('noopener', '1').
348
349 2017-04-28  Eric Carlson  <eric.carlson@apple.com>
350
351         Implement ondevicechange
352         https://bugs.webkit.org/show_bug.cgi?id=169872
353
354         Unreviewed, remove some dead code accidentally committed in r215929.
355
356         * platform/mediastream/CaptureDeviceManager.cpp:
357
358 2017-04-28  Chris Dumez  <cdumez@apple.com>
359
360         Update DOMTokenList.replace() to match the latest DOM specification
361         https://bugs.webkit.org/show_bug.cgi?id=171388
362
363         Reviewed by Alex Christensen.
364
365         Update DOMTokenList.replace() to match the latest DOM specification after:
366         - https://github.com/whatwg/dom/issues/442
367         - https://github.com/whatwg/infra/pull/126
368
369         The latest spec text is at:
370         - https://dom.spec.whatwg.org/#dom-domtokenlist-replace
371         - https://infra.spec.whatwg.org/#set-replace
372
373         The behavior change in this patch causes (a, b, c).replace(a, c) to return
374         (c, b) instead of (b, c). This new behavior is aligned with Firefox as well.
375
376         No new tests, updated existing test.
377
378         * html/DOMTokenList.cpp:
379         (WebCore::DOMTokenList::replace):
380
381 2017-04-28  Brady Eidson  <beidson@apple.com>
382
383         Start of support for multiple WebsiteDataStore/SessionIDs per process
384         https://bugs.webkit.org/show_bug.cgi?id=171422
385
386         Reviewed by Geoffrey Garen.
387
388         Covered by API tests.
389
390         * platform/network/NetworkStorageSession.h:
391         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
392         (WebCore::NetworkStorageSession::ensureSession):
393         * platform/spi/cf/CFNetworkSPI.h:
394
395 2017-04-28  Chris Dumez  <cdumez@apple.com>
396
397         URLSearchParams should be reflective
398         https://bugs.webkit.org/show_bug.cgi?id=171345
399
400         Reviewed by Alex Christensen.
401
402         There was a bug in our implementation of [1] where we would replace
403         '+' with 0x20 *after* URL-decoding the string, instead of *before*.
404         This was causing us to replace URL-encoded '+' characters with 0x20.
405
406         [1] https://url.spec.whatwg.org/#concept-urlencoded-parser
407
408         No new tests, updated existing test.
409
410         * platform/URLParser.cpp:
411
412 2017-04-28  Youenn Fablet  <youenn@apple.com>
413
414         Adding a runtime flag specific to MediaDevices
415         https://bugs.webkit.org/show_bug.cgi?id=171433
416
417         Reviewed by Geoffrey Garen.
418
419         Covered by existing tests.
420
421         Adding a preference for MediaDevices.
422         Setting media devices runtime flag to false by default.
423         Setting peer connection and media stream flags to true by default.
424         Activating mediaDevices and getUserMedia Navigator properties based on media devices flag.
425
426         * Modules/mediastream/NavigatorMediaDevices.idl:
427         * Modules/mediastream/NavigatorUserMedia.idl:
428         * page/RuntimeEnabledFeatures.cpp:
429         (WebCore::RuntimeEnabledFeatures::RuntimeEnabledFeatures):
430         * page/RuntimeEnabledFeatures.h:
431         (WebCore::RuntimeEnabledFeatures::mediaDevicesEnabled):
432         (WebCore::RuntimeEnabledFeatures::setMediaDevicesEnabled):
433
434 2017-04-28  Eric Carlson  <eric.carlson@apple.com>
435
436         Implement ondevicechange
437         https://bugs.webkit.org/show_bug.cgi?id=169872
438
439         Unreviewed, fix test crash.
440
441         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
442         (WebCore::RealtimeMediaSourceCenter::addDevicesChangedObserver): "nextToken" must be static.
443
444 2017-04-28  Dean Jackson  <dino@apple.com>
445
446         [WebGPU] Label MTLCommandQueues with a prefix for internal telemetry
447         https://bugs.webkit.org/show_bug.cgi?id=171441
448         <rdar://problem/31826915>
449
450         Reviewed by Tim Horton.
451
452         Prefix any label that is set by the WebGPU API so that
453         our telemetry can identify the use. Don't expose that
454         prefix to the API though.
455
456         New API Test: GPUCommandQueue
457
458         * platform/graphics/cocoa/GPUCommandQueueMetal.mm:
459         (WebCore::GPUCommandQueue::GPUCommandQueue):
460         (WebCore::GPUCommandQueue::label):
461         (WebCore::GPUCommandQueue::setLabel):
462
463 2017-04-28  Joanmarie Diggs  <jdiggs@igalia.com>
464
465         [ATK] aria-modal="true" should be exposed via ATK_STATE_MODAL
466         https://bugs.webkit.org/show_bug.cgi?id=171188
467
468         Reviewed by Chris Fleizach.
469
470         Include ATK_STATE_MODAL in the AtkObject's state set if the accessible
471         element's node is the current ARIA modal node.
472
473         Test: accessibility/gtk/aria-modal-state-exposed.html
474
475         * accessibility/AccessibilityObject.cpp:
476         (WebCore::AccessibilityObject::isAriaModalNode):
477         * accessibility/AccessibilityObject.h:
478         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
479         (setAtkStateSetFromCoreObject):
480
481 2017-04-28  Eric Carlson  <eric.carlson@apple.com>
482
483         Implement ondevicechange
484         https://bugs.webkit.org/show_bug.cgi?id=169872
485         <rdar://problem/28945035>
486
487         Reviewed by Jer Noble.
488
489         Test: fast/mediastream/device-change-event.html
490
491         * Modules/mediastream/MediaDevices.cpp:
492         (WebCore::MediaDevices::MediaDevices): Register for devicechange callbacks.
493         (WebCore::MediaDevices::~MediaDevices): Unregister.
494         (WebCore::MediaDevices::scheduledEventTimerFired):
495         * Modules/mediastream/MediaDevices.h:
496         * Modules/mediastream/MediaDevices.idl:
497
498         * Modules/mediastream/MediaDevicesEnumerationRequest.cpp:
499         (WebCore::MediaDevicesEnumerationRequest::setDeviceInfo): Remove unnecessary instance variables.
500         * Modules/mediastream/MediaDevicesEnumerationRequest.h:
501
502         * Modules/mediastream/MediaDevicesRequest.cpp:
503         (WebCore::MediaDevicesRequest::start): Remove m_idHashSalt, it isn't used. RealtimeMediaSourceCenter
504         now has the method to hash ids and group IDs.
505         (WebCore::hashString): Deleted.
506         (WebCore::MediaDevicesRequest::hashID): Deleted.
507         * Modules/mediastream/MediaDevicesRequest.h:
508
509         * dom/Document.h:
510         (WebCore::Document::setDeviceIDHashSalt):
511         (WebCore::Document::deviceIDHashSalt):
512
513         * dom/EventNames.h: Add devicechange.
514
515         * dom/EventTargetFactory.in: Add MediaDevices.
516
517         * html/HTMLAttributeNames.in: Add ondevicechange.
518
519         * platform/mediastream/CaptureDeviceManager.cpp:
520         (WebCore::CaptureDeviceManager::captureDeviceFromPersistentID): Renamed from captureDeviceFromDeviceID
521         and changed to return a std::optional<CaptureDevice>.
522         (WebCore::CaptureDeviceManager::captureDeviceFromDeviceID): Deleted.
523
524         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
525         (WebCore::addStringToSHA): New, add string bytes to SHA1. Moved from MediaDevicesRequest
526         so we can use for in testing.
527         (WebCore::RealtimeMediaSourceCenter::hashStringWithSalt): Generate hash for a string with a
528         salt. Moved from MediaDevicesRequest so we can use for in testing.
529         (WebCore::RealtimeMediaSourceCenter::captureDeviceWithUniqueID): Find a CaptureDevice given 
530         a unique ID and the process hash salt.
531         (WebCore::RealtimeMediaSourceCenter::setDeviceEnabled): Enable/disable a device. Used for
532         layout tests only.
533         (WebCore::RealtimeMediaSourceCenter::addDevicesChangedObserver): Add a devices changed listener.
534         (WebCore::RealtimeMediaSourceCenter::removeDevicesChangedObserver): Remove a listener.
535         (WebCore::RealtimeMediaSourceCenter::captureDevicesChanged): Notify listeners.
536         * platform/mediastream/RealtimeMediaSourceCenter.h:
537
538         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
539         (WebCore::AVCaptureDeviceManager::addDevicesChangedObserver): Update for change to captureDeviceFromDeviceID.
540
541         * platform/mock/MockRealtimeMediaSource.cpp:
542         (WebCore::MockRealtimeMediaSource::audioDevices): All devices are enabled by default.
543         (WebCore::MockRealtimeMediaSource::videoDevices): Ditto.
544
545         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
546         (WebCore::MockRealtimeMediaSourceCenter::createMediaStream): Drive-by cleanup: use the vector
547         of devices instead of making assumptions about the number.
548         (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamDevices): Only include enabled devices.
549         (WebCore::MockRealtimeMediaSourceCenter::setDeviceEnabled): Enable or disable a device.
550         * platform/mock/MockRealtimeMediaSourceCenter.h:
551
552         * testing/Internals.cpp:
553         (WebCore::Internals::setMediaDeviceState): Enable or disable a mock capture device.
554         * testing/Internals.h:
555         * testing/Internals.idl:
556
557 2017-04-28  Alex Christensen  <achristensen@webkit.org>
558
559         Fix memory corruption issue after r215883.
560         https://bugs.webkit.org/show_bug.cgi?id=171365
561
562         Reviewed by Brady Eidson.
563
564         This fixes a crash when starting WebKit2.
565
566         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
567         (WebCore::NetworkStorageSession::NetworkStorageSession):
568         Initialize m_platformCookieStorage with the default constructor of RetainPtr,
569         then call NetworkStorageSession::cookieStorage which checks m_platformCookieStorage
570         for null.  It was checking uninitialized memory when we had m_platformCookieStorage
571         in the initializer list.
572
573 2017-04-28  Joanmarie Diggs  <jdiggs@igalia.com>
574
575         AX: Implement aria-value support for focusable separators
576         https://bugs.webkit.org/show_bug.cgi?id=171169
577
578         Reviewed by Chris Fleizach.
579
580         Add SplitterRole to the roles which support range value and are considered a range
581         control, as long as the SplitterRole element is focusable. Also replace ATK's role-
582         based check with a call to supportsRangeValue() when determining if the AtkValue
583         interface should be implemented.
584
585         Test: accessibility/separator-values.html
586
587         * accessibility/AccessibilityObject.cpp:
588         (WebCore::AccessibilityObject::isRangeControl):
589         (WebCore::AccessibilityObject::supportsRangeValue):
590         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
591         (getInterfaceMaskFromObject):
592
593 2017-04-28  Joanmarie Diggs  <jdiggs@igalia.com>
594
595         [ATK] GridCellRole should implement AtkTableCell (regression?)
596         https://bugs.webkit.org/show_bug.cgi?id=171179
597
598         Reviewed by Chris Fleizach.
599
600         Add GridCellRole to the group of roles which should implement AtkTableCell.
601
602         Test: accessibility/gtk/interface-table-cell.html
603
604         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
605         (getInterfaceMaskFromObject):
606
607 2017-04-28  Miguel Gomez  <magomez@igalia.com>
608
609         REGRESSION(r215211): [GTK] Several webgl related tests are failing
610         https://bugs.webkit.org/show_bug.cgi?id=170730
611
612         Reviewed by Said Abou-Hallawa.
613
614         There is a wrong situation in the image decoders where the complete data has been assigned
615         to them but the size of the image hasn't been decoded yet. This is causing rendering
616         issues in webgl when decoding the images used as textures. To fix this, we refactor how the
617         encoded data status is stored to avoid that situation: the status is handled completely
618         by ImageDecoder.h, and it's the one forcing the decode of the size when data gets assigned
619         to the decoders.
620
621         Covered by existent tests.
622
623         * platform/image-decoders/ImageDecoder.h:
624         (WebCore::ImageDecoder::isAllDataReceived):
625         (WebCore::ImageDecoder::setData):
626         (WebCore::ImageDecoder::encodedDataStatus):
627         (WebCore::ImageDecoder::isSizeAvailable):
628         (WebCore::ImageDecoder::setSize):
629         (WebCore::ImageDecoder::setFailed):
630         (WebCore::ImageDecoder::failed):
631         * platform/image-decoders/bmp/BMPImageDecoder.cpp:
632         (WebCore::BMPImageDecoder::frameBufferAtIndex):
633         (WebCore::BMPImageDecoder::decode):
634         (WebCore::BMPImageDecoder::encodedDataStatus): Deleted.
635         * platform/image-decoders/bmp/BMPImageDecoder.h:
636         * platform/image-decoders/gif/GIFImageDecoder.cpp:
637         (WebCore::GIFImageDecoder::frameCount):
638         (WebCore::GIFImageDecoder::frameBufferAtIndex):
639         (WebCore::GIFImageDecoder::decode):
640         (WebCore::GIFImageDecoder::encodedDataStatus): Deleted.
641         * platform/image-decoders/gif/GIFImageDecoder.h:
642         * platform/image-decoders/ico/ICOImageDecoder.cpp:
643         (WebCore::ICOImageDecoder::setData):
644         (WebCore::ICOImageDecoder::frameCount):
645         (WebCore::ICOImageDecoder::frameBufferAtIndex):
646         (WebCore::ICOImageDecoder::setDataForPNGDecoderAtIndex):
647         (WebCore::ICOImageDecoder::decode):
648         (WebCore::ICOImageDecoder::decodeAtIndex):
649         (WebCore::ICOImageDecoder::encodedDataStatus): Deleted.
650         * platform/image-decoders/ico/ICOImageDecoder.h:
651         * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
652         (WebCore::JPEGImageDecoder::frameBufferAtIndex):
653         (WebCore::JPEGImageDecoder::decode):
654         (WebCore::JPEGImageDecoder::encodedDataStatus): Deleted.
655         * platform/image-decoders/jpeg/JPEGImageDecoder.h:
656         * platform/image-decoders/png/PNGImageDecoder.cpp:
657         (WebCore::PNGImageDecoder::frameBufferAtIndex):
658         (WebCore::PNGImageDecoder::decode):
659         (WebCore::PNGImageDecoder::encodedDataStatus): Deleted.
660         * platform/image-decoders/png/PNGImageDecoder.h:
661         * platform/image-decoders/webp/WEBPImageDecoder.cpp:
662         (WebCore::WEBPImageDecoder::frameBufferAtIndex):
663         (WebCore::WEBPImageDecoder::decode):
664         (WebCore::WEBPImageDecoder::encodedDataStatus): Deleted.
665         * platform/image-decoders/webp/WEBPImageDecoder.h:
666
667 2017-04-27  Carlos Garcia Campos  <cgarcia@igalia.com>
668
669         Move UUID from WebCore/platform to WTF
670         https://bugs.webkit.org/show_bug.cgi?id=171372
671
672         Reviewed by Michael Catanzaro.
673
674         UUID only contains createCanonicalUUIDString() that is platform independent and doesn't depend on anything from
675         WebCore, only from WTF.
676
677         * CMakeLists.txt:
678         * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
679         * Modules/mediacontrols/MediaControlsHost.cpp:
680         * Modules/mediastream/RTCPeerConnection.cpp:
681         * Modules/webaudio/MediaStreamAudioSource.cpp:
682         * Modules/webdatabase/DatabaseTracker.cpp:
683         * WebCore.order:
684         * WebCore.xcodeproj/project.pbxproj:
685         * editing/mac/EditorMac.mm:
686         * fileapi/BlobURL.cpp:
687         * loader/appcache/ApplicationCacheHost.cpp:
688         * loader/appcache/ApplicationCacheStorage.cpp:
689         * platform/URL.cpp:
690         * platform/glib/FileSystemGlib.cpp:
691         * platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:
692         * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
693         * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
694         * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
695         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
696         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
697         * platform/mediastream/CaptureDeviceManager.cpp:
698         * platform/mediastream/MediaStreamPrivate.h:
699         * platform/mediastream/MediaStreamTrackPrivate.cpp:
700         * platform/mediastream/RealtimeMediaSource.cpp:
701         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
702         * platform/mediastream/mac/AVMediaCaptureSource.mm:
703         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
704         * platform/mock/MockRealtimeAudioSource.cpp:
705         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
706         * platform/mock/MockRealtimeVideoSource.cpp:
707         * testing/MockCDMFactory.cpp:
708
709 2017-04-27  Alex Christensen  <achristensen@webkit.org>
710
711         Make navigation policy checking more robust
712         https://bugs.webkit.org/show_bug.cgi?id=171409
713         <rdar://problem/31489248>
714
715         Reviewed by Geoffrey Garen.
716
717         No change in behavior.  Just added a protectedThis to a lambda and made the functions non-copyable.
718
719         * loader/DocumentLoader.cpp:
720         (WebCore::DocumentLoader::willSendRequest):
721         * loader/PolicyCallback.cpp:
722         (WebCore::PolicyCallback::set):
723         (WebCore::PolicyCallback::clear): Deleted.
724         * loader/PolicyCallback.h:
725         * loader/PolicyChecker.cpp:
726         (WebCore::PolicyChecker::cancelCheck):
727         (WebCore::PolicyChecker::stopCheck):
728         (WebCore::PolicyChecker::continueAfterNavigationPolicy):
729         (WebCore::PolicyChecker::continueAfterNewWindowPolicy):
730         (WebCore::PolicyChecker::continueAfterContentPolicy):
731
732 2017-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
733
734         Data interaction should not load pasteboard content before performing the data operation
735         https://bugs.webkit.org/show_bug.cgi?id=171414
736         <rdar://problem/31878197>
737
738         Reviewed by Tim Horton.
739
740         When interacting with a link, we should not try to fetch pasteboard contents for the URL UTI type before
741         performing the data operation. Teaches DragController to know whether it is allowed to load data from the
742         dragging pasteboard, and uses this information in DragController::dragOperation to determine whether to use
743         DragData::containsURLTypeIdentifier or DragData::containsURL.
744
745         * page/DragController.cpp:
746         (WebCore::DragController::DragController):
747         (WebCore::DragController::performDragOperation):
748         * page/DragController.h:
749         (WebCore::DragController::canLoadDataFromDraggingPasteboard):
750         * page/mac/DragControllerMac.mm:
751         (WebCore::DragController::dragOperation):
752         * platform/DragData.h:
753         * platform/ios/WebItemProviderPasteboard.mm:
754         (-[WebItemProviderPasteboard _preLoadedDataConformingToType:forItemProviderAtIndex:]):
755         * platform/mac/DragDataMac.mm:
756         (WebCore::DragData::containsURLTypeIdentifier):
757
758 2017-04-27  Joseph Pecoraro  <pecoraro@apple.com>
759
760         Support for promise rejection events (unhandledrejection)
761         https://bugs.webkit.org/show_bug.cgi?id=150358
762         <rdar://problem/28441651>
763
764         Reviewed by Saam Barati.
765
766         Patch by Joseph Pecoraro and Yusuke Suzuki.
767
768         Implement support for the `onunhandledrejection` and `rejectionhandled` events.
769         They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
770         https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
771         https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
772
773         This is currently implemented only for Documents and not yet Web Workers.
774
775         Tests: js/dom/unhandled-promise-rejection-basic.html
776                js/dom/unhandled-promise-rejection-bindings-type-error.html
777                js/dom/unhandled-promise-rejection-console-no-report.html
778                js/dom/unhandled-promise-rejection-console-report.html
779                js/dom/unhandled-promise-rejection-handle-during-event.html
780                js/dom/unhandled-promise-rejection-handle-in-handler.html
781                js/dom/unhandled-promise-rejection-handle.html
782                js/dom/unhandled-promise-rejection-order.html
783
784         * CMakeLists.txt:
785         * DerivedSources.cpp:
786         * DerivedSources.make:
787         * WebCore.xcodeproj/project.pbxproj:
788         * dom/DOMAllInOne.cpp:
789         New files.
790
791         * bindings/scripts/CodeGenerator.pm:
792         (IsPromiseType):
793         * bindings/scripts/CodeGeneratorJS.pm:
794         (AddToIncludesForIDLType):
795         (GetBaseIDLType):
796         Binding support for Promise<T> attributes.
797
798         * bindings/js/JSDOMConvert.h:
799         * bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
800         (WebCore::Converter<IDLPromise<T>>::convert):
801         (WebCore::JSConverter<IDLPromise<T>>::convert):
802         Promise<T> binding conversion is currently unimplemented, which only means
803         web developers creating their own PromiseRejectionEvent will not get
804         autowrapping of values assigned to `promise` in event initialization.
805         Engine generated events will have expected behavior.
806
807         * bindings/js/JSDOMWindowBase.cpp:
808         (WebCore::JSDOMWindowBase::promiseRejectionTracker):
809         * bindings/js/JSDOMWindowBase.h:
810         * bindings/js/JSWorkerGlobalScopeBase.cpp:
811         Implement HostPromiseRejectionTracker hook for Document but not Worker.
812         Passes through to the ScriptExecutionContext's tracker.
813
814         * bindings/js/JSMainThreadExecState.cpp:
815         (WebCore::JSMainThreadExecState::didLeaveScriptContext):
816         * bindings/js/JSMainThreadExecState.h:
817         (WebCore::JSMainThreadExecState::~JSMainThreadExecState):
818         When completing script execution and performing microtasks notify
819         about rejected promises. Technically this should go inside of
820         performing a microtask checkpoint, except lacking EventLoop
821         concepts we use ScriptExecutionState.
822
823         * dom/EventNames.h:
824         * dom/EventNames.in:
825         * dom/PromiseRejectionEvent.cpp: Added.
826         (WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
827         (WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
828         * dom/PromiseRejectionEvent.h: Added.
829         * dom/PromiseRejectionEvent.idl: Added.
830         New PromiseRejectionEvent event interface.
831
832         * dom/GlobalEventHandlers.idl:
833         New onunhandledrejection and onrejectionhandled.
834
835         * dom/RejectedPromiseTracker.cpp: Added.
836         (WebCore::RejectedPromise::RejectedPromise):
837         (WebCore::RejectedPromise::globalObject):
838         (WebCore::RejectedPromise::promise):
839         (WebCore::UnhandledPromise::UnhandledPromise):
840         (WebCore::UnhandledPromise::callStack):
841         (WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
842         (WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
843         (WebCore::createScriptCallStackFromReason):
844         (WebCore::RejectedPromiseTracker::promiseRejected):
845         (WebCore::RejectedPromiseTracker::promiseHandled):
846         (WebCore::RejectedPromiseTracker::processQueueSoon):
847         (WebCore::RejectedPromiseTracker::reportUnhandledRejections):
848         (WebCore::RejectedPromiseTracker::reportRejectionHandled):
849         * dom/RejectedPromiseTracker.h: Added.
850         Track and report rejected promises. The promises are tracked weakly
851         allowing them to be collected before they are reported. When reporting
852         we dispatch PromiseRejectionEvent events, and if the default is not
853         prevented we log a message to the console.
854
855         * dom/ScriptExecutionContext.cpp:
856         (WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
857         (WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
858         * dom/ScriptExecutionContext.h:
859         (WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
860         Each ScriptExecutionContext can own a rejected promise tracker.
861
862         * html/HTMLMediaElement.cpp:
863         (WebCore::HTMLMediaElement::pauseInternal):
864         https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
865         Internal pause steps say to timeupdate, pause, and rejecting pending play promises
866         should all happen in a queued task. Here the first two actions are already scheduled
867         on tasks, but rejecting play promises was not being done in a task, so this makes
868         that change.
869
870         * Modules/streams/ReadableStream.js:
871         (pipeThrough):
872         * Modules/streams/ReadableStreamInternals.js:
873         (readableStreamReaderGenericInitialize):
874         (readableStreamError):
875         (readableStreamReaderGenericRelease):
876         Satisfy parts of the Streams specification which state to set the
877         [[PromiseIsHandled]] internal state of promises created internally
878         by the Streams APIs. This prevents some internal promises from
879         appearing as unhandled promise rejections.
880
881 2017-04-27  Chris Dumez  <cdumez@apple.com>
882
883         Align colspan/rowspan limits with the latest HTML specification
884         https://bugs.webkit.org/show_bug.cgi?id=171322
885
886         Reviewed by Darin Adler.
887
888         Align colspan/rowspan limits with the latest HTML specification after:
889         - https://github.com/whatwg/html/pull/1993
890
891         The following changes were made:
892         - Our rowspan limit was raised from 8190 to 65534
893         - A colspan limit of 1000 was introduced. Blink has UseCounter data showing that
894           colspans over 1000 are extremely rare and Gecko has data showing that when we
895           get a colspan greater than 1000, it is usually a bug. Therefore, this change
896           should be fine.
897         - The limits are now properly reflected via the IDL attributes instead of lying
898           to the Web about the colspan / rowspan we are using internally.
899
900         Test: imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/span-limits.html
901
902         * html/HTMLTableCellElement.cpp:
903         (WebCore::HTMLTableCellElement::colSpan):
904         (WebCore::HTMLTableCellElement::rowSpan):
905         (WebCore::HTMLTableCellElement::rowSpanForBindings):
906         (WebCore::HTMLTableCellElement::setColSpan):
907         * html/HTMLTableCellElement.h:
908         * html/HTMLTableCellElement.idl:
909         * html/parser/HTMLParserIdioms.cpp:
910         (WebCore::parseHTMLIntegerInternal):
911         (WebCore::parseHTMLInteger):
912         (WebCore::parseHTMLNonNegativeInteger):
913         (WebCore::parseValidHTMLNonNegativeIntegerInternal):
914         (WebCore::parseHTTPRefreshInternal):
915         * html/parser/HTMLParserIdioms.h:
916         (WebCore::parseHTMLInteger):
917         (WebCore::parseHTMLNonNegativeInteger):
918
919         (WebCore::clampHTMLNonNegativeIntegerToRange):
920         Add utility function to implement:
921         - https://html.spec.whatwg.org/#clamped-to-the-range
922
923 2017-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
924
925         WKUIDelegatePrivate needs a hook to vend data used to initialize item providers for data interaction
926         https://bugs.webkit.org/show_bug.cgi?id=171386
927         <rdar://problem/31557237>
928
929         Reviewed by Beth Dakin.
930
931         Teach WebItemProviderPasteboard to remember what WebItemProviderRegistrationInfoList it was initialized with
932         when beginning a drag. This information is cleared out the next time the list of item providers is set to
933         something different, which happens when the data interaction session concludes.
934
935         * platform/ios/WebItemProviderPasteboard.h:
936         * platform/ios/WebItemProviderPasteboard.mm:
937         (-[WebItemProviderPasteboard init]):
938         (-[WebItemProviderPasteboard setItemProviders:]):
939         (-[WebItemProviderPasteboard setItemsUsingRegistrationInfoLists:]):
940         (-[WebItemProviderPasteboard registrationInfoAtIndex:]):
941         (-[WebItemProviderPasteboard itemProviderAtIndex:]):
942
943 2017-04-27  Brady Eidson  <beidson@apple.com>
944
945         Refactor SessionID to support multiple non-ephemeral (persistent) sessions.
946         https://bugs.webkit.org/show_bug.cgi?id=171367
947
948         Reviewed by Andy Estes.
949
950         This is also a nice general cleanup of SessionID, including privatizing the "arbitrary number" constructor
951         and moving encode/decode into the class.
952
953         No new tests (Refactor, no behavior change yet).
954
955         * CMakeLists.txt:
956         * WebCore.xcodeproj/project.pbxproj:
957         
958         * page/SessionID.cpp: Added.
959         (WebCore::SessionID::generatePersistentSessionID):
960         (WebCore::SessionID::generateEphemeralSessionID):
961         (WebCore::SessionID::enableGenerationProtection):
962         
963         * page/SessionID.h:
964         (WebCore::SessionID::SessionID):
965         (WebCore::SessionID::emptySessionID):
966         (WebCore::SessionID::hashTableDeletedValue):
967         (WebCore::SessionID::defaultSessionID):
968         (WebCore::SessionID::legacyPrivateSessionID):
969         (WebCore::SessionID::isValid):
970         (WebCore::SessionID::isEphemeral):
971         (WebCore::SessionID::encode):
972         (WebCore::SessionID::decode):
973         (WTF::HashTraits<WebCore::SessionID>::constructDeletedValue):
974         (WTF::HashTraits<WebCore::SessionID>::isDeletedValue):
975
976 2017-04-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
977
978         Attempt to fix a PLT regression on Mac
979         <rdar://problem/31826998>
980
981         Unreviewed.
982
983         Disable passing the TypeIdentifierHint to CGImageSourceCreateIncremental()
984         on Mac for now.
985
986         * platform/graphics/cg/ImageDecoderCG.cpp:
987         (WebCore::ImageDecoder::ImageDecoder):
988
989 2017-04-27  Daniel Bates  <dabates@apple.com>
990
991         Rename callerDOMWindow()/CallerDocument to incumbentDOMWindow()/IncumbentDocument
992         https://bugs.webkit.org/show_bug.cgi?id=171145
993
994         Reviewed by Saam Barati.
995
996         Standardize on the terminology "incumbent" to refer to "most-recently-entered author
997         function or script on the stack, or the author function or script that originally
998         scheduled the currently-running callback" (1).
999
1000         [1] <https://html.spec.whatwg.org/multipage/webappapis.html#realms-settings-objects-global-objects> (27 April 2017)
1001
1002         * bindings/js/JSDOMWindowBase.cpp:
1003         (WebCore::incumbentDOMWindow):
1004         (WebCore::callerDOMWindow): Deleted.
1005         * bindings/js/JSDOMWindowBase.h:
1006         * bindings/scripts/CodeGeneratorJS.pm:
1007         (GenerateCallWith):
1008         * bindings/scripts/test/JS/JSTestObj.cpp:
1009         (WebCore::jsTestObjPrototypeFunctionWithCallerDocumentArgumentCaller):
1010         (WebCore::jsTestObjPrototypeFunctionWithCallerWindowArgumentCaller):
1011         * bindings/scripts/test/TestObj.idl:
1012         * page/DOMWindow.idl:
1013
1014 2017-04-27  Youenn Fablet  <youenn@apple.com>
1015
1016         LayoutTest webrtc/datachannel/datachannel-event.html is a flaky crash
1017         https://bugs.webkit.org/show_bug.cgi?id=171092
1018         <rdar://problem/31748066>
1019
1020         Reviewed by Eric Carlson.
1021
1022         Covered by manual testing on iterating on the crashing tests.
1023         With the patch, they appear to no longer crash.
1024
1025         The current RTCPeerConnection/RTCController was expecting that peer connections would be stopped before the controller.
1026         This assumption is sometimes wrong.
1027         Adding clean-up on both sides so that if controller goes away, it notifies its peer connections that they are unregistered.
1028
1029         * Modules/mediastream/RTCController.cpp:
1030         (WebCore::RTCController::~RTCController):
1031         * Modules/mediastream/RTCController.h:
1032         * Modules/mediastream/RTCPeerConnection.cpp:
1033         (WebCore::RTCPeerConnection::create):
1034         (WebCore::RTCPeerConnection::~RTCPeerConnection):
1035         (WebCore::RTCPeerConnection::doStop):
1036         (WebCore::RTCPeerConnection::registerToController):
1037         (WebCore::RTCPeerConnection::unregisterFromController):
1038         (WebCore::RTCPeerConnection::rtcController): Deleted.
1039         * Modules/mediastream/RTCPeerConnection.h:
1040
1041 2017-04-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
1042
1043         REGRESSION(r213764): Async decoding of animated images is disabled for ImageDocument
1044         https://bugs.webkit.org/show_bug.cgi?id=170333
1045
1046         Reviewed by Simon Fraser.
1047
1048         The way the image drawing settings are transfered from the Settings to
1049         BitmapImage is problematic. The drawing settings are retrieved from the
1050         CachedImageObserver which store them in the constructor only if the
1051         CachedImage as a loader. In the case of ImageDocument, there isn't loader
1052         set in CachedImage so the settings of ImageDocument are not set. Also
1053         the CachedImage can be used after loading by another document which may
1054         have a different drawing settings.
1055
1056         The fix is to make BitmapImage reads the drawing settings every time it 
1057         is drawn as a foreground or background image in a RenderElement.
1058
1059         * html/canvas/CanvasRenderingContext2D.cpp:
1060         (WebCore::CanvasRenderingContext2D::drawImage):
1061         * loader/cache/CachedImage.cpp:
1062         (WebCore::CachedImage::CachedImageObserver::CachedImageObserver):
1063         * loader/cache/CachedImage.h:
1064         * platform/graphics/BitmapImage.cpp:
1065         (WebCore::BitmapImage::setDrawingSettings):
1066         (WebCore::BitmapImage::draw):
1067         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImages): I was
1068         trying to disable the async image decoding temporarily but this way will
1069         even prevent testing it until it is enabled. Disable it through WK1 and
1070         WK2 preferences.
1071         (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages):
1072         (WebCore::BitmapImage::advanceAnimation):
1073         * platform/graphics/BitmapImage.h:
1074         * platform/graphics/ImageObserver.h:
1075         * rendering/RenderBoxModelObject.cpp:
1076         (WebCore::RenderBoxModelObject::paintFillLayerExtended):
1077         * rendering/RenderImage.cpp:
1078         (WebCore::RenderImage::paintIntoRect):
1079
1080 2017-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
1081
1082         Performing data interaction with plain text into a contenteditable does not insert any content
1083         https://bugs.webkit.org/show_bug.cgi?id=171381
1084
1085         Reviewed by Tim Horton.
1086
1087         Attempt to read plain-text-conformant UTI types as kUTTypePlainText before reading them as kUTTypeText.
1088         This allows WebItemProviderPasteboard to properly materialize an NSString in -valuesForPasteboardType:
1089         inItemSet: using a pre-loaded NSData blob.
1090
1091         This scenario is covered by DataInteractionTests.ExternalSourceUTF8PlainTextOnly, but DataInteractionTests
1092         are temporarily disabled due to incompatibilities with the current internal SDK.
1093
1094         * platform/ios/PasteboardIOS.mm:
1095         (WebCore::readPasteboardWebContentDataForType):
1096
1097 2017-04-27  Chris Dumez  <cdumez@apple.com>
1098
1099         Element.getBoundingClientRect() / getClientRects() should return a DOMRect types
1100         https://bugs.webkit.org/show_bug.cgi?id=171226
1101
1102         Reviewed by Simon Fraser.
1103
1104         Element.getBoundingClientRect() / getClientRects() should return a DOMRect types
1105         as per:
1106         - https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface
1107
1108         DOMRect is compatible with ClientRect, which we used to return so the risk should
1109         be low.
1110
1111         Tests: fast/css/DOMRect-attributes-prototype.html
1112                fast/css/DOMRect-serialization.html
1113                fast/dom/Element/getClientRects-return-type.html
1114
1115         * dom/ClientRectList.cpp:
1116         (WebCore::ClientRectList::ClientRectList):
1117         * dom/ClientRectList.h:
1118         (WebCore::ClientRectList::create):
1119         * dom/DOMRect.h:
1120         (WebCore::DOMRect::create):
1121         * dom/DOMRectReadOnly.h:
1122         * dom/Element.cpp:
1123         (WebCore::toDOMRectVector):
1124         (WebCore::Element::getClientRects):
1125         (WebCore::Element::getBoundingClientRect):
1126         * dom/Element.h:
1127         * dom/Element.idl:
1128         * html/track/VTTRegion.cpp:
1129         (WebCore::VTTRegion::displayLastTextTrackCueBox):
1130
1131 2017-04-27  Joanmarie Diggs  <jdiggs@igalia.com>
1132
1133         AX: Expose elements with the ARIA "feed" role
1134         https://bugs.webkit.org/show_bug.cgi?id=171184
1135
1136         Reviewed by Chris Fleizach.
1137
1138         Map elements with the "feed" role to the internal ApplicationGroupRole
1139         AccessibilityRole. This prevents them from being unexpectedly pruned from
1140         the accessibility tree, and causes them to be exposed with ATK_ROLE_PANEL
1141         in WebKitGtk and AXGroup in Safari.
1142
1143         No new tests needed. Instead, add the "feed" role to roles-exposed.html,
1144         xml-roles-exposed.html, and roles-computedRoleString.html.
1145
1146         * accessibility/AccessibilityObject.cpp:
1147         (WebCore::initializeRoleMap):
1148
1149 2017-04-27  Brady Eidson  <beidson@apple.com>
1150
1151         Update NetworkStorageSession to support multiple persistent sessions and explicitly set cookie storages.
1152         https://bugs.webkit.org/show_bug.cgi?id=171365
1153
1154         Reviewed by Andy Estes.
1155
1156         No new tests (No testable behavior change yet).
1157
1158         * platform/network/NetworkStorageSession.cpp:
1159         (WebCore::NetworkStorageSession::destroySession):
1160         * platform/network/NetworkStorageSession.h:
1161         
1162         * platform/network/NetworkStorageSessionStub.cpp:
1163         (WebCore::NetworkStorageSession::ensurePrivateBrowsingSession):
1164         (WebCore::NetworkStorageSession::ensureSession):
1165         
1166         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
1167         (WebCore::createCFStorageSessionForIdentifier):
1168         (WebCore::NetworkStorageSession::NetworkStorageSession):
1169         (WebCore::NetworkStorageSession::switchToNewTestingSession):
1170         (WebCore::NetworkStorageSession::defaultStorageSession):
1171         (WebCore::NetworkStorageSession::ensurePrivateBrowsingSession):
1172         (WebCore::NetworkStorageSession::ensureSession):
1173         (WebCore::NetworkStorageSession::cookieStorage):
1174         
1175         * platform/network/soup/NetworkStorageSessionSoup.cpp:
1176         (WebCore::NetworkStorageSession::ensureSession):
1177         
1178         * platform/spi/cf/CFNetworkSPI.h:
1179
1180 2017-04-27  Zalan Bujtas  <zalan@apple.com>
1181
1182         Use text-shadow to visualize simple line layout coverage.
1183         https://bugs.webkit.org/show_bug.cgi?id=171379
1184
1185         Reviewed by Antti Koivisto.
1186
1187         It's more subtle (for everyday use).
1188
1189         * rendering/SimpleLineLayoutFunctions.cpp:
1190         (WebCore::SimpleLineLayout::paintFlow):
1191         (WebCore::SimpleLineLayout::paintDebugBorders): Deleted.
1192
1193 2017-04-27  Joanmarie Diggs  <jdiggs@igalia.com>
1194
1195         [ATK] ARIA alertdialogs should be exposed with ROLE_DIALOG
1196         https://bugs.webkit.org/show_bug.cgi?id=171187
1197
1198         Reviewed by Chris Fleizach.
1199
1200         Map ApplicationAlertDialogRole to ATK_ROLE_DIALOG. While ATK_ROLE_ALERT is
1201         appropriate as far as ATK is concerned, the Core Accessibility API Mappings
1202         map ARIA's alertdialog role to ATK_ROLE_DIALOG. We should be consistent
1203         with the spec. The fact that this is an alert dialog can still be obtained
1204         via the AtkObject attributes.
1205
1206         No new tests needed. Update the expectations for roles-exposed.html,
1207         xml-roles-exposed.html, and aria-mappings.html to reflect the change.
1208
1209         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
1210         (atkRole):
1211
1212 2017-04-27  Antti Koivisto  <antti@apple.com>
1213
1214         Repeated layouts in Mail due to viewport units being used with auto-sizing
1215         https://bugs.webkit.org/show_bug.cgi?id=171371
1216         <rdar://problem/28780084>
1217
1218         Reviewed by Zalan Bujtas.
1219
1220         Test: css3/viewport-percentage-lengths/vh-auto-size.html
1221
1222         Auto-sizing code would adjust the size of the view in the beginning of layout(). This would
1223         end up invalidating style for elements that use vh units and we would perform main layout
1224         with unclean style. This would result in endless layout loops and hit assert on debug.
1225
1226         * page/FrameView.cpp:
1227         (WebCore::FrameView::availableContentSizeChanged):
1228
1229             Ensure we heve clean style after resize if we are in pre-layout.
1230
1231 2017-04-27  Alex Christensen  <achristensen@webkit.org>
1232
1233         Modernize Frame.h
1234         https://bugs.webkit.org/show_bug.cgi?id=171357
1235
1236         Reviewed by Andy Estes.
1237
1238         Frame.h has several std::unique_ptrs that are created in the constructor, never null,
1239         and destroyed in the destructor.  This is what WTF::UniqueRef is for, and using UniqueRef
1240         allows us to not check for null values because a UniqueRef can never be null.
1241         An interesting case was the EventHandler, which we explicitly set to nullptr in the destructor
1242         of MainFrame, a subclass of Frame.  We added this in r199181 to fix a crash tested by
1243         fast/events/wheel-event-destroys-frame.html and this improved lifetime also does not crash
1244         or assert in that test.
1245
1246         Using UniqueRef also requires const correctness, which this patch adds when necessary.
1247
1248         * accessibility/AccessibilityObject.cpp:
1249         (WebCore::AccessibilityObject::dispatchTouchEvent):
1250         * editing/DeleteSelectionCommand.cpp:
1251         (WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
1252         * editing/Editor.cpp:
1253         (WebCore::Editor::isSelectTrailingWhitespaceEnabled):
1254         (WebCore::Editor::computeAndSetTypingStyle):
1255         * editing/Editor.h:
1256         * editing/FrameSelection.cpp:
1257         (WebCore::FrameSelection::contains):
1258         (WebCore::FrameSelection::copyTypingStyle):
1259         * editing/FrameSelection.h:
1260         (WebCore::FrameSelection::setTypingStyle):
1261         * loader/EmptyClients.cpp:
1262         * loader/FrameLoader.cpp:
1263         (WebCore::FrameLoader::clear):
1264         * page/EditorClient.h:
1265         * page/EventHandler.cpp:
1266         (WebCore::EventHandler::hitTestResultAtPoint):
1267         * page/EventHandler.h:
1268         * page/Frame.cpp:
1269         (WebCore::Frame::Frame):
1270         (WebCore::Frame::setView):
1271         (WebCore::Frame::injectUserScripts):
1272         * page/Frame.h:
1273         (WebCore::Frame::editor):
1274         (WebCore::Frame::eventHandler):
1275         (WebCore::Frame::selection):
1276         (WebCore::Frame::animation):
1277         (WebCore::Frame::script):
1278         (WebCore::Frame::eventHandlerPtr): Deleted.
1279         * page/MainFrame.cpp:
1280         (WebCore::MainFrame::~MainFrame):
1281         * replay/UserInputBridge.cpp:
1282         (WebCore::UserInputBridge::handleContextMenuEvent):
1283         * replay/UserInputBridge.h:
1284
1285 2017-04-27  Andy Estes  <aestes@apple.com>
1286
1287         Fix the macOS build.
1288
1289         * platform/mac/WebPlaybackControlsManager.h:
1290
1291 2017-04-27  Zalan Bujtas  <zalan@apple.com>
1292
1293         Text gets cut off when bailing out of simple line layout with widows.
1294         https://bugs.webkit.org/show_bug.cgi?id=171370
1295         <rdar://problem/31563414>
1296
1297         Reviewed by Antti Koivisto.
1298
1299         Normal line layout requires an extra layout to handle widows. See RenderBlockFlow::relayoutToAvoidWidows. 
1300
1301         Test: fast/multicol/simple-line-layout-widows-when-switching-over-to-normal-line-layout.html
1302
1303         * rendering/RenderBlockFlow.cpp:
1304         (WebCore::RenderBlockFlow::ensureLineBoxes):
1305
1306 2017-04-27  Dean Jackson  <dino@apple.com>
1307
1308         Use the correct modern-media-controls
1309         https://bugs.webkit.org/show_bug.cgi?id=171358
1310
1311         Reviewed by Antoine Quint.
1312
1313         * WebCore.xcodeproj/project.pbxproj:
1314
1315 2017-04-26  Dan Bernstein  <mitz@apple.com>
1316
1317         Reverted r215774.
1318
1319         That change wasn’t doing what it was intended to do and was inappropriate for WebCore.
1320
1321         * WebCore.xcodeproj/project.pbxproj:
1322
1323 2017-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
1324
1325         Attempt to fix a PLT regression.
1326         <rdar://problem/31826998>
1327
1328         Unreviewed.
1329
1330         Disable passing the TypeIdentifierHint to CGImageSourceCreateIncremental()
1331         on iOS for now.
1332
1333         * platform/graphics/cg/ImageDecoderCG.cpp:
1334         (WebCore::ImageDecoder::ImageDecoder):
1335
1336 2017-04-26  Joanmarie Diggs  <jdiggs@igalia.com>
1337
1338         [ATK] ARIA buttons which have a popup should be ATK_ROLE_PUSH_BUTTON; not ATK_ROLE_COMBO_BOX
1339         https://bugs.webkit.org/show_bug.cgi?id=171182
1340
1341         Reviewed by Chris Fleizach.
1342
1343         Test: accessibility/gtk/button-with-aria-haspopup-is-not-a-combobox.html
1344
1345         WebCore Accessibility assigns PopUpButtonRole to collapsed select elements,
1346         which the ATK code correctly maps to ATK_ROLE_COMBO_BOX. It turns out that
1347         WebCore Accessibility also maps the ARIA button role to PopUpButtonRole if
1348         it also has aria-haspopup. Add a check to atkRole() so that the latter case
1349         is mapped to ATK_ROLE_PUSH_BUTTON.
1350
1351         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
1352         (atkRole):
1353
1354 2017-04-26  Tim Horton  <timothy_horton@apple.com>
1355
1356         Should not drag x-apple-data-detectors links
1357         https://bugs.webkit.org/show_bug.cgi?id=171352
1358         <rdar://problem/31309081>
1359
1360         Reviewed by Beth Dakin.
1361
1362         Test: fast/events/do-not-drag-and-drop-data-detectors-link.html
1363
1364         These links are only meaningful in the context of the original document,
1365         so they should not be draggable.
1366
1367         * editing/cocoa/DataDetection.h:
1368         * editing/cocoa/DataDetection.mm:
1369         (WebCore::DataDetection::dataDetectorURLProtocol):
1370         (WebCore::DataDetection::isDataDetectorURL):
1371         * page/DragController.cpp:
1372         (WebCore::isDraggableLink):
1373         Disallow dragging of <a href="x-apple-data-detectors://..."> links.
1374
1375 2017-04-26  Tim Horton  <timothy_horton@apple.com>
1376
1377         Revert accidentally smushed commit.
1378
1379         * editing/cocoa/DataDetection.h:
1380         * editing/cocoa/DataDetection.mm:
1381         (WebCore::DataDetection::dataDetectorURLProtocol): Deleted.
1382         (WebCore::DataDetection::isDataDetectorURL): Deleted.
1383         * page/DragController.cpp:
1384         (WebCore::isDraggableLink):
1385         * platform/mac/DragImageMac.mm:
1386         (WebCore::createDragImageForLink):
1387
1388 2017-04-26  Alex Christensen  <achristensen@webkit.org>
1389
1390         REGRESSION (r215686): ASSERTION FAILED: data seen with webarchive/loading tests
1391         https://bugs.webkit.org/show_bug.cgi?id=171340
1392
1393         Reviewed by Brady Eidson.
1394
1395         This fixes a flaky assertion in webarchive/loading/missing-data.html
1396
1397         * platform/cf/SharedBufferCF.cpp:
1398         (WebCore::SharedBuffer::append):
1399         If there's no CFDataRef, there's no need to append data.
1400         This happens sometimes.
1401
1402 2017-04-26  Ryan Haddad  <ryanhaddad@apple.com>
1403
1404         Unreviewed, rolling out r215814.
1405
1406         The LayoutTest for this change is failing on ios-simulator and
1407         is flaky on macOS.
1408
1409         Reverted changeset:
1410
1411         "Response.blob() does not set the content-type based on the
1412         header value."
1413         https://bugs.webkit.org/show_bug.cgi?id=170849
1414         http://trac.webkit.org/changeset/215814
1415
1416 2017-04-26  Wenson Hsieh  <wenson_hsieh@apple.com>
1417
1418         WebItemProviderPasteboard should not synchronously load provided data
1419         https://bugs.webkit.org/show_bug.cgi?id=171341
1420         <rdar://problem/31614010>
1421
1422         Reviewed by Tim Horton.
1423
1424         Refactors WebItemProviderPasteboard to not require asynchronously loading item provider data. To accomplish this,
1425         we ensure that before performing data interaction, the UTI type that the data operation target should consume is
1426         propagated to the UI process prior to the web process receiving the signal from the UI process to begin the
1427         data operation itself. This information is sent via WebPlatformStrategies::updatePreferredTypeIdentifiers, a new
1428         pasteboard helper function.
1429
1430         * page/DragController.cpp:
1431         (WebCore::DragController::DragController):
1432         (WebCore::dragIsHandledByDocument):
1433         (WebCore::DragController::performDragOperation):
1434         (WebCore::DragController::dragEnteredOrUpdated):
1435         (WebCore::DragController::updatePreferredTypeIdentifiersForDragHandlingMethod):
1436         (WebCore::DragController::tryDocumentDrag):
1437
1438         Give DragHandlingMethod a richer representation of what type of action will be performed. DragController::
1439         updatePreferredTypeIdentifiersForDragHandlingMethod uses this to determine what kinds of UTIs are acceptable for
1440         the current drop session.
1441
1442         * page/DragController.h:
1443         (WebCore::DragController::documentIsHandlingNonDefaultDrag):
1444         * page/mac/DragControllerMac.mm:
1445         (WebCore::DragController::updatePreferredTypeIdentifiersForDragHandlingMethod):
1446
1447         Updates the data interaction pasteboard's list of preferred type identifiers it should load upon data operation.
1448
1449         * platform/DragData.h:
1450         * platform/PasteboardStrategy.h:
1451         * platform/PlatformPasteboard.h:
1452         * platform/ios/AbstractPasteboard.h:
1453         * platform/ios/PlatformPasteboardIOS.mm:
1454         (WebCore::PlatformPasteboard::updatePreferredTypeIdentifiers):
1455         * platform/ios/WebItemProviderPasteboard.mm:
1456
1457         Introduce _preferredTypeIdentifiers, which -doAfterLoadingProvidedContentIntoFileURLs: uses as a hint when
1458         determining which UTI to load for an item provider. In the absence of preferred type identifiers, the default
1459         behavior is to use the highest fidelity type adhering to "public.content".
1460
1461         (-[WebItemProviderPasteboard init]):
1462         (-[WebItemProviderPasteboard updatePreferredTypeIdentifiers:]):
1463         (-[WebItemProviderPasteboard setItemProviders:]):
1464         (-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
1465         (-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):
1466
1467         Remove calls to -createObjectOfClass: and -copyDataRepresentation:. Instead, rely solely on the loaded file URL
1468         to read and initialize data and objects from the pasteboard.
1469
1470         (-[WebItemProviderPasteboard doAfterLoadingProvidedContentIntoFileURLs:]):
1471         (-[WebItemProviderPasteboard _tryToCreateObjectOfClass:usingProvider:]): Deleted.
1472         * platform/mac/DragDataMac.mm:
1473         (WebCore::DragData::updatePreferredTypeIdentifiers):
1474
1475 2017-04-26  Joanmarie Diggs  <jdiggs@igalia.com>
1476
1477         [ATK] Elements with a defined, non-false value for aria-current should expose ATK_STATE_ACTIVE
1478         https://bugs.webkit.org/show_bug.cgi?id=171163
1479
1480         Reviewed by Chris Fleizach.
1481
1482         Add ATK_STATE_ACTIVE to the state set of elements which have a valid, non-false
1483         value for aria-current, expose the value of via the "current" AtkObject attribute,
1484         and emit state-change notifications when the value of aria-current changes from
1485         non-false to false, or vice versa.
1486
1487         Tests: accessibility/gtk/aria-current-changed-notification.html
1488                accessibility/gtk/aria-current.html
1489
1490         * accessibility/AXObjectCache.cpp:
1491         (WebCore::AXObjectCache::handleAttributeChanged):
1492         * accessibility/AXObjectCache.h:
1493         * accessibility/AccessibilityObject.cpp:
1494         (WebCore::AccessibilityObject::supportsARIACurrent):
1495         (WebCore::AccessibilityObject::ariaCurrentValue):
1496         * accessibility/AccessibilityObject.h:
1497         * accessibility/atk/AXObjectCacheAtk.cpp:
1498         (WebCore::AXObjectCache::postPlatformNotification):
1499         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
1500         (webkitAccessibleGetAttributes):
1501         (setAtkStateSetFromCoreObject):
1502         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
1503         (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): Moved code returning
1504         string value for aria-current into AccessibilityObject:ariaCurrentValue().
1505
1506 2017-04-26  Wenson Hsieh  <wenson_hsieh@apple.com>
1507
1508         WebItemProviderPasteboard should fetch preloaded assets from disk when possible
1509         https://bugs.webkit.org/show_bug.cgi?id=171320
1510         <rdar://problem/31614010>
1511
1512         Reviewed by Tim Horton.
1513
1514         Adds a mechanism to WebItemProviderPasteboard to remember the temporary file URLs of assets it has loaded using
1515         doAfterLoadingProvidedContentIntoFileURLs:. When retrieving data from the pasteboard, we then see if we can
1516         first fetch serialized data straight from disk instead of having to go through the item provider in both
1517         -dataForPasteboardType:inItemSet: and -valuesForPasteboardType:inItemSet:.
1518
1519         See below annotations for more detail.
1520
1521         * platform/ios/AbstractPasteboard.h:
1522         * platform/ios/PlatformPasteboardIOS.mm:
1523         (WebCore::PlatformPasteboard::filenamesForDataInteraction):
1524         * platform/ios/WebItemProviderPasteboard.h:
1525         * platform/ios/WebItemProviderPasteboard.mm:
1526
1527         Introduces _typeToFileURLMaps, an array of dictionaries. A dictionary at the ith index of this array represents
1528         a mapping of UTIs to loaded temo file URLs for the ith UIItemProvider in the _itemProviders array. Before data
1529         interaction is performed, all entries in this array will be empty.
1530
1531         (-[WebItemProviderPasteboard init]):
1532         (-[WebItemProviderPasteboard setItemProviders:]):
1533         (-[WebItemProviderPasteboard _preLoadedDataConformingToType:forItemProviderAtIndex:]):
1534         (-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
1535         (-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):
1536
1537         Consult any loaded assets on disk before hitting UIItemProviders via the new
1538         -_preLoadedDataConformingToType:forItemProviderAtIndex: helper method.
1539
1540         (-[WebItemProviderPasteboard _tryToCreateObjectOfClass:usingProvider:]):
1541         (-[WebItemProviderPasteboard fileURLsForDataInteraction]):
1542
1543         Traverse _typeToFileURLMaps to collect all file URLs.
1544
1545         (-[WebItemProviderPasteboard doAfterLoadingProvidedContentIntoFileURLs:]):
1546
1547         Refactored to populate and set _typeToFileURLMaps when loading completes, rather than an array of file URLs.
1548
1549         (-[WebItemProviderPasteboard _tryToCreateAndAppendObjectOfClass:toArray:usingProvider:]): Deleted.
1550         (-[WebItemProviderPasteboard filenamesForDataInteraction]): Deleted.
1551
1552         Correct an erroneously named method (replaces filenames with fileURLs).
1553
1554 2017-04-26  Youenn Fablet  <youenn@apple.com>
1555
1556         LayoutTest webrtc/datachannel/basic.html is a flaky crash
1557         https://bugs.webkit.org/show_bug.cgi?id=170154
1558         <rdar://problem/31288423>
1559
1560         Reviewed by Geoffrey Garen.
1561
1562         Before the patch, we are setting the channel handler client to null and then unregistering from observer to
1563         libwebrtc data channel. Since this happens in two different threads, there might be a timing issue.
1564
1565         Removing this risk by first unregistering (done synchronously on the other thread), before setting client to null.
1566         Made some clean-up related refactoring.
1567
1568         * Modules/mediastream/RTCDataChannel.cpp:
1569         (WebCore::RTCDataChannel::create):
1570         (WebCore::RTCDataChannel::close):
1571         * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
1572         (WebCore::LibWebRTCDataChannelHandler::setClient):
1573         (WebCore::LibWebRTCDataChannelHandler::close):
1574         * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
1575         * platform/mediastream/RTCDataChannelHandler.h:
1576         * platform/mock/RTCDataChannelHandlerMock.cpp:
1577         (WebCore::RTCDataChannelHandlerMock::setClient):
1578         * platform/mock/RTCDataChannelHandlerMock.h:
1579
1580 2017-04-26  Alex Christensen  <achristensen@webkit.org>
1581
1582         Make user script injection more robust
1583         https://bugs.webkit.org/show_bug.cgi?id=171339
1584         <rdar://problem/30643691>
1585
1586         Reviewed by Geoffrey Garen.
1587
1588         * loader/EmptyClients.cpp:
1589         * page/Frame.cpp:
1590         (WebCore::Frame::injectUserScripts):
1591         * page/UserContentController.cpp:
1592         (WebCore::UserContentController::forEachUserScript):
1593         (WebCore::UserContentController::forEachUserStyleSheet):
1594         (WebCore::UserContentController::forEachUserMessageHandler):
1595         * page/UserContentController.h:
1596         * page/UserContentProvider.h:
1597
1598 2017-04-26  Zalan Bujtas  <zalan@apple.com>
1599
1600         RTL: recent searches popover is displayed in incorrect location
1601         https://bugs.webkit.org/show_bug.cgi?id=171338
1602         <rdar://problem/31377807>
1603
1604         Reviewed by Dean Jackson.
1605
1606         Compute the absolute coordinates for the popup the same way we do for the select dropdown.
1607
1608         * rendering/RenderSearchField.cpp:
1609         (WebCore::RenderSearchField::showPopup):
1610
1611 2017-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
1612
1613         Restrict WebKit image formats to a known whitelist
1614         https://bugs.webkit.org/show_bug.cgi?id=170700
1615
1616         Reviewed by Tim Horton.
1617
1618         If the image format is not supported, the load should be canceled and the
1619         image is marked a broken image.
1620
1621         Test: fast/images/image-formats-support.html
1622
1623         * loader/cache/CachedImage.cpp:
1624         (WebCore::CachedImage::addIncrementalDataBuffer):
1625         (WebCore::CachedImage::setImageDataBuffer):
1626         (WebCore::CachedImage::finishLoading):
1627         * loader/cache/CachedImage.h:
1628
1629 2017-04-26  Joanmarie Diggs  <jdiggs@igalia.com>
1630
1631         [ATK] Implement support for new ARIA 1.1 values of aria-haspopup
1632         https://bugs.webkit.org/show_bug.cgi?id=171164
1633
1634         Reviewed by Chris Fleizach.
1635
1636         In ARIA 1.1, aria-haspopup's value type changed from true/false to a token.
1637         Values: true, false (default, unless it's a combobox), dialog, grid, listbox
1638         (default for combobox), menu, and tree. Any value of aria-haspopup that is
1639         not included in the list of allowed values, including an empty string, must
1640         be treated as if the value false had been provided.
1641
1642         Add AccessibilityObject::ariaPopupValue() to validate the value, handle implicit
1643         values, and give platform assistive technologies a means to access that value.
1644
1645         If there is a valid, non-false value of aria-haspopup, include ATK_STATE_HAS_POPUP
1646         in the AtkStateSet. Lastly, expose the value (rather than true/false) via the "haspop"
1647         AtkObject attribute.
1648
1649         Test: accessibility/gtk/aria-haspopup.html
1650
1651         * accessibility/AccessibilityObject.h:
1652         (WebCore::AccessibilityObject::ariaPopupValue):
1653         (WebCore::AccessibilityObject::supportsARIAHasPopup):
1654         * accessibility/AccessibilityRenderObject.cpp:
1655         (WebCore::AccessibilityRenderObject::ariaHasPopup):
1656         * accessibility/AccessibilityRenderObject.h:
1657         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
1658         (webkitAccessibleGetAttributes):
1659         (setAtkStateSetFromCoreObject):
1660
1661 2017-04-26  Alex Christensen  <achristensen@webkit.org>
1662
1663         Fix CMake build.
1664
1665         * PlatformMac.cmake:
1666
1667 2017-04-26  Antti Koivisto  <antti@apple.com>
1668
1669         Enable expired-only reload policy on Mac and iOS
1670         https://bugs.webkit.org/show_bug.cgi?id=171264
1671         <rdar://problem/31807637>
1672
1673         Reviewed by Andreas Kling.
1674
1675         Limit the behavior to http and data URLs (where we explicitly know about expiration).
1676
1677         * html/HTMLLinkElement.cpp:
1678         (WebCore::HTMLLinkElement::setCSSStyleSheet):
1679         * loader/FrameLoader.cpp:
1680         (WebCore::FrameLoader::subresourceCachePolicy):
1681
1682             Pass the URL so we can test for protocol.
1683
1684         * loader/FrameLoader.h:
1685         * loader/NavigationAction.cpp:
1686         (WebCore::navigationType):
1687
1688             Test for reload navigation type correctly.
1689
1690         * loader/cache/CachedResource.cpp:
1691         (WebCore::CachedResource::load):
1692         * loader/cache/CachedResourceLoader.cpp:
1693         (WebCore::CachedResourceLoader::determineRevalidationPolicy):
1694         (WebCore::CachedResourceLoader::cachePolicy):
1695         * loader/cache/CachedResourceLoader.h:
1696
1697 2017-04-26  WebKit Contributor  <webkitcontrib@gmail.com>
1698
1699         Response.blob() does not set the content-type based on the header value.
1700         https://bugs.webkit.org/show_bug.cgi?id=170849
1701
1702         Reviewed by Alex Christensen.
1703
1704         The Fetch API specification requires setting the blob contentType
1705         using the Content-Type header value, if present.  Previously the
1706         FetchResponse class only called updateContentType() when first
1707         created even though all the headers were not available.  Call
1708         updateContentType() again after the headers are populated.
1709
1710         This change allows WebKit to pass the "Consume response's body: from
1711         fetch to blob" case in the WPT response-consume.html test.
1712
1713         Test: http://w3c-test.org/fetch/api/response/response-consume.html
1714
1715         * Modules/fetch/FetchResponse.cpp:
1716         (WebCore::FetchResponse::BodyLoader::didReceiveResponse): Modified to
1717         call FetchBodyOwner::updateContentType() after filling m_headers.
1718
1719 2017-04-26  Andy Estes  <aestes@apple.com>
1720
1721         Try to fix the macOS Sierra build.
1722
1723         * platform/mac/WebVideoFullscreenInterfaceMac.mm:
1724
1725 2017-04-26  Andy Estes  <aestes@apple.com>
1726
1727         [macOS] Add picture-in-picture support to WebPlaybackControlsManager
1728         https://bugs.webkit.org/show_bug.cgi?id=171328
1729         <rdar://problem/29875010>
1730
1731         Reviewed by Jer Noble.
1732
1733         * platform/cocoa/WebPlaybackSessionModel.h:
1734         * platform/cocoa/WebPlaybackSessionModelMediaElement.h:
1735         * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
1736         (WebCore::WebPlaybackSessionModelMediaElement::togglePictureInPicture): If the media element
1737         is currently in PiP fullscreen mode, exit fullscreen. Otherwise, enter PiP fullscreen mode.
1738         * platform/mac/WebPlaybackControlsManager.h:
1739         * platform/mac/WebPlaybackControlsManager.mm:
1740         (-[WebPlaybackControlsManager canTogglePictureInPicture]): Added. Returns YES if
1741         -allowsPictureInPicturePlayback returns YES.
1742         (-[WebPlaybackControlsManager togglePictureInPicture]): Added. Calls
1743         WebPlaybackSessionModel::togglePictureInPicture().
1744         * platform/mac/WebVideoFullscreenInterfaceMac.mm:
1745         (WebCore::WebVideoFullscreenInterfaceMac::enterFullscreen): Added a call to
1746         -[WebPlaybackControlsManager setPictureInPictureActive:YES].
1747         (WebCore::WebVideoFullscreenInterfaceMac::exitFullscreen): Added a call to
1748         -[WebPlaybackControlsManager setPictureInPictureActive:NO].
1749         (WebCore::WebVideoFullscreenInterfaceMac::exitFullscreenWithoutAnimationToMode): Ditto.
1750         * platform/spi/cocoa/AVKitSPI.h: Declared new SPI on AVTouchBarPlaybackControlsControlling.
1751
1752 2017-04-25  Dean Jackson  <dino@apple.com>
1753
1754         [Color] Make gradients work with ExtendedColors
1755         https://bugs.webkit.org/show_bug.cgi?id=171315
1756         <rdar://problems/31830177>
1757
1758         Reviewed by Antoine Quint.
1759
1760         Allow gradients to hold Color objects, and thus
1761         handle ExtendedColor. Implement the backend for
1762         CoreGraphics.
1763
1764         Test: css3/color/gradients.html
1765
1766         * platform/graphics/Gradient.cpp:
1767         (WebCore::Gradient::addColorStop): Just copy the Color now.
1768         (WebCore::compareStops): Handle rename of stop to offset.
1769         (WebCore::Gradient::hasAlpha): Use Color's helper.
1770         * platform/graphics/Gradient.h:
1771         (WebCore::Gradient::ColorStop::ColorStop): Rename stop
1772         to offset, and store a Color rather than four floating
1773         point values.
1774         * platform/graphics/cairo/GradientCairo.cpp:
1775         (WebCore::Gradient::platformGradient):
1776         * platform/graphics/cg/GradientCG.cpp:
1777         (WebCore::Gradient::platformGradient): Use the CG method
1778         that can handle CGColorRefs with ColorSpace values, and
1779         pass the Extended sRGB space which should be no change for
1780         all existing gradients but also handle ColorSpaces like
1781         Display P3.
1782         * platform/graphics/win/GradientDirect2D.cpp:
1783         (WebCore::Gradient::generateGradient):
1784         * svg/SVGGradientElement.cpp:
1785         (WebCore::SVGGradientElement::buildStops):
1786
1787 2017-04-25  Alex Christensen  <achristensen@webkit.org>
1788
1789         Encoded filename should be decoded for WKContentExtension.identifier
1790         https://bugs.webkit.org/show_bug.cgi?id=171316
1791
1792         Reviewed by Andy Estes.
1793
1794         * platform/FileSystem.h:
1795
1796 2017-04-26  Frederic Wang  <fwang@igalia.com>
1797
1798         Fix typo in RenderFrameBase
1799         https://bugs.webkit.org/show_bug.cgi?id=171324
1800
1801         Reviewed by Zalan Bujtas.
1802
1803         No new tests, behavior unchanged.
1804
1805         * rendering/RenderFrameBase.cpp:
1806         (WebCore::RenderFrameBase::layoutWithFlattening):
1807         (WebCore::RenderFrameBase::performLayoutWithFlattening):
1808         (WebCore::RenderFrameBase::peformLayoutWithFlattening): Deleted.
1809         * rendering/RenderFrameBase.h:
1810
1811 2017-04-26  Zalan Bujtas  <zalan@apple.com>
1812
1813         Forced page break on :after triggers infinite loop in column balancing
1814         https://bugs.webkit.org/show_bug.cgi?id=171309
1815         rdar://problem/26285884
1816
1817         Reviewed by David Hyatt.
1818
1819         Stop trying to balance the columns when the forced page breaks >= the number of
1820         columns even when this number is 1. Content will always overflow to the next page.
1821         see https://chromium.googlesource.com/chromium/src/+/fbbebf38cefb2712c912581eccb046ef363ec84e%5E%21/#F2 
1822
1823         Test: fast/multicol/infinite-loop-when-forced-break.html
1824
1825         * rendering/RenderMultiColumnSet.cpp:
1826         (WebCore::RenderMultiColumnSet::calculateBalancedHeight):
1827
1828 2017-04-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
1829
1830         Attempt to fix a JetStream regression.
1831         <rdar://problem/31742414>
1832
1833         Unreviewed.
1834
1835         Disable async decoding for large images till the flickering bug wk170640
1836         is fixed.
1837
1838         * platform/graphics/BitmapImage.cpp:
1839         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImages):
1840
1841 2017-04-26  Ryan Haddad  <ryanhaddad@apple.com>
1842
1843         Unreviewed, rolling out r215767.
1844
1845         The LayoutTest for this change is a flaky failure.
1846
1847         Reverted changeset:
1848
1849         "Restrict WebKit image formats to a known whitelist"
1850         https://bugs.webkit.org/show_bug.cgi?id=170700
1851         http://trac.webkit.org/changeset/215767
1852
1853 2017-04-26  Dave Hyatt  <hyatt@apple.com>
1854
1855         Improve wavy underline rendering
1856         https://bugs.webkit.org/show_bug.cgi?id=171281
1857
1858         Reviewed by Sam Weinig.
1859
1860         Change wavy underline rendering to use font size instead of stroke
1861         thickness as a way to tune it. Cut the extra offset from 2 to 1.
1862         Change the parameters to make the line flatter and to make the proportion
1863         of the wave that renders underneath a glyph the same.
1864
1865         * rendering/TextDecorationPainter.cpp:
1866         (WebCore::strokeWavyTextDecoration):
1867         (WebCore::TextDecorationPainter::paintTextDecoration):
1868         * style/InlineTextBoxStyle.cpp:
1869         (WebCore::getWavyStrokeParameters):
1870         (WebCore::visualOverflowForDecorations):
1871         * style/InlineTextBoxStyle.h:
1872         (WebCore::wavyOffsetFromDecoration):
1873
1874 2017-04-24  Sergio Villar Senin  <svillar@igalia.com>
1875
1876         [css-grid] Remove most of the usage of SizingOperation
1877         https://bugs.webkit.org/show_bug.cgi?id=171225
1878
1879         Reviewed by Darin Adler.
1880
1881         SizingOperation was added as a way to modify the behaviour of the track sizing algorithm
1882         with the specifics for intrinsic size computations. The problem is that although intrinsic
1883         size computation does imply indefinite sizes, the opposite is not always true. For example,
1884         a grid container with height:auto would compute the row sizes with an indefinite size but is
1885         not part of the intrinsic size (preferred widths) computation.
1886
1887         That's why it was wrongly used in some parts of the current code, in most of the cases is
1888         more than enough to check whether the available space is indefinite or not. In order to do
1889         that we have to keep both available sizes (height & width) around all the time to properly
1890         support orthogonal flows.
1891
1892         This change does not imply any change in behaviour.
1893
1894         * rendering/GridTrackSizingAlgorithm.cpp:
1895         (WebCore::GridTrackSizingAlgorithm::setAvailableSpace):
1896         (WebCore::GridTrackSizingAlgorithm::computeTrackBasedSize):
1897         (WebCore::GridTrackSizingAlgorithm::initialBaseSize):
1898         (WebCore::GridTrackSizingAlgorithm::initialGrowthLimit):
1899         (WebCore::GridTrackSizingAlgorithm::sizeTrackToFitNonSpanningItem):
1900         (WebCore::GridTrackSizingAlgorithm::increaseSizesToAccommodateSpanningItems):
1901         (WebCore::GridTrackSizingAlgorithm::assumedRowsSizeForOrthogonalChild):
1902         (WebCore::GridTrackSizingAlgorithm::gridAreaBreadthForChild):
1903         (WebCore::GridTrackSizingAlgorithm::gridTrackSize):
1904         (WebCore::IndefiniteSizeStrategy::findUsedFlexFraction):
1905         (WebCore::IndefiniteSizeStrategy::recomputeUsedFlexFractionIfNeeded):
1906         (WebCore::GridTrackSizingAlgorithm::initializeTrackSizes):
1907         (WebCore::GridTrackSizingAlgorithm::setup):
1908         (WebCore::GridTrackSizingAlgorithm::reset):
1909         * rendering/GridTrackSizingAlgorithm.h:
1910         (WebCore::GridTrackSizingAlgorithmStrategy::availableSpace):
1911         * rendering/RenderGrid.cpp:
1912         (WebCore::RenderGrid::availableSpaceForGutters):
1913         (WebCore::RenderGrid::computeTrackBasedLogicalHeight):
1914         (WebCore::RenderGrid::computeTrackSizesForDefiniteSize):
1915         (WebCore::RenderGrid::layoutBlock):
1916         (WebCore::RenderGrid::gridGap):
1917         (WebCore::RenderGrid::guttersSize):
1918         (WebCore::RenderGrid::computeIntrinsicLogicalWidths):
1919         (WebCore::RenderGrid::computeTrackSizesForIndefiniteSize):
1920         (WebCore::RenderGrid::computeAutoRepeatTracksCount):
1921         (WebCore::RenderGrid::placeItemsOnGrid):
1922         (WebCore::RenderGrid::trackSizesForComputedStyle):
1923         (WebCore::RenderGrid::applyStretchAlignmentToTracksIfNeeded):
1924         (WebCore::RenderGrid::offsetAndBreadthForPositionedChild):
1925         (WebCore::RenderGrid::populateGridPositionsForDirection):
1926         (WebCore::RenderGrid::columnAxisOffsetForChild):
1927         (WebCore::RenderGrid::rowAxisOffsetForChild):
1928         (WebCore::RenderGrid::gridGapForDirection): Deleted.
1929         * rendering/RenderGrid.h:
1930
1931 2017-04-26  Frederic Wang  <fwang@igalia.com>
1932
1933         Remove Document::*FrameElementsShouldIgnoreScrolling
1934         https://bugs.webkit.org/show_bug.cgi?id=171271
1935
1936         Reviewed by Chris Dumez.
1937
1938         setFrameElementsShouldIgnoreScrolling and frameElementsShouldIgnoreScrolling were
1939         introduced bug 23072 in order to work around a bug in the Dictionary application.
1940         However, this was removed in bug 132095 and hence the functions are no longer necessary.
1941
1942         No new tests.
1943
1944         * dom/Document.h:
1945         (WebCore::Document::setFrameElementsShouldIgnoreScrolling): Deleted.
1946         (WebCore::Document::frameElementsShouldIgnoreScrolling): Deleted.
1947         * html/HTMLFrameElementBase.cpp:
1948         (WebCore::HTMLFrameElementBase::parseAttribute):
1949
1950 2017-04-26  Zan Dobersek  <zdobersek@igalia.com>
1951
1952         [GCrypt] CryptoKeyRSA: implement create(), keySizeInBits(), buildAlgorithm(), exportData()
1953         https://bugs.webkit.org/show_bug.cgi?id=171213
1954
1955         Reviewed by Michael Catanzaro.
1956
1957         CryptoKeyRSA::create() validates the specified key type along with the
1958         provided data. If everything is OK, it then proceeds to build the key
1959         of the appropriate type through an s-expression that is constructed with
1960         the necessary data. We don't currently support creating private keys
1961         with any additional prime information (apart from p and q).
1962
1963         CryptoKeyRSA::keySizeInBits() calls the helper getRSAModulusLength()
1964         function that find the modulus MPI in the key s-expression and returns
1965         the modulus data length in bits.
1966
1967         CryptoKeyRSA::buildAlgorithm() returns KeyAlgorithm that's constructed
1968         from the appropriate name, this key's modulus length, and this key's
1969         public exponent data. It also specifies the hash if there is such a
1970         restriction for this key.
1971
1972         CryptoKeyRSA::exportData() returns a properly-constructed
1973         CryptoKeyDataRSAComponents object. The public modulus and exponent are
1974         used in case the key is public. If the key is private, the secret
1975         exponent and the p and q prime numbers are retrieved in MPI format.
1976         They're then used to calculate the dp, dq and qi parameters that are
1977         exported in the JWK format. Note that libgcrypt internally switches
1978         the p and q prime numbers such that p < q, but the Web Crypto
1979         specification and the dependant RFCs expect that q < p. We address
1980         this by simply switching the roles of the two primes and follow the
1981         usual q < p assumption when exporting the primes and computing the
1982         dependant exponents and coefficients.
1983
1984         No new tests -- existing ones cover this but don't work yet due to missing
1985         RSA-related CryptoAlgorithm implementations.
1986
1987         * crypto/gcrypt/CryptoKeyRSAGCrypt.cpp:
1988         (WebCore::getRSAModulusLength):
1989         (WebCore::getParameterMPIData):
1990         (WebCore::getRSAKeyParameter):
1991         (WebCore::CryptoKeyRSA::create):
1992         (WebCore::CryptoKeyRSA::keySizeInBits):
1993         (WebCore::CryptoKeyRSA::buildAlgorithm):
1994         (WebCore::CryptoKeyRSA::exportData):
1995
1996 2017-04-25  Jiewen Tan  <jiewen_tan@apple.com>
1997
1998         [WebCrypto] Enhance ways to convert an ECDSA signature binary into DER format
1999         https://bugs.webkit.org/show_bug.cgi?id=171287
2000         <rdar://problem/31735332>
2001
2002         Reviewed by Brent Fulgham.
2003
2004         Covered by existing tests.
2005
2006         * crypto/mac/CryptoAlgorithmECDSAMac.cpp:
2007         (WebCore::verifyECDSA):
2008
2009 2017-04-25  Brent Fulgham  <bfulgham@apple.com>
2010
2011         Relax the event firing ASSERT for Attr changes
2012         https://bugs.webkit.org/show_bug.cgi?id=171236
2013         <rdar://problem/30516349>
2014
2015         Reviewed by Dean Jackson.
2016
2017         The assertions added in Bug 167318 were overly strict, and trigger for valid behavior.
2018         Relax the assertion preventing event dispatch for the case of Attr elements at the
2019         end of childrenChanged.
2020
2021         Test: fast/dom/HTMLLinkElement/event-while-removing-attribute.html
2022
2023         * dom/Attr.cpp:
2024         (WebCore::Attr::childrenChanged):
2025
2026 2017-04-25  John Wilander  <wilander@apple.com>
2027
2028         Resource Load Statistics: Introduce shorter time-to-live for cookie partition whitelisting
2029         https://bugs.webkit.org/show_bug.cgi?id=171295
2030         <rdar://problem/31823818>
2031
2032         Reviewed by Brent Fulgham.
2033
2034         Test: http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html
2035
2036         * loader/ResourceLoadObserver.cpp:
2037         (WebCore::reduceTimeResolutionToOneDay): Deleted.
2038         (WebCore::reduceTimeResolution):
2039             Changed name to no longer lock this to a specific resolution.
2040         (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
2041             Now calls WebCore::reduceTimeResolution().
2042         (WebCore::ResourceLoadObserver::setTimeToLiveCookiePartitionFree):
2043             Added for testing purposes.
2044         (WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler):
2045             Added for testing purposes.
2046         * loader/ResourceLoadObserver.h:
2047         * loader/ResourceLoadStatisticsStore.cpp:
2048         (WebCore::shouldPartitionCookies):
2049             Static inline convenience function.
2050         (WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
2051             Now decides whether a domain should get partitioned cookies
2052             based on timeToLiveCookiePartitionFree.
2053             Removed clearFirst parameter since it's not needed here
2054             and it introduced complexity in keeping the store and the
2055             network process cache in sync.
2056         (WebCore::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
2057             Added for testing purposes.
2058         * loader/ResourceLoadStatisticsStore.h:
2059
2060 2017-04-25  Saam Barati  <sbarati@apple.com>
2061
2062         JSArray::isArrayPrototypeIteratorProtocolFastAndNonObservable is wrong because it does not do the necessary checks on the base object
2063         https://bugs.webkit.org/show_bug.cgi?id=171150
2064         <rdar://problem/31771880>
2065
2066         Reviewed by Sam Weinig.
2067
2068         This patch moves the sequence converters to use the now fixed
2069         JSArray::isArrayPrototypeIteratorProtocolFastAndNonObservable test
2070         inside JSC.
2071         
2072         This patch also fixes a few bugs:
2073         1. Converting to a sequence of numbers must prove that the JSArray
2074         is filled only with Int32/Double. If there is a chance the array
2075         contains objects, the conversion to a numeric IDLType can be observable
2076         (via valueOf()), and can change the iterator protocol.
2077         2. There are other conversions that can have side effects a-la valueOf().
2078         This patch introduces a new static constant in the various Converter
2079         classes that tell the sequence converter if the conversion operation
2080         can have JS side effects. If it does have side effects, we fall back to
2081         the generic conversion that uses the iterator protocol. If not, we can
2082         do a faster version that iterates over each element of the array,
2083         reading it directly, and converting it.
2084
2085         Tests: js/sequence-iterator-protocol-2.html
2086                js/sequence-iterator-protocol.html
2087
2088         * bindings/js/JSDOMConvertAny.h: Does not have side effects.
2089         * bindings/js/JSDOMConvertBase.h: We pessimistically assume inside DefaultConverter that converions have side effects.
2090         * bindings/js/JSDOMConvertBoolean.h: Does not have side effects.
2091         * bindings/js/JSDOMConvertCallbacks.h: Does not have side effects.
2092         * bindings/js/JSDOMConvertObject.h: Does not have side effects.
2093         * bindings/js/JSDOMConvertSequences.h:
2094         (WebCore::Detail::NumericSequenceConverter::convert):
2095         (WebCore::Detail::SequenceConverter::convert):
2096
2097 2017-04-25  Michael Saboff  <msaboff@apple.com>
2098
2099         Call bmalloc scavenger first when handling a memory pressure event
2100         https://bugs.webkit.org/show_bug.cgi?id=171289
2101
2102         Reviewed by Geoffrey Garen.
2103
2104         Let bmalloc free any pages to the OS that it can before doing anything else.
2105
2106         * page/MemoryRelease.cpp:
2107         (WebCore::releaseMemory):
2108
2109 2017-04-25  Dean Jackson  <dino@apple.com>
2110
2111         Skip WebKitAdditions for Safari Technology Preview media controls
2112         https://bugs.webkit.org/show_bug.cgi?id=171302
2113         <rdar://problem/31823256>
2114
2115         Reviewed by Simon Fraser.
2116
2117         Safari Technology Preview should use the same controls
2118         as OpenSource.
2119
2120         * WebCore.xcodeproj/project.pbxproj:
2121
2122 2017-04-25  Ryan Haddad  <ryanhaddad@apple.com>
2123
2124         Unreviewed, rolling out r215730.
2125
2126         The LayoutTest for this change is a flaky timeout on mac-wk1
2127         debug.
2128
2129         Reverted changeset:
2130
2131         "Enable expired-only reload policy on Mac and iOS"
2132         https://bugs.webkit.org/show_bug.cgi?id=171264
2133         http://trac.webkit.org/changeset/215730
2134
2135 2017-04-24  Matt Rajca  <mrajca@apple.com>
2136
2137         Indicate presence of audio when handling autoplay events.
2138         https://bugs.webkit.org/show_bug.cgi?id=171227
2139
2140         Reviewed by Alex Christensen.
2141
2142         Added API tests.
2143
2144         * html/HTMLMediaElement.cpp:
2145         (WebCore::HTMLMediaElement::handleAutoplayEvent):
2146         (WebCore::HTMLMediaElement::playInternal):
2147         (WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
2148         (WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer):
2149         (WebCore::HTMLMediaElement::userDidInterfereWithAutoplay):
2150         (WebCore::HTMLMediaElement::setPlaybackWithoutUserGesture):
2151         * html/HTMLMediaElement.h:
2152         * page/AutoplayEvent.h:
2153         * page/ChromeClient.h:
2154
2155 2017-04-25  Aakash Jain  <aakash_jain@apple.com>
2156
2157         WebCore.framework should restrict allowable_clients
2158         https://bugs.webkit.org/show_bug.cgi?id=171260
2159
2160         Reviewed by Alexey Proskuryakov.
2161
2162         * Configurations/WebCore.xcconfig: Adding allowable_client to all platform, in order to restrict WebCore
2163         from being directly linked on any platform.
2164         Moved WebKitLegacy and WebCoreTestSupport to OTHER_LDFLAGS_BASE.
2165         Removed WebKit2 as allowable_client from mac.
2166         Added iTunesU, Casablanca and Remote to OTHER_LDFLAGS_BASE_ios for iTunes related projects.
2167         Added WebKit, TVBooks, DumpRenderTree, WebKitTestRunner and TestWebKitAPI to OTHER_LDFLAGS_BASE_ios.
2168
2169 2017-04-25  Said Abou-Hallawa  <sabouhallawa@apple.com>
2170
2171         Restrict WebKit image formats to a known whitelist
2172         https://bugs.webkit.org/show_bug.cgi?id=170700
2173
2174         Reviewed by Tim Horton.
2175
2176         If the image format is not supported, the load should be canceled and the
2177         image is marked a broken image.
2178
2179         Test: fast/images/image-formats-support.html
2180
2181         * loader/cache/CachedImage.cpp:
2182         (WebCore::CachedImage::addIncrementalDataBuffer):
2183         (WebCore::CachedImage::setImageDataBuffer):
2184         (WebCore::CachedImage::finishLoading):
2185         * loader/cache/CachedImage.h:
2186
2187 2017-04-25  Youenn Fablet  <youenn@apple.com>
2188
2189         CoreAudioCaptureSource::suspend is asserting too often
2190         https://bugs.webkit.org/show_bug.cgi?id=171285
2191
2192         Reviewed by Eric Carlson.
2193
2194         No change of behavior.
2195
2196         * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
2197         (WebCore::CoreAudioCaptureSource::suspend): Moving the assertion to where it might be useful.
2198
2199 2017-04-25  Daniel Bates  <dabates@apple.com>
2200
2201         Use an OptionSet for compositing reasons bitmask
2202         https://bugs.webkit.org/show_bug.cgi?id=171153
2203
2204         Reviewed by Simon Fraser.
2205
2206         We should make use of OptionSet to represent the bitmask of the reasons a layer
2207         was composited instead of using an integer and bitwise operations.
2208
2209         * inspector/InspectorLayerTreeAgent.cpp:
2210         (WebCore::InspectorLayerTreeAgent::reasonsForCompositingLayer):
2211         * rendering/RenderLayerCompositor.cpp:
2212         (WebCore::RenderLayerCompositor::reasonsForCompositing):
2213         (WebCore::RenderLayerCompositor::logReasonsForCompositing): Also fix code style issues;
2214         an else-if statement should be written as an if-statement when the prior if-statement
2215         concludes with a return statement.
2216         * rendering/RenderLayerCompositor.h:
2217
2218 2017-04-25  Myles C. Maxfield  <mmaxfield@apple.com>
2219
2220         Supplementary Multilingual Plane Complex Scripts Rendered Incorrectly
2221         https://bugs.webkit.org/show_bug.cgi?id=171272
2222         <rdar://problem/30966764>
2223
2224         Reviewed by Zalan Bujtas.
2225
2226         These scripts need to take the complex text codepath.
2227
2228         Test: fast/text/kaithi.html
2229
2230         * platform/graphics/FontCascade.cpp:
2231         (WebCore::FontCascade::characterRangeCodePath):
2232
2233 2017-04-25  Carlos Alberto Lopez Perez  <clopez@igalia.com>
2234
2235         [GTK] Revert r215745 (especulative build fix) after r215752.
2236         https://bugs.webkit.org/show_bug.cgi?id=170842
2237
2238         Unreviewed.
2239
2240         * platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
2241         (WebCore::normalizeCharacters):
2242
2243 2017-04-25  Daniel Bates  <dabates@apple.com>
2244
2245         [Cocoa][Win] Enable of X-Content-Type-Options: nosniff header
2246         https://bugs.webkit.org/show_bug.cgi?id=136452
2247         <rdar://problem/23412620>
2248
2249         Reviewed by Brent Fulgham.
2250
2251         Enable support for X-Content-Type-Options: nosniff on Mac, iOS and Windows.
2252
2253         Additionally, honor X-Content-Type-Options: nosniff header for stylesheets as per
2254         <https://fetch.spec.whatwg.org/#should-response-to-request-be-blocked-due-to-nosniff%3F> (30 March 2017).
2255
2256         Test: http/tests/security/contentTypeOptions/nosniff-dynamic-script-blocked.html
2257
2258         * Configurations/FeatureDefines.xcconfig:
2259         * css/StyleSheetContents.cpp:
2260         (WebCore::StyleSheetContents::parseAuthorStyleSheet): Log an error if the stylesheet
2261         has the nosniff header and does not have a valid MIME type. Also update code for
2262         renaming of MIMETypeCheck to MIMETypeCheckHint.
2263         (WebCore::StyleSheetContents::notifyLoadedSheet): If the stylesheet is blocked by
2264         nosniff then consider it analogous to a load error so that we dispatch a DOM error
2265         event at the <style>/<link> element.
2266         * dom/LoadableClassicScript.cpp:
2267         (WebCore::LoadableClassicScript::notifyFinished): Modified the wording of the error
2268         message when a script is disallowed by nosniff so as to more closely match the
2269         wording used when a stylesheet is disallowed by nonsniff.
2270         * loader/cache/CachedCSSStyleSheet.cpp:
2271         (WebCore::CachedCSSStyleSheet::sheetText): Update for renaming of MIMETypeCheck
2272         to MIMETypeCheckHint.
2273         (WebCore::CachedCSSStyleSheet::responseMIMEType): Added.
2274         (WebCore::CachedCSSStyleSheet::mimeTypeAllowedByNosniff): Added.
2275         (WebCore::CachedCSSStyleSheet::canUseSheet): Modified to check if the X-Content-Type-Options: nosniff
2276         header is in the HTTP response for the stylesheet. If it is then we can only use the stylesheet
2277         if its content-type is "text/css". Otherwise, apply the existing criterion for determining whether
2278         to to use the stylesheet.
2279         * loader/cache/CachedCSSStyleSheet.h: Rename MIMETypeCheck to MIMETypeCheckHint to better
2280         describe its purpose as a hint as to whether to enforce MIME type checking for the stylesheet.
2281         Processing of the HTTP header X-Content-Type-Options takes precedence over this hint.
2282         * loader/cache/CachedScript.h: Make mimeType() private.
2283
2284 2017-04-25  Daniel Bates  <dabates@apple.com>
2285
2286         [Cocoa][Win] Enable of X-Content-Type-Options: nosniff header
2287         https://bugs.webkit.org/show_bug.cgi?id=136452
2288         <rdar://problem/23412620>
2289
2290         Reviewed by Brent Fulgham.
2291
2292         Part 1
2293
2294         Enable X-Content-Type-Options: nosniff on Mac, iOS and Windows platforms.
2295
2296         * Configurations/FeatureDefines.xcconfig:
2297
2298 2017-04-25  Myles C. Maxfield  <mmaxfield@apple.com>
2299
2300         [GTK] Build fix after r215737
2301         https://bugs.webkit.org/show_bug.cgi?id=170842
2302
2303         Unreviewed.
2304
2305         No new tests because there is no behavior change.
2306
2307         * platform/graphics/FontCascade.h:
2308         (WebCore::FontCascade::treatAsZeroWidthSpace):
2309         (WebCore::FontCascade::treatAsZeroWidthSpaceInComplexScript):
2310
2311 2017-04-25  Wenson Hsieh  <wenson_hsieh@apple.com>
2312
2313         Remove an unnecessary -respondsToSelector: check after r215724
2314
2315         Rubber-stamped by Tim Horton.
2316
2317         Addresses review feedback from <https://bugs.webkit.org/show_bug.cgi?id=171156>. -[NSURL _title]
2318         will always for builds that need to access it.
2319
2320         * platform/ios/PlatformPasteboardIOS.mm:
2321         (WebCore::PlatformPasteboard::readURL):
2322
2323 2017-04-25  Antti Koivisto  <antti@apple.com>
2324
2325         REGRESSION (r215469): [ios-simulator-wk2] LayoutTest compositing/animation/animation-backing.html is a flaky failure
2326         https://bugs.webkit.org/show_bug.cgi?id=171060
2327         <rdar://problem/31771174>
2328
2329         Reviewed by Simon Fraser.
2330
2331         Accelerated transform animations move underlying layers without invalidating GraphicsLayers.
2332         To update tile coverage we need to commit such subtrees even if there are not other changes.
2333
2334         * platform/graphics/ca/GraphicsLayerCA.cpp:
2335         (WebCore::GraphicsLayerCA::GraphicsLayerCA):
2336         (WebCore::GraphicsLayerCA::needsCommit):
2337
2338             Commit subtrees with accelerated transform animations.
2339             Factor into a function.
2340
2341         (WebCore::GraphicsLayerCA::recursiveCommitChanges):
2342
2343             Track if descendants had any accelerated transform animations after commit.
2344
2345         * platform/graphics/ca/GraphicsLayerCA.h:
2346         (WebCore::GraphicsLayerCA::hasDescendantsWithRunningTransformAnimations):
2347         (WebCore::GraphicsLayerCA::setHasDescendantsWithRunningTransformAnimations):
2348
2349 2017-04-25  Eric Carlson  <eric.carlson@apple.com>
2350
2351         [MediaStream macOS] Unable to apply frameRate constraint
2352         https://bugs.webkit.org/show_bug.cgi?id=171279
2353
2354         Reviewed by Youenn Fablet.
2355
2356         No new tests, this doesn't affect the mock capture devices.
2357
2358         * platform/mediastream/mac/AVVideoCaptureSource.mm:
2359         (WebCore::AVVideoCaptureSource::supportsSizeAndFrameRate): Cast frame rate
2360         ranges to int before comparing.
2361
2362 2017-04-25  Carlos Alberto Lopez Perez  <clopez@igalia.com>
2363
2364         [GTK] Build fix after r215737
2365         https://bugs.webkit.org/show_bug.cgi?id=170842
2366
2367         Unreviewed.
2368
2369         * platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
2370         (WebCore::normalizeCharacters):
2371
2372 2017-04-25  John Wilander  <wilander@apple.com>
2373
2374         Resource Load Statistics: Clear network process cache when clearing store
2375         https://bugs.webkit.org/show_bug.cgi?id=171256
2376         <rdar://problem/31802347>
2377
2378         Reviewed by Brent Fulgham.
2379
2380         Test that covers this code:
2381         http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
2382
2383         * loader/ResourceLoadObserver.cpp:
2384         (WebCore::ResourceLoadObserver::clearInMemoryStore):
2385             Better name.
2386         (WebCore::ResourceLoadObserver::logUserInteraction):
2387             Now passes on the boolean parameter clearFirst to
2388             ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
2389         (WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler):
2390             Now takes and passes on the boolean parameter clearFirst to
2391             ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
2392         (WebCore::ResourceLoadObserver::statisticsStore): Deleted.
2393             This getter violated abstraction. The way it was used
2394             is now solved through dedicated functions.
2395         * loader/ResourceLoadObserver.h:
2396         * loader/ResourceLoadStatisticsStore.cpp:
2397         (WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
2398             Now passes on the boolean parameter clearFirst to
2399             ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
2400         (WebCore::ResourceLoadStatisticsStore::clearInMemory):
2401             Better name.
2402             Now triggers clearing of the associated network process cache.
2403         (WebCore::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
2404             Now calls clearInMemory().
2405         (WebCore::ResourceLoadStatisticsStore::setShouldPartitionCookiesCallback):
2406             Now expects a handler with the boolean parameter clearFirst.
2407         (WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
2408             Now takes and passes on the boolean parameter clearFirst to
2409             m_shouldPartitionCookiesForDomainsHandler().
2410         * loader/ResourceLoadStatisticsStore.h:
2411         (WebCore::ResourceLoadStatisticsStore::clear): Deleted.
2412         * platform/network/NetworkStorageSession.h:
2413             NetworkStorageSession::setShouldPartitionCookiesForHosts() now
2414             takes the boolean parameter clearFirst.
2415         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
2416         (WebCore::NetworkStorageSession::setShouldPartitionCookiesForHosts):
2417             Now clears m_topPrivatelyControlledDomainsForCookiePartitioning
2418             if the boolean parameter clearFirst is true.
2419
2420 2017-04-25  Myles C. Maxfield  <mmaxfield@apple.com>
2421
2422         Add performance test for FontCache::systemFallbackForCharacters()
2423         https://bugs.webkit.org/show_bug.cgi?id=170842
2424
2425         Reviewed by Tim Horton.
2426
2427         No new tests because there is no behavior change.
2428
2429         * platform/graphics/FontCascade.h:
2430         (WebCore::FontCascade::treatAsZeroWidthSpace):
2431         (WebCore::FontCascade::treatAsZeroWidthSpaceInComplexScript): Deleted.
2432         * platform/graphics/WidthCache.h:
2433         (WebCore::WidthCache::add):
2434         (WebCore::WidthCache::addSlowCase):
2435
2436 2017-04-25  Chris Dumez  <cdumez@apple.com>
2437
2438         Content-Disposition header filename is ignored when 'download' attribute is specified in HTML
2439         https://bugs.webkit.org/show_bug.cgi?id=171239
2440         <rdar://problem/31789855>
2441
2442         Reviewed by Alex Christensen.
2443
2444         Add isAttachmentWithFilename() utility method to ResourceResponse to implement:
2445         - https://html.spec.whatwg.org/#as-a-download (Step 2)
2446
2447         Test: http/tests/download/anchor-download-attribute-content-disposition.html
2448
2449         * platform/network/ResourceResponseBase.cpp:
2450         (WebCore::ResourceResponseBase::isAttachmentWithFilename):
2451         * platform/network/ResourceResponseBase.h:
2452
2453 2017-04-25  Antti Koivisto  <antti@apple.com>
2454
2455         Enable expired-only reload policy on Mac and iOS
2456         https://bugs.webkit.org/show_bug.cgi?id=171264
2457         <rdar://problem/31807637>
2458
2459         Reviewed by Andreas Kling.
2460
2461         * loader/NavigationAction.cpp:
2462         (WebCore::navigationType):
2463
2464         Test for reload navigation type correctly.
2465
2466 2017-04-25  Miguel Gomez  <magomez@igalia.com>
2467
2468         Image decoders must have private constructors to avoid refcount misuse: ASSERTION FAILED: m_deletionHasBegun when destroying ImageDecoder
2469         https://bugs.webkit.org/show_bug.cgi?id=171211
2470
2471         Reviewed by Carlos Garcia Campos.
2472
2473         Add a create method to each of the decoders and set their constructors as private. Change
2474         ICOImageDecoder to store its internal PNG decoders as RefPtr and use the new create method, and
2475         change ImageDecoder to use the create methods as well.
2476
2477         Covered by existent tests.
2478
2479         * platform/image-decoders/ImageDecoder.cpp:
2480         (WebCore::ImageDecoder::create):
2481         * platform/image-decoders/bmp/BMPImageDecoder.h:
2482         * platform/image-decoders/gif/GIFImageDecoder.h:
2483         * platform/image-decoders/ico/ICOImageDecoder.cpp:
2484         (WebCore::ICOImageDecoder::decodeAtIndex):
2485         * platform/image-decoders/ico/ICOImageDecoder.h:
2486         * platform/image-decoders/jpeg/JPEGImageDecoder.h:
2487         * platform/image-decoders/png/PNGImageDecoder.h:
2488         * platform/image-decoders/webp/WEBPImageDecoder.h:
2489
2490 2017-04-25  Myles C. Maxfield  <mmaxfield@apple.com>
2491
2492         Build fix
2493
2494         Unreviewed.
2495
2496         No new tests because there is no behavior change.
2497
2498         * crypto/mac/SerializedCryptoKeyWrapMac.mm:
2499         (WebCore::wrapSerializedCryptoKey):
2500         (WebCore::unwrapSerializedCryptoKey):
2501
2502 2017-04-25  Wenson Hsieh  <wenson_hsieh@apple.com>
2503
2504         Support reading NSURL titles from the pasteboard when performing data interaction
2505         https://bugs.webkit.org/show_bug.cgi?id=171156
2506         <rdar://problem/31356937>
2507
2508         Reviewed by Tim Horton.
2509
2510         Support reading link titles from the pasteboard when performing data interaction. To do this, we refactor
2511         Pasteboard::readURL to take in an additional String& title which is ultimately plumbed to the PlatformPasteboard
2512         where it is set to the value of -[NSURL _title].
2513
2514         Test: DataInteractionTests.ExternalSourceTitledNSURL.
2515
2516         * editing/FrameSelection.h:
2517         * editing/ios/EditorIOS.mm:
2518         (WebCore::Editor::WebContentReader::readURL):
2519         * page/DragController.cpp:
2520         (WebCore::DragController::performDragOperation):
2521         (WebCore::DragController::concludeEditDrag):
2522
2523         Move calls to clearDragCaret() out of concludeEditDrag and into the call site, in performDragOperation after
2524         attempting to concludeEditDrag. This is done so that if the WebEditorClient queries whether the drag caret is
2525         in richly editable content for the purposes of generating a document fragment to insert, the answer will not
2526         always be false as a drop is occurring.
2527
2528         * platform/PasteboardStrategy.h:
2529         * platform/PlatformPasteboard.h:
2530         * platform/ios/PasteboardIOS.mm:
2531         (WebCore::Pasteboard::respectsUTIFidelities):
2532         (WebCore::Pasteboard::readString):
2533         * platform/ios/PlatformPasteboardIOS.mm:
2534         (WebCore::PlatformPasteboard::readURL):
2535
2536 2017-04-24  Andy VanWagoner  <thetalecrafter@gmail.com>
2537
2538         Clean up ICU headers
2539         https://bugs.webkit.org/show_bug.cgi?id=170997
2540
2541         Reviewed by JF Bastien.
2542
2543         Update all icu headers to 55.1
2544
2545         * icu/LICENSE: Update copyright
2546         * icu/README: Explain ICU headers for OS X better
2547         * icu/unicode/localpointer.h:
2548         (LocalPointer::LocalPointer):
2549         (LocalPointer::adoptInsteadAndCheckErrorCode):
2550         * icu/unicode/platform.h:
2551         * icu/unicode/putil.h:
2552         * icu/unicode/std_string.h:
2553         * icu/unicode/ubrk.h:
2554         * icu/unicode/uchar.h:
2555         * icu/unicode/ucnv.h:
2556         * icu/unicode/ucol.h:
2557         * icu/unicode/ucoleitr.h:
2558         * icu/unicode/uconfig.h:
2559         * icu/unicode/ucurr.h:
2560         * icu/unicode/uidna.h:
2561         * icu/unicode/uloc.h:
2562         * icu/unicode/umachine.h:
2563         * icu/unicode/unistr.h:
2564         (UnicodeString::getArrayStart):
2565         (UnicodeString::UnicodeString):
2566         (UnicodeString::hasShortLength):
2567         (UnicodeString::getShortLength):
2568         (UnicodeString::length):
2569         (UnicodeString::getCapacity):
2570         (UnicodeString::isBogus):
2571         (UnicodeString::isWritable):
2572         (UnicodeString::isBufferWritable):
2573         (UnicodeString::getBuffer):
2574         (UnicodeString::isEmpty):
2575         (UnicodeString::setZeroLength):
2576         (UnicodeString::setShortLength):
2577         (UnicodeString::setLength):
2578         (UnicodeString::setToEmpty):
2579         (UnicodeString::remove):
2580         * icu/unicode/urename.h:
2581         * icu/unicode/uscript.h:
2582         * icu/unicode/usearch.h:
2583         * icu/unicode/uset.h:
2584         * icu/unicode/ustring.h:
2585         * icu/unicode/utf8.h:
2586         * icu/unicode/utypes.h:
2587         * icu/unicode/uvernum.h:
2588
2589 2017-04-24  Jiewen Tan  <jiewen_tan@apple.com>
2590
2591         LayoutTests crypto/subtle/ecdsa-generate-key-sign-verify-p384.html and crypto/subtle/ecdsa-generate-key-sign-verify-p256.html are flaky failures
2592         https://bugs.webkit.org/show_bug.cgi?id=171059
2593         <rdar://problem/31734958>
2594
2595         Reviewed by Brent Fulgham.
2596
2597         Covered by existing tests.
2598
2599         * crypto/mac/CryptoAlgorithmECDSAMac.cpp:
2600         (WebCore::signECDSA):
2601         Enhance ways to convert the DER signatures produced from CommonCrypto to r||s.
2602
2603 2017-04-24  Manuel Rego Casasnovas  <rego@igalia.com>
2604
2605         [selectors4] :focus-within should use the flat tree
2606         https://bugs.webkit.org/show_bug.cgi?id=170899
2607
2608         Reviewed by Antti Koivisto.
2609
2610         This has been discussed in the following CSS WG issue:
2611         https://github.com/w3c/csswg-drafts/issues/1135
2612
2613         And the spec has been updated (https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo):
2614         "An element also matches :focus-within if one of its descendants in the flat tree
2615          (including non-element nodes, such as text nodes) matches the conditions for matching :focus."
2616
2617         Test: imported/w3c/web-platform-tests/css/selectors4/focus-within-shadow-006.html
2618
2619         * dom/Element.cpp:
2620         (WebCore::Element::setFocus): Use "flat tree" ("composed tree" in WebKit)
2621         to set focus-within flag.
2622
2623 2017-04-24  Wenson Hsieh  <wenson_hsieh@apple.com>
2624
2625         Respect fidelity order when reading web content from item providers
2626         https://bugs.webkit.org/show_bug.cgi?id=171155
2627         <rdar://problem/31356937>
2628
2629         Reviewed by Tim Horton.
2630
2631         Currently, when reading web content from pasteboards, we assume the old UIPasteboard/NSPasteboard model wherein
2632         the destination must determine which of the items is considered to have the highest fidelity for the purposes of
2633         inserting into an editable area. This destination-side fidelity ranking is determined solely by the NSArray
2634         returned from Pasteboard::supportedPasteboardTypes, which lists compatible types in order from highest fidelity
2635         to lowest fidelity. Pasteboard::read effectively iterates over this list of types in order, attempting to read
2636         highest fidelity types and bailing when it first successfully reads data.
2637
2638         However, when our pasteboard is backed by UIItemProviders, we should instead read pasteboard types in order of
2639         fidelity as specified by the source rather than the destination. To accomplish this, we introduce an alternate
2640         codepath, Pasteboard::readRespectingUTIFidelities, which we take if Pasteboard::respectsUTIFidelities is true
2641         (currently, this only applies for the purposes of data interaction). This version follows a different flow:
2642         for each item in the pasteboard, we ask for just the UTIs for that item, in order of fidelity. For each item,
2643         we then call readPasteboardWebContentDataForType to try and read data for that type, continuing until either
2644         all UTIs have been attempted, or reading was successful.
2645
2646         This patch makes two additional adjustments. First, we introduce Pasteboard::getTypesByFidelityForItemAtIndex,
2647         which is used by Pasteboard::readRespectingUTIFidelities when querying the list of supported UTIs for each
2648         pasteboard item, sorted by highest to lowest fidelity.
2649
2650         Secondly, we refactor logic to write to the item provider pasteboard in PlatformPasteboardIOS. Since we are
2651         now respecting fidelity rankings on the destination, the source must also register UTI types in the right
2652         fidelity order. While this was mostly achieved using our existing method of writing a list of object
2653         representations to the pasteboard and then all of the contents of a NSString => NSData dictionary containing
2654         private UTI data, this approach has two flaws:
2655         1.  We are unable to register high-priority custom types, followed by representing objects, followed by more
2656             lower-priority custom types, since we assume that all custom types follow all representing objects.
2657         2.  Since we're just iterating over a dictionary of NSString => NSData when registering custom UTI
2658             representations to the item provider, there cannot inherently be any fidelity ordering for custom types.
2659
2660         To address both of these issues, we introduce two new objects that encapsulate how we register data to the item
2661         provider pasteboard. WebItemProviderRegistrationInfo represents some data that can be registered to an item
2662         provider (either an object conforming to UIItemProviderWriting, or an NSString and NSData).
2663         WebItemProviderRegistrationInfoList represents a list of WebItemProviderRegistrationInfos in order of highest to
2664         lowest fidelity. In PlatformPasteboardIOS, we transform PasteboardWebContent, PasteboardImage, and PasteboardURL
2665         into a WebItemProviderRegistrationInfoList, which we then pass along to the WebItemProviderPasteboard. In
2666         WebItemProviderPasteboard, we traverse the list of WebItemProviderRegistrationInfos in the list and register
2667         each WebItemProviderRegistrationInfo's representing object or data to the item provider.
2668
2669         Test: DataInteractionTests.RespectsExternalSourceFidelityRankings.
2670
2671         * WebCore.xcodeproj/project.pbxproj:
2672         * platform/Pasteboard.h:
2673         * platform/PasteboardStrategy.h:
2674         * platform/PlatformPasteboard.h:
2675         * platform/ios/AbstractPasteboard.h:
2676         * platform/ios/AbstractPasteboard.mm: Removed.
2677
2678         Moves WebItemProviderData, formerly implemented in AbstractPasteboard.mm, into WebItemProviderPasteboard.mm.
2679         We can delete AbstractPasteboard.mm as a result.
2680
2681         * platform/ios/PasteboardIOS.mm:
2682         (WebCore::readPasteboardWebContentDataForType):
2683
2684         Pull out common logic for reading data given a UTI type from the pasteboard into the PasteboardWebContentReader.
2685         This is invoked from both the existing Pasteboard::read codepath, as well as the readRespectingUTIFidelities
2686         codepath.
2687
2688         (WebCore::Pasteboard::read):
2689
2690         Refactored to call the new readPasteboardWebContentDataForType helper. Behavior should not have changed, unless
2691         the pasteboard supports UTI fidelities.
2692
2693         (WebCore::Pasteboard::respectsUTIFidelities):
2694         (WebCore::Pasteboard::readRespectingUTIFidelities):
2695
2696         An alternative to Pasteboard::read that considers source-side fidelity rankings of UTIs.
2697
2698         * platform/ios/PlatformPasteboardIOS.mm:
2699         (WebCore::PlatformPasteboard::getTypesByFidelityForItemAtIndex):
2700         (WebCore::PlatformPasteboard::writeObjectRepresentations):
2701
2702         Refactored to build a WebItemProviderRegistrationInfoList and pass it to the WebItemProviderPasteboard to
2703         register items and data.
2704
2705         (WebCore::PlatformPasteboard::write):
2706         * platform/ios/WebItemProviderPasteboard.h:
2707         * platform/ios/WebItemProviderPasteboard.mm:
2708         (-[WebItemProviderRegistrationInfo initWithRepresentingObject:typeIdentifier:data:]):
2709         (-[WebItemProviderRegistrationInfo representingObject]):
2710         (-[WebItemProviderRegistrationInfo typeIdentifier]):
2711         (-[WebItemProviderRegistrationInfo data]):
2712
2713         Represents a single calls to register data onto the item provider pasteboard. See
2714         WebItemProviderPasteboard.h header comments for more info.
2715
2716         (-[WebItemProviderRegistrationInfoList init]):
2717         (-[WebItemProviderRegistrationInfoList addData:forType:]):
2718         (-[WebItemProviderRegistrationInfoList addRepresentingObject:]):
2719         (-[WebItemProviderRegistrationInfoList numberOfItems]):
2720         (-[WebItemProviderRegistrationInfoList itemAtIndex:]):
2721         (-[WebItemProviderRegistrationInfoList enumerateItems:]):
2722
2723         Represents a series of calls to register representations onto the item provider pasteboard. See
2724         WebItemProviderPasteboard.h header comments for more info.
2725
2726         (-[WebItemProviderPasteboard pasteboardTypesByFidelityForItemAtIndex:]):
2727         (-[WebItemProviderPasteboard setItemsUsingRegistrationInfoLists:]):
2728         (-[WebItemProviderPasteboard setItemsFromObjectRepresentations:]): Deleted.
2729
2730 2017-04-24  Chris Dumez  <cdumez@apple.com>
2731
2732         Regression(r204605): support for "cp874" charset alias was inadvertently dropped which may cause issues on certain Thai sites
2733         https://bugs.webkit.org/show_bug.cgi?id=171128
2734         <rdar://problem/31526844>
2735
2736         Reviewed by Alexey Proskuryakov.
2737
2738         When using Thai as default language on MacOS, defaultTextEncodingNameForSystemLanguage()
2739         was returning "cp874" encoding with was dropped in r204605 for not being part of the
2740         encoding specification (https://encoding.spec.whatwg.org/#names-and-labels).
2741
2742         To address the issue, we map "cp874" encoding to the "dos-874" encoding which is
2743         properly recognized. Without this, this could lead to issue on WebSites that do not
2744         specify a charset.
2745
2746         * platform/text/TextEncodingRegistry.cpp:
2747         (WebCore::defaultTextEncodingNameForSystemLanguage):
2748
2749 2017-04-24  Said Abou-Hallawa  <sabouhallawa@apple.com>
2750
2751         [CG] Provide a type identifier hint to the CGImageSource so getting the type identifier is more accurate
2752         https://bugs.webkit.org/show_bug.cgi?id=171042
2753
2754         Reviewed by Tim Horton.
2755
2756         The image URL can be used to get the type identifier hint. Without providing
2757         this hint, the image type identifier is not accurate for image formats.
2758
2759         Also add a function to the ImageDecoder class to get the typeIdentifier. Add
2760         all the pluming from the ImageDecoder till the Image class.
2761
2762         * WebCore.xcodeproj/project.pbxproj:
2763         * platform/graphics/BitmapImage.cpp:
2764         (WebCore::BitmapImage::destroyDecodedData):
2765         (WebCore::BitmapImage::frameImageAtIndexCacheIfNeeded):
2766         (WebCore::BitmapImage::draw):
2767         (WebCore::BitmapImage::internalStartAnimation):
2768         (WebCore::BitmapImage::advanceAnimation):
2769         (WebCore::BitmapImage::internalAdvanceAnimation):
2770         (WebCore::BitmapImage::newFrameNativeImageAvailableAtIndex):
2771         * platform/graphics/BitmapImage.h:
2772         * platform/graphics/Image.cpp:
2773         (WebCore::Image::sourceURL):
2774         * platform/graphics/Image.h: Change the sourceURL() to return a URL so CG can create CFURLRef from it.
2775         (WebCore::Image::uti):
2776         * platform/graphics/ImageFrameCache.cpp:
2777         (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex):
2778         (WebCore::ImageFrameCache::startAsyncDecodingQueue):
2779         (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex):
2780         (WebCore::ImageFrameCache::stopAsyncDecodingQueue):
2781         (WebCore::ImageFrameCache::clearMetadata):
2782         (WebCore::ImageFrameCache::sourceURL):
2783         (WebCore::ImageFrameCache::encodedDataStatus):
2784         (WebCore::ImageFrameCache::uti):
2785         (WebCore::ImageFrameCache::filenameExtension):
2786         * platform/graphics/ImageFrameCache.h:
2787         * platform/graphics/ImageSource.cpp:
2788         (WebCore::ImageSource::ensureDecoderAvailable):
2789         * platform/graphics/ImageSource.h:
2790         (WebCore::ImageSource::uti):
2791         * platform/graphics/cg/ImageDecoderCG.cpp:
2792         (WebCore::ImageDecoder::ImageDecoder): Pass the type identifier hint to CGImageSourceCreateIncremental().
2793         (WebCore::ImageDecoder::uti):
2794         (WebCore::ImageDecoder::filenameExtension):
2795         (WebCore::ImageDecoder::frameHasAlphaAtIndex):
2796         (WebCore::ImageDecoder::createFrameImageAtIndex):
2797         * platform/graphics/cg/ImageDecoderCG.h:
2798         (WebCore::ImageDecoder::create):
2799         * platform/graphics/win/ImageDecoderDirect2D.cpp:
2800         (WebCore::ImageDecoder::encodedDataStatus):
2801         * platform/graphics/win/ImageDecoderDirect2D.h:
2802         (WebCore::ImageDecoder::create): Add an argument of type URL.
2803         * platform/image-decoders/ImageDecoder.cpp:
2804         (WebCore::ImageDecoder::create): Add an argument of type URL.
2805         * platform/image-decoders/ImageDecoder.h:
2806         (WebCore::ImageDecoder::encodedDataStatus): Make it const.
2807         * platform/image-decoders/bmp/BMPImageDecoder.cpp:
2808         (WebCore::BMPImageDecoder::encodedDataStatus):
2809         * platform/image-decoders/bmp/BMPImageDecoder.h:
2810         * platform/image-decoders/gif/GIFImageDecoder.cpp:
2811         (WebCore::GIFImageDecoder::encodedDataStatus):
2812         * platform/image-decoders/gif/GIFImageDecoder.h:
2813         * platform/image-decoders/ico/ICOImageDecoder.cpp:
2814         (WebCore::ICOImageDecoder::encodedDataStatus):
2815         * platform/image-decoders/ico/ICOImageDecoder.h:
2816         * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
2817         (WebCore::JPEGImageDecoder::encodedDataStatus):
2818         * platform/image-decoders/jpeg/JPEGImageDecoder.h:
2819         * platform/image-decoders/png/PNGImageDecoder.cpp:
2820         (WebCore::PNGImageDecoder::encodedDataStatus):
2821         * platform/image-decoders/png/PNGImageDecoder.h:
2822         * platform/image-decoders/webp/WEBPImageDecoder.cpp:
2823         (WebCore::WEBPImageDecoder::encodedDataStatus):
2824         * platform/image-decoders/webp/WEBPImageDecoder.h:
2825         * platform/spi/cg/ImageIOSPI.h: Added.
2826
2827 2017-04-24  Ryan Haddad  <ryanhaddad@apple.com>
2828
2829         Unreviewed build fix.
2830
2831         * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
2832         (WebCore::encryptAES_GCM):
2833         (WebCore::decyptAES_GCM):
2834
2835 2017-04-24  Said Abou-Hallawa  <sabouhallawa@apple.com>
2836
2837         Whitelist supported image MIME types
2838         https://bugs.webkit.org/show_bug.cgi?id=171077
2839
2840         Reviewed by Tim Horton.
2841
2842         Restrict the CG port image formats to a known whitelist. Build this list from image
2843         UTI's instead of MIME types, since the image UTI's is a superset of the MIME types.
2844         Use this list to build the list of supported image MIME types.
2845
2846         * PlatformAppleWin.cmake:
2847         * WebCore.xcodeproj/project.pbxproj:
2848         * platform/MIMETypeRegistry.cpp:
2849         (WebCore::initializeSupportedImageMIMETypes):
2850         * platform/graphics/cg/UTIRegistry.cpp: Added.
2851         (WebCore::allowedImageUTIs):
2852         (WebCore::isAllowedImageUTI):
2853         * platform/graphics/cg/UTIRegistry.h: Added.
2854
2855 2017-04-24  Nan Wang  <n_wang@apple.com>
2856
2857         AX: Crash at WebCore::AXObjectCache::characterOffsetForIndex(int, WebCore::AccessibilityObject const*) + 703
2858         https://bugs.webkit.org/show_bug.cgi?id=171247
2859
2860         Reviewed by Chris Fleizach.
2861
2862         Crashed because we were passing a nil node into rootAXEditableElement(). Fixed it by
2863         adding a null check.
2864
2865         Test: accessibility/mac/input-string-for-range-crash.html
2866
2867         * accessibility/AXObjectCache.cpp:
2868         (WebCore::AXObjectCache::characterOffsetForIndex):
2869
2870 2017-04-24  Youenn Fablet  <youenn@apple.com>
2871
2872         Set defaults video getUserMedia constraints
2873         https://bugs.webkit.org/show_bug.cgi?id=171127
2874
2875         Reviewed by Eric Carlson.
2876
2877         Test: fast/mediastream/getUserMedia-default.html
2878
2879         Adding default optional constraints for video size and frame rate if none is defined.
2880         Default is 640x480 30fps.
2881
2882         Doing some refactoring in MeddiaConstraintsImpl and MeddiaConstraintsData to use more move constructors.
2883
2884         * Modules/mediastream/MediaConstraintsImpl.cpp:
2885         (WebCore::defaultVideoConstraints):
2886         (WebCore::MediaConstraintsData::setDefaultVideoConstraints):
2887         (WebCore::MediaConstraintsImpl::create): Deleted.
2888         * Modules/mediastream/MediaConstraintsImpl.h:
2889         * Modules/mediastream/MediaDevices.cpp:
2890         (WebCore::MediaDevices::getUserMedia):
2891         * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
2892         (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer): Fixing crash when setting frameRate.
2893
2894 2017-04-24  Chris Dumez  <cdumez@apple.com>
2895
2896         createElementNS() should now throw only InvalidCharacterError, not NamespaceError
2897         https://bugs.webkit.org/show_bug.cgi?id=171052
2898
2899         Reviewed by Sam Weinig.
2900
2901         Validating a qualified name should only throw InvalidCharacterError, not NamespaceError,
2902         after:
2903         - https://github.com/whatwg/dom/issues/319
2904         - https://github.com/w3c/web-platform-tests/issues/5161
2905         - https://github.com/whatwg/dom/issues/423
2906
2907         Latest spec:
2908         - https://dom.spec.whatwg.org/#validate
2909
2910         No new tests, updated web-platform-tests.
2911
2912         * dom/Document.cpp:
2913         (WebCore::Document::parseQualifiedName):
2914
2915 2017-04-24  Chris Dumez  <cdumez@apple.com>
2916
2917         REGRESSION (214503): Webkit crash under RenderElement::repaintForPausedImageAnimationsIfNeeded() when scrolling giphy pages
2918         https://bugs.webkit.org/show_bug.cgi?id=171243
2919         <rdar://problem/31715572>
2920
2921         Reviewed by Antti Koivisto.
2922
2923         After r214503, we would frequently crash when scrolling giphy pages because we were failing to call
2924         RenderView::removeRendererWithPausedImageAnimations(renderer, cachedImage) in some cases. This would
2925         cause a RenderElement to still be associated to a CachedImage in RenderView but not in practice.
2926         If the CachedImage then gets destroyed and the user scrolls, we end up calling
2927         RenderElement::repaintForPausedImageAnimationsIfNeeded() with a bad CachedImage.
2928
2929         StyleCachedImage was properly calling RenderView::removeRendererWithPausedImageAnimations() before
2930         unregistering the renderer as a client to the CachedImage. However, RenderImageResource was failing
2931         to do the same. To make this less error-prone, I added a didRemoveCachedImageClient(CachedImage&)
2932         function to the CachedImageClient interface. It is overriden in RenderElement only to call
2933         RenderView::removeRendererWithPausedImageAnimations().
2934
2935         Test: fast/images/animated-gif-scrolling-crash.html
2936
2937         * loader/cache/CachedImage.cpp:
2938         (WebCore::CachedImage::didRemoveClient):
2939         * loader/cache/CachedImageClient.h:
2940         (WebCore::CachedImageClient::didRemoveCachedImageClient):
2941         * rendering/RenderElement.cpp:
2942         (WebCore::RenderElement::didRemoveCachedImageClient):
2943         * rendering/RenderElement.h:
2944         * rendering/style/StyleCachedImage.cpp:
2945         (WebCore::StyleCachedImage::removeClient):
2946
2947 2017-04-24  Andy Estes  <aestes@apple.com>
2948
2949         [macOS] Fix two minor issues with MediaSelectionOption::Type
2950         https://bugs.webkit.org/show_bug.cgi?id=171235
2951
2952         Reviewed by Sam Weinig.
2953
2954         * platform/MediaSelectionOption.h: Gave type a default value, and added explicit
2955         constructors to make gcc and msvc happy.
2956         * platform/mac/WebPlaybackControlsManager.mm:
2957         (toAVTouchBarMediaSelectionOptionType): Added an ASSERT_NOT_REACHED if none of the switch
2958         cases match.
2959
2960 2017-04-24  Andy Estes  <aestes@apple.com>
2961
2962         [macOS] Enable media selection button on AVTouchBarScrubber
2963         https://bugs.webkit.org/show_bug.cgi?id=171149
2964         <rdar://problem/29875010>
2965
2966         Reviewed by Beth Dakin.
2967
2968         * platform/spi/cocoa/AVKitSPI.h:
2969
2970 2017-04-24  Alex Christensen  <achristensen@webkit.org>
2971
2972         Reduce copies and allocations in SharedBuffer::append
2973         https://bugs.webkit.org/show_bug.cgi?id=170956
2974
2975         Reviewed by Andreas Kling.
2976
2977         SharedBuffer was a mess of different data structures added over the years.
2978         SharedBuffer::append would allocate large Vector<char>s and call memcpy, and that
2979         is inefficient and causes crashes when large allocations fail, and the allocations
2980         and copies aren't even necessary.  There were also const correctness problems in
2981         ResourceLoader::addDataOrBuffer, and iterating a SharedBuffer was strange because
2982         sometimes we don't want to add unnecessary copies.
2983
2984         These problems are solved by making SharedBuffer a Vector of read-only data segments,
2985         which can be contained in various ways but we don't care because all we want to do is
2986         read them.  Appending SharedBuffers is now const correct because we just add to a
2987         Vector<Ref<DataSegment>> and neither SharedBuffer can write to the data.  Sometimes,
2988         though, we want all the data to be in continuous memory, and if there are multiple
2989         segments then the data needs to be copied once to a new segment.  We should audit the
2990         call sites of SharedBuffer::data and see if this is really necessary.
2991
2992         No change in functional behavior.  Fewer copies of the data are made when buffering
2993         data in the NetworkProcess.  No extra memory is allocated for bytes we think we might
2994         need to append in the future.  Data is now only copied into one buffer lazily as needed,
2995         which could slightly change when small delays from memcpy happen, but it's an overall
2996         improvement.  We could have a performance hit if we were to call append() then data()
2997         then append() then data() etc. but that doesn't happen in WebKit because we call append
2998         repeatedly when buffering the data then call data() once when reading the data.
2999
3000         * editing/cocoa/EditorCocoa.mm:
3001         (WebCore::archivedDataForAttributedString):
3002         (WebCore::Editor::selectionInWebArchiveFormat):
3003         (WebCore::Editor::dataInRTFDFormat):
3004         (WebCore::Editor::dataInRTFFormat):
3005         * editing/ios/EditorIOS.mm:
3006         (WebCore::Editor::WebContentReader::readURL):
3007         * editing/mac/EditorMac.mm:
3008         (WebCore::Editor::imageInWebArchiveFormat):
3009         * loader/TextTrackLoader.cpp:
3010         (WebCore::TextTrackLoader::processNewCueData):
3011         * loader/archive/cf/LegacyWebArchive.cpp:
3012         (WebCore::LegacyWebArchive::createResource):
3013         * loader/cache/CachedResource.cpp:
3014         (WebCore::CachedResource::tryReplaceEncodedData):
3015         * loader/cocoa/DiskCacheMonitorCocoa.mm:
3016         (WebCore::DiskCacheMonitor::tryGetFileBackedSharedBufferFromCFURLCachedResponse):
3017         * platform/SharedBuffer.cpp:
3018         (WebCore::SharedBuffer::SharedBuffer):
3019         (WebCore::SharedBuffer::create):
3020         (WebCore::SharedBuffer::combineToOneSegment):
3021         (WebCore::SharedBuffer::data):
3022         (WebCore::SharedBuffer::createArrayBuffer):
3023         (WebCore::SharedBuffer::append):
3024         (WebCore::SharedBuffer::clear):
3025         (WebCore::SharedBuffer::copy):
3026         (WebCore::SharedBuffer::DataSegment::data):
3027         (WebCore::SharedBuffer::DataSegment::size):
3028         (WebCore::segmentIndex): Deleted.
3029         (WebCore::offsetInSegment): Deleted.
3030         (WebCore::allocateSegment): Deleted.
3031         (WebCore::freeSegment): Deleted.
3032         (WebCore::SharedBuffer::~SharedBuffer): Deleted.
3033         (WebCore::SharedBuffer::size): Deleted.
3034         (WebCore::SharedBuffer::duplicateDataBufferIfNecessary): Deleted.
3035         (WebCore::SharedBuffer::appendToDataBuffer): Deleted.
3036         (WebCore::SharedBuffer::clearDataBuffer): Deleted.
3037         (WebCore::SharedBuffer::copyBufferAndClear): Deleted.
3038         (WebCore::SharedBuffer::buffer): Deleted.
3039         (WebCore::SharedBuffer::getSomeData): Deleted.
3040         (WebCore::SharedBuffer::maybeTransferMappedFileData): Deleted.
3041         (WebCore::SharedBuffer::clearPlatformData): Deleted.
3042         (WebCore::SharedBuffer::maybeTransferPlatformData): Deleted.
3043         (WebCore::SharedBuffer::hasPlatformData): Deleted.
3044         (WebCore::SharedBuffer::platformData): Deleted.
3045         (WebCore::SharedBuffer::maybeAppendPlatformData): Deleted.
3046         * platform/SharedBuffer.h:
3047         (WebCore::SharedBuffer::create): Deleted.
3048         (WebCore::SharedBuffer::isEmpty): Deleted.
3049         * platform/SharedBufferChunkReader.cpp:
3050         (WebCore::SharedBufferChunkReader::nextChunk):
3051         (WebCore::SharedBufferChunkReader::peek):
3052         * platform/SharedBufferChunkReader.h:
3053         * platform/URLParser.cpp:
3054         (WebCore::URLParser::URLParser):
3055         * platform/cf/KeyedEncoderCF.cpp:
3056         (WebCore::KeyedEncoderCF::finishEncoding):
3057         * platform/cf/SharedBufferCF.cpp:
3058         (WebCore::SharedBuffer::SharedBuffer):
3059         (WebCore::SharedBuffer::createCFData):
3060         (WebCore::SharedBuffer::create):
3061         (WebCore::SharedBuffer::hintMemoryNotNeededSoon):
3062         (WebCore::SharedBuffer::append):
3063         (WebCore::SharedBuffer::wrapCFData): Deleted.
3064         (WebCore::SharedBuffer::hasPlatformData): Deleted.
3065         (WebCore::SharedBuffer::platformData): Deleted.
3066         (WebCore::SharedBuffer::platformDataSize): Deleted.
3067         (WebCore::SharedBuffer::maybeTransferPlatformData): Deleted.
3068         (WebCore::SharedBuffer::clearPlatformData): Deleted.
3069         (WebCore::SharedBuffer::tryReplaceContentsWithPlatformBuffer): Deleted.
3070         (WebCore::SharedBuffer::maybeAppendPlatformData): Deleted.
3071         (WebCore::SharedBuffer::copyBufferAndClear): Deleted.
3072         (WebCore::SharedBuffer::copySomeDataFromDataArray): Deleted.
3073         (WebCore::SharedBuffer::singleDataArrayBuffer): Deleted.
3074         (WebCore::SharedBuffer::maybeAppendDataArray): Deleted.
3075         * platform/cocoa/NetworkExtensionContentFilter.mm:
3076         (WebCore::NetworkExtensionContentFilter::replacementData):
3077         * platform/cocoa/ParentalControlsContentFilter.mm:
3078         (WebCore::ParentalControlsContentFilter::replacementData):
3079         * platform/cocoa/SharedBufferCocoa.mm:
3080         (-[WebCoreSharedBufferData initWithSharedBufferDataSegment:]):
3081         (-[WebCoreSharedBufferData length]):
3082         (-[WebCoreSharedBufferData bytes]):
3083         (WebCore::SharedBuffer::create):
3084         (WebCore::SharedBuffer::createCFData):
3085         (WebCore::SharedBuffer::createFromReadingFile):
3086         (WebCore::SharedBuffer::createNSDataArray):
3087         (-[WebCoreSharedBufferData initWithSharedBufferDataBuffer:]): Deleted.
3088         (WebCore::SharedBuffer::wrapNSData): Deleted.
3089         (WebCore::SharedBuffer::existingCFData): Deleted.
3090         * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
3091         (WebCore::WebCoreAVFResourceLoader::fulfillRequestWithResource):
3092         * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
3093         (WebCore::FontPlatformData::openTypeTable):
3094         * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
3095         (ResourceHandleStreamingClient::didReceiveBuffer):
3096         * platform/graphics/mac/ImageMac.mm:
3097         (WebCore::Image::loadPlatformResource):
3098         * platform/image-decoders/ImageDecoder.cpp:
3099         (WebCore::ImageDecoder::create):
3100         * platform/image-decoders/png/PNGImageDecoder.cpp:
3101         (WebCore::PNGImageReader::decode):
3102         * platform/ios/PlatformPasteboardIOS.mm:
3103         (WebCore::PlatformPasteboard::readBuffer):
3104         * platform/mac/PasteboardMac.mm:
3105         (WebCore::writeFileWrapperAsRTFDAttachment):
3106         (WebCore::Pasteboard::write):
3107         * platform/mac/PlatformPasteboardMac.mm:
3108         (WebCore::PlatformPasteboard::bufferForType):
3109         * platform/network/BlobResourceHandle.cpp:
3110         (WebCore::BlobResourceHandle::notifyReceiveData):
3111         * platform/network/MIMEHeader.cpp:
3112         * platform/network/MIMEHeader.h:
3113         * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
3114         (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveData):
3115         * platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp:
3116         (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveData):
3117         * platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
3118         (-[WebCoreResourceHandleAsDelegate connection:didReceiveData:lengthReceived:]):
3119         * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
3120         (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveData:lengthReceived:]):
3121         * platform/soup/SharedBufferSoup.cpp:
3122         (WebCore::SharedBuffer::SharedBuffer):
3123         (WebCore::SharedBuffer::createSoupBuffer):
3124         (WebCore::SharedBuffer::clearPlatformData): Deleted.
3125         (WebCore::SharedBuffer::maybeTransferPlatformData): Deleted.
3126         (WebCore::SharedBuffer::hasPlatformData): Deleted.
3127         (WebCore::SharedBuffer::platformData): Deleted.
3128         (WebCore::SharedBuffer::platformDataSize): Deleted.
3129         (WebCore::SharedBuffer::maybeAppendPlatformData): Deleted.
3130         (WebCore::SharedBuffer::tryReplaceContentsWithPlatformBuffer): Deleted.
3131
3132 2017-04-24  Dan Bernstein  <mitz@apple.com>
3133
3134         [Cocoa] Some ivars are needlessly @protected
3135         https://bugs.webkit.org/show_bug.cgi?id=171208
3136
3137         Reviewed by Anders Carlsson.
3138
3139         Made ivars @private where possible.
3140
3141         * platform/mac/WebCoreFullScreenPlaceholderView.h:
3142         * platform/mac/WebCoreFullScreenWarningView.h:
3143         * platform/mac/WebPlaybackControlsManager.h:
3144         * platform/network/cocoa/WebCoreNSURLSession.h:
3145
3146 2017-04-24  Carlos Garcia Campos  <cgarcia@igalia.com>
3147
3148         [GTK] Switch to use ENABLE_REMOTE_INSPECTOR instead of ENABLE_INSPECTOR_SERVER for the remote inspector
3149         https://bugs.webkit.org/show_bug.cgi?id=166680
3150
3151         Reviewed by Michael Catanzaro.
3152
3153         Add PageDebuggable.cpp to the compilation.
3154
3155         * CMakeLists.txt:
3156
3157 2017-04-23  Commit Queue  <commit-queue@webkit.org>
3158
3159         Unreviewed, rolling out r215657 and r215676.
3160         https://bugs.webkit.org/show_bug.cgi?id=171201
3161
3162         Broke the build (Requested by ap on #webkit).
3163
3164         Reverted changesets:
3165
3166         "[macOS] Enable media selection button on AVTouchBarScrubber"
3167         https://bugs.webkit.org/show_bug.cgi?id=171149
3168         http://trac.webkit.org/changeset/215657
3169
3170         "Build fix after r215657."
3171         http://trac.webkit.org/changeset/215676
3172
3173 2017-04-23  Andy Estes  <aestes@apple.com>
3174
3175         [macOS] AVTouchBarMediaSelectionOptions should be created with the correct type
3176         https://bugs.webkit.org/show_bug.cgi?id=171192
3177         <rdar://problem/29875010>
3178
3179         Reviewed by Wenson Hsieh.
3180
3181         AVTouchBarMediaSelectionOption was always being created with type
3182         AVTouchBarMediaSelectionOptionTypeRegular, but we know if a TextTrack is really the legible
3183         off or legible auto track. This change plumbs that information into
3184         WebPlaybackControlsManager so that AVTouchBarMediaSelectionOptions can be created with the
3185         right AVTouchBarMediaSelectionOptionType. 
3186
3187         * WebCore.xcodeproj/project.pbxproj:
3188         * page/CaptionUserPreferences.cpp:
3189         (WebCore::CaptionUserPreferences::mediaSelectionOptionForTrack):
3190         * page/CaptionUserPreferences.h:
3191         * platform/MediaSelectionOption.h: Added.
3192         * platform/cocoa/WebPlaybackSessionModel.h:
3193         (WebCore::WebPlaybackSessionModelClient::audioMediaSelectionOptionsChanged):
3194         (WebCore::WebPlaybackSessionModelClient::legibleMediaSelectionOptionsChanged):
3195         * platform/cocoa/WebPlaybackSessionModelMediaElement.h:
3196         * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
3197         (WebCore::WebPlaybackSessionModelMediaElement::audioMediaSelectionOptions):
3198         (WebCore::WebPlaybackSessionModelMediaElement::legibleMediaSelectionOptions):
3199         * platform/ios/WebPlaybackSessionInterfaceAVKit.h:
3200         * platform/ios/WebPlaybackSessionInterfaceAVKit.mm:
3201         (WebCore::mediaSelectionOptions):
3202         (WebCore::WebPlaybackSessionInterfaceAVKit::audioMediaSelectionOptionsChanged):
3203         (WebCore::WebPlaybackSessionInterfaceAVKit::legibleMediaSelectionOptionsChanged):
3204         * platform/ios/WebVideoFullscreenControllerAVKit.mm:
3205         (WebVideoFullscreenControllerContext::audioMediaSelectionOptionsChanged):
3206         (WebVideoFullscreenControllerContext::legibleMediaSelectionOptionsChanged):
3207         (WebVideoFullscreenControllerContext::audioMediaSelectionOptions):
3208         (WebVideoFullscreenControllerContext::legibleMediaSelectionOptions):
3209         * platform/mac/WebPlaybackControlsManager.h:
3210         * platform/mac/WebPlaybackControlsManager.mm:
3211         (toAVTouchBarMediaSelectionOptionType):
3212         (mediaSelectionOptions):
3213         (-[WebPlaybackControlsManager setAudioMediaSelectionOptions:withSelectedIndex:]):
3214         (-[WebPlaybackControlsManager setLegibleMediaSelectionOptions:withSelectedIndex:]):
3215         (-[WebPlaybackControlsManager webPlaybackSessionInterfaceMac]):
3216         (-[WebPlaybackControlsManager setWebPlaybackSessionInterfaceMac:]):
3217         * platform/mac/WebPlaybackSessionInterfaceMac.h:
3218         * platform/mac/WebPlaybackSessionInterfaceMac.mm:
3219         (WebCore::WebPlaybackSessionInterfaceMac::audioMediaSelectionOptionsChanged):
3220         (WebCore::WebPlaybackSessionInterfaceMac::legibleMediaSelectionOptionsChanged):
3221
3222 2017-04-22  Wenson Hsieh  <wenson_hsieh@apple.com>
3223
3224         File inputs only accept UTI types that can be inserted into contenteditable areas when dropping
3225         https://bugs.webkit.org/show_bug.cgi?id=171177
3226         <rdar://problem/31765379>
3227
3228         Reviewed by Andy Estes.
3229
3230         Currently, DragController::canProcessDrag bails immediately with `false` if the drag data does not contain
3231         compatible content. However, if we are dragging over a file input, we want the presence of files in the drag
3232         data to take priority. To fix this, we teach DragData::containsCompatibleContent to take the purpose of the drag
3233         into account (by default, this is Editing, but when dragging over a file input, this becomes FileUpload). We
3234         then consider DragData to have compatible content for the purpose of file uploading if it contains any files.
3235
3236         Test: DataInteractionTests.ExternalSourceJSONToFileInput.
3237
3238         * page/DragController.cpp:
3239         (WebCore::DragController::canProcessDrag):
3240         * platform/DragData.h:
3241         * platform/gtk/DragDataGtk.cpp:
3242         (WebCore::DragData::containsCompatibleContent):
3243         * platform/mac/DragDataMac.mm:
3244         (WebCore::DragData::containsCompatibleContent):
3245         * platform/win/DragDataWin.cpp:
3246         (WebCore::DragData::containsCompatibleContent):
3247
3248 2017-04-22  Eric Carlson  <eric.carlson@apple.com>
3249
3250         [MediaStream] Fix regression caused by r215626
3251         https://bugs.webkit.org/show_bug.cgi?id=171168
3252         <rdar://problem/31774787>
3253
3254         Reviewed by Antoine Quint.
3255
3256         No new tests, fixes fast/mediastream/MediaStream-page-muted.html
3257
3258         * Modules/mediastream/MediaStream.cpp:
3259         (WebCore::MediaStream::mediaState): Test muted before m_isProducingData because if both are 
3260         true we want to report that the stream is muted.
3261
3262 2017-04-21  Zalan Bujtas  <zalan@apple.com>
3263
3264         Do not measure large chunk of text repeatedly during mid-word breaking.
3265         https://bugs.webkit.org/show_bug.cgi?id=171065
3266         <rdar://problem/31630245>
3267
3268         Reviewed by Antti Koivisto.
3269
3270         This patch reduces redundant text measuring for mid-word breaking by
3271         1. Adjusting the range for the binary search when the text fragment is longer than the available width
3272         2. Preserving the width value for the left side of the split fragment (computed during the binary search) so
3273         that when the fragment is being split we don't need to re-measure it
3274         3. Checking if the right side fits the next line and only adjust the width (by re-measuring the text) for
3275         kerning/ligature if it does (if it does not fit, we'll end up re-measuring some part of it
3276         during the next split)
3277
3278         Performance test has already been added.
3279
3280         * rendering/SimpleLineLayout.cpp:
3281         (WebCore::SimpleLineLayout::hyphenPositionForFragment):
3282         (WebCore::SimpleLineLayout::split): binary search with adjusting the range and preserving the width for the left side.
3283         (WebCore::SimpleLineLayout::splitFragmentToFitLine):
3284         (WebCore::SimpleLineLayout::FragmentForwardIterator::FragmentForwardIterator): Deleted.
3285         (WebCore::SimpleLineLayout::FragmentForwardIterator::operator++): Deleted.
3286         (WebCore::SimpleLineLayout::FragmentForwardIterator::operator!=): Deleted.
3287         (WebCore::SimpleLineLayout::FragmentForwardIterator::operator==): Deleted.
3288         (WebCore::SimpleLineLayout::FragmentForwardIterator::operator*): Deleted.
3289         (WebCore::SimpleLineLayout::begin): Deleted.
3290         (WebCore::SimpleLineLayout::end): Deleted.
3291         * rendering/SimpleLineLayoutTextFragmentIterator.h:
3292         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::split):
3293         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::splitWithHyphen):
3294
3295 2017-04-21  Wenson Hsieh  <wenson_hsieh@apple.com>
3296
3297         Support writing link titles to the pasteboard when beginning data interaction on a link
3298         https://bugs.webkit.org/show_bug.cgi?id=171154
3299         <rdar://problem/31356937>
3300
3301         Reviewed by Andy Estes.
3302
3303         Currently, when writing NSURLs to the pasteboard, we only write a String to the pasteboard corresponding to
3304         kUTTypeURL. This means richer data associated with the link (in this case, the title) are not captured when
3305         writing to the pasteboard. To address this, we introduce a new codepath for writing links to the pasteboard that
3306         mirrors the way PasteboardImage and PasteboardWebContent are written to the pasteboard.
3307
3308         Test: Augmented DataInteractionTests.LinkToInput.
3309
3310         * platform/PasteboardStrategy.h:
3311         * platform/PlatformPasteboard.h:
3312
3313         Add plumbing support for writing PasteboardURLs.
3314
3315         * platform/ios/PasteboardIOS.mm:
3316         (WebCore::Pasteboard::write):
3317         * platform/ios/PlatformPasteboardIOS.mm:
3318         (WebCore::PlatformPasteboard::writeObjectRepresentations):
3319
3320         Teach PlatformPasteboard to also set the _title attribute of the NSURL when creating an NSURL representation
3321         for registering with the shared WebItemProviderPasteboard.
3322
3323         (WebCore::PlatformPasteboard::write):
3324         * platform/ios/WebItemProviderPasteboard.mm:
3325
3326         Remove deprecation guards and replace deprecated method calls with the latest undeprecated versions.
3327
3328         (-[WebItemProviderPasteboard setItemsFromObjectRepresentations:]):
3329
3330 2017-04-21  Michael Catanzaro  <mcatanzaro@igalia.com>
3331
3332         Unreviewed, rolling out r215608.
3333
3334         Hundreds of test failures on GTK bot
3335
3336         Reverted changeset:
3337
3338         "Reduce copies and allocations in SharedBuffer::append"
3339         https://bugs.webkit.org/show_bug.cgi?id=170956
3340         http://trac.webkit.org/changeset/215608
3341
3342 2017-04-21  Zalan Bujtas  <zalan@apple.com>
3343
3344         REGRESSION(r205374): <li> content inside <ul> should mid-word wrap when word-break: break-word is present.
3345         https://bugs.webkit.org/show_bug.cgi?id=171108
3346         <rdar://problem/30271747>
3347
3348         Reviewed by Dan Bernstein.
3349
3350         This patch ensures that we search for mid-word breaks when a zero sized element has been committed on the line
3351         unless it's an image or some other replaced element with special properties (e.g. list-style: inside).  
3352
3353         Tests: fast/replaced/ul-li-word-break-break-word.html
3354                fast/replaced/zero-width-image-force-linebreak.html
3355
3356         * rendering/line/BreakingContext.h:
3357         (WebCore::BreakingContext::handleReplaced):
3358         (WebCore::BreakingContext::handleText): This matches pre-r205374 behaviour, but it's explicit about whether a 
3359         replaced width has already been committed on the current line.
3360         * rendering/line/LineWidth.cpp:
3361         (WebCore::LineWidth::commit):
3362         * rendering/line/LineWidth.h:
3363         (WebCore::LineWidth::hasCommittedReplaced):
3364         (WebCore::LineWidth::addUncommittedReplacedWidth): These 2 last functions were removed with r205374 (and now I am adding them back). 
3365
3366 2017-04-21  Jer Noble  <jer.noble@apple.com>
3367
3368         [MediaCapture] Improvements to CoreAudioCaptureSource
3369         https://bugs.webkit.org/show_bug.cgi?id=171146
3370
3371         Reviewed by Eric Carlson.
3372
3373         Various interlocking improvements to CoreAudioCaptureSource:
3374
3375         - Allow the volume, sampleRate, and echoCancellation settings to be applied to the source.
3376         - Update the values returned via settings() when these values change.
3377         - Obey the sampleRate and echoCancellation settings when creating the VPIO unit.
3378         - Because AudioUnitRender() mutates the passed in AudioBufferList, reset it immediately before calling.
3379
3380         * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
3381         (WebCore::CoreAudioCaptureSource::create):
3382         (WebCore::CoreAudioCaptureSource::CoreAudioCaptureSource):
3383         (WebCore::CoreAudioCaptureSource::preferredSampleRate):
3384         (WebCore::CoreAudioCaptureSource::preferredIOBufferSize):
3385         (WebCore::CoreAudioCaptureSource::configureMicrophoneProc):
3386         (WebCore::CoreAudioCaptureSource::configureSpeakerProc):
3387         (WebCore::CoreAudioCaptureSource::processMicrophoneSamples):
3388         (WebCore::CoreAudioCaptureSource::setupAudioUnits):
3389         (WebCore::CoreAudioCaptureSource::stopProducingData):
3390         (WebCore::CoreAudioCaptureSource::settings):
3391         (WebCore::CoreAudioCaptureSource::settingsDidChange):
3392         (WebCore::CoreAudioCaptureSource::preferredIOBufferDuration): Deleted.
3393         * platform/mediastream/mac/CoreAudioCaptureSource.h:
3394
3395 2017-04-21  Youenn Fablet  <youenn@apple.com>
3396
3397         com.apple.WebCore: non-virtual thunk to WebCore::LibWebRTCDataChannelHandler::OnBufferedAmountChange + 39
3398         https://bugs.webkit.org/show_bug.cgi?id=171087
3399         <rdar://problem/31739051>
3400
3401         Reviewed by Eric Carlson.
3402
3403         Covered by existing tests.
3404         No test added as this behavior is really libwebrtc specific and cannot be triggered easily.
3405
3406         * Modules/mediastream/RTCDataChannel.cpp:
3407         (WebCore::RTCDataChannel::close): Stopping observing libwebrtc data channel before closing it.
3408         This ensures we will stop getting notified as soon as there is no more interest.
3409         * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
3410         (WebCore::LibWebRTCDataChannelHandler::OnStateChange): libwebrtc can still notify us even though we said we were
3411         not interested. Ensuring we do not call the client if we are no longer interested.
3412         (WebCore::LibWebRTCDataChannelHandler::OnMessage): Ditto.
3413         (WebCore::LibWebRTCDataChannelHandler::OnBufferedAmountChange): Ditto.
3414
3415 2017-04-21  Andy Estes  <aestes@apple.com>
3416
3417         [macOS] Enable media selection button on AVTouchBarScrubber
3418         https://bugs.webkit.org/show_bug.cgi?id=171149
3419         <rdar://problem/29875010>
3420
3421         Reviewed by Beth Dakin.
3422
3423         * platform/spi/cocoa/AVKitSPI.h:
3424
3425 2017-04-21  Andy Estes  <aestes@apple.com>
3426
3427         [macOS] Name WebPlaybackControlsManager delegate methods correctly depending on OS version
3428         https://bugs.webkit.org/show_bug.cgi?id=171147
3429         <rdar://problem/29875010>
3430
3431         Reviewed by Beth Dakin.
3432
3433         On macOS 10.12, WebPlaybackControlsManager conforms to
3434         AVFunctionBarPlaybackControlsControlling, but on