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