2556b61be074fcceb58119611846d40124bc0dc0
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-02-07  Myles C. Maxfield  <mmaxfield@apple.com>
2
3         Move platform-independent parts of ComplexTextController out of mac/ subfolder
4         https://bugs.webkit.org/show_bug.cgi?id=167922
5
6         Reviewed by Jon Lee.
7
8         Just a mechanical git mv, and updating the Xcode projects.
9
10         No new tests because there is no behavior change.
11
12         * WebCore.xcodeproj/project.pbxproj:
13         * platform/graphics/ComplexTextController.cpp: Renamed from Source/WebCore/platform/graphics/mac/ComplexTextController.cpp.
14         * platform/graphics/ComplexTextController.h: Renamed from Source/WebCore/platform/graphics/mac/ComplexTextController.h.
15
16 2017-02-06  Carlos Garcia Campos  <cgarcia@igalia.com>
17
18         Overlay scrolling with iframe-s broken
19         https://bugs.webkit.org/show_bug.cgi?id=165056
20
21         Reviewed by Antonio Gomes.
22
23         Mouse press events for overlay scrollbars are ignored if there's a subframe under the scrollbar. This doesn't
24         happen with normal scrollbars, because the subframe is not really under the scrollbar, so events are always
25         correctly passed to the scrollbar. With overlay scrollbars, the hit test detects the scrollbar, but events are
26         always passed first to the subframe. Scrollbars are correctly updated on hover though, because
27         handleMouseMoveEvent checks the presence of scrollbars before checking for subframes and move events are
28         actually passed to both, the scrollbar and the subframe. Overlay scrollbars should always take precedence over
29         subframes to handle mouse press events, so we should check first if mouse is over a scrollbar and never pass the
30         event to a subframe in that case. Another problem is that the cursor is not updated either when the overlay
31         scrollbar is hovered and there's a subframe. This is because in handleMouseMoveEvent we pass the event to both
32         the scrollbar and subframe but we never update the cursor when a suframe was found. So, here again we need to make
33         an exception for scrollbars and upate the cursor when mouse is over the scrollbar even if a subframe was found.
34
35         Test: fast/scrolling/scroll-animator-overlay-scrollbars-clicked.html
36
37         * page/EventHandler.cpp:
38         (WebCore::EventHandler::handleMousePressEvent): Move the scrollbar check before the subframe check.
39         (WebCore::EventHandler::handleMouseMoveEvent): Update the cursor when hovering a scrollbar even if a subframe
40         was found.
41         (WebCore::EventHandler::updateLastScrollbarUnderMouse): Use an enum instead of a boolean for setLast parameter.
42         * page/EventHandler.h:
43
44 2017-02-06  Chris Dumez  <cdumez@apple.com>
45
46         Symbols exposed on cross-origin Window / Location objects should be configurable
47         https://bugs.webkit.org/show_bug.cgi?id=167920
48
49         Reviewed by Ryosuke Niwa.
50
51         Symbols exposed on cross-origin Window / Location objects should be configurable:
52         - https://html.spec.whatwg.org/#crossorigingetownpropertyhelper-(-o,-p-) (Step 1)
53
54         Firefox behaves as per specification.
55
56         No new tests, rebaselined existing test.
57
58         * bindings/js/JSDOMWindowCustom.cpp:
59         (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
60         * bindings/js/JSLocationCustom.cpp:
61         (WebCore::JSLocation::getOwnPropertySlotDelegate):
62
63 2017-02-06  Joseph Pecoraro  <pecoraro@apple.com>
64
65         Web Inspector: Do not use RunLoop when dispatching inspector GC event
66         https://bugs.webkit.org/show_bug.cgi?id=167683
67         <rdar://problem/30167791>
68
69         Reviewed by Brian Burg.
70
71         Covered by existing tests.
72
73         * CMakeLists.txt:
74         * WebCore.xcodeproj/project.pbxproj:
75         * inspector/InspectorAllInOne.cpp:
76         Add new file.
77
78         * inspector/PageHeapAgent.cpp:
79         (WebCore::PageHeapAgent::PageHeapAgent):
80         (WebCore::PageHeapAgent::enable):
81         (WebCore::PageHeapAgent::disable):
82         * inspector/PageHeapAgent.h:
83         Extend WebHeapAgent.
84
85         * inspector/WorkerInspectorController.cpp:
86         (WebCore::WorkerInspectorController::WorkerInspectorController):
87         Use WebHeapAgent.
88
89         * inspector/WebHeapAgent.cpp: Added.
90         (WebCore::SendGarbageCollectionEventsTask::SendGarbageCollectionEventsTask):
91         (WebCore::SendGarbageCollectionEventsTask::addGarbageCollection):
92         (WebCore::SendGarbageCollectionEventsTask::reset):
93         (WebCore::SendGarbageCollectionEventsTask::timerFired):
94         (WebCore::WebHeapAgent::WebHeapAgent):
95         (WebCore::WebHeapAgent::~WebHeapAgent):
96         (WebCore::WebHeapAgent::disable):
97         (WebCore::WebHeapAgent::dispatchGarbageCollectedEvent):
98         (WebCore::WebHeapAgent::dispatchGarbageCollectionEventsAfterDelay):
99         * inspector/WebHeapAgent.h:
100         Move the defered event dispatch from InspectorHeapAgent here where a RunLoop is guarenteed.
101
102 2017-02-06  Joseph Pecoraro  <pecoraro@apple.com>
103
104         ExtendedColor leaks seen on leaks bot
105         https://bugs.webkit.org/show_bug.cgi?id=167912
106
107         Reviewed by Alexey Proskuryakov.
108
109         * platform/graphics/Color.cpp:
110         (WebCore::Color::operator=):
111         Before overwriting m_colorData, we must deref the extended color inside it.
112
113 2017-02-06  Simon Fraser  <simon.fraser@apple.com>
114
115         Re-land r210095 (avoid a tile revalidation on scale change)
116         https://bugs.webkit.org/show_bug.cgi?id=167866
117
118         Reviewed by Tim Horton.
119         
120         r210095 was rolled out in r211230 but now that all TileControllers unparent
121         offscreen tiles, we can roll it back it.
122         
123         Also add more Tiling logging.
124
125         * platform/graphics/ca/TileGrid.cpp:
126         (WebCore::validationPolicyAsString):
127         (WebCore::TileGrid::setScale):
128         (WebCore::TileGrid::prepopulateRect):
129         (WebCore::TileGrid::revalidateTiles):
130         (WebCore::TileGrid::ensureTilesForRect):
131
132 2017-02-06  Myles C. Maxfield  <mmaxfield@apple.com>
133
134         Migrate ComplexTextController to use platform-independent types
135         https://bugs.webkit.org/show_bug.cgi?id=167833
136
137         Reviewed by Brent Fulgham.
138
139         ComplexTextController will eventually be used on all ports to perform complex text layout.
140         This is a mechanical patch which migrates the shared parts of ComplexTextController away from
141         using CoreGraphics and CoreFoundation types in favor of WebCore/platform types. Eventually,
142         ComplexTextController will get moved to PAL but there is a layering violation (TextLayout) to
143         fix first.
144
145         No new tests because there is no behavior change.
146
147         * platform/graphics/GlyphBuffer.h:
148         (WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
149         * platform/graphics/mac/ComplexTextController.cpp:
150         (WebCore::ComplexTextController::offsetForPosition):
151         (WebCore::advanceByCombiningCharacterSequence):
152         (WebCore::ComplexTextController::ComplexTextRun::indexAt):
153         (WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic):
154         (WebCore::ComplexTextController::advance):
155         (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
156         * platform/graphics/mac/ComplexTextController.h:
157         (WebCore::ComplexTextController::ComplexTextRun::create):
158         (WebCore::ComplexTextController::ComplexTextRun::stringLength):
159         (WebCore::ComplexTextController::ComplexTextRun::indexBegin):
160         (WebCore::ComplexTextController::ComplexTextRun::indexEnd):
161         (WebCore::ComplexTextController::ComplexTextRun::endOffsetAt):
162         (WebCore::ComplexTextController::ComplexTextRun::glyphs):
163         (WebCore::ComplexTextController::ComplexTextRun::growInitialAdvanceHorizontally):
164         (WebCore::ComplexTextController::ComplexTextRun::initialAdvance):
165         (WebCore::ComplexTextController::ComplexTextRun::baseAdvances):
166         (WebCore::ComplexTextController::ComplexTextRun::glyphOrigins):
167         (WebCore::ComplexTextController::glyphOrigin):
168         (WebCore::ComplexTextController::ComplexTextRun::createForTesting): Deleted.
169         * platform/graphics/mac/ComplexTextControllerCoreText.mm:
170         (SOFT_LINK):
171         (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
172         (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
173
174 2017-02-06  Brent Fulgham  <bfulgham@apple.com>
175
176         Correct File Path Handling in SecurityOrigin and FileSystem
177         https://bugs.webkit.org/show_bug.cgi?id=167894
178         <rdar://problem/30380080>
179
180         Reviewed by Alexey Proskuryakov.
181
182         Roll out the URL decoding being done in the FileSystem class (added in Bug 167894), and instead ensure that
183         SecurityOrigin properly handles file URLs, and only passes valid file strings to the FileSystem interface.
184
185         Tested by FileSystemTests and SecurityOriginTests in TestWebKitAPI.
186
187         * page/SecurityOrigin.cpp:
188         (WebCore::SecurityOrigin::SecurityOrigin): Initialize m_filePath using the url's fileSystemPath, not
189         the %-encoded 'path' property.
190         (WebCore::SecurityOrigin::canDisplay): Pass the 'fileSystemPath' to 'filesHaveSameVolume', rather than
191         the %-encoded 'path' property.
192         * page/SecurityOrigin.h:
193         * platform/FileSystem.cpp:
194         (WebCore::filesHaveSameVolume): Do not use 'decodeURLEscapeSequences' in 'filesHaveSameVolume'.
195
196 2017-02-06  Andy Estes  <aestes@apple.com>
197
198         [Cocoa] Split FileSystemMac.mm into Mac and Cocoa parts
199         https://bugs.webkit.org/show_bug.cgi?id=167908
200
201         Reviewed by Sam Weinig.
202
203         Kept the Mac-only functions in FileSystemMac.mm and moved the rest into FileSystemCocoa.mm.
204
205         * PlatformMac.cmake:
206         * WebCore.xcodeproj/project.pbxproj:
207         * platform/cocoa/FileSystemCocoa.mm: Copied from Source/WebCore/platform/mac/FileSystemMac.mm.
208         * platform/mac/FileSystemMac.mm:
209         (-[WebFileManagerDelegate fileManager:shouldProceedAfterError:movingItemAtURL:toURL:]): Moved to FileSystemCocoa.mm.
210         (WebCore::homeDirectoryPath): Ditto.
211         (WebCore::openTemporaryFile): Ditto.
212         (WebCore::moveFile): Ditto.
213         (WebCore::getVolumeFreeSpace): Ditto.
214
215 2017-02-06  Eric Carlson  <eric.carlson@apple.com>
216
217         [MediaStream Mac] Remove some unused code
218         https://bugs.webkit.org/show_bug.cgi?id=167913
219
220         Reviewed by Jer Noble.
221
222         No new tests, no functional change.
223
224         * platform/mediastream/CaptureDeviceManager.h:
225         (WebCore::CaptureSessionInfo::~CaptureSessionInfo): Deleted.
226         (WebCore::CaptureSessionInfo::supportsVideoSize): Deleted.
227         (WebCore::CaptureSessionInfo::bestSessionPresetForVideoDimensions): Deleted.
228         * platform/mediastream/mac/AVCaptureDeviceManager.h:
229         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
230         (WebCore::AVCaptureDeviceManager::refreshCaptureDeviceList):
231         (WebCore::AVCaptureSessionInfo::AVCaptureSessionInfo): Deleted.
232         (WebCore::AVCaptureSessionInfo::supportsVideoSize): Deleted.
233         (WebCore::AVCaptureSessionInfo::bestSessionPresetForVideoDimensions): Deleted.
234         * platform/mediastream/mac/AVMediaCaptureSource.mm:
235         (WebCore::AVMediaCaptureSource::AVMediaCaptureSource):
236
237 2017-02-06  Youenn Fablet  <youennf@gmail.com>
238
239         Allow some schemes to opt-out of CORS
240         https://bugs.webkit.org/show_bug.cgi?id=167795
241
242         Reviewed by Alex Christensen.
243
244         Test: http/tests/security/bypassing-cors-checks-for-extension-urls.html
245
246         Adding the possibility to opt out of CORS for DocumentThreadableLoader clients (fetch and XHR).
247         This is made specific to the case of user extension URLs for pages running user scripts.
248         Introducing a boolean flag in Page for that purpose.
249         Introducing a helper routine in SchemeRegistry to centralize the various user script extension schemes.
250
251         * loader/DocumentThreadableLoader.cpp:
252         (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
253         * page/Frame.cpp:
254         (WebCore::Frame::injectUserScripts):
255         * page/Page.h:
256         (WebCore::Page::setAsRunningUserScripts):
257         (WebCore::Page::isRunningUserScripts):
258         * platform/SchemeRegistry.cpp:
259         (WebCore::SchemeRegistry::isUserExtensionScheme):
260         * platform/SchemeRegistry.h:
261         * testing/Internals.cpp:
262         (WebCore::Internals::setAsRunningUserScripts):
263         * testing/Internals.h:
264         * testing/Internals.idl:
265
266 2017-02-06  Chris Dumez  <cdumez@apple.com>
267
268         Align [[OwnPropertyKeys]] with the HTML specification for cross-origin Window / Location objects
269         https://bugs.webkit.org/show_bug.cgi?id=167647
270         <rdar://problem/30339489>
271
272         Reviewed by Sam Weinig.
273
274         Align [[OwnPropertyKeys]] with the HTML specification for cross-origin Window / Location objects:
275         - https://html.spec.whatwg.org/#windowproxy-ownpropertykeys [1]
276         - https://html.spec.whatwg.org/#crossoriginownpropertykeys-(-o-) [2]
277         - https://html.spec.whatwg.org/#crossoriginproperties-(-o-) [3]
278
279         In particular, the following changes were made:
280         - Location:
281           - We now return the following symbols as well: @@toStringTag, @@hasInstance,
282             @@isConcatSpreadable as per [2].
283         - Window:
284           - We now return the following symbols as well: @@toStringTag, @@hasInstance,
285             @@isConcatSpreadable as per [2].
286           - We now return the indices of the child browsing contexts as per [1].
287           - We now return the names of the child browsing contexts as per [3].
288
289         No new tests, updated / rebaselined existing tests.
290
291         * bindings/js/JSDOMWindowCustom.cpp:
292         (WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
293         Index properties should be configurable as per:
294         - https://html.spec.whatwg.org/#windowproxy-getownproperty (step 2.5)
295
296         (WebCore::inScope):
297         (WebCore::addScopedChildrenNames):
298         (WebCore::addCrossOriginPropertyNames):
299         (WebCore::addScopedChildrenIndexes):
300         (WebCore::addCrossOriginOwnPropertyNames):
301         (WebCore::JSDOMWindow::getOwnPropertyNames):
302         * bindings/js/JSLocationCustom.cpp:
303         (WebCore::addCrossOriginPropertyNames):
304         (WebCore::addCrossOriginOwnPropertyNames):
305         (WebCore::JSLocation::getOwnPropertyNames):
306
307 2017-02-06  Yoav Weiss  <yoav@yoav.ws>
308
309         http/tests/preload/dynamic_removing_preload.html fails to test what it should
310         https://bugs.webkit.org/show_bug.cgi?id=167792
311
312         Reviewed by Ryosuke Niwa.
313
314         Cancel the link preload resource load when the link element is removed from the DOM.
315
316         No new tests, but unskipping an existing test: http/tests/preload/dynamic_removing_preload.html
317
318         * html/HTMLLinkElement.cpp:
319         (WebCore::HTMLLinkElement::removedFrom): Call m_linkLoader.cancelLoad().
320         * loader/LinkLoader.cpp:
321         (WebCore::LinkLoader::cancelLoad): Clear m_preloadResourceClient.
322         * loader/LinkLoader.h:
323         * loader/LinkPreloadResourceClients.h:
324         (WebCore::LinkPreloadResourceClient::clearResource): Call m_resource->cancelLoad().
325         * loader/SubresourceLoader.cpp:
326         (WebCore::LinkPreloadResourceClient::didFinishLoading): Change ASSERT to exempt cancelled loads.
327
328 2017-02-06  Alex Christensen  <achristensen@webkit.org>
329
330         More build fixes after r211751
331         https://bugs.webkit.org/show_bug.cgi?id=166998
332
333         * platform/network/soup/ResourceHandleSoup.cpp:
334         (WebCore::applyAuthenticationToRequest):
335         * platform/network/soup/SocketStreamHandleImplSoup.cpp:
336         (WebCore::SocketStreamHandleImpl::create):
337
338 2017-02-06  Alex Christensen  <achristensen@webkit.org>
339
340         Fix non-cocoa builds after r211751.
341         https://bugs.webkit.org/show_bug.cgi?id=166998
342
343         * platform/network/cf/ResourceHandleCFNet.cpp:
344         (WebCore::ResourceHandle::createCFURLConnection):
345         (WebCore::ResourceHandle::willSendRequest):
346         (WebCore::ResourceHandle::tryHandlePasswordBasedAuthentication):
347         (WebCore::ResourceHandle::receivedCredential):
348         * platform/network/curl/ResourceHandleCurl.cpp:
349         (WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
350         (WebCore::ResourceHandle::receivedCredential):
351         * platform/network/curl/ResourceHandleManager.cpp:
352         (WebCore::ResourceHandleManager::applyAuthenticationToRequest):
353         * platform/network/soup/ResourceHandleSoup.cpp:
354         (WebCore::applyAuthenticationToRequest):
355         (WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
356         (WebCore::ResourceHandle::receivedCredential):
357
358 2017-02-06  Alex Christensen  <achristensen@webkit.org>
359
360         credentials should be partitioned by main document domain
361         https://bugs.webkit.org/show_bug.cgi?id=166998
362         rdar://problem/22901123
363
364         Reviewed by Brady Eidson.
365
366         Covered by http/tests/security/credentials-iframes.html
367         Also added http/tests/security/credentials-from-different-domains.html to verify existing behavior without iframes.
368
369         * Modules/websockets/WebSocketChannel.cpp:
370         (WebCore::WebSocketChannel::connect):
371         * dom/Document.h:
372         * page/SecurityOrigin.cpp:
373         (WebCore::SecurityOrigin::domainForCachePartition):
374         Return emptyString instead of a null String because it is used as a key in a HashMap, and hashing null strings dereferences null.
375         * page/SocketProvider.cpp:
376         (WebCore::SocketProvider::createSocketStreamHandle):
377         * page/SocketProvider.h:
378         * platform/network/CredentialStorage.cpp:
379         (WebCore::CredentialStorage::set):
380         (WebCore::CredentialStorage::get):
381         (WebCore::CredentialStorage::remove):
382         * platform/network/CredentialStorage.h:
383         Partition credentials.
384         * platform/network/ResourceHandleInternal.h:
385         (WebCore::ResourceHandleInternal::ResourceHandleInternal):
386         * platform/network/cf/SocketStreamHandleImpl.h:
387         (WebCore::SocketStreamHandleImpl::create):
388         * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
389         (WebCore::SocketStreamHandleImpl::SocketStreamHandleImpl):
390         (WebCore::SocketStreamHandleImpl::getStoredCONNECTProxyCredentials):
391         * platform/network/curl/SocketStreamHandleImpl.h:
392         (WebCore::SocketStreamHandleImpl::create):
393         * platform/network/mac/ResourceHandleMac.mm:
394         (WebCore::ResourceHandle::createNSURLConnection):
395         (WebCore::ResourceHandle::willSendRequest):
396         (WebCore::ResourceHandle::tryHandlePasswordBasedAuthentication):
397         (WebCore::ResourceHandle::receivedCredential):
398         * platform/network/soup/SocketStreamHandleImpl.h:
399
400 2017-02-06  Simon Fraser  <simon.fraser@apple.com>
401
402         Safari pages are blank sometimes (missing tiles)
403         https://bugs.webkit.org/show_bug.cgi?id=167904
404
405         Reviewed by Tim Horton.
406
407         After r211683 we failed to udpate the "inWindow" flag on the page tiled layer, because
408         usingTiledBacking() on GraphicsLayer confusingly was false for the page tiled layer.
409
410         Fix by removing usingTiledBacking() entirely, and checking for tiledBacking(),
411         looking at the layer type when necessary.
412
413         Tested by tiled-drawing/tiled-backing-in-window.html
414
415         * platform/graphics/GraphicsLayer.cpp:
416         (WebCore::GraphicsLayer::GraphicsLayer):
417         (WebCore::GraphicsLayer::setIsInWindowIncludingDescendants): This is the bug fix.
418         (WebCore::GraphicsLayer::getDebugBorderInfo):
419         (WebCore::GraphicsLayer::dumpProperties):
420         * platform/graphics/GraphicsLayer.h:
421         (WebCore::GraphicsLayer::usingTiledBacking): Deleted.
422         * platform/graphics/ca/GraphicsLayerCA.cpp:
423         (WebCore::GraphicsLayerCA::recursiveCommitChanges):
424         (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
425         (WebCore::GraphicsLayerCA::changeLayerTypeTo):
426         * rendering/RenderLayerBacking.cpp:
427         (WebCore::RenderLayerBacking::willDestroyLayer):
428         (WebCore::RenderLayerBacking::compositingLayerType):
429         * rendering/RenderLayerCompositor.cpp: A bit more logging.
430         (WebCore::RenderLayerCompositor::setIsInWindow):
431         (WebCore::RenderLayerCompositor::attachRootLayer):
432
433 2017-02-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
434
435         Change the CSS animation timer a to be little more than 60fps to ensure we hit that frame rate
436         https://bugs.webkit.org/show_bug.cgi?id=167825
437
438         Reviewed by Simon Fraser.
439
440         The system timer fires little bit slower than 60fps. This might cause the
441         frame to be missed and hence it can lower the frame rate significantly. The
442         rAF timer was set to 15ms for the same reason. So set the repeated CSS
443         animation timer also to 15ms.
444
445         * page/animation/CSSAnimationController.cpp:
446
447 2017-02-06  Jer Noble  <jer.noble@apple.com>
448
449         Playback stalls when a SourceBuffer append causes frame eviction
450         https://bugs.webkit.org/show_bug.cgi?id=167834
451
452         Reviewed by Eric Carlson.
453
454         Test: PerformanceTests/Media/MSERemoveCodedFrames.html
455
456         Optimize searching through SampleMap by presentationTime.
457
458         Many of the methods exposed by PresentationOrderSampleMap used the bare  std::equal_range,
459         lower_bound, or upper_bound methods. Unlike those methods exposed on std::map, the bare
460         search methods perform a linear O(n) search, rather than a the binary O(log(n)) search used
461         by std::map. Rewrite those methods using the bare methods in terms of the std::map search
462         methods.
463
464         Drive-by fix: rename findSampleOnOrAfterPresentationTime to
465         findSampleStartingOnOrAfterPresentationTime to make the behavior of the method more
466         explicit.
467
468         * Modules/mediasource/SampleMap.cpp:
469         (WebCore::PresentationOrderSampleMap::findSampleContainingPresentationTime):
470         (WebCore::PresentationOrderSampleMap::findSampleStartingOnOrAfterPresentationTime):
471         (WebCore::PresentationOrderSampleMap::reverseFindSampleBeforePresentationTime):
472         (WebCore::DecodeOrderSampleMap::findSyncSampleAfterPresentationTime):
473         (WebCore::PresentationOrderSampleMap::findSamplesBetweenPresentationTimes):
474         (WebCore::PresentationOrderSampleMap::findSamplesWithinPresentationRange):
475         (WebCore::PresentationOrderSampleMap::findSampleOnOrAfterPresentationTime): Deleted.
476         * Modules/mediasource/SampleMap.h:
477         (WebCore::PresentationOrderSampleMap::begin):
478         (WebCore::PresentationOrderSampleMap::end):
479         (WebCore::PresentationOrderSampleMap::rbegin):
480         (WebCore::PresentationOrderSampleMap::rend):
481         (WebCore::DecodeOrderSampleMap::begin):
482         (WebCore::DecodeOrderSampleMap::end):
483         (WebCore::DecodeOrderSampleMap::rbegin):
484         (WebCore::DecodeOrderSampleMap::rend):
485         (WebCore::SampleMap::SampleMap):
486         (WebCore::SampleMap::sizeInBytes):
487         (WebCore::SampleMap::decodeOrder):
488         (WebCore::SampleMap::presentationOrder):
489         * Modules/mediasource/SourceBuffer.cpp:
490         (WebCore::removeSamplesFromTrackBuffer):
491         (WebCore::SourceBuffer::removeCodedFrames):
492         (WebCore::SourceBuffer::reenqueueMediaForTime):
493         * WebCore.xcodeproj/project.pbxproj:
494
495 2017-02-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
496
497         Rename AnimationController to CSSAnimationController
498         https://bugs.webkit.org/show_bug.cgi?id=167829
499
500         Reviewed by Simon Fraser.
501
502         AnimationController is a very generic name. The current function of this
503         class is CSS animation.
504
505         * CMakeLists.txt:
506         * WebCore.xcodeproj/project.pbxproj:
507         * css/CSSComputedStyleDeclaration.cpp:
508         (WebCore::computeRenderStyleForProperty):
509         * dom/Document.cpp:
510         * history/CachedFrame.cpp:
511         * page/Frame.cpp:
512         (WebCore::Frame::Frame):
513         * page/Frame.h:
514         (WebCore::Frame::animation):
515         * page/FrameView.cpp:
516         * page/Page.cpp:
517         * page/animation/AnimationBase.cpp:
518         * page/animation/CSSAnimationController.cpp: Renamed from Source/WebCore/page/animation/AnimationController.cpp.
519         (WebCore::AnimationPrivateUpdateBlock::AnimationPrivateUpdateBlock):
520         (WebCore::AnimationPrivateUpdateBlock::~AnimationPrivateUpdateBlock):
521         (WebCore::CSSAnimationControllerPrivate::CSSAnimationControllerPrivate):
522         (WebCore::CSSAnimationControllerPrivate::~CSSAnimationControllerPrivate):
523         (WebCore::CSSAnimationControllerPrivate::ensureCompositeAnimation):
524         (WebCore::CSSAnimationControllerPrivate::clear):
525         (WebCore::CSSAnimationControllerPrivate::updateAnimations):
526         (WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForRenderer):
527         (WebCore::CSSAnimationControllerPrivate::updateAnimationTimer):
528         (WebCore::CSSAnimationControllerPrivate::updateStyleIfNeededDispatcherFired):
529         (WebCore::CSSAnimationControllerPrivate::fireEventsAndUpdateStyle):
530         (WebCore::CSSAnimationControllerPrivate::startUpdateStyleIfNeededDispatcher):
531         (WebCore::CSSAnimationControllerPrivate::addEventToDispatch):
532         (WebCore::CSSAnimationControllerPrivate::addElementChangeToDispatch):
533         (WebCore::CSSAnimationControllerPrivate::animationFrameCallbackFired):
534         (WebCore::CSSAnimationControllerPrivate::animationTimerFired):
535         (WebCore::CSSAnimationControllerPrivate::isRunningAnimationOnRenderer):
536         (WebCore::CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer):
537         (WebCore::CSSAnimationControllerPrivate::suspendAnimations):
538         (WebCore::CSSAnimationControllerPrivate::resumeAnimations):
539         (WebCore::CSSAnimationControllerPrivate::animationsAreSuspendedForDocument):
540         (WebCore::CSSAnimationControllerPrivate::detachFromDocument):
541         (WebCore::CSSAnimationControllerPrivate::suspendAnimationsForDocument):
542         (WebCore::CSSAnimationControllerPrivate::resumeAnimationsForDocument):
543         (WebCore::CSSAnimationControllerPrivate::startAnimationsIfNotSuspended):
544         (WebCore::CSSAnimationControllerPrivate::setAllowsNewAnimationsWhileSuspended):
545         (WebCore::CSSAnimationControllerPrivate::pauseAnimationAtTime):
546         (WebCore::CSSAnimationControllerPrivate::pauseTransitionAtTime):
547         (WebCore::CSSAnimationControllerPrivate::beginAnimationUpdateTime):
548         (WebCore::CSSAnimationControllerPrivate::beginAnimationUpdate):
549         (WebCore::CSSAnimationControllerPrivate::endAnimationUpdate):
550         (WebCore::CSSAnimationControllerPrivate::receivedStartTimeResponse):
551         (WebCore::CSSAnimationControllerPrivate::getAnimatedStyleForRenderer):
552         (WebCore::CSSAnimationControllerPrivate::computeExtentOfAnimation):
553         (WebCore::CSSAnimationControllerPrivate::numberOfActiveAnimations):
554         (WebCore::CSSAnimationControllerPrivate::addToAnimationsWaitingForStyle):
555         (WebCore::CSSAnimationControllerPrivate::removeFromAnimationsWaitingForStyle):
556         (WebCore::CSSAnimationControllerPrivate::styleAvailable):
557         (WebCore::CSSAnimationControllerPrivate::addToAnimationsWaitingForStartTimeResponse):
558         (WebCore::CSSAnimationControllerPrivate::removeFromAnimationsWaitingForStartTimeResponse):
559         (WebCore::CSSAnimationControllerPrivate::startTimeResponse):
560         (WebCore::CSSAnimationControllerPrivate::animationWillBeRemoved):
561         (WebCore::CSSAnimationControllerPrivate::addToAnimationsDependentOnScroll):
562         (WebCore::CSSAnimationControllerPrivate::removeFromAnimationsDependentOnScroll):
563         (WebCore::CSSAnimationControllerPrivate::scrollWasUpdated):
564         (WebCore::CSSAnimationController::CSSAnimationController):
565         (WebCore::CSSAnimationController::~CSSAnimationController):
566         (WebCore::CSSAnimationController::cancelAnimations):
567         (WebCore::CSSAnimationController::updateAnimations):
568         (WebCore::CSSAnimationController::getAnimatedStyleForRenderer):
569         (WebCore::CSSAnimationController::computeExtentOfAnimation):
570         (WebCore::CSSAnimationController::notifyAnimationStarted):
571         (WebCore::CSSAnimationController::pauseAnimationAtTime):
572         (WebCore::CSSAnimationController::numberOfActiveAnimations):
573         (WebCore::CSSAnimationController::pauseTransitionAtTime):
574         (WebCore::CSSAnimationController::isRunningAnimationOnRenderer):
575         (WebCore::CSSAnimationController::isRunningAcceleratedAnimationOnRenderer):
576         (WebCore::CSSAnimationController::isSuspended):
577         (WebCore::CSSAnimationController::suspendAnimations):
578         (WebCore::CSSAnimationController::resumeAnimations):
579         (WebCore::CSSAnimationController::allowsNewAnimationsWhileSuspended):
580         (WebCore::CSSAnimationController::setAllowsNewAnimationsWhileSuspended):
581         (WebCore::CSSAnimationController::serviceAnimations):
582         (WebCore::CSSAnimationController::animationsAreSuspendedForDocument):
583         (WebCore::CSSAnimationController::detachFromDocument):
584         (WebCore::CSSAnimationController::suspendAnimationsForDocument):
585         (WebCore::CSSAnimationController::resumeAnimationsForDocument):
586         (WebCore::CSSAnimationController::startAnimationsIfNotSuspended):
587         (WebCore::CSSAnimationController::beginAnimationUpdate):
588         (WebCore::CSSAnimationController::endAnimationUpdate):
589         (WebCore::CSSAnimationController::supportsAcceleratedAnimationOfProperty):
590         (WebCore::CSSAnimationController::wantsScrollUpdates):
591         (WebCore::CSSAnimationController::scrollWasUpdated):
592         (WebCore::CSSAnimationController::hasAnimations):
593         * page/animation/CSSAnimationController.h: Renamed from Source/WebCore/page/animation/AnimationController.h.
594         (WebCore::AnimationUpdateBlock::AnimationUpdateBlock):
595         (WebCore::AnimationUpdateBlock::~AnimationUpdateBlock):
596         * page/animation/CSSAnimationControllerPrivate.h: Renamed from Source/WebCore/page/animation/AnimationControllerPrivate.h.
597         (WebCore::CSSAnimationControllerPrivate::hasAnimations):
598         (WebCore::CSSAnimationControllerPrivate::isSuspended):
599         (WebCore::CSSAnimationControllerPrivate::setBeginAnimationUpdateTime):
600         (WebCore::CSSAnimationControllerPrivate::allowsNewAnimationsWhileSuspended):
601         (WebCore::CSSAnimationControllerPrivate::wantsScrollUpdates):
602         (WebCore::CSSAnimationControllerPrivate::scrollPosition):
603         * page/animation/CSSPropertyAnimation.cpp:
604         (WebCore::CSSPropertyAnimationWrapperMap::singleton):
605         * page/animation/CompositeAnimation.cpp:
606         (WebCore::CompositeAnimation::CompositeAnimation):
607         * page/animation/CompositeAnimation.h:
608         (WebCore::CompositeAnimation::create):
609         (WebCore::CompositeAnimation::animationController):
610         * page/animation/ImplicitAnimation.cpp:
611         * page/animation/KeyframeAnimation.cpp:
612         * page/ios/FrameIOS.mm:
613         * platform/graphics/GraphicsLayer.h:
614         * rendering/RenderElement.h:
615         * rendering/RenderLayer.cpp:
616         * rendering/RenderLayerBacking.cpp:
617         * rendering/RenderLayerCompositor.cpp:
618         (WebCore::RenderLayerCompositor::requiresCompositingForAnimation):
619         * rendering/RenderObject.cpp:
620         * rendering/RenderObject.h:
621         (WebCore::RenderObject::animation):
622         * testing/Internals.cpp:
623
624 2017-02-06  Zalan Bujtas  <zalan@apple.com>
625
626         Simple line layout: Use simplified text measuring when possible.
627         https://bugs.webkit.org/show_bug.cgi?id=167843
628         <rdar://problem/30364907>
629
630         Reviewed by Antti Koivisto.
631
632         This patch adds a simplified version of text width measuring.
633         Certain type of text runs (no spacing etc) only require a subset of what we
634         currently do in FontCascade::width().
635
636         * platform/graphics/FontCascade.cpp:
637         (WebCore::FontCascade::widthForSimpleText):
638         * platform/graphics/FontCascade.h:
639         * platform/graphics/WidthCache.h:
640         (WebCore::WidthCache::add):
641         (WebCore::WidthCache::addSlowCase):
642         * platform/graphics/WidthIterator.cpp:
643         (WebCore::WidthIterator::advanceInternal):
644         * rendering/RenderText.cpp:
645         (WebCore::RenderText::styleDidChange):
646         (WebCore::RenderText::setRenderedText):
647         (WebCore::RenderText::computeCanUseSimplifiedTextMeasuring):
648         * rendering/RenderText.h:
649         (WebCore::RenderText::canUseSimplifiedTextMeasuring):
650         * rendering/SimpleLineLayoutFlowContents.cpp:
651         (WebCore::SimpleLineLayout::initializeSegments):
652         * rendering/SimpleLineLayoutFlowContents.h:
653         * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
654         (WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style):
655         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragmentIterator):
656         (WebCore::SimpleLineLayout::TextFragmentIterator::textWidth):
657         * rendering/SimpleLineLayoutTextFragmentIterator.h:
658
659 2017-02-06  Carlos Garcia Campos  <cgarcia@igalia.com>
660
661         Resource usage overlay should ignore mouse events outside bounds by default
662         https://bugs.webkit.org/show_bug.cgi?id=167874
663
664         Reviewed by Andreas Kling.
665
666         It's overriding the default causing that the first click after the overlay is shown is always handled by the
667         overlay even when clicked outside bounds. It should only be set false while dragging.
668
669         * page/ResourceUsageOverlay.cpp:
670         (WebCore::ResourceUsageOverlay::initialize):
671
672 2017-02-06  Antti Koivisto  <antti@apple.com>
673
674         CrashTracer: com.apple.WebKit.WebContent at WebCore: WebCore::Node::invalidateStyle
675         https://bugs.webkit.org/show_bug.cgi?id=167878
676         rdar://problem/30251840
677
678         Reviewed by Andreas Kling.
679
680         Speculative fix.
681
682         We are trying to invalidate a null node from ~PostResolutionCallbackDisabler. Looks like the only way
683         this could happen is if HTMLFrameOwnerElement::scheduleinvalidateStyleAndLayerComposition is called
684         with null 'this'. There is one place where this might happen.
685
686         * rendering/RenderLayerCompositor.cpp:
687         (WebCore::RenderLayerCompositor::attachRootLayer): Add null check.
688
689 2017-02-06  Ryan Haddad  <ryanhaddad@apple.com>
690
691         Unreviewed, rolling out r211722.
692
693         This change introduced a LayoutTest failure on mac-wk2.
694
695         Reverted changeset:
696
697         "[Modern Media Controls] Improve handling of <video> with only
698         audio tracks"
699         https://bugs.webkit.org/show_bug.cgi?id=167836
700         http://trac.webkit.org/changeset/211722
701
702 2017-02-06  Eric Carlson  <eric.carlson@apple.com>
703
704         [MediaStream Mac] Stop using AVSampleBufferAudioRenderer
705         https://bugs.webkit.org/show_bug.cgi?id=167821
706
707         Reviewed by Jer Noble.
708
709         * WebCore.xcodeproj/project.pbxproj: Add new files.
710
711         * platform/audio/mac/AudioSampleDataSource.cpp:
712         (WebCore::AudioSampleDataSource::pullSamplesInternal): Don't assume the first timestamp from the
713         render proc after a pause is zero.
714
715         Stop using an audio renderer for each audio track. No audio renderers means we don't need to use
716         an AVSampleBufferRenderSynchronizer.
717         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
718         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
719         (-[WebAVSampleBufferStatusChangeListener invalidate]): No more audio renderers.
720         (-[WebAVSampleBufferStatusChangeListener observeValueForKeyPath:ofObject:change:context:]): Ditto.
721         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC): Ditto.
722         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::~MediaPlayerPrivateMediaStreamAVFObjC): Pause
723           audio tracks explicitly.
724         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::audioSourceProvider): Remove the existing code,
725           it was incorrect and not thread safe.
726         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::flushRenderers): No more audio renderers.
727         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::ensureLayer): No more render synchronizer.
728         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::destroyLayer): Ditto.
729         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::play): Start each audio track.
730         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::pause): Pause each audio track.
731         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVolume): Pass the command to each audio track.
732         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setMuted): Ditto.
733         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::streamTime): No more render synchronizer.
734         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::sampleBufferUpdated): Don't handle audio samples.
735         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateTracks): Update for audio track class change. No
736         more render synchronizer.
737         (-[WebAVSampleBufferStatusChangeListener beginObservingRenderer:]): Deleted.
738         (-[WebAVSampleBufferStatusChangeListener stopObservingRenderer:]): Deleted.
739         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueAudioSample): Deleted.
740         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::requestNotificationWhenReadyForAudioData): Deleted.
741         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createAudioRenderer): Deleted.
742         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::destroyAudioRenderer): Deleted.
743         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::destroyAudioRenderers): Deleted.
744         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::rendererStatusDidChange): Deleted.
745
746         * platform/mediastream/AudioTrackPrivateMediaStream.h:
747
748         * platform/mediastream/MediaStreamTrackPrivate.cpp:
749         (WebCore::MediaStreamTrackPrivate::MediaStreamTrackPrivate): add/removeObserver takes a reference,
750         not a pointer.
751         (WebCore::MediaStreamTrackPrivate::~MediaStreamTrackPrivate): Ditto.
752         (WebCore::MediaStreamTrackPrivate::videoSampleAvailable): Renamed from sourceHasMoreMediaData.
753         (WebCore::MediaStreamTrackPrivate::sourceHasMoreMediaData): Deleted.
754         * platform/mediastream/MediaStreamTrackPrivate.h:
755
756         * platform/mediastream/RealtimeMediaSource.cpp:
757         (WebCore::RealtimeMediaSource::addObserver): Take a reference, not a pointer.
758         (WebCore::RealtimeMediaSource::removeObserver): Ditto.
759         (WebCore::RealtimeMediaSource::videoSampleAvailable): Renamed from mediaDataUpdated.
760         (WebCore::RealtimeMediaSource::audioSamplesAvailable): New.
761         (WebCore::RealtimeMediaSource::stop): Drive-by cleanup.
762         (WebCore::RealtimeMediaSource::requestStop): Ditto.
763         (WebCore::RealtimeMediaSource::mediaDataUpdated): Deleted.
764         * platform/mediastream/RealtimeMediaSource.h:
765
766         * platform/mediastream/mac/AVAudioCaptureSource.h:
767         * platform/mediastream/mac/AVAudioCaptureSource.mm:
768         (WebCore::AVAudioCaptureSource::AVAudioCaptureSource):
769         (WebCore::AVAudioCaptureSource::addObserver):
770         (WebCore::AVAudioCaptureSource::shutdownCaptureSession):
771         (WebCore::AVAudioCaptureSource::captureOutputDidOutputSampleBufferFromConnection):
772         (WebCore::operator==): Deleted.
773         (WebCore::operator!=): Deleted.
774
775         * platform/mediastream/mac/AVVideoCaptureSource.mm:
776         (WebCore::AVVideoCaptureSource::processNewFrame): Call videoSampleAvailable, not mediaDataUpdated.
777
778         Render audio with a CoreAudio output unit.
779         * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp: Added.
780         (WebCore::AudioTrackPrivateMediaStreamCocoa::AudioTrackPrivateMediaStreamCocoa):
781         (WebCore::AudioTrackPrivateMediaStreamCocoa::~AudioTrackPrivateMediaStreamCocoa):
782         (WebCore::AudioTrackPrivateMediaStreamCocoa::playInternal):
783         (WebCore::AudioTrackPrivateMediaStreamCocoa::play):
784         (WebCore::AudioTrackPrivateMediaStreamCocoa::pause):
785         (WebCore::AudioTrackPrivateMediaStreamCocoa::setVolume):
786         (WebCore::AudioTrackPrivateMediaStreamCocoa::setupAudioUnit):
787         (WebCore::AudioTrackPrivateMediaStreamCocoa::audioSamplesAvailable):
788         (WebCore::AudioTrackPrivateMediaStreamCocoa::sourceStopped):
789         (WebCore::AudioTrackPrivateMediaStreamCocoa::render):
790         (WebCore::AudioTrackPrivateMediaStreamCocoa::inputProc):
791         * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h: Added.
792
793         * platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
794         * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
795         (WebCore::alignTo16Bytes):
796         (WebCore::MockRealtimeAudioSourceMac::emitSampleBuffers):
797         (WebCore::MockRealtimeAudioSourceMac::reconfigure): Minor cleanup.
798         (WebCore::MockRealtimeAudioSourceMac::render): Ditto.
799
800         * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
801         (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer): Call videoSampleAvailable, not mediaDataUpdated.
802
803         * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h:
804         * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm:
805         (WebCore::WebAudioSourceProviderAVFObjC::~WebAudioSourceProviderAVFObjC):
806         (WebCore::WebAudioSourceProviderAVFObjC::provideInput): Use a mutex. Get rid of m_writeAheadCount,
807         it is always 0.
808         (WebCore::WebAudioSourceProviderAVFObjC::prepare): Use a lock.
809         (WebCore::WebAudioSourceProviderAVFObjC::unprepare): Ditto.
810         (WebCore::WebAudioSourceProviderAVFObjC::process): Ditto.
811         * platform/mock/MockRealtimeAudioSource.h:
812         (WebCore::MockRealtimeAudioSource::renderInterval): Decrease the render interval.
813
814 2017-02-06  Antoine Quint  <graouts@apple.com>
815
816         [Modern Media Controls] Add a backdrop filter to the start button on macOS
817         https://bugs.webkit.org/show_bug.cgi?id=167879
818         <rdar://problem/30375174>
819
820         Reviewed by Eric Carlson.
821
822         Add a backdrop filter to the start button on macOS.
823
824         Test: media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-start-button-style.html
825
826         * Modules/modern-media-controls/controls/macos-inline-media-controls.css:
827         (.media-controls.mac.inline > button.start > div):
828
829 2017-02-06  Antoine Quint  <graouts@apple.com>
830
831         [Modern Media Controls] Bring fullscreen controls up to spec
832         https://bugs.webkit.org/show_bug.cgi?id=167875
833         <rdar://problem/29611222>
834
835         Reviewed by Eric Carlson.
836
837         We update the fullscreen PiP icon to have the correct size and add two new buttons
838         around the volume slider, "volume-down" to bring the volume to 0 and "volume-up"
839         to bring the volume to 1.
840
841         To accomodate the new volume buttons, we move the volume slider inside an additional
842         ButtonsContainer object, along with the two new buttons.
843
844         Tests: media/modern-media-controls/volume-down-support/volume-down-support.html
845                media/modern-media-controls/volume-up-support/volume-up-support.html
846
847         * Modules/modern-media-controls/controls/icon-service.js:
848         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.css:
849         (.media-controls.mac.fullscreen button.volume-down):
850         (.media-controls.mac.fullscreen button.volume-up):
851         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js:
852         * Modules/modern-media-controls/controls/volume-down-button.js: Added.
853         (VolumeDownButton):
854         * Modules/modern-media-controls/controls/volume-slider.js:
855         (VolumeSlider):
856         * Modules/modern-media-controls/controls/volume-up-button.js: Added.
857         (VolumeUpButton):
858         * Modules/modern-media-controls/images/macOS/pip-in-fullscreen@1x.png:
859         * Modules/modern-media-controls/images/macOS/pip-in-fullscreen@2x.png:
860         * Modules/modern-media-controls/images/macOS/volume-down-fullscreen@1x.png: Added.
861         * Modules/modern-media-controls/images/macOS/volume-down-fullscreen@2x.png: Added.
862         * Modules/modern-media-controls/images/macOS/volume-up-fullscreen@1x.png: Added.
863         * Modules/modern-media-controls/images/macOS/volume-up-fullscreen@2x.png: Added.
864         * Modules/modern-media-controls/js-files:
865         * Modules/modern-media-controls/media/media-controller.js:
866         (MediaController.prototype._updateControlsIfNeeded):
867         * Modules/modern-media-controls/media/volume-down-support.js: Added.
868         (VolumeDownSupport.prototype.get control):
869         (VolumeDownSupport.prototype.buttonWasPressed):
870         (VolumeDownSupport):
871         * Modules/modern-media-controls/media/volume-up-support.js: Added.
872         (VolumeUpSupport.prototype.get control):
873         (VolumeUpSupport.prototype.buttonWasPressed):
874         (VolumeUpSupport):
875         * WebCore.xcodeproj/project.pbxproj:
876
877 2017-02-06  Antoine Quint  <graouts@apple.com>
878
879         [Modern Media Controls] Improve handling of <video> with only audio tracks
880         https://bugs.webkit.org/show_bug.cgi?id=167836
881         <rdar://problem/30255812>
882
883         Reviewed by Dean Jackson.
884
885         We now check for the availability of video tracks before considering a <video>
886         element is displaying an actual video file and turning auto-hide on. We also
887         check that we have video tracks before enabling the fullscreen button. This
888         brings the behavior of a <video> pointing to a resource with no video tracks
889         to be the same as an <audio> element.
890
891         Test: media/modern-media-controls/media-controller/media-controller-video-with-only-audio.html
892
893         * Modules/modern-media-controls/media/controls-visibility-support.js:
894         (ControlsVisibilitySupport.prototype.get tracksToMonitor):
895         (ControlsVisibilitySupport.prototype._updateControls):
896         (ControlsVisibilitySupport):
897         * Modules/modern-media-controls/media/fullscreen-support.js:
898         (FullscreenSupport.prototype.syncControl):
899         (FullscreenSupport):
900
901 2017-02-06  Alex Christensen  <achristensen@webkit.org>
902
903         Fix WinCairo build after r211681
904         https://bugs.webkit.org/show_bug.cgi?id=167096
905
906         * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp:
907         Include some necessary GLES headers.
908
909 2017-02-05  Wenson Hsieh  <wenson_hsieh@apple.com>
910
911         Data interaction fails in Safari splitscreen mode when dropping into a contenteditable
912         https://bugs.webkit.org/show_bug.cgi?id=167862
913         <rdar://problem/30368405>
914
915         Reviewed by Tim Horton.
916
917         Adds a counter to WebItemProviderPasteboard that can incremented, decremented, and queried by clients.
918
919         * platform/ios/WebItemProviderPasteboard.h:
920         * platform/ios/WebItemProviderPasteboard.mm:
921         (-[WebItemProviderPasteboard init]):
922         (-[WebItemProviderPasteboard hasPendingOperation]):
923         (-[WebItemProviderPasteboard incrementPendingOperationCount]):
924         (-[WebItemProviderPasteboard decrementPendingOperationCount]):
925
926 2017-02-05  Simon Fraser  <simon.fraser@apple.com>
927
928         Remove unparentsOffscreenTiles logic in TileController
929         https://bugs.webkit.org/show_bug.cgi?id=167823
930
931         Reviewed by Tim Horton.
932
933         Give all TileGrids the "unparents offscreen tiles" behavior. This was enabled for
934         only the page tiles in WK2 on Mac and iOS, but there's no reason to not use it for
935         tiled composited layers also.
936
937         Also use more modern C++ idioms in a few places.
938
939         * platform/graphics/TiledBacking.h:
940         * platform/graphics/ca/TileController.h:
941         * platform/graphics/ca/TileGrid.cpp:
942         (WebCore::TileGrid::revalidateTiles):
943         (WebCore::TileGrid::ensureTilesForRect):
944         * rendering/RenderLayerBacking.cpp:
945         (WebCore::RenderLayerBacking::RenderLayerBacking):
946
947 2017-02-05  Antoine Quint  <graouts@apple.com>
948
949         [Modern Media Controls] PiP button is not visible with a live broadcast video
950         https://bugs.webkit.org/show_bug.cgi?id=167794
951         <rdar://problem/30348790>
952
953         Reviewed by Dean Jackson.
954
955         We were only listening to the "loadedmetadata", "error", "webkitpresentationmodechanged"
956         and "webkitcurrentplaybacktargetiswirelesschanged" events to invalidate the enabled state
957         for the PiP button. We also need to check availability of video tracks, which we already
958         did for fullscreen, which is quite similar.
959         
960         So we now listen to "addtrack", "removetrack" and "change" events on the media.videoTracks
961         property, which correctly invalidates the PiP button when the first video track becomes
962         available or the last video track is removed.
963
964         Since a couple of other MediaControllerSupport subclasses (FullscreenSupport and TracksSupport)
965         would also listen to those events on various track types, we add a new "tracksToMonitor"
966         property on MediaControllerSupport which subclasses can override to provide a list of tracks
967         that should listen to those events. This removes the need for dedicated construction and
968         destruction time in MediaControllerSupport subclasses that need to listen to events on
969         tracks rather than the media itself.
970
971         Test: http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast.html
972
973         * Modules/modern-media-controls/media/fullscreen-support.js:
974         (FullscreenSupport):
975         (FullscreenSupport.prototype.get tracksToMonitor):
976         (FullscreenSupport.prototype.destroy): Deleted.
977         * Modules/modern-media-controls/media/media-controller-support.js:
978         (MediaControllerSupport):
979         (MediaControllerSupport.prototype.destroy):
980         (MediaControllerSupport.prototype.get tracksToMonitor):
981         * Modules/modern-media-controls/media/pip-support.js:
982         (PiPSupport.prototype.get tracksToMonitor):
983         * Modules/modern-media-controls/media/tracks-support.js:
984         (TracksSupport):
985         (TracksSupport.prototype.get tracksToMonitor):
986         (TracksSupport.prototype.destroy): Deleted.
987
988 2017-02-05  Antoine Quint  <graouts@apple.com>
989
990         [Modern Media Controls] Time labels may wrap instead of displaying on a single line
991         https://bugs.webkit.org/show_bug.cgi?id=167835
992         <rdar://problem/30340534>
993
994         Reviewed by Dean Jackson.
995
996         No text in modern media controls is expected to wrap, so let's prevent any wrapping.
997
998         Test: media/modern-media-controls/time-label/time-label-white-space-nowrap.html
999
1000         * Modules/modern-media-controls/controls/media-controls.css:
1001         (.media-controls):
1002
1003 2017-02-04  Simon Fraser  <simon.fraser@apple.com>
1004
1005         Clean up how GraphicsLayer's "inWindow" state is set, and fix some issues with Page Overlays
1006         https://bugs.webkit.org/show_bug.cgi?id=167850
1007
1008         Reviewed by Tim Horton.
1009         
1010         RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants() walked the RenderLayer
1011         tree to set the GraphicsLayer's "inWindow" state. This had the problem of skipping non-primary
1012         GraphicsLayers. We also never did this work for page overlay layers.
1013
1014         Fix by giving GraphicsLayers a recursive function that sets the inWindow state, and call that
1015         from RenderLayerCompositor::setIsInWindow() and PageOverlayController.
1016
1017         PageOverlayController also needs to implement tiledBackingUsageChanged so that tiled backings
1018         created dynamically get the correct in-window state.
1019
1020         Page overlays also had some serious issues in MiniBrowser, in that they disappeared on reload,
1021         and on hide/show web view. This was because the overlay root layers were re-parented, but
1022         addChild() for each overlay's layer wasn't called. Clean up by replacing willAttachRootLayer() followed
1023         by viewOverlayRootLayer()/documentOverlayRootLayer() with single calls that set up the layers,
1024         update the inWindow state, and return the layer.
1025
1026         Make it possible to dump tile caches in page overlay tests.
1027
1028         Make showGraphicsLayers() always dump page overlay layers (source of much confusion).
1029
1030         Test: pageoverlay/overlay-remove-reinsert-view.html
1031
1032         * page/PageOverlayController.cpp:
1033         (WebCore::PageOverlayController::documentOverlayRootLayer):
1034         (WebCore::PageOverlayController::viewOverlayRootLayer):
1035         (WebCore::PageOverlayController::layerWithDocumentOverlays):
1036         (WebCore::PageOverlayController::layerWithViewOverlays):
1037         (WebCore::PageOverlayController::tiledBackingUsageChanged):
1038         (WebCore::PageOverlayController::willAttachRootLayer): Deleted.
1039         * page/PageOverlayController.h:
1040         * platform/graphics/GraphicsLayer.cpp:
1041         (WebCore::GraphicsLayer::setIsInWindowIncludingDescendants):
1042         (WebCore::dumpChildren):
1043         * platform/graphics/GraphicsLayer.h:
1044         * rendering/RenderLayerCompositor.cpp:
1045         (WebCore::RenderLayerCompositor::appendDocumentOverlayLayers):
1046         (WebCore::RenderLayerCompositor::setIsInWindow):
1047         (WebCore::RenderLayerCompositor::attachRootLayer):
1048         (WebCore::RenderLayerCompositor::rootLayerAttachmentChanged):
1049         (WebCore::RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants): Deleted.
1050         * rendering/RenderLayerCompositor.h:
1051         * testing/Internals.cpp:
1052         (WebCore::toLayerTreeFlags):
1053         (WebCore::Internals::layerTreeAsText):
1054         (WebCore::Internals::pageOverlayLayerTreeAsText):
1055         * testing/Internals.h:
1056         * testing/Internals.idl:
1057         * testing/MockPageOverlayClient.cpp:
1058         (WebCore::MockPageOverlayClient::layerTreeAsText):
1059         * testing/MockPageOverlayClient.h:
1060
1061 2017-02-05  Zalan Bujtas  <zalan@apple.com>
1062
1063         Simple line layout: Use RenderText::canUseSimpleFontCodePath() only as a hint.
1064         https://bugs.webkit.org/show_bug.cgi?id=167853
1065         <rdar://problem/30367302>
1066
1067         Reviewed by Simon Fraser.
1068
1069         Apparently RenderText::canUseSimpleFontCodePath() only checks if the string is qualified for
1070         the simple font code path. However certain css properties could still force us to use the complex
1071         path.
1072         In most cases, we still do only one string traversal thanks to TextRun::setCharacterScanForCodePath(). 
1073
1074         Test: fast/text/simple-line-layout-simple-text-but-complex-font-path.html
1075
1076         * rendering/SimpleLineLayout.cpp:
1077         (WebCore::SimpleLineLayout::canUseForFontAndText):
1078
1079 2017-02-05  Zan Dobersek  <zdobersek@igalia.com>
1080
1081         Move TextureMapper-specific logic out of GraphicsContext3DPrivate
1082         https://bugs.webkit.org/show_bug.cgi?id=167096
1083
1084         Reviewed by Alex Christensen.
1085
1086         Move the TextureMapper-specific functionality in GraphicsContext3DPrivate into a
1087         separate class. The new TextureMapperGC3DPlatformLayer class inherits from the
1088         class that's aliased to the PlatformLayer type, like GraphicsContext3DPrivate did
1089         before.
1090
1091         In GraphicsContext3D, the new m_texmapLayer member variable of the
1092         std::unique_ptr<TextureMapperGC3DPlatformLayer> type is used for configurations
1093         that enable TextureMapper, largely the same way the GraphicsContext3DPrivate
1094         object was used before. The remaining code in GraphicsContext3DPrivate is left
1095         unchanged to keep it working for other ports.
1096
1097         No new tests -- no change in behavior.
1098
1099         * platform/TextureMapper.cmake:
1100         * platform/graphics/GraphicsContext3D.h:
1101         * platform/graphics/GraphicsContext3DPrivate.cpp:
1102         (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
1103         (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate): Deleted.
1104         (WebCore::GraphicsContext3DPrivate::proxy): Deleted.
1105         (WebCore::GraphicsContext3DPrivate::swapBuffersIfNeeded): Deleted.
1106         (WebCore::GraphicsContext3DPrivate::paintToTextureMapper): Deleted.
1107         * platform/graphics/GraphicsContext3DPrivate.h:
1108         * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
1109         (WebCore::GraphicsContext3D::GraphicsContext3D):
1110         (WebCore::GraphicsContext3D::~GraphicsContext3D):
1111         (WebCore::GraphicsContext3D::makeContextCurrent):
1112         (WebCore::GraphicsContext3D::platformGraphicsContext3D):
1113         (WebCore::GraphicsContext3D::platformLayer):
1114         * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
1115         (WebCore::GraphicsContext3D::createForCurrentGLContext):
1116         * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp.
1117         (WebCore::TextureMapperGC3DPlatformLayer::TextureMapperGC3DPlatformLayer):
1118         (WebCore::TextureMapperGC3DPlatformLayer::~TextureMapperGC3DPlatformLayer):
1119         (WebCore::TextureMapperGC3DPlatformLayer::makeContextCurrent):
1120         (WebCore::TextureMapperGC3DPlatformLayer::platformContext):
1121         (WebCore::TextureMapperGC3DPlatformLayer::proxy):
1122         (WebCore::TextureMapperGC3DPlatformLayer::swapBuffersIfNeeded):
1123         (WebCore::TextureMapperGC3DPlatformLayer::paintToTextureMapper):
1124         * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h.
1125         (WebCore::TextureMapperGC3DPlatformLayer::renderStyle):
1126
1127 2017-02-05  Zalan Bujtas  <zalan@apple.com>
1128
1129         Simple line layout: Bail out from Simple Line Layout on surrogate pairs.
1130         https://bugs.webkit.org/show_bug.cgi?id=167840
1131         <rdar://problem/30364784>
1132
1133         Reviewed by Myles C. Maxfield.
1134
1135         Surrogate pairs require special line breaking logic. 
1136
1137         Test: fast/text/simple-line-layout-no-surrogate-pairs.html
1138
1139         * rendering/SimpleLineLayout.cpp:
1140         (WebCore::SimpleLineLayout::canUseForCharacter):
1141         (WebCore::SimpleLineLayout::canUseForText): Checking against special characters is faster than
1142         checking against glyphs. Reverse their order. 
1143         (WebCore::SimpleLineLayout::printReason):
1144
1145 2017-02-04  Joseph Pecoraro  <pecoraro@apple.com>
1146
1147         Static Analyzer: WebCoreNSURLExtras.mm: Potential leak of memory pointed to by 'allBytesBuffer'
1148         https://bugs.webkit.org/show_bug.cgi?id=167849
1149
1150         Reviewed by Sam Weinig.
1151
1152         Source/WebCore/platform/mac/WebCoreNSURLExtras.mm:883:20: warning: Potential leak of memory pointed to by 'allBytesBuffer'
1153                     return nil;
1154                            ^~~
1155
1156         * platform/mac/WebCoreNSURLExtras.mm:
1157         (WebCore::dataForURLComponentType):
1158         Free the potentially malloc'd buffer before the early return.
1159
1160 2017-02-04  Chris Dumez  <cdumez@apple.com>
1161
1162         Unreviewed, fix mistake in comment added in r211569.
1163
1164         * history/PageCache.cpp:
1165         (WebCore::PageCache::removeAllItemsForPage):
1166
1167 2017-02-04  Yoav Weiss  <yoav@yoav.ws>
1168
1169         Fix memory issues related to preload eviction.
1170         https://bugs.webkit.org/show_bug.cgi?id=167838
1171
1172         Reviewed by Andreas Kling.
1173
1174         This avoids removing resources from m_preloads during the iteration
1175         by creating a second HashSetList containing the remaining link preloads.
1176
1177         No new tests but this will fix crashes on the leak bots.
1178
1179         * loader/cache/CachedResourceLoader.cpp:
1180         (WebCore::CachedResourceLoader::clearPreloads):
1181
1182 2017-02-04  Zalan Bujtas  <zalan@apple.com>
1183
1184         Simple line layout: Skip 16bit specific checks on 8bit content.
1185         https://bugs.webkit.org/show_bug.cgi?id=167831
1186         <rdar://problem/30361948>
1187
1188         Reviewed by Antti Koivisto and Myles C. Maxfield.
1189
1190         Skip various checks on 8bit content.
1191
1192         Covered by existing tests.
1193
1194         * rendering/SimpleLineLayout.cpp:
1195         (WebCore::SimpleLineLayout::canUseForCharacter):
1196         (WebCore::SimpleLineLayout::canUseForText):
1197         (WebCore::SimpleLineLayout::canUseForFontAndText):
1198
1199 2017-02-03  Zalan Bujtas  <zalan@apple.com>
1200
1201         Simple line layout: Remove redundant codepath check.
1202         https://bugs.webkit.org/show_bug.cgi?id=167827
1203         <rdar://problem/30361850>
1204
1205         Reviewed by Myles C. Maxfield.
1206
1207         FontCascade::codePath() iterates through the entire text. It's rather wasteful to do twice.
1208
1209         No change in functionality.
1210
1211         * rendering/SimpleLineLayout.cpp:
1212         (WebCore::SimpleLineLayout::canUseForFontAndText):
1213         (WebCore::SimpleLineLayout::printReason):
1214
1215 2017-02-03  Myles C. Maxfield  <mmaxfield@apple.com>
1216
1217         REGRESSION(r204858): Synthetic bold text in vertical writing mode is rotated away from original text
1218         https://bugs.webkit.org/show_bug.cgi?id=167826
1219         <rdar://problem/28193222>
1220
1221         Reviewed by Zalan Bujtas.
1222
1223         When drawing vertical text, the rotation is not reset between successive paint calls. We implement
1224         synthetic bold by drawing text twice, which means that the second draw call was getting rotated
1225         twice. This was an oversight in r204858.
1226
1227         Test: fast/text/synthetic-bold-vertical-text.html
1228
1229         * platform/graphics/cocoa/FontCascadeCocoa.mm:
1230         (WebCore::showGlyphsWithAdvances):
1231
1232 2017-02-03  Joseph Pecoraro  <pecoraro@apple.com>
1233
1234         Performance Timing: Convert WTF::MonotonicTime and WTF::Seconds
1235         https://bugs.webkit.org/show_bug.cgi?id=167768
1236
1237         Reviewed by Geoffrey Garen.
1238
1239         The public APIs still return double (DOMHighResTimeStamp), which
1240         is milliseconds since a time origin:
1241         https://w3c.github.io/hr-time/#dom-domhighrestimestamp
1242
1243         * loader/LoadTiming.cpp:
1244         (WebCore::LoadTiming::secondsSinceStartTime):
1245         (WebCore::LoadTiming::monotonicTimeToPseudoWallTime):
1246         (WebCore::LoadTiming::markStartTime):
1247         (WebCore::LoadTiming::addRedirect):
1248         (WebCore::LoadTiming::monotonicTimeToZeroBasedDocumentTime): Deleted.
1249         * loader/LoadTiming.h:
1250         (WebCore::LoadTiming::markUnloadEventStart):
1251         (WebCore::LoadTiming::markUnloadEventEnd):
1252         (WebCore::LoadTiming::markRedirectStart):
1253         (WebCore::LoadTiming::markRedirectEnd):
1254         (WebCore::LoadTiming::markFetchStart):
1255         (WebCore::LoadTiming::setResponseEnd):
1256         (WebCore::LoadTiming::markLoadEventStart):
1257         (WebCore::LoadTiming::markLoadEventEnd):
1258         (WebCore::LoadTiming::startTime):
1259         (WebCore::LoadTiming::unloadEventStart):
1260         (WebCore::LoadTiming::unloadEventEnd):
1261         (WebCore::LoadTiming::redirectStart):
1262         (WebCore::LoadTiming::redirectEnd):
1263         (WebCore::LoadTiming::fetchStart):
1264         (WebCore::LoadTiming::responseEnd):
1265         (WebCore::LoadTiming::loadEventStart):
1266         (WebCore::LoadTiming::loadEventEnd):
1267         (WebCore::LoadTiming::redirectCount):
1268         (WebCore::LoadTiming::referenceMonotonicTime):
1269         (WebCore::LoadTiming::referenceWallTime):
1270         Use MonotonicTime and WallTime for timestamps and references.
1271
1272         * dom/Document.cpp:
1273         (WebCore::Document::setReadyState):
1274         (WebCore::Document::finishedParsing):
1275         (WebCore::Document::monotonicTimestamp):
1276         * dom/DocumentTiming.h:
1277         (WebCore::DocumentTiming::DocumentTiming): Deleted.
1278         * dom/ScriptedAnimationController.cpp:
1279         (WebCore::ScriptedAnimationController::serviceScriptedAnimations):
1280         * inspector/InspectorNetworkAgent.cpp:
1281         (WebCore::InspectorNetworkAgent::buildObjectForTiming):
1282         (WebCore::InspectorNetworkAgent::didFinishLoading):
1283         * loader/DocumentLoader.cpp:
1284         (WebCore::DocumentLoader::finishedLoading):
1285         (WebCore::DocumentLoader::dataReceived):
1286         * loader/DocumentLoader.h:
1287         * loader/SubresourceLoader.cpp:
1288         (WebCore::SubresourceLoader::didFinishLoading):
1289         * loader/cache/CachedResourceLoader.cpp:
1290         (WebCore::CachedResourceLoader::requestResource):
1291         * page/DOMWindow.cpp:
1292         (WebCore::DOMWindow::performance):
1293         Use new types instead of raw doubles.
1294
1295         * page/Performance.cpp:
1296         (WebCore::Performance::Performance):
1297         (WebCore::Performance::now):
1298         (WebCore::Performance::reduceTimeResolution):
1299         (WebCore::Performance::addResourceTiming):
1300         * page/Performance.h:
1301         Do time arithmatic with WTF::Time classes.
1302         This clarifies that we reduce our timestamps to 100us
1303         resolution instead of the maximum 5us allowed by the spec.
1304
1305         * page/PerformanceResourceTiming.cpp:
1306         (WebCore::monotonicTimeToDOMHighResTimeStamp):
1307         (WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
1308         (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp):
1309         * page/PerformanceResourceTiming.h:
1310         * page/PerformanceTiming.cpp:
1311         (WebCore::PerformanceTiming::resourceLoadTimeRelativeToFetchStart):
1312         (WebCore::PerformanceTiming::monotonicTimeToIntegerMilliseconds):
1313         (WebCore::toIntegerMilliseconds): Deleted.
1314         * page/PerformanceTiming.h:
1315         Do time arithmatic with WTF::Time classes.
1316
1317         * workers/DedicatedWorkerGlobalScope.cpp:
1318         (WebCore::DedicatedWorkerGlobalScope::create):
1319         (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
1320         * workers/DedicatedWorkerGlobalScope.h:
1321         * workers/DedicatedWorkerThread.cpp:
1322         (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
1323         (WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
1324         * workers/DedicatedWorkerThread.h:
1325         * workers/WorkerGlobalScope.cpp:
1326         (WebCore::WorkerGlobalScope::WorkerGlobalScope):
1327         * workers/WorkerGlobalScope.h:
1328         * workers/WorkerGlobalScopeProxy.h:
1329         * workers/WorkerMessagingProxy.cpp:
1330         (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
1331         * workers/WorkerMessagingProxy.h:
1332         * workers/WorkerThread.cpp:
1333         (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
1334         (WebCore::WorkerThread::WorkerThread):
1335         * workers/WorkerThread.h:
1336         Pass time origin as MonotonicTime.
1337
1338         * workers/Worker.cpp:
1339         (WebCore::Worker::create):
1340         (WebCore::Worker::notifyFinished):
1341         * workers/Worker.h:
1342         Rename creation timestamp member. This matches Document's m_documentCreationTime.
1343
1344 2017-02-03  Jeremy Jones  <jeremyj@apple.com>
1345
1346         WK1 mouse events are missing movementX and movementY for pointerlock.
1347         https://bugs.webkit.org/show_bug.cgi?id=167775
1348         rdar://problem/30343810
1349
1350         Reviewed by Alexey Proskuryakov.
1351
1352         pointer-lock/mouse-event-delivery.html
1353
1354         Improve mouse-event-delivery.html test to mouse move and check for valid movementX and movementY.
1355         
1356         * platform/mac/PlatformEventFactoryMac.mm:
1357         (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder): WK1 plumb throuhg movementX and movementY
1358
1359 2017-02-03  Simon Fraser  <simon.fraser@apple.com>
1360
1361         Correctly set the "inWindow" flag for TileControllers that aren't the page tiles, and clarify "usingTiledBacking" logic
1362         https://bugs.webkit.org/show_bug.cgi?id=167774
1363
1364         Reviewed by Tim Horton.
1365
1366         RenderLayerBacking had some very confusing "usingTiledCacheLayer" uses.
1367
1368         Its member variable, m_usingTiledCacheLayer, really meant "m_isMainFrameLayerWithTiledBacking" so make it so.
1369         It had a usingTiledBacking(), which returned the same thing, which this patch replaces with isMainFrameLayerWithTiledBacking().
1370
1371         The fact that usingTiledBacking() was only true for the page tiled layer tripped up
1372         RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants(), which would only ever call setIsInWindow()
1373         on the page tiled layer. These changes fix that.
1374
1375         Also make a way for tests to unparent the web view via UIScriptController, and dump out the "in window"
1376         status of TileBackings when dumping tile caches.
1377
1378         Test: tiled-drawing/tiled-backing-in-window.html
1379
1380         * platform/graphics/TiledBacking.h:
1381         * platform/graphics/ca/GraphicsLayerCA.cpp:
1382         (WebCore::GraphicsLayerCA::dumpAdditionalProperties):
1383         * platform/graphics/ca/TileController.h:
1384         * rendering/RenderLayerBacking.cpp:
1385         (WebCore::RenderLayerBacking::RenderLayerBacking):
1386         (WebCore::computePageTiledBackingCoverage):
1387         (WebCore::RenderLayerBacking::adjustTiledBackingCoverage):
1388         (WebCore::RenderLayerBacking::setTiledBackingHasMargins):
1389         (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
1390         (WebCore::RenderLayerBacking::shouldClipCompositedBounds):
1391         (WebCore::RenderLayerBacking::updateDescendantClippingLayer):
1392         (WebCore::RenderLayerBacking::updateRootLayerConfiguration):
1393         (WebCore::RenderLayerBacking::paintsIntoWindow):
1394         (WebCore::computeTileCoverage): Deleted.
1395         * rendering/RenderLayerBacking.h:
1396         * rendering/RenderLayerCompositor.cpp:
1397         (WebCore::RenderLayerCompositor::flushPendingLayerChanges):
1398         (WebCore::RenderLayerCompositor::rootFixedBackgroundsChanged):
1399         (WebCore::RenderLayerCompositor::setIsInWindowForLayerIncludingDescendants):
1400         (WebCore::RenderLayerCompositor::supportsFixedRootBackgroundCompositing):
1401         (WebCore::RenderLayerCompositor::documentUsesTiledBacking):
1402
1403 2017-02-03  Zalan Bujtas  <zalan@apple.com>
1404
1405         Simple line layout: Bail out from Simple Line Layout when the primary font is insufficient.
1406         https://bugs.webkit.org/show_bug.cgi?id=167820
1407         <rdar://problem/30359685>
1408
1409         Reviewed by Myles C. Maxfield.
1410
1411         Currently simple line layout requires the primary font to have all the glyps for the content.
1412
1413         Test: fast/text/simple-line-layout-do-not-support-unicode-range.html
1414
1415         * rendering/SimpleLineLayout.cpp:
1416         (WebCore::SimpleLineLayout::canUseForText):
1417         (WebCore::SimpleLineLayout::canUseForFontAndText):
1418         (WebCore::SimpleLineLayout::printReason):
1419
1420 2017-02-03  Jer Noble  <jer.noble@apple.com>
1421
1422         ASSERT in HTMLMediaElement::~HTMLMediaElement
1423         https://bugs.webkit.org/show_bug.cgi?id=167818
1424
1425         Reviewed by Brent Fulgham.
1426
1427         Test: media/audio-dealloc-crash.html
1428
1429         HTMLMediaElement's MediaElementSession can nominate the HTMLMediaElement itself
1430         to become the playback controls session from inside the HTMLMediaElement destructor. Protect
1431         against this by clearing out the session before calling updatePlaybackControlsManager().
1432
1433         * html/HTMLMediaElement.cpp:
1434         (WebCore::HTMLMediaElement::~HTMLMediaElement):
1435
1436 2017-02-03  Daniel Bates  <dabates@apple.com>
1437
1438         [Mac][WK2] Add SPI to override the Content Security Policy of a page
1439         https://bugs.webkit.org/show_bug.cgi?id=167810
1440         <rdar://problem/30102568>
1441
1442         Reviewed by Anders Carlsson.
1443
1444         * dom/Document.cpp:
1445         (WebCore::Document::initSecurityContext): Apply the embedding client's override Content Security
1446         Policy to the document if one exists.
1447         * loader/FrameLoaderClient.h: Add function overrideContentSecurityPolicy() that a FrameLoaderClient
1448         can override to provide a custom Content Security Policy for a document (defaults: null string - no policy).
1449         As its name implies, the policy returned by overrideContentSecurityPolicy() will define the Content
1450         Security Policy for the document, overriding any subsequently received Content Security Policy for
1451         the document.
1452         * page/csp/ContentSecurityPolicy.cpp:
1453         (WebCore::ContentSecurityPolicy::copyStateFrom): Only copy policies from the specified ContentSecurityPolicy
1454         object if our policy was not specified by the embedding client.
1455         (WebCore::ContentSecurityPolicy::didReceiveHeader): Set ContentSecurityPolicy::m_hasAPIPolicy to true
1456         when we receive an API policy from the embedding client (ContentSecurityPolicy::PolicyFrom::API). An
1457         API policy must be defined before a policy received from a document. Do not process a received header
1458         if we already have an API policy as the API policy overrides all other policies.
1459         * page/csp/ContentSecurityPolicy.h:
1460
1461 2017-02-03  Chris Dumez  <cdumez@apple.com>
1462
1463         Drop Mac App Store workaround for window.getComputedStyle()
1464         https://bugs.webkit.org/show_bug.cgi?id=166891
1465         <rdar://problem/28282452>
1466
1467         Reviewed by Sam Weinig.
1468
1469         Drop Mac App Store workaround for window.getComputedStyle() now that
1470         <rdar://problem/28020681> has been fixed.
1471
1472         * page/DOMWindow.cpp:
1473         * page/DOMWindow.h:
1474         * page/DOMWindow.idl:
1475         * platform/RuntimeApplicationChecks.h:
1476         * platform/RuntimeApplicationChecks.mm:
1477         (WebCore::MacApplication::isAppStore): Deleted.
1478
1479 2017-02-03  Chris Dumez  <cdumez@apple.com>
1480
1481         Dismiss HTML form validation popover when pressing Escape key
1482         https://bugs.webkit.org/show_bug.cgi?id=167716
1483         <rdar://problem/29872943>
1484
1485         Reviewed by Simon Fraser.
1486
1487         Dismiss any visible HTML form validation popover when pressing
1488         the Escape key.
1489
1490         Test: fast/forms/validation-bubble-escape-key-dismiss.html
1491
1492         * page/EventHandler.cpp:
1493         (WebCore::EventHandler::keyEvent):
1494         * page/ValidationMessageClient.h:
1495
1496 2017-02-03  Jeremy Jones  <jeremyj@apple.com>
1497
1498         Pointer lock events should be delivered directly to the target element
1499         https://bugs.webkit.org/show_bug.cgi?id=167134
1500         rdar://problem/30268004
1501
1502         Reviewed by Dean Jackson.
1503
1504         pointer-lock/mouse-event-delivery.html: Enabled for mac, added wheel event tests.
1505
1506         When pointer is locked on an element, route mouse events directly to the target element, instead of 
1507         doing the normal event disptach.
1508
1509         * page/EventHandler.cpp:
1510         (WebCore::EventHandler::handleMousePressEvent):
1511         (WebCore::EventHandler::handleMouseDoubleClickEvent):
1512         (WebCore::EventHandler::handleMouseMoveEvent):
1513         (WebCore::EventHandler::handleMouseReleaseEvent):
1514         (WebCore::EventHandler::handleMouseForceEvent):
1515         (WebCore::EventHandler::handleWheelEvent):
1516         * page/PointerLockController.cpp:
1517         (WebCore::PointerLockController::isLocked): Added.
1518         (WebCore::PointerLockController::dispatchLockedWheelEvent): Added.
1519         * page/PointerLockController.h:
1520
1521 2017-02-03  Yoav Weiss  <yoav@yoav.ws>
1522
1523         Avoid evicting link preload resources when parsing is done.
1524         https://bugs.webkit.org/show_bug.cgi?id=167415
1525
1526         Reviewed by Ryosuke Niwa.
1527
1528         Currently all preloads (speculative and link preload) are being cleared when the document has finished parsing.
1529         When it comes to link preloads, it can result in resources being cleared before the page had a chance to use them. (e.g. resources
1530         that are preloaded in order to be loaded through script after DOMContentLoaded)
1531
1532         This patch fixes that by marking link preload resources as such, so that they can be handled separately inside clearPreloads().
1533         As this fix also exposed an issue with load cancelation with invalid hrefs (which tests were passing before due to the preloads
1534         being cleared), said issue is also fixed by clearing previousely preloaded resources if an invalid link preload is later detected.
1535
1536         Test: http/tests/preload/not_evicting_preload_at_onload.html
1537
1538         * dom/Document.cpp:
1539         (WebCore::Document::finishedParsing): Only clear speculative preloads when parsing is finished.
1540         * loader/LinkLoader.cpp:
1541         (WebCore::LinkLoader::preloadIfNeeded): Set request flag indicating link preload.
1542         (WebCore::LinkLoader::loadLink): Clear previousely preloaded resource to cancel their load.
1543         * loader/LinkPreloadResourceClients.h:
1544         (WebCore::LinkPreloadResourceClient::clearResource): Call cancelLoad() when the client is cleared.
1545         * loader/cache/CachedResource.h:
1546         (WebCore::CachedResource::isLinkPreload):
1547         (WebCore::CachedResource::setLinkPreload):
1548         * loader/cache/CachedResource.cpp:
1549         (WebCore::CachedResource::CachedResource): Initialize m_isLinkPreload with the request's value.
1550         * loader/cache/CachedResourceLoader.cpp:
1551         (WebCore::CachedResourceLoader::~CachedResourceLoader):
1552         (WebCore::CachedResourceLoader::requestResource): Mirror the request link preload flag to the resource if it's fetched from cache.
1553         (WebCore::CachedResourceLoader::clearPreloads): Add a "speculative only" mode, which doesn't clear link preloads.
1554         * loader/cache/CachedResourceLoader.h:
1555         * loader/cache/CachedResourceRequest.cpp:
1556         (WebCore::CachedResourceRequest::CachedResourceRequest):
1557         * loader/cache/CachedResourceRequest.h:
1558         (WebCore::CachedResourceRequest::isLinkPreload):
1559         (WebCore::CachedResourceRequest::setIsLinkPreload):
1560
1561 2017-02-03  Zalan Bujtas  <zalan@apple.com>
1562
1563         Simple line layout: Removing adjacent trailing whitespace runs should not crash.
1564         https://bugs.webkit.org/show_bug.cgi?id=167803
1565         <rdar://problem/30337368>
1566
1567         Reviewed by Antti Koivisto.
1568
1569         In case of adjacent collapsed whitespace fragments, the length of these fragments (TextFragmentIterator::TextFragment)
1570         do not necessarily equal the length of the final runs (SimpleLineLayout::Run).
1571         This patch removes the dependency on the length and switches over to using the position information instead.
1572
1573         Test: fast/text/simple-line-layout-multiple-trailingwhitespace-crash.html
1574
1575         * rendering/SimpleLineLayout.cpp:
1576         (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded):
1577         (WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace):
1578
1579 2017-02-03  Brent Fulgham  <bfulgham@apple.com>
1580
1581         Correct memory leak in MediaConstraints
1582         https://bugs.webkit.org/show_bug.cgi?id=167744
1583         <rdar://problem/30331444>
1584
1585         Reviewed by Anders Carlsson.
1586
1587         ConstraintHolder returns a reference to an object created by operator new. When the
1588         returned value is assigned or stored in Vector or other containers we leak memory.
1589         Instead, this value should just be returned as a regular object so that the return
1590         value optimization can make sure memory is properly (and efficiently) used.
1591
1592         Tested by existing mediastream tests.
1593
1594         * platform/mediastream/MediaConstraints.h:
1595         (WebCore::FlattenedConstraint::ConstraintHolder::create): Return by value.
1596         (WebCore::FlattenedConstraint::ConstraintHolder::~ConstraintHolder): Don't attempt to
1597         delete memory that was moved away.
1598         (WebCore::FlattenedConstraint::ConstraintHolder::ConstraintHolder): Add Move constructor.
1599
1600 2017-02-03  Chris Dumez  <cdumez@apple.com>
1601
1602         Fix bad assertion under HTMLTreeBuilder::processStartTagForInBody()
1603         https://bugs.webkit.org/show_bug.cgi?id=167799
1604         <rdar://problem/30237241>
1605
1606         Reviewed by Brent Fulgham.
1607
1608         Fix bad assertion under HTMLTreeBuilder::processStartTagForInBody() that was
1609         expecting the root element to be an <html> element when parsing a <frameset>.
1610         While this assertion is true in theory and as per the specification, it does
1611         not hold in WebKit when parsing a DocumentFragment. This is because WebKit
1612         has an optimization causing us to have a DocumentFragment as root element
1613         when parsing a fragment. See the following constructor:
1614         "HTMLTreeBuilder(HTMLDocumentParser&, DocumentFragment&, Element&, ParserContentPolicy, const HTMLParserOptions&)"
1615
1616         which has the following code:
1617         """
1618         // https://html.spec.whatwg.org/multipage/syntax.html#parsing-html-fragments
1619         // For efficiency, we skip step 5 ("Let root be a new html element with no attributes") and instead use the DocumentFragment as a root node.
1620         m_tree.openElements().pushRootNode(HTMLStackItem::create(fragment));
1621         """
1622
1623         Update the assertion to expect a DocumentFragment as root element when parsing
1624         a fragment, and keep expecting an <html> element otherwise.
1625
1626         Test: fast/parser/fragment-with-frameset-crash.html
1627
1628         * html/parser/HTMLTreeBuilder.cpp:
1629         (WebCore::HTMLTreeBuilder::processStartTagForInBody):
1630
1631 2017-02-03  Antoine Quint  <graouts@apple.com>
1632
1633         [Modern Media Controls] Skip back button is visible with a live broadcast video
1634         https://bugs.webkit.org/show_bug.cgi?id=167793
1635
1636         Reviewed by Eric Carlson.
1637
1638         We shouldn't be showing the skip back button when a live broadcast video is playing.
1639         We now listen to the "durationchange" event to determine when we have an inifinite-duration
1640         video and disable the skip button in that case.
1641
1642         Test: http/tests/media/modern-media-controls/skip-back-support/skip-back-support-live-broadcast.html
1643
1644         * Modules/modern-media-controls/media/skip-back-support.js:
1645         (SkipBackSupport.prototype.get mediaEvents):
1646         (SkipBackSupport.prototype.syncControl):
1647         (SkipBackSupport):
1648
1649 2017-02-03  Alex Christensen  <achristensen@webkit.org>
1650
1651         URLParser: implement forbidden host code points for non-special URLs
1652         https://bugs.webkit.org/show_bug.cgi?id=167779
1653
1654         Reviewed by Chris Dumez.
1655
1656         Covered by newly passing web platform tests.
1657
1658         * platform/URLParser.cpp:
1659         (WebCore::isC0Control):
1660         (WebCore::isForbiddenHostCodePoint):
1661         (WebCore::URLParser::parseHostAndPort):
1662         In non-special URL hosts such as customprotocol://strange%host
1663         don't accept characters that are part of the URL grammar and would be forbidden
1664         in a special URL host, like https://not[allowed
1665         This was recently added to the spec in https://github.com/whatwg/url/issues/214
1666
1667 2017-02-03  Per Arne Vollan  <pvollan@apple.com>
1668
1669         The CSS property -webkit-text-stroke is not applied on captions.
1670         https://bugs.webkit.org/show_bug.cgi?id=167687
1671
1672         Reviewed by Brent Fulgham.
1673
1674         Add style to list of valid properties for cue.
1675
1676         Test: media/track/track-css-stroke-cues.html
1677
1678         * css/StyleResolver.cpp:
1679         (WebCore::StyleResolver::isValidCueStyleProperty):
1680
1681 2017-02-03  Alex Christensen  <achristensen@webkit.org>
1682
1683         Align URL setters with spec for URLs that cannot be a base URL
1684         https://bugs.webkit.org/show_bug.cgi?id=167783
1685
1686         Reviewed by Chris Dumez.
1687
1688         Setting things like credentials on mailto URLs doesn't make sense.
1689         It's forbidden by the spec.
1690
1691         Covered by newly passing web platform tests.
1692
1693         * html/URLUtils.h:
1694         (WebCore::URLUtils<T>::setUsername):
1695         (WebCore::URLUtils<T>::setPassword):
1696         (WebCore::URLUtils<T>::setHost):
1697         (WebCore::URLUtils<T>::setHostname):
1698         (WebCore::URLUtils<T>::setPort):
1699         (WebCore::URLUtils<T>::setPathname):
1700         * platform/URL.cpp:
1701         (WebCore::URL::serialize):
1702         * platform/URL.h:
1703         (WebCore::URL::cannotBeABaseURL):
1704
1705 2017-02-03  Eric Carlson  <eric.carlson@apple.com>
1706
1707         [Mac] Add classes to manage audio samples
1708         https://bugs.webkit.org/show_bug.cgi?id=167739
1709
1710         Reviewed by Jer Noble.
1711
1712         No new tests, this code isn't used yet.
1713
1714         * WebCore.xcodeproj/project.pbxproj:
1715         * platform/audio/mac/AudioSampleBufferList.cpp: Added.
1716         (WebCore::AudioSampleBufferList::create):
1717         (WebCore::AudioSampleBufferList::AudioSampleBufferList):
1718         (WebCore::AudioSampleBufferList::~AudioSampleBufferList):
1719         (WebCore::AudioSampleBufferList::setSampleCount):
1720         (WebCore::AudioSampleBufferList::applyGain):
1721         (WebCore::AudioSampleBufferList::mixFrom):
1722         (WebCore::AudioSampleBufferList::copyFrom):
1723         (WebCore::AudioSampleBufferList::copyTo):
1724         (WebCore::AudioSampleBufferList::reset):
1725         (WebCore::AudioSampleBufferList::zero):
1726         (WebCore::AudioSampleBufferList::zeroABL):
1727         (WebCore::AudioSampleBufferList::convertInput):
1728         (WebCore::AudioSampleBufferList::audioConverterCallback):
1729         (WebCore::AudioSampleBufferList::configureBufferListForStream):
1730         * platform/audio/mac/AudioSampleBufferList.h: Added.
1731         (WebCore::AudioSampleBufferList::streamDescription):
1732         (WebCore::AudioSampleBufferList::bufferList):
1733         (WebCore::AudioSampleBufferList::sampleCapacity):
1734         (WebCore::AudioSampleBufferList::sampleCount):
1735         (WebCore::AudioSampleBufferList::timestamp):
1736         (WebCore::AudioSampleBufferList::hostTime):
1737         (WebCore::AudioSampleBufferList::setTimes):
1738         (WebCore::AudioSampleBufferList::audioBufferListSizeForStream):
1739         * platform/audio/mac/AudioSampleDataSource.cpp: Added.
1740         (WebCore::AudioSampleDataSource::create):
1741         (WebCore::AudioSampleDataSource::AudioSampleDataSource):
1742         (WebCore::AudioSampleDataSource::~AudioSampleDataSource):
1743         (WebCore::AudioSampleDataSource::setPaused):
1744         (WebCore::AudioSampleDataSource::setupConverter):
1745         (WebCore::AudioSampleDataSource::setInputFormat):
1746         (WebCore::AudioSampleDataSource::setOutputFormat):
1747         (WebCore::AudioSampleDataSource::hostTime):
1748         (WebCore::AudioSampleDataSource::pushSamplesInternal):
1749         (WebCore::AudioSampleDataSource::pushSamples):
1750         (WebCore::AudioSampleDataSource::pullSamplesInternal):
1751         (WebCore::AudioSampleDataSource::pullSamples):
1752         * platform/audio/mac/AudioSampleDataSource.h: Added.
1753         (WebCore::AudioSampleDataSource::setVolume):
1754         (WebCore::AudioSampleDataSource::volume):
1755         (WebCore::AudioSampleDataSource::setMuted):
1756         (WebCore::AudioSampleDataSource::muted):
1757
1758 2017-02-03  Carlos Garcia Campos  <cgarcia@igalia.com>
1759
1760         Unreviewed. Fix the buidl after r211631.
1761
1762         I added the OS(LINUX) ifdef to the wrong file by mistake.
1763
1764         * page/ResourceUsageThread.h:
1765         * page/linux/ResourceUsageThreadLinux.cpp:
1766
1767 2017-02-03  Carlos Garcia Campos  <cgarcia@igalia.com>
1768
1769         [GTK] Add initial implementation of resource usage overlay
1770         https://bugs.webkit.org/show_bug.cgi?id=167731
1771
1772         Reviewed by Michael Catanzaro.
1773
1774         Add an implementation of ResourceUsageOverlay and ResourceUsageThread for Linux systems.
1775
1776         * PlatformGTK.cmake: Add new new files to compilation.
1777         * page/Page.cpp:
1778         (WebCore::Page::setResourceUsageOverlayVisible): Do not create the page overlay if accelerated compositing is
1779         not enabled.
1780         * page/ResourceUsageOverlay.h:
1781         * page/linux/ResourceUsageOverlayLinux.cpp: Added.
1782         (WebCore::cpuUsageString):
1783         (WebCore::formatByteNumber):
1784         (WebCore::gcTimerString):
1785         (WebCore::ResourceUsageOverlay::platformInitialize):
1786         (WebCore::ResourceUsageOverlay::platformDestroy):
1787         * page/linux/ResourceUsageThreadLinux.cpp: Added.
1788         (WebCore::cpuPeriod):
1789         (WebCore::cpuUsage):
1790         (WebCore::ResourceUsageThread::platformThreadBody):
1791
1792 2017-02-03  Enrique Ocaña González  <eocanha@igalia.com>
1793
1794         [GStreamer] Store preloaded media in webkit's cache
1795         https://bugs.webkit.org/show_bug.cgi?id=119477
1796
1797         Reviewed by Xabier Rodriguez-Calvar.
1798
1799         Files cached on disk by MediaPlayerPrivateGStreamer are deleted only when the player is closed. If the
1800         WebProcess crashed, they're just left there in the cache directory. This patch changes the location
1801         of those temporary files to a proper temporary directory (/var/tmp, as those files aren't actually
1802         reusable, so they don't belong to a cache directory, and /tmp is a bad place because it's RAM-based on
1803         some distros), unlinks (deletes) them right after creation and also deletes any other stalled temporary
1804         file on the old legacy cache directory.
1805
1806         There's no API in GstPlaybin to control the temporary file location, so we do it manually by locating
1807         the GstDownloadBuffer element in the pipeline as soon as it's created, reconfiguring it with the right
1808         temporary file path and deleting the file as soon as it's created.
1809
1810         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
1811         (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer): Stop listening to element-added.
1812         (WebCore::MediaPlayerPrivateGStreamer::uriDecodeBinElementAddedCallback): Look for GstDownloadBuffer.
1813         (WebCore::MediaPlayerPrivateGStreamer::downloadBufferFileCreatedCallback): Remove the file after creation.
1814         (WebCore::MediaPlayerPrivateGStreamer::purgeOldDownloadFiles): Delete legacy files.
1815         (WebCore::MediaPlayerPrivateGStreamer::sourceChanged): Listen to element-added signals on GstUriDecodeBin.
1816         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: New reference to GstDownloadBuffer.
1817
1818 2017-02-03  Antti Koivisto  <antti@apple.com>
1819
1820         WebContent crash when pasting into input fields at com.apple.WebCore: WebCore::ResourceRequestBase::url const + 9
1821         https://bugs.webkit.org/show_bug.cgi?id=167787
1822         rdar://problem/29168795
1823
1824         Reviewed by Andreas Kling.
1825
1826         No test, don't know how to get here.
1827
1828         * page/animation/CSSPropertyAnimation.cpp:
1829         (WebCore::crossfadeBlend): Null check.
1830
1831 2017-02-03  Alberto Garcia  <berto@igalia.com>
1832
1833         JSDOMWindowBase.cpp doesn't build if the JIT is disabled
1834         https://bugs.webkit.org/show_bug.cgi?id=167785
1835
1836         Reviewed by Carlos Garcia Campos.
1837
1838         r211403 moved GetCallerGlobalObjectFunctor from JSDOMBinding.cpp
1839         to JSDOMWindowBase.cpp, but forgot to include bytecode/CodeBlock.h
1840         in the latter file.
1841
1842         This breaks the build if the JIT is disabled because the headers
1843         that would include ClodeBlock.h indirectly are guarded by
1844         ENABLE(JIT).
1845
1846         * bindings/js/JSDOMWindowBase.cpp:
1847
1848 2017-02-02  Andreas Kling  <akling@apple.com>
1849
1850         [Mac] In-process memory pressure monitor for WebContent processes AKA websam
1851         <https://webkit.org/b/167491>
1852         <rdar://problem/30116072>
1853
1854         Reviewed by Antti Koivisto.
1855
1856         Add a new timer-based memory pressure monitor that checks the process memory
1857         footprint every 30 seconds and reacts to changes by setting a MemoryUsagePolicy.
1858
1859         There are four MemoryUsagePolicy values:
1860
1861             - Unrestricted (below 1GB)
1862             - Conservative (above 1GB)
1863             - Strict (above 2GB)
1864             - Panic (above 4GB, or 3GB if 32-bit)
1865
1866         For Strict and above, the old-style "isUnderMemoryPressure()" API will return true.
1867
1868         Transitioning to a higher policy will cause memory pressure handlers to run:
1869
1870         At Strict, we run the "non-critical" memory pressure handler, then carry on.
1871
1872         At Panic, we run the "critical" memory pressure handler. If that fails to recover
1873         enough memory to bring us back below 4GB, we may kill the process:
1874
1875         A process is eligible to get killed for using too much memory if:
1876
1877             - It's not visible on screen (i.e it's a background tab.)
1878             - It's not playing audio.
1879             - It has not performed a main frame navigation in the last hour.
1880
1881         Before killing the process, an exit-time callback will run. This patch installs such
1882         a callback that prints out some time-of-death statistics about C++ and JavaScript memory
1883         usage to hopefully help understand what was soaking up all the memory.
1884
1885         * bindings/js/CommonVM.cpp:
1886         (WebCore::commonVMSlow):
1887         * loader/FrameLoader.cpp:
1888         (WebCore::FrameLoader::setState):
1889         * page/MainFrame.cpp:
1890         (WebCore::MainFrame::didCompleteLoad):
1891         * page/MainFrame.h:
1892         * page/MemoryRelease.cpp:
1893         (WebCore::pageCount):
1894         (WebCore::logMemoryStatisticsAtTimeOfDeath):
1895         (WebCore::didExceedMemoryLimitAndFailedToRecover):
1896         (WebCore::processIsEligibleForMemoryKill):
1897         * page/MemoryRelease.h:
1898         * page/ResourceUsageThread.h:
1899         * page/cocoa/ResourceUsageThreadCocoa.mm:
1900         (WebCore::vmPageSize):
1901         * platform/MemoryPressureHandler.cpp:
1902         (WebCore::MemoryPressureHandler::MemoryPressureHandler):
1903         (WebCore::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
1904         (WebCore::toString):
1905         (WebCore::thresholdForPolicy):
1906         (WebCore::policyForFootprint):
1907         (WebCore::MemoryPressureHandler::measurementTimerFired):
1908         * platform/MemoryPressureHandler.h:
1909         (WebCore::MemoryPressureHandler::setMemoryKillCallback):
1910         (WebCore::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback):
1911         (WebCore::MemoryPressureHandler::isUnderMemoryPressure):
1912
1913 2017-02-02  Alex Christensen  <achristensen@webkit.org>
1914
1915         URLParser: Fix parsing invalid IPv4 addresses with non-ASCII characters
1916         https://bugs.webkit.org/show_bug.cgi?id=167773
1917         <rdar://problem/30221102>
1918
1919         Reviewed by Ryosuke Niwa.
1920
1921         If an invalid IPv4 address contains the first syntaxViolation (difference between input and canonicalized URL),
1922         an iterator is used to calculate how far we have parsed in the input string to copy all the syntax-violation-free
1923         characters into a Vector. If a URL contains only ASCII that doesn't contain anything percent-encoded in the host,
1924         there is a fast path to parse ASCII hosts.  All my existing invalid IPv4 tests followed this path.
1925         If there is a non-ASCII character, we need to use an iterator to the original string instead of an iterator
1926         to the string after converting the input string's host to ASCII.
1927
1928         Covered by a new API test which used to RELEASE_ASSERT.
1929
1930         * platform/URLParser.cpp:
1931         (WebCore::URLParser::parseIPv4Host):
1932         (WebCore::URLParser::parseIPv6Host):
1933         (WebCore::URLParser::parseHostAndPort):
1934         * platform/URLParser.h:
1935
1936 2017-02-02  Wenson Hsieh  <wenson_hsieh@apple.com>
1937
1938         CrashTracer: [USER] com.apple.WebKit.WebContent at com.apple.WebCore: WebCore::URL::host const + 9
1939         https://bugs.webkit.org/show_bug.cgi?id=167766
1940         <rdar://problem/30132707>
1941
1942         Reviewed by Chris Dumez.
1943
1944         The mainframe's document pointer may be null when tearing down a page upon navigation to a page that is in the
1945         page cache. If this triggers a GC sweep, we will attempt to reload touch bar media controls, which (as a part of
1946         the media controller heuristic) checks the mainframe's document URL to see if quirks should be enabled. This
1947         assumes that the mainframe's document exists, which is not a safe assumption if page navigation is occurring. As
1948         such, we need a null check for the mainframe's document in needsPlaybackControlsManagerQuirk().
1949
1950         No test, as we were unable to reproduce this crash.
1951
1952         * html/HTMLMediaElement.cpp:
1953         (WebCore::needsPlaybackControlsManagerQuirk):
1954
1955 2017-02-02  Chris Dumez  <cdumez@apple.com>
1956
1957         Suspend SVG animations in hidden pages
1958         https://bugs.webkit.org/show_bug.cgi?id=167763
1959         <rdar://problem/29986313>
1960
1961         Reviewed by Simon Fraser.
1962
1963         Suspend SVG animations in hidden pages to save power, similarly to what
1964         we already do for another types of animations.
1965
1966         Test: svg/animations/animations-paused-page-non-visible.html
1967
1968         * page/Page.cpp:
1969         (WebCore::setSVGAnimationSuspended):
1970         (WebCore::Page::setIsVisibleInternal):
1971         * svg/SVGDocumentExtensions.cpp:
1972         (WebCore::SVGDocumentExtensions::pauseAnimations):
1973         (WebCore::SVGDocumentExtensions::unpauseAnimations):
1974         * svg/SVGDocumentExtensions.h:
1975         (WebCore::SVGDocumentExtensions::areAnimationsPaused):
1976         * testing/Internals.cpp:
1977         (WebCore::Internals::areSVGAnimationsPaused):
1978         * testing/Internals.h:
1979         * testing/Internals.idl:
1980
1981 2017-02-02  Commit Queue  <commit-queue@webkit.org>
1982
1983         Unreviewed, rolling out r211596 and r211605.
1984         https://bugs.webkit.org/show_bug.cgi?id=167767
1985
1986         This change broke certain build configurations (Requested by
1987         ryanhaddad on #webkit).
1988
1989         Reverted changesets:
1990
1991         "[Mac] Add classes to manage audio samples"
1992         https://bugs.webkit.org/show_bug.cgi?id=167739
1993         http://trac.webkit.org/changeset/211596
1994
1995         "Unreviewed speculative build fix."
1996         http://trac.webkit.org/changeset/211605
1997
1998 2017-02-02  Ryan Haddad  <ryanhaddad@apple.com>
1999
2000         Unreviewed speculative build fix.
2001
2002         * platform/audio/mac/AudioSampleDataSource.cpp:
2003         (WebCore::AudioSampleDataSource::setupConverter):
2004         (WebCore::AudioSampleDataSource::pushSamples):
2005
2006 2017-02-02  Alex Christensen  <achristensen@webkit.org>
2007
2008         Build libwebrtc and dependencies with Xcode
2009         https://bugs.webkit.org/show_bug.cgi?id=167758
2010
2011         Reviewed by Dean Jackson.
2012
2013         * WebCore.xcodeproj/project.pbxproj:
2014
2015 2017-02-02  Chris Dumez  <cdumez@apple.com>
2016
2017         {}.toString.call(crossOriginWindow) should return "[object Object]"
2018         https://bugs.webkit.org/show_bug.cgi?id=167701
2019         <rdar://problem/30330797>
2020
2021         Reviewed by Keith Miller.
2022
2023         {}.toString.call() to should "[object Object] for cross origin
2024         Window / Location objects. This new behavior is consistent with
2025         Firefox and Chrome.
2026
2027         No new tests, rebaselined existing tests.
2028
2029         * bindings/js/JSDOMWindowCustom.cpp:
2030         (WebCore::JSDOMWindow::toStringName):
2031         * bindings/js/JSLocationCustom.cpp:
2032         (WebCore::JSLocation::toStringName):
2033         * bindings/scripts/CodeGeneratorJS.pm:
2034         (GenerateHeader):
2035         * bindings/scripts/IDLAttributes.txt:
2036         * page/DOMWindow.idl:
2037         * page/Location.idl:
2038
2039 2017-02-02  Wenson Hsieh  <wenson_hsieh@apple.com>
2040
2041         Drag images should be anchored to the mouse location
2042         https://bugs.webkit.org/show_bug.cgi?id=167690
2043         <rdar://problem/30295261>
2044
2045         Reviewed by Enrica Casucci.
2046
2047         Adds logic to compute the mouse anchor point. This is a point in the unit square indicating where the drag
2048         origin is relative to the bounds of the drag image. There is no behavior change, since this anchor point is not
2049         used by any client yet; this patch only computes and vends this information from WebCore.
2050
2051         * loader/EmptyClients.cpp:
2052         * page/DragClient.h:
2053         * page/DragController.cpp:
2054         (WebCore::DragController::startDrag):
2055         (WebCore::DragController::doImageDrag):
2056         (WebCore::DragController::doSystemDrag):
2057         * page/DragController.h:
2058         * platform/DragImage.h:
2059
2060 2017-02-02  Eric Carlson  <eric.carlson@apple.com>
2061
2062         [Mac] Add classes to manage audio samples
2063         https://bugs.webkit.org/show_bug.cgi?id=167739
2064
2065         Reviewed by Jer Noble.
2066
2067         No new tests, this code isn't used yet.
2068
2069         * WebCore.xcodeproj/project.pbxproj:
2070         * platform/audio/mac/AudioSampleBufferList.cpp: Added.
2071         (WebCore::AudioSampleBufferList::create):
2072         (WebCore::AudioSampleBufferList::AudioSampleBufferList):
2073         (WebCore::AudioSampleBufferList::~AudioSampleBufferList):
2074         (WebCore::AudioSampleBufferList::setSampleCount):
2075         (WebCore::AudioSampleBufferList::applyGain):
2076         (WebCore::AudioSampleBufferList::mixFrom):
2077         (WebCore::AudioSampleBufferList::copyFrom):
2078         (WebCore::AudioSampleBufferList::copyTo):
2079         (WebCore::AudioSampleBufferList::reset):
2080         (WebCore::AudioSampleBufferList::zero):
2081         (WebCore::AudioSampleBufferList::zeroABL):
2082         (WebCore::AudioSampleBufferList::convertInput):
2083         (WebCore::AudioSampleBufferList::audioConverterCallback):
2084         (WebCore::AudioSampleBufferList::configureBufferListForStream):
2085         * platform/audio/mac/AudioSampleBufferList.h: Added.
2086         (WebCore::AudioSampleBufferList::streamDescription):
2087         (WebCore::AudioSampleBufferList::bufferList):
2088         (WebCore::AudioSampleBufferList::sampleCapacity):
2089         (WebCore::AudioSampleBufferList::sampleCount):
2090         (WebCore::AudioSampleBufferList::timestamp):
2091         (WebCore::AudioSampleBufferList::hostTime):
2092         (WebCore::AudioSampleBufferList::setTimes):
2093         (WebCore::AudioSampleBufferList::audioBufferListSizeForStream):
2094         * platform/audio/mac/AudioSampleDataSource.cpp: Added.
2095         (WebCore::AudioSampleDataSource::create):
2096         (WebCore::AudioSampleDataSource::AudioSampleDataSource):
2097         (WebCore::AudioSampleDataSource::~AudioSampleDataSource):
2098         (WebCore::AudioSampleDataSource::setPaused):
2099         (WebCore::AudioSampleDataSource::setupConverter):
2100         (WebCore::AudioSampleDataSource::setInputFormat):
2101         (WebCore::AudioSampleDataSource::setOutputFormat):
2102         (WebCore::AudioSampleDataSource::hostTime):
2103         (WebCore::AudioSampleDataSource::pushSamplesInternal):
2104         (WebCore::AudioSampleDataSource::pushSamples):
2105         (WebCore::AudioSampleDataSource::pullSamplesInternal):
2106         (WebCore::AudioSampleDataSource::pullSamples):
2107         * platform/audio/mac/AudioSampleDataSource.h: Added.
2108         (WebCore::AudioSampleDataSource::setVolume):
2109         (WebCore::AudioSampleDataSource::volume):
2110         (WebCore::AudioSampleDataSource::setMuted):
2111         (WebCore::AudioSampleDataSource::muted):
2112
2113 2017-02-02  Joseph Pecoraro  <pecoraro@apple.com>
2114
2115         Support Performance API (performance.now(), UserTiming) in Workers
2116         https://bugs.webkit.org/show_bug.cgi?id=167717
2117
2118         Reviewed by Ryosuke Niwa.
2119
2120         Tests: performance-api/performance-mark-name.html
2121                performance-api/performance-now-api.html
2122                performance-api/performance-now-time-origin-in-worker.html
2123                performance-api/user-timing-apis.html
2124
2125         * CMakeLists.txt:
2126         * DerivedSources.make:
2127         New files.
2128
2129         * page/DOMWindow.idl:
2130         * page/GlobalPerformance.idl:
2131         * workers/WorkerGlobalScope.idl:
2132         Add partial interface for performance attribute.
2133
2134         * page/Performance.idl:
2135         * page/PerformanceEntry.idl:
2136         * page/PerformanceMark.idl:
2137         * page/PerformanceMeasure.idl:
2138         * page/PerformanceObserver.idl:
2139         * page/PerformanceObserverEntryList.idl:
2140         Expose these to Workers.
2141
2142         * page/Performance.cpp:
2143         (WebCore::Performance::Performance):
2144         (WebCore::Performance::contextDestroyed):
2145         * page/Performance.h:
2146         Use the EventQueue variant that works with any ScriptExectionContext.
2147
2148         * page/PerformanceObserver.cpp:
2149         (WebCore::PerformanceObserver::PerformanceObserver):
2150         Get the Performance base in a Worker context.
2151
2152         * page/PerformanceUserTiming.cpp:
2153         (WebCore::UserTiming::mark):
2154         Only reject legacy special mark names in a Window, not a Worker.
2155
2156         (WebCore::UserTiming::findExistingMarkStartTime):
2157         Simple implementation returns 0 as the start time in Workers. The spec
2158         is currently imprecise here, but it does not have the unusual
2159         PerformanceTiming behavior in a Window which is part of User Timing 1.
2160
2161         * workers/Worker.cpp:
2162         (WebCore::Worker::create):
2163         (WebCore::Worker::notifyFinished):
2164         * workers/Worker.h:
2165         Record the moment of Worker creation.
2166
2167         * workers/WorkerGlobalScope.cpp:
2168         (WebCore::WorkerGlobalScope::WorkerGlobalScope):
2169         (WebCore::WorkerGlobalScope::performance):
2170         * workers/WorkerGlobalScope.h:
2171         Construct the Performance object with the moment of creation (timeOrigin).
2172
2173         * workers/DedicatedWorkerGlobalScope.cpp:
2174         (WebCore::DedicatedWorkerGlobalScope::create):
2175         (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
2176         * workers/DedicatedWorkerGlobalScope.h:
2177         * workers/DedicatedWorkerThread.cpp:
2178         (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
2179         (WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
2180         * workers/DedicatedWorkerThread.h:
2181         * workers/WorkerGlobalScopeProxy.h:
2182         * workers/WorkerMessagingProxy.cpp:
2183         (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
2184         * workers/WorkerMessagingProxy.h:
2185         * workers/WorkerThread.cpp:
2186         (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
2187         (WebCore::WorkerThread::WorkerThread):
2188         (WebCore::WorkerThread::workerThread):
2189         * workers/WorkerThread.h:
2190         Pass the moment of creation (timeOrigin) through to WorkerGlobalScope creation.
2191
2192 2017-02-02  Commit Queue  <commit-queue@webkit.org>
2193
2194         Unreviewed, rolling out r211579.
2195         https://bugs.webkit.org/show_bug.cgi?id=167753
2196
2197         Caused mediastream crashes. (Requested by bfulgham_ on
2198         #webkit).
2199
2200         Reverted changeset:
2201
2202         "Correct memory leak in MediaConstraints"
2203         https://bugs.webkit.org/show_bug.cgi?id=167744
2204         http://trac.webkit.org/changeset/211579
2205
2206 2017-02-02  Chris Dumez  <cdumez@apple.com>
2207
2208         Rename Node::inDocument() to isConnected()
2209         https://bugs.webkit.org/show_bug.cgi?id=167743
2210
2211         Reviewed by Sam Weinig.
2212
2213         Rename Node::inDocument() to isConnected() to match the DOM specification more closely:
2214         - https://dom.spec.whatwg.org/#connected
2215
2216 2017-02-02  Antoine Quint  <graouts@apple.com>
2217
2218         [Modern Media Controls] Provide a compact mode for when the controls are small
2219         https://bugs.webkit.org/show_bug.cgi?id=167746
2220         <rdar://problem/29565842>
2221
2222         Reviewed by Dean Jackson.
2223
2224         When the macOS inline media controls become too narrow to display both the volume and fullscreen
2225         buttons in their right container (width < 242), we switch to a compact mode where the controls bar
2226         is shorter and the buttons smaller.
2227
2228         To facilitate this, we provide a new subclass of MacOSInlineMediaControls called MacOSCompactInlineMediaControls
2229         which changes some of the layout properties of the buttons to have shorter margins around buttons.
2230
2231         We also added a new "Compact" LayoutTrait and improved IconService to provide specific icons
2232         for this mode for the buttons that can exist in compact mode. 
2233
2234         To correctly implement the design, we needed to add a way to provide different margins around the
2235         left and right edges of the container, so the "padding" property is now split between "leftMargin"
2236         and "rightMargin", and to make property naming cleaner, the "margin" property which specifies the
2237         space between each button in a container is now called "buttonMargin". We also set the default
2238         values for those properties to be 24 (instead of 0) which are the most widely used values, requiring
2239         less customization.
2240
2241         Tests: media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-buttons-styles.html
2242                media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-constructor.html
2243                media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-controls-bar-styles.html
2244                media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-layout.html
2245                media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-volume-styles.html
2246                media/modern-media-controls/media-controller/media-controller-toggle-compact-mode.html
2247
2248         * Modules/modern-media-controls/controls/buttons-container.js:
2249         (ButtonsContainer.prototype.layout): Refactor the "margin" and "padding" properties into
2250         "leftMargin", "rightMargin" and "buttonMargin".
2251         * Modules/modern-media-controls/controls/icon-button.js:
2252         (IconButton.prototype._updateImage): Fix a small bug that would prevent the image source
2253         change to occur after changing the "iconName" property should the previous and new icons
2254         share the same metrics, which is the case for the "play" and "pause" icons in compact mode.
2255         * Modules/modern-media-controls/controls/icon-service.js: Add support for compact variants.
2256         (const.iconService.new.IconService.prototype._fileNameAndPlatformForIconNameAndLayoutTraits):
2257         (const.iconService.new.IconService):
2258         * Modules/modern-media-controls/controls/ios-inline-media-controls.js: Adopt new margin defaults.
2259         * Modules/modern-media-controls/controls/layout-item.js: Add the new "Compact" LayoutTrait.
2260         * Modules/modern-media-controls/controls/macos-compact-inline-media-controls.css: Added.
2261         (.media-controls.mac.inline.compact > .controls-bar):
2262         (.media-controls.mac.inline.compact button.play-pause):
2263         (.media-controls.mac.inline.compact button.skip-back):
2264         (.media-controls.mac.inline.compact .scrubber.slider):
2265         (.media-controls.mac.inline.compact button.mute):
2266         (.media-controls.mac.inline.compact button.fullscreen):
2267         (.media-controls.mac.inline.compact .time-label,):
2268         (.media-controls.mac.inline.compact .volume-slider-container):
2269         (.media-controls.mac.inline.compact .volume.slider):
2270         (.media-controls.mac.inline.compact .scrubber.slider > input::-webkit-slider-thumb):
2271         * Modules/modern-media-controls/controls/macos-compact-inline-media-controls.js: Added.
2272         (MacOSCompactInlineMediaControls):
2273         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js: Adopt new margin defaults.
2274         (MacOSFullscreenMediaControls.prototype.layout):
2275         * Modules/modern-media-controls/controls/macos-inline-media-controls.js: Adopt new margin defaults
2276         and make the _leftContainer and _rightContainer properties public such that the MacOSCompactInlineMediaControls
2277         subclass may customize them without accessing a private property.
2278         (MacOSInlineMediaControls.prototype.layout):
2279         (MacOSInlineMediaControls.prototype.showTracksPanel):
2280         * Modules/modern-media-controls/images/macOS/enter-fullscreen-compact@1x.png: Added.
2281         * Modules/modern-media-controls/images/macOS/enter-fullscreen-compact@2x.png: Added.
2282         * Modules/modern-media-controls/images/macOS/interval-skip-back-compact@1x.png: Added.
2283         * Modules/modern-media-controls/images/macOS/interval-skip-back-compact@2x.png: Added.
2284         * Modules/modern-media-controls/images/macOS/pause-compact@1x.png: Added.
2285         * Modules/modern-media-controls/images/macOS/pause-compact@2x.png: Added.
2286         * Modules/modern-media-controls/images/macOS/play-compact@1x.png: Added.
2287         * Modules/modern-media-controls/images/macOS/play-compact@2x.png: Added.
2288         * Modules/modern-media-controls/images/macOS/volume-compact@1x.png: Added.
2289         * Modules/modern-media-controls/images/macOS/volume-compact@2x.png: Added.
2290         * Modules/modern-media-controls/js-files: Add the new files so they are concatenated by the build script.
2291         * Modules/modern-media-controls/media/media-controller.js: Toggle compact mode if controls
2292         are below the 242px width threshold.
2293         (MediaController.prototype.get layoutTraits):
2294         (MediaController.prototype.handleEvent):
2295         (MediaController.prototype._updateControlsIfNeeded):
2296         (MediaController.prototype._shouldFadeBetweenControls):
2297         (MediaController.prototype._updateControlsSize):
2298         (MediaController.prototype._controlsWidth):
2299         (MediaController.prototype._controlsClass):
2300         (MediaController):
2301         * WebCore.xcodeproj/project.pbxproj: Add new files and perform some cleanup so that the
2302         project accurately lists all the existing project files and remove some older ones.
2303
2304 2017-02-02  Commit Queue  <commit-queue@webkit.org>
2305
2306         Unreviewed, rolling out r211571 and r211582.
2307         https://bugs.webkit.org/show_bug.cgi?id=167751
2308
2309         This change caused API test WebKit1.MemoryPressureHandler to
2310         fail with an assertion. (Requested by ryanhaddad on #webkit).
2311
2312         Reverted changesets:
2313
2314         "[Mac] In-process memory pressure monitor for WebContent
2315         processes."
2316         https://bugs.webkit.org/show_bug.cgi?id=167491
2317         http://trac.webkit.org/changeset/211571
2318
2319         "Unreviewed attempt to fix the Windows build after r211571."
2320         http://trac.webkit.org/changeset/211582
2321
2322 2017-02-02  Chris Dumez  <cdumez@apple.com>
2323
2324         Unreviewed attempt to fix the Windows build after r211571.
2325
2326         * platform/MemoryPressureHandler.cpp:
2327         (WebCore::thresholdForPolicy):
2328         (WebCore::policyForFootprint):
2329
2330 2017-02-02  Brent Fulgham  <bfulgham@apple.com>
2331
2332         Correct memory leak in MediaConstraints
2333         https://bugs.webkit.org/show_bug.cgi?id=167744
2334         <rdar://problem/30331444>
2335
2336         Reviewed by Anders Carlsson.
2337
2338         ConstraintHolder returns a reference to an object created by operator new. When the
2339         returned value is assigned or stored in Vector or other containers we leak memory.
2340         Instead, this value should just be returned as a regular object so that the return
2341         value optimization can make sure memory is properly (and efficiently) used.
2342
2343         * platform/mediastream/MediaConstraints.h:
2344         (WebCore::FlattenedConstraint::ConstraintHolder::create): Return by value.
2345
2346 2017-02-02  Andreas Kling  <akling@apple.com>
2347
2348         [Mac] In-process memory pressure monitor for WebContent processes AKA websam
2349         <https://webkit.org/b/167491>
2350         <rdar://problem/30116072>
2351
2352         Reviewed by Antti Koivisto.
2353
2354         Add a new timer-based memory pressure monitor that checks the process memory
2355         footprint every 30 seconds and reacts to changes by setting a MemoryUsagePolicy.
2356
2357         There are four MemoryUsagePolicy values:
2358
2359             - Unrestricted (below 1GB)
2360             - Conservative (above 1GB)
2361             - Strict (above 2GB)
2362             - Panic (above 4GB, or 3GB if 32-bit)
2363
2364         For Strict and above, the old-style "isUnderMemoryPressure()" API will return true.
2365
2366         Transitioning to a higher policy will cause memory pressure handlers to run:
2367
2368         At Strict, we run the "non-critical" memory pressure handler, then carry on.
2369
2370         At Panic, we run the "critical" memory pressure handler. If that fails to recover
2371         enough memory to bring us back below 4GB, we may kill the process:
2372
2373         A process is eligible to get killed for using too much memory if:
2374
2375             - It's not visible on screen (i.e it's a background tab.)
2376             - It's not playing audio.
2377             - It has not performed a main frame navigation in the last hour.
2378
2379         Before killing the process, an exit-time callback will run. This patch installs such
2380         a callback that prints out some time-of-death statistics about C++ and JavaScript memory
2381         usage to hopefully help understand what was soaking up all the memory.
2382
2383         * bindings/js/CommonVM.cpp:
2384         (WebCore::commonVMSlow):
2385         * loader/FrameLoader.cpp:
2386         (WebCore::FrameLoader::setState):
2387         * page/MainFrame.cpp:
2388         (WebCore::MainFrame::didCompleteLoad):
2389         * page/MainFrame.h:
2390         * page/MemoryRelease.cpp:
2391         (WebCore::pageCount):
2392         (WebCore::logMemoryStatisticsAtTimeOfDeath):
2393         (WebCore::didExceedMemoryLimitAndFailedToRecover):
2394         (WebCore::processIsEligibleForMemoryKill):
2395         * page/MemoryRelease.h:
2396         * page/ResourceUsageThread.h:
2397         * page/cocoa/ResourceUsageThreadCocoa.mm:
2398         (WebCore::vmPageSize):
2399         * platform/MemoryPressureHandler.cpp:
2400         (WebCore::MemoryPressureHandler::MemoryPressureHandler):
2401         (WebCore::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
2402         (WebCore::toString):
2403         (WebCore::thresholdForPolicy):
2404         (WebCore::policyForFootprint):
2405         (WebCore::MemoryPressureHandler::measurementTimerFired):
2406         * platform/MemoryPressureHandler.h:
2407         (WebCore::MemoryPressureHandler::setMemoryKillCallback):
2408         (WebCore::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback):
2409         (WebCore::MemoryPressureHandler::isUnderMemoryPressure):
2410
2411 2017-02-02  Chris Dumez  <cdumez@apple.com>
2412
2413         [Crash] com.apple.WebKit.WebContent at WebKit: WebKit::WebPage::fromCorePage()
2414         https://bugs.webkit.org/show_bug.cgi?id=167738
2415         <rdar://problem/30229990>
2416
2417         Reviewed by Andreas Kling.
2418
2419         Upon destruction of a Page, we destroy the BackForwardClient, which is supposed
2420         to keep track of HistoryItems associated to this particular page and remove them
2421         from the PageCache. Given the crash trace, the issue seems to be that some
2422         HistoryItems associated with the Page sometimes linger in the PageCache *after*
2423         the Page has been destroyed, which leads to crashes later on when pruning the
2424         PageCache.
2425
2426         In order to make the process more robust, this patch refactors the code so that
2427         the Page is now in charge of removing all its associated HistoryItems from the
2428         PageCache instead of relying on the BackForwardClient. Also, instead of having
2429         the Page keep track of which HistoryItems are associated with it (which is
2430         error prone), we now scan all PageCache entries instead to find which ones are
2431         associated with the Page. While this is in theory slower, this is much safer
2432         and in practice not an issue because the PageCache usually has 3-5 entries.
2433
2434         No new tests, could not reproduce.
2435
2436         * history/CachedPage.cpp:
2437         (WebCore::CachedPage::CachedPage):
2438         * history/CachedPage.h:
2439         (WebCore::CachedPage::page):
2440         * history/PageCache.cpp:
2441         (WebCore::PageCache::removeAllItemsForPage):
2442         * history/PageCache.h:
2443         * page/Page.cpp:
2444         (WebCore::Page::~Page):
2445
2446 2017-02-02  Antti Koivisto  <antti@apple.com>
2447
2448         Column progression wrong after enabling pagination on RTL document
2449         https://bugs.webkit.org/show_bug.cgi?id=167733
2450         <rdar://problem/29012252>
2451
2452         Reviewed by Zalan Bujtas.
2453
2454         Column progression depends on document direction but was not updated when direction changed.
2455
2456         Test: fast/multicol/pagination/pagination-dynamic-rtl.html
2457
2458         * rendering/RenderBox.cpp:
2459         (WebCore::RenderBox::styleDidChange):
2460
2461             Update column styles if document direction changes.
2462
2463 2017-02-02  Xabier Rodriguez Calvar  <calvaris@igalia.com>
2464
2465         [EME][GStreamer] Fixed decryptor selection
2466         https://bugs.webkit.org/show_bug.cgi?id=167588
2467
2468         Reviewed by Žan Doberšek.
2469
2470         GStreamer selected a decryptor automatically but we need to be
2471         able to tell it which decryptor we want because one file can be
2472         encrypted with more than one system and the one we want to use can
2473         depend on what the user tells us.
2474
2475         Now when the demuxer is about to select the demuxer, it runs a
2476         GstContext query with the events, which are forwarded through the
2477         EME api to the application, which will answer the the
2478         generateKeyRequest and then we can instruct the demuxer to select
2479         the one we tell it, not the one that is selected automatically. If
2480         the demuxer has already a preferred decryptor, the codepath will
2481         be similar to the older one.
2482
2483         Something that is also fixed is the report of the keyneeded event,
2484         which will contain all pssh boxes as requested by the spec.
2485
2486         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
2487         (WebCore::MediaPlayerPrivateGStreamer::handleMessage): Intercept
2488         the event and handle it.
2489         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
2490         (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
2491         Initialize the CDM session.
2492         (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
2493         Unlock the protection condition just in case and set CDM to null.
2494         (WebCore::extractEventsAndSystemsFromMessage): Access the events
2495         and accepted key systems coming at the message from the demuxer.
2496         (WebCore::MediaPlayerPrivateGStreamerBase::handleSyncMessage):
2497         Handle the protection event not as an element event but as a
2498         context request. It also concatenates all the initdatas in case
2499         there is more than one. The event is sent in the main thread and
2500         the current one blocks until a timeout is hit or the
2501         generateKeyRequest is called.
2502         (WebCore::MediaPlayerPrivateGStreamerBase::handleProtectionEvent):
2503         Check if the event was already handled and if not, run the need
2504         key event.
2505         (WebCore::MediaPlayerPrivateGStreamerBase::receivedGenerateKeyRequest):
2506         Notify the that the query arrived so that we can unlock the
2507         demuxer thread.
2508         (WebCore::keySystemIdToUuid): Translates ids to uuids, meaning
2509         the ones coming from JS to the ones coming from the media engine.
2510         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
2511         Attributes and methods.
2512         * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
2513         (webkit_media_clear_key_decrypt_class_init):
2514         (webKitMediaClearKeyDecryptorRequestDecryptionKey): Deleted.
2515         * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.h:
2516         Added the ui and uuid.
2517         * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
2518         (webkitMediaCommonEncryptionDecryptSinkEventHandler): Do not rely
2519         on the subclass, just forward the event to the pipeline inside a message.
2520         * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h:
2521         Remove unused function signature.
2522         * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
2523         (WebCore::appendPipelineNeedContextMessageCallback): Renamed from
2524         appendPipelineElementMessageCallback.
2525         (WebCore::AppendPipeline::AppendPipeline): Connect to the
2526         need-context message instead of the element one.
2527         (WebCore::AppendPipeline::dispatchPendingDecryptionKey):
2528         Dispatches the drm-cypher message if there is one pending.
2529         (WebCore::AppendPipeline::dispatchDecryptionKey): Dispatches the
2530         drm-cypher.
2531         (WebCore::AppendPipeline::handleNeedContextSyncMessage): Handles
2532         the need-context event instead of the element one.
2533         (WebCore::AppendPipeline::connectDemuxerSrcPadToAppsinkFromAnyThread):
2534         Dispatches the key to the pipeline if there's any pending.
2535         (WebCore::appendPipelineElementMessageCallback): Deleted.
2536         (WebCore::AppendPipeline::handleElementMessage): Deleted.
2537         * platform/graphics/gstreamer/mse/AppendPipeline.h: New methods
2538         and attributes.
2539         * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
2540         (WebCore::MediaPlayerPrivateGStreamerMSE::dispatchDecryptionKey):
2541         Use the dispatchDecryptionKey method of the AppendPipeline.
2542
2543 2017-02-02  Joseph Pecoraro  <pecoraro@apple.com>
2544
2545         Removed unused EventHandler members
2546         https://bugs.webkit.org/show_bug.cgi?id=167723
2547
2548         Reviewed by Yusuke Suzuki.
2549
2550         * page/EventHandler.cpp:
2551         (WebCore::EventHandler::clear):
2552         (WebCore::EventHandler::handleWheelEvent):
2553         * page/EventHandler.h:
2554         Remove unused members.
2555
2556         * editing/FrameSelection.cpp:
2557         * html/HTMLTextAreaElement.cpp:
2558         * rendering/RenderObject.cpp:
2559         * rendering/RenderSlider.cpp:
2560         Remove unnecessary includes.
2561
2562 2017-02-02  Joseph Pecoraro  <pecoraro@apple.com>
2563
2564         Removed unused m_navigationStart from NavigatorGamepad
2565         https://bugs.webkit.org/show_bug.cgi?id=167722
2566
2567         Reviewed by Yusuke Suzuki.
2568
2569         * Modules/gamepad/NavigatorGamepad.cpp:
2570         (WebCore::NavigatorGamepad::NavigatorGamepad):
2571         (WebCore::NavigatorGamepad::from):
2572         * Modules/gamepad/NavigatorGamepad.h:
2573         (WebCore::NavigatorGamepad::navigationStart): Deleted.
2574
2575 2017-02-02  Yongjun Zhang  <yongjun_zhang@apple.com>
2576
2577         In iOS, we should take background assertion when accessing localstorage databases.
2578         https://bugs.webkit.org/show_bug.cgi?id=165478
2579
2580         Move WebSQLiteDatabaseTrackerClient from WebKitLegacy to WebCore so that it can be accessible from
2581         WebKit1 and WebKit2. Previously, to avoid dependencies on UIKit, WebKitLegacy introduced several
2582         global methods for UIKit to setup the start/end background task blocks on runtime (WebKitSetStartBackgroundTaskBlock,
2583         WebKitSetInvalidWebBackgroundTaskIdentifier and WebKitSetEndBackgroundTaskBlock). Since we have to
2584         move the background task handling to WebCore, to avoid adding WebCore dependencies on UIKit, this
2585         patch introdues a new WebCore class WebBackgroundTaskController which holds the start/end background
2586         task blocks. The existing WebKitSetStartBackgroundTaskBlock and WebKitSetEndBackgroundTaskBlock methods
2587         in WebKit1 will use WebBackgroundTaskController to store the blocks set by UIKit. 
2588
2589         Reviewed by Brady Eidson.
2590
2591         No new test since this is code refactoring.
2592
2593         * WebCore.xcodeproj/project.pbxproj: Add a new class WebBackgroundTaskController to the project. Also move
2594             WebSQLiteDatabaseTrackerClient from WebKitLegacy to WebCore.
2595         * platform/ios/WebBackgroundTaskController.h: Use properties to hold the blocks for starting or ending background tasks.
2596         * platform/ios/WebBackgroundTaskController.mm:
2597         (+[WebBackgroundTaskController sharedController]):
2598         (-[WebBackgroundTaskController dealloc]):
2599         (-[WebBackgroundTaskController startBackgroundTaskWithExpirationHandler:]): Start a background task with a expiration handler;
2600             to start the background task, we will use backgroundTaskStartBlock set up by UIKit.
2601         (-[WebBackgroundTaskController endBackgroundTaskWithIdentifier:]): Call backgroundTaskEndBlack to end a background task.
2602         * platform/ios/WebSQLiteDatabaseTrackerClient.h: Copied from Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.h.
2603         * platform/ios/WebSQLiteDatabaseTrackerClient.mm: Copied from Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.mm.
2604         (WebCore::WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient): Make WebSQLiteDatabaseTrackerClient a singleton.
2605         (WebCore::WebSQLiteDatabaseTrackerClient::WebSQLiteDatabaseTrackerClient): 
2606         (WebCore::WebSQLiteDatabaseTrackerClient::~WebSQLiteDatabaseTrackerClient):
2607         (WebCore::WebSQLiteDatabaseTrackerClient::willBeginFirstTransaction): Use a utility class WebDatabaseTransactionBackgroundTaskController
2608             to schedule database transaction background task.
2609         (WebCore::WebSQLiteDatabaseTrackerClient::didFinishLastTransaction): Use WebDatabaseTransactionBackgroundTaskController to stop
2610             databas transaction background task.
2611         (transactionBackgroundTaskIdentifierLock: Moved from Source/WebKit/mac/Storage/WebDatabaseManager.mm.
2612         (setTransactionBackgroundTaskIdentifier): Ditto.
2613         (getTransactionBackgroundTaskIdentifier): Ditto.
2614         (+[WebDatabaseTransactionBackgroundTaskController startBackgroundTask]): Ditto.
2615         (+[WebDatabaseTransactionBackgroundTaskController endBackgroundTask]): Ditto.
2616
2617 2017-02-01  Zan Dobersek  <zdobersek@igalia.com>
2618
2619         [EME] Implement MediaKeySession::update()
2620         https://bugs.webkit.org/show_bug.cgi?id=167636
2621
2622         Reviewed by Xabier Rodriguez-Calvar.
2623
2624         Implement the MediaKeySession::update() method by following the steps as
2625         they are described in the specification.
2626
2627         In order to sanitize the passed-in response data, CDM::sanitizeResponse()
2628         is added. It passes the SharedBuffer object by reference to the CDMPrivate
2629         interface implementor, which returns a SharedBuffer object containing
2630         sanitized response data.
2631
2632         CDMInstance::updateLicense() virtual method is added to perform the license
2633         update for some specific CDMInstance object. After the update the CDMInstance
2634         invokes the callback that's passed to updateLicense(), providing information
2635         about session being closed, changed keys or expiration value, any message
2636         that has to be enqueued, and whether the update was successful.
2637
2638         After that callback is invoked, MediaKeySession::update() goes on to handle
2639         all the provided information in a future task, finally resolving the promise
2640         (or rejecting it beforehand in case of any failure during response handling
2641         or license update).
2642
2643         Three algorithms that can be invoked from MediaKeySession::update() (key
2644         status update, expiration update and session closure) will be implemented
2645         separately. Placeholder methods are provided until then.
2646
2647         MockCDM::sanitizeResponse() and MockCDMInstance::updateLicense() are
2648         implemented for testing purposes. For now only the response sanitization
2649         and sanitized response format are checked there. Key status update,
2650         expiration update and session closure should be tested once the
2651         implementations for those algorithms are added.
2652
2653         Test: media/encrypted-media/mock-MediaKeySession-update.html
2654
2655         * Modules/encryptedmedia/CDM.cpp:
2656         (WebCore::CDM::sanitizeResponse):
2657         * Modules/encryptedmedia/CDM.h:
2658         * Modules/encryptedmedia/CDMInstance.h:
2659         * Modules/encryptedmedia/CDMPrivate.h:
2660         * Modules/encryptedmedia/MediaKeySession.cpp:
2661         (WebCore::MediaKeySession::update):
2662         (WebCore::MediaKeySession::updateKeyStatuses):
2663         (WebCore::MediaKeySession::updateExpiration):
2664         (WebCore::MediaKeySession::sessionClosed):
2665         * Modules/encryptedmedia/MediaKeySession.h:
2666         * testing/MockCDMFactory.cpp:
2667         (WebCore::MockCDM::sanitizeResponse):
2668         (WebCore::MockCDMInstance::updateLicense):
2669         * testing/MockCDMFactory.h:
2670
2671 2017-02-01  Eric Carlson  <eric.carlson@apple.com>
2672
2673         [Mac] Update CARingBuffer class
2674         https://bugs.webkit.org/show_bug.cgi?id=167656
2675         <rdar://problem/30318329>
2676
2677         Unreviewed fix the 32-bit build after r211539.
2678
2679         * platform/audio/mac/CAAudioStreamDescription.cpp:
2680         (WebCore::CAAudioStreamDescription::CAAudioStreamDescription):
2681
2682 2017-02-01  Simon Fraser  <simon.fraser@apple.com>
2683
2684         [iOS WK2] With visual viewports, a fixed bottom bar can be clipped out when the keyboard is visible
2685         https://bugs.webkit.org/show_bug.cgi?id=167710
2686         rdar://problem/30100286
2687
2688         Reviewed by Wenson Hsieh.
2689         
2690         Add a bit of logging to show when RLC decides to not composite a fixed element which
2691         is out of bounds.
2692
2693         Test: fast/visual-viewport/ios/bottom-bar-with-keyboard.html
2694
2695         * rendering/RenderLayerCompositor.cpp:
2696         (WebCore::RenderLayerCompositor::requiresCompositingForPosition):
2697
2698 2017-02-01  Eric Carlson  <eric.carlson@apple.com>
2699
2700         [Mac] Update CARingBuffer class
2701         https://bugs.webkit.org/show_bug.cgi?id=167656
2702
2703         Unreviewed build fix after r211539.
2704
2705         * platform/audio/mac/CAAudioStreamDescription.cpp:
2706         (WebCore::CAAudioStreamDescription::CAAudioStreamDescription): Initialize a variable to fix
2707         release builds.
2708
2709 2017-02-01  Eric Carlson  <eric.carlson@apple.com>
2710
2711         [Mac] Update CARingBuffer class
2712         https://bugs.webkit.org/show_bug.cgi?id=167656
2713
2714         Reviewed by Jer Noble.
2715
2716         API test CARingBufferTest added.
2717
2718         * WebCore.xcodeproj/project.pbxproj: Add headers to framework so they can be used from the API test.
2719
2720         * platform/audio/AudioStreamDescription.h: Add Int32.
2721
2722         * platform/audio/mac/CAAudioStreamDescription.cpp:
2723         (WebCore::CAAudioStreamDescription::CAAudioStreamDescription):
2724         (WebCore::CAAudioStreamDescription::~CAAudioStreamDescription):
2725         (WebCore::CAAudioStreamDescription::format): Support Int32.
2726         (WebCore::CAAudioStreamDescription::operator==): Make inline.
2727         * platform/audio/mac/CAAudioStreamDescription.h:
2728
2729         * platform/audio/mac/CARingBuffer.cpp:
2730         (WebCore::CARingBuffer::CARingBuffer): Move initializers into class declaration.
2731         (WebCore::CARingBuffer::allocate): Use flush method, get allocation info from a CAAudioStreamDescription.
2732         (WebCore::FetchABL): Add a mode parameter to allow samples to replace or mix into destination.
2733         (WebCore::CARingBuffer::flush): New.
2734         (WebCore::CARingBuffer::fetch): Add mode parameter.
2735         (WebCore::CARingBuffer::~CARingBuffer): Deleted.
2736         * platform/audio/mac/CARingBuffer.h:
2737         (WebCore::CARingBuffer::~CARingBuffer):
2738
2739         * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
2740         (WebCore::AudioSourceProviderAVFObjC::prepare): Use new CARingBuffer constructor.
2741         (WebCore::operator==): Deleted.
2742         (WebCore::operator!=): Deleted.
2743
2744         * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm:
2745         (WebCore::WebAudioSourceProviderAVFObjC::prepare): Use new CARingBuffer constructor
2746         (WebCore::operator==): Deleted.
2747         (WebCore::operator!=): Deleted.
2748
2749 2017-02-01  Zalan Bujtas  <zalan@apple.com>
2750
2751         Simple line layout: Move TextFragmentIterator::runWidth to ::textWidth.
2752         https://bugs.webkit.org/show_bug.cgi?id=167705
2753         <rdar://problem/30314393>
2754
2755         Reviewed by Antti Koivisto.
2756
2757         We also don't need to compute logicalHeight for logicalLeft/right since the
2758         cases where it matters (floating boxes) are not supported by simple line layout. 
2759
2760         Covered by existing test.
2761
2762         * rendering/SimpleLineLayout.cpp:
2763         (WebCore::SimpleLineLayout::updateLineConstrains):
2764         * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
2765         (WebCore::SimpleLineLayout::nextBreakablePositionInSegment):
2766         (WebCore::SimpleLineLayout::TextFragmentIterator::textWidth):
2767         (WebCore::SimpleLineLayout::TextFragmentIterator::runWidth): Deleted.
2768         * rendering/SimpleLineLayoutTextFragmentIterator.h:
2769
2770 2017-02-01  Jer Noble  <jer.noble@apple.com>
2771
2772         Fix compilation error under recent clang update
2773         https://bugs.webkit.org/show_bug.cgi?id=167707
2774
2775         Reviewed by Eric Carlson.
2776
2777         Include TypedArrayInlines.h to fix a "missing symbol" link error when compiling under a recent clang update.
2778
2779         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
2780
2781 2017-02-01  Joseph Pecoraro  <pecoraro@apple.com>
2782
2783         Performance Timeline: Prepare for Worker support
2784         https://bugs.webkit.org/show_bug.cgi?id=167633
2785
2786         Reviewed by Ryosuke Niwa.
2787
2788         Remove references to Document/Frame in Performance. Instead use
2789         ScriptExecutionContext and pass in the time origin / SecurityOrigin
2790         where it is relevant. No tests should change this is just refactoring.
2791
2792         * loader/ResourceTimingInformation.cpp:
2793         (WebCore::ResourceTimingInformation::addResourceTiming):
2794         * page/DOMWindow.cpp:
2795         (WebCore::DOMWindow::performance):
2796         * page/Performance.cpp:
2797         (WebCore::Performance::Performance):
2798         (WebCore::Performance::now):
2799         (WebCore::Performance::reduceTimeResolution):
2800         (WebCore::Performance::navigation):
2801         (WebCore::Performance::timing):
2802         (WebCore::Performance::addResourceTiming):
2803         (WebCore::Performance::scriptExecutionContext): Deleted.
2804         * page/Performance.h:
2805         * page/Performance.idl:
2806         * page/PerformanceResourceTiming.cpp:
2807         (WebCore::monotonicTimeToDOMHighResTimeStamp):
2808         (WebCore::passesTimingAllowCheck):
2809         (WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
2810         (WebCore::PerformanceResourceTiming::redirectStart):
2811         (WebCore::PerformanceResourceTiming::redirectEnd):
2812         (WebCore::PerformanceResourceTiming::fetchStart):
2813         (WebCore::PerformanceResourceTiming::domainLookupStart):
2814         (WebCore::PerformanceResourceTiming::domainLookupEnd):
2815         (WebCore::PerformanceResourceTiming::connectStart):
2816         (WebCore::PerformanceResourceTiming::connectEnd):
2817         (WebCore::PerformanceResourceTiming::secureConnectionStart):
2818         (WebCore::PerformanceResourceTiming::requestStart):
2819         (WebCore::PerformanceResourceTiming::responseStart):
2820         (WebCore::PerformanceResourceTiming::responseEnd):
2821         (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp):
2822         (WebCore::monotonicTimeToDocumentMilliseconds): Deleted.
2823         (WebCore::PerformanceResourceTiming::initiatorType): Deleted.
2824         (WebCore::PerformanceResourceTiming::resourceTimeToDocumentMilliseconds): Deleted.
2825         * page/PerformanceResourceTiming.h:
2826         * page/PerformanceUserTiming.cpp:
2827         (WebCore::UserTiming::findExistingMarkStartTime):
2828
2829 2017-02-01  Chris Dumez  <cdumez@apple.com>
2830
2831         REGRESSION(r205136): {}.toString.call(crossOriginWindow) should not throw
2832         https://bugs.webkit.org/show_bug.cgi?id=167681
2833         <rdar://problem/30301117>
2834
2835         Reviewed by Mark Lam.
2836
2837         As per https://html.spec.whatwg.org/#crossorigingetownpropertyhelper-(-o,-p-):
2838         """
2839         If P is @@toStringTag, @@hasInstance, or @@isConcatSpreadable, then return
2840         PropertyDescriptor{ [[Value]]: undefined, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
2841         """
2842
2843         We now implement this behavior instead of throwing.
2844
2845         Test: http/tests/security/symbols-cross-origin.html
2846
2847         * bindings/js/JSDOMWindowCustom.cpp:
2848         (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
2849         * bindings/js/JSLocationCustom.cpp:
2850         (WebCore::JSLocation::getOwnPropertySlotDelegate):
2851
2852 2017-02-01  Brent Fulgham  <bfulgham@apple.com>
2853
2854         Correct "filesHaveSameVolume" predicate
2855         https://bugs.webkit.org/show_bug.cgi?id=167696
2856         <rdar://problem/30298722>
2857
2858         Reviewed by David Kilzer.
2859
2860         We are passing %-encoded strings to the underlying operating system's file system APIs.
2861         This doesn't work. Instead, we need to present a decoded version of the file path
2862         that matches what the system APIs expect.
2863
2864         Tested by new TestWebKitAPI Test.
2865
2866         * platform/FileSystem.cpp:
2867         (WebCore::filesHaveSameVolume): Make sure the file paths we give to the underlying
2868         operating system are not percent encoded.
2869         * platform/FileSystem.h: Export 'filesHaveSameVolume' for use by testing system.
2870
2871 2017-02-01  Antoine Quint  <graouts@apple.com>
2872
2873         [mac-wk1] LayoutTest media/modern-media-controls/tracks-support/tracks-support-click-track-in-panel.html is a flaky timeout
2874         https://bugs.webkit.org/show_bug.cgi?id=165319
2875         <rdar://problem/30284104>
2876
2877         Reviewed by Dean Jackson.
2878
2879         Running media/controls/track-menu.html before media/modern-media-controls/tracks-support/tracks-
2880         support-click-track-in-panel.html makes that test time out in all test runs. The root of the issue
2881         is that animations are suspended by media/controls/track-menu.html with a call to
2882         internals.suspendAnimations(), and that state isn't reset with a call to internals.resumeAnimations().
2883         Then, media/modern-media-controls/tracks-support/tracks-support-click-track-in-panel.html fails because
2884         the selection animation for the tracks panel menu item that is clicked never completes and the delegate
2885         to notify that an item in the tracks panel was selected is never fired, which leads to the test failure.
2886
2887         We change Internals::suspendAnimations() and Internals::resumeAnimations() to only affect the current
2888         document, rather than calling into AnimationController::suspendAnimations() which would do just that,
2889         but also set a Frame-wide flag that would prevent further animations from running, even in a subsequent
2890         document load.
2891
2892         * dom/Document.cpp:
2893         (WebCore::Document::prepareForDestruction): Ensure the document that is about to be destroyed is no longer
2894         associated with an AnimationController.
2895         * page/animation/AnimationController.cpp:
2896         (WebCore::AnimationControllerPrivate::ensureCompositeAnimation): Update the animation's suspend state in case
2897         the document its renderer is associated with is suspended. This is required since previously CompositeAnimations
2898         would set their suspend state in their constructor, based on the Frame-wide suspended state, but there is no
2899         document to use as a basis to query its suspended state in that constructor.
2900         (WebCore::AnimationControllerPrivate::animationsAreSuspendedForDocument):
2901         (WebCore::AnimationControllerPrivate::detachFromDocument):
2902         (WebCore::AnimationControllerPrivate::suspendAnimationsForDocument):
2903         (WebCore::AnimationControllerPrivate::resumeAnimationsForDocument):
2904         (WebCore::AnimationControllerPrivate::startAnimationsIfNotSuspended):
2905         (WebCore::AnimationController::animationsAreSuspendedForDocument):
2906         (WebCore::AnimationController::detachFromDocument):
2907         * page/animation/AnimationController.h:
2908         * page/animation/AnimationControllerPrivate.h:
2909         * testing/Internals.cpp:
2910         (WebCore::Internals::animationsAreSuspended):
2911         (WebCore::Internals::suspendAnimations):
2912         (WebCore::Internals::resumeAnimations):
2913
2914 2017-02-01  Ryan Haddad  <ryanhaddad@apple.com>
2915
2916         Unreviewed build fix after r211488.
2917
2918         * accessibility/AXObjectCache.h: Removed property svn:executable.
2919
2920 2017-02-01  Brent Fulgham  <bfulgham@apple.com>
2921
2922         Unreviewed build fix.
2923
2924         * html/HTMLMediaElement.h: Removed property svn:executable.
2925
2926 2017-02-01  Jer Noble  <jer.noble@apple.com>
2927
2928         NULL-deref crash in TextTrack::removeCue()
2929         https://bugs.webkit.org/show_bug.cgi?id=167615
2930
2931         Reviewed by Eric Carlson.
2932
2933         Test: http/tests/media/track-in-band-hls-metadata-crash.html
2934
2935         Follow-up to r211401. When passing around a reference to an object, the assumption is that
2936         the caller is retaining the underlying object. This breaks down for
2937         InbandDataTextTrack::removeDataCue(), which releases its own ownership of the cue object,
2938         then passes the reference to that object to its superclass to do further remove steps. The
2939         retain count of the cue can thus drop to zero within the scope of
2940         InbandTextTrack::removeCue(). Use "take" semantics to remove the cue from the
2941         m_incompleteCueMap without releasing ownership, and pass a reference to that retained object
2942         on to removeCue(), guaranteeing that the cue will not be destroyed until after the
2943         romeveDataCue() method returns.
2944
2945         * html/track/InbandDataTextTrack.cpp:
2946         (WebCore::InbandDataTextTrack::removeDataCue):
2947
2948 2017-02-01  Nan Wang  <n_wang@apple.com>
2949
2950         AX: Incorrect range from index and length in text controls when there are newlines
2951         https://bugs.webkit.org/show_bug.cgi?id=167677
2952         <rdar://problem/30300099>
2953
2954         Reviewed by Chris Fleizach.
2955
2956         When there are newlines in text controls, the VisiblePosition that is created
2957         from the index could be wrong. Because the index doesn't include the information 
2958         regarding a position's affinity. Fixed it by using CharacterOffset instead, since
2959         it doesn't require that information.
2960
2961         Test: accessibility/mac/range-for-contenteditable-newline.html
2962
2963         * accessibility/AXObjectCache.cpp:
2964         (WebCore::AXObjectCache::traverseToOffsetInRange):
2965         (WebCore::AXObjectCache::nextCharacterOffset):
2966         (WebCore::AXObjectCache::characterOffsetForIndex):
2967
2968 2017-02-01  Timothy Hatcher  <timothy@hatcher.name>
2969
2970         AXObjectCache is missing two functions at link time when !HAVE(ACCESSIBILITY)
2971         https://bugs.webkit.org/show_bug.cgi?id=167691
2972
2973         Reviewed by Chris Fleizach.
2974
2975         * accessibility/AXObjectCache.h:
2976         (WebCore::AXObjectCache::recomputeDeferredIsIgnored): Added empty stub.
2977         (WebCore::AXObjectCache::performDeferredIsIgnoredChange): Added empty stub.
2978
2979 2017-02-01  Timothy Hatcher  <timothy@hatcher.name>
2980
2981         HTMLMediaElement.h fails to build when ENABLE(MEDIA_CONTROLS_SCRIPT) is false
2982         https://bugs.webkit.org/show_bug.cgi?id=167689
2983
2984         Reviewed by Joseph Pecoraro.
2985
2986         * html/HTMLMediaElement.h: Move mediaControlsHost() into the ENABLE(MEDIA_CONTROLS_SCRIPT)
2987         block that is just above it to match m_mediaControlsHost.
2988
2989 2017-02-01  Romain Bellessort  <romain.bellessort@crf.canon.fr>
2990
2991         [Readable Streams API] Implement ReadableByteStreamController pull()
2992         https://bugs.webkit.org/show_bug.cgi?id=167593
2993
2994         Reviewed by Youenn Fablet.
2995
2996         Implemented pull() method for ReadableByteStreamController. Also updated
2997         pendingPullIntos attribute, which was a more complex object than necessary
2998         (an array is enough).
2999
3000         Added 2 tests that allow covering most of new code. Code not yet tested will
3001         become reachable as the rest of the spec is implemented (new tests will then
3002         be added).
3003
3004         * Modules/streams/ReadableByteStreamInternals.js:
3005         (privateInitializeReadableByteStreamController): Updated pendingPullIntos.
3006         (readableByteStreamControllerCancel): Updated pendingPullIntos.
3007         (readableByteStreamControllerClose): Updated pendingPullIntos.
3008         (readableByteStreamControllerHandleQueueDrain): Added.
3009         (readableByteStreamControllerPull): Added.
3010
3011 2017-02-01  Enrique Ocaña González  <eocanha@igalia.com>
3012
3013         [GStreamer][MSE] qtdemux: Update the tfdt patch to the version finally accepted upstream
3014         https://bugs.webkit.org/show_bug.cgi?id=166529
3015
3016         Reviewed by Xabier Rodriguez-Calvar.
3017
3018         * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
3019         (WebCore::AppendPipeline::AppendPipeline): Don't use the "always-honor-tfdt" property
3020         in qtdemux anymore.
3021
3022 2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
3023
3024         Unreviewed, build fix for macOS and iOS ports, part 2
3025
3026         Annotate the function with static.
3027
3028         * bindings/js/ScriptModuleLoader.cpp:
3029         (WebCore::rejectToPropagateNetworkError):
3030
3031 2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
3032
3033         Unreviewed, build fix for macOS and iOS ports
3034
3035         * bindings/js/ModuleFetchFailureKind.h: Renamed from Source/ModuleFetchFailureKind.h.
3036
3037 2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
3038
3039         Propagate networking errors correctly for import() operator
3040         https://bugs.webkit.org/show_bug.cgi?id=167501
3041
3042         Reviewed by Ryosuke Niwa.
3043
3044         We use the promise chain inside the module loader pipeline.
3045         The problem is that,
3046
3047         1. The errors of loading module scripts are propagated through the promise's rejection.
3048         2. Some module related errors like syntax error (when scanning module dependencies) are
3049            reported at loading time (evaluating time). These errors are propagated through the
3050            promise rejections and dumped to the console. LoadableModuleScript set catch handler
3051            for that and print these errors to the console for ScriptElement.
3052         3. Some of errors are already reported to the console. For example, networking errors
3053            are reported by the CachedModuleLoader.
3054         4. But there is no way to distinguish between (2) and (3) at the catch handler.
3055
3056         Previously, we propagate the special symbol for the already reported errors to distinguish
3057         that. This was OK because these errors cannot be catched by the user code. However,
3058         recent `import()` call needs to expose these errors to the user code. So now, accidentally,
3059         the special purpose symbol is exposed.
3060
3061         Instead of propagating the special symbol, this patch just propagates the errors. But these
3062         error objects are annotated with the private symbol. So these errors can be distinguished
3063         from the other ones.
3064
3065         Currently, we do not have the way to expose the error details to the client of the
3066         CachedScript. So we just report the error with the failed / canceled. This should be
3067         more descriptive error messages in the separate patch[1].
3068
3069         [1]: https://bugs.webkit.org/show_bug.cgi?id=167553
3070
3071         Tests: http/tests/security/mixedContent/import-insecure-script-in-iframe.html
3072                js/dom/modules/import-not-found-error.html
3073
3074         * WebCore.xcodeproj/project.pbxproj:
3075         * bindings/js/JSDOMPromise.h:
3076         (WebCore::DeferredPromise::resolveWithCallback):
3077         (WebCore::DeferredPromise::rejectWithCallback):
3078         * bindings/js/ScriptController.cpp:
3079         (WebCore::ScriptController::setupModuleScriptHandlers):
3080         * bindings/js/ScriptController.h:
3081         (WebCore::ScriptController::moduleLoaderAlreadyReportedErrorSymbol): Deleted.
3082         (WebCore::ScriptController::moduleLoaderFetchingIsCanceledSymbol): Deleted.
3083         * bindings/js/ScriptModuleLoader.cpp:
3084         (WebCore::rejectToPropagateNetworkError):
3085         (WebCore::ScriptModuleLoader::fetch):
3086         (WebCore::ScriptModuleLoader::notifyFinished):
3087         * bindings/js/WebCoreBuiltinNames.h:
3088
3089 2017-01-31  Wenson Hsieh  <wenson_hsieh@apple.com>
3090
3091         Regression (Safari 10.1): Pressing Return in a contenteditable no longer inserts a line break under certain conditions
3092         https://bugs.webkit.org/show_bug.cgi?id=167525
3093         <rdar://problem/30270210>
3094
3095         Reviewed by Ryosuke Niwa.
3096
3097         Test: fast/events/input-events-insert-newlines-after-mutation.html
3098
3099         Reverts an unintended change made while refactoring code for input events that caused input events to be
3100         dispatched immediately rather than on the scoped queue. Normally, input events are dispatched in
3101         CompositeEditCommand::apply after the end of the scope, but TypingCommands may fire input events *from within*
3102         the scope by calling typingAddedToOpenCommand.
3103
3104         Instead, TypingCommands should always dispatch events
3105         synchronously after the end of the scoped queue in CompositeEditCommand::apply, but this is a riskier change
3106         than we should currently allow, so we should revert to our old behavior for the time being.
3107
3108         * editing/Editor.cpp:
3109
3110 2017-01-31  Zalan Bujtas  <zalan@apple.com>
3111
3112         Simple line layout: Do not assert on zero length/width trailing whitespace.
3113         https://bugs.webkit.org/show_bug.cgi?id=167679
3114
3115         Reviewed by Simon Fraser.
3116
3117         It's valid to have an zero length/width trailing whitespace.
3118
3119         Covered by existing tests.
3120
3121         * rendering/SimpleLineLayout.cpp:
3122         (WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace): Zero length -> nothing to do.
3123         Zero width with length > 0 (font-size: 0) -> remove trailing run.
3124
3125 2017-01-31  Alex Christensen  <achristensen@webkit.org>
3126
3127         Fix debug libwebrtc build after r211439
3128         https://bugs.webkit.org/show_bug.cgi?id=167572
3129
3130         * platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp:
3131         (WebCore::LibWebRTCAudioModule::OnMessage):
3132
3133 2017-01-31  Zalan Bujtas  <zalan@apple.com>
3134
3135         Simple line layout: Collect fragments in LineState only when needed for post-processing.
3136         https://bugs.webkit.org/show_bug.cgi?id=167655
3137         <rdar://problem/30290592>
3138
3139         Reviewed by Antti Koivisto.
3140
3141         The fragments we need to keep around for basic line breaking are the last and last non-whitespace fragments.
3142         However in certain cases such as text-align: justify, we have to traverse the entire line
3143         at post-processing which requires all the fragments on the current line.
3144         This patch speeds up the basic line handling by using m_fragment list only for the special cases.
3145         It improves PerformanceTests/Layout/simple-line-layout-non-repeating-text.html by ~7% (local measurement)
3146         median: 114.25 runs/s -> median: 122.16 runs
3147
3148         Covered by existing tests.
3149
3150         * rendering/SimpleLineLayout.cpp:
3151         (WebCore::SimpleLineLayout::LineState::setNeedsAllFragments):
3152         (WebCore::SimpleLineLayout::LineState::hasTrailingWhitespace):
3153         (WebCore::SimpleLineLayout::LineState::lastFragment):
3154         (WebCore::SimpleLineLayout::LineState::expansionOpportunityCount):
3155         (WebCore::SimpleLineLayout::LineState::isEmpty):
3156         (WebCore::SimpleLineLayout::LineState::endPositionForCollapsedFragment):
3157         (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded): Track uncompleted width.
3158         (WebCore::SimpleLineLayout::LineState::revertToLastCompleteFragment):
3159         (WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace):
3160         (WebCore::SimpleLineLayout::removeTrailingWhitespace):
3161         (WebCore::SimpleLineLayout::updateLineConstrains): Set the slow path for text-align: justify.
3162         (WebCore::SimpleLineLayout::createLineRuns):
3163         (WebCore::SimpleLineLayout::closeLineEndingAndAdjustRuns):
3164         (WebCore::SimpleLineLayout::createTextRuns):
3165         * rendering/SimpleLineLayoutTextFragmentIterator.h:
3166         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isValid):
3167         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::length):
3168
3169 2017-01-31  Chris Dumez  <cdumez@apple.com>
3170
3171         com.apple.WebKit.WebContent.Development crashed in com.apple.WebCore: WebCore::FrameView::didDestroyRenderTree
3172         https://bugs.webkit.org/show_bug.cgi?id=167665
3173         <rdar://problem/30241193>
3174
3175         Reviewed by Andreas Kling.
3176
3177         When destroying a PageCache entry, we would call Document::prepareFromDestruction()
3178         which would destroy the render tree and then call FrameView::didDestroyRenderTree().
3179         We would sometimes hit the ASSERT(m_widgetsInRenderTree.isEmpty()) assertion in
3180         didDestroyRenderTree(). This indicates that there are still RenderWidgets associated
3181         with the FrameView even though we claim we already destroyed the render tree.
3182
3183         The reason for this is that, in the PageCache context, the top document's frame is
3184         reused on navigation and may not be associated with a new document that is currently
3185         displayed, has a render tree (and possible RenderWidgets). The solution proposed is
3186         to stop calling FrameView::didDestroyRenderTree() in Document::prepareFromDestruction()
3187         if the frame's document is not |this|. This happens when the document is destroyed
3188         while in PageCache. We do not want to mess with the frame / frameview in this case
3189         since they are no longer associated to the present document anymore.
3190
3191         No new tests, already covered by existing tests which currently crash flakily.
3192
3193         * dom/Document.cpp:
3194         (WebCore::Document::destroyRenderTree):
3195
3196 2017-01-31  Sam Weinig  <sam@webkit.org>
3197
3198         Remove unused/rarely used bindings helpers
3199         https://bugs.webkit.org/show_bug.cgi?id=167648
3200
3201         Reviewed by Anders Carlsson.
3202
3203         * bindings/js/JSDOMBinding.cpp:
3204         * bindings/js/JSDOMBinding.h:
3205         (WebCore::jsString): Deleted.
3206         (WebCore::jsStringOrUndefined): Deleted.
3207         (WebCore::finiteInt32Value): Deleted.
3208         (WebCore::toJS): Deleted.
3209         Remove unused functions. The toJS overrides can be replaced with their
3210         modern JSDOMConvert counterparts.
3211         
3212         * bindings/js/JSDOMExceptionHandling.h:
3213         (WebCore::toJS): Deleted.
3214         (WebCore::toJSNewlyCreated): Deleted.
3215         Remove unused functions.
3216
3217         * bindings/js/JSDOMIterator.h:
3218         Add more specific include of JSDOMConvert.h to fix compile.
3219
3220         * bindings/js/JSDOMPromise.cpp:
3221         (WebCore::DeferredPromise::reject):
3222         Create the Symbol directly, instead of using the toJS override.
3223
3224         * bindings/js/JSWorkerCustom.cpp:
3225         (WebCore::constructJSWorker):
3226         Use JSDOMConvert toJS function.
3227
3228         * bindings/js/JSXMLHttpRequestCustom.cpp:
3229         (WebCore::JSXMLHttpRequest::retrieveResponse):
3230         Use JSDOMConvert toJS functions.
3231
3232         * bindings/js/ScriptController.h:
3233         Add missing forward declaration of URL.
3234
3235         * bindings/js/ScriptModuleLoader.cpp:
3236         (WebCore::ScriptModuleLoader::resolve):
3237         Create the Symbol directly, instead of using the toJS override.
3238
3239         * html/HTMLPlugInImageElement.cpp:
3240         (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):
3241         Use JSDOMConvert toJS functions.
3242
3243 2017-01-31  Wenson Hsieh  <wenson_hsieh@apple.com>
3244
3245         WebItemProviderPasteboard should be robust when UIItemProvider fails to initialize an object
3246         https://bugs.webkit.org/show_bug.cgi?id=167663
3247         <rdar://problem/30294240>
3248
3249         Reviewed by Tim Horton.
3250
3251         Adds a nil check for the result of -createObjectOfClass:error:.
3252
3253         * platform/ios/WebItemProviderPasteboard.mm:
3254         (-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):
3255         (-[WebItemProviderPasteboard _tryToCreateAndAppendObjectOfClass:toArray:usingProvider:]):
3256
3257 2017-01-31  Keith Rollin  <krollin@apple.com>
3258
3259         Variable used after it's been WTFMove'd
3260         https://bugs.webkit.org/show_bug.cgi?id=167658
3261
3262         Reviewed by Chris Dumez.
3263
3264         Rather than WTFMoving the variable as part of passing it to a function
3265         that takes an RValue-ref, call copyRef to provide the RValue-ref. This
3266         preserves the original variable for later use in the function.
3267
3268         No new tests -- this issue was found by inspection. It's not apparent
3269         what the side-effect of this bug is or how a test would verify it.
3270
3271         * loader/SubresourceLoader.cpp:
3272         (WebCore::SubresourceLoader::didReceiveDataOrBuffer):
3273
3274 2017-01-31  Anders Carlsson  <andersca@apple.com>
3275
3276         Apple Pay button does nothing on nytimes.com
3277         https://bugs.webkit.org/show_bug.cgi?id=167664
3278         rdar://problem/30273885
3279
3280         Reviewed by Sam Weinig.
3281
3282         Separate line item validation into convertAndValidateTotal and convertAndValidate. The former
3283         works on totals (which require an amount), and the latter works on regular line items that do not require an amount
3284         if the item type is "pending".
3285
3286         * Modules/applepay/ApplePaySession.cpp:
3287         (WebCore::convertAndValidateTotal):
3288         (WebCore::convertAndValidate):
3289         Only check the amount if the type is not pending.
3290
3291         (WebCore::ApplePaySession::completeShippingMethodSelection):
3292         (WebCore::ApplePaySession::completeShippingContactSelection):
3293         (WebCore::ApplePaySession::completePaymentMethodSelection):
3294         Call convertAndValidateTotal for totals.
3295
3296 2017-01-31  Youenn Fablet  <youenn@apple.com>
3297
3298         [WebRTC] Add a libwebrtc AudioModule specific to WebKit
3299         https://bugs.webkit.org/show_bug.cgi?id=167572
3300
3301         Reviewed by Alex Christensen.
3302
3303         To be covered by webrtc audio tests.
3304         Adding an AudioModule to circumvent the default LibWebRTC Audio Module which does the audio directly.
3305         The implementation of the AudioModule is restricted to enable fueling the incoming audio tracks with incoming data.
3306         Code inspired from https://chromium.googlesource.com/chromium/src/+/master/remoting/protocol/webrtc_audio_module.h
3307
3308         * WebCore.xcodeproj/project.pbxproj:
3309         * platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp: Added.
3310         (WebCore::LibWebRTCAudioModule::LibWebRTCAudioModule):
3311         (WebCore::LibWebRTCAudioModule::RegisterAudioCallback):
3312         (WebCore::LibWebRTCAudioModule::OnMessage):
3313         (WebCore::LibWebRTCAudioModule::StartPlayout):
3314         (WebCore::LibWebRTCAudioModule::StopPlayout):
3315         (WebCore::LibWebRTCAudioModule::StartPlayoutOnAudioThread):
3316         (WebCore::LibWebRTCAudioModule::PollFromSource):
3317         * platform/mediastream/libwebrtc/LibWebRTCAudioModule.h: Added.
3318         * platform/mediastream/libwebrtc/LibWebRTCUtils.cpp:
3319         (WebCore::ThreadMessageData::ThreadMessageData):
3320         (WebCore::initializePeerConnectionFactoryAndThreads):
3321
3322 2017-01-31  Jessie Berlin  <jberlin@webkit.org>
3323
3324         Build fix.
3325
3326         * editing/mac/EditorMac.mm:
3327         (WebCore::Editor::pasteWithPasteboard):
3328         (WebCore::Editor::takeFindStringFromSelection):
3329         (WebCore::Editor::replaceNodeFromPasteboard):
3330         * page/mac/EventHandlerMac.mm:
3331         (WebCore::EventHandler::createDraggingDataTransfer):
3332         * platform/mac/PasteboardMac.mm:
3333         (WebCore::Pasteboard::createForCopyAndPaste):
3334         (WebCore::Pasteboard::createForDragAndDrop):
3335
3336 2017-01-31  Eric Carlson  <eric.carlson@apple.com>
3337
3338         [Mac] Add an audio stream description class
3339         https://bugs.webkit.org/show_bug.cgi?id=167639
3340
3341         Reviewed by Youenn Fablet.
3342
3343         No new tests, the new class is not used yet.
3344
3345         * WebCore.xcodeproj/project.pbxproj:
3346         * platform/audio/AudioStreamDescription.h: Added.
3347         (WebCore::AudioStreamDescription::isPCM):
3348         * platform/audio/mac/CAAudioStreamDescription.cpp: Added.
3349         (WebCore::CAAudioStreamDescription::CAAudioStreamDescription):
3350         (WebCore::CAAudioStreamDescription::platformDescription):
3351         (WebCore::CAAudioStreamDescription::format):
3352         (WebCore::toCAAudioStreamDescription):
3353         (WebCore::CAAudioStreamDescription::operator==):
3354         (WebCore::operator==):
3355         * platform/audio/mac/CAAudioStreamDescription.h: Added.
3356         (WebCore::operator!=):
3357         (WebCore::CAAudioStreamDescription::bytesPerFrame):
3358         (WebCore::CAAudioStreamDescription::bytesPerPacket):
3359         (WebCore::CAAudioStreamDescription::formatFlags):
3360         (WebCore::CAAudioStreamDescription::operator==):
3361         (WebCore::CAAudioStreamDescription::operator!=):
3362         (WebCore::CAAudioStreamDescription::streamDescription):
3363
3364 2017-01-31  Youenn Fablet  <youenn@apple.com>
3365
3366         RTCPeerConnection methods can take dictionaries as input
3367         https://bugs.webkit.org/show_bug.cgi?id=167590
3368
3369         Reviewed by Alex Christensen.
3370
3371         Test: webrtc/rtcpeerconnection-error-messages.html
3372
3373         Made addIceCandidate/setRemoteDescription/setLocalDescription take either dictionaries or objects as parameter.
3374         Spec only mandates this for addIceCandidate, but sites may be using the old version for setRemoteDescription and setLocalDescription.
3375
3376         Updated RTCPeerConnection methods error messages.
3377
3378         * Modules/mediastream/RTCPeerConnection.js:
3379         (getLocalStreams):
3380         (getStreamById):
3381         (addStream):
3382         (createOffer):
3383         (createAnswer):
3384         (setLocalDescription):
3385         (setRemoteDescription):
3386         (addIceCandidate):
3387         (getStats):
3388         * Modules/mediastream/RTCPeerConnectionInternals.js:
3389
3390 2017-01-31  Simon Fraser  <simon.fraser@apple.com>
3391
3392         REGRESSION (r209411): Scrolling to a fragment identifier in overflow:scroll inside position:fixed no longer works
3393         https://bugs.webkit.org/show_bug.cgi?id=167630
3394         rdar://problem/30091558
3395
3396         Reviewed by Zalan Bujtas.
3397         
3398         r209411 added special handling for scrolling inside position:fixed, but cut off all scrolling, breaking
3399         overflow:scroll inside position:fixed. Fix by only handling the position:fixed case when we get to 
3400         the root layer, which is where we scroll the document.
3401
3402         Test: fast/overflow/scroll-anchor-in-overflow-in-position-fixed.html
3403
3404         * rendering/RenderLayer.cpp:
3405         (WebCore::RenderLayer::getRectToExpose):
3406
3407 2017-01-31  Zan Dobersek  <zdobersek@igalia.com>
3408
3409         [EME] InitDataRegistry should use base64url encoding and decoding for keyids
3410         https://bugs.webkit.org/show_bug.cgi?id=167592
3411
3412         Reviewed by Jer Noble.
3413
3414         In InitDataRegistry, WTF::base64URLEncode() and WTF::base64URLDecode() should
3415         be used to encode and decode the 'keyids' initialization data format, as
3416         required by the relevant specification.
3417         https://w3c.github.io/encrypted-media/format-registry/initdata/keyids.html#format
3418
3419         Relevant test case was added to media/encrypted-media/mock-MediaKeySession-generateRequest.html.
3420
3421         * Modules/encryptedmedia/InitDataRegistry.cpp:
3422         (WebCore::extractKeyIDsKeyids):
3423         (WebCore::sanitizeKeyids):
3424
3425 2017-01-31  Joseph Pecoraro  <pecoraro@apple.com>
3426
3427         Performance Timeline: Add serializer to PerformanceEntry
3428         https://bugs.webkit.org/show_bug.cgi?id=167632
3429
3430         Reviewed by Ryosuke Niwa.
3431
3432         Test: performance-api/performance-timeline-serializers.html
3433
3434         * page/PerformanceEntry.idl:
3435
3436 2017-01-31  Chris Fleizach  <cfleizach@apple.com>
3437
3438         AX: enable search predication for iOS
3439         https://bugs.webkit.org/show_bug.cgi?id=167558
3440         <rdar://problem/30251367>
3441
3442         Reviewed by Joanmarie Diggs.
3443
3444         Move the code to support accessibility searching into a shared place so it can be used by iOS.
3445
3446         Test: accessibility/ios-simulator/ios-search-predicate.html
3447
3448         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
3449         (-[WebAccessibilityObjectWrapper accessibilityFindMatchingObjects:]):
3450         * accessibility/mac/WebAccessibilityObjectWrapperBase.h:
3451         * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
3452         (convertToNSArray):
3453         (createAccessibilitySearchKeyMap):
3454         (accessibilitySearchKeyForString):
3455         (accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute):
3456         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
3457         (createAccessibilitySearchKeyMap): Deleted.
3458         (accessibilitySearchKeyForString): Deleted.
3459         (accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute): Deleted.
3460         (convertToNSArray): Deleted.
3461
3462 2017-01-30  Joseph Pecoraro  <pecoraro@apple.com>
3463
3464         [WebIDL] Add support for inherit serializer attribute
3465         https://bugs.webkit.org/show_bug.cgi?id=167274
3466
3467         Reviewed by Darin Adler.
3468
3469         Support for serializer { inherit }, which will be used by Resource Timing.
3470         https://heycam.github.io/webidl/#idl-serializers
3471
3472         * bindings/scripts/CodeGenerator.pm:
3473         (GetInterfaceForAttribute):
3474         (IsSerializableAttribute):
3475         Determine if an attribute is serializable at generation time so we can
3476         verify types. This allows us to support typedefs. We don't yet support
3477         serializing an attribute that is itself a serializable interface.
3478
3479         * bindings/scripts/CodeGeneratorJS.pm:
3480         (GenerateSerializerFunction):
3481         (GenerateSerializerAttributesForInterface):
3482         Generate inherited attributes first, then generate our own list.
3483         Explicitly provided attribute names are expected to be serializable,
3484         so produce an error if they are not.
3485
3486         * bindings/scripts/IDLParser.pm:
3487         (parseSerializationAttributes):
3488         Update parsing of serializer attributes to allow for multiple
3489         special strings. The spec does not precisely define where the
3490         special "attribute" keyword is allowed.
3491
3492         (applyMemberList):
3493         (isSerializableAttribute): Deleted.
3494         Move serializable attribute checking to generation.
3495
3496         * bindings/scripts/test/JS/JSTestSerialization.cpp:
3497         * bindings/scripts/test/JS/JSTestSerializationInherit.cpp: Added.
3498         * bindings/scripts/test/JS/JSTestSerializationInherit.h: Added.
3499         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp: Added.
3500         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.h: Added.
3501         The toJSON implementations are the most interesting.
3502
3503         * bindings/scripts/test/TestSerialization.idl:
3504         Extend this test for typedefed attributes that are serializable.
3505         Change TestNode (a serializable Interface) to TestException (an
3506         unserializable Interface) for expected behavior of an
3507         unserializable attribute.
3508
3509         * bindings/scripts/test/TestSerializationInherit.idl:
3510         Test for { inherit, attribute }.
3511
3512         * bindings/scripts/test/TestSerializationInheritFinal.idl:
3513         Test for { inherit, attribute_names... }, and multi-level inherit.
3514
3515 2017-01-30  Joseph Pecoraro  <pecoraro@apple.com>
3516
3517         Implement PerformanceObserver
3518         https://bugs.webkit.org/show_bug.cgi?id=167546
3519         <rdar://problem/30247959>
3520
3521         Reviewed by Ryosuke Niwa.
3522
3523         This implements PerformanceObserver from Performance Timeline Level 2:
3524         https://w3c.github.io/performance-timeline/
3525
3526         Tests: performance-api/performance-observer-api.html
3527                performance-api/performance-observer-basic.html
3528                performance-api/performance-observer-callback-mutate.html
3529                performance-api/performance-observer-callback-task.html
3530                performance-api/performance-observer-entry-sort.html
3531                performance-api/performance-observer-exception.html
3532                performance-api/performance-observer-nested.html
3533                performance-api/performance-observer-order.html
3534                performance-api/performance-observer-periodic.html
3535                performance-api/performance-timeline-api.html
3536
3537         * CMakeLists.txt:
3538         * DerivedSources.make:
3539         * WebCore.xcodeproj/project.pbxproj:
3540         New files.
3541
3542         * page/Performance.h:
3543         * page/Performance.cpp:
3544         (WebCore::Performance::mark):
3545         (WebCore::Performance::measure):
3546         (WebCore::Performance::registerPerformanceObserver):
3547         (WebCore::Performance::unregisterPerformanceObserver):
3548         (WebCore::Performance::queueEntry):
3549         Register PerformanceObservers with the Performance object.
3550         When new PerformanceEntries are created (Mark and Measure
3551         right now) check them against observers.
3552
3553         * page/PerformanceEntry.cpp:
3554         (WebCore::PerformanceEntry::PerformanceEntry):
3555         (WebCore::PerformanceEntry::typeForEntryTypeString):
3556         * page/PerformanceEntry.h:
3557         (WebCore::PerformanceEntry::type):
3558         Give PerformanceEntry a convenience enum for easy comparison
3559         and to know if it is one of the built-in known types (which the
3560         PerformanceObserver API takes into account).
3561
3562         * page/PerformanceObserver.cpp: Added.
3563         (WebCore::PerformanceObserver::PerformanceObserver):
3564         (WebCore::PerformanceObserver::observe):
3565         (WebCore::PerformanceObserver::disconnect):
3566         (WebCore::PerformanceObserver::queueEntry):
3567         (WebCore::PerformanceObserver::deliver):
3568         * page/PerformanceObserver.h:
3569         (WebCore::PerformanceObserver::create):
3570         (WebCore::PerformanceObserver::typeFilter):
3571         - TypeErrors on observe bad behavior
3572         - Completely replace types filter on observe
3573         - Handle register and unregister
3574         - Handle calling the callback
3575
3576         * page/PerformanceObserverCallback.idl: Added.
3577         * page/PerformanceObserverEntryList.cpp: Added.
3578         (WebCore::PerformanceObserverEntryList::PerformanceObserverEntryList):
3579         (WebCore::PerformanceObserverEntryList::getEntries):
3580         (WebCore::PerformanceObserverEntryList::getEntriesByType):
3581         (WebCore::PerformanceObserverEntryList::getEntriesByName):
3582         * page/PerformanceObserverEntryList.h:
3583         (WebCore::PerformanceObserverEntryList::create):
3584         * page/PerformanceObserverEntryList.idl: Added.
3585         Implement sorting and filtering of entries.
3586
3587         * page/PerformanceObserver.idl: Added.
3588         * page/PerformanceObserverCallback.h:
3589         (WebCore::PerformanceObserverCallback::~PerformanceObserverCallback):
3590         Mostly autogenerated.
3591
3592         * page/PerformanceUserTiming.cpp:
3593         (WebCore::UserTiming::mark):
3594         (WebCore::UserTiming::measure):
3595         * page/PerformanceUserTiming.h:
3596         Update these to return the entry so it can be passed on to
3597         any interested PerformanceObservers.
3598
3599 2017-01-30  Youenn Fablet  <youenn@apple.com>
3600
3601         [WebRTC] getStats does not support legacy callback
3602         https://bugs.webkit.org/show_bug.cgi?id=167617
3603
3604         Reviewed by Alex Christensen.
3605
3606         Covered by updated tests.
3607
3608         * Modules/mediastream/RTCPeerConnection.cpp:
3609         (WebCore::RTCPeerConnection::getStats):
3610         (WebCore::RTCPeerConnection::privateGetStats): Deleted.
3611         * Modules/mediastream/RTCPeerConnection.h:
3612         * Modules/mediastream/RTCPeerConnection.idl:
3613         * Modules/mediastream/RTCPeerConnection.js:
3614         (addIceCandidate):
3615         (getStats): Deleted.
3616
3617 2017-01-30  Sam Weinig  <sam@webkit.org>
3618
3619         JSDOMBinding is too big. Split it up!
3620         https://bugs.webkit.org/show_bug.cgi?id=167601
3621
3622         Reviewed by Darin Adler.
3623
3624         Splits JSDOMBinding.h/cpp up a bit by splitting out:
3625         - JSDOMBindingCaller.h
3626         - JSDOMBindingSecurity.h/cpp
3627         - JSDOMExceptionHandling.h/cpp
3628         - JSDOMWrapperCache.h/cpp
3629
3630         Also:
3631         - Moves all constructor objects to JSDOMConstructor.h/cpp,  
3632         - Moves special DOMWindow accessors to JSDOMWindowBase.
3633         - Deletes unused CallbackFunction.h/cpp
3634
3635         * CMakeLists.txt:
3636         * Modules/webdatabase/Database.cpp:
3637         * WebCore.xcodeproj/project.pbxproj:
3638         * bindings/js/CallbackFunction.cpp: Removed.
3639         * bindings/js/CallbackFunction.h: Removed.
3640         * bindings/js/DOMConstructorWithDocument.h: Removed.
3641         * bindings/js/JSCryptoCustom.cpp:
3642         * bindings/js/JSCustomXPathNSResolver.cpp:
3643         * bindings/js/JSDOMBinding.cpp:
3644         * bindings/js/JSDOMBinding.h:
3645         * bindings/js/JSDOMBindingCaller.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
3646         * bindings/js/JSDOMBindingSecurity.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
3647         * bindings/js/JSDOMBindingSecurity.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
3648         * bindings/js/JSDOMConstructor.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
3649         * bindings/js/JSDOMConstructor.h:
3650         * bindings/js/JSDOMConvert.h:
3651         * bindings/js/JSDOMExceptionHandling.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
3652         * bindings/js/JSDOMExceptionHandling.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
3653         * bindings/js/JSDOMWindowBase.cpp:
3654         (WebCore::callerDOMWindow): Moved from JSDOMBinding.h
3655         (WebCore::activeDOMWindow): Moved from JSDOMBinding.h
3656         (WebCore::firstDOMWindow): Moved from JSDOMBinding.h
3657         * bindings/js/JSDOMWindowBase.h:
3658         * bindings/js/JSDOMWindowCustom.cpp:
3659         * bindings/js/JSDOMWindowProperties.cpp:
3660         * bindings/js/JSDOMWrapperCache.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
3661         * bindings/js/JSDOMWrapperCache.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
3662         * bindings/js/JSEventTargetCustom.h:
3663         * bindings/js/JSHTMLElementCustom.cpp:
3664         * bindings/js/JSLocationCustom.cpp:
3665         * bindings/js/JSMutationObserverCustom.cpp:
3666         * bindings/js/JSSQLStatementErrorCallbackCustom.cpp:
3667         * bindings/js/JSStorageCustom.cpp:
3668         * bindings/js/JSWorkerCustom.cpp:
3669         * bindings/js/JSXPathNSResolverCustom.cpp:
3670         * bindings/js/ScheduledAction.cpp:
3671         * bindings/js/ScriptController.cpp:
3672         * bindings/js/ScriptController.h:
3673         * bindings/js/ScriptGlobalObject.cpp:
3674         (WebCore::ScriptGlobalObject::set):
3675         * bindings/js/StructuredClone.cpp:
3676         * bindings/scripts/CodeGeneratorJS.pm:
3677         (GenerateImplementation):
3678         (GenerateCallWith):
3679         (GenerateParametersCheck):
3680         (GenerateCallbackImplementationContent):
3681         (NativeToJSValue):
3682         * bridge/objc/WebScriptObject.mm:
3683         * html/HTMLFrameElementBase.cpp:
3684         * html/HTMLVideoElement.cpp:
3685         * inspector/InspectorController.cpp:
3686         * inspector/InspectorDOMAgent.cpp:
3687         * inspector/PageScriptDebugServer.cpp:
3688         * inspector/WorkerScriptDebugServer.cpp:
3689
3690 2017-01-30  Andy Estes  <aestes@apple.com>
3691
3692         [QuickLook] FrameLoaderClient should return the new QuickLookHandleClient it creates
3693         https://bugs.webkit.org/show_bug.cgi?id=167625
3694
3695         Reviewed by Andreas Kling.
3696
3697         QuickLookHandleClients were being created by QuickLookHandle calling
3698         FrameLoaderClient::didCreateQuickLookHandle() then having the FrameLoaderClient create a new
3699         QuickLookHandleClient and set it using QuickLookHandle::setClient().
3700
3701         Since all FrameLoaderClient::didCreateQuickLookHandle() does is create a new
3702         QuickLookHandleClient, this patch changes the FrameLoaderClient function to return the new
3703         QuickLookHandleClient directly and removes the API from QuickLookHandle to set a client.
3704         This also removes previewFileName() and previewUTI() from QuickLookHandle and instead passes
3705         these as arguments to the FrameLoaderClient.
3706
3707         No change in behavior. Covered by existing tests.
3708
3709         * loader/EmptyClients.cpp: Added an implementation of createQuickLookHandleClient() that
3710         returns nullptr.
3711         * loader/FrameLoaderClient.h: Declared createQuickLookHandleClient() and removed
3712         didCreateQuickLookHandle().
3713         * loader/ios/QuickLook.h: Removed setClient(), previewFileName(), and previewUTI().
3714         * loader/ios/QuickLook.mm: Removed testingOrEmptyClient().
3715         (-[WebPreviewLoader initWithResourceLoader:resourceResponse:quickLookHandle:]): Set _client
3716         to testingClient() if it exists, otherwise set it to the client returned by
3717         FrameLoaderClient::createQuickLookHandleClient() it non-null, otherwise set it to
3718         emptyClient().
3719         (testingOrEmptyClient): Deleted.
3720         (-[WebPreviewLoader setClient:]): Deleted.
3721         (-[WebPreviewLoader converter]): Deleted.
3722         (WebCore::QuickLookHandle::setClient): Deleted.
3723         (WebCore::QuickLookHandle::previewFileName): Deleted.
3724         (WebCore::QuickLookHandle::previewUTI): Deleted.
3725
3726 2017-01-30  Jer Noble  <jer.noble@apple.com>
3727
3728         NULL-deref crash in TextTrack::removeCue()
3729         https://bugs.webkit.org/show_bug.cgi?id=167615
3730
3731         Reviewed by Eric Carlson.
3732
3733         It's possible for a track to be removed which was never actually added to the cue list.
3734         Specifically, if an in-band track with a negative start or end time was parsed, it would
3735         have been rejected by TextTrack::addCue(). When it comes time to flush those in-band cues,
3736         TextTrack::m_cues will still be NULL. Rather than ASSERT in this case, we should revert the
3737         behavior added in r210319 and throw an exception.
3738
3739         * html/track/TextTrack.cpp:
3740         (WebCore::TextTrack::removeCue):
3741
3742 2017-01-30  Andreas Kling  <akling@apple.com>
3743
3744         Fix CMSampleBuffer leak in MediaSampleAVFObjC::createNonDisplayingCopy().
3745         <https://webkit.org/b/167621>
3746
3747         Reviewed by Andy Estes.
3748
3749         We were failing to adopt the CMSampleBuffer after copying it. Seen on leaks bot.
3750
3751         * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
3752         (WebCore::MediaSampleAVFObjC::createNonDisplayingCopy):
3753
3754 2017-01-30  Andy Estes  <aestes@apple.com>
3755
3756         [QuickLook] QLPreviewConverter and QuickLookHandle have different lifetime requirements
3757         https://bugs.webkit.org/show_bug.cgi?id=167609
3758
3759         Reviewed by Andreas Kling.
3760         
3761         Currently, QuickLookHandles are owned by DocumentLoader so that the underlying
3762         QLPreviewConverter stays alive to service subresource requests. However, the QuickLookHandle
3763         itself only needs to live long enough to handle the main resource load. And in a follow-on
3764         patch we will need to create QLPreviewConverters independent of QuickLookHandle.
3765
3766         This patch moves ownership of QuickLookHandle from DocumentLoader to ResourceLoader. It also
3767         creates a C++ wrapper around QLPreviewConverter and teaches QuickLookHandle to transfer
3768         ownership of the wrapper to DocumentLoader once the main resource conversion is complete.
3769
3770         No change in behavior. Covered by existing tests.
3771
3772         * WebCore.xcodeproj/project.pbxproj: Added PreviewConverter.{h,mm}.
3773         * loader/DocumentLoader.cpp:
3774         (WebCore::DocumentLoader::setPreviewConverter): Renamed from setQuickLookHandle().
3775         (WebCore::DocumentLoader::previewConverter): Renamed from quickLookHandle().
3776         (WebCore::DocumentLoader::setQuickLookHandle): Renamed to setPreviewConverter().
3777         * loader/DocumentLoader.h:
3778         (WebCore::DocumentLoader::quickLookHandle): Renamed to quickLookHandle().
3779         * loader/ResourceLoader.cpp:
3780         (WebCore::ResourceLoader::willSendRequestInternal): Changed to call PreviewConverter::safeRequest().
3781         (WebCore::ResourceLoader::isQuickLookResource): Changed to check if m_quickLookHandle is null.
3782         (WebCore::ResourceLoader::didCreateQuickLookHandle): Deleted.
3783         * loader/ResourceLoader.h:
3784         * loader/SubresourceLoader.cpp:
3785         (WebCore::SubresourceLoader::shouldCreateQuickLookHandleForResponse): Changed to access m_quickLookHandle.
3786         (WebCore::SubresourceLoader::didReceiveResponse): Ditto.
3787         (WebCore::SubresourceLoader::didReceiveData): Ditto.
3788         (WebCore::SubresourceLoader::didReceiveBuffer): Ditto.
3789         (WebCore::SubresourceLoader::didFinishLoading): Ditto.
3790         (WebCore::SubresourceLoader::didFail): Ditto.
3791         * loader/cache/CachedRawResource.cpp:
3792         (WebCore::CachedRawResource::finishLoading): Wrapped the call to ResourceLoader::isQuickLookResource() in USE(QUICK_LOOK).
3793         * loader/ios/QuickLook.h: Renamed m_converter to m_previewLoader.
3794         * loader/ios/QuickLook.mm: Renamed WebPreviewConverter to WebPreviewLoader.
3795         (WebCore::registerQLPreviewConverterIfNeeded): Created a PreviewConverter instead of a QLPreviewConverter.
3796         (-[WebPreviewLoader initWithResourceLoader:resourceResponse:quickLookHandle:]): Ditto.
3797         (-[WebPreviewLoader appendDataArray:]): Accessed the QLPreviewConverter from the PreviewConverter.
3798         (-[WebPreviewLoader finishedAppending]): Ditto.
3799         (-[WebPreviewLoader failed]): Ditto.
3800         (-[WebPreviewLoader converter]): Renamed from platformConverter. Returns a pointer to the PreviewConverter.
3801         (-[WebPreviewLoader _sendDidReceiveResponseIfNecessary]): Moved _converter to DocumentLoader.
3802         (-[WebPreviewLoader connection:didFailWithError:]): Created a PreviewConverter instead of a QLPreviewConverter.
3803         (WebCore::QuickLookHandle::QuickLookHandle): Called FrameLoaderClient::didCreateQuickLookHandle() instead of going through FrameLoader.
3804         (WebCore::QuickLookHandle::didReceiveData): Renamed m_converter to m_previewLoader.
3805         (WebCore::QuickLookHandle::didReceiveBuffer): Ditto.
3806         (WebCore::QuickLookHandle::didFinishLoading): Ditto.
3807         (WebCore::QuickLookHandle::didFail): Ditto.
3808         (WebCore::QuickLookHandle::setClient): Ditto.
3809         (WebCore::QuickLookHandle::previewFileName): Ditto.
3810         (WebCore::QuickLookHandle::previewUTI): Ditto.
3811         (WebCore::QuickLookHandle::willSendRequest): Deleted.
3812         * platform/ios/QuickLookSoftLink.h: Removed soft-linking of QLPreviewConverter and kQLPreviewOptionPasswordKey.
3813         * platform/ios/QuickLookSoftLink.mm: Ditto.
3814         * platform/network/ios/PreviewConverter.h: Added.
3815         (WebCore::PreviewConverter::platformConverter): Added. Returns the underlying QLPreviewConverter.
3816         * platform/network/ios/PreviewConverter.mm: Added.
3817         (WebCore::optionsWithPassword): Creates a dictionary with the kQLPreviewOptionPasswordKey option set if password is non-null.
3818         (WebCore::PreviewConverter::PreviewConverter): Added constructors for the delegate/response and data/uti cases.
3819         (WebCore::PreviewConverter::safeRequest): Wraps -[QLPreviewConverter safeRequestForRequest:].
3820         (WebCore::PreviewConverter::previewRequest): Wraps -[QLPreviewConverter previewRequest].
3821         (WebCore::PreviewConverter::previewResponse): Wraps -[QLPreviewConverter previewResponse].
3822         (WebCore::PreviewConverter::previewFileName): Wraps -[QLPreviewConverter previewFileName].
3823         (WebCore::PreviewConverter::previewUTI): Wraps -[QLPreviewConverter previewUTI].
3824
3825 2017-01-30  Chris Dumez  <cdumez@apple.com>
3826
3827         Drop legacy Attributes.isId attribute
3828         https://bugs.webkit.org/show_bug.cgi?id=167603
3829
3830         Reviewed by Ryosuke Niwa.
3831
3832         Drop legacy Attributes.isId attribute.
3833
3834         This attribute is not in the specification:
3835         - https://dom.spec.whatwg.org/#interface-attr
3836
3837         Both Firefox and Chrome currently do not expose this attribute.
3838
3839         No new tests, rebaselined existing test.
3840
3841         * dom/Attr.cpp:
3842         * dom/Attr.h:
3843         * dom/Attr.idl:
3844
3845 2017-01-30  Zalan Bujtas  <zalan@apple.com>
3846
3847         Simple line layout: Small tweaks to improve performance.
3848         https://bugs.webkit.org/show_bug.cgi?id=167611
3849         <rdar://problem/30274294>
3850
3851         Reviewed by Simon Fraser.
3852
3853         This is ~10% progression on the attached test case (paragraphs with non-redundant content).
3854         median: 102.08 runs/s -> median: 114.25 runs/s
3855
3856         * rendering/SimpleLineLayout.cpp:
3857         (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded):
3858         * rendering/SimpleLineLayoutFlowContents.cpp:
3859         (WebCore::SimpleLineLayout::initializeSegments):
3860         (WebCore::SimpleLineLayout::FlowContents::FlowContents):
3861         * rendering/SimpleLineLayoutFlowContents.h:
3862         * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
3863         (WebCore::SimpleLineLayout::TextFragmentIterator::nextNonWhitespacePosition):
3864         (WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):
3865         * rendering/SimpleLineLayoutTextFragmentIterator.h:
3866
3867 2017-01-30  Chris Dumez  <cdumez@apple.com>
3868
3869         Drop legacy constants on Event interface
3870         https://bugs.webkit.org/show_bug.cgi?id=167602
3871
3872         Reviewed by Sam Weinig.
3873
3874         Drop legacy constants on Event interface:
3875         MOUSEDOWN, MOUSEUP, MOUSEOVER, MOUSEOUT, MOUSEMOVE, MOUSEDRAG,
3876         CLICK, DBLCLICK, KEYDOWN, KEYUP, KEYPRESS, DRAGDROP, FOCUS,
3877         BLUR, SELECT, and CHANGE.
3878
3879         Those constants are not used for anything, they are not in the
3880         specification and Chrome / Firefox do not have them.
3881
3882         No new tests, rebaselined existing test.
3883
3884         * dom/Event.idl:
3885
3886 2017-01-30  Simon Fraser  <simon.fraser@apple.com>
3887
3888         [iOS] position:fixed inside touch-scrollable overflow is mispositioned
3889         https://bugs.webkit.org/show_bug.cgi?id=167604
3890         rdar://problem/29500273
3891
3892         Reviewed by Zalan Bujtas.
3893         
3894         For layers inside touch-scrollable overflow, RenderLayerBacking::computeParentGraphicsLayerRect() needs
3895         to account for the offset from the ancestor compositing layer's origin, to handle scrollable elements with
3896         box-shadow, for example.
3897         
3898         Also make the compositing log output a little easier to read.
3899
3900         Test: compositing/scrolling/fixed-inside-scroll.html
3901
3902         * rendering/RenderLayerBacking.cpp:
3903         (WebCore::RenderLayerBacking::computeParentGraphicsLayerRect):
3904         * rendering/RenderLayerCompositor.cpp:
3905         (WebCore::RenderLayerCompositor::logLayerInfo):
3906
3907 2017-01-30  Jer Noble  <jer.noble@apple.com>
3908
3909         NULL-deref crash at PlatformMediaSession::endInterruption
3910         https://bugs.webkit.org/show_bug.cgi?id=167595
3911
3912         Reviewed by Eric Carlson.
3913
3914         Use the same, NULL-aware forEachSession() iterator rather than iterating over m_sessions directly.
3915
3916         * platform/audio/PlatformMediaSessionManager.cpp:
3917         (WebCore::PlatformMediaSessionManager::beginInterruption):
3918         (WebCore::PlatformMediaSessionManager::endInterruption):
3919
3920 2017-01-30  Myles C. Maxfield  <mmaxfield@apple.com>
3921
3922         Correct spacing regression on inter-element complex path shaping on some fonts
3923         https://bugs.webkit.org/show_bug.cgi?id=166013
3924
3925         Reviewed by Simon Fraser.
3926
3927         This patch brings the implementation of ComplexTextController in-line with the
3928         design at https://trac.webkit.org/wiki/ComplexTextController. Previously,
3929         ComplexTextController had a few problems:
3930         - The total width computed by ComplexTextController didn't match the width if
3931         you iterated over the entire string and added up the advances
3932         - FontCascade::getGlyphsAndAdvancesForComplexText() tried to compensate for
3933         the above by construing the concepts of paint advances as distinct from layout
3934         advances
3935         - Initial advances were considered part of layout sometimes and part of painting
3936         other times, depending on which function reports the information
3937         - For RTL runs, the wrong origin was added to the initial advance, and the origin
3938         should have been subtracted instead of added
3939
3940         This patch exhaustively updates every function in ComplexTextController to be
3941         consistent with the design linked to above. This design solves all of these
3942         problems.
3943
3944         Tests: ComplexTextControllerTest.InitialAdvanceWithLeftRunInRTL
3945                ComplexTextControllerTest.InitialAdvanceInRTL
3946                ComplexTextControllerTest.InitialAdvanceWithLeftRunInLTR
3947                ComplexTextControllerTest.InitialAdvanceInLTR
3948                ComplexTextControllerTest.InitialAdvanceInRTLNoOrigins
3949                ComplexTextControllerTest.LeadingExpansion
3950                ComplexTextControllerTest.VerticalAdvances
3951
3952         * platform/graphics/GlyphBuffer.h:
3953         (WebCore::GlyphBuffer::setLeadingExpansion): Deleted. No longer necessary.
3954         (WebCore::GlyphBuffer::leadingExpansion): Deleted. Ditto.
3955         * platform/graphics/cocoa/FontCascadeCocoa.mm:
3956         (WebCore::FontCascade::adjustSelectionRectForComplexText): Removed use of
3957         unnecessary leadingExpansion().
3958         (WebCore::FontCascade::getGlyphsAndAdvancesForComplexText): This function needs
3959         to compute paint advances, which means that it can't base this information off
3960         of layout advances. This function uses the trick mentioned at the end of the
3961         above link to compute the paint offset of an arbitrary glyph in the middle of
3962         an RTL run.
3963         * platform/graphics/mac/ComplexTextController.cpp:
3964         (WebCore::ComplexTextController::computeExpansionOpportunity): Refactored for
3965         testing.
3966         (WebCore::ComplexTextController::ComplexTextController): Ditto.
3967         (WebCore::ComplexTextController::finishConstruction): Ditto.
3968         (WebCore::ComplexTextController::offsetForPosition): This function operates on
3969         layout advances,