897ca5a82fdbb51242a4e51262dc9162849190e5
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-05-04  Joseph Pecoraro  <pecoraro@apple.com>
2
3         REGRESSION(r216138): Web Inspector: ASSERT(!content.isNull()) when checking for source map url opening inspector
4         https://bugs.webkit.org/show_bug.cgi?id=171697
5         <rdar://problem/31999512>
6
7         Reviewed by Matt Baker.
8
9         * inspector/InspectorPageAgent.cpp:
10         (WebCore::InspectorPageAgent::cachedResourceContent):
11         Always set base64Encoded when returning true. Return the empty
12         string instead of a null string matching previous behavior.
13
14 2017-05-04  Wenson Hsieh  <wenson_hsieh@apple.com>
15
16         [WK2] Add support for keeping the selection in a focused editable element when dragging begins
17         https://bugs.webkit.org/show_bug.cgi?id=171585
18         <rdar://problem/31544320>
19
20         Reviewed by Beth Dakin and Zalan Bujtas.
21
22         Covered by 4 API tests.
23
24         * dom/DocumentMarker.h:
25
26         Introduces the DraggedContent DocumentMarker type, which applies to the Range in the DOM that is being used as
27         a drag source. Also adds DraggedContentData, which contains nodes found by the TextIterator in the process of
28         finding Ranges to mark.
29
30         (WebCore::DocumentMarker::AllMarkers::AllMarkers):
31         * dom/DocumentMarkerController.cpp:
32         (WebCore::DocumentMarkerController::addDraggedContentMarker):
33         (WebCore::shouldInsertAsSeparateMarker):
34         (WebCore::DocumentMarkerController::addMarker):
35
36         When adding DocumentMarkers of type DraggedContent, keep adjacent RenderReplaced elements separate, rather than
37         merging them into existing RenderedDocumentMarkers. This is because the data for each of these (i.e. the target
38         node) needs to be preserved.
39
40         (WebCore::DocumentMarkerController::markersFor):
41
42         Bail and return an empty list if the map of document markers cannot possibly contain a dragged content marker.
43
44         * dom/DocumentMarkerController.h:
45         * page/DragController.h:
46         * page/DragState.h:
47
48         Add draggedContentRange to DragState. This tracks the Range that is being dragged; it is created when the drag
49         session has begun, and ends when drag session finishes (either via WebPage::dragEnded or WebPage::dragCancelled).
50
51         * page/EventHandler.cpp:
52         (WebCore::repaintContentsOfRange):
53         (WebCore::EventHandler::dragCancelled):
54
55         Called when a drag is cancelled in the UI process without a session ever getting a chance to begin. We use this
56         as a hook to remove all DraggedContent document markers from the document of the dragged content range.
57
58         (WebCore::EventHandler::didStartDrag):
59
60         Called when a drag session has begun in the UI process. We use this as a hook to set up document markers for the
61         Range of content being dragged.
62
63         (WebCore::EventHandler::dragSourceEndedAt):
64
65         Called when a drag session ends. We use this as a hook to remove all DraggedContent document markers from the
66         document of the dragged content range.
67
68         (WebCore::EventHandler::draggedElement):
69         * page/EventHandler.h:
70         * page/FocusController.cpp:
71         (WebCore::shouldClearSelectionWhenChangingFocusedElement):
72
73         Prevent the selection from clearing when the previously focused element is editable and also contains the drag
74         source element. Ideally, we should experiment with clearing out the selection whenever the element is blurred
75         (and not have additional restrictions on editability and containing the drag source), but this change is much
76         riskier.
77
78         (WebCore::FocusController::setFocusedElement):
79         * rendering/InlineTextBox.cpp:
80         (WebCore::InlineTextBox::paint):
81
82         Use RenderText::draggedContentStartEnd to find the range of text (if any) that is dragged content, and paint
83         these ranges of text at a lower alpha using TextPainter::paintTextInRange.
84
85         * rendering/RenderReplaced.cpp:
86         (WebCore::draggedContentContainsReplacedElement):
87
88         Determines whether or not the element being rendered is contained within a dragged content range. Assuming that
89         the DraggedContent type flag is set in DocumentMarkerController, we first look to see whether or not the
90         container node is in the document marker map. If so, instead of consulting node offset ranges (since this is, in
91         the worst-case, linear in the number of sibling nodes per RenderReplaced) we simply check the DraggedContentData
92         to see if the current element being rendered matches one of the target nodes.
93
94         (WebCore::RenderReplaced::paint):
95
96         If the element rendered by this RenderReplaced is dragged content, then render it at a low alpha.
97
98         * rendering/RenderText.cpp:
99         (WebCore::RenderText::draggedContentRangesBetweenOffsets):
100
101         Determines what range of text, if any, contains dragged content by consulting the Document's DocumentMarkers.
102
103         * rendering/RenderText.h:
104         * rendering/TextPainter.cpp:
105         (WebCore::TextPainter::paintTextInRange):
106
107         Teach TextPainter to only paint a given range in a TextRun.
108
109         * rendering/TextPainter.h:
110
111         Add TextPainter support for specifying special text offset ranges when rendering a TextRun, such that each
112         special range in text is rendered after applying some modification to the GraphicsContext.
113
114 2017-05-04  Jeremy Jones  <jeremyj@apple.com>
115
116         Crash when pointer lock element is removed before pointer lock allowed arrives.
117         https://bugs.webkit.org/show_bug.cgi?id=171642
118
119         Reviewed by Jer Noble.
120
121         Make sure there a pending lock before attempting to complete pointer lock.
122
123         * page/PointerLockController.cpp:
124         (WebCore::PointerLockController::didAcquirePointerLock):
125
126 2017-05-04  Chris Dumez  <cdumez@apple.com>
127
128         Reformat / Clean up Node.idl to match the specification
129         https://bugs.webkit.org/show_bug.cgi?id=171686
130
131         Reviewed by Sam Weinig.
132
133         Reformat / Clean up Node.idl to match the specification:
134         - https://dom.spec.whatwg.org/#node
135
136         There should be no Web-facing behavior change, except for Node properties
137         being enumerated in a slightly different order.
138
139         * dom/Node.idl:
140
141 2017-05-04  Sam Weinig  <sam@webkit.org>
142
143         Remove support for legacy Notifications
144         https://bugs.webkit.org/show_bug.cgi?id=171487
145
146         Reviewed by Jon Lee.
147
148         * CMakeLists.txt:
149         * WebCore.xcodeproj/project.pbxproj:
150         Remove files.
151
152         * Configurations/FeatureDefines.xcconfig:
153         Remove definition of ENABLE_LEGACY_NOTIFICATIONS.
154
155         * DerivedSources.make:
156         Remove IDL files.
157
158         * Modules/notifications/DOMWindowNotifications.cpp: Removed.
159         * Modules/notifications/DOMWindowNotifications.h: Removed.
160         * Modules/notifications/DOMWindowNotifications.idl: Removed.
161         * Modules/notifications/NotificationCenter.cpp: Removed.
162         * Modules/notifications/NotificationCenter.h: Removed.
163         * Modules/notifications/NotificationCenter.idl: Removed.
164         * Modules/notifications/NotificationClient.h:
165         * Modules/notifications/NotificationController.cpp:
166         * Modules/notifications/NotificationController.h:
167         * Modules/notifications/WorkerGlobalScopeNotifications.cpp: Removed.
168         * Modules/notifications/WorkerGlobalScopeNotifications.h: Removed.
169         * Modules/notifications/WorkerGlobalScopeNotifications.idl: Removed.
170         * Modules/notifications/Notification.idl:
171         * Modules/notifications/Notification.cpp:
172         * Modules/notifications/Notification.h:
173         * dom/EventTargetFactory.in:
174         * page/DOMWindow.cpp:
175         * workers/WorkerThread.h:
176         Remove code legacy Notification code. Replace use of NotificationCenter with direct
177         calls to the NotificationClient.
178
179 2017-05-04  Antti Koivisto  <antti@apple.com>
180
181         REGRESSION (Safari 10.1): When 'transition' contains -ms-transform, transform-origin is also transitioned
182         https://bugs.webkit.org/show_bug.cgi?id=171250
183         <rdar://problem/31827243>
184
185         Reviewed by Geoffrey Garen.
186
187         We were mapping unknown properties to 'all' animation. With this patch we ignore them instead.
188         The patch also implements roundtripping of unknown properties via CSSOM, matching Blink and Gecko.
189
190         Test: transitions/transition-unknown-property-ignore.html
191
192         * css/CSSComputedStyleDeclaration.cpp:
193         (WebCore::createTransitionPropertyValue):
194
195             Return the correct name for unknown properties.
196
197         * css/CSSToStyleMap.cpp:
198         (WebCore::CSSToStyleMap::mapAnimationProperty):
199
200             Map any unknown property to AnimateUnknownProperty mode instead of falling back to the default of AnimateAll.
201             Save the unknown property name so we can roundtrip it properly.
202
203         * page/animation/CompositeAnimation.cpp:
204         (WebCore::CompositeAnimation::updateTransitions):
205
206             Ignore AnimateUnknownProperty like AnimateNone.
207
208         * platform/animation/Animation.h:
209         (WebCore::Animation::unknownProperty):
210         (WebCore::Animation::setUnknownProperty):
211
212 2017-05-04  Chris Dumez  <cdumez@apple.com>
213
214         Clean up MutationRecord.idl
215         https://bugs.webkit.org/show_bug.cgi?id=171685
216
217         Reviewed by Sam Weinig.
218
219         Clean up MutationRecord.idl to match the specification:
220         - https://dom.spec.whatwg.org/#mutationrecord
221
222         There is no Web-facing behavior change.
223
224         * dom/MutationRecord.idl:
225
226 2017-05-04  Chris Dumez  <cdumez@apple.com>
227
228         Reformat / clean up Event.idl
229         https://bugs.webkit.org/show_bug.cgi?id=171675
230
231         Reviewed by Sam Weinig.
232
233         Reformat / clean up Event.idl to match the latest spec more closely:
234         - https://dom.spec.whatwg.org/#interface-event
235
236         There is no web-facing behavior change, except for properties being
237         enumerated in a slightly different order.
238
239         * dom/Event.idl:
240
241 2017-05-04  Daniel Bates  <dabates@apple.com>
242
243         Cleanup: Extract CachedScript::mimeTypeAllowedByNosniff() into a common function
244         https://bugs.webkit.org/show_bug.cgi?id=171678
245
246         Reviewed by Andy Estes.
247
248         Extract CachedScript::mimeTypeAllowedByNosniff() into a common function that can
249         be shared by LoadableClassicScript and WorkerScriptLoader.
250
251         No functionality was changed. So, no new tests.
252
253         * dom/LoadableClassicScript.cpp:
254         (WebCore::LoadableClassicScript::notifyFinished): Modified to use WebCore::isScriptAllowedByNosniff().
255         * loader/cache/CachedScript.cpp:
256         (WebCore::CachedScript::mimeType): Deleted; incorporated into WebCore::isScriptAllowedByNosniff().
257         (WebCore::CachedScript::mimeTypeAllowedByNosniff): Deleted; incorporated into WebCore::isScriptAllowedByNosniff().
258         * loader/cache/CachedScript.h:
259         * platform/network/ResourceResponseBase.cpp:
260         (WebCore::isScriptAllowedByNosniff): Added. Note that it is sufficient to extract the MIME type
261         as-is and query the MIME type registry because the MIME type registry performs look ups case-insensitively.
262         * platform/network/ResourceResponseBase.h:
263         * workers/WorkerScriptLoader.cpp:
264         (WebCore::WorkerScriptLoader::didReceiveResponse): Modified to use WebCore::isScriptAllowedByNosniff().
265         (WebCore::mimeTypeAllowedByNosniff): Deleted.
266
267 2017-05-04  Sam Weinig  <sam@webkit.org>
268
269         Make the [EnabledBySetting] extended attribute work for any attribute or operation on a prototype
270         https://bugs.webkit.org/show_bug.cgi?id=171588
271
272         Reviewed by Dean Jackson.
273
274         * bindings/js/JSDOMIterator.h:
275         (WebCore::JSDOMIterator::createPrototype):
276         * bindings/js/JSDOMWindowShell.cpp:
277         (WebCore::JSDOMWindowShell::setWindow):
278         * bindings/js/JSDOMWrapperCache.h:
279         (WebCore::getDOMStructure):
280         (WebCore::getDOMPrototype):
281         * bindings/js/WorkerScriptController.cpp:
282         (WebCore::WorkerScriptController::initScript):
283         Update to account for createPrototype and prototype taking the global object by reference.
284         
285         * bindings/scripts/CodeGeneratorJS.pm:
286         (NeedsSettingsCheckForPrototypeProperty):
287         Add predicate to determine if an interface has any settings enabled properties on the prototype,
288         needed to determine if we should pass the global object to finishCreation.
289
290         (GenerateHeader):
291         Update signature of both createPrototype and prototype to take JSDOMGlobalObject& rather than
292         a JSC::JSGlobalObject*, this allows us to pass the more specific type to the prototype constructor,
293         and access the ScriptExecutionContext for the Settings.
294
295         (GeneratePropertiesHashTable):
296         Update to return, via out parameter, arrays with the attributes and operations that specify EnabledBySetting. This
297         mimics the model used for RuntimeEnabledFeatures.
298
299         (GenerateImplementation):
300         In {Class}Prototype::finishCreation, add code to check settings to see if an attribute or operation should be enabled,
301         and if it shouldn't remove it from the object. This, again, is modeled on RuntimeEnabledFeatures.
302
303         (GeneratePrototypeDeclaration):
304         Update signatures to take JSDOMGlobalObject& and specialize finishCreation to take one if there are any properties
305         that require settings to enable.
306
307         (GenerateConstructorHelperMethods):
308         Update for new signature of prototype(...).
309
310         * bindings/scripts/test/JS/JSInterfaceName.cpp:
311         * bindings/scripts/test/JS/JSInterfaceName.h:
312         * bindings/scripts/test/JS/JSMapLike.cpp:
313         * bindings/scripts/test/JS/JSMapLike.h:
314         * bindings/scripts/test/JS/JSReadOnlyMapLike.cpp:
315         * bindings/scripts/test/JS/JSReadOnlyMapLike.h:
316         * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
317         * bindings/scripts/test/JS/JSTestActiveDOMObject.h:
318         * bindings/scripts/test/JS/JSTestCEReactions.cpp:
319         * bindings/scripts/test/JS/JSTestCEReactions.h:
320         * bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp:
321         * bindings/scripts/test/JS/JSTestCEReactionsStringifier.h:
322         * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.cpp:
323         * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h:
324         * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp:
325         * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h:
326         * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
327         * bindings/scripts/test/JS/JSTestCustomNamedGetter.h:
328         * bindings/scripts/test/JS/JSTestDOMJIT.cpp:
329         * bindings/scripts/test/JS/JSTestDOMJIT.h:
330         * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
331         * bindings/scripts/test/JS/JSTestEventConstructor.h:
332         * bindings/scripts/test/JS/JSTestEventTarget.cpp:
333         * bindings/scripts/test/JS/JSTestEventTarget.h:
334         * bindings/scripts/test/JS/JSTestException.cpp:
335         * bindings/scripts/test/JS/JSTestException.h:
336         * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
337         * bindings/scripts/test/JS/JSTestGenerateIsReachable.h:
338         * bindings/scripts/test/JS/JSTestGlobalObject.h:
339         * bindings/scripts/test/JS/JSTestInterface.cpp:
340         * bindings/scripts/test/JS/JSTestInterface.h:
341         * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.cpp:
342         * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.h:
343         * bindings/scripts/test/JS/JSTestIterable.cpp:
344         * bindings/scripts/test/JS/JSTestIterable.h:
345         * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp:
346         * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.h:
347         * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
348         * bindings/scripts/test/JS/JSTestMediaQueryListListener.h:
349         * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
350         * bindings/scripts/test/JS/JSTestNamedConstructor.h:
351         * bindings/scripts/test/JS/JSTestNode.cpp:
352         * bindings/scripts/test/JS/JSTestNode.h:
353         * bindings/scripts/test/JS/JSTestObj.cpp:
354         * bindings/scripts/test/JS/JSTestObj.h:
355         * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
356         * bindings/scripts/test/JS/JSTestOverloadedConstructors.h:
357         * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
358         * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.h:
359         * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp:
360         * bindings/scripts/test/JS/JSTestOverrideBuiltins.h:
361         * bindings/scripts/test/JS/JSTestSerialization.cpp:
362         * bindings/scripts/test/JS/JSTestSerialization.h:
363         * bindings/scripts/test/JS/JSTestSerializationInherit.cpp:
364         * bindings/scripts/test/JS/JSTestSerializationInherit.h:
365         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp:
366         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.h:
367         * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
368         * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:
369         * bindings/scripts/test/JS/JSTestTypedefs.cpp:
370         * bindings/scripts/test/JS/JSTestTypedefs.h:
371         Update test results for new test values and changes in signatures to pass JSDOMGlobalObject.
372
373         * bindings/scripts/test/TestObj.idl:
374         Add tests for [EnableBySetting] for attributes and operations.
375
376         * bridge/objc/objc_runtime.h:
377         * bridge/runtime_array.h:
378         * bridge/runtime_method.h:
379         * bridge/runtime_object.h:
380         * inspector/CommandLineAPIHost.cpp:
381         Update createPrototype function to take the global object by reference.
382
383 2017-05-04  Eric Carlson  <eric.carlson@apple.com>
384
385         [MediaStream] Allow host application to enable/disable media capture
386         https://bugs.webkit.org/show_bug.cgi?id=171292
387         <rdar://problem/31821492>
388
389         Reviewed by Jer Noble.
390
391         No new layout tests, added an API test instead.
392
393         * Modules/mediastream/MediaStream.cpp:
394         (WebCore::MediaStream::endStream): New, stop all tracks.
395         * Modules/mediastream/MediaStream.h:
396
397         * Modules/mediastream/MediaStreamRegistry.cpp:
398         (WebCore::MediaStreamRegistry::unregisterStream): Minor cleanup.
399         (WebCore::MediaStreamRegistry::forEach): New, call the lambda with each stream.
400         (WebCore::MediaStreamRegistry::MediaStreamRegistry): Deleted, unused.
401         * Modules/mediastream/MediaStreamRegistry.h:
402
403         * Modules/mediastream/MediaStreamTrack.cpp:
404         (WebCore::MediaStreamTrack::stopTrack): Add parameter so caller can specify if an 'ended' 
405         event should be sent or not.
406         (WebCore::MediaStreamTrack::trackMutedChanged): Don't post an event if the track has ended.
407         * Modules/mediastream/MediaStreamTrack.h:
408
409         * dom/Document.cpp:
410         (WebCore::Document::stopMediaCapture): Stop all streams in the document.
411         * dom/Document.h:
412
413         * page/Page.cpp:
414         (WebCore::Page::stopMediaCapture): Stop all streams.
415         * page/Page.h:
416
417         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
418         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::currentDisplayMode): Display a black frame
419         when the stream ends.
420         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::activeStatusChanged): Signal a characteristics
421         change to HTMLMediaElement refresh state.
422         * platform/mediastream/MediaStreamPrivate.h:
423
424         * platform/mediastream/mac/AVMediaCaptureSource.mm:
425         (WebCore::AVMediaCaptureSource::stopProducingData): Don't return early if the session isn't 
426         running, we always need to clear m_session on iOS.
427
428 2017-05-04  Zalan Bujtas  <zalan@apple.com>
429
430         Should never hit layout while updating the render tree.
431         https://bugs.webkit.org/show_bug.cgi?id=171643
432
433         Reviewed by Antti Koivisto.
434
435         Laying out a half-baked render tree is not a great idea. Especially considering
436         that layout (sadly) can mutate the render tree.  
437
438         * page/FrameView.cpp:
439         (WebCore::FrameView::layout):
440
441 2017-05-04  Daniel Bates  <dabates@apple.com>
442
443         importScripts() should respect X-Content-Type-Options: nosniff
444         https://bugs.webkit.org/show_bug.cgi?id=171248
445         <rdar://problem/31819023>
446
447         Reviewed by Andy Estes.
448
449         Do not load a worker script if it has the HTTP response header "X-Content-Type-Options: nosniff"
450         and its Content-type header is not an allowed JavaScript script mime type. This behavior follows
451         from <https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-imported-script> (3 May 2017),
452         <https://fetch.spec.whatwg.org/#concept-fetch> (2 May 2017), and <https://fetch.spec.whatwg.org/#concept-main-fetch>.
453
454         * workers/WorkerScriptLoader.cpp:
455         (WebCore::mimeTypeAllowedByNosniff): Added.
456         (WebCore::WorkerScriptLoader::didReceiveResponse): Mark the load as failed if the response
457         is not allowed by X-Content-Type-Options: nosniff.
458
459 2017-05-04  Dave Hyatt  <hyatt@apple.com>
460
461         REGRESSION(STP): rgb() with calc() containing variables doesn't work
462         https://bugs.webkit.org/show_bug.cgi?id=169939
463
464         Reviewed by Zalan Bujtas.
465
466         Added new test in fast/css/variables.
467
468         * css/CSSCalculationValue.cpp:
469         (WebCore::CSSCalcExpressionNodeParser::parseValue):
470         Treat floats in calcs as integers when we can.
471
472 2017-05-04  Commit Queue  <commit-queue@webkit.org>
473
474         Unreviewed, rolling out r216172.
475         https://bugs.webkit.org/show_bug.cgi?id=171654
476
477         FTBFS for iOS due to missing WebPageProxy::stopMediaCapture()
478         implementation. (Requested by ddkilzer on #webkit).
479
480         Reverted changeset:
481
482         "[MediaStream] Allow host application to enable/disable media
483         capture"
484         https://bugs.webkit.org/show_bug.cgi?id=171292
485         http://trac.webkit.org/changeset/216172
486
487 2017-05-03  Carlos Garcia Campos  <cgarcia@igalia.com>
488
489         REGRESSION(r215686): Incremental reads from SharedBuffer are wrong after r215686
490         https://bugs.webkit.org/show_bug.cgi?id=171602
491
492         Reviewed by Michael Catanzaro.
493
494         In TextTrackLoader::processNewCueData() and PNGImageReader::decode() we changed the patter to read data from a
495         SharedBuffer at a given offset. The new pattern is not correct, because it assumes the whole segment is always
496         read, and the new offset is not correct when that's not the case. This has broken the rendering of png images in
497         the GTK+ port, only the first bytes are correctly decoded and drawn, but not the rest of the image.
498
499         Fixes: editing/pasteboard/paste-image-using-image-data.html
500
501         * loader/TextTrackLoader.cpp:
502         (WebCore::TextTrackLoader::processNewCueData):
503         * platform/image-decoders/png/PNGImageDecoder.cpp:
504         (WebCore::PNGImageReader::decode):
505
506 2017-05-03  Eric Carlson  <eric.carlson@apple.com>
507
508         [MediaStream] Allow host application to enable/disable media capture
509         https://bugs.webkit.org/show_bug.cgi?id=171292
510         <rdar://problem/31821492>
511
512         Reviewed by Jer Noble.
513
514         No new layout tests, added an API test instead.
515
516         * Modules/mediastream/MediaStream.cpp:
517         (WebCore::MediaStream::endStream): New, stop all tracks.
518         * Modules/mediastream/MediaStream.h:
519
520         * Modules/mediastream/MediaStreamRegistry.cpp:
521         (WebCore::MediaStreamRegistry::unregisterStream): Minor cleanup.
522         (WebCore::MediaStreamRegistry::forEach): New, call the lambda with each stream.
523         (WebCore::MediaStreamRegistry::MediaStreamRegistry): Deleted, unused.
524         * Modules/mediastream/MediaStreamRegistry.h:
525
526         * Modules/mediastream/MediaStreamTrack.cpp:
527         (WebCore::MediaStreamTrack::stopTrack): Add parameter so caller can specify if an 'ended' 
528         event should be sent or not.
529         (WebCore::MediaStreamTrack::trackMutedChanged): Don't post an event if the track has ended.
530         * Modules/mediastream/MediaStreamTrack.h:
531
532         * dom/Document.cpp:
533         (WebCore::Document::stopMediaCapture): Stop all streams in the document.
534         * dom/Document.h:
535
536         * page/Page.cpp:
537         (WebCore::Page::stopMediaCapture): Stop all streams.
538         * page/Page.h:
539
540         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
541         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::currentDisplayMode): Display a black frame
542         when the stream ends.
543         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::activeStatusChanged): Signal a characteristics
544         change to HTMLMediaElement refresh state.
545         * platform/mediastream/MediaStreamPrivate.h:
546
547         * platform/mediastream/mac/AVMediaCaptureSource.mm:
548         (WebCore::AVMediaCaptureSource::stopProducingData): Don't return early if the session isn't 
549         running, we always need to clear m_session on iOS.
550
551 2017-05-03  John Wilander  <wilander@apple.com>
552
553         Resource Load Statistics: Remove all statistics for modifiedSince website data removals
554         https://bugs.webkit.org/show_bug.cgi?id=171584
555         <rdar://problem/24702576>
556
557         Reviewed by Brent Fulgham.
558
559         Test: http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html
560
561         * loader/ResourceLoadObserver.cpp:
562         (WebCore::ResourceLoadObserver::clearInMemoryAndPersistentStore):
563             Now clears all regardless of the modifiedSince parameter's value.
564
565 2017-05-03  Andy Estes  <aestes@apple.com>
566
567         Try to fix the macOS Public SDK build
568         https://bugs.webkit.org/show_bug.cgi?id=171635
569         <rdar://problem/31812751>
570
571         Unreviewed because the commit queue told me to say this.
572
573         * platform/spi/cocoa/AVKitSPI.h:
574
575 2017-05-03  Joanmarie Diggs  <jdiggs@igalia.com>
576
577         AX: aria-rowspan value should be ignored if td/th rowspan value is provided
578         https://bugs.webkit.org/show_bug.cgi?id=171214
579
580         Reviewed by Chris Fleizach.
581
582         Return -1 in AccessibilityTableCell::ariaColumnSpan() and ariaRowSpan() if the
583         cell element has an explicit value for the native host language's span attribute.
584         Add checks to AccessibilityTableCell::columnIndexRange() and rowIndexRange() so
585         that we prefer an author-provided ARIA span value over an implicit host-language
586         span value. Similarly, add checks to AccessibilityARIAGridCell::columnIndexRange()
587         and rowIndexRange() so that we fall back on implicit host-language span values
588         when there is no author-provided ARIA span value and the ARIA cell is associated
589         with a cell element.
590
591         Test: accessibility/aria-cellspans-with-native-cellspans.html
592
593         * accessibility/AccessibilityARIAGridCell.cpp:
594         (WebCore::AccessibilityARIAGridCell::ariaRowSpanWithRowIndex):
595         (WebCore::AccessibilityARIAGridCell::columnIndexRange):
596         * accessibility/AccessibilityTableCell.cpp:
597         (WebCore::AccessibilityTableCell::rowIndexRange):
598         (WebCore::AccessibilityTableCell::columnIndexRange):
599         (WebCore::AccessibilityTableCell::ariaColumnSpan):
600         (WebCore::AccessibilityTableCell::ariaRowSpan):
601
602 2017-05-03  Commit Queue  <commit-queue@webkit.org>
603
604         Unreviewed, rolling out r216160 and r216161.
605         https://bugs.webkit.org/show_bug.cgi?id=171640
606
607         These changes broke the iOS build. (Requested by mlewis13 on
608         #webkit).
609
610         Reverted changesets:
611
612         "[MediaStream] Allow host application to enable/disable media
613         capture"
614         https://bugs.webkit.org/show_bug.cgi?id=171292
615         http://trac.webkit.org/changeset/216160
616
617         "[MediaStream] Allow host application to enable/disable media
618         capture"
619         https://bugs.webkit.org/show_bug.cgi?id=171292
620         http://trac.webkit.org/changeset/216161
621
622 2017-05-03  Eric Carlson  <eric.carlson@apple.com>
623
624         [MediaStream] Allow host application to enable/disable media capture
625         https://bugs.webkit.org/show_bug.cgi?id=171292
626         <rdar://problem/31821492>
627
628         Reviewed by Jer Noble.
629
630         No new layout tests, added an API test instead.
631
632         * Modules/mediastream/MediaStream.cpp:
633         (WebCore::MediaStream::endStream): New, stop all tracks.
634         * Modules/mediastream/MediaStream.h:
635
636         * Modules/mediastream/MediaStreamRegistry.cpp:
637         (WebCore::MediaStreamRegistry::unregisterStream): Minor cleanup.
638         (WebCore::MediaStreamRegistry::forEach): New, call the lambda with each stream.
639         (WebCore::MediaStreamRegistry::MediaStreamRegistry): Deleted, unused.
640         * Modules/mediastream/MediaStreamRegistry.h:
641
642         * Modules/mediastream/MediaStreamTrack.cpp:
643         (WebCore::MediaStreamTrack::stopTrack): Add parameter so caller can specify if an 'ended' 
644         event should be sent or not.
645         (WebCore::MediaStreamTrack::trackMutedChanged): Don't post an event if the track has ended.
646         * Modules/mediastream/MediaStreamTrack.h:
647
648         * dom/Document.cpp:
649         (WebCore::Document::stopMediaCapture): Stop all streams in the document.
650         * dom/Document.h:
651
652         * page/Page.cpp:
653         (WebCore::Page::stopMediaCapture): Stop all streams.
654         * page/Page.h:
655
656         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
657         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::currentDisplayMode): Display a black frame
658         when the stream ends.
659         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::activeStatusChanged): Signal a characteristics
660         change to HTMLMediaElement refresh state.
661         * platform/mediastream/MediaStreamPrivate.h:
662
663         * platform/mediastream/mac/AVMediaCaptureSource.mm:
664         (WebCore::AVMediaCaptureSource::stopProducingData): Don't return early if the session isn't 
665         running, we always need to clear m_session on iOS.
666
667 2017-05-03  Zalan Bujtas  <zalan@apple.com>
668
669         SearchInputType could end up with a mismatched renderer.
670         https://bugs.webkit.org/show_bug.cgi?id=171547
671         <rdar://problem/31935047>
672
673         Reviewed by Antti Koivisto.
674
675         Normally we've got the correct renderer by the time we call into SearchInputType.
676         However, since HTMLInputElement::updateType() eagerly updates the type while the associated renderers are done lazily
677         (so we don't get them updated until after the next tree update), we could actually end up
678         with a mismatched renderer (e.g. through form submission).
679
680         Test: fast/forms/change-input-type-and-submit-form-crash.html
681
682         * html/SearchInputType.cpp:
683         (WebCore::SearchInputType::addSearchResult):
684         (WebCore::SearchInputType::didSetValueByUserEdit):
685
686 2017-05-03  Jer Noble  <jer.noble@apple.com>
687
688         Make the VPIO audio unit a singleton, shared between multiple CaptureSources
689         https://bugs.webkit.org/show_bug.cgi?id=171622
690
691         Reviewed by Eric Carlson.
692
693         Move the implemnetation of CoreAudioCaptureSource into a shared singleton class, CoreAudioSharedUnit,
694         which will send audio to each of it's client CoreAudioCaptureSources. The first registered client will
695         define the settings used by the shared unit.
696
697         Drive-by fixes: Fix up setUseAVFoundationAudioCapture() to always accept the first value set.
698
699         * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
700         (WebCore::CoreAudioSharedUnit::isProducingData):
701         (WebCore::CoreAudioSharedUnit::microphoneFormat):
702         (WebCore::CoreAudioSharedUnit::singleton):
703         (WebCore::CoreAudioSharedUnit::addClient):
704         (WebCore::CoreAudioSharedUnit::removeClient):
705         (WebCore::CoreAudioSharedUnit::addEchoCancellationSource):
706         (WebCore::CoreAudioSharedUnit::removeEchoCancellationSource):
707         (WebCore::CoreAudioSharedUnit::preferredIOBufferSize):
708         (WebCore::CoreAudioSharedUnit::setupAudioUnits):
709         (WebCore::CoreAudioSharedUnit::configureMicrophoneProc):
710         (WebCore::CoreAudioSharedUnit::configureSpeakerProc):
711         (WebCore::CoreAudioSharedUnit::checkTimestamps):
712         (WebCore::CoreAudioSharedUnit::provideSpeakerData):
713         (WebCore::CoreAudioSharedUnit::speakerCallback):
714         (WebCore::CoreAudioSharedUnit::processMicrophoneSamples):
715         (WebCore::CoreAudioSharedUnit::microphoneCallback):
716         (WebCore::CoreAudioSharedUnit::cleanupAudioUnits):
717         (WebCore::CoreAudioSharedUnit::startProducingData):
718         (WebCore::CoreAudioSharedUnit::stopProducingData):
719         (WebCore::CoreAudioSharedUnit::suspend):
720         (WebCore::CoreAudioSharedUnit::defaultInputDevice):
721         (WebCore::CoreAudioCaptureSource::create):
722         (WebCore::CoreAudioCaptureSource::factory):
723         (WebCore::CoreAudioCaptureSource::CoreAudioCaptureSource):
724         (WebCore::CoreAudioCaptureSource::~CoreAudioCaptureSource):
725         (WebCore::CoreAudioCaptureSource::addEchoCancellationSource):
726         (WebCore::CoreAudioCaptureSource::removeEchoCancellationSource):
727         (WebCore::CoreAudioCaptureSource::startProducingData):
728         (WebCore::CoreAudioCaptureSource::stopProducingData):
729         (WebCore::CoreAudioCaptureSource::audioSourceProvider):
730         (WebCore::CoreAudioCaptureSource::preferredSampleRate): Deleted.
731         (WebCore::CoreAudioCaptureSource::preferredIOBufferSize): Deleted.
732         (WebCore::CoreAudioCaptureSource::configureMicrophoneProc): Deleted.
733         (WebCore::CoreAudioCaptureSource::configureSpeakerProc): Deleted.
734         (WebCore::CoreAudioCaptureSource::checkTimestamps): Deleted.
735         (WebCore::CoreAudioCaptureSource::provideSpeakerData): Deleted.
736         (WebCore::CoreAudioCaptureSource::speakerCallback): Deleted.
737         (WebCore::CoreAudioCaptureSource::processMicrophoneSamples): Deleted.
738         (WebCore::CoreAudioCaptureSource::microphoneCallback): Deleted.
739         (WebCore::CoreAudioCaptureSource::cleanupAudioUnits): Deleted.
740         (WebCore::CoreAudioCaptureSource::defaultInputDevice): Deleted.
741         (WebCore::CoreAudioCaptureSource::setupAudioUnits): Deleted.
742         (WebCore::CoreAudioCaptureSource::suspend): Deleted.
743         (WebCore::CoreAudioCaptureSource::resume): Deleted.
744         * platform/mediastream/mac/CoreAudioCaptureSource.h:
745         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
746         (WebCore::RealtimeMediaSourceCenterMac::setUseAVFoundationAudioCapture):
747
748 2017-05-03  Jer Noble  <jer.noble@apple.com>
749
750         getUserMedia() fails because devices list is empty / inactive
751         https://bugs.webkit.org/show_bug.cgi?id=171626
752
753         Reviewed by Eric Carlson.
754
755         When creating a AVAudioSessionCaptureDevice, set the device's enabled state to true if the port description
756         has any items in its dataSources property (which is the best analogue to "isActive" we have in AVAudioSession).
757
758         Also, when creating the generic list of CaptureDevices, use the copy constructor to ensure the enabled state
759         gets copied to the new generic device.
760
761         * platform/mediastream/ios/AVAudioSessionCaptureDevice.mm:
762         (WebCore::AVAudioSessionCaptureDevice::create):
763         * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm:
764         (WebCore::AVAudioSessionCaptureDeviceManager::refreshAudioCaptureDevices):
765
766 2017-05-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
767
768         Implement the imageready event to reliably test the async image decoding
769         https://bugs.webkit.org/show_bug.cgi?id=171016
770
771         Reviewed by Simon Fraser.
772
773         The event will be fired for each client of the image. Firing the event
774         will happen after finishing the decoding and repainting the client.
775
776         Existing tests will be modified in a separate patch to use this event.
777
778         * dom/Element.cpp:
779         (WebCore::Element::dispatchWebKitImageReadyEventForTesting):
780         * dom/Element.h:
781         * page/Settings.in:
782         * rendering/RenderElement.cpp:
783         (WebCore::RenderElement::imageFrameAvailable):
784
785 2017-05-03  Tim Horton  <timothy_horton@apple.com>
786
787         Maintain interaction information URL as a URL, not a string
788         https://bugs.webkit.org/show_bug.cgi?id=171623
789
790         Reviewed by Simon Fraser.
791
792         No new tests, not a behavior change.
793
794         * platform/URL.h:
795
796 2017-05-03  Yoav Weiss  <yoav@yoav.ws>
797
798         Link preload HTMLPreloadScanner support
799         https://bugs.webkit.org/show_bug.cgi?id=170747
800
801         Reviewed by Youenn Fablet.
802
803         Test: http/tests/preload/preloadscanner_download_resources.html
804
805         * html/parser/HTMLPreloadScanner.cpp:
806         (WebCore::TokenPreloadScanner::StartTagScanner::StartTagScanner): Initialize link preload flag.
807         (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): Create a request only if the type is known (so ignore
808         preloads with unknown type).
809         (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): Add handling for link preload and the `as` attribute.
810         (WebCore::TokenPreloadScanner::StartTagScanner::relAttributeIsStyleSheet): Get LinkRelAttribute as input.
811         (WebCore::TokenPreloadScanner::StartTagScanner::resourceType): Return an std::optional, in case the preload type is unknown.
812         (WebCore::TokenPreloadScanner::StartTagScanner::shouldPreload): Return true for the link preload case.
813         * loader/cache/CachedResourceLoader.cpp:
814         (WebCore::CachedResourceLoader::preload): Return the resource rather than a nullptr if it's already in m_preloads.
815
816 2017-05-03  Michael Catanzaro  <mcatanzaro@igalia.com>
817
818         YouTube user agent quirk breaks new YouTube
819         https://bugs.webkit.org/show_bug.cgi?id=171603
820
821         Reviewed by Carlos Garcia Campos.
822
823         Our user agent quirk to make YouTube 360 work breaks the new YouTube UI, causing it to
824         attempt to use the obsolete custom elements v0 API. WebKit only supports the v1 API. We
825         have to remove this quirk.
826
827         Note this does not affect Safari as Apple ports don't use our user agent quirks.
828
829         * platform/UserAgentQuirks.cpp:
830         (WebCore::urlRequiresChromeBrowser):
831
832 2017-05-03  Joseph Pecoraro  <pecoraro@apple.com>
833
834         Web Inspector: 404 Image Load does not appear as a failure in Web Inspector
835         https://bugs.webkit.org/show_bug.cgi?id=171587
836         <rdar://problem/13222846>
837
838         Reviewed by Matt Baker.
839
840         * inspector/InspectorPageAgent.h:
841         * inspector/InspectorPageAgent.cpp:
842         (WebCore::InspectorPageAgent::cachedResourceContent):
843         (WebCore::prepareCachedResourceBuffer): Deleted.
844         Inline the function to make this less confusing.
845
846         (WebCore::InspectorPageAgent::buildObjectForFrameTree):
847         Treat a DecodeError as a failure.
848
849 2017-05-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
850
851         Async image decoding should be disabled for snapshots, printing and preview
852         https://bugs.webkit.org/show_bug.cgi?id=171467
853  
854         Reviewed by Simon Fraser.
855  
856         Asynchronous image decoding should only be used for window display where
857         RenderElements can be repainted and painted. For cases where there is only
858         one chance to draw the image, synchronous decoding should be used. 
859
860         * rendering/RenderBoxModelObject.cpp:
861         (WebCore::RenderBoxModelObject::paintFillLayerExtended):
862         * rendering/RenderImage.cpp:
863         (WebCore::RenderImage::paintIntoRect):
864
865 2017-05-03  Nan Wang  <n_wang@apple.com>
866
867         AX: VO skips cells after cell with aria-colspan
868         https://bugs.webkit.org/show_bug.cgi?id=171579
869
870         Reviewed by Chris Fleizach.
871
872         We should consider the previous cells' column span value when
873         calculating the column index.
874
875         Test: accessibility/mac/aria-grid-column-span.html
876
877         * accessibility/AccessibilityARIAGridCell.cpp:
878         (WebCore::AccessibilityARIAGridCell::columnIndexRange):
879
880 2017-05-03  Jiewen Tan  <jiewen_tan@apple.com>
881
882         ASSERTION FAILED: m_scriptExecutionContext->isContextThread() seen with LayoutTest crypto/workers/crypto-random-values-limits-worker.html
883         https://bugs.webkit.org/show_bug.cgi?id=171462
884         <rdar://problem/31906859>
885
886         Reviewed by Brent Fulgham.
887
888         Covered by existing tests.
889
890         * workers/WorkerGlobalScope.cpp:
891         (WebCore::WorkerGlobalScope::~WorkerGlobalScope):
892         Clear Crypto early in destruction since its ContextDestructionObserver
893         destruction makes checks about the WorkerThread.
894
895 2017-05-03  Zalan Bujtas  <zalan@apple.com>
896
897         RenderSearchField should not use isTextField() in SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT
898         https://bugs.webkit.org/show_bug.cgi?id=171608
899
900         Reviewed by Simon Fraser.
901
902         isTextField() is true for any generic single line text control.
903
904         * rendering/RenderObject.h:
905         (WebCore::RenderObject::isSearchField):
906         * rendering/RenderSearchField.h:
907
908 2017-05-03  Frederic Wang  <fwang@igalia.com>
909
910         Remove ScrollingCoordinator::supportsFixedPositionLayers()
911         https://bugs.webkit.org/show_bug.cgi?id=171557
912
913         Reviewed by Simon Fraser.
914
915         No new tests, behavior is not changed.
916
917         * page/FrameView.cpp:
918         (WebCore::FrameView::shouldUpdateCompositingLayersAfterScrolling):
919         * page/scrolling/AsyncScrollingCoordinator.cpp:
920         (WebCore::AsyncScrollingCoordinator::updateViewportConstrainedNode):
921         * page/scrolling/AsyncScrollingCoordinator.h:
922         * page/scrolling/ScrollingCoordinator.cpp:
923         (WebCore::ScrollingCoordinator::synchronousScrollingReasons):
924         * page/scrolling/ScrollingCoordinator.h:
925         (WebCore::ScrollingCoordinator::supportsFixedPositionLayers): Deleted.
926         * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp:
927         (WebCore::ScrollingCoordinatorCoordinatedGraphics::updateViewportConstrainedNode):
928         * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h:
929         (): Deleted.
930         * rendering/RenderLayerCompositor.cpp:
931         (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer):
932
933 2017-05-03  Chris Dumez  <cdumez@apple.com>
934
935         Use PassRefPtr less in CompositeEditCommand
936         https://bugs.webkit.org/show_bug.cgi?id=171590
937
938         Reviewed by Sam Weinig.
939
940         Use PassRefPtr less in CompositeEditCommand.
941
942         * CMakeLists.txt:
943         * WebCore.xcodeproj/project.pbxproj:
944         * editing/ApplyStyleCommand.cpp:
945         (WebCore::hasNoAttributeOrOnlyStyleAttribute):
946         (WebCore::isStyleSpanOrSpanWithOnlyStyleAttribute):
947         (WebCore::isSpanWithoutAttributesOrUnstyledStyleSpan):
948         (WebCore::isEmptyFontTag):
949         (WebCore::ApplyStyleCommand::doApply):
950         (WebCore::ApplyStyleCommand::applyBlockStyle):
951         (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
952         (WebCore::dummySpanAncestorForNode):
953         (WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans):
954         (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock):
955         (WebCore::ApplyStyleCommand::applyInlineStyle):
956         (WebCore::ApplyStyleCommand::fixRangeAndApplyInlineStyle):
957         (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
958         (WebCore::ApplyStyleCommand::shouldApplyInlineStyleToRun):
959         (WebCore::ApplyStyleCommand::removeConflictingInlineStyleFromRun):
960         (WebCore::ApplyStyleCommand::removeInlineStyleFromElement):
961         (WebCore::ApplyStyleCommand::replaceWithSpanOrRemoveIfWithoutAttributes):
962         (WebCore::ApplyStyleCommand::removeImplicitlyStyledElement):
963         (WebCore::ApplyStyleCommand::removeCSSStyle):
964         (WebCore::ApplyStyleCommand::highestAncestorWithConflictingInlineStyle):
965         (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
966         (WebCore::ApplyStyleCommand::removeInlineStyle):
967         (WebCore::ApplyStyleCommand::shouldSplitTextElement):
968         (WebCore::ApplyStyleCommand::mergeStartWithPreviousIfIdentical):
969         (WebCore::ApplyStyleCommand::mergeEndWithNextIfIdentical):
970         (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
971         (WebCore::ApplyStyleCommand::addBlockStyle):
972         (WebCore::ApplyStyleCommand::joinChildTextNodes):
973         * editing/ApplyStyleCommand.h:
974         (WebCore::ApplyStyleCommand::shouldRemoveInlineStyleFromElement):
975         * editing/CompositeEditCommand.cpp:
976         (WebCore::CompositeEditCommand::removeChildrenInRange):
977         (WebCore::CompositeEditCommand::mergeIdenticalElements):
978         (WebCore::CompositeEditCommand::insertTextIntoNode):
979         (WebCore::CompositeEditCommand::deleteTextFromNode):
980         (WebCore::CompositeEditCommand::replaceTextInNode):
981         (WebCore::CompositeEditCommand::replaceSelectedTextInNode):
982         (WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):
983         (WebCore::CompositeEditCommand::removeNodeAttribute):
984         (WebCore::CompositeEditCommand::rebalanceWhitespaceAt):
985         (WebCore::CompositeEditCommand::rebalanceWhitespaceOnTextSubstring):
986         (WebCore::CompositeEditCommand::prepareWhitespaceAtPositionForSplit):
987         (WebCore::CompositeEditCommand::deleteInsignificantText):
988         (WebCore::CompositeEditCommand::removePlaceholderAt):
989         (WebCore::CompositeEditCommand::cleanupAfterDeletion):
990         (WebCore::CompositeEditCommand::moveParagraphs):
991         * editing/CompositeEditCommand.h:
992         * editing/DeleteFromTextNodeCommand.cpp:
993         (WebCore::DeleteFromTextNodeCommand::DeleteFromTextNodeCommand):
994         (WebCore::DeleteFromTextNodeCommand::doApply):
995         (WebCore::DeleteFromTextNodeCommand::doUnapply):
996         (WebCore::DeleteFromTextNodeCommand::getNodesInCommand):
997         * editing/DeleteFromTextNodeCommand.h:
998         (WebCore::DeleteFromTextNodeCommand::create):
999         * editing/DeleteSelectionCommand.cpp:
1000         (WebCore::DeleteSelectionCommand::deleteTextFromNode):
1001         (WebCore::DeleteSelectionCommand::handleGeneralDelete):
1002         (WebCore::DeleteSelectionCommand::fixupWhitespace):
1003         * editing/DeleteSelectionCommand.h:
1004         * editing/EditingAllInOne.cpp:
1005         * editing/EditingStyle.cpp:
1006         (WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
1007         (WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl):
1008         (WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement):
1009         (WebCore::EditingStyle::wrappingStyleForSerialization):
1010         (WebCore::styleFromMatchedRulesForElement):
1011         (WebCore::EditingStyle::mergeStyleFromRules):
1012         (WebCore::EditingStyle::mergeStyleFromRulesForSerialization):
1013         (WebCore::EditingStyle::removeStyleFromRulesAndContext):
1014         (WebCore::EditingStyle::removePropertiesInElementDefaultStyle):
1015         * editing/EditingStyle.h:
1016         * editing/IndentOutdentCommand.cpp:
1017         (WebCore::IndentOutdentCommand::tryIndentingAsListItem):
1018         * editing/InsertIntoTextNodeCommand.cpp:
1019         (WebCore::InsertIntoTextNodeCommand::InsertIntoTextNodeCommand):
1020         (WebCore::InsertIntoTextNodeCommand::getNodesInCommand):
1021         * editing/InsertIntoTextNodeCommand.h:
1022         (WebCore::InsertIntoTextNodeCommand::create):
1023         * editing/InsertLineBreakCommand.cpp:
1024         (WebCore::InsertLineBreakCommand::doApply):
1025         * editing/InsertListCommand.cpp:
1026         (WebCore::InsertListCommand::mergeWithNeighboringLists):
1027         (WebCore::InsertListCommand::listifyParagraph):
1028         * editing/InsertParagraphSeparatorCommand.cpp:
1029         (WebCore::InsertParagraphSeparatorCommand::doApply):
1030         * editing/InsertTextCommand.cpp:
1031         (WebCore::InsertTextCommand::performOverwrite):
1032         (WebCore::InsertTextCommand::doApply):
1033         (WebCore::InsertTextCommand::insertTab):
1034         * editing/MergeIdenticalElementsCommand.cpp:
1035         (WebCore::MergeIdenticalElementsCommand::MergeIdenticalElementsCommand):
1036         (WebCore::MergeIdenticalElementsCommand::doApply):
1037         (WebCore::MergeIdenticalElementsCommand::doUnapply):
1038         (WebCore::MergeIdenticalElementsCommand::getNodesInCommand):
1039         * editing/MergeIdenticalElementsCommand.h:
1040         (WebCore::MergeIdenticalElementsCommand::create):
1041         * editing/RemoveCSSPropertyCommand.cpp: Removed.
1042         * editing/RemoveCSSPropertyCommand.h: Removed.
1043         * editing/ReplaceSelectionCommand.cpp:
1044         (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
1045         (WebCore::ReplaceSelectionCommand::doApply):
1046         (WebCore::ReplaceSelectionCommand::addSpacesForSmartReplace):
1047         (WebCore::ReplaceSelectionCommand::mergeTextNodesAroundPosition):
1048         * editing/markup.cpp:
1049         (WebCore::StyledMarkupAccumulator::appendElement):
1050         (WebCore::styleFromMatchedRulesAndInlineDecl):
1051         (WebCore::createMarkupInternal):
1052
1053 2017-05-03  Joanmarie Diggs  <jdiggs@igalia.com>
1054
1055         AX: Treat cells with ARIA table cell properties as cells
1056         https://bugs.webkit.org/show_bug.cgi?id=171178
1057
1058         Reviewed by Chris Fleizach.
1059
1060         Add the following checks to heuristics in AccessibilityTable::isDataTable():
1061         1. If the author has provided a valid aria-rowcount or aria-colcount value on
1062            the table element, expose it as a data table.
1063         2. If the author has provided a valid aria-colindex or aria-rowindex on the
1064            cell element, expose it as a data table.
1065         3. If the author has provided a valid aria-rowindex on the row element, expose
1066            it as a data table.
1067         4. If the author has provided a value for aria-colspan or aria-rowspan on a cell,
1068            expose it as a data table (even though we are supposed to ignore the value for
1069            the purpose of exposing the span via platform accessibility APIs)
1070
1071         Remove the heuristic that a table with only one cell is "not a good AXTable candidate."
1072         It prevents us from ever doing the above checks.
1073
1074         Test: accessibility/minimal-table-with-aria-is-data-table.html
1075
1076         * accessibility/AccessibilityTable.cpp:
1077         (WebCore::AccessibilityTable::isDataTable):
1078
1079 2017-05-03  Carlos Garcia Campos  <cgarcia@igalia.com>
1080
1081         [Cairo] Handle extended colors in gradients
1082         https://bugs.webkit.org/show_bug.cgi?id=171596
1083
1084         Reviewed by Michael Catanzaro.
1085
1086         Check if every gradient color step is an extended color and use asExtended() instead of getRGBA() in such case.
1087
1088         Fixes: css3/color/gradients.html
1089
1090         * platform/graphics/cairo/GradientCairo.cpp:
1091         (WebCore::Gradient::platformGradient):
1092
1093 2017-05-03  Daniel Bates  <dabates@apple.com>
1094
1095         Abandon the current load once the provisional loader detaches from the frame
1096         https://bugs.webkit.org/show_bug.cgi?id=171577
1097         <rdar://problem/31581227>
1098
1099         Reviewed by Brent Fulgham and Brady Eidson.
1100
1101         We detach all child frames as part of setting our document loader to the provisional
1102         document loader when committing a load for a frame. Detaching child frames invokes
1103         the unload event handler on the child frames that can run arbitrary JavaScript script.
1104         Among other things, such script can initiate a new load in the frame whose current
1105         load is being committed. We should stop processing the current load as soon as we
1106         detect that updating our document loader has started a new provisional load.
1107
1108         Test: fast/loader/inner-iframe-loads-data-url-into-parent-on-unload-crash.html
1109
1110         * loader/FrameLoader.cpp:
1111         (WebCore::FrameLoader::transitionToCommitted):
1112
1113 2017-05-03  Daniel Bates  <dabates@apple.com>
1114
1115         Cleanup: Remove out-of-date comment and null check from DocumentLoader::detachFromFrame()
1116         https://bugs.webkit.org/show_bug.cgi?id=171604
1117
1118         Reviewed by Brady Eidson.
1119
1120         We no longer want to passively allow DocumentLoader::detachFromFrame() to be called twice.
1121         It does not make sense to be called twice and should never be called twice. A release assert
1122         in DocumentLoader::cancelPolicyCheckIfNeeded() (added in r187558) called by DocumentLoader::detachFromFrame()
1123         enforces this invariant. Therefore we can remove the null check of DocumentLoader::m_frame
1124         and the comment that explains the purpose of this null check from DocumentLoader::detachFromFrame().
1125
1126         * loader/DocumentLoader.cpp:
1127         (WebCore::DocumentLoader::detachFromFrame):
1128
1129 2017-05-03  Ryan Haddad  <ryanhaddad@apple.com>
1130
1131         Unreviewed attempt to fix the Windows build after r216117.
1132         https://bugs.webkit.org/show_bug.cgi?id=171601
1133
1134         * css/CSSAllInOne.cpp:
1135
1136 2017-05-03  Antti Koivisto  <antti@apple.com>
1137
1138         Rename StyleInvalidationAnalysis to Style::Invalidator
1139         https://bugs.webkit.org/show_bug.cgi?id=171601
1140
1141         Reviewed by Žan Doberšek.
1142
1143         Also move it to the 'style' directory.
1144
1145         * CMakeLists.txt:
1146         * WebCore.xcodeproj/project.pbxproj:
1147         * css/StyleInvalidationAnalysis.cpp: Removed.
1148         * css/StyleInvalidationAnalysis.h: Removed.
1149         * dom/ExtensionStyleSheets.cpp:
1150         * style/AttributeChangeInvalidation.cpp:
1151         (WebCore::Style::AttributeChangeInvalidation::invalidateDescendants):
1152         * style/ClassChangeInvalidation.cpp:
1153         (WebCore::Style::ClassChangeInvalidation::invalidateDescendantStyle):
1154         * style/StyleInvalidator.cpp: Copied from Source/WebCore/css/StyleInvalidationAnalysis.cpp.
1155         (WebCore::Style::Invalidator::Invalidator):
1156         (WebCore::Style::Invalidator::invalidateIfNeeded):
1157         (WebCore::Style::Invalidator::invalidateStyleForTree):
1158         (WebCore::Style::Invalidator::invalidateStyle):
1159         (WebCore::shouldDirtyAllStyle): Deleted.
1160         (WebCore::StyleInvalidationAnalysis::StyleInvalidationAnalysis): Deleted.
1161         (WebCore::StyleInvalidationAnalysis::invalidateIfNeeded): Deleted.
1162         (WebCore::StyleInvalidationAnalysis::invalidateStyleForTree): Deleted.
1163         (WebCore::StyleInvalidationAnalysis::invalidateStyle): Deleted.
1164         * style/StyleInvalidator.h: Copied from Source/WebCore/css/StyleInvalidationAnalysis.h.
1165         (WebCore::StyleInvalidationAnalysis::dirtiesAllStyle): Deleted.
1166         (WebCore::StyleInvalidationAnalysis::hasShadowPseudoElementRulesInAuthorSheet): Deleted.
1167         * style/StyleScope.cpp:
1168         (WebCore::Style::Scope::resolver):
1169         (WebCore::Style::Scope::analyzeStyleSheetChange):
1170
1171 2017-05-02  Andrew Gold  <agold@apple.com>
1172
1173         Typo in AVAudioSessionCaptureDeviceManager.mm
1174         https://bugs.webkit.org/show_bug.cgi?id=171572
1175
1176         Reviewed by Jer Noble.
1177
1178         We attempt to call +[AVAudioSession sharedSession], but the actual method is 
1179         called +[AVAudioSession sharedInstance].
1180
1181         * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm:
1182         (WebCore::AVAudioSessionCaptureDeviceManager::refreshAudioCaptureDevices):
1183
1184 2017-05-02  Simon Fraser  <simon.fraser@apple.com>
1185
1186         Improve scrolling tree logging
1187         https://bugs.webkit.org/show_bug.cgi?id=171574
1188
1189         Reviewed by Tim Horton.
1190
1191         Make a call to showScrollingStateTree() print debugging-related information like node and layer IDs.
1192         Required fixing scrolling state tree nodes to respect ScrollingStateTreeAsTextBehavior, and fixing
1193         fixed and sticky nodes to call super.
1194
1195         Also enhance compositing logging to show layer IDs, and to log for layer scrolling tree registration.
1196
1197         * page/scrolling/AsyncScrollingCoordinator.cpp:
1198         (WebCore::AsyncScrollingCoordinator::scrollingStateTreeAsText):
1199         * page/scrolling/AsyncScrollingCoordinator.h:
1200         * page/scrolling/ScrollingCoordinator.cpp:
1201         (WebCore::ScrollingCoordinator::scrollingStateTreeAsText):
1202         * page/scrolling/ScrollingCoordinator.h:
1203         * page/scrolling/ScrollingStateFixedNode.cpp:
1204         (WebCore::ScrollingStateFixedNode::dumpProperties):
1205         * page/scrolling/ScrollingStateNode.cpp:
1206         (WebCore::ScrollingStateNode::dumpProperties):
1207         (WebCore::ScrollingStateNode::scrollingStateTreeAsText):
1208         * page/scrolling/ScrollingStateNode.h:
1209         * page/scrolling/ScrollingStateScrollingNode.cpp:
1210         (WebCore::ScrollingStateScrollingNode::dumpProperties):
1211         * page/scrolling/ScrollingStateStickyNode.cpp:
1212         (WebCore::ScrollingStateStickyNode::dumpProperties):
1213         * page/scrolling/ScrollingStateTree.cpp:
1214         (showScrollingStateTree):
1215         * page/scrolling/mac/ScrollingCoordinatorMac.mm:
1216         (WebCore::ScrollingCoordinatorMac::commitTreeState):
1217         * rendering/RenderLayerBacking.cpp:
1218         (WebCore::RenderLayerBacking::detachFromScrollingCoordinator):
1219         * rendering/RenderLayerCompositor.cpp:
1220         (WebCore::RenderLayerCompositor::logLayerInfo):
1221         (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer):
1222
1223 2017-05-02  Daniel Bates  <dabates@apple.com>
1224
1225         Using StringView.split() instead of String.split() in some places
1226         https://bugs.webkit.org/show_bug.cgi?id=170925
1227
1228         Reviewed by Darin Adler and Sam Weinig.
1229
1230         Replace some uses of String.split() with StringView.split() (added in r211087) as the latter
1231         avoids the need to allocate an intermediary Vector of substrings. Instead StringView.split()
1232         returns an iterator for traversing the substrings.
1233
1234         No functionality changed. So, no new tests.
1235
1236         * accessibility/AccessibilityObject.cpp: Convert some typedefs to modern C++ using declarations.
1237         (WebCore::AccessibilityObject::ariaRoleToWebCoreRole): Modified code to use StringView.split().
1238         (WebCore::AccessibilityObject::elementsFromAttribute): Ditto.
1239         * dom/TreeScope.cpp:
1240         (WebCore::TreeScope::getElementById): Added.
1241         * dom/TreeScope.h:
1242         * html/LinkRelAttribute.cpp:
1243         (WebCore::LinkRelAttribute::LinkRelAttribute): Modified code to use StringView.split().
1244         * html/parser/XSSAuditor.cpp:
1245         (WebCore::semicolonSeparatedValueContainsJavaScriptURL): Ditto.
1246         * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
1247         (WebCore::CDMPrivateMediaSourceAVFObjC::createSession): Ditto.
1248         * platform/network/CacheValidation.cpp:
1249         (WebCore::collectVaryingRequestHeaders): Simplify code by using the String.split(UChar, Vector<String>&) overload.
1250         * svg/SVGAnimationElement.cpp:
1251         (WebCore::parseKeyTimes): Modified code to use StringView.split().
1252         * svg/SVGToOTFFontConversion.cpp:
1253         (WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter): Ditto.
1254         * testing/Internals.cpp:
1255         (WebCore::Internals::setMediaSessionRestrictions): Ditto.
1256         (WebCore::Internals::setMediaElementRestrictions): Ditto.
1257         (WebCore::Internals::setAudioContextRestrictions): Ditto.
1258         (WebCore::Internals::setPageMuted): Ditto.
1259         * testing/Internals.h:
1260
1261 2017-05-02  Gwang Yoon Hwang  <yoon@igalia.com>
1262
1263         [GTK] Drop coordinated surfaces from the compositing thread as soon as possible
1264         https://bugs.webkit.org/show_bug.cgi?id=171544
1265
1266         Reviewed by Žan Doberšek.
1267
1268         * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
1269         Remove atlasesToRemove from the GraphicsState. It is not a commit
1270         state anymore.
1271
1272 2017-05-02  Gwang Yoon Hwang  <yoon@igalia.com>
1273
1274         [GTK] Recycle textures while handling tiles
1275         https://bugs.webkit.org/show_bug.cgi?id=171541
1276
1277         Reviewed by Žan Doberšek.
1278
1279         * platform/graphics/texmap/TextureMapperTile.h:
1280         Modified m_texture as a protected member to avoid unnessary
1281         refcountings from the CoordinatedBackingStore.
1282         * platform/graphics/texmap/coordinated/CoordinatedSurface.h:
1283         Use reference instead of RefPtr to pass BitmapTexture
1284
1285         No new tests since there should be no change in behavior.
1286
1287 2017-05-02  Zalan Bujtas  <zalan@apple.com>
1288
1289         Defer AX cache update when text content changes until after layout is finished.
1290         https://bugs.webkit.org/show_bug.cgi?id=171429
1291         <rdar://problem/31885984>
1292
1293         Reviewed by Simon Fraser.
1294
1295         When the content of the RenderText changes (even as the result of a text-transform change)
1296         instead of updating the AX cache eagerly (and trigger layout on a half-backed render tree)
1297         we should just defer it until after the subsequent layout is done. 
1298
1299         Test: accessibility/crash-while-adding-text-child-with-transform.html
1300
1301         * accessibility/AXObjectCache.cpp:
1302         (WebCore::AXObjectCache::remove):
1303         (WebCore::AXObjectCache::performDeferredCacheUpdate):
1304         (WebCore::AXObjectCache::recomputeDeferredIsIgnored):
1305         (WebCore::AXObjectCache::deferTextChanged):
1306         (WebCore::AXObjectCache::performDeferredIsIgnoredChange): Deleted.
1307         * accessibility/AXObjectCache.h:
1308         (WebCore::AXObjectCache::deferTextChanged):
1309         (WebCore::AXObjectCache::performDeferredCacheUpdate):
1310         (WebCore::AXObjectCache::performDeferredIsIgnoredChange): Deleted.
1311         * page/FrameView.cpp:
1312         (WebCore::FrameView::performPostLayoutTasks):
1313         * rendering/RenderText.cpp:
1314         (WebCore::RenderText::setText):
1315
1316 2017-05-02  Wenson Hsieh  <wenson_hsieh@apple.com>
1317
1318         Remove an extraneous call to dispatch_group_async in WebItemProviderPasteboard.mm
1319         https://bugs.webkit.org/show_bug.cgi?id=171561
1320
1321         Reviewed by Tim Horton.
1322
1323         In -[WebItemProviderPasteboard doAfterLoadingProvidedContentIntoFileURLs:], the lifetime of the dispatch group
1324         `fileLoadingGroup` is already guarded by dispatch_group_enter/leave calls when beginning and concluding an
1325         item provider load, respectively. As such, the call to dispatch_group_async serves no purpose and should be removed.
1326
1327         No new tests, since there is no change in behavior.
1328
1329         * platform/ios/WebItemProviderPasteboard.mm:
1330         (-[WebItemProviderPasteboard doAfterLoadingProvidedContentIntoFileURLs:]):
1331
1332 2017-05-02  Youenn Fablet  <youenn@apple.com>
1333
1334         [LibWebRTC] Set explicitly logging level in debug mode
1335         https://bugs.webkit.org/show_bug.cgi?id=171562
1336
1337         Reviewed by Eric Carlson.
1338
1339         No change of behavior.
1340
1341         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
1342         (WebCore::initializePeerConnectionFactoryAndThreads): Setting explictly LibWebRTC logging to Info level for
1343         debug builds if WebRTC channel is on.
1344
1345 2017-05-02  Joanmarie Diggs  <jdiggs@igalia.com>
1346
1347         AX: Update implementation of aria-orientation
1348         https://bugs.webkit.org/show_bug.cgi?id=171166
1349
1350         Reviewed by Chris Fleizach.
1351
1352         Update AccessibilityRenderObject::orientation() to be consistent with what is
1353         in the ARIA 1.1 spec. Also add an isTreeGrid() convenience method to be consistent
1354         with what we do for other roles.
1355
1356         Test: accessibility/aria-orientation.html
1357
1358         * accessibility/AccessibilityARIAGridRow.cpp:
1359         (WebCore::AccessibilityARIAGridRow::isARIATreeGridRow):
1360         * accessibility/AccessibilityObject.h:
1361         (WebCore::AccessibilityObject::isTreeGrid):
1362         * accessibility/AccessibilityRenderObject.cpp:
1363         (WebCore::AccessibilityRenderObject::orientation):
1364
1365 2017-05-02  Myles C. Maxfield  <mmaxfield@apple.com>
1366
1367         REGRESSION (r211382): Partial right-to-left text runs are painted at an offset (breaks Find indicators, Look Up, and custom ::selection style)
1368         https://bugs.webkit.org/show_bug.cgi?id=169517
1369         <rdar://problem/30652443>
1370
1371         Reviewed by Dean Jackson.
1372
1373         FontCascade::getGlyphsAndAdvancesForComplexText() is tasked with calculating paint advances for a
1374         subrange of RTL text. It does this by creating a ComplexTextController, telling it to iterate to
1375         the beginning of the subrange (outputting to a GlyphBuffer), then telling it to iterate to the end
1376         of the subrange (outputting to another GlyphBuffer). Because the text is RTL, the sum of the
1377         advances gathered so far is the distance from the right edge of the text to the left edge of the
1378         subrange (because we advance in logical order). Therefore, the x-coordinate we are at now is the
1379         total width minus the sum of both of the GlyphBuffers. For some reason, when I wrote this code I
1380         forgot to add in the contribution from the first GlyphBuffer. Unfortunately, this particular
1381         codepath is rarely hit in practice and completely untested, which made me miss it when I wrote it.
1382
1383         Test: fast/text/complex-text-selection.html
1384
1385         * platform/graphics/cocoa/FontCascadeCocoa.mm:
1386         (WebCore::FontCascade::getGlyphsAndAdvancesForComplexText):
1387
1388 2017-05-02  Chris Dumez  <cdumez@apple.com>
1389
1390         [macOS] Flaky Crash under EventTarget::fireEventListeners on imported/blink/paint/deprecatedpaintlayer/non-self-painting-layer-overrides-visibility.html
1391         https://bugs.webkit.org/show_bug.cgi?id=171406
1392         <rdar://problem/30945281>
1393
1394         Reviewed by Eric Carlson.
1395
1396         I was unfortunately unable to reproduce the flaky crash locally. However, the crash trace
1397         indicates that one of the EventTarget::scriptExecutionContext() overrides is returning a
1398         stale ScriptExecutionContext pointer. Since a GenericEventQueue is involved, the EventTarget
1399         is likely a media-related object. I therefore audited media classes that override
1400         EventTarget::scriptExecutionContext() and found several that look unsafe. I am fixing those
1401         by having them override ContextDestructionObserver, instead of having a raw
1402         ScriptExecutionContext pointer member. This makes sure the pointer gets nulled out whenever
1403         the scriptexecutioncontext gets destroyed, ensuring that those classes's
1404         EventTarget::scriptExecutionContext() overrides can never return a stale pointer.
1405
1406         * Modules/mediasource/SourceBufferList.cpp:
1407         (WebCore::SourceBufferList::SourceBufferList):
1408         * Modules/mediasource/SourceBufferList.h:
1409         * html/track/TextTrack.cpp:
1410         (WebCore::TextTrack::TextTrack):
1411         * html/track/TextTrack.h:
1412         * html/track/TrackListBase.cpp:
1413         (TrackListBase::TrackListBase):
1414         * html/track/TrackListBase.h:
1415
1416 2017-05-02  Antti Koivisto  <antti@apple.com>
1417
1418         Document style resolvers should share user rulesets
1419         https://bugs.webkit.org/show_bug.cgi?id=171549
1420
1421         Reviewed by Andreas Kling.
1422
1423         Large user stylesheets (like those used by ad blockers) can end up using lots of memory if
1424         a document uses large number of shadow trees. User style is inherently per-document and
1425         the resulting rulesets can be shared between the document and the shadow trees.
1426
1427         * css/DocumentRuleSets.cpp:
1428         (WebCore::DocumentRuleSets::DocumentRuleSets):
1429         (WebCore::DocumentRuleSets::userStyle):
1430
1431             Return per-document user style for shadow trees.
1432
1433         (WebCore::DocumentRuleSets::collectFeatures):
1434         * css/DocumentRuleSets.h:
1435         (WebCore::DocumentRuleSets::setUsesSharedUserStyle):
1436         (WebCore::DocumentRuleSets::userStyle): Deleted.
1437         * css/StyleResolver.cpp:
1438         (WebCore::StyleResolver::StyleResolver):
1439         (WebCore::StyleResolver::initializeUserStyle):
1440
1441             Separate user style initialization from construction.
1442
1443         * css/StyleResolver.h:
1444         * style/StyleScope.cpp:
1445         (WebCore::Style::Scope::resolver):
1446
1447             Don't initialize user style for user agents shadow trees.
1448
1449 2017-05-02  Myles C. Maxfield  <mmaxfield@apple.com>
1450
1451         Font Loading API specifies font is loaded but sizing of font after load reports inconsistent values
1452         https://bugs.webkit.org/show_bug.cgi?id=168533
1453
1454         Reviewed by Zalan Bujtas.
1455
1456         Previously, we were marking all local() fonts as immediately successful,
1457         regardless of whether or not they were present on the system. Instead, we
1458         should use the load() function to make this determination and mark the font
1459         as failed if it doesn't exist. (This is, after all, the whole point of the
1460         load() function). This brings us in-line with Firefox's and Chrome's
1461         behavior.
1462
1463         Test: fast/text/font-loading-local.html
1464
1465         * css/CSSFontFace.cpp:
1466         (WebCore::CSSFontFace::pump): Remote loading requires the FontSelector,
1467         but it isn't available for local fonts. Now that load() is called for both
1468         local and remote fonts, the ASSERT() should be lowered into the load()
1469         function and scoped to just the case where we have a remote font.
1470         (WebCore::CSSFontFace::font): Ditto.
1471         * css/CSSFontFaceSource.cpp:
1472         (WebCore::CSSFontFaceSource::CSSFontFaceSource): Don't immediatley set
1473         the success/failure state for local fonts.
1474         (WebCore::CSSFontFaceSource::load): Move loading logic from font() to
1475         load(). None of this code is new; it just is moved.
1476         (WebCore::CSSFontFaceSource::font): Delete code moved to load().
1477         * css/CSSFontFaceSource.h:
1478         * css/FontFace.cpp:
1479         (WebCore::FontFace::create):
1480
1481 2017-05-02  Youenn Fablet  <youenn@apple.com>
1482
1483         Allow media stream based videos with sound to autoplay if the page is already playing sound
1484         https://bugs.webkit.org/show_bug.cgi?id=171447
1485
1486         Reviewed by Eric Carlson.
1487
1488         Test: http/tests/media/autoplay-if-audio-is-playing.html for ensuring non-mediastream based video will not autoplay.
1489         Manual testing for the autoplay of media stream based videos since such a test should happen without using getUserMedia.
1490
1491         * html/MediaElementSession.cpp:
1492         (WebCore::MediaElementSession::playbackPermitted):
1493
1494 2017-05-02  Chris Dumez  <cdumez@apple.com>
1495
1496         Use PassRefPtr less in editing code
1497         https://bugs.webkit.org/show_bug.cgi?id=171534
1498
1499         Reviewed by Geoffrey Garen.
1500
1501         Use PassRefPtr less in editing code.
1502
1503         * editing/AppendNodeCommand.cpp:
1504         (WebCore::AppendNodeCommand::AppendNodeCommand):
1505         (WebCore::AppendNodeCommand::getNodesInCommand):
1506         * editing/AppendNodeCommand.h:
1507         (WebCore::AppendNodeCommand::create):
1508         * editing/ApplyStyleCommand.cpp:
1509         (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
1510         (WebCore::ApplyStyleCommand::positionToComputeInlineStyleChange):
1511         * editing/BreakBlockquoteCommand.cpp:
1512         (WebCore::BreakBlockquoteCommand::doApply):
1513         * editing/CompositeEditCommand.cpp:
1514         (WebCore::CompositeEditCommand::insertNodeBefore):
1515         (WebCore::CompositeEditCommand::insertNodeAfter):
1516         (WebCore::CompositeEditCommand::insertNodeAt):
1517         (WebCore::CompositeEditCommand::appendNode):
1518         (WebCore::CompositeEditCommand::moveRemainingSiblingsToNewParent):
1519         (WebCore::CompositeEditCommand::mergeIdenticalElements):
1520         (WebCore::CompositeEditCommand::insertNodeAtTabSpanPosition):
1521         (WebCore::CompositeEditCommand::appendBlockPlaceholder):
1522         (WebCore::CompositeEditCommand::insertBlockPlaceholder):
1523         (WebCore::CompositeEditCommand::addBlockPlaceholderIfNeeded):
1524         (WebCore::CompositeEditCommand::insertNewDefaultParagraphElementAt):
1525         (WebCore::CompositeEditCommand::cloneParagraphUnderNewElement):
1526         (WebCore::CompositeEditCommand::moveParagraphs):
1527         * editing/CompositeEditCommand.h:
1528         * editing/CreateLinkCommand.cpp:
1529         (WebCore::CreateLinkCommand::doApply):
1530         * editing/DeleteSelectionCommand.cpp:
1531         (WebCore::DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss):
1532         (WebCore::DeleteSelectionCommand::mergeParagraphs):
1533         * editing/FormatBlockCommand.cpp:
1534         (WebCore::FormatBlockCommand::formatRange):
1535         * editing/IndentOutdentCommand.cpp:
1536         (WebCore::IndentOutdentCommand::tryIndentingAsListItem):
1537         (WebCore::IndentOutdentCommand::indentIntoBlockquote):
1538         (WebCore::IndentOutdentCommand::outdentParagraph):
1539         * editing/InsertLineBreakCommand.cpp:
1540         (WebCore::InsertLineBreakCommand::doApply):
1541         * editing/InsertLineBreakCommand.h:
1542         * editing/InsertListCommand.cpp:
1543         (WebCore::InsertListCommand::fixOrphanedListChild):
1544         (WebCore::InsertListCommand::doApplyForSingleParagraph):
1545         (WebCore::InsertListCommand::unlistifyParagraph):
1546         (WebCore::InsertListCommand::listifyParagraph):
1547         * editing/InsertListCommand.h:
1548         * editing/InsertNodeBeforeCommand.cpp:
1549         (WebCore::InsertNodeBeforeCommand::InsertNodeBeforeCommand):
1550         (WebCore::InsertNodeBeforeCommand::doApply):
1551         (WebCore::InsertNodeBeforeCommand::doUnapply):
1552         (WebCore::InsertNodeBeforeCommand::getNodesInCommand):
1553         * editing/InsertNodeBeforeCommand.h:
1554         (WebCore::InsertNodeBeforeCommand::create):
1555         * editing/InsertParagraphSeparatorCommand.cpp:
1556         (WebCore::InsertParagraphSeparatorCommand::cloneHierarchyUnderNewBlock):
1557         (WebCore::InsertParagraphSeparatorCommand::doApply):
1558         * editing/InsertParagraphSeparatorCommand.h:
1559         * editing/InsertTextCommand.cpp:
1560         (WebCore::InsertTextCommand::positionInsideTextNode):
1561         (WebCore::InsertTextCommand::insertTab):
1562         * editing/ModifySelectionListLevel.cpp:
1563         (WebCore::ModifySelectionListLevelCommand::insertSiblingNodeRangeBefore):
1564         (WebCore::ModifySelectionListLevelCommand::insertSiblingNodeRangeAfter):
1565         (WebCore::ModifySelectionListLevelCommand::appendSiblingNodeRange):
1566         (WebCore::IncreaseSelectionListLevelCommand::doApply):
1567         * editing/RemoveNodePreservingChildrenCommand.cpp:
1568         (WebCore::RemoveNodePreservingChildrenCommand::doApply):
1569         * editing/ReplaceSelectionCommand.cpp:
1570         (WebCore::ReplaceSelectionCommand::moveNodeOutOfAncestor):
1571         (WebCore::ReplaceSelectionCommand::mergeEndIfNeeded):
1572         (WebCore::ReplaceSelectionCommand::doApply):
1573         (WebCore::ReplaceSelectionCommand::addSpacesForSmartReplace):
1574         (WebCore::ReplaceSelectionCommand::insertAsListItems):
1575         * editing/SimplifyMarkupCommand.cpp:
1576         (WebCore::SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove):
1577
1578 2017-05-02  Ben Kelly <ben@wanderview.com>
1579
1580         Set Response.blob() type correctly when body is a ReadableStream.
1581         https://bugs.webkit.org/show_bug.cgi?id=171489
1582
1583         Reviewed by Youenn Fablet
1584
1585         The Fetch API specification requires setting the blob contentType
1586         using the Content-Type header value, if present.  Currently WebKit
1587         only sets the type on the FetchBodyConsumer when FetchBody::blob()
1588         is called.  Unfortunately, this is never called if the body is
1589         actually a ReadableStream.
1590
1591         This change allows WebKit to pass the "Consume response's body: from
1592         stream to blob" case in the WPT response-consume.html test.
1593
1594         Test: http://w3c-test.org/fetch/api/response/response-consume.html
1595
1596         * Modules/fetch/FetchResponse.cpp:
1597         (WebCore::FetchResponse::startConsumingStream): Modified to call
1598         FetchBodyConsumer::setContentType() before processing the stream.
1599
1600 2017-05-02  Ryan Haddad  <ryanhaddad@apple.com>
1601
1602         Unreviewed, rolling out r216069.
1603
1604         This change broke the build.
1605
1606         Reverted changeset:
1607
1608         "Document style resolvers should share user rulesets"
1609         https://bugs.webkit.org/show_bug.cgi?id=171549
1610         http://trac.webkit.org/changeset/216069
1611
1612 2017-05-02  Antti Koivisto  <antti@apple.com>
1613
1614         Document style resolvers should share user rulesets
1615         https://bugs.webkit.org/show_bug.cgi?id=171549
1616
1617         Reviewed by Andreas Kling.
1618
1619         Large user stylesheets (like those used by ad blockers) can end up using lots of memory if
1620         a document uses large number of shadow trees. User style is inherently per-document and
1621         the resulting rulesets can be shared between the document and the shadow trees.
1622
1623         * css/DocumentRuleSets.cpp:
1624         (WebCore::DocumentRuleSets::DocumentRuleSets):
1625         (WebCore::DocumentRuleSets::userStyle):
1626
1627             Return per-document user style for shadow trees.
1628
1629         (WebCore::DocumentRuleSets::collectFeatures):
1630         * css/DocumentRuleSets.h:
1631         (WebCore::DocumentRuleSets::setUsesSharedUserStyle):
1632         (WebCore::DocumentRuleSets::userStyle): Deleted.
1633         * css/StyleResolver.cpp:
1634         (WebCore::StyleResolver::StyleResolver):
1635         (WebCore::StyleResolver::initializeUserStyle):
1636
1637             Separate user style initialization from construction.
1638
1639         * css/StyleResolver.h:
1640         * style/StyleScope.cpp:
1641         (WebCore::Style::Scope::resolver):
1642
1643             Don't initialize user style for user agents shadow trees.
1644
1645 2017-05-02  Gwang Yoon Hwang  <yoon@igalia.com>
1646
1647         [GTK] Remove undefined nativeImage method from the ImageBuffer's header
1648         https://bugs.webkit.org/show_bug.cgi?id=171502
1649
1650         Unreviewed, remove a dead code accidentally committed in r194630.
1651
1652         * platform/graphics/ImageBuffer.h: Remove nativeImage method.
1653         It is accidentally added during a refectorying at r194630, and there is
1654         no definition for this method.
1655
1656 2017-05-02  Carlos Garcia Campos  <cgarcia@igalia.com>
1657
1658         [GStreamer] Dailymotion live stream videos don't play
1659         https://bugs.webkit.org/show_bug.cgi?id=170767
1660
1661         Reviewed by Sergio Villar Senin.
1662
1663         The video shows a message saying that an error occurred and nothing is played. There are actually several
1664         problems with dailymotion. The main issue is that URLs are redirected by the server, and GStreamer needs to
1665         know the redirected URL. Once GStreamer knows the redirected URL the error message no longer appears, the video
1666         starts but it always stops after a few seconds. This is because the source receives an early EOS while still
1667         downloading the fragments. The reason of the early EOS is because dailymotion sends a wrong Content-Length header,
1668         something that is expected to happen and we correctly handle that case when receiving the data, by updating the
1669         size accordingly if the bytes received are longer than the expected content length. This particular case
1670         doesn't work well with GStreamer automatic EOS handling, which is the default. At some point, GStreamer detects
1671         that the bytes received are at least the expected ones and emits a GST_EVENT_EOS that the GstUriDownloader
1672         handles finishing the download early. We should always disable automatic EOS, since we know when EOS actually
1673         happens and we already call gst_app_src_end_of_stream(). This patch also emits a GST_EVENT_CUSTOM_DOWNSTREAM_STICKY
1674         event to let GStreamer know about the HTTP headers sent and received.
1675
1676         * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
1677         (webkit_web_src_init): Disable automatic EOS.
1678         (webKitWebSrcGetProperty): Return the redirected URL in case of redirection.
1679         (webKitWebSrcStart): Pass the ResourceRequest to the stream clients.
1680         (webKitWebSrcQueryWithParent): Set the redirected URL in the query in case of redirection.
1681         (webKitWebSrcSetUri): Clear also the redirected URL when setting a new URI.
1682         (StreamingClient::StreamingClient): Use GRefPtr for the source and initialize the request too.
1683         (StreamingClient::~StreamingClient): Remove explicit unref.
1684         (StreamingClient::createReadBuffer):
1685         (StreamingClient::handleResponseReceived): Initialize the redirected URL in case of redirection. Create and push
1686         the HTTP headers event.
1687         (StreamingClient::handleDataReceived):
1688         (StreamingClient::handleNotifyFinished):
1689         (CachedResourceStreamingClient::CachedResourceStreamingClient):
1690         (CachedResourceStreamingClient::responseReceived):
1691         (CachedResourceStreamingClient::accessControlCheckFailed):
1692         (CachedResourceStreamingClient::loadFailed):
1693         (ResourceHandleStreamingClient::ResourceHandleStreamingClient):
1694         (ResourceHandleStreamingClient::didFail):
1695         (ResourceHandleStreamingClient::wasBlocked):
1696         (ResourceHandleStreamingClient::cannotShowURL):
1697
1698 2017-05-02  Youenn Fablet  <youenn@apple.com>
1699
1700         Adding logging to RTCPeerConnection to allow WebRTC application debugging
1701         https://bugs.webkit.org/show_bug.cgi?id=171531
1702
1703         Reviewed by Jon Lee.
1704
1705         No change of behavior.
1706         This allows easier debugging of webrtc-enabled web pages.
1707
1708         * Modules/mediastream/PeerConnectionBackend.cpp:
1709         (WebCore::PeerConnectionBackend::createOfferSucceeded):
1710         (WebCore::PeerConnectionBackend::createOfferFailed):
1711         (WebCore::PeerConnectionBackend::createAnswerSucceeded):
1712         (WebCore::PeerConnectionBackend::createAnswerFailed):
1713         (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded):
1714         (WebCore::PeerConnectionBackend::setLocalDescriptionFailed):
1715         (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded):
1716         (WebCore::PeerConnectionBackend::setRemoteDescriptionFailed):
1717         (WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
1718         (WebCore::PeerConnectionBackend::addIceCandidateFailed):
1719         (WebCore::PeerConnectionBackend::newICECandidate):
1720         (WebCore::PeerConnectionBackend::doneGatheringCandidates):
1721         * Modules/mediastream/RTCPeerConnection.cpp:
1722         (WebCore::RTCPeerConnection::queuedCreateOffer):
1723         (WebCore::RTCPeerConnection::queuedCreateAnswer):
1724         (WebCore::RTCPeerConnection::queuedSetLocalDescription):
1725         (WebCore::RTCPeerConnection::queuedSetRemoteDescription):
1726         (WebCore::RTCPeerConnection::queuedAddIceCandidate):
1727
1728 2017-04-12  Carlos Garcia Campos  <cgarcia@igalia.com>
1729
1730         [GTK] Crash at WebCore::ResourceHandle::clearClient() when streaming live video from dailymotion
1731         https://bugs.webkit.org/show_bug.cgi?id=169725
1732
1733         Reviewed by Michael Catanzaro.
1734
1735         Make ResourceHandleStreamingClient refcounted and add an invalidate method to do the cleanup in the networking
1736         thread while keeping a reference.
1737
1738         * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
1739         (webKitWebSrcStop): Call invalidate before reseting client pointer.
1740         (webKitWebSrcStart): Ditto.
1741         (ResourceHandleStreamingClient::ResourceHandleStreamingClient): Remove all cleanup code after the run loop run call.
1742         (ResourceHandleStreamingClient::~ResourceHandleStreamingClient): Just detach the thread.
1743         (ResourceHandleStreamingClient::invalidate): Schedule a task on the networking thread to clean up and fiish the
1744         run loop, protecting this.
1745         (ResourceHandleStreamingClient::setDefersLoading): Protect this.
1746         (ResourceHandleStreamingClient::didReceiveResponse): Do nothing if client was invalidated.
1747         (ResourceHandleStreamingClient::didReceiveBuffer): Ditto.
1748         (ResourceHandleStreamingClient::didFinishLoading): Ditto.
1749
1750 2017-05-01  Zan Dobersek  <zdobersek@igalia.com>
1751
1752         [GCrypt] ECDSA signing and verification support
1753         https://bugs.webkit.org/show_bug.cgi?id=171103
1754
1755         Reviewed by Carlos Garcia Campos.
1756
1757         Implement WebCrypto ECDSA support for configurations that
1758         are using libgcrypt.
1759
1760         For signing, the provided data is first hashed with the specified
1761         digest algorithm and embedded into a data s-expression. It's then
1762         passed to gcry_pk_sign() along with the private key, returning a
1763         sig-val s-expression. The r and s parameters are then retrieved from
1764         that sig-val and their data extracted and concatenated in the output
1765         Vector<>.
1766
1767         For verification, the data is again hashed and embedded into a data
1768         s-expression. The r and s parameters are extracted from the passed-in
1769         signature Vector<> and embedded into a sig-val s-expression. The data
1770         and sig-val s-expressions are then passed to gcry_pk_verify() along
1771         with the public key. The verification succeeds if no error is returned
1772         and fails if the returned error code is GPG_ERR_BAD_SIGNATURE.
1773
1774         * crypto/gcrypt/CryptoAlgorithmECDSAGCrypt.cpp:
1775         (WebCore::hashCryptoDigestAlgorithm):
1776         (WebCore::hashAlgorithmName):
1777         (WebCore::mpiData):
1778         (WebCore::gcryptSign):
1779         (WebCore::gcryptVerify):
1780         (WebCore::CryptoAlgorithmECDSA::platformSign):
1781         (WebCore::CryptoAlgorithmECDSA::platformVerify):
1782
1783 2017-05-01  Zan Dobersek  <zdobersek@igalia.com>
1784
1785         [GCrypt] HKDF bit derivation support
1786         https://bugs.webkit.org/show_bug.cgi?id=171074
1787
1788         Reviewed by Michael Catanzaro.
1789
1790         Implement bit derivation support for the HKDF algorithm for configurations
1791         that use libgcrypt.
1792
1793         libgcrypt doesn't provide HKDF support out of the box, so we have to
1794         implement the two steps manually. In the first one, we retrieve the
1795         pseudo-random key by using the specified MAC algorithm with the salt data
1796         as the key and the key data as the input keying material.
1797
1798         In the expand step, we do the required amount of iterations to derive
1799         a sufficient amount of data, using the same MAC algorithm with the
1800         pseudo-random key from the previous step on the data we compose from the
1801         previous block data, the info data, and the current iteration value. The
1802         resulting blocks are appended together until they can be clipped to the
1803         desired output length.
1804
1805         * crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:
1806         (WebCore::macAlgorithmForHashFunction):
1807         (WebCore::gcryptDeriveBits):
1808         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
1809
1810 2017-05-01  Zan Dobersek  <zdobersek@igalia.com>
1811
1812         [GCrypt] ECDH bit derivation support
1813         https://bugs.webkit.org/show_bug.cgi?id=171070
1814
1815         Reviewed by Michael Catanzaro.
1816
1817         Implement bit derivation support for the ECDH algorithm for configurations
1818         that use libgcrypt.
1819
1820         This is done by retrieving the private key data and wrapping it in a new
1821         data s-expression. That's then encrypted with the public key, and the
1822         returned s-expression contains the shared point data. That data is then
1823         decoded into an EC point, from which the x-coordinate is retrieved. This
1824         coordinate data is finally our bit derivation result.
1825
1826         * crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:
1827         (WebCore::gcryptDerive):
1828         (WebCore::CryptoAlgorithmECDH::platformDeriveBits):
1829
1830 2017-05-01  Youenn Fablet  <youenn@apple.com>
1831
1832         Ensure RealtimeOutgoingVideoSource sends a black frame when its related source is muted
1833         https://bugs.webkit.org/show_bug.cgi?id=171497
1834
1835         Reviewed by Eric Carlson.
1836
1837         Covered by updated test.
1838
1839         When the track is being muted or disabled, send a black frame explicitly.
1840         VideoToolBox sometimes does not output a frame until it receives the other.
1841         That is why we end up sending two frames, the second asynchronously so that libwebrtc will not skip it.
1842         Also storing the rotation so that we keep the same rotation for black frames.
1843         Storing width and height for consistency as well.
1844
1845         * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
1846         (WebCore::RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource):
1847         (WebCore::RealtimeOutgoingVideoSource::setSource):
1848         (WebCore::RealtimeOutgoingVideoSource::stop):
1849         (WebCore::RealtimeOutgoingVideoSource::sourceMutedChanged):
1850         (WebCore::RealtimeOutgoingVideoSource::sourceEnabledChanged):
1851         (WebCore::RealtimeOutgoingVideoSource::setSizeFromSource):
1852         (WebCore::RealtimeOutgoingVideoSource::sendBlackFrame):
1853         (WebCore::RealtimeOutgoingVideoSource::sendFrame):
1854         (WebCore::RealtimeOutgoingVideoSource::videoSampleAvailable):
1855         * platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
1856
1857 2017-05-01  Joseph Pecoraro  <pecoraro@apple.com>
1858
1859         Simplify Resource Timing handling of cached resource
1860         https://bugs.webkit.org/show_bug.cgi?id=171526
1861
1862         Reviewed by Youenn Fablet.
1863
1864         * loader/DocumentThreadableLoader.cpp:
1865         (WebCore::DocumentThreadableLoader::loadRequest):
1866         * loader/SubresourceLoader.cpp:
1867         (WebCore::SubresourceLoader::init):
1868         (WebCore::SubresourceLoader::reportResourceTiming):
1869         Use auto in ResourceTiming construction.
1870         Eliminate an outdated comment.
1871
1872         * loader/cache/CachedResourceLoader.cpp:
1873         (WebCore::CachedResourceLoader::requestResource):
1874         We can avoid the checks around the request.origin. It should already
1875         be the cases we were checking and asserting because of login in
1876         CachedResourceLoader::prepareFetch.
1877
1878 2017-05-01  Ryan Haddad  <ryanhaddad@apple.com>
1879
1880         Unreviewed, rolling out r216024.
1881
1882         This change caused ios-simulator LayoutTests to exit early
1883         with assertion failures.
1884
1885         Reverted changeset:
1886
1887         "Add audio device change notifications to AudioSession."
1888         https://bugs.webkit.org/show_bug.cgi?id=171403
1889         http://trac.webkit.org/changeset/216024
1890
1891 2017-05-01  Timothy Horton  <timothy_horton@apple.com>
1892
1893         Expose viewport-fit instead of clip-to-safe-area
1894         https://bugs.webkit.org/show_bug.cgi?id=171503
1895         <rdar://problem/31918249>
1896
1897         Reviewed by Simon Fraser.
1898
1899         Tests: fast/viewport/ios/viewport-fit-auto.html
1900                fast/viewport/ios/viewport-fit-contain.html
1901                fast/viewport/ios/viewport-fit-cover.html
1902
1903         * dom/ConstantPropertyMap.cpp:
1904         (WebCore::ConstantPropertyMap::buildValues):
1905         (WebCore::ConstantPropertyMap::updateConstantsForUnobscuredSafeAreaInsets):
1906         (WebCore::ConstantPropertyMap::didChangeSafeAreaInsets):
1907         (WebCore::ConstantPropertyMap::updateConstantsForObscuredInsets): Deleted.
1908         (WebCore::ConstantPropertyMap::didChangeObscuredInsets): Deleted.
1909         * dom/ConstantPropertyMap.h:
1910         Retrieve the safe area insets from page, instead of assuming that we should
1911         just expose the entire obscured inset. Also, do some renames.
1912
1913         * dom/ViewportArguments.cpp:
1914         (WebCore::ViewportArguments::resolve):
1915         (WebCore::parseViewportFitValue):
1916         (WebCore::setViewportFeature):
1917         * dom/ViewportArguments.h:
1918         (WebCore::ViewportArguments::operator==):
1919         * page/ChromeClient.h:
1920         * page/FrameView.cpp:
1921         (WebCore::FrameView::enableSpeculativeTilingIfNeeded):
1922         (WebCore::FrameView::calculateExtendedBackgroundMode):
1923         (WebCore::FrameView::setClipToSafeArea): Deleted.
1924         * page/FrameView.h:
1925         * page/ViewportConfiguration.cpp:
1926         (WebCore::ViewportConfiguration::updateConfiguration):
1927         (WebCore::operator<<):
1928         (WebCore::ViewportConfiguration::description):
1929         (WebCore::ViewportConfiguration::dump):
1930         * page/ViewportConfiguration.h:
1931         (WebCore::ViewportConfiguration::avoidsUnsafeArea):
1932         (WebCore::ViewportConfiguration::Parameters::Parameters):
1933         (WebCore::ViewportConfiguration::clipToSafeArea): Deleted.
1934         * rendering/RenderLayerCompositor.cpp:
1935         (WebCore::RenderLayerCompositor::updateRootContentLayerClipping):
1936         * rendering/RenderObject.cpp:
1937         (WebCore::RenderObject::repaintUsingContainer):
1938         Un-do changes to support clip-to-safe-area, and instead implement
1939         a new viewport-fit argument in the viewport meta tag, which takes
1940         "auto", "contain", and "cover". "auto" and "contain" cause web content
1941         to lay out excluding the safe area inset from the layout size, while
1942         "cover" causes web content to expand into the unsafe area.
1943
1944         * page/Page.cpp:
1945         (WebCore::Page::setUnobscuredSafeAreaInsets):
1946         (WebCore::Page::setObscuredInsets): Deleted.
1947         * page/Page.h:
1948         (WebCore::Page::setObscuredInsets):
1949         (WebCore::Page::unobscuredSafeAreaInsets):
1950         Keep safe area and obscured insets separately.
1951
1952 2017-05-01  Chris Dumez  <cdumez@apple.com>
1953
1954         Documents created using DOMParser.parseFromString should inherit their context document's origin / URL
1955         https://bugs.webkit.org/show_bug.cgi?id=171499
1956
1957         Reviewed by Sam Weinig.
1958
1959         Documents created using DOMParser.parseFromString should inherit their context document's
1960         origin / URL:
1961         - https://w3c.github.io/DOM-Parsing/#dom-domparser-parsefromstring
1962
1963         Test: fast/dom/domparser-parsefromstring-origin.html
1964
1965         * xml/DOMParser.cpp:
1966         (WebCore::DOMParser::parseFromString):
1967
1968 2017-05-01  Ross Kirsling  <ross.kirsling@sony.com>
1969
1970         Web Inspector: ASSERT(!m_startedComposite) fails when recording on non-Cocoa Timeline
1971         https://bugs.webkit.org/show_bug.cgi?id=171363
1972
1973         Reviewed by Matt Baker.
1974
1975         * page/FrameView.cpp:
1976         (WebCore::FrameView::flushCompositingStateIncludingSubframes): Add PLATFORM(COCOA) guard.
1977
1978 2017-05-01  David Kilzer  <ddkilzer@apple.com>
1979
1980         Stop using strcpy() in fullyQualifiedInfoTableName() from Database.cpp
1981         <https://webkit.org/b/171517>
1982
1983         Reviewed by Brady Eidson.
1984
1985         * Modules/webdatabase/Database.cpp:
1986         (WebCore::fullyQualifiedInfoTableName): Switch from strcpy() to
1987         snprintf().
1988
1989 2017-05-01  Chris Fleizach  <cfleizach@apple.com>
1990
1991         AX: Support time@datetime for verbosity clarification of dates, times, and durations
1992         https://bugs.webkit.org/show_bug.cgi?id=171498
1993         <rdar://problem/12985540>
1994
1995         Reviewed by Joanmarie Diggs.
1996
1997         Expose the datetime attribute value.
1998
1999         Test: accessibility/datetime-attribute.html
2000
2001         * accessibility/AccessibilityObject.cpp:
2002         (WebCore::AccessibilityObject::datetimeAttributeValue):
2003         * accessibility/AccessibilityObject.h:
2004         * accessibility/AccessibilityRenderObject.cpp:
2005         (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
2006         (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
2007         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
2008         (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
2009         (-[WebAccessibilityObjectWrapper accessibilityDatetimeValue]):
2010         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
2011         (-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
2012         (createAccessibilityRoleMap):
2013         (-[WebAccessibilityObjectWrapper subrole]):
2014         (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
2015
2016 2017-05-01  Joseph Pecoraro  <pecoraro@apple.com>
2017
2018         RejectedPromiseTracker should produce better callstacks and avoid capturing callstacks unless there is a debugger/inspector
2019         https://bugs.webkit.org/show_bug.cgi?id=171416
2020         <rdar://problem/31899425>
2021
2022         Reviewed by Saam Barati and Brian Burg.
2023
2024         Test: inspector/console/message-stack-trace.html
2025
2026         * dom/RejectedPromiseTracker.cpp:
2027         (WebCore::UnhandledPromise::UnhandledPromise):
2028         (WebCore::UnhandledPromise::callStack):
2029         Switch to RefPtr to allow not capturing the stack.
2030
2031         (WebCore::createScriptCallStackFromReason):
2032         Use the VM's lastException if the value in the exception is the
2033         rejected promise value. Using the Exception call stack is important
2034         because uncaught exceptions in promise rejections trigger a built-in
2035         try/catch and re-enter JavaScript before passing the Error through
2036         to the RejectionTracker. When possible, we don't want to capture the
2037         new stack originating from the try/catch. Instead, we want the stack
2038         from before the try/catch when the error was created.
2039
2040         * dom/ScriptExecutionContext.h:
2041         * dom/ScriptExecutionContext.cpp:
2042         (WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
2043         Switch to a pointer since the stack could be empty.
2044
2045 2017-05-01  Jer Noble  <jer.noble@apple.com>
2046
2047         Unreviewed build fix after r216033.
2048
2049         * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
2050         (WebCore::CoreAudioCaptureSource::create):
2051
2052 2017-05-01  Jer Noble  <jer.noble@apple.com>
2053
2054         Use AVAudioSession to enumerate audio capture devices on iOS
2055         https://bugs.webkit.org/show_bug.cgi?id=170861
2056         <rdar://problem/31653658>
2057
2058         Reviewed by Eric Carlson.
2059
2060         Hook up the new AVAudioSessionCaptureDeviceManager class to CoreAudioCaptureSource and to the (increasingly ill-named)
2061         RealtimeMediaSourceCenterMac.
2062
2063         * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
2064         (WebCore::CoreAudioCaptureSource::create):
2065         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
2066         (WebCore::RealtimeMediaSourceCenterMac::setUseAVFoundationAudioCapture):
2067
2068 2017-05-01  Joanmarie Diggs  <jdiggs@igalia.com>
2069
2070         [ATK] Expose values of aria-rowcount, aria-colcount, aria-rowindex, aria-colindex, aria-rowspan, and aria-colspan as object attributes
2071         https://bugs.webkit.org/show_bug.cgi?id=171496
2072
2073         Reviewed by Chris Fleizach.
2074
2075         Expose valid, author-provided values as an object attribute. In order to distinguish
2076         author-provided values from the default returned by WebCore Accessibility (1), change
2077         the default return value to -1. We cannot return 0 because the ARIA spec states that
2078         0 is a valid value for authors to provide to indicate that the cell spans the remaining
2079         rows in the row group.
2080
2081         Also removed some legacy code. The "layout-guess" attribute was needed and expected
2082         as a way for AT-SPI2-based assistive technologies to identify layout tables. WebCore
2083         Accessibility does not expose tables which are purely for layout as accessible tables,
2084         and WebKitGtk uses that implementation, thus this attribute is no longer relevant.
2085
2086         No new tests. Unskipped existing test which is now passing.
2087
2088         * accessibility/AccessibilityARIAGridCell.cpp:
2089         (WebCore::AccessibilityARIAGridCell::ariaRowSpanWithRowIndex):
2090         (WebCore::AccessibilityARIAGridCell::columnIndexRange):
2091         * accessibility/AccessibilityTableCell.cpp:
2092         (WebCore::AccessibilityTableCell::ariaColumnSpan):
2093         (WebCore::AccessibilityTableCell::ariaRowSpan):
2094         * accessibility/AccessibilityTableCell.h:
2095         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
2096         (webkitAccessibleGetAttributes):
2097
2098 2017-05-01  Jer Noble  <jer.noble@apple.com>
2099
2100         Add audio device change notifications to AudioSession.
2101         https://bugs.webkit.org/show_bug.cgi?id=171403
2102
2103         Reviewed by Eric Carlson.
2104
2105         Add notifications to AudioSession which fire when the current input and output audio devices
2106         change. Also add a notification when audio services are lost (which will only fire on iOS).
2107         Take this opportunity to make the existing hardwareMutedStateDidChange() notification be
2108         platform agnostic, to move the outputDeviceSupportsLowPowerMode() code from AudioHardwareListener,
2109         and to do a few more clean-ups of the AudioSession code.
2110
2111         * WebCore.xcodeproj/project.pbxproj:
2112         * html/HTMLMediaElement.cpp:
2113         (WebCore::HTMLMediaElement::HTMLMediaElement):
2114         (WebCore::HTMLMediaElement::~HTMLMediaElement):
2115         * html/HTMLMediaElement.h:
2116         * platform/audio/AudioSession.cpp:
2117         (WebCore::AudioSession::AudioSession):
2118         * platform/audio/AudioSession.h:
2119         (WebCore::AudioSession::Observer::hardwareMutedStateDidChange):
2120         (WebCore::AudioSession::Observer::audioInputDeviceChanged):
2121         (WebCore::AudioSession::Observer::audioOutputDeviceChanged):
2122         (WebCore::AudioSession::Observer::audioServicesLost):
2123         (WebCore::AudioSession::Observer::audioServicesReset):
2124         (WebCore::AudioSession::MutedStateObserver::~MutedStateObserver): Deleted.
2125         * platform/audio/ios/AudioSessionIOS.mm:
2126         (WebCore::AudioSessionPrivate::AudioSessionPrivate):
2127         (WebCore::AudioSession::AudioSession):
2128         (WebCore::AudioSession::setCategoryOverride):
2129         (WebCore::AudioSession::categoryOverride):
2130         (WebCore::AudioSession::isMuted):
2131         (WebCore::AudioSession::outputDeviceSupportsLowPowerMode):
2132         (WebCore::AudioSession::addObserver):
2133         (WebCore::AudioSession::removeObserver):
2134         * platform/audio/mac/AudioSessionMac.mm: Renamed from Source/WebCore/platform/audio/mac/AudioSessionMac.cpp.
2135         (WebCore::defaultDevice):
2136         (WebCore::AudioSessionPrivate::AudioSessionPrivate):
2137         (WebCore::AudioSession::AudioSession):
2138         (WebCore::AudioSession::~AudioSession):
2139         (WebCore::AudioSession::category):
2140         (WebCore::AudioSession::setCategory):
2141         (WebCore::AudioSession::categoryOverride):
2142         (WebCore::AudioSession::setCategoryOverride):
2143         (WebCore::AudioSession::sampleRate):
2144         (WebCore::AudioSession::bufferSize):
2145         (WebCore::AudioSession::numberOfOutputChannels):
2146         (WebCore::AudioSession::tryToSetActive):
2147         (WebCore::AudioSession::preferredBufferSize):
2148         (WebCore::AudioSession::setPreferredBufferSize):
2149         (WebCore::AudioSession::isMuted):
2150         (WebCore::currentDeviceSupportsLowPowerBufferSize):
2151         (WebCore::AudioSession::outputDeviceSupportsLowPowerMode):
2152         (WebCore::AudioSession::addObserver):
2153         (WebCore::AudioSession::removeObserver):
2154
2155 2017-05-01  Chris Dumez  <cdumez@apple.com>
2156
2157         Do not dispatch SVG load event in frameless documents
2158         https://bugs.webkit.org/show_bug.cgi?id=171505
2159         <rdar://problem/31799776>
2160
2161         Reviewed by Andreas Kling.
2162
2163         We should not dispatch SVG load events in frameless documents. <https://trac.webkit.org/changeset/173028/webkit>
2164         took care of most load events but forgot the SVG load event.
2165
2166         Test: fast/dom/domparser-parsefromstring-svg-load-event.html
2167
2168         * dom/Document.cpp:
2169         (WebCore::Document::implicitClose):
2170
2171 2017-05-01  Chris Dumez  <cdumez@apple.com>
2172
2173         Remove some usage of PassRefPtr in editing code
2174         https://bugs.webkit.org/show_bug.cgi?id=171490
2175
2176         Reviewed by Darin Adler.
2177
2178         Remove some usage of PassRefPtr in editing code.
2179
2180         * dom/DocumentMarkerController.cpp:
2181         (WebCore::DocumentMarkerController::markersInRange):
2182         (DocumentMarkerController::hasMarkers):
2183         (DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange):
2184         * dom/DocumentMarkerController.h:
2185         * editing/AlternativeTextController.cpp:
2186         (WebCore::AlternativeTextController::isSpellingMarkerAllowed):
2187         (WebCore::AlternativeTextController::show):
2188         (WebCore::AlternativeTextController::applyAlternativeTextToRange):
2189         (WebCore::AlternativeTextController::timerFired):
2190         (WebCore::AlternativeTextController::handleAlternativeTextUIResult):
2191         (WebCore::AlternativeTextController::recordAutocorrectionResponse):
2192         (WebCore::AlternativeTextController::markReversed):
2193         (WebCore::AlternativeTextController::markCorrection):
2194         (WebCore::AlternativeTextController::recordSpellcheckerResponseForModifiedCorrection):
2195         (WebCore::AlternativeTextController::processMarkersOnTextToBeReplacedByResult):
2196         (WebCore::AlternativeTextController::applyDictationAlternative):
2197         * editing/AlternativeTextController.h:
2198         (WebCore::AlternativeTextController::UNLESS_ENABLED):
2199         * editing/ApplyStyleCommand.cpp:
2200         (WebCore::createFontElement):
2201         (WebCore::createStyleSpanElement):
2202         (WebCore::ApplyStyleCommand::ApplyStyleCommand):
2203         (WebCore::copyStyleOrCreateEmpty):
2204         (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
2205         (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
2206         (WebCore::ApplyStyleCommand::removeConflictingInlineStyleFromRun):
2207         (WebCore::ApplyStyleCommand::removeInlineStyleFromElement):
2208         (WebCore::ApplyStyleCommand::highestAncestorWithConflictingInlineStyle):
2209         (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
2210         (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
2211         (WebCore::ApplyStyleCommand::removeInlineStyle):
2212         (WebCore::ApplyStyleCommand::shouldSplitTextElement):
2213         (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
2214         (WebCore::ApplyStyleCommand::addInlineStyleIfNeeded):
2215         (WebCore::ApplyStyleCommand::positionToComputeInlineStyleChange):
2216         (WebCore::ApplyStyleCommand::applyInlineStyleChange):
2217         * editing/ApplyStyleCommand.h:
2218         (WebCore::ApplyStyleCommand::create):
2219         (WebCore::ApplyStyleCommand::shouldRemoveInlineStyleFromElement):
2220         * editing/CompositeEditCommand.cpp:
2221         (WebCore::CompositeEditCommand::applyCommandToComposite):
2222         (WebCore::CompositeEditCommand::applyStyledElement):
2223         (WebCore::CompositeEditCommand::removeStyledElement):
2224         (WebCore::CompositeEditCommand::replaceElementWithSpanPreservingChildrenAndAttributes):
2225         (WebCore::CompositeEditCommand::inputText):
2226         (WebCore::CompositeEditCommand::replaceTextInNodePreservingMarkers):
2227         (WebCore::CompositeEditCommand::pushAnchorElementDown):
2228         * editing/CompositeEditCommand.h:
2229         * editing/DeleteSelectionCommand.cpp:
2230         (WebCore::DeleteSelectionCommand::originalStringForAutocorrectionAtBeginningOfSelection):
2231         * editing/DictationCommand.cpp:
2232         (WebCore::DictationCommand::insertTextRunWithoutNewlines):
2233         * editing/EditingStyle.cpp:
2234         (WebCore::copyEditingProperties):
2235         (WebCore::copyPropertiesFromComputedStyle):
2236         (WebCore::extractPropertyValue):
2237         (WebCore::HTMLAttributeEquivalent::attributeValueAsCSSValue):
2238         (WebCore::HTMLFontSizeEquivalent::attributeValueAsCSSValue):
2239         (WebCore::EditingStyle::setStyle):
2240         (WebCore::EditingStyle::copy):
2241         (WebCore::EditingStyle::extractAndRemoveBlockProperties):
2242         (WebCore::EditingStyle::extractAndRemoveTextDirection):
2243         (WebCore::EditingStyle::mergeInlineStyleOfElement):
2244         (WebCore::extractEditingProperties):
2245         (WebCore::EditingStyle::styleAtSelectionStart):
2246         (WebCore::getPropertiesNotIn):
2247         * editing/EditingStyle.h:
2248         * editing/Editor.cpp:
2249         (WebCore::Editor::handleTextEvent):
2250         (WebCore::Editor::replaceSelectionWithFragment):
2251         (WebCore::Editor::insertOrderedList):
2252         (WebCore::Editor::insertUnorderedList):
2253         (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
2254         (WebCore::correctSpellcheckingPreservingTextCheckingParagraph):
2255         (WebCore::Editor::markAndReplaceFor):
2256         (WebCore::Editor::changeBackToReplacedString):
2257         (WebCore::Editor::updateMarkersForWordsAffectedByEditing):
2258         (WebCore::Editor::rangeForPoint):
2259         * editing/Editor.h:
2260         * editing/ModifySelectionListLevel.cpp:
2261         (WebCore::IncreaseSelectionListLevelCommand::increaseSelectionListLevel):
2262         (WebCore::IncreaseSelectionListLevelCommand::increaseSelectionListLevelOrdered):
2263         (WebCore::IncreaseSelectionListLevelCommand::increaseSelectionListLevelUnordered):
2264         * editing/ModifySelectionListLevel.h:
2265         * editing/SpellChecker.cpp:
2266         (WebCore::SpellChecker::requestCheckingFor):
2267         (WebCore::SpellChecker::didCheckSucceed):
2268         * editing/SpellChecker.h:
2269         (WebCore::SpellCheckRequest::checkingRange):
2270         (WebCore::SpellCheckRequest::paragraphRange):
2271         (WebCore::SpellCheckRequest::rootEditableElement):
2272         * editing/SpellingCorrectionCommand.cpp:
2273         (WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand):
2274         (WebCore::SpellingCorrectionCommand::willApplyCommand):
2275         (WebCore::SpellingCorrectionCommand::doApply):
2276         (WebCore::SpellingCorrectionCommand::targetRanges):
2277         * editing/SpellingCorrectionCommand.h:
2278         (WebCore::SpellingCorrectionCommand::create):
2279         * editing/SurroundingText.h:
2280         * editing/TextCheckingHelper.cpp:
2281         (WebCore::TextCheckingParagraph::expandRangeToNextEnd):
2282         (WebCore::TextCheckingParagraph::rangeLength):
2283         (WebCore::TextCheckingParagraph::paragraphRange):
2284         (WebCore::TextCheckingParagraph::subrange):
2285         (WebCore::TextCheckingParagraph::offsetTo):
2286         (WebCore::TextCheckingParagraph::offsetAsRange):
2287         (WebCore::TextCheckingParagraph::text):
2288         (WebCore::TextCheckingParagraph::checkingStart):
2289         * editing/TextCheckingHelper.h:
2290         * editing/TypingCommand.cpp:
2291         (WebCore::TypingCommand::insertTextRunWithoutNewlines):
2292         * editing/cocoa/HTMLConverter.mm:
2293         (HTMLConverterCaches::computedStylePropertyForElement):
2294         (HTMLConverterCaches::inlineStylePropertyForElement):
2295         * page/ios/FrameIOS.mm:
2296         (WebCore::Frame::interpretationsForCurrentRoot):
2297
2298 2017-05-01  Jer Noble  <jer.noble@apple.com>
2299
2300         Add notifications from CaptureDeviceManager (and subclasses) when device lists change
2301         https://bugs.webkit.org/show_bug.cgi?id=171442
2302
2303         Reviewed by Youenn Fablet.
2304
2305         Add a new callback-based notification to CaptureDeviceManager which fires when the underlying list
2306         of devices changes. Add support for enumerating AVAudioSession capture devices.
2307
2308         * WebCore.xcodeproj/project.pbxproj:
2309         * platform/mediastream/CaptureDeviceManager.cpp:
2310         (nextObserverToken):
2311         (CaptureDeviceManager::addCaptureDeviceChangedObserver):
2312         (CaptureDeviceManager::removeCaptureDeviceChangedObserver):
2313         * platform/mediastream/CaptureDeviceManager.h:
2314         * platform/mediastream/ios/AVAudioSessionCaptureDevice.h: Added.
2315         * platform/mediastream/ios/AVAudioSessionCaptureDevice.mm: Added.
2316         (WebCore::AVAudioSessionCaptureDevice::create):
2317         (WebCore::AVAudioSessionCaptureDevice::AVAudioSessionCaptureDevice):
2318         * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Added.
2319         * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm: Added.
2320         (-[WebAVAudioSessionAvailableInputsListener initWithCallback:]):
2321         (-[WebAVAudioSessionAvailableInputsListener invalidate]):
2322         (-[WebAVAudioSessionAvailableInputsListener observeValueForKeyPath:ofObject:change:context:]):
2323         (WebCore::AVAudioSessionCaptureDeviceManager::singleton):
2324         (WebCore::AVAudioSessionCaptureDeviceManager::captureDevices):
2325         (WebCore::AVAudioSessionCaptureDeviceManager::audioSessionCaptureDevices):
2326         (WebCore::AVAudioSessionCaptureDeviceManager::audioSessionDeviceWithUID):
2327         (WebCore::AVAudioSessionCaptureDeviceManager::refreshAudioCaptureDevices):
2328         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
2329         (WebCore::AVCaptureDeviceManager::deviceConnected):
2330         (WebCore::AVCaptureDeviceManager::deviceDisconnected):
2331         * platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:
2332         (WebCore::CoreAudioCaptureDeviceManager::refreshAudioCaptureDevices):
2333         (WebCore::CoreAudioCaptureDeviceManager::devicesChanged):
2334
2335 2017-05-01  Joanmarie Diggs  <jdiggs@igalia.com>
2336
2337         AX: AccessibilityTable::ariaRowCount() and ariaColumnCount() should not return -1 unless that is the author-provided value
2338         https://bugs.webkit.org/show_bug.cgi?id=171475
2339
2340         Reviewed by Chris Fleizach.
2341
2342         If the author has provided a valid value, return it. Otherwise, return 0.
2343
2344         No new tests needed. Update existing test expectations to reflect the change.
2345
2346         * accessibility/AccessibilityTable.cpp:
2347         (WebCore::AccessibilityTable::ariaColumnCount):
2348         (WebCore::AccessibilityTable::ariaRowCount):
2349
2350 2017-05-01  Joanmarie Diggs  <jdiggs@igalia.com>
2351
2352         AX: Implement support for ARIA "figure" and "term" roles; update AXRoleDescription mapping for "feed" role
2353         https://bugs.webkit.org/show_bug.cgi?id=171183
2354
2355         Reviewed by Chris Fleizach.
2356
2357         Create FeedRole, FigureRole, and TermRole and map them on the Mac and Gtk
2358         ports. Also rename AccessibilityObject::isFigure() to isFigureElement()
2359         for clarity as this method is specific to the HTML element and not the role.
2360
2361         No new tests needed: We have existing tests that cover mappings. Add new test cases
2362         to roles-exposed.html, xml-roles-exposed.html, and roles-computedRoleString.html.
2363
2364         * English.lproj/Localizable.strings:
2365         * accessibility/AccessibilityNodeObject.cpp:
2366         (WebCore::AccessibilityNodeObject::captionForFigure):
2367         (WebCore::AccessibilityNodeObject::alternativeText):
2368         * accessibility/AccessibilityObject.cpp:
2369         (WebCore::initializeRoleMap):
2370         (WebCore::AccessibilityObject::isFigureElement): Added.
2371         (WebCore::AccessibilityObject::isFigure): Deleted.
2372         * accessibility/AccessibilityObject.h:
2373         * accessibility/AccessibilityRenderObject.cpp:
2374         (WebCore::AccessibilityRenderObject::exposesTitleUIElement):
2375         (WebCore::AccessibilityRenderObject::titleUIElement):
2376         (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
2377         (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
2378         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
2379         (atkRole):
2380         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
2381         (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
2382         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
2383         (createAccessibilityRoleMap):
2384         (-[WebAccessibilityObjectWrapper subrole]):
2385         (-[WebAccessibilityObjectWrapper roleDescription]):
2386         * platform/LocalizedStrings.cpp:
2387         (WebCore::AXFeedText):
2388         * platform/LocalizedStrings.h:
2389
2390 2017-04-30  Chris Dumez  <cdumez@apple.com>
2391
2392         Drop support for legacy ClientRect / ClientRectList
2393         https://bugs.webkit.org/show_bug.cgi?id=171418
2394
2395         Reviewed by Sam Weinig.
2396
2397         Drop support for legacy ClientRect / ClientRectList types now we use
2398         DOMRect everywhere.
2399
2400         * CMakeLists.txt:
2401         * DerivedSources.cpp:
2402         * DerivedSources.make:
2403         * WebCore.xcodeproj/project.pbxproj:
2404         * dom/ClientRect.cpp: Removed.
2405         * dom/ClientRect.h: Removed.
2406         * dom/ClientRect.idl: Removed.
2407         * dom/ClientRectList.cpp: Removed.
2408         * dom/ClientRectList.h: Removed.
2409         * dom/ClientRectList.idl: Removed.
2410         * dom/DOMAllInOne.cpp:
2411         * dom/Element.cpp:
2412         * html/HTMLMediaElement.cpp:
2413         * html/track/VTTRegion.cpp:
2414         * page/DragController.cpp:
2415
2416 2017-04-30  Zalan Bujtas  <zalan@apple.com>
2417
2418         Initialize a new layout state while bailing out of simple line layout only when needed.
2419         https://bugs.webkit.org/show_bug.cgi?id=171481
2420         <rdar://problem/31906382>
2421
2422         '-webkit-border-fit: lines' requires inline box tree.
2423         We normally bail out of simple line layout early when we see this property. 
2424         When this property is dynamically set and we already have a simple line layout context,
2425         RenderBlockFlow::ensureLineBoxes() takes care of the switch by calling layoutLineBoxes().
2426         This patch makes sure that we create the layout state for this (forced)line layout only when
2427         we don't yet have one.
2428
2429         Reviewed by Antti Koivisto.
2430
2431         Test: fast/multicol/simple-line-layout-switch-to-normal-layout-while-inside-layout.html
2432
2433         * rendering/RenderBlockFlow.cpp:
2434         (WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer):
2435         (WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer):
2436         (WebCore::RenderBlockFlow::ensureLineBoxes):
2437         * rendering/RenderView.cpp:
2438         (WebCore::RenderView::pushLayoutStateForPaginationIfNeeded):
2439         (WebCore::RenderView::pushLayoutStateForPagination): Deleted.
2440         * rendering/RenderView.h:
2441
2442 2017-04-30  Dan Bernstein  <mitz@apple.com>
2443
2444         Tried to fix the iOS build after r215992
2445
2446         * platform/ios/WebVideoFullscreenControllerAVKit.mm:
2447
2448 2017-04-30  Brady Eidson  <beidson@apple.com>
2449
2450         Fix r215991
2451         https://bugs.webkit.org/show_bug.cgi?id=171483
2452
2453         Unreviewed.
2454
2455         * platform/spi/cf/CFNetworkSPI.h:
2456
2457 2017-04-30  Dan Bernstein  <mitz@apple.com>
2458
2459         Tried to fix the iOS build after r215992
2460
2461         * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
2462         (WebAVPlayerLayerView_pictureInPicturePlayerLayerView):
2463         (WebVideoFullscreenInterfaceAVKit::setupFullscreen):
2464
2465 2017-04-30  Dan Bernstein  <mitz@apple.com>
2466
2467         [Cocoa] Replaces uses of [get…() alloc] with alloc…Instance()
2468         https://bugs.webkit.org/show_bug.cgi?id=171485
2469
2470         Reviewed by Geoffrey Garen.
2471
2472         * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
2473         (WebCore::CDMSessionAVContentKeySession::contentKeySession):
2474         * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
2475         (WebCore::MediaPlaybackTargetPickerMac::devicePicker):
2476         * platform/ios/ValidationBubbleIOS.mm:
2477         (-[WebValidationBubbleTapRecognizer initWithPopoverController:]):
2478         (WebCore::ValidationBubble::ValidationBubble):
2479         * platform/ios/WebVideoFullscreenControllerAVKit.mm:
2480         (WebVideoFullscreenControllerContext::setUpFullscreen):
2481         * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
2482         (WebAVPlayerLayerView_pictureInPicturePlayerLayerView):
2483         (WebVideoFullscreenInterfaceAVKit::setupFullscreen):
2484         * platform/mac/WebVideoFullscreenInterfaceMac.mm:
2485         (-[WebVideoFullscreenInterfaceMacObjC setUpPIPForVideoView:withFrame:inWindow:]):
2486         * platform/network/ios/PreviewConverter.mm:
2487         (WebCore::PreviewConverter::PreviewConverter):
2488         * rendering/RenderThemeIOS.mm:
2489         (WebCore::iconForAttachment):
2490
2491 2017-04-30  Brady Eidson  <beidson@apple.com>
2492
2493         Updates to _WKWebsiteDataStoreConfiguration cookie storage location SPI.
2494         <rdar://problem/31906397> and https://bugs.webkit.org/show_bug.cgi?id=171483
2495
2496         Reviewed by Geoff Garen (and kind of Andy Estes).
2497
2498         No new tests (Covered by API test).
2499
2500         * platform/spi/cf/CFNetworkSPI.h:
2501
2502 2017-04-30  Dan Bernstein  <mitz@apple.com>
2503
2504         <rdar://problem/31906525> WebCore-7604.1.19 has failed to build
2505
2506         * platform/ios/WebItemProviderPasteboard.mm:
2507         (-[WebItemProviderPasteboard setItemsUsingRegistrationInfoLists:]): Resolved type ambiguity
2508           by using allocUIItemProviderInstance() instead of [getUIItemProviderClass() alloc].
2509
2510 2017-04-30  Joanmarie Diggs  <jdiggs@igalia.com>
2511
2512         [ATK] Implement support for aria-autocomplete
2513         https://bugs.webkit.org/show_bug.cgi?id=171167
2514
2515         Reviewed by Chris Fleizach.
2516
2517         Expose ATK_STATE_SUPPORTS_AUTOCOMPLETION in the state set, and the value
2518         of aria-autocomplete as an object attribute, for elements which indicate
2519         they support autocompletion.
2520
2521         Test: accessibility/gtk/aria-autocomplete.html
2522
2523         * accessibility/AccessibilityObject.cpp:
2524         (WebCore::AccessibilityObject::supportsARIAAutoComplete):
2525         (WebCore::AccessibilityObject::ariaAutoCompleteValue):
2526         * accessibility/AccessibilityObject.h:
2527         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
2528         (webkitAccessibleGetAttributes):
2529         (setAtkStateSetFromCoreObject):
2530         * html/HTMLAttributeNames.in:
2531
2532 2017-04-30  Joanmarie Diggs  <jdiggs@igalia.com>
2533
2534         [ATK] ARIA treegrid role should be exposed as ATK_ROLE_TREE_TABLE; not ATK_ROLE_TABLE
2535         https://bugs.webkit.org/show_bug.cgi?id=171170
2536
2537         Reviewed by Chris Fleizach.
2538
2539         AccessibilityTable::roleValue() was returning GridRole for both grid and treegrid.
2540         Change this so that GridRole is returned for grid and TreeGridRole is returned for
2541         treegrid. Add TreeGridRole to, or call isTable() in, methods where the behavior
2542         should be the same as GridRole.
2543
2544         Test: accessibility/gtk/interface-table.html
2545
2546         * accessibility/AccessibilityRenderObject.cpp:
2547         (WebCore::AccessibilityRenderObject::selectedChildren):
2548         * accessibility/AccessibilityTable.cpp:
2549         (WebCore::AccessibilityTable::roleValue):
2550         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
2551         (atkRole):
2552         (getInterfaceMaskFromObject):
2553         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
2554         (-[WebAccessibilityObjectWrapper _accessibilityTableAncestor]):
2555         (-[WebAccessibilityObjectWrapper _accessibilityTraitsFromAncestors]):
2556         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
2557         (createAccessibilityRoleMap):
2558
2559 2017-04-30  Joanmarie Diggs  <jdiggs@igalia.com>
2560
2561         [ATK] Emit object:state-changed:busy event when aria-busy value changes
2562         https://bugs.webkit.org/show_bug.cgi?id=171181
2563
2564         Reviewed by Chris Fleizach.
2565
2566         Emit object:state-changed:busy for AXElementBusyChanged notifications.
2567
2568         Test: accessibility/gtk/aria-busy-changed-notification.html
2569
2570         * accessibility/atk/AXObjectCacheAtk.cpp:
2571         (WebCore::AXObjectCache::postPlatformNotification):
2572
2573 2017-04-29  Joseph Pecoraro  <pecoraro@apple.com>
2574
2575         Zero out PerformanceResourceTiming properties for cached cross-origin responses without Timing-Allow-Origin
2576         https://bugs.webkit.org/show_bug.cgi?id=171394
2577
2578         Reviewed by Youenn Fablet.
2579
2580         * loader/ResourceTiming.cpp:
2581         (WebCore::ResourceTiming::fromCache):
2582         (WebCore::ResourceTiming::ResourceTiming):
2583         * loader/ResourceTiming.h:
2584         * loader/cache/CachedResourceLoader.cpp:
2585         (WebCore::CachedResourceLoader::requestResource):
2586         Include the timing-allow-origin check for cached responses.
2587         Also, avoid including an extra entry for an ongoing cached resource
2588         load, since when that load completes it should be reported.
2589
2590 2017-04-29  Youenn Fablet  <youenn@apple.com>
2591
2592         Readd assertion removed accidentally in r215955
2593         https://bugs.webkit.org/show_bug.cgi?id=171466
2594
2595         Reviewed by Eric Carlson.
2596
2597         Unreviewed.
2598
2599         * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
2600         (WebCore::MockRealtimeVideoSourceMac::orientationChanged): Improved FIXME after review.
2601
2602 2017-04-29  Andy Estes  <aestes@apple.com>
2603
2604         [macOS] Picture-in-picture should be disabled in WebPlaybackControlsManager during external media playback
2605         https://bugs.webkit.org/show_bug.cgi?id=171468
2606         <rdar://problem/31900349>
2607
2608         Reviewed by Eric Carlson.
2609
2610         * platform/mac/WebPlaybackControlsManager.h: Declared canTogglePictureInPicture as a
2611         readwrite property.
2612         * platform/mac/WebPlaybackControlsManager.mm: Synthesize canTogglePictureInPicture.
2613         (-[WebPlaybackControlsManager canTogglePictureInPicture]): Deleted.
2614         * platform/mac/WebPlaybackSessionInterfaceMac.h:
2615         * platform/mac/WebPlaybackSessionInterfaceMac.mm:
2616         (WebCore::WebPlaybackSessionInterfaceMac::externalPlaybackChanged): Called
2617         -[WebPlaybackControlsManager setCanTogglePictureInPicture:].
2618
2619 2017-04-29  Simon Fraser  <simon.fraser@apple.com>
2620
2621         Fix tests broken by r215964.
2622
2623         Fix copy-paste error that caused the wrong paint phase to get passed to the fire writeLayerRenderers()
2624         call, causing extra renderer dumping.
2625
2626         Also remove unused default arguments.
2627
2628         * rendering/RenderTreeAsText.cpp:
2629         (WebCore::writeLayerRenderers):
2630         (WebCore::writeLayers):
2631
2632 2017-04-28  Zalan Bujtas  <zalan@apple.com>
2633
2634         iBooks text can overlap, sometimes columns are shifted splitting words.
2635         https://bugs.webkit.org/show_bug.cgi?id=171472
2636         <rdar://problem/31096037>
2637
2638         Reviewed by Antti Koivisto.
2639
2640         Instead of just checking if the glyph is taller than the line, we need to ensure that both the
2641         ascent and the descent have enough space (this is for -webkit-line-box-contain: glyph).
2642
2643         Test: fast/text/simple-line-layout-glyph-overflows-line.html
2644
2645         * rendering/SimpleLineLayout.cpp:
2646         (WebCore::SimpleLineLayout::canUseForText): compute the available space for the ascent/descent
2647         and check them against the ceil-ed(see FontCascade::floatWidthForSimpleText) glyph min/max y.
2648
2649 2017-04-29  Nan Wang  <n_wang@apple.com>
2650
2651         AX: Improve performance of addChildren()/childrenChanged()
2652         https://bugs.webkit.org/show_bug.cgi?id=171443
2653
2654         Reviewed by Chris Fleizach.
2655
2656         There's a lot of unnecessary work happening when childrenChanged() is being called.
2657         Some of the improvements here:
2658         1. When childrenChanged() is being called on some element, we are marking its parent
2659            chain dirty. However, in the addChild() method we are then clearing each child of
2660            that 'dirty' parent, eventually making the entire tree dirty. 
2661            Added a m_subTreeDirty flag and using the needsToUpdateChildren() check to make sure
2662            we are only clearing the right chain without updating the unchanged siblings.
2663         2. In the addChild() method we are calling accessibilityIsIgnored() on each child and that 
2664            might lead to going up the parent chain again to get necessary information. 
2665            Since we are already traversing the tree from top to bottom to add children, added a 
2666            struct to store the information and pass it to the child so to avoid unnecessary traversal.
2667         3. Reduced the amount work of ARIA text controls perform when updating its parents in childrenChanged() 
2668            so that we don't update a big portion of the tree while typing.
2669
2670         No new tests since this didn't change any functionality. 
2671
2672         * accessibility/AccessibilityNodeObject.cpp:
2673         (WebCore::AccessibilityNodeObject::AccessibilityNodeObject):
2674         (WebCore::AccessibilityNodeObject::childrenChanged):
2675         (WebCore::AccessibilityNodeObject::insertChild):
2676         (WebCore::AccessibilityNodeObject::addChildren):
2677         (WebCore::AccessibilityNodeObject::isDescendantOfBarrenParent):
2678         * accessibility/AccessibilityNodeObject.h:
2679         * accessibility/AccessibilityObject.cpp:
2680         (WebCore::AccessibilityObject::AccessibilityObject):
2681         (WebCore::AccessibilityObject::defaultObjectInclusion):
2682         (WebCore::AccessibilityObject::setIsIgnoredFromParentDataForChild):
2683         * accessibility/AccessibilityObject.h:
2684         (WebCore::AccessibilityIsIgnoredFromParentData::AccessibilityIsIgnoredFromParentData):
2685         (WebCore::AccessibilityIsIgnoredFromParentData::isNull):
2686         (WebCore::AccessibilityObject::setNeedsToUpdateSubTree):
2687         (WebCore::AccessibilityObject::needsToUpdateChildren):
2688         (WebCore::AccessibilityObject::setIsIgnoredFromParentData):
2689         * accessibility/AccessibilityRenderObject.cpp:
2690         (WebCore::AccessibilityRenderObject::updateChildrenIfNecessary):
2691         (WebCore::AccessibilityRenderObject::addChildren):
2692         * accessibility/AccessibilityRenderObject.h:
2693         (WebCore::AccessibilityRenderObject::setRenderObject):
2694         (WebCore::AccessibilityRenderObject::needsToUpdateChildren): Deleted.
2695
2696 2017-04-29  Yusuke Suzuki  <utatane.tea@gmail.com>
2697
2698         Move WebCore CPUTime to WTF and implement it in all the platforms
2699         https://bugs.webkit.org/show_bug.cgi?id=171477
2700
2701         Reviewed by Chris Dumez.
2702
2703         Move CPUTime to WTF. And rename getCPUTime to CPUTime::get().
2704
2705         * CMakeLists.txt:
2706         * PlatformMac.cmake:
2707         * WebCore.xcodeproj/project.pbxproj:
2708         * page/ChromeClient.h:
2709         * page/PerformanceMonitor.cpp:
2710         (WebCore::PerformanceMonitor::PerformanceMonitor):
2711         (WebCore::PerformanceMonitor::measurePostLoadCPUUsage):
2712         (WebCore::PerformanceMonitor::measurePostBackgroundingCPUUsage):
2713         (WebCore::PerformanceMonitor::measureCPUUsageInActivityState):
2714         * page/PerformanceMonitor.h:
2715         * platform/CPUMonitor.cpp:
2716         (WebCore::CPUMonitor::setCPULimit):
2717         (WebCore::CPUMonitor::timerFired):
2718         * platform/CPUMonitor.h:
2719
2720 2017-04-28  Per Arne Vollan  <pvollan@apple.com>
2721
2722         Crash under WebCore::AccessibilityRenderObject::handleAriaExpandedChanged().
2723         https://bugs.webkit.org/show_bug.cgi?id=171427
2724         rdar://problem/31863417
2725
2726         Reviewed by Brent Fulgham.
2727
2728         The AccessibilityRenderObject object might delete itself in handleAriaExpandedChanged() under the call
2729         to the parentObject() method. This will cause a crash when accessing the object later in this method.
2730         Protect the current object while executing arbitrary event code.
2731
2732         Test: accessibility/accessibility-crash-setattribute.html
2733
2734         * accessibility/AccessibilityRenderObject.cpp:
2735         (WebCore::AccessibilityRenderObject::handleAriaExpandedChanged):
2736
2737 2017-04-28  Chris Dumez  <cdumez@apple.com>
2738
2739         Diagnostic logging of navigations is too verbose
2740         https://bugs.webkit.org/show_bug.cgi?id=171455
2741         <rdar://problem/31543815>
2742
2743         Reviewed by Andreas Kling.
2744
2745         Diagnostic logging of navigation is too verbose. We log things that are not actually user
2746         navigations (e.g. speculative loads, bookmark icon fetches, ...). To address the issue,
2747         we now only log *observable* loads. We do so by only logging if the page is visible or
2748         if it becomes visible.
2749
2750         * loader/FrameLoader.cpp:
2751         (WebCore::FrameLoader::loadWithDocumentLoader):
2752         (WebCore::logNavigation): Deleted.
2753         * page/Page.cpp:
2754         (WebCore::Page::setIsVisibleInternal):
2755         (WebCore::Page::logNavigation):
2756         (WebCore::Page::mainFrameLoadStarted):
2757         * page/Page.h:
2758
2759 2017-04-28  Joanmarie Diggs  <jdiggs@igalia.com>
2760
2761         AX: ARIA "region" role which lacks an accessible name should not be treated as a landmark
2762         https://bugs.webkit.org/show_bug.cgi?id=171180
2763
2764         Reviewed by Chris Fleizach.
2765
2766         Remove mapping of LandmarkRegionRole for regions which lack an accessible name.
2767         Doing so had a side effect of causing a number of DPub ARIA roles to stop being
2768         mapped as ARIA landmarks. This is due to our internal role mappings, namely
2769         treating the DPub ARIA landmark roles as if they were regions. Because DPub's
2770         landmarks do not subclass region, and do not have the same name-from-author
2771         requirement as region, create a new LandmarkDocRegionRole AccessibilityRole and
2772         map DPub ARIA's generic landmarks to it.
2773
2774         No new tests because we already have sufficient coverage. Several existing
2775         tests were given additional test cases to cover named and unnamed regions,
2776         and test expectations updated accordingly.
2777
2778         * accessibility/AccessibilityNodeObject.cpp:
2779         (WebCore::AccessibilityNodeObject::determineAriaRoleAttribute):
2780         * accessibility/AccessibilityObject.cpp:
2781         (WebCore::AccessibilityObject::accessibleNameDerivesFromContent):
2782         (WebCore::AccessibilityObject::isLandmark):
2783         (WebCore::initializeRoleMap):
2784         (WebCore::AccessibilityObject::computedRoleString):
2785         * accessibility/AccessibilityObject.h:
2786         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
2787         (atkRole):
2788         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
2789         (-[WebAccessibilityObjectWrapper _accessibilityIsLandmarkRole:]):
2790         (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
2791         * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
2792         (-[WebAccessibilityObjectWrapperBase ariaLandmarkRoleDescription]):
2793         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
2794         (createAccessibilityRoleMap):
2795         (-[WebAccessibilityObjectWrapper subrole]):
2796
2797 2017-04-28  Simon Fraser  <simon.fraser@apple.com>
2798
2799         Enhance showLayerTree() to show fragments
2800         https://bugs.webkit.org/show_bug.cgi?id=171469
2801
2802         Reviewed by Zalan Bujtas.
2803
2804         Have showLayerTree() dump fragments, like:
2805
2806              normal flow list(1)
2807               layer 0x11c1879c0 at (0,0) size 700x1858 backgroundClip at (0,0) size 2120x779 clip at (0,0) size 2120x779
2808                    fragment 0: bounds in layer at (0,0) size 700x1858 fragment bounds at (0,0) size 700x779
2809                    fragment 1: bounds in layer at (710,-779) size 700x1858 fragment bounds at (710,0) size 700x779
2810                    fragment 2: bounds in layer at (1420,-1558) size 700x1858 fragment bounds at (1420,0) size 700x300
2811                 RenderMultiColumnFlowThread 0x11f1f3340 at (0,0) size 700x1858
2812
2813         We want these to show before the child renderers, so factor that code into writeLayerRenderers().
2814         
2815         Overloading of write() for layers doesn't help anyone, so call it writeLayer() for searchability.
2816
2817         * rendering/RenderLayer.cpp:
2818         (WebCore::showLayerTree):
2819         * rendering/RenderLayer.h:
2820         * rendering/RenderTreeAsText.cpp:
2821         (WebCore::writeLayer):
2822         (WebCore::writeLayerRenderers):
2823         (WebCore::writeLayers):
2824         * rendering/RenderTreeAsText.h:
2825
2826 2017-04-28  Simon Fraser  <simon.fraser@apple.com>
2827
2828         Modernize RenderTreeAsText code
2829         https://bugs.webkit.org/show_bug.cgi?id=171458
2830
2831         Reviewed by Zalan Bujtas.
2832
2833         Use modern loops. More references to render objects and layers.
2834
2835         * rendering/RenderTreeAsText.cpp:
2836         (WebCore::write):
2837         (WebCore::writeRenderNamedFlowThreads):
2838         (WebCore::writeLayers):
2839         (WebCore::writeSelection):
2840         (WebCore::externalRepresentation):
2841
2842 2017-04-28  Wenson Hsieh  <wenson_hsieh@apple.com>
2843
2844         Fix and re-enable data interaction unit tests
2845         https://bugs.webkit.org/show_bug.cgi?id=171446
2846         <rdar://problem/31820646>
2847
2848         Reviewed by Tim Horton.
2849
2850         Three small tweaks to get all data interaction tests passing again (changes detailed below).
2851         Fixes a failing unit test: DataInteractionTests.RespectsExternalSourceFidelityRankings.
2852
2853         * page/mac/DragControllerMac.mm:
2854
2855         When dropping in a plain text editable area, don't consider kUTTypeText to be a UTI supported by the destination.
2856         This is because doing so would cause rich text UTIs, such as kUTTypeHTML, to match, so that the plain text area
2857         would report HTML as a preferred UTI type to load when dropping rich content over it. What we want to check for
2858         conformance here is really kUTTypePlainText.
2859
2860         (WebCore::DragController::updatePreferredTypeIdentifiersForDragHandlingMethod):
2861         * platform/Pasteboard.h:
2862         * platform/ios/PasteboardIOS.mm:
2863
2864         The default Pasteboard constructor no longer makes a sync call to the UI process to get the change count.
2865         Instead, we introduce a new constructor that takes and sets the change count. This default constructor was used
2866         from three places: Pasteboard::createForCopyAndPaste, Pasteboard::createPrivate and StaticPasteboard::create.
2867
2868         The first two call sites have been refactored to first fetch the change count from the UI process and then pass
2869         it in to the constructor.
2870
2871         (WebCore::changeCountForPasteboard):
2872         (WebCore::Pasteboard::Pasteboard):
2873         (WebCore::Pasteboard::createForCopyAndPaste):
2874         (WebCore::Pasteboard::createPrivate):
2875         (WebCore::Pasteboard::readString):
2876         (WebCore::Pasteboard::types):
2877         * platform/mac/DragDataMac.mm:
2878         (WebCore::typeIsAppropriateForSupportedTypes):
2879         (WebCore::DragData::updatePreferredTypeIdentifiers):
2880
2881         Remove the two-pass heuristic. Instead, we should follow this policy: "select the highest fidelity UTI that
2882         conforms to one of the destination's supported types".
2883
2884         * platform/mac/PasteboardMac.mm:
2885         (WebCore::Pasteboard::Pasteboard):
2886
2887 2017-04-28  Dean Jackson  <dino@apple.com>
2888
2889         App crashing: Dispatch queue: com.apple.root.user-interactive-qos / vBoxConvolve / WebCore::FEGaussianBlur::platformApplySoftware()
2890         https://bugs.webkit.org/show_bug.cgi?id=171461
2891         <rdar://problem/30534722>
2892
2893         Reviewed by Eric Carlson.
2894
2895         We're getting reports of crashes in this function, caused by null or empty data being
2896         passed to vImage. Guard against this, in a way that will ASSERT in debug builds if
2897         anyone comes across it.
2898
2899         Test: css3/filters/blur-various-radii.html
2900
2901         * platform/graphics/filters/FEGaussianBlur.cpp:
2902         (WebCore::accelerateBoxBlur): Return early if things don't look good.
2903
2904 2017-04-28  Chris Dumez  <cdumez@apple.com>
2905
2906         Stop using legacy ClientRect / ClientRectList in Internals
2907         https://bugs.webkit.org/show_bug.cgi?id=171412
2908
2909         Reviewed by Simon Fraser.
2910
2911         Stop using legacy ClientRect / ClientRectList in Internals amd use the
2912         newer DOMRect instead.
2913
2914         * dom/DOMRect.idl:
2915         * page/Page.cpp:
2916         (WebCore::Page::nonFastScrollableRects):
2917         (WebCore::Page::touchEventRectsForEvent):
2918         (WebCore::Page::passiveTouchEventListenerRects):
2919         * page/Page.h:
2920         * testing/Internals.cpp:
2921         (WebCore::Internals::absoluteCaretBounds):
2922         (WebCore::Internals::boundingBox):
2923         (WebCore::Internals::inspectorHighlightRects):
2924         (WebCore::Internals::layoutViewportRect):
2925         (WebCore::Internals::visualViewportRect):
2926         (WebCore::Internals::touchEventRectsForEvent):
2927         (WebCore::Internals::passiveTouchEventListenerRects):
2928         (WebCore::Internals::nonFastScrollableRects):
2929         (WebCore::Internals::selectionBounds):
2930         * testing/Internals.h:
2931         * testing/Internals.idl:
2932
2933 2017-04-28  Youenn Fablet  <youenn@apple.com>
2934
2935         getUserMedia video streams should follow device orientation
2936         https://bugs.webkit.org/show_bug.cgi?id=171284
2937
2938         Reviewed by Eric Carlson.
2939
2940         Only really affects AVVideoCaptureSource on iOS. Manually testing the following cases:
2941         - Mac: no change of behavior
2942         - iOS: page loaded in portrait, video is portrait. page loaded in landscape, video is landscape
2943         - iOS: changing the device orientation makes the video samples to be moved to landscape/portrait.
2944         - Same tests as above with peer connection.
2945
2946         Making Document having an OrientationNotifier that AVVideoCaptureSources get registered to.
2947         Making AVVideoCaptureSource an OrientationNotifier::Observer so that it can changes width/height if needed.
2948
2949         Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory.
2950         Refactoring to return a CaptureSourceOrError instead of passing an out parameter plus returning a RefPtr.
2951
2952         * Modules/mediastream/UserMediaRequest.cpp:
2953         (WebCore::UserMediaRequest::allow):
2954         * WebCore.xcodeproj/project.pbxproj:
2955         * dom/Document.cpp:
2956         (WebCore::Document::orientationChanged):
2957         * dom/Document.h:
2958         * page/Frame.cpp:
2959         (WebCore::Frame::orientationChanged):
2960         * platform/OrientationNotifer.h: Copied from Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h.
2961         (WebCore::OrientationNotifier::Observer::setNotifier):
2962         (WebCore::OrientationNotifier::Observer::~Observer):
2963         (WebCore::OrientationNotifier::orientationChanged):
2964         (WebCore::OrientationNotifier::addObserver):
2965         (WebCore::OrientationNotifier::removeObserver):
2966         * platform/mediastream/MediaStreamPrivate.cpp:
2967         (WebCore::MediaStreamPrivate::monitorOrientation):
2968         * platform/mediastream/MediaStreamPrivate.h:
2969         * platform/mediastream/RealtimeMediaSource.h:
2970         (WebCore::CaptureSourceOrError::CaptureSourceOrError):
2971         (WebCore::CaptureSourceOrError::operator bool):
2972         (WebCore::CaptureSourceOrError::source):
2973         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
2974         (WebCore::RealtimeMediaSourceCenter::setAudioFactory):
2975         (WebCore::RealtimeMediaSourceCenter::unsetAudioFactory):
2976         (WebCore::RealtimeMediaSourceCenter::setVideoFactory):
2977         (WebCore::RealtimeMediaSourceCenter::unsetVideoFactory):
2978         * platform/mediastream/RealtimeMediaSourceCenter.h:
2979         (WebCore::RealtimeMediaSourceCenter::defaultAudioFactory):
2980         (WebCore::RealtimeMediaSourceCenter::defaultVideoFactory):
2981         (WebCore::RealtimeMediaSourceCenter::audioFactory):
2982         (WebCore::RealtimeMediaSourceCenter::videoFactory):
2983         * platform/mediastream/mac/AVAudioCaptureSource.h:
2984         * platform/mediastream/mac/AVAudioCaptureSource.mm:
2985         (WebCore::AVAudioCaptureSource::create):
2986         (WebCore::AVAudioCaptureSource::factory):
2987         * platform/mediastream/mac/AVVideoCaptureSource.h:
2988         * platform/mediastream/mac/AVVideoCaptureSource.mm:
2989         (WebCore::AVVideoCaptureSource::create):
2990         (WebCore::AVVideoCaptureSource::factory):
2991         (WebCore::AVVideoCaptureSource::monitorOrientation):
2992         (WebCore::AVVideoCaptureSource::orientationChanged):
2993         (WebCore::AVVideoCaptureSource::processNewFrame):
2994         * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
2995         (WebCore::CoreAudioCaptureSource::create):
2996         (WebCore::CoreAudioCaptureSource::factory):
2997         * platform/mediastream/mac/CoreAudioCaptureSource.h:
2998         * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
2999         (WebCore::MockRealtimeAudioSource::create):
3000         * platform/mediastream/mac/MockRealtimeVideoSourceMac.h:
3001         * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
3002         (WebCore::MockRealtimeVideoSource::create):
3003         (WebCore::MockRealtimeVideoSourceMac::orientationChanged):
3004         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
3005         (WebCore::RealtimeMediaSourceCenterMac::createMediaStream):
3006         (WebCore::RealtimeMediaSourceCenterMac::bestSourcesForTypeAndConstraints):
3007         (WebCore::RealtimeMediaSourceCenterMac::defaultAudioFactory):
3008         (WebCore::RealtimeMediaSourceCenterMac::defaultVideoFactory):
3009         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:
3010         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
3011         (WebCore::RealtimeMediaSourceCenterOwr::createMediaStream):
3012         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.h:
3013         * platform/mock/MockRealtimeAudioSource.cpp:
3014         (WebCore::MockRealtimeAudioSource::create):
3015         (WebCore::MockRealtimeAudioSource::factory):
3016         * platform/mock/MockRealtimeAudioSource.h:
3017         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
3018         (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints):
3019         (WebCore::MockRealtimeMediaSourceCenter::createMediaStream):
3020         (WebCore::MockRealtimeMediaSourceCenter::defaultAudioFactory):
3021         (WebCore::MockRealtimeMediaSourceCenter::defaultVideoFactory):
3022         * platform/mock/MockRealtimeMediaSourceCenter.h:
3023         * platform/mock/MockRealtimeVideoSource.cpp:
3024         (WebCore::MockRealtimeVideoSource::create):
3025         (WebCore::MockRealtimeVideoSource::factory):
3026         * platform/mock/MockRealtimeVideoSource.h:
3027
3028 2017-04-28  Said Abou-Hallawa  <sabouhallawa@apple.com>
3029
3030         Unify how BitmapImage handles the availability of a decoded for large and animated images
3031         https://bugs.webkit.org/show_bug.cgi?id=171410
3032
3033         Reviewed by Simon Fraser.
3034
3035         Rename some functions which are related to animation frame availability.
3036         Make BitmapImage call ImageObserver::imageFrameAvailable() whenever a 
3037         frame is available regardless it is for an animated or for a large image.
3038
3039         * html/HTMLMediaElement.cpp:
3040         (WebCore::HTMLMediaElement::isVisibleInViewport):
3041         * html/MediaElementSession.cpp:
3042         (WebCore::MediaElementSession::autoplayPermitted):
3043         (WebCore::isMainContentForPurposesOfAutoplay):
3044         * loader/cache/CachedImage.cpp:
3045         (WebCore::CachedImage::CachedImageObserver::imageFrameAvailable):
3046         (WebCore::CachedImage::imageFrameAvailable):
3047         (WebCore::CachedImage::usesImageContainerSize): Deleted.
3048         (WebCore::CachedImage::imageHasRelativeWidth): Deleted.
3049         (WebCore::CachedImage::imageHasRelativeHeight): Deleted.
3050         (WebCore::CachedImage::CachedImageObserver::animationAdvanced): Deleted.
3051         (WebCore::CachedImage::animationAdvanced): Deleted.
3052         * loader/cache/CachedImage.h:
3053         * loader/cache/CachedImageClient.h:
3054         (WebCore::CachedImageClient::imageFrameAvailable):
3055         (WebCore::CachedImageClient::newImageAnimationFrameAvailable): Deleted.
3056         * platform/graphics/BitmapImage.cpp:
3057         (WebCore::BitmapImage::internalAdvanceAnimation):
3058         (WebCore::BitmapImage::imageFrameAvailableAtIndex):
3059         (WebCore::BitmapImage::newFrameNativeImageAvailableAtIndex): Deleted.
3060         * platform/graphics/BitmapImage.h:
3061         * platform/graphics/Image.h:
3062         (WebCore::Image::imageFrameAvailableAtIndex):
3063         (WebCore::Image::newFrameNativeImageAvailableAtIndex): Deleted.
3064         * platform/graphics/ImageFrameCache.cpp:
3065         (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex):
3066         * platform/graphics/ImageObserver.h:
3067         * platform/graphics/ImageTypes.h:
3068         * rendering/RenderElement.cpp:
3069         (WebCore::RenderElement::RenderElement):
3070         (WebCore::RenderElement::shouldRepaintInVisibleRect):
3071         (WebCore::RenderElement::imageFrameAvailable):
3072         (WebCore::RenderElement::repaintForPausedImageAnimationsIfNeeded):
3073         (WebCore::shouldRepaintForImageAnimation): Deleted.
3074         (WebCore::RenderElement::newImageAnimationFrameAvailable): Deleted.
3075         * rendering/RenderElement.h:
3076         * rendering/RenderView.cpp:
3077         (WebCore::RenderView::updateVisibleViewportRect):
3078         * svg/graphics/SVGImageClients.h:
3079
3080 2017-04-28  Jeremy Jones  <jeremyj@apple.com>
3081
3082         ARGUMENT BAD: time, time >= 0
3083         https://bugs.webkit.org/show_bug.cgi?id=164336
3084         rdar://problem/29314891
3085
3086         Reviewed by Eric Carlson.
3087
3088         Handle invalid duration and current time when calculating remaining time.
3089
3090         Test media/modern-media-controls/pip-support/pip-support-click.html now works without a workaround
3091         in media/modern-media-controls/pip-support/pip-support-enabled.html
3092
3093         * platform/mac/WebVideoFullscreenHUDWindowController.mm:
3094         (-[WebVideoFullscreenHUDWindowController remainingTimeText]):
3095
3096 2017-04-28  Daniel Bates  <dabates@apple.com>
3097
3098         Add WebCore::protocolIsJavaScript(StringView)
3099         https://bugs.webkit.org/show_bug.cgi?id=171396
3100
3101         Reviewed by Alex Christensen.
3102
3103         Add an overload of WebCore::protocolIsJavaScript() that takes a StringView to
3104         avoid the need for a caller to allocate a new String object when converting
3105         from a StringView to a String. We are not using this functionality at the moment,
3106         but we will in the patch for <https://bugs.webkit.org/show_bug.cgi?id=170925>.
3107
3108         No functionality has changed. So, no new tests.
3109
3110         * platform/URL.cpp: Remove an outdated comment about protocolIs(StringView, const char*).
3111         This overload was removed in r212508.
3112         (WebCore::protocolIsInternal): Added.
3113         (WebCore::protocolIs): Implemented in terms of WebCore::protocolIsInternal().
3114         (WebCore::URL::protocolIs): Ditto.
3115         (WebCore::protocolIsJavaScript): Added; overload that takes a StringView.
3116         (WebCore::mimeTypeFromDataURL): Modified to use WebCore::protocolIsInternal().
3117         * platform/URL.h:
3118
3119 2017-04-28  Andy Estes  <aestes@apple.com>
3120
3121         [macOS] WebPlaybackControlsManager needs to know when the selected text or audio track changes
3122         https://bugs.webkit.org/show_bug.cgi?id=171434
3123         <rdar://problem/31887922>
3124
3125         Reviewed by Eric Carlson.
3126
3127         * dom/GenericEventQueue.cpp:
3128         (WebCore::GenericEventQueue::hasPendingEventsOfType): Added to check if a pending event
3129         exists of a certain type.
3130         * dom/GenericEventQueue.h:
3131         * html/HTMLMediaElement.cpp:
3132         (WebCore::HTMLMediaElement::setSelectedTextTrack): Even if no track modes change, fire a
3133         change event when the track to select is off or automatic so that
3134         WebPlaybackSessionModelMediaElement detects the change.
3135         * html/track/TrackListBase.cpp:
3136         (TrackListBase::isChangeEventScheduled): Returns true if m_asyncEventQueue has a pending
3137         change event.
3138         * html/track/TrackListBase.h:
3139         * platform/cocoa/WebPlaybackSessionModel.h:
3140         (WebCore::WebPlaybackSessionModelClient::audioMediaSelectionIndexChanged):
3141         (WebCore::WebPlaybackSessionModelClient::legibleMediaSelectionIndexChanged):
3142         * platform/cocoa/WebPlaybackSessionModelMediaElement.h:
3143         * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
3144         (WebCore::WebPlaybackSessionModelMediaElement::setMediaElement): Registered/unregistered for
3145         the change event on the audio and text tracks.
3146         (WebCore::WebPlaybackSessionModelMediaElement::updateForEventName): Called
3147         updateMediaSelectionIndices() when the change event fires.
3148         (WebCore::WebPlaybackSessionModelMediaElement::updateMediaSelectionOptions): Renamed from
3149         updateLegibleOptions().
3150         (WebCore::WebPlaybackSessionModelMediaElement::updateMediaSelectionIndices): Called
3151         audioMediaSelectionIndexChanged() and legibleMediaSelectionIndexChanged() on m_clients with
3152         the updated indices.
3153         (WebCore::WebPlaybackSessionModelMediaElement::legibleMediaSelectedIndex): Fixed a bug
3154         where selectedIndex would never be set to offIndex if offIndex is 0 (which it usually is).
3155         (WebCore::WebPlaybackSessionModelMediaElement::updateLegibleOptions): Renamed to
3156         updateMediaSelectionOptions().
3157         * platform/mac/WebPlaybackControlsManager.h:
3158         * platform/mac/WebPlaybackControlsManager.mm:
3159         (-[WebPlaybackControlsManager setAudioMediaSelectionIndex:]): Set
3160         _currentAudioTouchBarMediaSelectionOption to the object at selectedIndex and manually
3161         triggered a KVO notification. We can't call -setCurrentAudioTouchBarMediaSelectionOption:
3162         here since that will send a message back to the Web process.
3163         (-[WebPlaybackControlsManager setLegibleMediaSelectionIndex:]): Ditto for
3164         _currentLegibleTouchBarMediaSelectionOption.
3165         * platform/mac/WebPlaybackSessionInterfaceMac.h:
3166         * platform/mac/WebPlaybackSessionInterfaceMac.mm:
3167         (WebCore::WebPlaybackSessionInterfaceMac::audioMediaSelectionIndexChanged): Called
3168         -[WebPlaybackControlsManager setAudioMediaSelectionIndex:].
3169         (WebCore::WebPlaybackSessionInterfaceMac::legibleMediaSelectionIndexChanged): Called
3170         -[WebPlaybackControlsManager setLegibleMediaSelectionIndex:].
3171
3172 2017-04-28  Chris Dumez  <cdumez@apple.com>
3173
3174         Range.getClientRects() / getBoundingClientRect() should return DOMRect types
3175         https://bugs.webkit.org/show_bug.cgi?id=171393
3176
3177         Reviewed by Simon Fraser.
3178
3179         Range.getClientRects() / getBoundingClientRect() should return DOMRect types:
3180         - https://drafts.csswg.org/cssom-view/#extensions-to-the-range-interface
3181
3182         Test: fast/dom/Range/getBoundingClientRect-getClientRects-return-type.html
3183
3184         * CMakeLists.txt:
3185         * WebCore.xcodeproj/project.pbxproj:
3186         * dom/DOMRect.cpp: Copied from Source/WebCore/dom/DOMRect.h.
3187         (WebCore::createDOMRectVector):
3188         * dom/DOMRect.h:
3189         * dom/Element.cpp:
3190         (WebCore::Element::getClientRects):
3191         * dom/Range.cpp:
3192         (WebCore::Range::getClientRects):
3193         (WebCore::Range::getBoundingClientRect):
3194         * dom/Range.h:
3195         * dom/Range.idl:
3196
3197 2017-04-28  Chris Dumez  <cdumez@apple.com>
3198
3199         Tweak window.open features argument tokenizer to match HTML standard and Edge
3200         https://bugs.webkit.org/show_bug.cgi?id=170548
3201
3202         Reviewed by Geoffrey Garen.
3203
3204         Update window.open() features argument tokenizer to match HTML standard:
3205         - https://html.spec.whatwg.org/#concept-window-open-features-tokenize
3206
3207         Also update window.open() to return null instead of the window when
3208         the 'noopener' feature is activated, as per:
3209         - https://html.spec.whatwg.org/#dom-open (Step 10)
3210
3211         No new tests, rebaselined existing test.
3212
3213         * page/DOMWindow.cpp:
3214         (WebCore::DOMWindow::createWindow):
3215         Update window.open() to return null instead of the window when
3216         the 'noopener' feature is activated, as per:
3217         - https://html.spec.whatwg.org/#dom-open (Step 10)
3218
3219         * page/WindowFeatures.cpp:
3220         (WebCore::isSeparator):
3221         Treat all ASCII spaces as feature separators, as per:
3222         - https://html.spec.whatwg.org/#feature-separator
3223         This has the effect of adding U+000C (FormFeed) as a separator.
3224
3225         (WebCore::processFeaturesString):
3226         Align tokenizing code with the specification:
3227         - https://html.spec.whatwg.org/#concept-window-open-features-tokenize
3228         In particular, the following changes were made:
3229         - After the key, skip to first '=', but don't skip past a ',' or a non-separator.
3230           The "or a non-separator" part is new in the spec (step 3.6.1) and is now implemented.
3231         - After looking for the '=', only treat what follows as a value if the current character
3232           is a separator. This is as per step 7 in the spec.
3233         These changes now cause us to parse 'foo noopener=1' as ('foo', ''), ('noopener', '1').
3234
3235 2017-04-28  Eric Carlson  <eric.carlson@apple.com>
3236
3237         Implement ondevicechange
3238         https://bugs.webkit.org/show_bug.cgi?id=169872
3239
3240         Unreviewed, remove some dead code accidentally committed in r215929.
3241
3242         * platform/mediastream/CaptureDeviceManager.cpp:
3243
3244 2017-04-28  Chris Dumez  <cdumez@apple.com>
3245
3246         Update DOMTokenList.replace() to match the latest DOM specification
3247         https://bugs.webkit.org/show_bug.cgi?id=171388
3248
3249         Reviewed by Alex Christensen.
3250
3251         Update DOMTokenList.replace() to match the latest DOM specification after:
3252         - https://github.com/whatwg/dom/issues/442
3253         - https://github.com/whatwg/infra/pull/126
3254
3255         The latest spec text is at:
3256         - https://dom.spec.whatwg.org/#dom-domtokenlist-replace
3257         - https://infra.spec.whatwg.org/#set-replace
3258
3259         The behavior change in this patch causes (a, b, c).replace(a, c) to return
3260         (c, b) instead of (b, c). This new behavior is aligned with Firefox as well.
3261
3262         No new tests, updated existing test.
3263
3264         * html/DOMTokenList.cpp:
3265         (WebCore::DOMTokenList::replace):
3266
3267 2017-04-28  Brady Eidson  <beidson@apple.com>
3268
3269         Start of support for multiple WebsiteDataStore/SessionIDs per process
3270         https://bugs.webkit.org/show_bug.cgi?id=171422
3271
3272         Reviewed by Geoffrey Garen.
3273
3274         Covered by API tests.
3275
3276         * platform/network/NetworkStorageSession.h:
3277         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
3278         (WebCore::NetworkStorageSession::ensureSession):
3279         * platform/spi/cf/CFNetworkSPI.h:
3280
3281 2017-04-28  Chris Dumez  <cdumez@apple.com>
3282
3283         URLSearchParams should be reflective
3284         https://bugs.webkit.org/show_bug.cgi?id=171345
3285
3286         Reviewed by Alex Christensen.
3287
3288         There was a bug in our implementation of [1] where we would replace
3289         '+' with 0x20 *after* URL-decoding the string, instead of *before*.
3290         This was causing us to replace URL-encoded '+' characters with 0x20.
3291
3292         [1] https://url.spec.whatwg.org/#concept-urlencoded-parser
3293
3294         No new tests, updated existing test.
3295
3296         * platform/URLParser.cpp:
3297
3298 2017-04-28  Youenn Fablet  <youenn@apple.com>
3299
3300         Adding a runtime flag specific to MediaDevices
3301         https://bugs.webkit.org/show_bug.cgi?id=171433
3302
3303         Reviewed by Geoffrey Garen.
3304
3305         Covered by existing tests.
3306
3307         Adding a preference for MediaDevices.
3308         Setting media devices runtime flag to false by default.
3309         Setting peer connection and media stream flags to true by default.
3310         Activating mediaDevices and getUserMedia Navigator properties based on media devices flag.
3311
3312         * Modules/mediastream/NavigatorMediaDevices.idl:
3313         * Modules/mediastream/NavigatorUserMedia.idl:
3314         * page/RuntimeEnabledFeatures.cpp:
3315         (WebCore::RuntimeEnabledFeatures::RuntimeEnabledFeatures):
3316         * page/RuntimeEnabledFeatures.h:
3317         (WebCore::RuntimeEnabledFeatures::mediaDevicesEnabled):
3318         (WebCore::RuntimeEnabledFeatures::setMediaDevicesEnabled):
3319
3320 2017-04-28  Eric Carlson  <eric.carlson@apple.com>
3321
3322         Implement ondevicechange
3323         https://bugs.webkit.org/show_bug.cgi?id=169872
3324
3325         Unreviewed, fix test crash.
3326
3327         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
3328         (WebCore::RealtimeMediaSourceCenter::addDevicesChangedObserver): "nextToken" must be static.
3329
3330 2017-04-28  Dean Jackson  <dino@apple.com>
3331
3332         [WebGPU] Label MTLCommandQueues with a prefix for internal telemetry
3333         https://bugs.webkit.org/show_bug.cgi?id=171441
3334         <rdar://problem/31826915>
3335
3336         Reviewed by Tim Horton.
3337
3338         Prefix any label that is set by the WebGPU API so that
3339         our telemetry can identify the use. Don't expose that
3340         prefix to the API though.
3341
3342         New API Test: GPUCommandQueue
3343
3344         * platform/graphics/cocoa/GPUCommandQueueMetal.mm:
3345         (WebCore::GPUCommandQueue::GPUCommandQueue):
3346         (WebCore::GPUCommandQueue::label):
3347         (WebCore::GPUCommandQueue::setLabel):
3348
3349 2017-04-28  Joanmarie Diggs  <jdiggs@igalia.com>
3350
3351         [ATK] aria-modal="true" should be exposed via ATK_STATE_MODAL
3352         https://bugs.webkit.org/show_bug.cgi?id=171188
3353
3354         Reviewed by Chris Fleizach.
3355
3356         Include ATK_STATE_MODAL in the AtkObject's state set if the accessible
3357         element's node is the current ARIA modal node.
3358
3359         Test: accessibility/gtk/aria-modal-state-exposed.html
3360
3361         * accessibility/AccessibilityObject.cpp:
3362         (WebCore::AccessibilityObject::isAriaModalNode):
3363         * accessibility/AccessibilityObject.h:
3364         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
3365         (setAtkStateSetFromCoreObject):
3366
3367 2017-04-28  Eric Carlson  <eric.carlson@apple.com>
3368
3369         Implement ondevicechange
3370         https://bugs.webkit.org/show_bug.cgi?id=169872
3371         <rdar://problem/28945035>
3372
3373         Reviewed by Jer Noble.
3374
3375         Test: fast/mediastream/device-change-event.html
3376
3377         * Modules/mediastream/MediaDevices.cpp:
3378         (WebCore::MediaDevices::MediaDevices): Register for devicechange callbacks.
3379         (WebCore::MediaDevices::~MediaDevices): Unregister.
3380         (WebCore::MediaDevices::scheduledEventTimerFired):
3381         * Modules/mediastream/MediaDevices.h:
3382         * Modules/mediastream/MediaDevices.idl:
3383
3384         * Modules/mediastream/MediaDevicesEnumerationRequest.cpp:
3385         (WebCore::MediaDevicesEnumerationRequest::setDeviceInfo): Remove unnecessary instance variables.
3386         * Modules/mediastream/MediaDevicesEnumerationRequest.h:
3387
3388         * Modules/mediastream/MediaDevicesRequest.cpp:
3389         (WebCore::MediaDevicesRequest::start): Remove m_idHashSalt, it isn't used. RealtimeMediaSourceCenter
3390         now has the method to hash ids and group IDs.
3391         (WebCore::hashString): Deleted.
3392         (WebCore::MediaDevicesRequest::hashID): Deleted.
3393         * Modules/mediastream/MediaDevicesRequest.h:
3394
3395         * dom/Document.h:
3396         (WebCore::Document::setDeviceIDHashSalt):
3397         (WebCore::Document::deviceIDHashSalt):
3398
3399         * dom/EventNames.h: Add devicechange.
3400
3401         * dom/EventTargetFactory.in: Add MediaDevices.
3402
3403         * html/HTMLAttributeNames.in: Add ondevicechange.
3404
3405         * platform/mediastream/CaptureDeviceManager.cpp:
3406         (WebCore::CaptureDeviceManager::captureDeviceFromPersistentID): Renamed from captureDeviceFromDeviceID
3407         and changed to return a std::optional<CaptureDevice>.
3408         (WebCore::CaptureDeviceManager::captureDeviceFromDeviceID): Deleted.
3409
3410         * platform/mediastream/RealtimeMediaSourceCenter.cpp:
3411         (WebCore::addStringToSHA): New, add string bytes to SHA1. Moved from MediaDevicesRequest
3412         so we can use for in testing.
3413         (WebCore::RealtimeMediaSourceCenter::hashStringWithSalt): Generate hash for a string with a
3414         salt. Moved from MediaDevicesRequest so we can use for in testing.
3415         (WebCore::RealtimeMediaSourceCenter::captureDeviceWithUniqueID): Find a CaptureDevice given 
3416         a unique ID and the process hash salt.
3417         (WebCore::RealtimeMediaSourceCenter::setDeviceEnabled): Enable/disable a device. Used for
3418         layout tests only.
3419         (WebCore::RealtimeMediaSourceCenter::addDevicesChangedObserver): Add a devices changed listener.
3420         (WebCore::RealtimeMediaSourceCenter::removeDevicesChangedObserver): Remove a listener.
3421         (WebCore::RealtimeMediaSourceCenter::captureDevicesChanged): Notify listeners.
3422         * platform/mediastream/RealtimeMediaSourceCenter.h:
3423
3424         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
3425         (WebCore::AVCaptureDeviceManager::addDevicesChangedObserver): Update for change to captureDeviceFromDeviceID.
3426
3427         * platform/mock/MockRealtimeMediaSource.cpp:
3428         (WebCore::MockRealtimeMediaSource::audioDevices): All devices are enabled by default.
3429         (WebCore::MockRealtimeMediaSource::videoDevices): Ditto.
3430
3431         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
3432         (WebCore::MockRealtimeMediaSourceCenter::createMediaStream): Drive-by cleanup: use the vector
3433         of devices instead of making assumptions about the number.
3434         (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamDevices): Only include enabled devices.
3435         (WebCore::MockRealtimeMediaSourceCenter::setDeviceEnabled): Enable or disable a device.
3436         * platform/mock/MockRealtimeMediaSourceCenter.h:
3437
3438         * testing/Internals.cpp:
3439         (WebCore::Internals::setMediaDeviceState): Enable or disable a mock capture device.
3440         * testing/Internals.h:
3441         * testing/Internals.idl:
3442
3443 2017-04-28  Alex Christensen  <achristensen@webkit.org>
3444
3445         Fix memory corruption issue after r215883.
3446         https://bugs.webkit.org/show_bug.cgi?id=171365
3447
3448         Reviewed by Brady Eidson.
3449
3450         This fixes a crash when starting WebKit2.
3451
3452         * platform/network/cf/NetworkStorageSessionCFNet.cpp:
3453         (WebCore::NetworkStorageSession::NetworkStorageSession):
3454         Initialize m_platformCookieStorage with the default constructor of RetainPtr,
3455         then call NetworkStorageSession::cookieStorage which checks m_platformCookieStorage
3456         for null.  It was checking uninitialized memory when we had m_platformCookieStorage
3457         in the initializer list.
3458
3459 2017-04-28  Joanmarie Diggs  <jdiggs@igalia.com>
3460
3461         AX: Implement aria-value support for focusable separators
3462         https://bugs.webkit.org/show_bug.cgi?id=171169
3463
3464         Reviewed by Chris Fleizach.
3465
3466         Add SplitterRole to the roles which support range value and are considered a range
3467         control, as long as the SplitterRole element is focusable. Also replace ATK's role-
3468         based check with a call to supportsRangeValue() when determining if the AtkValue
3469         interface should be implemented.
3470
3471         Test: accessibility/separator-values.html
3472
3473         * accessibility/AccessibilityObject.cpp:
3474         (WebCore::AccessibilityObject::isRangeControl):
3475         (WebCore::AccessibilityObject::supportsRangeValue):
3476         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
3477         (getInterfaceMaskFromObject):
3478
3479 2017-04-28  Joanmarie Diggs  <jdiggs@igalia.com>
3480
3481         [ATK] GridCellRole should implement AtkTableCell (regression?)
3482         https://bugs.webkit.org/show_bug.cgi?id=171179
3483
3484         Reviewed by Chris Fleizach.
3485
3486         Add GridCellRole to the group of roles which should implement AtkTableCell.
3487
3488         Test: accessibility/gtk/interface-table-cell.html
3489
3490         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
3491         (getInterfaceMaskFromObject):
3492
3493 2017-04-28  Miguel Gomez  <magomez@igalia.com>
3494
3495         REGRESSION(r215211): [GTK] Several webgl related tests are failing
3496         https://bugs.webkit.org/show_bug.cgi?id=170730
3497
3498         Reviewed by Said Abou-Hallawa.
3499
3500         There is a wrong situation in the image decoders where the complete data has been assigned
3501         to them but the size of the image hasn't been decoded yet. This is causing rendering
3502         issues in webgl when decoding the images used as textures. To fix this, we refactor how the
3503         encoded data status is stored to avoid that situation: the status is handled completely
3504         by ImageDecoder.h, and it's the one forcing the decode of the size when data gets assigned
3505         to the decoders.
3506
3507         Covered by existent tests.
3508
3509         * platform/image-decoders/ImageDecoder.h:
3510         (WebCore::ImageDecoder::isAllDataReceived):
3511         (WebCore::ImageDecoder::setData):
3512         (WebCore::ImageDecoder::encodedDataStatus):
3513         (WebCore::ImageDecoder::isSizeAvailable):
3514         (WebCore::ImageDecoder::setSize):
3515         (WebCore::ImageDecoder::setFailed):
3516         (WebCore::ImageDecoder::failed):
3517         * platform/image-decoders/bmp/BMPImageDecoder.cpp:
3518         (WebCore::BMPImageDecoder::frameBufferAtIndex):
3519         (WebCore::BMPImageDecoder::decode):
3520         (WebCore::BMPImageDecoder::encodedDataStatus): Deleted.
3521         * platform/image-decoders/bmp/BMPImageDecoder.h:
3522         * platform/image-decoders/gif/GIFImageDecoder.cpp:
3523         (WebCore::GIFImageDecoder::frameCount):
3524         (WebCore::GIFImageDecoder::frameBufferAtIndex):
3525         (WebCore::GIFImageDecoder::decode):
3526         (WebCore::GIFImageDecoder::encodedDataStatus): Deleted.
3527         * platform/image-decoders/gif/GIFImageDecoder.h:
3528         * platform/image-decoders/ico/ICOImageDecoder.cpp:
3529         (WebCore::ICOImageDecoder::setData):
3530         (WebCore::ICOImageDecoder::frameCount):
3531         (WebCore::ICOImageDecoder::frameBufferAtIndex):
3532         (WebCore::ICOImageDecoder::setDataForPNGDecoderAtIndex):
3533         (WebCore::ICOImageDecoder::decode):
3534         (WebCore::ICOImageDecoder::decodeAtIndex):
3535         (WebCore::ICOImageDecoder::encodedDataStatus): Deleted.
3536         * platform/image-decoders/ico/ICOImageDecoder.h:
3537         * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
3538         (WebCore::JPEGImageDecoder::frameBufferAtIndex):
3539         (WebCore::JPEGImageDecoder::decode):
3540         (WebCore::JPEGImageDecoder::encodedDataStatus): Deleted.
3541         * platform/image-decoders/jpeg/JPEGImageDecoder.h:
3542         * platform/image-decoders/png/PNGImageDecoder.cpp:
3543         (WebCore::PNGImageDecoder::frameBufferAtIndex):
3544         (WebCore::PNGImageDecoder::decode):
3545         (WebCore::PNGImageDecoder::encodedDataStatus): Deleted.
3546         * platform/image-decoders/png/PNGImageDecoder.h:
3547         * platform/image-decoders/webp/WEBPImageDecoder.cpp:
3548         (WebCore::WEBPImageDecoder::frameBufferAtIndex):
3549         (WebCore::WEBPImageDecoder::decode):
3550         (WebCore::WEBPImageDecoder::encodedDataStatus): Deleted.
3551         * platform/image-decoders/webp/WEBPImageDecoder.h:
3552
3553 2017-04-27  Carlos Garcia Campos  <cgarcia@igalia.com>
3554
3555         Move UUID from WebCore/platform to WTF
3556         https://bugs.webkit.org/show_bug.cgi?id=171372
3557
3558         Reviewed by Michael Catanzaro.
3559
3560         UUID only contains createCanonicalUUIDString() that is platform independent and doesn't depend on anything from
3561         WebCore, only from WTF.
3562
3563         * CMakeLists.txt:
3564         * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
3565         * Modules/mediacontrols/MediaControlsHost.cpp:
3566         * Modules/mediastream/RTCPeerConnection.cpp:
3567         * Modules/webaudio/MediaStreamAudioSource.cpp:
3568         * Modules/webdatabase/DatabaseTracker.cpp:
3569         * WebCore.order:
3570         * WebCore.xcodeproj/project.pbxproj:
3571         * editing/mac/EditorMac.mm:
3572         * fileapi/BlobURL.cpp:
3573         * loader/appcache/ApplicationCacheHost.cpp:
3574         * loader/appcache/ApplicationCacheStorage.cpp:
3575         * platform/URL.cpp:
3576         * platform/glib/FileSystemGlib.cpp:
3577         * platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:
3578         * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
3579         * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
3580         * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
3581         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
3582         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
3583         * platform/mediastream/CaptureDeviceManager.cpp:
3584         * platform/mediastream/MediaStreamPrivate.h:
3585         * platform/mediastream/MediaStreamTrackPrivate.cpp:
3586         * platform/mediastream/RealtimeMediaSource.cpp:
3587         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
3588         * platform/mediastream/mac/AVMediaCaptureSource.mm:
3589         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
3590         * platform/mock/MockRealtimeAudioSource.cpp:
3591         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
3592         * platform/mock/MockRealtimeVideoSource.cpp:
3593         * testing/MockCDMFactory.cpp:
3594
3595 2017-04-27  Alex Christensen  <achristensen@webkit.org>
3596
3597         Make navigation policy checking more robust
3598         https://bugs.webkit.org/show_bug.cgi?id=171409
3599         <rdar://problem/31489248>
3600
3601         Reviewed by Geoffrey Garen.
3602
3603         No change in behavior.  Just added a protectedThis to a lambda and made the functions non-copyable.
3604
3605         * loader/DocumentLoader.cpp:
3606         (WebCore::DocumentLoader::willSendRequest):
3607         * loader/PolicyCallback.cpp:
3608         (WebCore::PolicyCallback::set):
3609         (WebCore::PolicyCallback::clear): Deleted.
3610         * loader/PolicyCallback.h:
3611         * loader/PolicyChecker.cpp:
3612         (WebCore::PolicyChecker::cancelCheck):
3613         (WebCore::PolicyChecker::stopCheck):
3614         (WebCore::PolicyChecker::continueAfterNavigationPolicy):
3615         (WebCore::PolicyChecker::continueAfterNewWindowPolicy):
3616         (WebCore::PolicyChecker::continueAfterContentPolicy):
3617
3618 2017-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
3619
3620         Data interaction should not load pasteboard content before performing the data operation
3621         https://bugs.webkit.org/show_bug.cgi?id=171414
3622         <rdar://problem/31878197>
3623
3624         Reviewed by Tim Horton.
3625
3626         When interacting with a link, we should not try to fetch pasteboard contents for the URL UTI type before
3627         performing the data operation. Teaches DragController to know whether it is allowed to load data from the
3628         dragging pasteboard, and uses this information in DragController::dragOperation to determine whether to use
3629         DragData::containsURLTypeIdentifier or DragData::containsURL.
3630
3631         * page/DragController.cpp:
3632         (WebCore::DragController::DragController):
3633         (WebCore::DragController::performDragOperation):
3634         * page/DragController.h:
3635         (WebCore::DragController::canLoadDataFromDraggingPasteboard):
3636         * page/mac/DragControllerMac.mm:
3637         (WebCore::DragController::dragOperation):
3638         * platform/DragData.h:
3639         * platform/ios/WebItemProviderPasteboard.mm:
3640         (-[WebItemProviderPasteboard _preLoadedDataConformingToType:forItemProviderAtIndex:]):
3641         * platform/mac/DragDataMac.mm:
3642         (WebCore::DragData::containsURLTypeIdentifier):
3643
3644 2017-04-27  Joseph Pecoraro  <pecoraro@apple.com>
3645
3646         Support for promise rejection events (unhandledrejection)
3647         https://bugs.webkit.org/show_bug.cgi?id=150358
3648         <rdar://problem/28441651>
3649
3650         Reviewed by Saam Barati.
3651
3652         Patch by Joseph Pecoraro and Yusuke Suzuki.
3653
3654         Implement support for the `onunhandledrejection` and `rejectionhandled` events.
3655         They dispatch a new PromiseRejectionEvent using the ES6 HostPromiseRejectionTracker hook:
3656         https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker
3657         https://html.spec.whatwg.org/multipage/webappapis.html#unhandled-promise-rejections
3658
3659         This is currently implemented only for Documents and not yet Web Workers.
3660
3661         Tests: js/dom/unhandled-promise-rejection-basic.html
3662                js/dom/unhandled-promise-rejection-bindings-type-error.html
3663                js/dom/unhandled-promise-rejection-console-no-report.html
3664                js/dom/unhandled-promise-rejection-console-report.html
3665                js/dom/unhandled-promise-rejection-handle-during-event.html
3666                js/dom/unhandled-promise-rejection-handle-in-handler.html
3667                js/dom/unhandled-promise-rejection-handle.html
3668                js/dom/unhandled-promise-rejection-order.html
3669
3670         * CMakeLists.txt:
3671         * DerivedSources.cpp:
3672         * DerivedSources.make:
3673         * WebCore.xcodeproj/project.pbxproj:
3674         * dom/DOMAllInOne.cpp:
3675         New files.
3676
3677         * bindings/scripts/CodeGenerator.pm:
3678         (IsPromiseType):
3679         * bindings/scripts/CodeGeneratorJS.pm:
3680         (AddToIncludesForIDLType):
3681         (GetBaseIDLType):
3682         Binding support for Promise<T> attributes.
3683
3684         * bindings/js/JSDOMConvert.h:
3685         * bindings/js/JSDOMConvertPromise.h: Copied from Source/JavaScriptCore/runtime/JSPromise.h.
3686         (WebCore::Converter<IDLPromise<T>>::convert):
3687         (WebCore::JSConverter<IDLPromise<T>>::convert):
3688         Promise<T> binding conversion is currently unimplemented, which only means
3689         web developers creating their own PromiseRejectionEvent will not get
3690         autowrapping of values assigned to `promise` in event initialization.
3691         Engine generated events will have expected behavior.
3692
3693         * bindings/js/JSDOMWindowBase.cpp:
3694         (WebCore::JSDOMWindowBase::promiseRejectionTracker):
3695         * bindings/js/JSDOMWindowBase.h:
3696         * bindings/js/JSWorkerGlobalScopeBase.cpp:
3697         Implement HostPromiseRejectionTracker hook for Document but not Worker.
3698         Passes through to the ScriptExecutionContext's tracker.
3699
3700         * bindings/js/JSMainThreadExecState.cpp:
3701         (WebCore::JSMainThreadExecState::didLeaveScriptContext):
3702         * bindings/js/JSMainThreadExecState.h:
3703         (WebCore::JSMainThreadExecState::~JSMainThreadExecState):
3704         When completing script execution and performing microtasks notify
3705         about rejected promises. Technically this should go inside of
3706         performing a microtask checkpoint, except lacking EventLoop
3707         concepts we use ScriptExecutionState.
3708
3709         * dom/EventNames.h:
3710         * dom/EventNames.in:
3711         * dom/PromiseRejectionEvent.cpp: Added.
3712         (WebCore::PromiseRejectionEvent::PromiseRejectionEvent):
3713         (WebCore::PromiseRejectionEvent::~PromiseRejectionEvent):
3714         * dom/PromiseRejectionEvent.h: Added.
3715         * dom/PromiseRejectionEvent.idl: Added.
3716         New PromiseRejectionEvent event interface.
3717
3718         * dom/GlobalEventHandlers.idl:
3719         New onunhandledrejection and onrejectionhandled.
3720
3721         * dom/RejectedPromiseTracker.cpp: Added.
3722         (WebCore::RejectedPromise::RejectedPromise):
3723         (WebCore::RejectedPromise::globalObject):
3724         (WebCore::RejectedPromise::promise):
3725         (WebCore::UnhandledPromise::UnhandledPromise):
3726         (WebCore::UnhandledPromise::callStack):
3727         (WebCore::RejectedPromiseTracker::RejectedPromiseTracker):
3728         (WebCore::RejectedPromiseTracker::~RejectedPromiseTracker):
3729         (WebCore::createScriptCallStackFromReason):
3730         (WebCore::RejectedPromiseTracker::promiseRejected):
3731         (WebCore::RejectedPromiseTracker::promiseHandled):
3732         (WebCore::RejectedPromiseTracker::processQueueSoon):
3733         (WebCore::RejectedPromiseTracker::reportUnhandledRejections):
3734         (WebCore::RejectedPromiseTracker::reportRejectionHandled):
3735         * dom/RejectedPromiseTracker.h: Added.
3736         Track and report rejected promises. The promises are tracked weakly
3737         allowing them to be collected before they are reported. When reporting
3738         we dispatch PromiseRejectionEvent events, and if the default is not
3739         prevented we log a message to the console.
3740
3741         * dom/ScriptExecutionContext.cpp:
3742         (WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
3743         (WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
3744         * dom/ScriptExecutionContext.h:
3745         (WebCore::ScriptExecutionContext::ensureRejectedPromiseTracker):
3746         Each ScriptExecutionContext can own a rejected promise tracker.
3747
3748         * html/HTMLMediaElement.cpp:
3749         (WebCore::HTMLMediaElement::pauseInternal):
3750         https://html.spec.whatwg.org/multipage/embedded-content.html#internal-pause-steps
3751         Internal pause steps say to timeupdate, pause, and rejecting pending play promises
3752         should all happen in a queued task. Here the first two actions are already scheduled
3753         on tasks, but rejecting play promises was not being done in a task, so this makes
3754         that change.
3755
3756         * Modules/streams/ReadableStream.js:
3757         (pipeThrough):
3758         * Modules/streams/ReadableStreamInternals.js:
3759         (readableStreamReaderGenericInitialize):
3760         (readableStreamError):
3761         (readableStreamReaderGenericRelease):
3762         Satisfy parts of the Streams specification which state to set the
3763         [[PromiseIsHandled]] internal state of promises created internally
3764         by the Streams APIs. This prevents some internal promises from
3765         appearing as unhandled promise rejections.
3766
3767 2017-04-27  Chris Dumez  <cdumez@apple.com>
3768
3769         Align colspan/rowspan limits with the latest HTML specification
3770         https://bugs.webkit.org/show_bug.cgi?id=171322
3771
3772         Reviewed by Darin Adler.
3773
3774         Align colspan/rowspan limits with the latest HTML specification after:
3775         - https://github.com/whatwg/html/pull/1993
3776
3777         The following changes were made:
3778         - Our rowspan limit was raised from 8190 to 65534
3779         - A colspan limit of 1000 was introduced. Blink has UseCounter data showing that
3780           colspans over 1000 are extremely rare and Gecko has data showing that when we
3781           get a colspan greater than 1000, it is usually a bug. Therefore, this change
3782           should be fine.
3783         - The limits are now properly reflected via the IDL attributes instead of lying
3784           to the Web about the colspan / rowspan we are using internally.
3785
3786         Test: imported/w3c/web-platform-tests/html/semantics/tabular-data/processing-model-1/span-limits.html
3787
3788         * html/HTMLTableCellElement.cpp:
3789         (WebCore::HTMLTableCellElement::colSpan):
3790         (WebCore::HTMLTableCellElement::rowSpan):
3791         (WebCore::HTMLTableCellElement::rowSpanForBindings):
3792         (WebCore::HTMLTableCellElement::setColSpan):
3793         * html/HTMLTableCellElement.h:
3794         * html/HTMLTableCellElement.idl:
3795         * html/parser/HTMLParserIdioms.cpp:
3796         (WebCore::parseHTMLIntegerInternal):
3797         (WebCore::parseHTMLInteger):
3798         (WebCore::parseHTMLNonNegativeInteger):
3799         (WebCore::parseValidHTMLNonNegativeIntegerInternal):
3800         (WebCore::parseHTTPRefreshInternal):
3801         * html/parser/HTMLParserIdioms.h:
3802         (WebCore::parseHTMLInteger):
3803         (WebCore::parseHTMLNonNegativeInteger):
3804
3805         (WebCore::clampHTMLNonNegativeIntegerToRange):
3806         Add utility function to implement:
3807         - https://html.spec.whatwg.org/#clamped-to-the-range
3808
3809 2017-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
3810
3811         WKUIDelegatePrivate needs a hook to vend data used to initialize item providers for data interaction
3812         https://bugs.webkit.org/show_bug.cgi?id=171386
3813         <rdar://problem/31557237>
3814
3815         Reviewed by Beth Dakin.
3816
3817         Teach WebItemProviderPasteboard to remember what WebItemProviderRegistrationInfoList it was initialized with
3818         when beginning a drag. This information is cleared out the next time the list of item providers is set to
3819         something different, which happens when the data interaction session concludes.
3820
3821         * platform/ios/WebItemProviderPasteboard.h:
3822         * platform/ios/WebItemProviderPasteboard.mm:
3823         (-[WebItemProviderPasteboard init]):
3824         (-[WebItemProviderPasteboard setItemProviders:]):
3825         (-[WebItemProviderPasteboard setItemsUsingRegistrationInfoLists:]):
3826         (-[WebItemProviderPasteboard registrationInfoAtIndex:]):
3827         (-[WebItemProviderPasteboard itemProviderAtIndex:]):
3828
3829 2017-04-27  Brady Eidson  <beidson@apple.com>
3830
3831         Refactor SessionID to support multiple non-ephemeral (persistent) sessions.
3832         https://bugs.webkit.org/show_bug.cgi?id=171367
3833
3834         Reviewed by Andy Estes.
3835
3836         This is also a nice general cleanup of SessionID, including privatizing the "arbitrary number" constructor
3837         and moving encode/decode into the class.
3838
3839         No new tests (Refactor, no behavior change yet).
3840
3841         * CMakeLists.txt:
3842         * WebCore.xcodeproj/project.pbxproj:
3843         
3844         * page/SessionID.cpp: Added.
3845         (WebCore::SessionID::generatePersistentSessionID):
3846         (WebCore::SessionID::generateEphemeralSessionID):
3847         (WebCore::SessionID::enableGenerationProtection):
3848         
3849         * page/SessionID.h:
3850         (WebCore::SessionID::SessionID):
3851         (WebCore::SessionID::emptySessionID):
3852         (WebCore::SessionID::hashTableDeletedValue):
3853         (WebCore::SessionID::defaultSessionID):
3854         (WebCore::SessionID::legacyPrivateSessionID):
3855         (WebCore::SessionID::isValid):
3856         (WebCore::SessionID::isEphemeral):
3857         (WebCore::SessionID::encode):
3858         (WebCore::SessionID::decode):
3859         (WTF::HashTraits<WebCore::SessionID>::constructDeletedValue):
3860         (WTF::HashTraits<WebCore::SessionID>::isDeletedValue):
3861
3862 2017-04-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
3863
3864         Attempt to fix a PLT regression on Mac
3865         <rdar://problem/31826998>
3866
3867         Unreviewed.
3868
3869         Disable passing the TypeIdentifierHint to CGImageSourceCreateIncremental()
3870         on Mac for now.
3871
3872         * platform/graphics/cg/ImageDecoderCG.cpp:
3873         (WebCore::ImageDecoder::ImageDecoder):
3874
3875 2017-04-27  Daniel Bates  <dabates@apple.com>
3876
3877         Rename callerDOMWindow()/CallerDocument to incumbentDOMWindow()/IncumbentDocument
3878         https://bugs.webkit.org/show_bug.cgi?id=171145
3879
3880         Reviewed by Saam Barati.
3881
3882         Standardize on the terminology "incumbent" to refer to "most-recently-entered author
3883         function or script on the stack, or the author function or script that originally
3884         scheduled the currently-running callback" (1).
3885
3886         [1] <https://html.spec.whatwg.org/multipage/webappapis.html#realms-settings-objects-global-objects> (27 April 2017)
3887
3888         * bindings/js/JSDOMWindowBase.cpp:
3889         (WebCore::incumbentDOMWindow):
3890         (WebCore::callerDOMWindow): Deleted.
3891         * bindings/js/JSDOMWindowBase.h:
3892         * bindings/scripts/CodeGeneratorJS.pm:
3893         (GenerateCallWith):
3894         * bindings/scripts/test/JS/JSTestObj.cpp:
3895         (WebCore::jsTestObjPrototypeFunctionWithCallerDocumentArgumentCaller):
3896         (WebCore::jsTestObjPrototypeFunctionWithCallerWindowArgumentCaller):
3897         * bindings/scripts/test/TestObj.idl:
3898         * page/DOMWindow.idl:
3899
3900 2017-04-27  Youenn Fablet  <youenn@apple.com>
3901
3902         LayoutTest webrtc/datachannel/datachannel-event.html is a flaky crash
3903         https://bugs.webkit.org/show_bug.cgi?id=171092
3904         <rdar://problem/31748066>
3905
3906         Reviewed by Eric Carlson.
3907
3908         Covered by manual testing on iterating on the crashing tests.
3909         With the patch, they appear to no longer crash.
3910
3911         The current RTCPeerConnection/RTCController was expecting that peer connections would be stopped before the controller.
3912         This assumption is sometimes wrong.
3913         Adding clean-up on both sides so that if controller goes away, it notifies its peer connections that they are unregistered.
3914
3915         * Modules/mediastream/RTCController.cpp:
3916         (WebCore::RTCController::~RTCController):
3917         * Modules/mediastream/RTCController.h:
3918         * Modules/mediastream/RTCPeerConnection.cpp:
3919         (WebCore::RTCPeerConnection::create):
3920         (WebCore::RTCPeerConnection::~RTCPeerConnection):
3921         (WebCore::RTCPeerConnection::doStop):
3922         (WebCore::RTCPeerConnection::registerToController):
3923         (WebCore::RTCPeerConnection::unregisterFromController):
3924         (WebCore::RTCPeerConnection::rtcController): Deleted.
3925         * Modules/mediastream/RTCPeerConnection.h:
3926
3927 2017-04-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
3928
3929         REGRESSION(r213764): Async decoding of animated images is disabled for ImageDocument
3930         https://bugs.webkit.org/show_bug.cgi?id=170333
3931
3932         Reviewed by Simon Fraser.
3933
3934         The way the image drawing settings are transfered from the Settings to
3935         BitmapImage is problematic. The drawing settings are retrieved from the
3936         CachedImageObserver which store them in the constructor only if the
3937         CachedImage as a loader. In the case of ImageDocument, there isn't loader
3938         set in CachedImage so the settings of ImageDocument are not set. Also
3939         the CachedImage can be used after loading by another document which may
3940         have a different drawing settings.
3941
3942         The fix is to make BitmapImage reads the drawing settings every time it 
3943         is drawn as a foreground or background image in a RenderElement.
3944
3945         * html/canvas/CanvasRenderingContext2D.cpp:
3946         (WebCore::CanvasRenderingContext2D::drawImage):
3947         * loader/cache/CachedImage.cpp:
3948         (WebCore::CachedImage::CachedImageObserver::CachedImageObserver):
3949         * loader/cache/CachedImage.h:
3950         * platform/graphics/BitmapImage.cpp:
3951         (WebCore::BitmapImage::setDrawingSettings):
3952         (WebCore::BitmapImage::draw):
3953         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImages): I was
3954         trying to disable the async image decoding temporarily but this way will
3955         even prevent testing it until it is enabled. Disable it through WK1 and
3956         WK2 preferences.
3957         (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages):
3958         (WebCore::BitmapImage::advanceAnimation):
3959         * platform/graphics/BitmapImage.h:
3960         * platform/graphics/ImageObserver.h:
3961         * rendering/RenderBoxModelObject.cpp:
3962         (WebCore::RenderBoxModelObject::paintFillLayerExtended):
3963         * rendering/RenderImage.cpp:
3964         (WebCore::RenderImage::paintIntoRect):
3965
3966 2017-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
3967
3968         Performing data interaction with plain text into a contenteditable does not insert any content
3969         https://bugs.webkit.org/show_bug.cgi?id=171381
3970
3971         Reviewed by Tim Horton.
3972
3973         Attempt to read plain-text-conformant UTI types as kUTTypePlainText before reading them as kUTTypeText.
3974         This allows WebItemProviderPasteboard to properly materialize an NSString in -valuesForPasteboardType:
3975         inItemSet: using a pre-loaded NSData blob.
3976
3977         This scenario is covered by DataInteractionTests.ExternalSourceUTF8PlainTextOnly, but DataInteractionTests
3978         are temporarily disabled due to incompatibilities with the current internal SDK.
3979
3980         * platform/ios/PasteboardIOS.mm:
3981         (WebCore::readPasteboardWebContentDataForType):
3982
3983 2017-04-27  Chris Dumez  <cdumez@apple.com>
3984
3985         Element.getBoundingClientRect() / getClientRects() should return a DOMRect types
3986         https://bugs.webkit.org/show_bug.cgi?id=171226
3987
3988         Reviewed by Simon Fraser.
3989
3990         Element.getBoundingClientRect() / getClientRects() should return a DOMRect types
3991         as per:
3992         - https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface
3993
3994         DOMRect is compatible with ClientRect, which we used to return so the risk should
3995         be low.
3996
3997         Tests: fast/css/DOMRect-attributes-prototype.html
3998                fast/css/DOMRect-serialization.html
3999                fast/dom/Element/getClientRects-return-type.html
4000