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