8094ee1e53647c809a7a8621169540755fd981e0
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-02-02  Joseph Pecoraro  <pecoraro@apple.com>
2
3         Support Performance API (performance.now(), UserTiming) in Workers
4         https://bugs.webkit.org/show_bug.cgi?id=167717
5
6         Reviewed by Ryosuke Niwa.
7
8         Tests: performance-api/performance-mark-name.html
9                performance-api/performance-now-api.html
10                performance-api/performance-now-time-origin-in-worker.html
11                performance-api/user-timing-apis.html
12
13         * CMakeLists.txt:
14         * DerivedSources.make:
15         New files.
16
17         * page/DOMWindow.idl:
18         * page/GlobalPerformance.idl:
19         * workers/WorkerGlobalScope.idl:
20         Add partial interface for performance attribute.
21
22         * page/Performance.idl:
23         * page/PerformanceEntry.idl:
24         * page/PerformanceMark.idl:
25         * page/PerformanceMeasure.idl:
26         * page/PerformanceObserver.idl:
27         * page/PerformanceObserverEntryList.idl:
28         Expose these to Workers.
29
30         * page/Performance.cpp:
31         (WebCore::Performance::Performance):
32         (WebCore::Performance::contextDestroyed):
33         * page/Performance.h:
34         Use the EventQueue variant that works with any ScriptExectionContext.
35
36         * page/PerformanceObserver.cpp:
37         (WebCore::PerformanceObserver::PerformanceObserver):
38         Get the Performance base in a Worker context.
39
40         * page/PerformanceUserTiming.cpp:
41         (WebCore::UserTiming::mark):
42         Only reject legacy special mark names in a Window, not a Worker.
43
44         (WebCore::UserTiming::findExistingMarkStartTime):
45         Simple implementation returns 0 as the start time in Workers. The spec
46         is currently imprecise here, but it does not have the unusual
47         PerformanceTiming behavior in a Window which is part of User Timing 1.
48
49         * workers/Worker.cpp:
50         (WebCore::Worker::create):
51         (WebCore::Worker::notifyFinished):
52         * workers/Worker.h:
53         Record the moment of Worker creation.
54
55         * workers/WorkerGlobalScope.cpp:
56         (WebCore::WorkerGlobalScope::WorkerGlobalScope):
57         (WebCore::WorkerGlobalScope::performance):
58         * workers/WorkerGlobalScope.h:
59         Construct the Performance object with the moment of creation (timeOrigin).
60
61         * workers/DedicatedWorkerGlobalScope.cpp:
62         (WebCore::DedicatedWorkerGlobalScope::create):
63         (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
64         * workers/DedicatedWorkerGlobalScope.h:
65         * workers/DedicatedWorkerThread.cpp:
66         (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
67         (WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
68         * workers/DedicatedWorkerThread.h:
69         * workers/WorkerGlobalScopeProxy.h:
70         * workers/WorkerMessagingProxy.cpp:
71         (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
72         * workers/WorkerMessagingProxy.h:
73         * workers/WorkerThread.cpp:
74         (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
75         (WebCore::WorkerThread::WorkerThread):
76         (WebCore::WorkerThread::workerThread):
77         * workers/WorkerThread.h:
78         Pass the moment of creation (timeOrigin) through to WorkerGlobalScope creation.
79
80 2017-02-02  Commit Queue  <commit-queue@webkit.org>
81
82         Unreviewed, rolling out r211579.
83         https://bugs.webkit.org/show_bug.cgi?id=167753
84
85         Caused mediastream crashes. (Requested by bfulgham_ on
86         #webkit).
87
88         Reverted changeset:
89
90         "Correct memory leak in MediaConstraints"
91         https://bugs.webkit.org/show_bug.cgi?id=167744
92         http://trac.webkit.org/changeset/211579
93
94 2017-02-02  Chris Dumez  <cdumez@apple.com>
95
96         Rename Node::inDocument() to isConnected()
97         https://bugs.webkit.org/show_bug.cgi?id=167743
98
99         Reviewed by Sam Weinig.
100
101         Rename Node::inDocument() to isConnected() to match the DOM specification more closely:
102         - https://dom.spec.whatwg.org/#connected
103
104 2017-02-02  Antoine Quint  <graouts@apple.com>
105
106         [Modern Media Controls] Provide a compact mode for when the controls are small
107         https://bugs.webkit.org/show_bug.cgi?id=167746
108         <rdar://problem/29565842>
109
110         Reviewed by Dean Jackson.
111
112         When the macOS inline media controls become too narrow to display both the volume and fullscreen
113         buttons in their right container (width < 242), we switch to a compact mode where the controls bar
114         is shorter and the buttons smaller.
115
116         To facilitate this, we provide a new subclass of MacOSInlineMediaControls called MacOSCompactInlineMediaControls
117         which changes some of the layout properties of the buttons to have shorter margins around buttons.
118
119         We also added a new "Compact" LayoutTrait and improved IconService to provide specific icons
120         for this mode for the buttons that can exist in compact mode. 
121
122         To correctly implement the design, we needed to add a way to provide different margins around the
123         left and right edges of the container, so the "padding" property is now split between "leftMargin"
124         and "rightMargin", and to make property naming cleaner, the "margin" property which specifies the
125         space between each button in a container is now called "buttonMargin". We also set the default
126         values for those properties to be 24 (instead of 0) which are the most widely used values, requiring
127         less customization.
128
129         Tests: media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-buttons-styles.html
130                media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-constructor.html
131                media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-controls-bar-styles.html
132                media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-layout.html
133                media/modern-media-controls/macos-compact-inline-media-controls/macos-compact-inline-media-controls-volume-styles.html
134                media/modern-media-controls/media-controller/media-controller-toggle-compact-mode.html
135
136         * Modules/modern-media-controls/controls/buttons-container.js:
137         (ButtonsContainer.prototype.layout): Refactor the "margin" and "padding" properties into
138         "leftMargin", "rightMargin" and "buttonMargin".
139         * Modules/modern-media-controls/controls/icon-button.js:
140         (IconButton.prototype._updateImage): Fix a small bug that would prevent the image source
141         change to occur after changing the "iconName" property should the previous and new icons
142         share the same metrics, which is the case for the "play" and "pause" icons in compact mode.
143         * Modules/modern-media-controls/controls/icon-service.js: Add support for compact variants.
144         (const.iconService.new.IconService.prototype._fileNameAndPlatformForIconNameAndLayoutTraits):
145         (const.iconService.new.IconService):
146         * Modules/modern-media-controls/controls/ios-inline-media-controls.js: Adopt new margin defaults.
147         * Modules/modern-media-controls/controls/layout-item.js: Add the new "Compact" LayoutTrait.
148         * Modules/modern-media-controls/controls/macos-compact-inline-media-controls.css: Added.
149         (.media-controls.mac.inline.compact > .controls-bar):
150         (.media-controls.mac.inline.compact button.play-pause):
151         (.media-controls.mac.inline.compact button.skip-back):
152         (.media-controls.mac.inline.compact .scrubber.slider):
153         (.media-controls.mac.inline.compact button.mute):
154         (.media-controls.mac.inline.compact button.fullscreen):
155         (.media-controls.mac.inline.compact .time-label,):
156         (.media-controls.mac.inline.compact .volume-slider-container):
157         (.media-controls.mac.inline.compact .volume.slider):
158         (.media-controls.mac.inline.compact .scrubber.slider > input::-webkit-slider-thumb):
159         * Modules/modern-media-controls/controls/macos-compact-inline-media-controls.js: Added.
160         (MacOSCompactInlineMediaControls):
161         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js: Adopt new margin defaults.
162         (MacOSFullscreenMediaControls.prototype.layout):
163         * Modules/modern-media-controls/controls/macos-inline-media-controls.js: Adopt new margin defaults
164         and make the _leftContainer and _rightContainer properties public such that the MacOSCompactInlineMediaControls
165         subclass may customize them without accessing a private property.
166         (MacOSInlineMediaControls.prototype.layout):
167         (MacOSInlineMediaControls.prototype.showTracksPanel):
168         * Modules/modern-media-controls/images/macOS/enter-fullscreen-compact@1x.png: Added.
169         * Modules/modern-media-controls/images/macOS/enter-fullscreen-compact@2x.png: Added.
170         * Modules/modern-media-controls/images/macOS/interval-skip-back-compact@1x.png: Added.
171         * Modules/modern-media-controls/images/macOS/interval-skip-back-compact@2x.png: Added.
172         * Modules/modern-media-controls/images/macOS/pause-compact@1x.png: Added.
173         * Modules/modern-media-controls/images/macOS/pause-compact@2x.png: Added.
174         * Modules/modern-media-controls/images/macOS/play-compact@1x.png: Added.
175         * Modules/modern-media-controls/images/macOS/play-compact@2x.png: Added.
176         * Modules/modern-media-controls/images/macOS/volume-compact@1x.png: Added.
177         * Modules/modern-media-controls/images/macOS/volume-compact@2x.png: Added.
178         * Modules/modern-media-controls/js-files: Add the new files so they are concatenated by the build script.
179         * Modules/modern-media-controls/media/media-controller.js: Toggle compact mode if controls
180         are below the 242px width threshold.
181         (MediaController.prototype.get layoutTraits):
182         (MediaController.prototype.handleEvent):
183         (MediaController.prototype._updateControlsIfNeeded):
184         (MediaController.prototype._shouldFadeBetweenControls):
185         (MediaController.prototype._updateControlsSize):
186         (MediaController.prototype._controlsWidth):
187         (MediaController.prototype._controlsClass):
188         (MediaController):
189         * WebCore.xcodeproj/project.pbxproj: Add new files and perform some cleanup so that the
190         project accurately lists all the existing project files and remove some older ones.
191
192 2017-02-02  Commit Queue  <commit-queue@webkit.org>
193
194         Unreviewed, rolling out r211571 and r211582.
195         https://bugs.webkit.org/show_bug.cgi?id=167751
196
197         This change caused API test WebKit1.MemoryPressureHandler to
198         fail with an assertion. (Requested by ryanhaddad on #webkit).
199
200         Reverted changesets:
201
202         "[Mac] In-process memory pressure monitor for WebContent
203         processes."
204         https://bugs.webkit.org/show_bug.cgi?id=167491
205         http://trac.webkit.org/changeset/211571
206
207         "Unreviewed attempt to fix the Windows build after r211571."
208         http://trac.webkit.org/changeset/211582
209
210 2017-02-02  Chris Dumez  <cdumez@apple.com>
211
212         Unreviewed attempt to fix the Windows build after r211571.
213
214         * platform/MemoryPressureHandler.cpp:
215         (WebCore::thresholdForPolicy):
216         (WebCore::policyForFootprint):
217
218 2017-02-02  Brent Fulgham  <bfulgham@apple.com>
219
220         Correct memory leak in MediaConstraints
221         https://bugs.webkit.org/show_bug.cgi?id=167744
222         <rdar://problem/30331444>
223
224         Reviewed by Anders Carlsson.
225
226         ConstraintHolder returns a reference to an object created by operator new. When the
227         returned value is assigned or stored in Vector or other containers we leak memory.
228         Instead, this value should just be returned as a regular object so that the return
229         value optimization can make sure memory is properly (and efficiently) used.
230
231         * platform/mediastream/MediaConstraints.h:
232         (WebCore::FlattenedConstraint::ConstraintHolder::create): Return by value.
233
234 2017-02-02  Andreas Kling  <akling@apple.com>
235
236         [Mac] In-process memory pressure monitor for WebContent processes AKA websam
237         <https://webkit.org/b/167491>
238         <rdar://problem/30116072>
239
240         Reviewed by Antti Koivisto.
241
242         Add a new timer-based memory pressure monitor that checks the process memory
243         footprint every 30 seconds and reacts to changes by setting a MemoryUsagePolicy.
244
245         There are four MemoryUsagePolicy values:
246
247             - Unrestricted (below 1GB)
248             - Conservative (above 1GB)
249             - Strict (above 2GB)
250             - Panic (above 4GB, or 3GB if 32-bit)
251
252         For Strict and above, the old-style "isUnderMemoryPressure()" API will return true.
253
254         Transitioning to a higher policy will cause memory pressure handlers to run:
255
256         At Strict, we run the "non-critical" memory pressure handler, then carry on.
257
258         At Panic, we run the "critical" memory pressure handler. If that fails to recover
259         enough memory to bring us back below 4GB, we may kill the process:
260
261         A process is eligible to get killed for using too much memory if:
262
263             - It's not visible on screen (i.e it's a background tab.)
264             - It's not playing audio.
265             - It has not performed a main frame navigation in the last hour.
266
267         Before killing the process, an exit-time callback will run. This patch installs such
268         a callback that prints out some time-of-death statistics about C++ and JavaScript memory
269         usage to hopefully help understand what was soaking up all the memory.
270
271         * bindings/js/CommonVM.cpp:
272         (WebCore::commonVMSlow):
273         * loader/FrameLoader.cpp:
274         (WebCore::FrameLoader::setState):
275         * page/MainFrame.cpp:
276         (WebCore::MainFrame::didCompleteLoad):
277         * page/MainFrame.h:
278         * page/MemoryRelease.cpp:
279         (WebCore::pageCount):
280         (WebCore::logMemoryStatisticsAtTimeOfDeath):
281         (WebCore::didExceedMemoryLimitAndFailedToRecover):
282         (WebCore::processIsEligibleForMemoryKill):
283         * page/MemoryRelease.h:
284         * page/ResourceUsageThread.h:
285         * page/cocoa/ResourceUsageThreadCocoa.mm:
286         (WebCore::vmPageSize):
287         * platform/MemoryPressureHandler.cpp:
288         (WebCore::MemoryPressureHandler::MemoryPressureHandler):
289         (WebCore::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
290         (WebCore::toString):
291         (WebCore::thresholdForPolicy):
292         (WebCore::policyForFootprint):
293         (WebCore::MemoryPressureHandler::measurementTimerFired):
294         * platform/MemoryPressureHandler.h:
295         (WebCore::MemoryPressureHandler::setMemoryKillCallback):
296         (WebCore::MemoryPressureHandler::setProcessIsEligibleForMemoryKillCallback):
297         (WebCore::MemoryPressureHandler::isUnderMemoryPressure):
298
299 2017-02-02  Chris Dumez  <cdumez@apple.com>
300
301         [Crash] com.apple.WebKit.WebContent at WebKit: WebKit::WebPage::fromCorePage()
302         https://bugs.webkit.org/show_bug.cgi?id=167738
303         <rdar://problem/30229990>
304
305         Reviewed by Andreas Kling.
306
307         Upon destruction of a Page, we destroy the BackForwardClient, which is supposed
308         to keep track of HistoryItems associated to this particular page and remove them
309         from the PageCache. Given the crash trace, the issue seems to be that some
310         HistoryItems associated with the Page sometimes linger in the PageCache *after*
311         the Page has been destroyed, which leads to crashes later on when pruning the
312         PageCache.
313
314         In order to make the process more robust, this patch refactors the code so that
315         the Page is now in charge of removing all its associated HistoryItems from the
316         PageCache instead of relying on the BackForwardClient. Also, instead of having
317         the Page keep track of which HistoryItems are associated with it (which is
318         error prone), we now scan all PageCache entries instead to find which ones are
319         associated with the Page. While this is in theory slower, this is much safer
320         and in practice not an issue because the PageCache usually has 3-5 entries.
321
322         No new tests, could not reproduce.
323
324         * history/CachedPage.cpp:
325         (WebCore::CachedPage::CachedPage):
326         * history/CachedPage.h:
327         (WebCore::CachedPage::page):
328         * history/PageCache.cpp:
329         (WebCore::PageCache::removeAllItemsForPage):
330         * history/PageCache.h:
331         * page/Page.cpp:
332         (WebCore::Page::~Page):
333
334 2017-02-02  Antti Koivisto  <antti@apple.com>
335
336         Column progression wrong after enabling pagination on RTL document
337         https://bugs.webkit.org/show_bug.cgi?id=167733
338         <rdar://problem/29012252>
339
340         Reviewed by Zalan Bujtas.
341
342         Column progression depends on document direction but was not updated when direction changed.
343
344         Test: fast/multicol/pagination/pagination-dynamic-rtl.html
345
346         * rendering/RenderBox.cpp:
347         (WebCore::RenderBox::styleDidChange):
348
349             Update column styles if document direction changes.
350
351 2017-02-02  Xabier Rodriguez Calvar  <calvaris@igalia.com>
352
353         [EME][GStreamer] Fixed decryptor selection
354         https://bugs.webkit.org/show_bug.cgi?id=167588
355
356         Reviewed by Žan Doberšek.
357
358         GStreamer selected a decryptor automatically but we need to be
359         able to tell it which decryptor we want because one file can be
360         encrypted with more than one system and the one we want to use can
361         depend on what the user tells us.
362
363         Now when the demuxer is about to select the demuxer, it runs a
364         GstContext query with the events, which are forwarded through the
365         EME api to the application, which will answer the the
366         generateKeyRequest and then we can instruct the demuxer to select
367         the one we tell it, not the one that is selected automatically. If
368         the demuxer has already a preferred decryptor, the codepath will
369         be similar to the older one.
370
371         Something that is also fixed is the report of the keyneeded event,
372         which will contain all pssh boxes as requested by the spec.
373
374         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
375         (WebCore::MediaPlayerPrivateGStreamer::handleMessage): Intercept
376         the event and handle it.
377         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
378         (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
379         Initialize the CDM session.
380         (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
381         Unlock the protection condition just in case and set CDM to null.
382         (WebCore::extractEventsAndSystemsFromMessage): Access the events
383         and accepted key systems coming at the message from the demuxer.
384         (WebCore::MediaPlayerPrivateGStreamerBase::handleSyncMessage):
385         Handle the protection event not as an element event but as a
386         context request. It also concatenates all the initdatas in case
387         there is more than one. The event is sent in the main thread and
388         the current one blocks until a timeout is hit or the
389         generateKeyRequest is called.
390         (WebCore::MediaPlayerPrivateGStreamerBase::handleProtectionEvent):
391         Check if the event was already handled and if not, run the need
392         key event.
393         (WebCore::MediaPlayerPrivateGStreamerBase::receivedGenerateKeyRequest):
394         Notify the that the query arrived so that we can unlock the
395         demuxer thread.
396         (WebCore::keySystemIdToUuid): Translates ids to uuids, meaning
397         the ones coming from JS to the ones coming from the media engine.
398         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
399         Attributes and methods.
400         * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
401         (webkit_media_clear_key_decrypt_class_init):
402         (webKitMediaClearKeyDecryptorRequestDecryptionKey): Deleted.
403         * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.h:
404         Added the ui and uuid.
405         * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
406         (webkitMediaCommonEncryptionDecryptSinkEventHandler): Do not rely
407         on the subclass, just forward the event to the pipeline inside a message.
408         * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h:
409         Remove unused function signature.
410         * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
411         (WebCore::appendPipelineNeedContextMessageCallback): Renamed from
412         appendPipelineElementMessageCallback.
413         (WebCore::AppendPipeline::AppendPipeline): Connect to the
414         need-context message instead of the element one.
415         (WebCore::AppendPipeline::dispatchPendingDecryptionKey):
416         Dispatches the drm-cypher message if there is one pending.
417         (WebCore::AppendPipeline::dispatchDecryptionKey): Dispatches the
418         drm-cypher.
419         (WebCore::AppendPipeline::handleNeedContextSyncMessage): Handles
420         the need-context event instead of the element one.
421         (WebCore::AppendPipeline::connectDemuxerSrcPadToAppsinkFromAnyThread):
422         Dispatches the key to the pipeline if there's any pending.
423         (WebCore::appendPipelineElementMessageCallback): Deleted.
424         (WebCore::AppendPipeline::handleElementMessage): Deleted.
425         * platform/graphics/gstreamer/mse/AppendPipeline.h: New methods
426         and attributes.
427         * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
428         (WebCore::MediaPlayerPrivateGStreamerMSE::dispatchDecryptionKey):
429         Use the dispatchDecryptionKey method of the AppendPipeline.
430
431 2017-02-02  Joseph Pecoraro  <pecoraro@apple.com>
432
433         Removed unused EventHandler members
434         https://bugs.webkit.org/show_bug.cgi?id=167723
435
436         Reviewed by Yusuke Suzuki.
437
438         * page/EventHandler.cpp:
439         (WebCore::EventHandler::clear):
440         (WebCore::EventHandler::handleWheelEvent):
441         * page/EventHandler.h:
442         Remove unused members.
443
444         * editing/FrameSelection.cpp:
445         * html/HTMLTextAreaElement.cpp:
446         * rendering/RenderObject.cpp:
447         * rendering/RenderSlider.cpp:
448         Remove unnecessary includes.
449
450 2017-02-02  Joseph Pecoraro  <pecoraro@apple.com>
451
452         Removed unused m_navigationStart from NavigatorGamepad
453         https://bugs.webkit.org/show_bug.cgi?id=167722
454
455         Reviewed by Yusuke Suzuki.
456
457         * Modules/gamepad/NavigatorGamepad.cpp:
458         (WebCore::NavigatorGamepad::NavigatorGamepad):
459         (WebCore::NavigatorGamepad::from):
460         * Modules/gamepad/NavigatorGamepad.h:
461         (WebCore::NavigatorGamepad::navigationStart): Deleted.
462
463 2017-02-02  Yongjun Zhang  <yongjun_zhang@apple.com>
464
465         In iOS, we should take background assertion when accessing localstorage databases.
466         https://bugs.webkit.org/show_bug.cgi?id=165478
467
468         Move WebSQLiteDatabaseTrackerClient from WebKitLegacy to WebCore so that it can be accessible from
469         WebKit1 and WebKit2. Previously, to avoid dependencies on UIKit, WebKitLegacy introduced several
470         global methods for UIKit to setup the start/end background task blocks on runtime (WebKitSetStartBackgroundTaskBlock,
471         WebKitSetInvalidWebBackgroundTaskIdentifier and WebKitSetEndBackgroundTaskBlock). Since we have to
472         move the background task handling to WebCore, to avoid adding WebCore dependencies on UIKit, this
473         patch introdues a new WebCore class WebBackgroundTaskController which holds the start/end background
474         task blocks. The existing WebKitSetStartBackgroundTaskBlock and WebKitSetEndBackgroundTaskBlock methods
475         in WebKit1 will use WebBackgroundTaskController to store the blocks set by UIKit. 
476
477         Reviewed by Brady Eidson.
478
479         No new test since this is code refactoring.
480
481         * WebCore.xcodeproj/project.pbxproj: Add a new class WebBackgroundTaskController to the project. Also move
482             WebSQLiteDatabaseTrackerClient from WebKitLegacy to WebCore.
483         * platform/ios/WebBackgroundTaskController.h: Use properties to hold the blocks for starting or ending background tasks.
484         * platform/ios/WebBackgroundTaskController.mm:
485         (+[WebBackgroundTaskController sharedController]):
486         (-[WebBackgroundTaskController dealloc]):
487         (-[WebBackgroundTaskController startBackgroundTaskWithExpirationHandler:]): Start a background task with a expiration handler;
488             to start the background task, we will use backgroundTaskStartBlock set up by UIKit.
489         (-[WebBackgroundTaskController endBackgroundTaskWithIdentifier:]): Call backgroundTaskEndBlack to end a background task.
490         * platform/ios/WebSQLiteDatabaseTrackerClient.h: Copied from Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.h.
491         * platform/ios/WebSQLiteDatabaseTrackerClient.mm: Copied from Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.mm.
492         (WebCore::WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient): Make WebSQLiteDatabaseTrackerClient a singleton.
493         (WebCore::WebSQLiteDatabaseTrackerClient::WebSQLiteDatabaseTrackerClient): 
494         (WebCore::WebSQLiteDatabaseTrackerClient::~WebSQLiteDatabaseTrackerClient):
495         (WebCore::WebSQLiteDatabaseTrackerClient::willBeginFirstTransaction): Use a utility class WebDatabaseTransactionBackgroundTaskController
496             to schedule database transaction background task.
497         (WebCore::WebSQLiteDatabaseTrackerClient::didFinishLastTransaction): Use WebDatabaseTransactionBackgroundTaskController to stop
498             databas transaction background task.
499         (transactionBackgroundTaskIdentifierLock: Moved from Source/WebKit/mac/Storage/WebDatabaseManager.mm.
500         (setTransactionBackgroundTaskIdentifier): Ditto.
501         (getTransactionBackgroundTaskIdentifier): Ditto.
502         (+[WebDatabaseTransactionBackgroundTaskController startBackgroundTask]): Ditto.
503         (+[WebDatabaseTransactionBackgroundTaskController endBackgroundTask]): Ditto.
504
505 2017-02-01  Zan Dobersek  <zdobersek@igalia.com>
506
507         [EME] Implement MediaKeySession::update()
508         https://bugs.webkit.org/show_bug.cgi?id=167636
509
510         Reviewed by Xabier Rodriguez-Calvar.
511
512         Implement the MediaKeySession::update() method by following the steps as
513         they are described in the specification.
514
515         In order to sanitize the passed-in response data, CDM::sanitizeResponse()
516         is added. It passes the SharedBuffer object by reference to the CDMPrivate
517         interface implementor, which returns a SharedBuffer object containing
518         sanitized response data.
519
520         CDMInstance::updateLicense() virtual method is added to perform the license
521         update for some specific CDMInstance object. After the update the CDMInstance
522         invokes the callback that's passed to updateLicense(), providing information
523         about session being closed, changed keys or expiration value, any message
524         that has to be enqueued, and whether the update was successful.
525
526         After that callback is invoked, MediaKeySession::update() goes on to handle
527         all the provided information in a future task, finally resolving the promise
528         (or rejecting it beforehand in case of any failure during response handling
529         or license update).
530
531         Three algorithms that can be invoked from MediaKeySession::update() (key
532         status update, expiration update and session closure) will be implemented
533         separately. Placeholder methods are provided until then.
534
535         MockCDM::sanitizeResponse() and MockCDMInstance::updateLicense() are
536         implemented for testing purposes. For now only the response sanitization
537         and sanitized response format are checked there. Key status update,
538         expiration update and session closure should be tested once the
539         implementations for those algorithms are added.
540
541         Test: media/encrypted-media/mock-MediaKeySession-update.html
542
543         * Modules/encryptedmedia/CDM.cpp:
544         (WebCore::CDM::sanitizeResponse):
545         * Modules/encryptedmedia/CDM.h:
546         * Modules/encryptedmedia/CDMInstance.h:
547         * Modules/encryptedmedia/CDMPrivate.h:
548         * Modules/encryptedmedia/MediaKeySession.cpp:
549         (WebCore::MediaKeySession::update):
550         (WebCore::MediaKeySession::updateKeyStatuses):
551         (WebCore::MediaKeySession::updateExpiration):
552         (WebCore::MediaKeySession::sessionClosed):
553         * Modules/encryptedmedia/MediaKeySession.h:
554         * testing/MockCDMFactory.cpp:
555         (WebCore::MockCDM::sanitizeResponse):
556         (WebCore::MockCDMInstance::updateLicense):
557         * testing/MockCDMFactory.h:
558
559 2017-02-01  Eric Carlson  <eric.carlson@apple.com>
560
561         [Mac] Update CARingBuffer class
562         https://bugs.webkit.org/show_bug.cgi?id=167656
563         <rdar://problem/30318329>
564
565         Unreviewed fix the 32-bit build after r211539.
566
567         * platform/audio/mac/CAAudioStreamDescription.cpp:
568         (WebCore::CAAudioStreamDescription::CAAudioStreamDescription):
569
570 2017-02-01  Simon Fraser  <simon.fraser@apple.com>
571
572         [iOS WK2] With visual viewports, a fixed bottom bar can be clipped out when the keyboard is visible
573         https://bugs.webkit.org/show_bug.cgi?id=167710
574         rdar://problem/30100286
575
576         Reviewed by Wenson Hsieh.
577         
578         Add a bit of logging to show when RLC decides to not composite a fixed element which
579         is out of bounds.
580
581         Test: fast/visual-viewport/ios/bottom-bar-with-keyboard.html
582
583         * rendering/RenderLayerCompositor.cpp:
584         (WebCore::RenderLayerCompositor::requiresCompositingForPosition):
585
586 2017-02-01  Eric Carlson  <eric.carlson@apple.com>
587
588         [Mac] Update CARingBuffer class
589         https://bugs.webkit.org/show_bug.cgi?id=167656
590
591         Unreviewed build fix after r211539.
592
593         * platform/audio/mac/CAAudioStreamDescription.cpp:
594         (WebCore::CAAudioStreamDescription::CAAudioStreamDescription): Initialize a variable to fix
595         release builds.
596
597 2017-02-01  Eric Carlson  <eric.carlson@apple.com>
598
599         [Mac] Update CARingBuffer class
600         https://bugs.webkit.org/show_bug.cgi?id=167656
601
602         Reviewed by Jer Noble.
603
604         API test CARingBufferTest added.
605
606         * WebCore.xcodeproj/project.pbxproj: Add headers to framework so they can be used from the API test.
607
608         * platform/audio/AudioStreamDescription.h: Add Int32.
609
610         * platform/audio/mac/CAAudioStreamDescription.cpp:
611         (WebCore::CAAudioStreamDescription::CAAudioStreamDescription):
612         (WebCore::CAAudioStreamDescription::~CAAudioStreamDescription):
613         (WebCore::CAAudioStreamDescription::format): Support Int32.
614         (WebCore::CAAudioStreamDescription::operator==): Make inline.
615         * platform/audio/mac/CAAudioStreamDescription.h:
616
617         * platform/audio/mac/CARingBuffer.cpp:
618         (WebCore::CARingBuffer::CARingBuffer): Move initializers into class declaration.
619         (WebCore::CARingBuffer::allocate): Use flush method, get allocation info from a CAAudioStreamDescription.
620         (WebCore::FetchABL): Add a mode parameter to allow samples to replace or mix into destination.
621         (WebCore::CARingBuffer::flush): New.
622         (WebCore::CARingBuffer::fetch): Add mode parameter.
623         (WebCore::CARingBuffer::~CARingBuffer): Deleted.
624         * platform/audio/mac/CARingBuffer.h:
625         (WebCore::CARingBuffer::~CARingBuffer):
626
627         * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
628         (WebCore::AudioSourceProviderAVFObjC::prepare): Use new CARingBuffer constructor.
629         (WebCore::operator==): Deleted.
630         (WebCore::operator!=): Deleted.
631
632         * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm:
633         (WebCore::WebAudioSourceProviderAVFObjC::prepare): Use new CARingBuffer constructor
634         (WebCore::operator==): Deleted.
635         (WebCore::operator!=): Deleted.
636
637 2017-02-01  Zalan Bujtas  <zalan@apple.com>
638
639         Simple line layout: Move TextFragmentIterator::runWidth to ::textWidth.
640         https://bugs.webkit.org/show_bug.cgi?id=167705
641         <rdar://problem/30314393>
642
643         Reviewed by Antti Koivisto.
644
645         We also don't need to compute logicalHeight for logicalLeft/right since the
646         cases where it matters (floating boxes) are not supported by simple line layout. 
647
648         Covered by existing test.
649
650         * rendering/SimpleLineLayout.cpp:
651         (WebCore::SimpleLineLayout::updateLineConstrains):
652         * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
653         (WebCore::SimpleLineLayout::nextBreakablePositionInSegment):
654         (WebCore::SimpleLineLayout::TextFragmentIterator::textWidth):
655         (WebCore::SimpleLineLayout::TextFragmentIterator::runWidth): Deleted.
656         * rendering/SimpleLineLayoutTextFragmentIterator.h:
657
658 2017-02-01  Jer Noble  <jer.noble@apple.com>
659
660         Fix compilation error under recent clang update
661         https://bugs.webkit.org/show_bug.cgi?id=167707
662
663         Reviewed by Eric Carlson.
664
665         Include TypedArrayInlines.h to fix a "missing symbol" link error when compiling under a recent clang update.
666
667         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
668
669 2017-02-01  Joseph Pecoraro  <pecoraro@apple.com>
670
671         Performance Timeline: Prepare for Worker support
672         https://bugs.webkit.org/show_bug.cgi?id=167633
673
674         Reviewed by Ryosuke Niwa.
675
676         Remove references to Document/Frame in Performance. Instead use
677         ScriptExecutionContext and pass in the time origin / SecurityOrigin
678         where it is relevant. No tests should change this is just refactoring.
679
680         * loader/ResourceTimingInformation.cpp:
681         (WebCore::ResourceTimingInformation::addResourceTiming):
682         * page/DOMWindow.cpp:
683         (WebCore::DOMWindow::performance):
684         * page/Performance.cpp:
685         (WebCore::Performance::Performance):
686         (WebCore::Performance::now):
687         (WebCore::Performance::reduceTimeResolution):
688         (WebCore::Performance::navigation):
689         (WebCore::Performance::timing):
690         (WebCore::Performance::addResourceTiming):
691         (WebCore::Performance::scriptExecutionContext): Deleted.
692         * page/Performance.h:
693         * page/Performance.idl:
694         * page/PerformanceResourceTiming.cpp:
695         (WebCore::monotonicTimeToDOMHighResTimeStamp):
696         (WebCore::passesTimingAllowCheck):
697         (WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
698         (WebCore::PerformanceResourceTiming::redirectStart):
699         (WebCore::PerformanceResourceTiming::redirectEnd):
700         (WebCore::PerformanceResourceTiming::fetchStart):
701         (WebCore::PerformanceResourceTiming::domainLookupStart):
702         (WebCore::PerformanceResourceTiming::domainLookupEnd):
703         (WebCore::PerformanceResourceTiming::connectStart):
704         (WebCore::PerformanceResourceTiming::connectEnd):
705         (WebCore::PerformanceResourceTiming::secureConnectionStart):
706         (WebCore::PerformanceResourceTiming::requestStart):
707         (WebCore::PerformanceResourceTiming::responseStart):
708         (WebCore::PerformanceResourceTiming::responseEnd):
709         (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp):
710         (WebCore::monotonicTimeToDocumentMilliseconds): Deleted.
711         (WebCore::PerformanceResourceTiming::initiatorType): Deleted.
712         (WebCore::PerformanceResourceTiming::resourceTimeToDocumentMilliseconds): Deleted.
713         * page/PerformanceResourceTiming.h:
714         * page/PerformanceUserTiming.cpp:
715         (WebCore::UserTiming::findExistingMarkStartTime):
716
717 2017-02-01  Chris Dumez  <cdumez@apple.com>
718
719         REGRESSION(r205136): {}.toString.call(crossOriginWindow) should not throw
720         https://bugs.webkit.org/show_bug.cgi?id=167681
721         <rdar://problem/30301117>
722
723         Reviewed by Mark Lam.
724
725         As per https://html.spec.whatwg.org/#crossorigingetownpropertyhelper-(-o,-p-):
726         """
727         If P is @@toStringTag, @@hasInstance, or @@isConcatSpreadable, then return
728         PropertyDescriptor{ [[Value]]: undefined, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
729         """
730
731         We now implement this behavior instead of throwing.
732
733         Test: http/tests/security/symbols-cross-origin.html
734
735         * bindings/js/JSDOMWindowCustom.cpp:
736         (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
737         * bindings/js/JSLocationCustom.cpp:
738         (WebCore::JSLocation::getOwnPropertySlotDelegate):
739
740 2017-02-01  Brent Fulgham  <bfulgham@apple.com>
741
742         Correct "filesHaveSameVolume" predicate
743         https://bugs.webkit.org/show_bug.cgi?id=167696
744         <rdar://problem/30298722>
745
746         Reviewed by David Kilzer.
747
748         We are passing %-encoded strings to the underlying operating system's file system APIs.
749         This doesn't work. Instead, we need to present a decoded version of the file path
750         that matches what the system APIs expect.
751
752         Tested by new TestWebKitAPI Test.
753
754         * platform/FileSystem.cpp:
755         (WebCore::filesHaveSameVolume): Make sure the file paths we give to the underlying
756         operating system are not percent encoded.
757         * platform/FileSystem.h: Export 'filesHaveSameVolume' for use by testing system.
758
759 2017-02-01  Antoine Quint  <graouts@apple.com>
760
761         [mac-wk1] LayoutTest media/modern-media-controls/tracks-support/tracks-support-click-track-in-panel.html is a flaky timeout
762         https://bugs.webkit.org/show_bug.cgi?id=165319
763         <rdar://problem/30284104>
764
765         Reviewed by Dean Jackson.
766
767         Running media/controls/track-menu.html before media/modern-media-controls/tracks-support/tracks-
768         support-click-track-in-panel.html makes that test time out in all test runs. The root of the issue
769         is that animations are suspended by media/controls/track-menu.html with a call to
770         internals.suspendAnimations(), and that state isn't reset with a call to internals.resumeAnimations().
771         Then, media/modern-media-controls/tracks-support/tracks-support-click-track-in-panel.html fails because
772         the selection animation for the tracks panel menu item that is clicked never completes and the delegate
773         to notify that an item in the tracks panel was selected is never fired, which leads to the test failure.
774
775         We change Internals::suspendAnimations() and Internals::resumeAnimations() to only affect the current
776         document, rather than calling into AnimationController::suspendAnimations() which would do just that,
777         but also set a Frame-wide flag that would prevent further animations from running, even in a subsequent
778         document load.
779
780         * dom/Document.cpp:
781         (WebCore::Document::prepareForDestruction): Ensure the document that is about to be destroyed is no longer
782         associated with an AnimationController.
783         * page/animation/AnimationController.cpp:
784         (WebCore::AnimationControllerPrivate::ensureCompositeAnimation): Update the animation's suspend state in case
785         the document its renderer is associated with is suspended. This is required since previously CompositeAnimations
786         would set their suspend state in their constructor, based on the Frame-wide suspended state, but there is no
787         document to use as a basis to query its suspended state in that constructor.
788         (WebCore::AnimationControllerPrivate::animationsAreSuspendedForDocument):
789         (WebCore::AnimationControllerPrivate::detachFromDocument):
790         (WebCore::AnimationControllerPrivate::suspendAnimationsForDocument):
791         (WebCore::AnimationControllerPrivate::resumeAnimationsForDocument):
792         (WebCore::AnimationControllerPrivate::startAnimationsIfNotSuspended):
793         (WebCore::AnimationController::animationsAreSuspendedForDocument):
794         (WebCore::AnimationController::detachFromDocument):
795         * page/animation/AnimationController.h:
796         * page/animation/AnimationControllerPrivate.h:
797         * testing/Internals.cpp:
798         (WebCore::Internals::animationsAreSuspended):
799         (WebCore::Internals::suspendAnimations):
800         (WebCore::Internals::resumeAnimations):
801
802 2017-02-01  Ryan Haddad  <ryanhaddad@apple.com>
803
804         Unreviewed build fix after r211488.
805
806         * accessibility/AXObjectCache.h: Removed property svn:executable.
807
808 2017-02-01  Brent Fulgham  <bfulgham@apple.com>
809
810         Unreviewed build fix.
811
812         * html/HTMLMediaElement.h: Removed property svn:executable.
813
814 2017-02-01  Jer Noble  <jer.noble@apple.com>
815
816         NULL-deref crash in TextTrack::removeCue()
817         https://bugs.webkit.org/show_bug.cgi?id=167615
818
819         Reviewed by Eric Carlson.
820
821         Test: http/tests/media/track-in-band-hls-metadata-crash.html
822
823         Follow-up to r211401. When passing around a reference to an object, the assumption is that
824         the caller is retaining the underlying object. This breaks down for
825         InbandDataTextTrack::removeDataCue(), which releases its own ownership of the cue object,
826         then passes the reference to that object to its superclass to do further remove steps. The
827         retain count of the cue can thus drop to zero within the scope of
828         InbandTextTrack::removeCue(). Use "take" semantics to remove the cue from the
829         m_incompleteCueMap without releasing ownership, and pass a reference to that retained object
830         on to removeCue(), guaranteeing that the cue will not be destroyed until after the
831         romeveDataCue() method returns.
832
833         * html/track/InbandDataTextTrack.cpp:
834         (WebCore::InbandDataTextTrack::removeDataCue):
835
836 2017-02-01  Nan Wang  <n_wang@apple.com>
837
838         AX: Incorrect range from index and length in text controls when there are newlines
839         https://bugs.webkit.org/show_bug.cgi?id=167677
840         <rdar://problem/30300099>
841
842         Reviewed by Chris Fleizach.
843
844         When there are newlines in text controls, the VisiblePosition that is created
845         from the index could be wrong. Because the index doesn't include the information 
846         regarding a position's affinity. Fixed it by using CharacterOffset instead, since
847         it doesn't require that information.
848
849         Test: accessibility/mac/range-for-contenteditable-newline.html
850
851         * accessibility/AXObjectCache.cpp:
852         (WebCore::AXObjectCache::traverseToOffsetInRange):
853         (WebCore::AXObjectCache::nextCharacterOffset):
854         (WebCore::AXObjectCache::characterOffsetForIndex):
855
856 2017-02-01  Timothy Hatcher  <timothy@hatcher.name>
857
858         AXObjectCache is missing two functions at link time when !HAVE(ACCESSIBILITY)
859         https://bugs.webkit.org/show_bug.cgi?id=167691
860
861         Reviewed by Chris Fleizach.
862
863         * accessibility/AXObjectCache.h:
864         (WebCore::AXObjectCache::recomputeDeferredIsIgnored): Added empty stub.
865         (WebCore::AXObjectCache::performDeferredIsIgnoredChange): Added empty stub.
866
867 2017-02-01  Timothy Hatcher  <timothy@hatcher.name>
868
869         HTMLMediaElement.h fails to build when ENABLE(MEDIA_CONTROLS_SCRIPT) is false
870         https://bugs.webkit.org/show_bug.cgi?id=167689
871
872         Reviewed by Joseph Pecoraro.
873
874         * html/HTMLMediaElement.h: Move mediaControlsHost() into the ENABLE(MEDIA_CONTROLS_SCRIPT)
875         block that is just above it to match m_mediaControlsHost.
876
877 2017-02-01  Romain Bellessort  <romain.bellessort@crf.canon.fr>
878
879         [Readable Streams API] Implement ReadableByteStreamController pull()
880         https://bugs.webkit.org/show_bug.cgi?id=167593
881
882         Reviewed by Youenn Fablet.
883
884         Implemented pull() method for ReadableByteStreamController. Also updated
885         pendingPullIntos attribute, which was a more complex object than necessary
886         (an array is enough).
887
888         Added 2 tests that allow covering most of new code. Code not yet tested will
889         become reachable as the rest of the spec is implemented (new tests will then
890         be added).
891
892         * Modules/streams/ReadableByteStreamInternals.js:
893         (privateInitializeReadableByteStreamController): Updated pendingPullIntos.
894         (readableByteStreamControllerCancel): Updated pendingPullIntos.
895         (readableByteStreamControllerClose): Updated pendingPullIntos.
896         (readableByteStreamControllerHandleQueueDrain): Added.
897         (readableByteStreamControllerPull): Added.
898
899 2017-02-01  Enrique Ocaña González  <eocanha@igalia.com>
900
901         [GStreamer][MSE] qtdemux: Update the tfdt patch to the version finally accepted upstream
902         https://bugs.webkit.org/show_bug.cgi?id=166529
903
904         Reviewed by Xabier Rodriguez-Calvar.
905
906         * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
907         (WebCore::AppendPipeline::AppendPipeline): Don't use the "always-honor-tfdt" property
908         in qtdemux anymore.
909
910 2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
911
912         Unreviewed, build fix for macOS and iOS ports, part 2
913
914         Annotate the function with static.
915
916         * bindings/js/ScriptModuleLoader.cpp:
917         (WebCore::rejectToPropagateNetworkError):
918
919 2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
920
921         Unreviewed, build fix for macOS and iOS ports
922
923         * bindings/js/ModuleFetchFailureKind.h: Renamed from Source/ModuleFetchFailureKind.h.
924
925 2017-02-01  Yusuke Suzuki  <utatane.tea@gmail.com>
926
927         Propagate networking errors correctly for import() operator
928         https://bugs.webkit.org/show_bug.cgi?id=167501
929
930         Reviewed by Ryosuke Niwa.
931
932         We use the promise chain inside the module loader pipeline.
933         The problem is that,
934
935         1. The errors of loading module scripts are propagated through the promise's rejection.
936         2. Some module related errors like syntax error (when scanning module dependencies) are
937            reported at loading time (evaluating time). These errors are propagated through the
938            promise rejections and dumped to the console. LoadableModuleScript set catch handler
939            for that and print these errors to the console for ScriptElement.
940         3. Some of errors are already reported to the console. For example, networking errors
941            are reported by the CachedModuleLoader.
942         4. But there is no way to distinguish between (2) and (3) at the catch handler.
943
944         Previously, we propagate the special symbol for the already reported errors to distinguish
945         that. This was OK because these errors cannot be catched by the user code. However,
946         recent `import()` call needs to expose these errors to the user code. So now, accidentally,
947         the special purpose symbol is exposed.
948
949         Instead of propagating the special symbol, this patch just propagates the errors. But these
950         error objects are annotated with the private symbol. So these errors can be distinguished
951         from the other ones.
952
953         Currently, we do not have the way to expose the error details to the client of the
954         CachedScript. So we just report the error with the failed / canceled. This should be
955         more descriptive error messages in the separate patch[1].
956
957         [1]: https://bugs.webkit.org/show_bug.cgi?id=167553
958
959         Tests: http/tests/security/mixedContent/import-insecure-script-in-iframe.html
960                js/dom/modules/import-not-found-error.html
961
962         * WebCore.xcodeproj/project.pbxproj:
963         * bindings/js/JSDOMPromise.h:
964         (WebCore::DeferredPromise::resolveWithCallback):
965         (WebCore::DeferredPromise::rejectWithCallback):
966         * bindings/js/ScriptController.cpp:
967         (WebCore::ScriptController::setupModuleScriptHandlers):
968         * bindings/js/ScriptController.h:
969         (WebCore::ScriptController::moduleLoaderAlreadyReportedErrorSymbol): Deleted.
970         (WebCore::ScriptController::moduleLoaderFetchingIsCanceledSymbol): Deleted.
971         * bindings/js/ScriptModuleLoader.cpp:
972         (WebCore::rejectToPropagateNetworkError):
973         (WebCore::ScriptModuleLoader::fetch):
974         (WebCore::ScriptModuleLoader::notifyFinished):
975         * bindings/js/WebCoreBuiltinNames.h:
976
977 2017-01-31  Wenson Hsieh  <wenson_hsieh@apple.com>
978
979         Regression (Safari 10.1): Pressing Return in a contenteditable no longer inserts a line break under certain conditions
980         https://bugs.webkit.org/show_bug.cgi?id=167525
981         <rdar://problem/30270210>
982
983         Reviewed by Ryosuke Niwa.
984
985         Test: fast/events/input-events-insert-newlines-after-mutation.html
986
987         Reverts an unintended change made while refactoring code for input events that caused input events to be
988         dispatched immediately rather than on the scoped queue. Normally, input events are dispatched in
989         CompositeEditCommand::apply after the end of the scope, but TypingCommands may fire input events *from within*
990         the scope by calling typingAddedToOpenCommand.
991
992         Instead, TypingCommands should always dispatch events
993         synchronously after the end of the scoped queue in CompositeEditCommand::apply, but this is a riskier change
994         than we should currently allow, so we should revert to our old behavior for the time being.
995
996         * editing/Editor.cpp:
997
998 2017-01-31  Zalan Bujtas  <zalan@apple.com>
999
1000         Simple line layout: Do not assert on zero length/width trailing whitespace.
1001         https://bugs.webkit.org/show_bug.cgi?id=167679
1002
1003         Reviewed by Simon Fraser.
1004
1005         It's valid to have an zero length/width trailing whitespace.
1006
1007         Covered by existing tests.
1008
1009         * rendering/SimpleLineLayout.cpp:
1010         (WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace): Zero length -> nothing to do.
1011         Zero width with length > 0 (font-size: 0) -> remove trailing run.
1012
1013 2017-01-31  Alex Christensen  <achristensen@webkit.org>
1014
1015         Fix debug libwebrtc build after r211439
1016         https://bugs.webkit.org/show_bug.cgi?id=167572
1017
1018         * platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp:
1019         (WebCore::LibWebRTCAudioModule::OnMessage):
1020
1021 2017-01-31  Zalan Bujtas  <zalan@apple.com>
1022
1023         Simple line layout: Collect fragments in LineState only when needed for post-processing.
1024         https://bugs.webkit.org/show_bug.cgi?id=167655
1025         <rdar://problem/30290592>
1026
1027         Reviewed by Antti Koivisto.
1028
1029         The fragments we need to keep around for basic line breaking are the last and last non-whitespace fragments.
1030         However in certain cases such as text-align: justify, we have to traverse the entire line
1031         at post-processing which requires all the fragments on the current line.
1032         This patch speeds up the basic line handling by using m_fragment list only for the special cases.
1033         It improves PerformanceTests/Layout/simple-line-layout-non-repeating-text.html by ~7% (local measurement)
1034         median: 114.25 runs/s -> median: 122.16 runs
1035
1036         Covered by existing tests.
1037
1038         * rendering/SimpleLineLayout.cpp:
1039         (WebCore::SimpleLineLayout::LineState::setNeedsAllFragments):
1040         (WebCore::SimpleLineLayout::LineState::hasTrailingWhitespace):
1041         (WebCore::SimpleLineLayout::LineState::lastFragment):
1042         (WebCore::SimpleLineLayout::LineState::expansionOpportunityCount):
1043         (WebCore::SimpleLineLayout::LineState::isEmpty):
1044         (WebCore::SimpleLineLayout::LineState::endPositionForCollapsedFragment):
1045         (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded): Track uncompleted width.
1046         (WebCore::SimpleLineLayout::LineState::revertToLastCompleteFragment):
1047         (WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace):
1048         (WebCore::SimpleLineLayout::removeTrailingWhitespace):
1049         (WebCore::SimpleLineLayout::updateLineConstrains): Set the slow path for text-align: justify.
1050         (WebCore::SimpleLineLayout::createLineRuns):
1051         (WebCore::SimpleLineLayout::closeLineEndingAndAdjustRuns):
1052         (WebCore::SimpleLineLayout::createTextRuns):
1053         * rendering/SimpleLineLayoutTextFragmentIterator.h:
1054         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isValid):
1055         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::length):
1056
1057 2017-01-31  Chris Dumez  <cdumez@apple.com>
1058
1059         com.apple.WebKit.WebContent.Development crashed in com.apple.WebCore: WebCore::FrameView::didDestroyRenderTree
1060         https://bugs.webkit.org/show_bug.cgi?id=167665
1061         <rdar://problem/30241193>
1062
1063         Reviewed by Andreas Kling.
1064
1065         When destroying a PageCache entry, we would call Document::prepareFromDestruction()
1066         which would destroy the render tree and then call FrameView::didDestroyRenderTree().
1067         We would sometimes hit the ASSERT(m_widgetsInRenderTree.isEmpty()) assertion in
1068         didDestroyRenderTree(). This indicates that there are still RenderWidgets associated
1069         with the FrameView even though we claim we already destroyed the render tree.
1070
1071         The reason for this is that, in the PageCache context, the top document's frame is
1072         reused on navigation and may not be associated with a new document that is currently
1073         displayed, has a render tree (and possible RenderWidgets). The solution proposed is
1074         to stop calling FrameView::didDestroyRenderTree() in Document::prepareFromDestruction()
1075         if the frame's document is not |this|. This happens when the document is destroyed
1076         while in PageCache. We do not want to mess with the frame / frameview in this case
1077         since they are no longer associated to the present document anymore.
1078
1079         No new tests, already covered by existing tests which currently crash flakily.
1080
1081         * dom/Document.cpp:
1082         (WebCore::Document::destroyRenderTree):
1083
1084 2017-01-31  Sam Weinig  <sam@webkit.org>
1085
1086         Remove unused/rarely used bindings helpers
1087         https://bugs.webkit.org/show_bug.cgi?id=167648
1088
1089         Reviewed by Anders Carlsson.
1090
1091         * bindings/js/JSDOMBinding.cpp:
1092         * bindings/js/JSDOMBinding.h:
1093         (WebCore::jsString): Deleted.
1094         (WebCore::jsStringOrUndefined): Deleted.
1095         (WebCore::finiteInt32Value): Deleted.
1096         (WebCore::toJS): Deleted.
1097         Remove unused functions. The toJS overrides can be replaced with their
1098         modern JSDOMConvert counterparts.
1099         
1100         * bindings/js/JSDOMExceptionHandling.h:
1101         (WebCore::toJS): Deleted.
1102         (WebCore::toJSNewlyCreated): Deleted.
1103         Remove unused functions.
1104
1105         * bindings/js/JSDOMIterator.h:
1106         Add more specific include of JSDOMConvert.h to fix compile.
1107
1108         * bindings/js/JSDOMPromise.cpp:
1109         (WebCore::DeferredPromise::reject):
1110         Create the Symbol directly, instead of using the toJS override.
1111
1112         * bindings/js/JSWorkerCustom.cpp:
1113         (WebCore::constructJSWorker):
1114         Use JSDOMConvert toJS function.
1115
1116         * bindings/js/JSXMLHttpRequestCustom.cpp:
1117         (WebCore::JSXMLHttpRequest::retrieveResponse):
1118         Use JSDOMConvert toJS functions.
1119
1120         * bindings/js/ScriptController.h:
1121         Add missing forward declaration of URL.
1122
1123         * bindings/js/ScriptModuleLoader.cpp:
1124         (WebCore::ScriptModuleLoader::resolve):
1125         Create the Symbol directly, instead of using the toJS override.
1126
1127         * html/HTMLPlugInImageElement.cpp:
1128         (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):
1129         Use JSDOMConvert toJS functions.
1130
1131 2017-01-31  Wenson Hsieh  <wenson_hsieh@apple.com>
1132
1133         WebItemProviderPasteboard should be robust when UIItemProvider fails to initialize an object
1134         https://bugs.webkit.org/show_bug.cgi?id=167663
1135         <rdar://problem/30294240>
1136
1137         Reviewed by Tim Horton.
1138
1139         Adds a nil check for the result of -createObjectOfClass:error:.
1140
1141         * platform/ios/WebItemProviderPasteboard.mm:
1142         (-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):
1143         (-[WebItemProviderPasteboard _tryToCreateAndAppendObjectOfClass:toArray:usingProvider:]):
1144
1145 2017-01-31  Keith Rollin  <krollin@apple.com>
1146
1147         Variable used after it's been WTFMove'd
1148         https://bugs.webkit.org/show_bug.cgi?id=167658
1149
1150         Reviewed by Chris Dumez.
1151
1152         Rather than WTFMoving the variable as part of passing it to a function
1153         that takes an RValue-ref, call copyRef to provide the RValue-ref. This
1154         preserves the original variable for later use in the function.
1155
1156         No new tests -- this issue was found by inspection. It's not apparent
1157         what the side-effect of this bug is or how a test would verify it.
1158
1159         * loader/SubresourceLoader.cpp:
1160         (WebCore::SubresourceLoader::didReceiveDataOrBuffer):
1161
1162 2017-01-31  Anders Carlsson  <andersca@apple.com>
1163
1164         Apple Pay button does nothing on nytimes.com
1165         https://bugs.webkit.org/show_bug.cgi?id=167664
1166         rdar://problem/30273885
1167
1168         Reviewed by Sam Weinig.
1169
1170         Separate line item validation into convertAndValidateTotal and convertAndValidate. The former
1171         works on totals (which require an amount), and the latter works on regular line items that do not require an amount
1172         if the item type is "pending".
1173
1174         * Modules/applepay/ApplePaySession.cpp:
1175         (WebCore::convertAndValidateTotal):
1176         (WebCore::convertAndValidate):
1177         Only check the amount if the type is not pending.
1178
1179         (WebCore::ApplePaySession::completeShippingMethodSelection):
1180         (WebCore::ApplePaySession::completeShippingContactSelection):
1181         (WebCore::ApplePaySession::completePaymentMethodSelection):
1182         Call convertAndValidateTotal for totals.
1183
1184 2017-01-31  Youenn Fablet  <youenn@apple.com>
1185
1186         [WebRTC] Add a libwebrtc AudioModule specific to WebKit
1187         https://bugs.webkit.org/show_bug.cgi?id=167572
1188
1189         Reviewed by Alex Christensen.
1190
1191         To be covered by webrtc audio tests.
1192         Adding an AudioModule to circumvent the default LibWebRTC Audio Module which does the audio directly.
1193         The implementation of the AudioModule is restricted to enable fueling the incoming audio tracks with incoming data.
1194         Code inspired from https://chromium.googlesource.com/chromium/src/+/master/remoting/protocol/webrtc_audio_module.h
1195
1196         * WebCore.xcodeproj/project.pbxproj:
1197         * platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp: Added.
1198         (WebCore::LibWebRTCAudioModule::LibWebRTCAudioModule):
1199         (WebCore::LibWebRTCAudioModule::RegisterAudioCallback):
1200         (WebCore::LibWebRTCAudioModule::OnMessage):
1201         (WebCore::LibWebRTCAudioModule::StartPlayout):
1202         (WebCore::LibWebRTCAudioModule::StopPlayout):
1203         (WebCore::LibWebRTCAudioModule::StartPlayoutOnAudioThread):
1204         (WebCore::LibWebRTCAudioModule::PollFromSource):
1205         * platform/mediastream/libwebrtc/LibWebRTCAudioModule.h: Added.
1206         * platform/mediastream/libwebrtc/LibWebRTCUtils.cpp:
1207         (WebCore::ThreadMessageData::ThreadMessageData):
1208         (WebCore::initializePeerConnectionFactoryAndThreads):
1209
1210 2017-01-31  Jessie Berlin  <jberlin@webkit.org>
1211
1212         Build fix.
1213
1214         * editing/mac/EditorMac.mm:
1215         (WebCore::Editor::pasteWithPasteboard):
1216         (WebCore::Editor::takeFindStringFromSelection):
1217         (WebCore::Editor::replaceNodeFromPasteboard):
1218         * page/mac/EventHandlerMac.mm:
1219         (WebCore::EventHandler::createDraggingDataTransfer):
1220         * platform/mac/PasteboardMac.mm:
1221         (WebCore::Pasteboard::createForCopyAndPaste):
1222         (WebCore::Pasteboard::createForDragAndDrop):
1223
1224 2017-01-31  Eric Carlson  <eric.carlson@apple.com>
1225
1226         [Mac] Add an audio stream description class
1227         https://bugs.webkit.org/show_bug.cgi?id=167639
1228
1229         Reviewed by Youenn Fablet.
1230
1231         No new tests, the new class is not used yet.
1232
1233         * WebCore.xcodeproj/project.pbxproj:
1234         * platform/audio/AudioStreamDescription.h: Added.
1235         (WebCore::AudioStreamDescription::isPCM):
1236         * platform/audio/mac/CAAudioStreamDescription.cpp: Added.
1237         (WebCore::CAAudioStreamDescription::CAAudioStreamDescription):
1238         (WebCore::CAAudioStreamDescription::platformDescription):
1239         (WebCore::CAAudioStreamDescription::format):
1240         (WebCore::toCAAudioStreamDescription):
1241         (WebCore::CAAudioStreamDescription::operator==):
1242         (WebCore::operator==):
1243         * platform/audio/mac/CAAudioStreamDescription.h: Added.
1244         (WebCore::operator!=):
1245         (WebCore::CAAudioStreamDescription::bytesPerFrame):
1246         (WebCore::CAAudioStreamDescription::bytesPerPacket):
1247         (WebCore::CAAudioStreamDescription::formatFlags):
1248         (WebCore::CAAudioStreamDescription::operator==):
1249         (WebCore::CAAudioStreamDescription::operator!=):
1250         (WebCore::CAAudioStreamDescription::streamDescription):
1251
1252 2017-01-31  Youenn Fablet  <youenn@apple.com>
1253
1254         RTCPeerConnection methods can take dictionaries as input
1255         https://bugs.webkit.org/show_bug.cgi?id=167590
1256
1257         Reviewed by Alex Christensen.
1258
1259         Test: webrtc/rtcpeerconnection-error-messages.html
1260
1261         Made addIceCandidate/setRemoteDescription/setLocalDescription take either dictionaries or objects as parameter.
1262         Spec only mandates this for addIceCandidate, but sites may be using the old version for setRemoteDescription and setLocalDescription.
1263
1264         Updated RTCPeerConnection methods error messages.
1265
1266         * Modules/mediastream/RTCPeerConnection.js:
1267         (getLocalStreams):
1268         (getStreamById):
1269         (addStream):
1270         (createOffer):
1271         (createAnswer):
1272         (setLocalDescription):
1273         (setRemoteDescription):
1274         (addIceCandidate):
1275         (getStats):
1276         * Modules/mediastream/RTCPeerConnectionInternals.js:
1277
1278 2017-01-31  Simon Fraser  <simon.fraser@apple.com>
1279
1280         REGRESSION (r209411): Scrolling to a fragment identifier in overflow:scroll inside position:fixed no longer works
1281         https://bugs.webkit.org/show_bug.cgi?id=167630
1282         rdar://problem/30091558
1283
1284         Reviewed by Zalan Bujtas.
1285         
1286         r209411 added special handling for scrolling inside position:fixed, but cut off all scrolling, breaking
1287         overflow:scroll inside position:fixed. Fix by only handling the position:fixed case when we get to 
1288         the root layer, which is where we scroll the document.
1289
1290         Test: fast/overflow/scroll-anchor-in-overflow-in-position-fixed.html
1291
1292         * rendering/RenderLayer.cpp:
1293         (WebCore::RenderLayer::getRectToExpose):
1294
1295 2017-01-31  Zan Dobersek  <zdobersek@igalia.com>
1296
1297         [EME] InitDataRegistry should use base64url encoding and decoding for keyids
1298         https://bugs.webkit.org/show_bug.cgi?id=167592
1299
1300         Reviewed by Jer Noble.
1301
1302         In InitDataRegistry, WTF::base64URLEncode() and WTF::base64URLDecode() should
1303         be used to encode and decode the 'keyids' initialization data format, as
1304         required by the relevant specification.
1305         https://w3c.github.io/encrypted-media/format-registry/initdata/keyids.html#format
1306
1307         Relevant test case was added to media/encrypted-media/mock-MediaKeySession-generateRequest.html.
1308
1309         * Modules/encryptedmedia/InitDataRegistry.cpp:
1310         (WebCore::extractKeyIDsKeyids):
1311         (WebCore::sanitizeKeyids):
1312
1313 2017-01-31  Joseph Pecoraro  <pecoraro@apple.com>
1314
1315         Performance Timeline: Add serializer to PerformanceEntry
1316         https://bugs.webkit.org/show_bug.cgi?id=167632
1317
1318         Reviewed by Ryosuke Niwa.
1319
1320         Test: performance-api/performance-timeline-serializers.html
1321
1322         * page/PerformanceEntry.idl:
1323
1324 2017-01-31  Chris Fleizach  <cfleizach@apple.com>
1325
1326         AX: enable search predication for iOS
1327         https://bugs.webkit.org/show_bug.cgi?id=167558
1328         <rdar://problem/30251367>
1329
1330         Reviewed by Joanmarie Diggs.
1331
1332         Move the code to support accessibility searching into a shared place so it can be used by iOS.
1333
1334         Test: accessibility/ios-simulator/ios-search-predicate.html
1335
1336         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
1337         (-[WebAccessibilityObjectWrapper accessibilityFindMatchingObjects:]):
1338         * accessibility/mac/WebAccessibilityObjectWrapperBase.h:
1339         * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
1340         (convertToNSArray):
1341         (createAccessibilitySearchKeyMap):
1342         (accessibilitySearchKeyForString):
1343         (accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute):
1344         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
1345         (createAccessibilitySearchKeyMap): Deleted.
1346         (accessibilitySearchKeyForString): Deleted.
1347         (accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute): Deleted.
1348         (convertToNSArray): Deleted.
1349
1350 2017-01-30  Joseph Pecoraro  <pecoraro@apple.com>
1351
1352         [WebIDL] Add support for inherit serializer attribute
1353         https://bugs.webkit.org/show_bug.cgi?id=167274
1354
1355         Reviewed by Darin Adler.
1356
1357         Support for serializer { inherit }, which will be used by Resource Timing.
1358         https://heycam.github.io/webidl/#idl-serializers
1359
1360         * bindings/scripts/CodeGenerator.pm:
1361         (GetInterfaceForAttribute):
1362         (IsSerializableAttribute):
1363         Determine if an attribute is serializable at generation time so we can
1364         verify types. This allows us to support typedefs. We don't yet support
1365         serializing an attribute that is itself a serializable interface.
1366
1367         * bindings/scripts/CodeGeneratorJS.pm:
1368         (GenerateSerializerFunction):
1369         (GenerateSerializerAttributesForInterface):
1370         Generate inherited attributes first, then generate our own list.
1371         Explicitly provided attribute names are expected to be serializable,
1372         so produce an error if they are not.
1373
1374         * bindings/scripts/IDLParser.pm:
1375         (parseSerializationAttributes):
1376         Update parsing of serializer attributes to allow for multiple
1377         special strings. The spec does not precisely define where the
1378         special "attribute" keyword is allowed.
1379
1380         (applyMemberList):
1381         (isSerializableAttribute): Deleted.
1382         Move serializable attribute checking to generation.
1383
1384         * bindings/scripts/test/JS/JSTestSerialization.cpp:
1385         * bindings/scripts/test/JS/JSTestSerializationInherit.cpp: Added.
1386         * bindings/scripts/test/JS/JSTestSerializationInherit.h: Added.
1387         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp: Added.
1388         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.h: Added.
1389         The toJSON implementations are the most interesting.
1390
1391         * bindings/scripts/test/TestSerialization.idl:
1392         Extend this test for typedefed attributes that are serializable.
1393         Change TestNode (a serializable Interface) to TestException (an
1394         unserializable Interface) for expected behavior of an
1395         unserializable attribute.
1396
1397         * bindings/scripts/test/TestSerializationInherit.idl:
1398         Test for { inherit, attribute }.
1399
1400         * bindings/scripts/test/TestSerializationInheritFinal.idl:
1401         Test for { inherit, attribute_names... }, and multi-level inherit.
1402
1403 2017-01-30  Joseph Pecoraro  <pecoraro@apple.com>
1404
1405         Implement PerformanceObserver
1406         https://bugs.webkit.org/show_bug.cgi?id=167546
1407         <rdar://problem/30247959>
1408
1409         Reviewed by Ryosuke Niwa.
1410
1411         This implements PerformanceObserver from Performance Timeline Level 2:
1412         https://w3c.github.io/performance-timeline/
1413
1414         Tests: performance-api/performance-observer-api.html
1415                performance-api/performance-observer-basic.html
1416                performance-api/performance-observer-callback-mutate.html
1417                performance-api/performance-observer-callback-task.html
1418                performance-api/performance-observer-entry-sort.html
1419                performance-api/performance-observer-exception.html
1420                performance-api/performance-observer-nested.html
1421                performance-api/performance-observer-order.html
1422                performance-api/performance-observer-periodic.html
1423                performance-api/performance-timeline-api.html
1424
1425         * CMakeLists.txt:
1426         * DerivedSources.make:
1427         * WebCore.xcodeproj/project.pbxproj:
1428         New files.
1429
1430         * page/Performance.h:
1431         * page/Performance.cpp:
1432         (WebCore::Performance::mark):
1433         (WebCore::Performance::measure):
1434         (WebCore::Performance::registerPerformanceObserver):
1435         (WebCore::Performance::unregisterPerformanceObserver):
1436         (WebCore::Performance::queueEntry):
1437         Register PerformanceObservers with the Performance object.
1438         When new PerformanceEntries are created (Mark and Measure
1439         right now) check them against observers.
1440
1441         * page/PerformanceEntry.cpp:
1442         (WebCore::PerformanceEntry::PerformanceEntry):
1443         (WebCore::PerformanceEntry::typeForEntryTypeString):
1444         * page/PerformanceEntry.h:
1445         (WebCore::PerformanceEntry::type):
1446         Give PerformanceEntry a convenience enum for easy comparison
1447         and to know if it is one of the built-in known types (which the
1448         PerformanceObserver API takes into account).
1449
1450         * page/PerformanceObserver.cpp: Added.
1451         (WebCore::PerformanceObserver::PerformanceObserver):
1452         (WebCore::PerformanceObserver::observe):
1453         (WebCore::PerformanceObserver::disconnect):
1454         (WebCore::PerformanceObserver::queueEntry):
1455         (WebCore::PerformanceObserver::deliver):
1456         * page/PerformanceObserver.h:
1457         (WebCore::PerformanceObserver::create):
1458         (WebCore::PerformanceObserver::typeFilter):
1459         - TypeErrors on observe bad behavior
1460         - Completely replace types filter on observe
1461         - Handle register and unregister
1462         - Handle calling the callback
1463
1464         * page/PerformanceObserverCallback.idl: Added.
1465         * page/PerformanceObserverEntryList.cpp: Added.
1466         (WebCore::PerformanceObserverEntryList::PerformanceObserverEntryList):
1467         (WebCore::PerformanceObserverEntryList::getEntries):
1468         (WebCore::PerformanceObserverEntryList::getEntriesByType):
1469         (WebCore::PerformanceObserverEntryList::getEntriesByName):
1470         * page/PerformanceObserverEntryList.h:
1471         (WebCore::PerformanceObserverEntryList::create):
1472         * page/PerformanceObserverEntryList.idl: Added.
1473         Implement sorting and filtering of entries.
1474
1475         * page/PerformanceObserver.idl: Added.
1476         * page/PerformanceObserverCallback.h:
1477         (WebCore::PerformanceObserverCallback::~PerformanceObserverCallback):
1478         Mostly autogenerated.
1479
1480         * page/PerformanceUserTiming.cpp:
1481         (WebCore::UserTiming::mark):
1482         (WebCore::UserTiming::measure):
1483         * page/PerformanceUserTiming.h:
1484         Update these to return the entry so it can be passed on to
1485         any interested PerformanceObservers.
1486
1487 2017-01-30  Youenn Fablet  <youenn@apple.com>
1488
1489         [WebRTC] getStats does not support legacy callback
1490         https://bugs.webkit.org/show_bug.cgi?id=167617
1491
1492         Reviewed by Alex Christensen.
1493
1494         Covered by updated tests.
1495
1496         * Modules/mediastream/RTCPeerConnection.cpp:
1497         (WebCore::RTCPeerConnection::getStats):
1498         (WebCore::RTCPeerConnection::privateGetStats): Deleted.
1499         * Modules/mediastream/RTCPeerConnection.h:
1500         * Modules/mediastream/RTCPeerConnection.idl:
1501         * Modules/mediastream/RTCPeerConnection.js:
1502         (addIceCandidate):
1503         (getStats): Deleted.
1504
1505 2017-01-30  Sam Weinig  <sam@webkit.org>
1506
1507         JSDOMBinding is too big. Split it up!
1508         https://bugs.webkit.org/show_bug.cgi?id=167601
1509
1510         Reviewed by Darin Adler.
1511
1512         Splits JSDOMBinding.h/cpp up a bit by splitting out:
1513         - JSDOMBindingCaller.h
1514         - JSDOMBindingSecurity.h/cpp
1515         - JSDOMExceptionHandling.h/cpp
1516         - JSDOMWrapperCache.h/cpp
1517
1518         Also:
1519         - Moves all constructor objects to JSDOMConstructor.h/cpp,  
1520         - Moves special DOMWindow accessors to JSDOMWindowBase.
1521         - Deletes unused CallbackFunction.h/cpp
1522
1523         * CMakeLists.txt:
1524         * Modules/webdatabase/Database.cpp:
1525         * WebCore.xcodeproj/project.pbxproj:
1526         * bindings/js/CallbackFunction.cpp: Removed.
1527         * bindings/js/CallbackFunction.h: Removed.
1528         * bindings/js/DOMConstructorWithDocument.h: Removed.
1529         * bindings/js/JSCryptoCustom.cpp:
1530         * bindings/js/JSCustomXPathNSResolver.cpp:
1531         * bindings/js/JSDOMBinding.cpp:
1532         * bindings/js/JSDOMBinding.h:
1533         * bindings/js/JSDOMBindingCaller.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
1534         * bindings/js/JSDOMBindingSecurity.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
1535         * bindings/js/JSDOMBindingSecurity.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
1536         * bindings/js/JSDOMConstructor.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
1537         * bindings/js/JSDOMConstructor.h:
1538         * bindings/js/JSDOMConvert.h:
1539         * bindings/js/JSDOMExceptionHandling.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
1540         * bindings/js/JSDOMExceptionHandling.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
1541         * bindings/js/JSDOMWindowBase.cpp:
1542         (WebCore::callerDOMWindow): Moved from JSDOMBinding.h
1543         (WebCore::activeDOMWindow): Moved from JSDOMBinding.h
1544         (WebCore::firstDOMWindow): Moved from JSDOMBinding.h
1545         * bindings/js/JSDOMWindowBase.h:
1546         * bindings/js/JSDOMWindowCustom.cpp:
1547         * bindings/js/JSDOMWindowProperties.cpp:
1548         * bindings/js/JSDOMWrapperCache.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
1549         * bindings/js/JSDOMWrapperCache.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
1550         * bindings/js/JSEventTargetCustom.h:
1551         * bindings/js/JSHTMLElementCustom.cpp:
1552         * bindings/js/JSLocationCustom.cpp:
1553         * bindings/js/JSMutationObserverCustom.cpp:
1554         * bindings/js/JSSQLStatementErrorCallbackCustom.cpp:
1555         * bindings/js/JSStorageCustom.cpp:
1556         * bindings/js/JSWorkerCustom.cpp:
1557         * bindings/js/JSXPathNSResolverCustom.cpp:
1558         * bindings/js/ScheduledAction.cpp:
1559         * bindings/js/ScriptController.cpp:
1560         * bindings/js/ScriptController.h:
1561         * bindings/js/ScriptGlobalObject.cpp:
1562         (WebCore::ScriptGlobalObject::set):
1563         * bindings/js/StructuredClone.cpp:
1564         * bindings/scripts/CodeGeneratorJS.pm:
1565         (GenerateImplementation):
1566         (GenerateCallWith):
1567         (GenerateParametersCheck):
1568         (GenerateCallbackImplementationContent):
1569         (NativeToJSValue):
1570         * bridge/objc/WebScriptObject.mm:
1571         * html/HTMLFrameElementBase.cpp:
1572         * html/HTMLVideoElement.cpp:
1573         * inspector/InspectorController.cpp:
1574         * inspector/InspectorDOMAgent.cpp:
1575         * inspector/PageScriptDebugServer.cpp:
1576         * inspector/WorkerScriptDebugServer.cpp:
1577
1578 2017-01-30  Andy Estes  <aestes@apple.com>
1579
1580         [QuickLook] FrameLoaderClient should return the new QuickLookHandleClient it creates
1581         https://bugs.webkit.org/show_bug.cgi?id=167625
1582
1583         Reviewed by Andreas Kling.
1584
1585         QuickLookHandleClients were being created by QuickLookHandle calling
1586         FrameLoaderClient::didCreateQuickLookHandle() then having the FrameLoaderClient create a new
1587         QuickLookHandleClient and set it using QuickLookHandle::setClient().
1588
1589         Since all FrameLoaderClient::didCreateQuickLookHandle() does is create a new
1590         QuickLookHandleClient, this patch changes the FrameLoaderClient function to return the new
1591         QuickLookHandleClient directly and removes the API from QuickLookHandle to set a client.
1592         This also removes previewFileName() and previewUTI() from QuickLookHandle and instead passes
1593         these as arguments to the FrameLoaderClient.
1594
1595         No change in behavior. Covered by existing tests.
1596
1597         * loader/EmptyClients.cpp: Added an implementation of createQuickLookHandleClient() that
1598         returns nullptr.
1599         * loader/FrameLoaderClient.h: Declared createQuickLookHandleClient() and removed
1600         didCreateQuickLookHandle().
1601         * loader/ios/QuickLook.h: Removed setClient(), previewFileName(), and previewUTI().
1602         * loader/ios/QuickLook.mm: Removed testingOrEmptyClient().
1603         (-[WebPreviewLoader initWithResourceLoader:resourceResponse:quickLookHandle:]): Set _client
1604         to testingClient() if it exists, otherwise set it to the client returned by
1605         FrameLoaderClient::createQuickLookHandleClient() it non-null, otherwise set it to
1606         emptyClient().
1607         (testingOrEmptyClient): Deleted.
1608         (-[WebPreviewLoader setClient:]): Deleted.
1609         (-[WebPreviewLoader converter]): Deleted.
1610         (WebCore::QuickLookHandle::setClient): Deleted.
1611         (WebCore::QuickLookHandle::previewFileName): Deleted.
1612         (WebCore::QuickLookHandle::previewUTI): Deleted.
1613
1614 2017-01-30  Jer Noble  <jer.noble@apple.com>
1615
1616         NULL-deref crash in TextTrack::removeCue()
1617         https://bugs.webkit.org/show_bug.cgi?id=167615
1618
1619         Reviewed by Eric Carlson.
1620
1621         It's possible for a track to be removed which was never actually added to the cue list.
1622         Specifically, if an in-band track with a negative start or end time was parsed, it would
1623         have been rejected by TextTrack::addCue(). When it comes time to flush those in-band cues,
1624         TextTrack::m_cues will still be NULL. Rather than ASSERT in this case, we should revert the
1625         behavior added in r210319 and throw an exception.
1626
1627         * html/track/TextTrack.cpp:
1628         (WebCore::TextTrack::removeCue):
1629
1630 2017-01-30  Andreas Kling  <akling@apple.com>
1631
1632         Fix CMSampleBuffer leak in MediaSampleAVFObjC::createNonDisplayingCopy().
1633         <https://webkit.org/b/167621>
1634
1635         Reviewed by Andy Estes.
1636
1637         We were failing to adopt the CMSampleBuffer after copying it. Seen on leaks bot.
1638
1639         * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
1640         (WebCore::MediaSampleAVFObjC::createNonDisplayingCopy):
1641
1642 2017-01-30  Andy Estes  <aestes@apple.com>
1643
1644         [QuickLook] QLPreviewConverter and QuickLookHandle have different lifetime requirements
1645         https://bugs.webkit.org/show_bug.cgi?id=167609
1646
1647         Reviewed by Andreas Kling.
1648         
1649         Currently, QuickLookHandles are owned by DocumentLoader so that the underlying
1650         QLPreviewConverter stays alive to service subresource requests. However, the QuickLookHandle
1651         itself only needs to live long enough to handle the main resource load. And in a follow-on
1652         patch we will need to create QLPreviewConverters independent of QuickLookHandle.
1653
1654         This patch moves ownership of QuickLookHandle from DocumentLoader to ResourceLoader. It also
1655         creates a C++ wrapper around QLPreviewConverter and teaches QuickLookHandle to transfer
1656         ownership of the wrapper to DocumentLoader once the main resource conversion is complete.
1657
1658         No change in behavior. Covered by existing tests.
1659
1660         * WebCore.xcodeproj/project.pbxproj: Added PreviewConverter.{h,mm}.
1661         * loader/DocumentLoader.cpp:
1662         (WebCore::DocumentLoader::setPreviewConverter): Renamed from setQuickLookHandle().
1663         (WebCore::DocumentLoader::previewConverter): Renamed from quickLookHandle().
1664         (WebCore::DocumentLoader::setQuickLookHandle): Renamed to setPreviewConverter().
1665         * loader/DocumentLoader.h:
1666         (WebCore::DocumentLoader::quickLookHandle): Renamed to quickLookHandle().
1667         * loader/ResourceLoader.cpp:
1668         (WebCore::ResourceLoader::willSendRequestInternal): Changed to call PreviewConverter::safeRequest().
1669         (WebCore::ResourceLoader::isQuickLookResource): Changed to check if m_quickLookHandle is null.
1670         (WebCore::ResourceLoader::didCreateQuickLookHandle): Deleted.
1671         * loader/ResourceLoader.h:
1672         * loader/SubresourceLoader.cpp:
1673         (WebCore::SubresourceLoader::shouldCreateQuickLookHandleForResponse): Changed to access m_quickLookHandle.
1674         (WebCore::SubresourceLoader::didReceiveResponse): Ditto.
1675         (WebCore::SubresourceLoader::didReceiveData): Ditto.
1676         (WebCore::SubresourceLoader::didReceiveBuffer): Ditto.
1677         (WebCore::SubresourceLoader::didFinishLoading): Ditto.
1678         (WebCore::SubresourceLoader::didFail): Ditto.
1679         * loader/cache/CachedRawResource.cpp:
1680         (WebCore::CachedRawResource::finishLoading): Wrapped the call to ResourceLoader::isQuickLookResource() in USE(QUICK_LOOK).
1681         * loader/ios/QuickLook.h: Renamed m_converter to m_previewLoader.
1682         * loader/ios/QuickLook.mm: Renamed WebPreviewConverter to WebPreviewLoader.
1683         (WebCore::registerQLPreviewConverterIfNeeded): Created a PreviewConverter instead of a QLPreviewConverter.
1684         (-[WebPreviewLoader initWithResourceLoader:resourceResponse:quickLookHandle:]): Ditto.
1685         (-[WebPreviewLoader appendDataArray:]): Accessed the QLPreviewConverter from the PreviewConverter.
1686         (-[WebPreviewLoader finishedAppending]): Ditto.
1687         (-[WebPreviewLoader failed]): Ditto.
1688         (-[WebPreviewLoader converter]): Renamed from platformConverter. Returns a pointer to the PreviewConverter.
1689         (-[WebPreviewLoader _sendDidReceiveResponseIfNecessary]): Moved _converter to DocumentLoader.
1690         (-[WebPreviewLoader connection:didFailWithError:]): Created a PreviewConverter instead of a QLPreviewConverter.
1691         (WebCore::QuickLookHandle::QuickLookHandle): Called FrameLoaderClient::didCreateQuickLookHandle() instead of going through FrameLoader.
1692         (WebCore::QuickLookHandle::didReceiveData): Renamed m_converter to m_previewLoader.
1693         (WebCore::QuickLookHandle::didReceiveBuffer): Ditto.
1694         (WebCore::QuickLookHandle::didFinishLoading): Ditto.
1695         (WebCore::QuickLookHandle::didFail): Ditto.
1696         (WebCore::QuickLookHandle::setClient): Ditto.
1697         (WebCore::QuickLookHandle::previewFileName): Ditto.
1698         (WebCore::QuickLookHandle::previewUTI): Ditto.
1699         (WebCore::QuickLookHandle::willSendRequest): Deleted.
1700         * platform/ios/QuickLookSoftLink.h: Removed soft-linking of QLPreviewConverter and kQLPreviewOptionPasswordKey.
1701         * platform/ios/QuickLookSoftLink.mm: Ditto.
1702         * platform/network/ios/PreviewConverter.h: Added.
1703         (WebCore::PreviewConverter::platformConverter): Added. Returns the underlying QLPreviewConverter.
1704         * platform/network/ios/PreviewConverter.mm: Added.
1705         (WebCore::optionsWithPassword): Creates a dictionary with the kQLPreviewOptionPasswordKey option set if password is non-null.
1706         (WebCore::PreviewConverter::PreviewConverter): Added constructors for the delegate/response and data/uti cases.
1707         (WebCore::PreviewConverter::safeRequest): Wraps -[QLPreviewConverter safeRequestForRequest:].
1708         (WebCore::PreviewConverter::previewRequest): Wraps -[QLPreviewConverter previewRequest].
1709         (WebCore::PreviewConverter::previewResponse): Wraps -[QLPreviewConverter previewResponse].
1710         (WebCore::PreviewConverter::previewFileName): Wraps -[QLPreviewConverter previewFileName].
1711         (WebCore::PreviewConverter::previewUTI): Wraps -[QLPreviewConverter previewUTI].
1712
1713 2017-01-30  Chris Dumez  <cdumez@apple.com>
1714
1715         Drop legacy Attributes.isId attribute
1716         https://bugs.webkit.org/show_bug.cgi?id=167603
1717
1718         Reviewed by Ryosuke Niwa.
1719
1720         Drop legacy Attributes.isId attribute.
1721
1722         This attribute is not in the specification:
1723         - https://dom.spec.whatwg.org/#interface-attr
1724
1725         Both Firefox and Chrome currently do not expose this attribute.
1726
1727         No new tests, rebaselined existing test.
1728
1729         * dom/Attr.cpp:
1730         * dom/Attr.h:
1731         * dom/Attr.idl:
1732
1733 2017-01-30  Zalan Bujtas  <zalan@apple.com>
1734
1735         Simple line layout: Small tweaks to improve performance.
1736         https://bugs.webkit.org/show_bug.cgi?id=167611
1737         <rdar://problem/30274294>
1738
1739         Reviewed by Simon Fraser.
1740
1741         This is ~10% progression on the attached test case (paragraphs with non-redundant content).
1742         median: 102.08 runs/s -> median: 114.25 runs/s
1743
1744         * rendering/SimpleLineLayout.cpp:
1745         (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded):
1746         * rendering/SimpleLineLayoutFlowContents.cpp:
1747         (WebCore::SimpleLineLayout::initializeSegments):
1748         (WebCore::SimpleLineLayout::FlowContents::FlowContents):
1749         * rendering/SimpleLineLayoutFlowContents.h:
1750         * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
1751         (WebCore::SimpleLineLayout::TextFragmentIterator::nextNonWhitespacePosition):
1752         (WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):
1753         * rendering/SimpleLineLayoutTextFragmentIterator.h:
1754
1755 2017-01-30  Chris Dumez  <cdumez@apple.com>
1756
1757         Drop legacy constants on Event interface
1758         https://bugs.webkit.org/show_bug.cgi?id=167602
1759
1760         Reviewed by Sam Weinig.
1761
1762         Drop legacy constants on Event interface:
1763         MOUSEDOWN, MOUSEUP, MOUSEOVER, MOUSEOUT, MOUSEMOVE, MOUSEDRAG,
1764         CLICK, DBLCLICK, KEYDOWN, KEYUP, KEYPRESS, DRAGDROP, FOCUS,
1765         BLUR, SELECT, and CHANGE.
1766
1767         Those constants are not used for anything, they are not in the
1768         specification and Chrome / Firefox do not have them.
1769
1770         No new tests, rebaselined existing test.
1771
1772         * dom/Event.idl:
1773
1774 2017-01-30  Simon Fraser  <simon.fraser@apple.com>
1775
1776         [iOS] position:fixed inside touch-scrollable overflow is mispositioned
1777         https://bugs.webkit.org/show_bug.cgi?id=167604
1778         rdar://problem/29500273
1779
1780         Reviewed by Zalan Bujtas.
1781         
1782         For layers inside touch-scrollable overflow, RenderLayerBacking::computeParentGraphicsLayerRect() needs
1783         to account for the offset from the ancestor compositing layer's origin, to handle scrollable elements with
1784         box-shadow, for example.
1785         
1786         Also make the compositing log output a little easier to read.
1787
1788         Test: compositing/scrolling/fixed-inside-scroll.html
1789
1790         * rendering/RenderLayerBacking.cpp:
1791         (WebCore::RenderLayerBacking::computeParentGraphicsLayerRect):
1792         * rendering/RenderLayerCompositor.cpp:
1793         (WebCore::RenderLayerCompositor::logLayerInfo):
1794
1795 2017-01-30  Jer Noble  <jer.noble@apple.com>
1796
1797         NULL-deref crash at PlatformMediaSession::endInterruption
1798         https://bugs.webkit.org/show_bug.cgi?id=167595
1799
1800         Reviewed by Eric Carlson.
1801
1802         Use the same, NULL-aware forEachSession() iterator rather than iterating over m_sessions directly.
1803
1804         * platform/audio/PlatformMediaSessionManager.cpp:
1805         (WebCore::PlatformMediaSessionManager::beginInterruption):
1806         (WebCore::PlatformMediaSessionManager::endInterruption):
1807
1808 2017-01-30  Myles C. Maxfield  <mmaxfield@apple.com>
1809
1810         Correct spacing regression on inter-element complex path shaping on some fonts
1811         https://bugs.webkit.org/show_bug.cgi?id=166013
1812
1813         Reviewed by Simon Fraser.
1814
1815         This patch brings the implementation of ComplexTextController in-line with the
1816         design at https://trac.webkit.org/wiki/ComplexTextController. Previously,
1817         ComplexTextController had a few problems:
1818         - The total width computed by ComplexTextController didn't match the width if
1819         you iterated over the entire string and added up the advances
1820         - FontCascade::getGlyphsAndAdvancesForComplexText() tried to compensate for
1821         the above by construing the concepts of paint advances as distinct from layout
1822         advances
1823         - Initial advances were considered part of layout sometimes and part of painting
1824         other times, depending on which function reports the information
1825         - For RTL runs, the wrong origin was added to the initial advance, and the origin
1826         should have been subtracted instead of added
1827
1828         This patch exhaustively updates every function in ComplexTextController to be
1829         consistent with the design linked to above. This design solves all of these
1830         problems.
1831
1832         Tests: ComplexTextControllerTest.InitialAdvanceWithLeftRunInRTL
1833                ComplexTextControllerTest.InitialAdvanceInRTL
1834                ComplexTextControllerTest.InitialAdvanceWithLeftRunInLTR
1835                ComplexTextControllerTest.InitialAdvanceInLTR
1836                ComplexTextControllerTest.InitialAdvanceInRTLNoOrigins
1837                ComplexTextControllerTest.LeadingExpansion
1838                ComplexTextControllerTest.VerticalAdvances
1839
1840         * platform/graphics/GlyphBuffer.h:
1841         (WebCore::GlyphBuffer::setLeadingExpansion): Deleted. No longer necessary.
1842         (WebCore::GlyphBuffer::leadingExpansion): Deleted. Ditto.
1843         * platform/graphics/cocoa/FontCascadeCocoa.mm:
1844         (WebCore::FontCascade::adjustSelectionRectForComplexText): Removed use of
1845         unnecessary leadingExpansion().
1846         (WebCore::FontCascade::getGlyphsAndAdvancesForComplexText): This function needs
1847         to compute paint advances, which means that it can't base this information off
1848         of layout advances. This function uses the trick mentioned at the end of the
1849         above link to compute the paint offset of an arbitrary glyph in the middle of
1850         an RTL run.
1851         * platform/graphics/mac/ComplexTextController.cpp:
1852         (WebCore::ComplexTextController::computeExpansionOpportunity): Refactored for
1853         testing.
1854         (WebCore::ComplexTextController::ComplexTextController): Ditto.
1855         (WebCore::ComplexTextController::finishConstruction): Ditto.
1856         (WebCore::ComplexTextController::offsetForPosition): This function operates on
1857         layout advances, and the initial layout advance is already added into the
1858         m_adjustedBaseAdvances vector by adjustGlyphsAndAdvances(). Therefore, there is
1859         no need to add it again here.
1860         (WebCore::ComplexTextController::advance): This function had completely busted
1861         logic about the relationship between initial advances and the first origin in
1862         each run. Because of the fortunate choice of only representing layout advances 
1863         in m_adjustedBaseAdvances, this entire block can be removed and the raw paint
1864         initial advance can be reported to the GlyphBuffer. Later in the function, we
1865         have to update the logic about how to compute a paint advance given a layout
1866         advance and some origins. In particular, there are two tricky pieces here: 1.
1867         The layout advance for the first glyph is equal to (initial advance - first
1868         origin + first Core Text advance, so computing the paint offset must cancel out
1869         the initial layout offset, and 2. the last paint advance in a run must actually
1870         end up at the position of the first glyph in the next run, so the next run's
1871         initial advance must be queried.
1872         (WebCore::ComplexTextController::adjustGlyphsAndAdvances): Previously, we
1873         represented an initial advance of a successive run by just adding it to the
1874         previous run's last advance. However, this is incompatible with the new model
1875         presented in the link above, so we remove this section. We also have to add in
1876         the logic that the layout advance for the first glyph is equal to the formula
1877         presented above.
1878         * platform/graphics/mac/ComplexTextController.h:
1879         (WebCore::ComplexTextController::ComplexTextRun::initialAdvance): Adjust comment
1880         to reflect reality.
1881         (WebCore::ComplexTextController::leadingExpansion): Deleted.
1882
1883 2017-01-30  Simon Fraser  <simon.fraser@apple.com>
1884
1885         Fixed elements should not rubber-band in WK2, nor remain at negative offsets
1886         https://bugs.webkit.org/show_bug.cgi?id=167484
1887         rdar://problem/29453068
1888
1889         Reviewed by Dean Jackson.
1890
1891         There were various problems with the layout rect computation:
1892         1. It ignored the scrollBehaviorForFixedElements() which we use to avoid rubber-banding fixed
1893            elements in WK2, but allow in WK1, so make use of that.
1894         2. Sometimes layouts/paints of fixed elements would be triggered when coalesced calls to
1895            AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll() failed to
1896            copy the layoutViewportOrigin to the scheduled update.
1897         3. The layout viewport could be left with a negative top/left after rubber-banding.
1898         
1899         Also add a way to do unconstrained scrollTo(), so that a test can call window.scrollTo(-10, -10) to
1900         simulate rubberbanding.
1901
1902         Tests: fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html
1903                fast/visual-viewport/rubberbanding-viewport-rects.html
1904
1905         * page/FrameView.cpp:
1906         (WebCore::FrameView::computeLayoutViewportOrigin): Handle ScrollBehaviorForFixedElements, incorporating it
1907         into logic that clamps layoutViewportOrigin between min/max when rubberbanding is not allowed, or not in progress.
1908         (WebCore::FrameView::updateLayoutViewport): Pass in scrollBehaviorForFixedElements().
1909         (WebCore::FrameView::visibleDocumentRect): The clamping here was preventing the visible rect from
1910         escaping the document bounds, which caused fixed elements to bounce with rubber-banding, so remove the clamping,
1911         and fix the logic to allow rubber-banding while taking headers and footers into account.
1912         * page/FrameView.h:
1913         * page/scrolling/AsyncScrollingCoordinator.cpp:
1914         (WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll): layoutViewportOrigin has to
1915         be pushed onto the scheduled update, just like scroll position.
1916         * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
1917         (WebCore::ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition): Pass in m_behaviorForFixed.
1918         * platform/ScrollView.cpp:
1919         (WebCore::ScrollView::ScrollView):
1920         (WebCore::ScrollView::adjustScrollPositionWithinRange):
1921         (WebCore::ScrollView::setScrollOffset):
1922         * platform/ScrollView.h:
1923         (WebCore::ScrollView::setAllowsUnclampedScrollPositionForTesting):
1924         (WebCore::ScrollView::allowsUnclampedScrollPosition):
1925         * testing/InternalSettings.cpp:
1926         (WebCore::InternalSettings::setAllowUnclampedScrollPosition):
1927         * testing/InternalSettings.h:
1928         * testing/InternalSettings.idl:
1929
1930 2017-01-30  Wenson Hsieh  <wenson_hsieh@apple.com>
1931
1932         Web content process crashes when initiating a drag on a very large image
1933         https://bugs.webkit.org/show_bug.cgi?id=167564
1934
1935         Reviewed by Beth Dakin.
1936
1937         If we begin dragging an image element that is too large to show the cached image for, we will show an image file
1938         icon instead of the cached image. This may return null if createDragImageIconForCachedImageFilename is
1939         unimplemented, so in the meantime, we should not assume that dragImage will always exist before calling into
1940         doSystemDrag in doImageDrag and bail from the drag operation if that is the case.
1941
1942         * page/DragController.cpp:
1943         (WebCore::DragController::doImageDrag):
1944
1945 2017-01-30  Chris Dumez  <cdumez@apple.com>
1946
1947         Update DiagnosticLoggingClient::logDiagnosticMessageWithValue() to take in the value as a double
1948         https://bugs.webkit.org/show_bug.cgi?id=167536
1949
1950         Reviewed by Darin Adler.
1951
1952         Update DiagnosticLoggingClient::logDiagnosticMessageWithValue() to take in the value as a double
1953         instead of a string. The value needs to be numeric and the current API is error-prone.
1954
1955         * html/HTMLMediaElement.cpp:
1956         (WebCore::HTMLMediaElement::mediaPlayerEngineFailedToLoad):
1957         * loader/EmptyClients.cpp:
1958         * page/DiagnosticLoggingClient.h:
1959
1960 2017-01-30  Ryan Haddad  <ryanhaddad@apple.com>
1961
1962         Unreviewed, rollout r211235 Pointer lock events should be delivered directly to the target element.
1963
1964         The LayoutTest for this change is frequently failing.
1965
1966         * page/EventHandler.cpp:
1967         (WebCore::EventHandler::handleMousePressEvent):
1968         (WebCore::EventHandler::handleMouseDoubleClickEvent):
1969         (WebCore::EventHandler::handleMouseMoveEvent):
1970         (WebCore::EventHandler::handleMouseReleaseEvent):
1971         (WebCore::EventHandler::handleMouseForceEvent):
1972         (WebCore::EventHandler::handleWheelEvent):
1973         * page/PointerLockController.cpp:
1974         (WebCore::PointerLockController::isLocked): Deleted.
1975         (WebCore::PointerLockController::dispatchLockedWheelEvent): Deleted.
1976         * page/PointerLockController.h:
1977
1978 2017-01-30  Antoine Quint  <graouts@apple.com>
1979
1980         LayoutTest media/modern-media-controls/media-controller/media-controller-auto-hide-mouse-leave-after-play.html is flaky
1981         https://bugs.webkit.org/show_bug.cgi?id=167254
1982         <rdar://problem/30259293>
1983
1984         Reviewed by Dean Jackson.
1985
1986         When we would identify that we need to prolong an existing auto-hide timer, when the previous
1987         auto-hide timer was marked as non-cancelable, calling _cancelAutoHideTimer() would not actually
1988         cancel the previous timer, which would let it fire and hide the controls bar. We now have two
1989         methods, _cancelAutoHideTimer() which always cancels the current auto-hide timer, and
1990         _cancelNonEnforcedAutoHideTimer() which is used from all other existing call sites, which only
1991         cancels the current auto-hide timer if it was marked as cancelable. This, and revised timing in
1992         the test itself, make media/modern-media-controls/media-controller/media-controller-auto-hide-
1993         mouse-leave-after-play.html a lot more reliable.
1994
1995         We also make a small drive-by fix where we ensure the "autoHideDelay" property is set first so
1996         that setting other members which may set a timer do not used an undefined value for the auto-hide
1997         timer delay.
1998
1999         * Modules/modern-media-controls/controls/controls-bar.js:
2000         (ControlsBar.prototype.set visible):
2001         (ControlsBar.prototype.handleEvent):
2002         (ControlsBar.prototype._cancelNonEnforcedAutoHideTimer):
2003         (ControlsBar.prototype._cancelAutoHideTimer):
2004
2005 2017-01-30  Carlos Garcia Campos  <cgarcia@igalia.com>
2006
2007         REGRESSION(r202615?): [GStreamer] ASSERTION FAILED: isMainThread() in WebCore::BuiltinResourceHandleConstructorMap& WebCore::builtinResourceHandleConstructorMap()
2008         https://bugs.webkit.org/show_bug.cgi?id=167003
2009
2010         Reviewed by Michael Catanzaro.
2011
2012         Add a way to create a ResourceHandle for a given SoupNetworkSession and use it in the GStreamer streaming client
2013         to ensure both the session and the handle are created and destroyed in the secondary thread. This way we also
2014         avoid using the default session for downloading HLS fragments.
2015
2016         * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
2017         (ResourceHandleStreamingClient::ResourceHandleStreamingClient): Create a SoupNetworkSession and pass it to ResourceHandle::create().
2018         * platform/network/ResourceHandle.h: Add create and constructor to receive a SoupNetworkSession.
2019         * platform/network/ResourceHandleInternal.h: Add SoupNetworkSession member.
2020         * platform/network/soup/ResourceHandleSoup.cpp:
2021         (WebCore::ResourceHandleInternal::soupSession): Return the SoupNetworkSession if not nullptr.
2022         (WebCore::ResourceHandle::create): Create a ResourceHandle without trying to use any builtin constructor and
2023         using the given SoupNetworkSession.
2024         (WebCore::ResourceHandle::ResourceHandle): Set the SoupNetworkSession if early request validations didn't fail.
2025
2026 2017-01-30  Youenn Fablet  <youennf@gmail.com>
2027
2028         [WebRTC] Add support for libwebrtc data channel
2029         https://bugs.webkit.org/show_bug.cgi?id=167489
2030
2031         Reviewed by Alex Christensen.
2032
2033         Partially covered by webrtc/datachannel/basic.html but not yet enabled on bots.
2034
2035         Introducing LibWebRTCDataChannelHandler as the integration layer between WebCore (RTCDataChannel)
2036         and libwebrtc (DataChannelObserver).
2037
2038         * Modules/mediastream/RTCDataChannel.cpp:
2039         (WebCore::RTCDataChannel::create):
2040         (WebCore::RTCDataChannel::RTCDataChannel):
2041         (WebCore::RTCDataChannel::bufferedAmount):
2042         (WebCore::RTCDataChannel::bufferedAmountIsDecreasing):
2043         * Modules/mediastream/RTCDataChannel.h:
2044         * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp: Added.
2045         (WebCore::LibWebRTCDataChannelHandler::~LibWebRTCDataChannelHandler):
2046         (WebCore::LibWebRTCDataChannelHandler::setClient):
2047         (WebCore::LibWebRTCDataChannelHandler::sendStringData):
2048         (WebCore::LibWebRTCDataChannelHandler::sendRawData):
2049         (WebCore::LibWebRTCDataChannelHandler::close):
2050         (WebCore::LibWebRTCDataChannelHandler::OnStateChange):
2051         (WebCore::LibWebRTCDataChannelHandler::OnMessage):
2052         * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
2053         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
2054         (WebCore::LibWebRTCMediaEndpoint::OnRemoveStream):
2055         (WebCore::LibWebRTCMediaEndpoint::addDataChannel):
2056         (): Deleted.
2057         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
2058         (WebCore::LibWebRTCPeerConnectionBackend::createDataChannelHandler):
2059         * dom/EventNames.h:
2060         * platform/mediastream/RTCDataChannelHandler.h:
2061         * platform/mediastream/RTCDataChannelHandlerClient.h:
2062         * platform/mock/RTCDataChannelHandlerMock.h:
2063
2064 2017-01-30  Carlos Garcia Campos  <cgarcia@igalia.com>
2065
2066         Several web timing tests crash in GTK+ and AppleWin bots
2067         https://bugs.webkit.org/show_bug.cgi?id=167577
2068
2069         Reviewed by Ryosuke Niwa.
2070
2071         The problem is that entry is used in both the key, to get name, and in the value with WTFMove. So, the name is
2072         invalidated by the move. It could be fixed by simply copying the name, instead of using entry->name, but I think
2073         that code could be simplified using HashMap::ensure and then we don't need any string copy, nor even the static
2074         insertPerformanceEntry().
2075
2076         Fix crashes in several imported/w3c/web-platform-tests/user-timing/ tests.
2077
2078         * page/PerformanceUserTiming.cpp:
2079         (WebCore::UserTiming::mark):
2080         (WebCore::UserTiming::measure):
2081         (WebCore::insertPerformanceEntry): Deleted.
2082
2083 2017-01-30  Carlos Garcia Campos  <cgarcia@igalia.com>
2084
2085         [Threaded Compositor] Crash in GraphicsContext3D::deleteTexture when destroying TextureMapperPlatformLayerProxy
2086         https://bugs.webkit.org/show_bug.cgi?id=167575
2087
2088         Reviewed by Žan Doberšek.
2089
2090         We should clear all the buffers on invalidate to ensure we don't have textures alive after CoordinatedGraphicsScene::purgeGLResources().
2091
2092         Fix crash in media/video-poster-background.html.
2093
2094         * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
2095         (WebCore::TextureMapperPlatformLayerProxy::invalidate): Clear current, pending and all used buffers.
2096
2097 2017-01-29  Carlos Garcia Campos  <cgarcia@igalia.com>
2098
2099         [Threaded Compositor] Crash on WebCore::GLContext::version()
2100         https://bugs.webkit.org/show_bug.cgi?id=167559
2101
2102         Reviewed by Michael Catanzaro.
2103
2104         Fixes crashes in several media tests.
2105
2106         * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
2107         (WebCore::TextureMapperPlatformLayerProxy::invalidate): Clear m_compositorThreadUpdateTimer and call the update function.
2108
2109 2017-01-29  Nan Wang  <n_wang@apple.com>
2110
2111         AX: WKContentView needs to implement UITextInput methods to make speak selection highlighting work
2112         https://bugs.webkit.org/show_bug.cgi?id=166955
2113
2114         Reviewed by Ryosuke Niwa.
2115
2116         Created a new version of Range::collectSelectionRect() that returns rects for each
2117         line, so that Speak Selection doesn't need to handle searching for soft line breaks.
2118         Also added a variant of findPlainText to search for the closest matched range to the given position.
2119
2120         Test: editing/text-iterator/range-of-string-closest-to-position.html
2121
2122         * dom/Range.cpp:
2123         (WebCore::Range::collectSelectionRectsWithoutUnionInteriorLines):
2124         (WebCore::Range::collectSelectionRects):
2125         * dom/Range.h:
2126         * editing/TextIterator.cpp:
2127         (WebCore::findPlainTextMatches):
2128         (WebCore::updateSearchBuffer):
2129         (WebCore::findIteratorOptions):
2130         (WebCore::rangeMatches):
2131         (WebCore::findClosestPlainText):
2132         (WebCore::findPlainText):
2133         (WebCore::findPlainTextOffset): Deleted.
2134         * editing/TextIterator.h:
2135         * editing/htmlediting.h:
2136         * testing/Internals.cpp:
2137         (WebCore::Internals::rangeOfStringNearLocation):
2138         * testing/Internals.h:
2139         * testing/Internals.idl:
2140
2141 2017-01-29  Andy Estes  <aestes@apple.com>
2142
2143         [QuickLook] Add a WebPreference to enable saving QuickLook documents in WebKitLegacy
2144         https://bugs.webkit.org/show_bug.cgi?id=167563
2145         <rdar://problem/30253207>
2146
2147         Reviewed by Andreas Kling.
2148
2149         * loader/ios/QuickLook.h: Removed unused declarations.
2150         (WebCore::QuickLookHandle::firstRequestURL): Deleted.
2151         * loader/ios/QuickLook.mm:
2152         (WebCore::removeQLPreviewConverterForURL): Stopped deleting the temporary file here; that's
2153         now done in QuickLookDocumentWriter.
2154         (addQLPreviewConverterWithFileForURL): Changed from an exported function to a static
2155         function since it's now only called inside QuickLook.mm.
2156         (WebCore::QuickLookHandle::QuickLookHandle): Stopped initializing m_firstRequestURL.
2157         (WebCore::addQLPreviewConverterWithFileForURL): Deleted.
2158         (WebCore::qlPreviewConverterFileNameForURL): Deleted.
2159         (WebCore::qlPreviewConverterUTIForURL): Deleted.
2160         (WebCore::QuickLookHandle::previewRequestURL): Deleted.
2161         (WebCore::QuickLookHandle::converter): Deleted.
2162
2163 2017-01-29  Zalan Bujtas  <zalan@apple.com>
2164
2165         Simple line layout: PerformanceTests/Layout/simple-line-layout-innertext.html regressed at r211108
2166         https://bugs.webkit.org/show_bug.cgi?id=167562
2167
2168         Reviewed by Antti Koivisto.
2169
2170         Apparently RunResolver::Run::constructStringForHyphenIfNeeded() is in a superhot codepath.
2171         The Run should not have any additional members anyway, so let's construct the hyphenated
2172         string on demand.
2173         Progression on simple-line-layout-innertext.html is from ~34runs/sec back to ~50runs/sec.
2174
2175         Covered by existing text.
2176
2177         * rendering/RenderTreeAsText.cpp:
2178         (WebCore::writeSimpleLine):
2179         * rendering/SimpleLineLayoutFunctions.cpp:
2180         (WebCore::SimpleLineLayout::paintFlow):
2181         * rendering/SimpleLineLayoutResolver.cpp:
2182         (WebCore::SimpleLineLayout::RunResolver::Run::Run):
2183         (WebCore::SimpleLineLayout::RunResolver::Run::textWithHyphen):
2184         (WebCore::SimpleLineLayout::RunResolver::Run::text):
2185         (WebCore::SimpleLineLayout::RunResolver::Run::constructStringForHyphenIfNeeded): Deleted.
2186         * rendering/SimpleLineLayoutResolver.h:
2187
2188 2017-01-28  Tim Horton  <timothy_horton@apple.com>
2189
2190         Don't flash a tap highlight for the entirety of an editable WKWebView
2191         https://bugs.webkit.org/show_bug.cgi?id=167486
2192         <rdar://problem/30193996>
2193
2194         Reviewed by Dan Bernstein.
2195
2196         * dom/Document.h:
2197         Export.
2198
2199 2017-01-28  Wenson Hsieh  <wenson_hsieh@apple.com>
2200
2201         Check USE(APPLE_INTERNAL_SDK) instead of specific headers when importing from WebKitAdditions
2202         https://bugs.webkit.org/show_bug.cgi?id=167555
2203
2204         Reviewed by Dan Bernstein.
2205
2206         Instead of guarding #import <WebKitAdditions/*> on the existence of the imported file, consult
2207         USE(APPLE_INTERNAL_SDK) instead.
2208
2209         * page/ios/EventHandlerIOS.mm:
2210         * platform/ios/DragImageIOS.mm:
2211         * platform/ios/PasteboardIOS.mm:
2212         * platform/mac/DragDataMac.mm:
2213
2214 2017-01-28  Yoav Weiss  <yoav@yoav.ws>
2215
2216         Add Link Preload as an off-by-default experimental feature menu item.
2217         https://bugs.webkit.org/show_bug.cgi?id=167201
2218
2219         Reviewed by Ryosuke Niwa.
2220
2221         Removed the explicit setting of the Link Preload experimental feature,
2222         as it is now on by default for testing.
2223
2224         No new tests as this just removes methods from settings.
2225
2226         * testing/InternalSettings.cpp:
2227         (WebCore::InternalSettings::Backup::Backup):
2228         (WebCore::InternalSettings::Backup::restoreTo):
2229         * testing/InternalSettings.h:
2230         * testing/InternalSettings.idl:
2231
2232 2017-01-28  Joseph Pecoraro  <pecoraro@apple.com>
2233
2234         Fix typo in error message
2235         https://bugs.webkit.org/show_bug.cgi?id=167554
2236
2237         Reviewed by Sam Weinig.
2238
2239         * bindings/scripts/CodeGenerator.pm:
2240         (GetEnumByType):
2241
2242 2017-01-28  Antoine Quint  <graouts@apple.com>
2243
2244         [Modern Media Controls] REGRESSION: Video stops playing after going into Full Screen in media documents
2245         https://bugs.webkit.org/show_bug.cgi?id=167552
2246         <rdar://problem/29601646>
2247
2248         Reviewed by Eric Carlson.
2249
2250         In the case of media documents, there is a built-in behavior, implemented in MediaDocument::defaultEventHandler(),
2251         that toggles playback when clicking or double-clicking the video. We disable this behavior by adding a "click" event
2252         handler on the entire media shadow root and calling "preventDefault()".
2253
2254         Test: media/modern-media-controls/media-documents/click-on-video-should-not-pause.html
2255
2256         * Modules/modern-media-controls/media/media-controller.js:
2257         (MediaController):
2258         (MediaController.prototype.handleEvent):
2259         (MediaController.prototype._containerWasClicked):
2260
2261 2017-01-28  Dan Bernstein  <mitz@apple.com>
2262
2263         [Xcode] Clean up PAL and WebCore’s build settings a little
2264         https://bugs.webkit.org/show_bug.cgi?id=167292
2265
2266         Reviewed by Sam Weinig.
2267
2268         * Configurations/Base.xcconfig: Simplified the definition of
2269           GCC_WARN_64_TO_32_BIT_CONVERSION, removed the unused build setting PREBINDING, removed
2270           a duplicate definition of GCC_GENERATE_DEBUGGING_SYMBOLS, and removed definitions specific
2271           to OS X versions that are no longer supported.
2272
2273         * Configurations/DebugRelease.xcconfig: Removed definitions specific to OS X versions
2274           that are no longer supported.
2275
2276 2017-01-28  Zalan Bujtas  <zalan@apple.com>
2277
2278         Resolve beforeChild's render tree position before calling addChildIgnoringContinuation.
2279         https://bugs.webkit.org/show_bug.cgi?id=167540
2280         <rdar://problem/30126535>
2281
2282         Reviewed by Simon Fraser.
2283
2284         Use the actual render tree position for the beforeChild when inside a flow thread.
2285
2286         Test: fast/multicol/assert-on-continuation-with-spanner.html
2287
2288         * rendering/RenderBlockFlow.cpp:
2289         (WebCore::RenderBlockFlow::addChild):
2290         * rendering/RenderInline.cpp:
2291         (WebCore::RenderInline::addChild):
2292         * rendering/RenderMultiColumnFlowThread.cpp:
2293         (WebCore::RenderMultiColumnFlowThread::resolveMovedChild):
2294
2295 2017-01-28  Andreas Kling  <akling@apple.com>
2296
2297         Avoid synchronous style recalc in dispatchUnloadEvents().
2298         <https://webkit.org/b/167551>
2299
2300         Reviewed by Antti Koivisto.
2301
2302         It shouldn't be necessary to force a synchronous style resolution in an unloading document.
2303         This call has been here since the import of KHTMLPart.
2304
2305         * loader/FrameLoader.cpp:
2306         (WebCore::FrameLoader::dispatchUnloadEvents):
2307
2308 2017-01-28  Andreas Kling  <akling@apple.com>
2309
2310         REGRESSION(r196383): Automatic shrink-to-fit of RuleSet no longer works.
2311         <https://webkit.org/b/167543>
2312
2313         Reviewed by Antti Koivisto.
2314
2315         Re-enable the automatic shrink-to-fit optimization in RuleSet.
2316         This was disabled accidentally, which I discovered while investigating
2317         the memory footprint of extension stylesheets.
2318
2319         * css/RuleSet.h:
2320
2321 2017-01-28  Antti Koivisto  <antti@apple.com>
2322
2323         Give scripts 'high' load priority
2324         https://bugs.webkit.org/show_bug.cgi?id=167550
2325
2326         Reviewed by Andreas Kling.
2327
2328         For historical reasons it is currently 'medium', same as web fonts and some other non-parsing blocking things.
2329
2330         * loader/cache/CachedResource.cpp:
2331         (WebCore::CachedResource::defaultPriorityForResourceType):
2332
2333 2017-01-28  Joseph Pecoraro  <pecoraro@apple.com>
2334
2335         Add User Timing Experimental Feature
2336         https://bugs.webkit.org/show_bug.cgi?id=167542
2337         <rdar://problem/22746307>
2338
2339         Reviewed by Ryosuke Niwa.
2340
2341         * page/RuntimeEnabledFeatures.h:
2342         (WebCore::RuntimeEnabledFeatures::performanceTimelineEnabled):
2343         * page/Performance.idl:
2344         * page/PerformanceEntry.idl:
2345         Make a better RuntimeEnabledFeature named "PerformanceTiming" which
2346         is enabled if either UserTiming or ResourceTiming is enabled. This
2347         will then expose the APIs that are only useful when at least one of
2348         the APIs are available.
2349
2350         * page/PerformanceEntry.cpp:
2351         (WebCore::PerformanceEntry::name): Deleted.
2352         (WebCore::PerformanceEntry::entryType): Deleted.
2353         (WebCore::PerformanceEntry::startTime): Deleted.
2354         (WebCore::PerformanceEntry::duration): Deleted.
2355         * page/PerformanceEntry.h:
2356         (WebCore::PerformanceEntry::name):
2357         (WebCore::PerformanceEntry::entryType):
2358         (WebCore::PerformanceEntry::startTime):
2359         (WebCore::PerformanceEntry::duration):
2360         Inline simple accessors.
2361
2362         * page/PerformanceUserTiming.cpp:
2363         (WebCore::UserTiming::measure):
2364         Fix a bug introduced by ExceptionOr refactoring.
2365
2366         (WebCore::UserTiming::clearMarks):
2367         (WebCore::UserTiming::clearMeasures):
2368         (WebCore::clearPerformanceEntries):
2369         (WebCore::clearPeformanceEntries): Deleted.
2370         Fix method name typo.
2371
2372 2017-01-27  Dan Bernstein  <mitz@apple.com>
2373
2374         Ignore Xcode’s project.xcworkspace and userdata directories in this new project like we do
2375         in other projects.
2376
2377         * PAL/PAL.xcodeproj: Added property svn:ignore.
2378
2379 2017-01-27  Andy Estes  <aestes@apple.com>
2380
2381         Fix the iOS build when USE(QUICK_LOOK) is disabled.
2382
2383         * testing/Internals.cpp:
2384         (WebCore::Internals::setQuickLookPassword):
2385         * testing/Internals.h:
2386
2387 2017-01-27  Yusuke Suzuki  <utatane.tea@gmail.com>
2388
2389         setTimeout / setInterval's string execution should inherit SourceOrigin correctly
2390         https://bugs.webkit.org/show_bug.cgi?id=167097
2391
2392         Reviewed by Darin Adler.
2393
2394         Tests: js/dom/modules/import-from-set-interval.html
2395                js/dom/modules/import-from-set-timeout.html
2396
2397         * bindings/js/ScriptController.cpp:
2398         (WebCore::ScriptController::executeScriptInWorld):
2399
2400 2017-01-27  Yusuke Suzuki  <utatane.tea@gmail.com>
2401
2402         Merge CachedModuleScript and LoadableModuleScript
2403         https://bugs.webkit.org/show_bug.cgi?id=167500
2404
2405         Reviewed by Darin Adler.
2406
2407         CachedModuleScript becomes duplicate with LoadableModuleScript.
2408         And CachedModuleScript does not offer any meaningful functionality
2409         to LoadableModuleScript.
2410         This patch merges CachedModuleScript to LoadableModuleScript.
2411
2412         No behavior change.
2413
2414         * CMakeLists.txt:
2415         * WebCore.xcodeproj/project.pbxproj:
2416         * bindings/js/CachedModuleScript.cpp: Removed.
2417         * bindings/js/CachedModuleScript.h: Removed.
2418         * bindings/js/CachedModuleScriptClient.h: Removed.
2419         * bindings/js/JSBindingsAllInOne.cpp:
2420         * bindings/js/ScriptController.cpp:
2421         (WebCore::ScriptController::loadModuleScriptInWorld):
2422         (WebCore::ScriptController::loadModuleScript):
2423         (WebCore::ScriptController::linkAndEvaluateModuleScriptInWorld):
2424         (WebCore::ScriptController::linkAndEvaluateModuleScript):
2425         (WebCore::ScriptController::setupModuleScriptHandlers):
2426         * bindings/js/ScriptController.h:
2427         * dom/LoadableModuleScript.cpp:
2428         (WebCore::LoadableModuleScript::create):
2429         (WebCore::LoadableModuleScript::LoadableModuleScript):
2430         (WebCore::LoadableModuleScript::~LoadableModuleScript):
2431         (WebCore::LoadableModuleScript::isLoaded):
2432         (WebCore::LoadableModuleScript::error):
2433         (WebCore::LoadableModuleScript::wasCanceled):
2434         (WebCore::LoadableModuleScript::notifyLoadCompleted):
2435         (WebCore::LoadableModuleScript::notifyLoadFailed):
2436         (WebCore::LoadableModuleScript::notifyLoadWasCanceled):
2437         (WebCore::LoadableModuleScript::execute):
2438         (WebCore::LoadableModuleScript::load):
2439         (WebCore::LoadableModuleScript::notifyFinished): Deleted.
2440         * dom/LoadableModuleScript.h:
2441         * dom/ScriptElement.cpp:
2442         (WebCore::ScriptElement::executeModuleScript):
2443         * dom/ScriptElement.h:
2444
2445 2017-01-27  Michael Saboff  <msaboff@apple.com>
2446
2447         JSCustomElementInterface::invokeCallback can be called with a null callback because Weak<>
2448         https://bugs.webkit.org/show_bug.cgi?id=167522
2449
2450         Reviewed by Filip Pizlo.
2451
2452         Added all provided callbacks to the global object with a private name the same way 
2453         that the constructor was added.  This will keep these callbacks from being GC'ed.
2454
2455         * bindings/js/JSCustomElementRegistryCustom.cpp:
2456         (WebCore::JSCustomElementRegistry::define):
2457
2458 2017-01-27  Myles C. Maxfield  <mmaxfield@apple.com>
2459
2460         [Cocoa] Prepare ComplexTextController for unit testing
2461         https://bugs.webkit.org/show_bug.cgi?id=167493
2462
2463         Reviewed by Simon Fraser.
2464
2465         Addressing post-review comments from Simon Fraser.
2466
2467         * platform/graphics/FontCascade.h:
2468         * platform/graphics/mac/ComplexTextController.h:
2469         (WebCore::ComplexTextController::ComplexTextRun::createForTesting):
2470         * platform/graphics/mac/ComplexTextControllerCoreText.h:
2471         (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
2472
2473 2017-01-27  Simon Fraser  <simon.fraser@apple.com>
2474
2475         Element with a backdrop-filter and a mask may not correctly mask the backdrop
2476         https://bugs.webkit.org/show_bug.cgi?id=167456
2477         rdar://problem/29320059
2478
2479         Reviewed by Antoine Quint.
2480
2481         If a layer had a backdrop filter, but also corner radii that triggered using a mask layer,
2482         then the call to updateClippingStrategy() in GraphicsLayerCA::updateBackdropFiltersRect() would
2483         set the backdrop layer's mask, but GraphicsLayerCA::updateMaskLayer() would promptly then set
2484         the mask layer back to nil.
2485
2486         Fix by having GraphicsLayerCA::updateMaskLayer() put the mask on the structural layer, if there
2487         is one. We always have a structural layer with backdrops, so this will mask both the layer
2488         and the backdrop.
2489
2490         Test: css3/filters/backdrop/backdrop-filter-uneven-corner-radii.html
2491
2492         * platform/graphics/ca/GraphicsLayerCA.cpp:
2493         (WebCore::GraphicsLayerCA::updateMaskLayer):
2494         * platform/graphics/mac/WebLayer.mm:
2495         (-[CALayer _descriptionWithPrefix:]): Dump the mask layer.
2496
2497 2017-01-27  Chris Dumez  <cdumez@apple.com>
2498
2499         Fix remaining bad uses of logDiagnosticMessageWithValue()
2500         https://bugs.webkit.org/show_bug.cgi?id=167526
2501
2502         Reviewed by Alex Christensen.
2503
2504         Drop unused keys, add new ones.
2505
2506         * page/DiagnosticLoggingKeys.cpp:
2507         (WebCore::DiagnosticLoggingKeys::networkCacheFailureReasonKey):
2508         (WebCore::DiagnosticLoggingKeys::networkCacheUnusedReasonKey):
2509         (WebCore::DiagnosticLoggingKeys::networkCacheReuseFailureKey):
2510         (WebCore::DiagnosticLoggingKeys::backNavigationDeltaKey):
2511         (WebCore::DiagnosticLoggingKeys::userZoomActionKey):
2512         (WebCore::DiagnosticLoggingKeys::deltaKey): Deleted.
2513         (WebCore::DiagnosticLoggingKeys::backNavigationKey): Deleted.
2514         (WebCore::DiagnosticLoggingKeys::requestKey): Deleted.
2515         (WebCore::DiagnosticLoggingKeys::unusableCachedEntryKey): Deleted.
2516         (WebCore::DiagnosticLoggingKeys::userKey): Deleted.
2517         (WebCore::DiagnosticLoggingKeys::zoomedKey): Deleted.
2518         (WebCore::DiagnosticLoggingKeys::notInCacheKey): Deleted.
2519         * page/DiagnosticLoggingKeys.h:
2520
2521 2017-01-27  Myles C. Maxfield  <mmaxfield@apple.com>
2522
2523         Proclaim that we are considering font-display, rhythmic sizing, and text decoration level 4
2524         https://bugs.webkit.org/show_bug.cgi?id=167340
2525
2526         Reviewed by Saam Barati.
2527
2528         * features.json:
2529
2530 2017-01-27  Chris Dumez  <cdumez@apple.com>
2531
2532         Fix diagnostic logging under loader/
2533         https://bugs.webkit.org/show_bug.cgi?id=167512
2534
2535         Reviewed by Alex Christensen.
2536
2537         Fix diagnostic logging under loader/. We should not be using logDiagnosticLoggingWithValue()
2538         without a numeric value.
2539
2540         * loader/ResourceLoader.cpp:
2541         (WebCore::logResourceResponseSource):
2542         * loader/SubresourceLoader.cpp:
2543         (WebCore::logResourceLoaded):
2544         * loader/cache/CachedResourceLoader.cpp:
2545         (WebCore::logMemoryCacheResourceRequest):
2546         (WebCore::CachedResourceLoader::requestResource):
2547         (WebCore::logRevalidation):
2548         * page/DiagnosticLoggingKeys.cpp:
2549         (WebCore::DiagnosticLoggingKeys::memoryCacheEntryDecisionKey):
2550         (WebCore::DiagnosticLoggingKeys::memoryCacheUsageKey):
2551         (WebCore::DiagnosticLoggingKeys::cachedResourceRevalidationReasonKey):
2552         (WebCore::DiagnosticLoggingKeys::resourceLoadedKey):
2553         (WebCore::DiagnosticLoggingKeys::resourceResponseSourceKey):
2554         * page/DiagnosticLoggingKeys.h:
2555
2556 2017-01-27  Chris Dumez  <cdumez@apple.com>
2557
2558         Fix diagnostic logging in media code
2559         https://bugs.webkit.org/show_bug.cgi?id=167510
2560
2561         Reviewed by Alex Christensen.
2562
2563         Fix diagnostic logging in media code. It should not use logDiagnosticMessageWithValue()
2564         with a non-numeric value.
2565
2566         * html/HTMLMediaElement.cpp:
2567         (WebCore::HTMLMediaElement::loadResource):
2568         (WebCore::HTMLMediaElement::updatePlayState):
2569
2570 2017-01-27  Myles C. Maxfield  <mmaxfield@apple.com>
2571
2572         [Cocoa] Prepare ComplexTextController for unit testing
2573         https://bugs.webkit.org/show_bug.cgi?id=167493
2574
2575         Reviewed by Dean Jackson.
2576
2577         ComplexTextController has three phases:
2578         1. Interrogate Core Text about some text
2579         2. Compute layout advances and paint advances from the information retrieved from
2580         Core Text
2581         3. Iterate through the layout advances or paint advances.
2582
2583         This patch tests phases 2 and 3 by chopping ComplexTextController between
2584         phases 1 and 2, and injecting foreign metrics from a unit test. These metrics
2585         have been gathered from real-world uses; however, a layout test is not appropriate
2586         because the fonts which produced these metrics are not licensed appropriately.
2587         The tests can enforce the correct behavior by using ComplexTextController's
2588         public API.
2589
2590         This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=166013.
2591         However, the fix for that bug is quite large, so I've split out this smaller piece
2592         to ease the reviewing burden. The tests I've added are disabled for now (because
2593         they fail), but will be enabled by the fix to that bug.
2594
2595         No new tests because there is no behavior change.
2596
2597         * WebCore.xcodeproj/project.pbxproj:
2598         * platform/graphics/FontCascade.h:
2599         * platform/graphics/FontDescription.h:
2600         * platform/graphics/mac/ComplexTextController.cpp:
2601         (WebCore::ComplexTextController::ComplexTextController):
2602         (WebCore::ComplexTextController::finishConstruction):
2603         * platform/graphics/mac/ComplexTextController.h:
2604         (WebCore::ComplexTextController::ComplexTextRun::createForTesting):
2605         * platform/graphics/mac/ComplexTextControllerCoreText.mm:
2606         (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
2607
2608 2017-01-27  Zalan Bujtas  <zalan@apple.com>
2609
2610         Simple line layout: Do not bail out on -webkit-line-box-contain: block glyphs unless text overflows vertically.
2611         https://bugs.webkit.org/show_bug.cgi?id=167481
2612         <rdar://problem/30180150>
2613
2614         Reviewed by Antti Koivisto.
2615
2616         Since -webkit-line-box-contain: glyphs requires variable line height support, we can use simple line layout
2617         only when each line happen to have the same height ('block' property value is set, glyphs do not overflow the block line height).  
2618
2619         Test: fast/text/simple-line-layout-line-box-contain-glyphs.html
2620
2621         * rendering/SimpleLineLayout.cpp:
2622         (WebCore::SimpleLineLayout::canUseForText):
2623         (WebCore::SimpleLineLayout::canUseForFontAndText):
2624         (WebCore::SimpleLineLayout::canUseForStyle):
2625         (WebCore::SimpleLineLayout::printReason):
2626
2627 2017-01-27  Chris Dumez  <cdumez@apple.com>
2628
2629         Fix PageCache diagnostic logging
2630         https://bugs.webkit.org/show_bug.cgi?id=167508
2631
2632         Reviewed by Sam Weinig.
2633
2634         Fix PageCache diagnostic logging. It should not call logDiagnosticMessageWithValue()
2635         with a non-numeric value. Use logDiagnosticMessage() instead.
2636
2637         * history/PageCache.cpp:
2638         (WebCore::logPageCacheFailureDiagnosticMessage):
2639         (WebCore::canCacheFrame):
2640         * page/DiagnosticLoggingKeys.cpp:
2641         (WebCore::DiagnosticLoggingKeys::pageCacheFailureKey):
2642         (WebCore::DiagnosticLoggingKeys::successKey): Deleted.
2643         (WebCore::DiagnosticLoggingKeys::failureKey): Deleted.
2644         * page/DiagnosticLoggingKeys.h:
2645
2646 2017-01-27  Devin Rousso  <dcrousso+webkit@gmail.com>
2647
2648         Styles should not show background-repeat-x/y, or -webkit-mask-repeat-x/y
2649         https://bugs.webkit.org/show_bug.cgi?id=167255
2650
2651         Reviewed by Joseph Pecoraro.
2652
2653         Test: inspector/css/css-property.html
2654
2655         * css/makeprop.pl:
2656         (addProperty):
2657         Add a generated function `isInternalCSSProperty` that checks the given CSSPropertyID against
2658         a derived list of properties from CSSProperties.json with "internal-only".
2659
2660         * inspector/InspectorCSSAgent.cpp:
2661         (WebCore::InspectorCSSAgent::getSupportedCSSProperties):
2662         * inspector/InspectorStyleSheet.cpp:
2663         (WebCore::InspectorStyle::styleWithProperties):
2664         Only pass CSS property payloads to the frontend if they are not internal.
2665
2666 2017-01-27  Antti Koivisto  <antti@apple.com>
2667
2668         Implement Cache-control: immutable
2669         https://bugs.webkit.org/show_bug.cgi?id=167497
2670
2671         Reviewed by Chris Dumez.
2672
2673         Cache-control value 'immutable' indicates that a subresource does not change and so does not need to be
2674         revalidated on a normal reload. This can significantly speed up reloads and reduce network traffic.
2675
2676         It is has been implemented in Firefox and is already used by Facebook.
2677
2678         https://tools.ietf.org/html/draft-mcmanus-immutable-00
2679         https://hacks.mozilla.org/2017/01/using-immutable-caching-to-speed-up-the-web/
2680
2681         This patch implements Cache-control: immutable for memory cache only. A disk cache implementation
2682         doesn't seem necessary as the resource is basically always expected to be in memory cache on reload.
2683
2684         Immutable is only supported for https as suggested by the draft specification (and Gecko implementation).
2685
2686         Test: http/tests/cache/cache-control-immutable-http.html
2687               http/tests/cache/cache-control-immutable-https.html
2688
2689         * loader/cache/CachedResource.cpp:
2690         (WebCore::CachedResource::makeRevalidationDecision):
2691
2692             On normal reloads (CachePolicyRevalidate) of https resources check for 'Cache-control: immutable'.
2693             If the resource is not expired don't revalidate it.
2694
2695         * platform/network/CacheValidation.cpp:
2696         (WebCore::parseCacheControlDirectives):
2697         * platform/network/CacheValidation.h:
2698         * platform/network/ResourceResponseBase.cpp:
2699         (WebCore::ResourceResponseBase::cacheControlContainsImmutable):
2700         * platform/network/ResourceResponseBase.h:
2701
2702 2017-01-27  Youenn Fablet  <youennf@gmail.com>
2703
2704         [WebRTC] Use MediaEndPointPeerConnection if not using libwebrtc
2705         https://bugs.webkit.org/show_bug.cgi?id=167504
2706
2707         Reviewed by Alex Christensen.
2708
2709         No change of behavior.
2710
2711         * Modules/mediastream/MediaEndpointPeerConnection.cpp: If libwebrtc, we should use libwebrtc peer connection backend.
2712
2713 2017-01-27  Ryan Haddad  <ryanhaddad@apple.com>
2714
2715         Rebaseline bindings tests after r211238.
2716
2717         Unreviewed test gardening.
2718
2719         * bindings/scripts/test/JS/JSTestDOMJIT.cpp:
2720         (WebCore::JSTestDOMJIT::visitChildren):
2721         * bindings/scripts/test/JS/JSTestEventTarget.cpp:
2722         (WebCore::JSTestEventTarget::visitChildren):
2723         * bindings/scripts/test/JS/JSTestNode.cpp:
2724         (WebCore::JSTestNode::visitChildren):
2725
2726 2017-01-25  Sergio Villar Senin  <svillar@igalia.com>
2727
2728         [css-grid] Move Grid class out of RenderGrid
2729         https://bugs.webkit.org/show_bug.cgi?id=167418
2730
2731         Reviewed by Antti Koivisto.
2732
2733         The RenderGrid should be able to use different implementations of
2734         the Grid class. The latter is big enough to be in its own file. That
2735         would help on the effort of moving the grid track sizing algorithm
2736         out of RenderGrid too.
2737
2738         No new tests required as we're just moving code.
2739
2740         * CMakeLists.txt:
2741         * rendering/Grid.cpp: Added.
2742         (WebCore::Grid::Grid):
2743         (WebCore::Grid::numTracks):
2744         (WebCore::Grid::ensureGridSize):
2745         (WebCore::Grid::insert):
2746         (WebCore::Grid::setSmallestTracksStart):
2747         (WebCore::Grid::smallestTrackStart):
2748         (WebCore::Grid::gridItemArea):
2749         (WebCore::Grid::setGridItemArea):
2750         (WebCore::Grid::setAutoRepeatTracks):
2751         (WebCore::Grid::autoRepeatTracks):
2752         (WebCore::Grid::setAutoRepeatEmptyColumns):
2753         (WebCore::Grid::setAutoRepeatEmptyRows):
2754         (WebCore::Grid::hasAutoRepeatEmptyTracks):
2755         (WebCore::Grid::isEmptyAutoRepeatTrack):
2756         (WebCore::Grid::autoRepeatEmptyTracks):
2757         (WebCore::Grid::gridItemSpan):
2758         (WebCore::Grid::setNeedsItemsPlacement):
2759         (WebCore::GridIterator::GridIterator):
2760         (WebCore::GridIterator::nextGridItem):
2761         (WebCore::GridIterator::isEmptyAreaEnough):
2762         (WebCore::GridIterator::nextEmptyGridArea):
2763         * rendering/Grid.h: Added.
2764         * rendering/RenderGrid.cpp:
2765         (WebCore::RenderGrid::computeEmptyTracksForAutoRepeat):
2766         (WebCore::RenderGrid::Grid::numTracks): Deleted.
2767         (WebCore::RenderGrid::Grid::ensureGridSize): Deleted.
2768         (WebCore::RenderGrid::Grid::insert): Deleted.
2769         (WebCore::RenderGrid::Grid::setSmallestTracksStart): Deleted.
2770         (WebCore::RenderGrid::Grid::smallestTrackStart): Deleted.
2771         (WebCore::RenderGrid::Grid::gridItemArea): Deleted.
2772         (WebCore::RenderGrid::Grid::setGridItemArea): Deleted.
2773         (WebCore::RenderGrid::Grid::setAutoRepeatTracks): Deleted.
2774         (WebCore::RenderGrid::Grid::autoRepeatTracks): Deleted.
2775         (WebCore::RenderGrid::Grid::setAutoRepeatEmptyColumns): Deleted.
2776         (WebCore::RenderGrid::Grid::setAutoRepeatEmptyRows): Deleted.
2777         (WebCore::RenderGrid::Grid::hasAutoRepeatEmptyTracks): Deleted.
2778         (WebCore::RenderGrid::Grid::isEmptyAutoRepeatTrack): Deleted.
2779         (WebCore::RenderGrid::Grid::autoRepeatEmptyTracks): Deleted.
2780         (WebCore::RenderGrid::Grid::gridItemSpan): Deleted.
2781         (WebCore::RenderGrid::Grid::setNeedsItemsPlacement): Deleted.
2782         (WebCore::RenderGrid::GridIterator::GridIterator): Deleted.
2783         (WebCore::RenderGrid::GridIterator::nextGridItem): Deleted.
2784         (WebCore::RenderGrid::GridIterator::isEmptyAreaEnough): Deleted.
2785         (WebCore::RenderGrid::GridIterator::nextEmptyGridArea): Deleted.
2786         * rendering/RenderGrid.h:
2787
2788 2017-01-27  Yusuke Suzuki  <utatane.tea@gmail.com>
2789
2790         Implement dynamic-import for WebCore
2791         https://bugs.webkit.org/show_bug.cgi?id=166926
2792
2793         Reviewed by Ryosuke Niwa.
2794
2795         This patch introduces browser side dynamic-import implementation.
2796         The dynamic-import is new ES feature which is now stage 3.
2797         The JSC shell already implements it.
2798
2799         The dynamic-import allows us to kick module loading in a dynamic manner.
2800         For example, you can write,
2801
2802             await module = import(`${HOST}/hello.js`);
2803
2804         The dynamic `import` operator (this is not a function) returns a promise with
2805         module namespace object if the module loading succeeds. Otherwise, it returns
2806         a rejected promise.
2807
2808         And importantly, this feature allows us to kick module loading from classic script.
2809         Previously, module loading can be only used from <script type="module"> tag. And
2810         all the module loading is done statically.
2811
2812         * CMakeLists.txt:
2813         * WebCore.xcodeproj/project.pbxproj:
2814         * bindings/js/CachedModuleScriptLoader.cpp:
2815         (WebCore::CachedModuleScriptLoader::load):
2816         * bindings/js/CachedScriptFetcher.cpp:
2817         (WebCore::CachedScriptFetcher::create):
2818         (WebCore::CachedScriptFetcher::requestModuleScript):
2819         requestModuleScript function is used only when loading a new module script.
2820         So, LoadableClassicScript should use requestScriptWithCache to load itself.
2821         We pass String() for cross origin mode for null cross origin attribute as
2822         specified.
2823
2824         (WebCore::CachedScriptFetcher::requestScriptWithCache):
2825         * bindings/js/CachedScriptFetcher.h:
2826         (WebCore::CachedScriptFetcher::CachedScriptFetcher):
2827         * bindings/js/JSDOMWindowBase.cpp:
2828         (WebCore::JSDOMWindowBase::moduleLoaderImportModule):
2829         * bindings/js/JSDOMWindowBase.h:
2830         * bindings/js/JSLazyEventListener.cpp:
2831         (WebCore::JSLazyEventListener::initializeJSFunction):
2832         * bindings/js/ScriptController.cpp:
2833         (WebCore::ScriptController::executeScript):
2834         * bindings/js/ScriptModuleLoader.cpp:
2835         (WebCore::resolveModuleSpecifier):
2836         Extract the part of resolving module specifier to a static function to use
2837         it in ScriptModuleLoader::resolve and ScriptModuleLoader::importModule.
2838
2839         (WebCore::ScriptModuleLoader::resolve):
2840         (WebCore::rejectPromise):
2841         (WebCore::ScriptModuleLoader::importModule):
2842         New hook moduleLoaderImportModule is implemented. This hook is called when
2843         `import` operator is used. This hook is responsible to
2844             1. resolve the module name to obtain module specifier. (like, resolve the
2845                 relative URL to get absolute URL.)
2846             2. kick module loading with the resolved specifier.
2847         When resolving the module name, the referrer information is needed.
2848         For example, "./script.js" will be resolved to "http://example.com/script.js" if
2849         the referrer module specifier is "http://example.com/".
2850         If `import("./script.js")` is executed in the classic script
2851         src="http://example.com/test.js", it starts loading "http://example.com/script.js".
2852         So the information of the caller of `import` operator is necessary here.
2853         This appropriate referrer is propagated by SourceOrigin.
2854
2855         * bindings/js/ScriptModuleLoader.h:
2856         * dom/InlineClassicScript.h:
2857         * dom/LoadableClassicScript.cpp:
2858         (WebCore::LoadableClassicScript::load):
2859         * dom/LoadableClassicScript.h:
2860         * dom/LoadableModuleScript.h:
2861         * dom/LoadableScript.h:
2862         (WebCore::LoadableScript::LoadableScript):
2863         (WebCore::LoadableScript::isClassicScript): Deleted.
2864         (WebCore::LoadableScript::isModuleScript): Deleted.
2865         * dom/ScriptElement.h:
2866         * dom/ScriptElementCachedScriptFetcher.cpp: Copied from Source/WebCore/dom/InlineClassicScript.h.
2867         (WebCore::ScriptElementCachedScriptFetcher::requestModuleScript):
2868         This requestModuleScript will be used when the script tag (or modules imported from the script tag) uses `import` operator.
2869         In classic scripts, `crossorigin` mode always becomes "omit" while module scripts
2870         propagate the original `crossorigin` value.
2871
2872         * dom/ScriptElementCachedScriptFetcher.h: Copied from Source/WebCore/bindings/js/CachedScriptFetcher.h.
2873         (WebCore::ScriptElementCachedScriptFetcher::crossOriginMode):
2874         (WebCore::ScriptElementCachedScriptFetcher::ScriptElementCachedScriptFetcher):
2875
2876 2017-01-26  Chris Dumez  <cdumez@apple.com>
2877
2878         Revert r210474 it is no longer needed
2879         https://bugs.webkit.org/show_bug.cgi?id=167487
2880
2881         Reviewed by Daniel Bates.
2882
2883         Revert r210474 it is no longer needed after r211254.
2884
2885         * dom/Document.cpp:
2886         (WebCore::Document::canNavigate):
2887         * html/HTMLAnchorElement.cpp:
2888         (WebCore::HTMLAnchorElement::handleClick):
2889         * html/HTMLLinkElement.cpp:
2890         (WebCore::HTMLLinkElement::handleClick):
2891         * loader/FrameLoader.cpp:
2892         (WebCore::FrameLoader::urlSelected):
2893         (WebCore::FrameLoader::submitForm):
2894         (WebCore::FrameLoader::loadFrameRequest):
2895         * mathml/MathMLElement.cpp:
2896         (WebCore::MathMLElement::defaultEventHandler):
2897         * svg/SVGAElement.cpp:
2898         (WebCore::SVGAElement::defaultEventHandler):
2899
2900 2017-01-26  Youenn Fablet  <youennf@gmail.com>
2901
2902         [WebRTC] Implement WebRTC PeerConnection backend based on libwebrtc
2903         https://bugs.webkit.org/show_bug.cgi?id=167289
2904
2905         Reviewed by Alex Christensen.
2906
2907         Introducing an initial implementation of WebRTC peer connection backend based on LibWebRTC.
2908         This is done behind a compilation flag which is off by default, until the implementation is ready.
2909
2910         The backend implements the PeerConnectionBackend API.
2911         The implementation is split into LibWebRTCPeerConnectionBackend which contains mostly generic code and
2912         passes the real work to LibWebRTCMediaEndpoint.
2913         The latter class is implementing the API using LibWebRTC.
2914
2915         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: Added.
2916         (WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
2917         (WebCore::sessionDescriptionType):
2918         (WebCore::LibWebRTCMediaEndpoint::doSetLocalDescription):
2919         (WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription):
2920         (WebCore::LibWebRTCMediaEndpoint::addPendingIceCandidates):
2921         (WebCore::streamId):
2922         (WebCore::LibWebRTCMediaEndpoint::doCreateOffer):
2923         (WebCore::LibWebRTCMediaEndpoint::doCreateAnswer):
2924         (WebCore::LibWebRTCMediaEndpoint::getStats):
2925         (WebCore::LibWebRTCMediaEndpoint::StatsCollector::StatsCollector):
2926         (WebCore::LibWebRTCMediaEndpoint::StatsCollector::OnStatsDelivered):
2927         (WebCore::signalingState):
2928         (WebCore::LibWebRTCMediaEndpoint::OnSignalingChange):
2929         (WebCore::trackId):
2930         (WebCore::createMediaStreamTrack):
2931         (WebCore::LibWebRTCMediaEndpoint::addStream):
2932         (WebCore::LibWebRTCMediaEndpoint::OnAddStream):
2933         (WebCore::LibWebRTCMediaEndpoint::OnRemoveStream):
2934         (WebCore::LibWebRTCMediaEndpoint::OnDataChannel):
2935         (WebCore::LibWebRTCMediaEndpoint::stop):
2936         (WebCore::LibWebRTCMediaEndpoint::OnRenegotiationNeeded):
2937         (WebCore::iceConnectionState):
2938         (WebCore::LibWebRTCMediaEndpoint::OnIceConnectionChange):
2939         (WebCore::LibWebRTCMediaEndpoint::OnIceGatheringChange):
2940         (WebCore::LibWebRTCMediaEndpoint::OnIceCandidate):
2941         (WebCore::LibWebRTCMediaEndpoint::OnIceCandidatesRemoved):
2942         (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionSucceeded):
2943         (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionFailed):
2944         (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionSucceeded):
2945         (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed):
2946         (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionSucceeded):
2947         (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed):
2948         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h: Added.
2949         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: Added.
2950         (WebCore::createLibWebRTCPeerConnectionBackend):
2951         (WebCore::libWebRTCProvider):
2952         (WebCore::LibWebRTCPeerConnectionBackend::LibWebRTCPeerConnectionBackend):
2953         (WebCore::configurationFromMediaEndpointConfiguration):
2954         (WebCore::LibWebRTCPeerConnectionBackend::setConfiguration):
2955         (WebCore::LibWebRTCPeerConnectionBackend::getStats):
2956         (WebCore::LibWebRTCPeerConnectionBackend::doSetLocalDescription):
2957         (WebCore::LibWebRTCPeerConnectionBackend::doSetRemoteDescription):
2958         (WebCore::LibWebRTCPeerConnectionBackend::doCreateOffer):
2959         (WebCore::LibWebRTCPeerConnectionBackend::doCreateAnswer):
2960         (WebCore::LibWebRTCPeerConnectionBackend::doStop):
2961         (WebCore::LibWebRTCPeerConnectionBackend::doAddIceCandidate):
2962         (WebCore::LibWebRTCPeerConnectionBackend::markAsNeedingNegotiation):
2963         (WebCore::LibWebRTCPeerConnectionBackend::createReceiver):
2964         (WebCore::LibWebRTCPeerConnectionBackend::createDataChannelHandler):
2965         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: Added.
2966         * WebCore.xcodeproj/project.pbxproj:
2967
2968 2017-01-26  Chris Dumez  <cdumez@apple.com>
2969
2970         Crash when navigating back to a page in PacheCache when one of its frames has been removed
2971         https://bugs.webkit.org/show_bug.cgi?id=167421
2972         <rdar://problem/30188490>
2973
2974         Reviewed by Darin Adler.
2975
2976         Disallow page caching of a page if:
2977         1. The main window has an opener (i.e. it was opened via window.open)
2978         2. It has ever used window.open()
2979
2980         This is because allowing page caching in this case would allow such
2981         windows to script each other even after one of them entered Page
2982         Cache. Allowing this is dangerous and easily causes crashes.
2983
2984         This is a short term workaround until we find a better solution to
2985         the problem. One issue is this workaround is that navigating back
2986         to a page that has an opener or used window.open() will not longer
2987         get the page from PageCache. As a result, state may be lost upon
2988         navigating back. However, we never guarantee that pages get page
2989         cached, and Chrome does not have a PageCache.
2990
2991         Tests: fast/history/page-cache-after-window-open.html
2992                fast/history/page-cache-back-navigation-crash.html
2993                fast/history/page-cache-with-opener.html
2994
2995         * dom/Document.cpp:
2996         (WebCore::Document::hasEverCalledWindowOpen):
2997         (WebCore::Document::markHasCalledWindowOpen):
2998         * dom/Document.h:
2999         * history/PageCache.cpp:
3000         (WebCore::canCachePage):
3001         * page/DOMWindow.cpp:
3002         (WebCore::DOMWindow::createWindow):
3003         * page/DiagnosticLoggingKeys.cpp:
3004         (WebCore::DiagnosticLoggingKeys::hasCalledWindowOpenKey):
3005         (WebCore::DiagnosticLoggingKeys::hasOpenerKey):
3006         * page/DiagnosticLoggingKeys.h:
3007         * page/Page.cpp:
3008         (WebCore::Page::openedByWindowOpen):
3009         * page/Page.h:
3010         * page/Settings.in:
3011
3012 2017-01-26  Youenn Fablet  <youennf@gmail.com>
3013
3014         [WebRTC] Add a LibWebRTC mock for testing
3015         https://bugs.webkit.org/show_bug.cgi?id=167429
3016
3017         Reviewed by Alex Christensen.
3018
3019         Covered by updated tests although feature is behind a flag, off by default.
3020         MockLibWebRTCPeerConnection will allow us testing the code above the WebRTC implementation above LibWebRTC,
3021         without reyling on it and controlling the way that the peer connections will behave.
3022         Adding support for mock factory to create real peer connections in case where we want to do full testing through the local loopback.
3023
3024         Tests: fast/mediastream/getUserMedia-webaudio.html
3025                webrtc/datachannel/basic.html
3026                webrtc/video.html
3027
3028         * WebCore.xcodeproj/project.pbxproj:
3029         * testing/Internals.cpp:
3030         (WebCore::Internals::Internals):
3031         (WebCore::Internals::useMockRTCPeerConnectionFactory):
3032         * testing/Internals.h:
3033         * testing/Internals.idl:
3034         * testing/MockLibWebRTCPeerConnection.cpp: Added.
3035         (WebCore::useMockRTCPeerConnectionFactory):
3036         (WebCore::MockLibWebRTCPeerConnectionForIceCandidates::MockLibWebRTCPeerConnectionForIceCandidates):
3037         (WebCore::MockLibWebRTCPeerConnectionForIceCandidates::gotLocalDescription):
3038         (WebCore::MockLibWebRTCPeerConnectionForIceConnectionState::MockLibWebRTCPeerConnectionForIceConnectionState):
3039         (WebCore::MockLibWebRTCPeerConnectionForIceConnectionState::gotLocalDescription):
3040         (WebCore::MockLibWebRTCPeerConnectionFactory::MockLibWebRTCPeerConnectionFactory):
3041         (WebCore::MockLibWebRTCPeerConnectionFactory::CreatePeerConnection):
3042         (WebCore::MockLibWebRTCPeerConnectionFactory::CreateLocalMediaStream):
3043         (WebCore::MockLibWebRTCPeerConnection::SetLocalDescription):
3044         (WebCore::MockLibWebRTCPeerConnection::SetRemoteDescription):
3045         (WebCore::MockLibWebRTCPeerConnection::CreateDataChannel):
3046         (WebCore::MockLibWebRTCPeerConnection::AddStream):
3047         (WebCore::MockLibWebRTCPeerConnection::RemoveStream):
3048         (WebCore::MockLibWebRTCPeerConnection::CreateOffer):
3049         (WebCore::MockLibWebRTCPeerConnection::CreateAnswer):
3050         * testing/MockLibWebRTCPeerConnection.h: Added.
3051         (WebCore::MockLibWebRTCPeerConnection::~MockLibWebRTCPeerConnection):
3052         (WebCore::MockLibWebRTCPeerConnection::MockLibWebRTCPeerConnection):
3053         (WebCore::MockLibWebRTCPeerConnection::local_streams):
3054         (WebCore::MockLibWebRTCPeerConnection::remote_streams):
3055         (WebCore::MockLibWebRTCPeerConnection::CreateDtmfSender):
3056         (WebCore::MockLibWebRTCPeerConnection::GetStats):
3057         (WebCore::MockLibWebRTCPeerConnection::local_description):
3058         (WebCore::MockLibWebRTCPeerConnection::remote_description):
3059         (WebCore::MockLibWebRTCPeerConnection::AddIceCandidate):
3060         (WebCore::MockLibWebRTCPeerConnection::RegisterUMAObserver):
3061         (WebCore::MockLibWebRTCPeerConnection::signaling_state):
3062         (WebCore::MockLibWebRTCPeerConnection::ice_connection_state):
3063         (WebCore::MockLibWebRTCPeerConnection::ice_gathering_state):
3064         (WebCore::MockLibWebRTCPeerConnection::StopRtcEventLog):
3065         (WebCore::MockLibWebRTCPeerConnection::Close):
3066         (WebCore::MockLibWebRTCPeerConnection::gotLocalDescription):
3067         (WebCore::MockLibWebRTCIceCandidate::MockLibWebRTCIceCandidate):
3068         (WebCore::MockLibWebRTCAudioTrack::MockLibWebRTCAudioTrack):
3069         (WebCore::MockLibWebRTCVideoTrack::MockLibWebRTCVideoTrack):
3070         (WebCore::MockLibWebRTCDataChannel::MockLibWebRTCDataChannel):
3071         (WebCore::MockLibWebRTCPeerConnectionFactory::create):
3072
3073 2017-01-26  Jeremy Jones  <jeremyj@apple.com>
3074
3075         Page should be able to request pointer lock without user gesture if it relinquished it without a user gesture
3076         https://bugs.webkit.org/show_bug.cgi?id=167126
3077
3078         Reviewed by Jon Lee.
3079
3080         Enabled pointer-lock/locked-element-removed-from-dom.html for WK2.
3081         Not enable in WK1 because of https://bugs.webkit.org/show_bug.cgi?id=167127
3082
3083         This change allows a page to lock the pointer again without a user gesture if it was unlocked by
3084         the page and not by the user. See https://www.w3.org/TR/2016/REC-pointerlock-20161027/ 5.1 Methods
3085
3086         * page/PointerLockController.cpp:
3087
3088         When a document acquires pointer lock with a user gesture, that document is allowed to request pointer lock again
3089         until the user takes an action to end pointer lock. We know it is a user action because user actions always
3090         call requestPointerUnlockAndForceCursorVisible().
3091
3092         When the page requests a pointer unlock (via requestPointerUnlock), that document is allowed to continue to relock
3093         the page. This continues until there is either an unlock request form the user 
3094         via requestPointerUnlockAndForceCursorVisible or a didLosePointerLock without a pointer unlock request.
3095
3096         (WebCore::PointerLockController::PointerLockController):
3097         (WebCore::PointerLockController::requestPointerLock):
3098         (WebCore::PointerLockController::requestPointerUnlock):
3099         (WebCore::PointerLockController::requestPointerUnlockAndForceCursorVisible):
3100         (WebCore::PointerLockController::elementRemoved):
3101         (WebCore::PointerLockController::documentDetached):
3102         (WebCore::PointerLockController::didAcquirePointerLock):
3103         (WebCore::PointerLockController::didLosePointerLock):
3104         (WebCore::PointerLockController::clearElement):
3105         * page/PointerLockController.h:
3106
3107 2017-01-26  Andy Estes  <aestes@apple.com>
3108
3109         [QuickLook] REGRESSION (WebKit2): Requests are made to invalid x-apple-ql-id: URLs
3110         https://bugs.webkit.org/show_bug.cgi?id=167453
3111
3112         Reviewed by Brent Fulgham.
3113
3114         Requests to x-apple-ql-id: URLs should be filtered by
3115         -[QLPreviewConverter safeRequestForRequest:]. This method checks that the URL is one of the
3116         ones generated for the current preview, and changes it to "about:" if it isn't.
3117
3118         WebCore::safeQLURLForDocumentURLAndResourceURL() was responsible for finding the
3119         QLPreviewConverter instance to use by looking it up in an NSMutableDictionary using the
3120         document URL as a key. In WebKit1, this dictionary was populated by the
3121         QuickLookHandleClient when new QuickLookHandles were created, but the WebKit2
3122         QuickLookHandleClient never did this. As a result, requests to invalid URLs were not being
3123         rewritten.
3124
3125         An easy way to load a QuickLook document with invalid URLs is to create an HTML file with a
3126         Microsoft Office extension (e.g. .xls); QuickLook, iWork, and Office support opening HTML
3127         files with Office document extensions. In r207155 we applied a Content Security Policy to
3128         QuickLook documents that only allows x-apple-ql-id: resources to load. This blocked
3129         cross-origin requests from loading, but same-origin requests to URLs that weren't generated
3130         by QLPreviewConverter were still allowed to load.
3131
3132         This change blocks these URLs by calling -[QLPreviewConverter safeRequestForRequest:] in a
3133         way that works for both WebKit1 and WebKit2.
3134
3135         After implementing QuickLook for WebKit2, we found a bug when loading HTML-as-Office
3136         documents (webkit.org/b/135651) that presented as a nil MIME type in the preview
3137         NSURLResponse returned by QLPreviewConverter. Unfortunately r172159 papered over the actual
3138         bug by failing to load previews with nil MIME types.
3139
3140         The real issue was that we were asking for the preview response before QuickLook had
3141         received enough data to determine a MIME type, so this change also removes the bad fix from
3142         r172159 and instead waits until QuickLook has converted the document to ask for its preview
3143         response. This restores the ability to load HTML files with Office document extensions.
3144         These two fixes are combined in a single patch because I don't know how to create an invalid
3145         QuickLook URL for testing without loading an HTML-as-Office document.
3146
3147         Test: quicklook/invalid-ql-id-url.html
3148
3149         * loader/ResourceLoader.cpp:
3150         (WebCore::ResourceLoader::willSendRequestInternal): Called
3151         QuickLookHandle::willSendRequest() if m_documentLoader has a QuickLookHandle.
3152         * loader/cache/CachedResource.cpp:
3153         (WebCore::CachedResource::load): Removed the call to
3154         WebCore::safeQLURLForDocumentURLAndResourceURL().
3155         * loader/ios/QuickLook.h: Removed safeQLURLForDocumentURLAndResourceURL() and declared
3156         QuickLookHandle::willSendRequest().
3157         * loader/ios/QuickLook.mm: Removed _previewResponse and _hasFailed ivars from
3158         WebPreviewConverter.
3159         (-[WebPreviewConverter initWithResourceLoader:resourceResponse:quickLookHandle:]): Stopped
3160         setting _previewResponse.
3161         (-[WebPreviewConverter _sendDidReceiveResponseIfNecessary]): Only emptied _bufferedDataArray
3162         if we haven't already called -_sendDidReceiveResponseIfNecessary; removed the check for a
3163         nil _previewResponse MIME type; accessed -[QLPreviewConverter previewResponse] now that the
3164         document has been converted and asserted its MIME type is non-nil.
3165         (-[WebPreviewConverter connection:didReceiveData:lengthReceived:]): Removed _hasFailed check.
3166         (-[WebPreviewConverter connectionDidFinishLoading:]): Ditto.
3167         (isQuickLookPasswordError): Moved the check for password failure errors to here from
3168         -connection:didFailWithError: for better readability.
3169         (-[WebPreviewConverter connection:didFailWithError:]): Removed _hasFailed check and used
3170         more early returns.
3171         (WebCore::QuickLookHandle::willSendRequest): Filtered the request through
3172         -[QLPreviewConverter safeRequestWithRequest:] if the request URL's scheme is x-apple-ql-id:.
3173         (WebCore::safeQLURLForDocumentURLAndResourceURL): Deleted.
3174
3175 2017-01-26  Keith Miller  <keith_miller@apple.com>
3176
3177         classInfo should take a VM so it is not materialized from the object on each call
3178         https://bugs.webkit.org/show_bug.cgi?id=167424
3179
3180         Rubber Stamped by Michael Saboff.
3181
3182         Previously, classInfo() would get the VM from the target's
3183         MarkedBlock.  Most callers already have a VM on hand, so it is
3184         wasteful to compute the VM from the marked block every time. This
3185         patch refactors some of the most common callers of classInfo(),
3186         jsDynamicCast and inherits to take a VM as well.
3187
3188         * Modules/fetch/FetchBody.cpp:
3189         (WebCore::FetchBody::extract):
3190         * Modules/plugins/QuickTimePluginReplacement.mm:
3191         (WebCore::QuickTimePluginReplacement::installReplacement):
3192         * bindings/js/IDBBindingUtilities.cpp:
3193         (WebCore::createIDBKeyFromValue):
3194         * bindings/js/JSCommandLineAPIHostCustom.cpp:
3195         (WebCore::JSCommandLineAPIHost::getEventListeners):
3196         (WebCore::JSCommandLineAPIHost::databaseId):
3197         (WebCore::JSCommandLineAPIHost::storageId):
3198         * bindings/js/JSCryptoAlgorithmDictionary.cpp:
3199         (WebCore::JSCryptoAlgorithmDictionary::parseAlgorithmIdentifier):
3200         (WebCore::createRsaKeyGenParams):
3201         * bindings/js/JSCryptoCustom.cpp:
3202         (WebCore::JSCrypto::getRandomValues):
3203         * bindings/js/JSCryptoOperationData.cpp:
3204         (WebCore::cryptoOperationDataFromJSValue):
3205         * bindings/js/JSCustomElementInterface.cpp:
3206         (WebCore::constructCustomElementSynchronously):
3207         (WebCore::JSCustomElementInterface::upgradeElement):
3208         * bindings/js/JSDOMBinding.cpp:
3209         (WebCore::valueToDate):
3210         (WebCore::reportException):
3211         (WebCore::retrieveErrorMessage):
3212         * bindings/js/JSDOMBinding.h:
3213         (WebCore::castThisValue):
3214         (WebCore::toPossiblySharedArrayBufferView):
3215         (WebCore::toUnsharedArrayBufferView):
3216         (WebCore::toPossiblySharedInt8Array):
3217         (WebCore::toPossiblySharedInt16Array):
3218         (WebCore::toPossiblySharedInt32Array):
3219         (WebCore::toPossiblySharedUint8Array):
3220         (WebCore::toPossiblySharedUint8ClampedArray):
3221         (WebCore::toPossiblySharedUint16Array):
3222         (WebCore::toPossiblySharedUint32Array):
3223         (WebCore::toPossiblySharedFloat32Array):
3224         (WebCore::toPossiblySharedFloat64Array):
3225         (WebCore::toUnsharedInt8Array):
3226         (WebCore::toUnsharedInt16Array):
3227         (WebCore::toUnsharedInt32Array):
3228         (WebCore::toUnsharedUint8Array):
3229         (WebCore::toUnsharedUint8ClampedArray):
3230         (WebCore::toUnsharedUint16Array):
3231         (WebCore::toUnsharedUint32Array):
3232         (WebCore::toUnsharedFloat32Array):
3233         (WebCore::toUnsharedFloat64Array):
3234         (WebCore::toRefNativeArray):
3235         * bindings/js/JSDOMConstructor.h:
3236         (WebCore::JSDOMConstructorNotConstructable<JSClass>::finishCreation):
3237         (WebCore::JSDOMConstructor<JSClass>::finishCreation):
3238         (WebCore::JSDOMNamedConstructor<JSClass>::finishCreation):
3239         (WebCore::JSBuiltinConstructor<JSClass>::finishCreation):
3240         * bindings/js/JSDOMConvert.h:
3241         (WebCore::Converter<IDLInterface<T>>::convert):
3242         (WebCore::Converter<IDLXPathNSResolver<T>>::convert):
3243         * bindings/js/JSDOMGlobalObject.cpp:
3244         (WebCore::JSDOMGlobalObject::finishCreation):
3245         (WebCore::JSDOMGlobalObject::scriptExecutionContext):
3246         * bindings/js/JSDOMIterator.h:
3247         (WebCore::IteratorTraits>::next):
3248         (WebCore::IteratorTraits>::finishCreation):
3249         * bindings/js/JSDOMWindowBase.cpp:
3250         (WebCore::JSDOMWindowBase::finishCreation):
3251         (WebCore::toJSDOMWindow):
3252         * bindings/js/JSDOMWindowBase.h:
3253         * bindings/js/JSDOMWindowCustom.cpp:
3254         (WebCore::jsDOMWindowWebKit):
3255         (WebCore::JSDOMWindow::toWrapped):
3256         * bindings/js/JSDOMWindowShell.cpp:
3257         (WebCore::JSDOMWindowShell::finishCreation):
3258         (WebCore::JSDOMWindowShell::toWrapped):
3259         * bindings/js/JSDOMWindowShell.h:
3260         * bindings/js/JSDocumentCustom.cpp:
3261         (WebCore::cachedDocumentWrapper):
3262         (WebCore::JSDocument::createTouchList):
3263         * bindings/js/JSDynamicDowncast.h:
3264         (WebCore::JSDynamicCastTrait::cast):
3265         (WebCore::JSDynamicCastTrait<JSNode>::cast):
3266         (WebCore::JSDynamicCastTrait<JSElement>::cast):
3267         (WebCore::JSDynamicCastTrait<JSDocument>::cast):
3268         (WebCore::JSDynamicCastTrait<JSEvent>::cast):
3269         (WebCore::jsDynamicDowncast):
3270         * bindings/js/JSEventListener.cpp:
3271         (WebCore::JSEventListener::handleEvent):
3272         * bindings/js/JSEventTargetCustom.cpp:
3273         (WebCore::JSEventTarget::toWrapped):
3274         (WebCore::jsEventTargetCast):
3275         * bindings/js/JSEventTargetCustom.h:
3276         (WebCore::BindingCaller<JSEventTarget>::callOperation):
3277         * bindings/js/JSExceptionBase.cpp:
3278         (WebCore::toExceptionBase):
3279         * bindings/js/JSExceptionBase.h:
3280         * bindings/js/JSInspectorFrontendHostCustom.cpp:
3281         (WebCore::populateContextMenuItems):
3282         (WebCore::JSInspectorFrontendHost::showContextMenu):
3283         * bindings/js/JSNodeCustom.cpp:
3284         (WebCore::JSNode::insertBefore):
3285         (WebCore::JSNode::replaceChild):
3286         (WebCore::JSNode::removeChild):
3287         (WebCore::JSNode::appendChild):
3288         (WebCore::JSNode::pushEventHandlerScope):
3289         * bindings/js/JSPluginElementFunctions.cpp:
3290         (WebCore::pluginElementPropertyGetter):
3291         * bindings/js/JSReadableStreamPrivateConstructors.cpp:
3292         (WebCore::constructJSReadableStreamDefaultReader):
3293         * bindings/js/JSReadableStreamSourceCustom.cpp:
3294         (WebCore::startReadableStream):
3295         (WebCore::JSReadableStreamSource::start):
3296         (WebCore::pullReadableStream):
3297         * bindings/js/JSSubtleCryptoCustom.cpp:
3298         (WebCore::toCryptoKey):
3299         (WebCore::jsSubtleCryptoFunctionEncryptPromise):
3300         (WebCore::jsSubtleCryptoFunctionDecryptPromise):
3301         (WebCore::jsSubtleCryptoFunctionSignPromise):
3302         (WebCore::jsSubtleCryptoFunctionVerifyPromise):
3303         (WebCore::jsSubtleCryptoFunctionDigestPromise):
3304         (WebCore::jsSubtleCryptoFunctionWrapKeyPromise):
3305         (WebCore::jsSubtleCryptoFunctionUnwrapKeyPromise):
3306         * bindings/js/JSTrackCustom.cpp:
3307         (WebCore::toTrack): Deleted.
3308         * bindings/js/JSTrackCustom.h:
3309         * bindings/js/JSWebKitSubtleCryptoCustom.cpp:
3310         (WebCore::JSWebKitSubtleCrypto::encrypt):
3311         (WebCore::JSWebKitSubtleCrypto::decrypt):
3312         (WebCore::JSWebKitSubtleCrypto::sign):
3313         (WebCore::JSWebKitSubtleCrypto::verify):
3314         (WebCore::JSWebKitSubtleCrypto::exportKey):
3315         (WebCore::JSWebKitSubtleCrypto::wrapKey):
3316         (WebCore::JSWebKitSubtleCrypto::unwrapKey):
3317         * bindings/js/JSWorkerGlobalScopeBase.cpp:
3318         (WebCore::JSWorkerGlobalScopeBase::finishCreation):
3319         (WebCore::toJSDedicatedWorkerGlobalScope):
3320         (WebCore::toJSWorkerGlobalScope):
3321         * bindings/js/JSWorkerGlobalScopeBase.h:
3322         * bindings/js/JSXMLHttpRequestCustom.cpp:
3323         (WebCore::JSXMLHttpRequest::send):
3324         * bindings/js/JSXPathNSResolverCustom.cpp:
3325         (WebCore::JSXPathNSResolver::toWrapped):
3326         * bindings/js/ScriptController.cpp:
3327         (WebCore::ScriptController::setupModuleScriptHandlers):
3328         * bindings/js/ScriptModuleLoader.cpp:
3329         (WebCore::ScriptModuleLoader::fetch):
3330         (WebCore::ScriptModuleLoader::evaluate):
3331         * bindings/js/ScriptState.cpp:
3332         (WebCore::domWindowFromExecState):
3333         (WebCore::scriptExecutionContextFromExecState):
3334         * bindings/js/SerializedScriptValue.cpp:
3335         (WebCore::CloneSerializer::isArray):
3336         (WebCore::CloneSerializer::isMap):
3337         (WebCore::CloneSerializer::isSet):
3338         (WebCore::CloneSerializer::dumpArrayBufferView):
3339         (WebCore::CloneSerializer::dumpIfTerminal):
3340         (WebCore::CloneSerializer::serialize):
3341         (WebCore::CloneDeserializer::CloneDeserializer):
3342         (WebCore::CloneDeserializer::readArrayBufferView):
3343         (WebCore::CloneDeserializer::readTerminal):
3344         (WebCore::transferArrayBuffers):
3345         (WebCore::SerializedScriptValue::create):
3346         * bindings/js/StructuredClone.cpp:
3347         (WebCore::structuredCloneArrayBuffer):
3348         (WebCore::structuredCloneArrayBufferView):
3349         * bindings/js/WorkerScriptController.cpp:
3350         (WebCore::WorkerScriptController::evaluate):
3351         * bindings/scripts/CodeGeneratorJS.pm:
3352         (GenerateHeader):
3353         (GenerateOverloadedFunctionOrConstructor):
3354         (GenerateImplementation):
3355         * bindings/scripts/test/JS/JSInterfaceName.cpp:
3356         (WebCore::JSInterfaceName::finishCreation):
3357         (WebCore::jsInterfaceNameConstructor):
3358         (WebCore::setJSInterfaceNameConstructor):
3359         (WebCore::JSInterfaceName::toWrapped):
3360         * bindings/scripts/test/JS/JSInterfaceName.h:
3361         * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
3362         (WebCore::JSTestActiveDOMObject::finishCreation):
3363         (WebCore::BindingCaller<JSTestActiveDOMObject>::castForAttribute):
3364         (WebCore::BindingCaller<JSTestActiveDOMObject>::castForOperation):
3365         (WebCore::jsTestActiveDOMObjectConstructor):
3366         (WebCore::setJSTestActiveDOMObjectConstructor):
3367         (WebCore::JSTestActiveDOMObject::toWrapped):
3368         * bindings/scripts/test/JS/JSTestActiveDOMObject.h:
3369         * bindings/scripts/test/JS/JSTestCEReactions.cpp:
3370         (WebCore::JSTestCEReactions::finishCreation):
3371         (WebCore::BindingCaller<JSTestCEReactions>::castForAttribute):
3372         (WebCore::BindingCaller<JSTestCEReactions>::castForOperation):
3373         (WebCore::jsTestCEReactionsConstructor):
3374         (WebCore::setJSTestCEReactionsConstructor):
3375         (WebCore::JSTestCEReactions::toWrapped):
3376         * bindings/scripts/test/JS/JSTestCEReactions.h:
3377         * bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp:
3378         (WebCore::JSTestCEReactionsStringifier::finishCreation):
3379         (WebCore::BindingCaller<JSTestCEReactionsStringifier>::castForAttribute):
3380         (WebCore::BindingCaller<JSTestCEReactionsStringifier>::castForOperation):
3381         (WebCore::jsTestCEReactionsStringifierConstructor):
3382         (WebCore::setJSTestCEReactionsStringifierConstructor):
3383         (WebCore::JSTestCEReactionsStringifier::toWrapped):
3384         * bindings/scripts/test/JS/JSTestCEReactionsStringifier.h:
3385         * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.cpp:
3386         (WebCore::JSTestClassWithJSBuiltinConstructor::finishCreation):
3387         (WebCore::jsTestClassWithJSBuiltinConstructorConstructor):
3388         (WebCore::setJSTestClassWithJSBuiltinConstructorConstructor):
3389         (WebCore::JSTestClassWithJSBuiltinConstructor::toWrapped):
3390         * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h:
3391         * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp:
3392         (WebCore::JSTestCustomConstructorWithNoInterfaceObject::finishCreation):
3393         (WebCore::jsTestCustomConstructorWithNoInterfaceObjectConstructor):
3394         (WebCore::setJSTestCustomConstructorWithNoInterfaceObjectConstructor):
3395         (WebCore::JSTestCustomConstructorWithNoInterfaceObject::toWrapped):
3396         * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h:
3397         * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
3398         (WebCore::JSTestCustomNamedGetter::finishCreation):
3399         (WebCore::BindingCaller<JSTestCustomNamedGetter>::castForOperation):
3400         (WebCore::jsTestCustomNamedGetterConstructor):
3401         (WebCore::setJSTestCustomNamedGetterConstructor):
3402         (WebCore::JSTestCustomNamedGetter::toWrapped):
3403         * bindings/scripts/test/JS/JSTestCustomNamedGetter.h:
3404         * bindings/scripts/test/JS/JSTestDOMJIT.cpp:
3405         (WebCore::JSTestDOMJIT::finishCreation):
3406         (WebCore::BindingCaller<JSTestDOMJIT>::castForAttribute):
3407         (WebCore::BindingCaller<JSTestDOMJIT>::castForOperation):
3408         (WebCore::jsTestDOMJITConstructor):
3409         (WebCore::setJSTestDOMJITConstructor):
3410         * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
3411         (WebCore::JSTestEventConstructor::finishCreation):
3412         (WebCore::BindingCaller<JSTestEventConstructor>::castForAttribute):
3413         (WebCore::jsTestEventConstructorConstructor):
3414         (WebCore::setJSTestEventConstructorConstructor):
3415         * bindings/scripts/test/JS/JSTestEventTarget.cpp:
3416         (WebCore::JSTestEventTarget::finishCreation):
3417         (WebCore::BindingCaller<JSTestEventTarget>::castForOperation):
3418         (WebCore::jsTestEventTargetConstructor):
3419         (WebCore::setJSTestEventTargetConstructor):
3420         (WebCore::JSTestEventTarget::toWrapped):
3421         * bindings/scripts/test/JS/JSTestEventTarget.h:
3422         * bindings/scripts/test/JS/JSTestException.cpp:
3423         (WebCore::JSTestException::finishCreation):
3424         (WebCore::BindingCaller<JSTestException>::castForAttribute):
3425         (WebCore::jsTestExceptionConstructor):
3426         (WebCore::setJSTestExceptionConstructor):
3427         (WebCore::JSTestException::toWrapped):
3428         * bindings/scripts/test/JS/JSTestException.h:
3429         * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
3430         (WebCore::JSTestGenerateIsReachable::finishCreation):
3431         (WebCore::jsTestGenerateIsReachableConstructor):
3432         (WebCore::setJSTestGenerateIsReachableConstructor):
3433         (WebCore::JSTestGenerateIsReachable::toWrapped):
3434         * bindings/scripts/test/JS/JSTestGenerateIsReachable.h:
3435         * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
3436         (WebCore::JSTestGlobalObject::finishCreation):
3437         (WebCore::BindingCaller<JSTestGlobalObject>::castForAttribute):
3438         (WebCore::BindingCaller<JSTestGlobalObject>::castForOperation):
3439         (WebCore::jsTestGlobalObjectConstructor):
3440         (WebCore::setJSTestGlobalObjectConstructor):
3441         (WebCore::JSTestGlobalObject::toWrapped):
3442         * bindings/scripts/test/JS/JSTestGlobalObject.h:
3443         * bindings/scripts/test/JS/JSTestInterface.cpp:
3444         (WebCore::JSTestInterface::finishCreation):
3445         (WebCore::BindingCaller<JSTestInterface>::castForAttribute):
3446         (WebCore::BindingCaller<JSTestInterface>::castForOperation):
3447         (WebCore::jsTestInterfaceConstructor):
3448         (WebCore::setJSTestInterfaceConstructor):
3449         (WebCore::JSTestInterface::toWrapped):
3450         * bindings/scripts/test/JS/JSTestInterface.h:
3451         * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.cpp:
3452         (WebCore::JSTestInterfaceLeadingUnderscore::finishCreation):
3453         (WebCore::BindingCaller<JSTestInterfaceLeadingUnderscore>::castForAttribute):
3454         (WebCore::jsTestInterfaceLeadingUnderscoreConstructor):
3455         (WebCore::setJSTestInterfaceLeadingUnderscoreConstructor):
3456         (WebCore::JSTestInterfaceLeadingUnderscore::toWrapped):
3457         * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.h:
3458         * bindings/scripts/test/JS/JSTestIterable.cpp:
3459         (WebCore::JSTestIterable::finishCreation):
3460         (WebCore::BindingCaller<JSTestIterable>::castForOperation):
3461         (WebCore::jsTestIterableConstructor):
3462         (WebCore::setJSTestIterableConstructor):
3463         (WebCore::JSTestIterable::toWrapped):
3464         * bindings/scripts/test/JS/JSTestIterable.h:
3465         * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp:
3466         (WebCore::JSTestJSBuiltinConstructor::finishCreation):
3467         (WebCore::BindingCaller<JSTestJSBuiltinConstructor>::castForAttribute):
3468         (WebCore::BindingCaller<JSTestJSBuiltinConstructor>::castForOperation):
3469         (WebCore::jsTestJSBuiltinConstructorConstructor):
3470         (WebCore::setJSTestJSBuiltinConstructorConstructor):
3471         * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
3472         (WebCore::JSTestMediaQueryListListener::finishCreation):
3473         (WebCore::BindingCaller<JSTestMediaQueryListListener>::castForOperation):
3474         (WebCore::jsTestMediaQueryListListenerConstructor):
3475         (WebCore::setJSTestMediaQueryListListenerConstructor):
3476         (WebCore::JSTestMediaQueryListListener::toWrapped):
3477         * bindings/scripts/test/JS/JSTestMediaQueryListListener.h:
3478         * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
3479         (WebCore::JSTestNamedConstructor::finishCreation):
3480         (WebCore::jsTestNamedConstructorConstructor):
3481         (WebCore::setJSTestNamedConstructorConstructor):
3482         (WebCore::JSTestNamedConstructor::toWrapped):
3483         * bindings/scripts/test/JS/JSTestNamedConstructor.h:
3484         * bindings/scripts/test/JS/JSTestNode.cpp:
3485         (WebCore::JSTestNode::finishCreation):
3486         (WebCore::BindingCaller<JSTestNode>::castForAttribute):
3487         (WebCore::BindingCaller<JSTestNode>::castForOperation):
3488         (WebCore::jsTestNodeConstructor):
3489         (WebCore::setJSTestNodeConstructor):
3490         * bindings/scripts/test/JS/JSTestObj.cpp:
3491         (WebCore::JSTestObj::finishCreation):
3492         (WebCore::BindingCaller<JSTestObj>::castForAttribute):
3493         (WebCore::BindingCaller<JSTestObj>::castForOperation):
3494         (WebCore::jsTestObjConstructor):
3495         (WebCore::setJSTestObjConstructor):
3496         (WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
3497         (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter):
3498         (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithDistinguishingUnion):
3499         (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWith2DistinguishingUnions):
3500         (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithNonDistinguishingUnion):
3501         (WebCore::jsTestObjPrototypeFunctionOverloadWithNullableUnion):
3502         (WebCore::jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter):
3503         (WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction):
3504         (WebCore::JSTestObj::toWrapped):
3505         * bindings/scripts/test/JS/JSTestObj.h:
3506         * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
3507         (WebCore::JSTestOverloadedConstructorsConstructor::construct):
3508         (WebCore::JSTestOverloadedConstructors::finishCreation):
3509         (WebCore::jsTestOverloadedConstructorsConstructor):
3510         (WebCore::setJSTestOverloadedConstructorsConstructor):
3511         (WebCore::JSTestOverloadedConstructors::toWrapped):
3512         * bindings/scripts/test/JS/JSTestOverloadedConstructors.h:
3513         * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
3514         (WebCore::JSTestOverloadedConstructorsWithSequence::finishCreation):
3515         (WebCore::jsTestOverloadedConstructorsWithSequenceConstructor):
3516         (WebCore::setJSTestOverloadedConstructorsWithSequenceConstructor):
3517         (WebCore::JSTestOverloadedConstructorsWithSequence::toWrapped):
3518         * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.h:
3519         * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp:
3520         (WebCore::JSTestOverrideBuiltins::finishCreation):
3521         (WebCore::BindingCaller<JSTestOverrideBuiltins>::castForOperation):
3522         (WebCore::jsTestOverrideBuiltinsConstructor):
3523         (WebCore::setJSTestOverrideBuiltinsConstructor):
3524         (WebCore::JSTestOverrideBuiltins::toWrapped):
3525         * bindings/scripts/test/JS/JSTestOverrideBuiltins.h:
3526         * bindings/scripts/test/JS/JSTestSerialization.cpp:
3527         (WebCore::JSTestSerialization::finishCreation):
3528         (WebCore::BindingCaller<JSTestSerialization>::castForAttribute):
3529         (WebCore::BindingCaller<JSTestSerialization>::castForOperation):
3530         (WebCore::jsTestSerializationConstructor):
3531         (WebCore::setJSTestSerializationConstructor):
3532         (WebCore::JSTestSerialization::toWrapped):
3533         * bindings/scripts/test/JS/JSTestSerialization.h:
3534         * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
3535         (WebCore::JSTestSerializedScriptValueInterface::finishCreation):
3536         (WebCore::BindingCaller<JSTestSerializedScriptValueInterface>::castForAttribute):
3537         (WebCore::BindingCaller<JSTestSerializedScriptValueInterface>::castForOperation):
3538         (WebCore::jsTestSerializedScriptValueInterfaceConstructor):
3539         (WebCore::setJSTestSerializedScriptValueInterfaceConstructor):
3540         (WebCore::JSTestSerializedScriptValueInterface::toWrapped):
3541         * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:
3542         * bindings/scripts/test/JS/JSTestTypedefs.cpp:
3543         (WebCore::JSTestTypedefs::finishCreation):
3544         (WebCore::BindingCaller<JSTestTypedefs>::castForAttribute):
3545         (WebCore::BindingCaller<JSTestTypedefs>::castForOperation):
3546         (WebCore::jsTestTypedefsConstructor):
3547         (WebCore::setJSTestTypedefsConstructor):
3548         (WebCore::JSTestTypedefs::toWrapped):
3549         * bindings/scripts/test/JS/JSTestTypedefs.h:
3550         * bridge/c/CRuntimeObject.cpp:
3551         (JSC::Bindings::CRuntimeObject::finishCreation):
3552         * bridge/c/c_instance.cpp:
3553         (JSC::Bindings::CRuntimeMethod::finishCreation):
3554         (JSC::Bindings::CInstance::invokeMethod):
3555         * bridge/c/c_utility.cpp:
3556         (JSC::Bindings::convertValueToNPVariant):
3557         * bridge/objc/ObjCRuntimeObject.mm:
3558         (JSC::Bindings::ObjCRuntimeObject::finishCreation):
3559         * bridge/objc/WebScriptObject.mm:
3560         (-[WebScriptObject setValue:forKey:]):
3561         (+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
3562         * bridge/objc/objc_instance.mm:
3563         (ObjCRuntimeMethod::finishCreation):
3564         (ObjcInstance::invokeMethod):
3565         * bridge/objc/objc_runtime.mm:
3566         (JSC::Bindings::ObjcFallbackObjectImp::finishCreation):
3567         (JSC::Bindings::callObjCFallbackObject):
3568         * bridge/runtime_array.cpp:
3569         (JSC::RuntimeArray::finishCreation):
3570         (JSC::RuntimeArray::lengthGetter):
3571         * bridge/runtime_method.cpp:
3572         (JSC::RuntimeMethod::finishCreation):
3573         (JSC::RuntimeMethod::lengthGetter):
3574         (JSC::callRuntimeMethod):
3575         * bridge/runtime_object.cpp:
3576         (JSC::Bindings::RuntimeObject::finishCreation):
3577         (JSC::Bindings::callRuntimeObject):
3578         (JSC::Bindings::callRuntimeConstructor):
3579         * css/FontFace.cpp:
3580         (WebCore::FontFace::create):
3581         * html/HTMLMediaElement.cpp:
3582         (WebCore::controllerJSValue):
3583         (WebCore::HTMLMediaElement::updateCaptionContainer):
3584         (WebCore::HTMLMediaElement::didAddUserAgentShadowRoot):
3585         * inspector/InspectorController.cpp:
3586         (WebCore::InspectorController::canAccessInspectedScriptState):
3587         * inspector/InspectorDOMAgent.cpp:
3588         (WebCore::InspectorDOMAgent::buildObjectForEventListener):
3589         (WebCore::InspectorDOMAgent::scriptValueAsNode):
3590         * inspector/WebInjectedScriptHost.cpp:
3591         (WebCore::WebInjectedScriptHost::subtype):
3592         (WebCore::WebInjectedScriptHost::isHTMLAllCollection):
3593         * inspector/WebInjectedScriptHost.h:
3594
3595 2017-01-26  Dean Jackson  <dino@apple.com>
3596
3597         WebGL content in Safari sticks to GPU that it was started on, sometimes causing extra battery drain and difficulty interacting with UI
3598         https://bugs.webkit.org/show_bug.cgi?id=167477
3599         <rdar://problem/29956321>
3600
3601         Reviewed by Tim Horton.
3602
3603         We were not implementing the recommended approach to properly handle
3604         GPU switching, causing some contexts to remain on a GPU and slow
3605         down the machine's UI. It also could stop the discrete GPU from
3606         turning off.
3607
3608         Register for CGL's display reconfiguration notification, so that we
3609         can alert any active CGLContexts and cause them to update.
3610
3611         The code change here doesn't lend itself to automated testing because
3612         it is specific to hardware with multiple GPUs, relies on some separate
3613         tools to detect which GPU is active, and an external method of triggering
3614         a GPU switch. It's best tested by the manual workflow in Radar.
3615
3616         * platform/graphics/GraphicsContext3D.h: Add a macOS-specific update
3617         call.
3618         * platform/graphics/mac/GraphicsContext3DMac.mm:
3619         (WebCore::displayWasReconfigured): The callback for display reconfigurations.
3620         (WebCore::addActiveContext): Helper to keep track of active contexts, so we
3621         can register/unregister the callback when necessary.
3622         (WebCore::removeActiveContext):
3623         (WebCore::GraphicsContext3D::create): Use the new helpers.
3624         (WebCore::GraphicsContext3D::~GraphicsContext3D):
3625         (WebCore::GraphicsContext3D::updateCGLContext): Tell the CGLContextRef to update.
3626
3627 2017-01-26  Commit Queue  <commit-queue@webkit.org>
3628
3629         Unreviewed, rolling out r210328.
3630         https://bugs.webkit.org/show_bug.cgi?id=167476
3631
3632         Blocking bug is fixed <rdar://problem/29957753> (Requested by
3633         keith_miller on #webkit).
3634
3635         Reverted changeset:
3636
3637         "Disable smooth playhead animation for main content media in
3638         the Touch Bar"
3639         https://bugs.webkit.org/show_bug.cgi?id=166715
3640         http://trac.webkit.org/changeset/210328
3641
3642 2017-01-26  Joseph Pecoraro  <pecoraro@apple.com>
3643
3644         Web Inspector: iOS: Memory timeline shows impossible values for Page size (underflowed)
3645         https://bugs.webkit.org/show_bug.cgi?id=167468
3646         <rdar://problem/30099051>
3647
3648         Reviewed by Andreas Kling.
3649
3650         * page/cocoa/ResourceUsageThreadCocoa.mm:
3651         (WebCore::vmPageSize):
3652         This value matches the sysctl value we were attempting to access, and is
3653         the most appropriate when dealing with mach APIs, as we are using here.
3654
3655 2017-01-26  Jer Noble  <jer.noble@apple.com>
3656
3657         Autoplay muted videos stop playback of any streaming app in the background
3658         https://bugs.webkit.org/show_bug.cgi?id=163993
3659         <rdar://problem/29020431>
3660
3661         Reviewed by Eric Carlson.
3662
3663         Added test in TestWebKitAPI, WebKit1.AudioSessionCategoryIOS.
3664
3665         Previously, we would set the audio session category to "playback" if there was a media-
3666         element-type media session, and if there was a session capable of playing audio. But because
3667         this was an "or" operation, we would incorrectly set the category to "playback" if there was
3668         a video element incapable of rendering audio (due to being muted, without an audio track,
3669         etc.), and also a session capable of producing audio, such as WebAudio.
3670
3671         With this change, this turns into an "and" operation; there must be a media element capable
3672         of rendering audio in order to switch the audio session category to "playback".
3673
3674         Additionally, we no longer cache the value of "canProduceAudio()"; it's queried directly
3675         whenever updateSessionState() is called.
3676
3677         * Modules/webaudio/AudioContext.cpp:
3678         (WebCore::AudioContext::constructCommon):
3679         * Modules/webaudio/AudioContext.h:
3680         * html/HTMLMediaElement.cpp:
3681         (WebCore::HTMLMediaElement::insertedInto):
3682         (WebCore::HTMLMediaElement::loadResource):
3683         (WebCore::HTMLMediaElement::setMuted):
3684         (WebCore::HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged):
3685         (WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged):
3686         (WebCore::HTMLMediaElement::clearMediaPlayer):
3687         (WebCore::HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged):
3688         (WebCore::HTMLMediaElement::presentationType):
3689         (WebCore::HTMLMediaElement::characteristics):
3690         (WebCore::HTMLMediaElement::canProduceAudio):
3691         * html/HTMLMediaElement.h:
3692         * platform/audio/PlatformMediaSession.cpp:
3693         (WebCore::PlatformMediaSession::activeAudioSessionRequired):
3694         (WebCore::PlatformMediaSession::canProduceAudio):
3695         (WebCore::PlatformMediaSession::canProduceAudioChanged):
3696         (WebCore::PlatformMediaSession::setCanProduceAudio): Deleted.
3697         * platform/audio/PlatformMediaSession.h:
3698         (WebCore::PlatformMediaSessionClient::canProduceAudio):
3699         (WebCore::PlatformMediaSession::canProduceAudio): Deleted.
3700         * platform/audio/cocoa/MediaSessionManagerCocoa.cpp:
3701         (PlatformMediaSessionManager::updateSessionState):
3702
3703 2017-01-26  Filip Pizlo  <fpizlo@apple.com>
3704
3705         EventTarget should visit the JSEventListeners using visitAdditionalChildren
3706         https://bugs.webkit.org/show_bug.cgi?id=167462
3707
3708         Reviewed by Michael Saboff.
3709
3710         No new tests because this is already caught by existing testing. This would show up as ASSERTs
3711         in debug, and we suspect it might be at fault for null deref crashes.
3712         
3713         Previously, EventTarget would have its event listeners visited by its subclasses' visitChildren
3714         methods. Every subclass of EventTarget would call EventTarget's visitJSEventListeners. For
3715         example, this means that if JSFoo has seven classes between it and JSEventTarget in the JSCell
3716         class hierarchy, then JSFoo::visitChildren would end up calling visitJSEventListeners seven extra
3717         times.
3718         
3719         Also, the weird way that visitJSEventListeners was called meant that it was not part of the GC's
3720         output constraint processing. This meant that it would not be called when the GC tried to
3721         terminate. So, if something about the event listener changes during a GC cycle, the GC would
3722         potentially fail to mark one of the references.
3723         
3724         Both problems can be solved by simply moving the call to visitJSEventListeners into
3725         visitAdditionalChildren.
3726
3727         * bindings/js/JSDOMWindowCustom.cpp:
3728         (WebCore::JSDOMWindow::visitAdditionalChildren):
3729         * bindings/js/JSEventTargetCustom.cpp:
3730         (WebCore::JSEventTarget::visitAdditionalChildren):
3731         * bindings/scripts/CodeGeneratorJS.pm:
3732         (GenerateImplementation):
3733         * dom/EventTarget.idl:
3734
3735 2017-01-26  Andy Estes  <aestes@apple.com>
3736
3737         [QuickLook] Create temporary files with NSFileProtectionCompleteUnlessOpen
3738         https://bugs.webkit.org/show_bug.cgi?id=167455
3739         <rdar://problem/12499118>
3740
3741         Reviewed by David Kilzer.
3742
3743         Add the NSFileProtectionKey attribute with value NSFileProtectionCompleteUnlessOpen to
3744         temporary directories created for QuickLook files. Also:
3745
3746         1. Stop calling -[NSFileManager _web_pathWithUniqueFilenameForPath:], since the temporary
3747         directory is already unique and only one file will be placed inside it.
3748         2. Create the temporary file with -[NSFileManager _web_createFileAtPath:contents:attributes:]
3749         instead of with -[NSFileManager _web_createFileAtPathWithIntermediateDirectories:contents:attributes:directoryAttributes:],
3750         since the intermediate directories were already created by createTemporaryDirectory().
3751         3. Explicitly set the temporary directory's attributes with
3752         -[NSFileManager setAttributes:ofItemAtPath:error:].
3753         4. Append the lastPathComponent of fileName to downloadDirectory to ensure fileName isn't
3754         really a relative path.
3755
3756         * loader/ios/QuickLook.h: Stopped declaring QLFileAttributes() and QLDirectoryAttributes().
3757         * loader/ios/QuickLook.mm:
3758         (WebCore::temporaryFileAttributes): Renamed from QLFileAttributes().
3759         (WebCore::temporaryDirectoryAttributes): Renamed from QLDirectoryAttributes().
3760         (WebCore::createTemporaryFileForQuickLook):
3761         (WebCore::QLFileAttributes): Deleted.
3762         (WebCore::QLDirectoryAttributes): Deleted.
3763         * platform/spi/cocoa/NSFileManagerSPI.h: Declared -_web_createFileAtPath:contents:attributes:
3764         and removed declarations for -_web_createFileAtPathWithIntermediateDirectories:contents:attributes:directoryAttributes:
3765         and -_web_pathWithUniqueFilenameForPath:
3766
3767 2017-01-26  Jeremy Jones  <jeremyj@apple.com>
3768
3769         Pointer lock events should be delivered directly to the target element
3770         https://bugs.webkit.org/show_bug.cgi?id=167134
3771
3772         Reviewed by Jon Lee.
3773
3774         pointer-lock/mouse-event-delivery.html: Enabled for mac, added wheel event tests.
3775
3776         When pointer is locked on an element, route mouse events directly to the target element, instead of 
3777         doing the normal event disptach.
3778
3779         * page/EventHandler.cpp:
3780         (WebCore::EventHandler::handleMousePressEvent):
3781         (WebCore::EventHandler::handleMouseDoubleClickEvent):
3782         (WebCore::EventHandler::handleMouseMoveEvent):
3783         (WebCore::EventHandler::handleMouseReleaseEvent):
3784         (WebCore::EventHandler::handleMouseForceEvent):
3785         (WebCore::EventHandler::handleWheelEvent):
3786         * page/PointerLockController.cpp:
3787         (WebCore::PointerLockController::isLocked): Added.
3788         (WebCore::PointerLockController::dispatchLockedWheelEvent): Added.
3789         * page/PointerLockController.h:
3790
3791 2017-01-26  Chris Dumez  <cdumez@apple.com>
3792
3793         Fix CPU / Memory diagnostic logging in PerformanceMonitor
3794         https://bugs.webkit.org/show_bug.cgi?id=167469
3795         <rdar://problem/30220959>
3796
3797         Reviewed by Alex Christensen.
3798
3799         Fix CPU / Memory diagnostic logging in PerformanceMonitor to use logDiagnosticMessage()
3800         instead of logDiagnosticMessageWithValue(). logDiagnosticMessageWithValue() should only
3801         be used with numeric values but we already take care of the bucketing on our side.
3802
3803         * page/DiagnosticLoggingClient.h:
3804         * page/DiagnosticLoggingKeys.cpp:
3805         (WebCore::DiagnosticLoggingKeys::postPageBackgroundingCPUUsageKey):
3806         (WebCore::DiagnosticLoggingKeys::postPageBackgroundingMemoryUsageKey):
3807         (WebCore::DiagnosticLoggingKeys::postPageLoadCPUUsageKey):
3808         (WebCore::DiagnosticLoggingKeys::postPageLoadMemoryUsageKey):
3809         (WebCore::DiagnosticLoggingKeys::foregroundCPUUsageToDiagnosticLoggingKey):
3810         (WebCore::DiagnosticLoggingKeys::backgroundCPUUsageToDiagnosticLoggingKey):
3811         (WebCore::DiagnosticLoggingKeys::postPageBackgroundingKey): Deleted.
3812         (WebCore::DiagnosticLoggingKeys::postPageLoadKey): Deleted.
3813         (WebCore::DiagnosticLoggingKeys::memoryUsageKey): Deleted.
3814         * page/DiagnosticLoggingKeys.h:
3815         * page/PerformanceMonitor.cpp:
3816         (WebCore::PerformanceMonitor::measurePostLoadCPUUsage):
3817         (WebCore::PerformanceMonitor::measurePostLoadMemoryUsage):
3818         (WebCore::PerformanceMonitor::measurePostBackgroundingMemoryUsage):
3819         (WebCore::PerformanceMonitor::measurePostBackgroundingCPUUsage):
3820
3821 2017-01-26  Brady Eidson  <beidson@apple.com>
3822
3823         Gamepads: Some DPads are still not exposed in the HID backend.
3824         rdar://problem/30217518 and https://bugs.webkit.org/show_bug.cgi?id=167465
3825
3826         Reviewed by Alex Christensen.
3827
3828         No new tests (Currently unable to test HID backend directly)
3829
3830         * platform/gamepad/mac/HIDGamepad.cpp:
3831         (WebCore::HIDGamepad::maybeAddButton): Allow GenericDesktop paged elements that are DPads to be buttons.
3832
3833 2017-01-26  Commit Queue  <commit-queue@webkit.org>
3834
3835         Unreviewed, rolling out r210095.
3836         https://bugs.webkit.org/show_bug.cgi?id=167464
3837
3838         broke tiling on mac (Requested by thorton on #webkit).
3839
3840         Reverted changeset:
3841
3842         "TileGrid revalidates tiles twice during flush, first with
3843         wrong visible rect"
3844         https://bugs.webkit.org/show_bug.cgi?id=166406
3845         http://trac.webkit.org/changeset/210095
3846
3847 2017-01-26  Chris Dumez  <cdumez@apple.com>
3848
3849         Fix WebGL diagnostic logging
3850         https://bugs.webkit.org/show_bug.cgi?id=167463
3851         <rdar://problem/30216981>
3852
3853         Reviewed by Alex Christensen.
3854
3855         Fix WebGL diagnostic logging so that it no longer uses logDiagnosticMessageWithValue().
3856         This is because the value apparently needs to be numeric on Mac.
3857
3858         * html/canvas/WebGLRenderingContextBase.cpp:
3859         (WebCore::WebGLRenderingContextBase::checkForContextLossHandling):
3860         * page/DiagnosticLoggingKeys.cpp:
3861         (WebCore::DiagnosticLoggingKeys::pageHandlesWebGLContextLossKey):
3862         (WebCore::WebCore::DiagnosticLoggingKeys::webGLStateKey):
3863         (WebCore::DiagnosticLoggingKeys::stateKey): Deleted.
3864         (WebCore::DiagnosticLoggingKeys::handlesContextLossKey): Deleted.
3865         (WebCore::WebCore::DiagnosticLoggingKeys::webGLKey): Deleted.
3866         * page/DiagnosticLoggingKeys.h:
3867
3868 2017-01-26  Zalan Bujtas  <zalan@apple.com>
3869
3870         Simple line layout: Add support for -webkit-hyphenate-limit-lines
3871         https://bugs.webkit.org/show_bug.cgi?id=167446
3872         <rdar://problem/30194030>
3873
3874         Reviewed by Antti Koivisto.
3875
3876         Now we can set the limit on the number of lines that a word can split across through hyphenation.
3877
3878         Tests: fast/text/simple-line-layout-hyphen-limit-lines.html
3879                fast/text/simple-line-layout-hyphen-limit-lines2.html
3880
3881         * rendering/SimpleLineLayout.cpp:
3882         (WebCore::SimpleLineLayout::canUseForStyle):
3883         (WebCore::SimpleLineLayout::splitFragmentToFitLine):
3884         (WebCore::SimpleLineLayout::printReason):
3885         * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
3886         (WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style):
3887         * rendering/SimpleLineLayoutTextFragmentIterator.h:
3888         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::TextFragment):
3889         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::wrappingWithHyphenCounter):
3890         (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::splitWithHyphen): The right side of the split has +1 on the wrapping counter.
3891
3892 2017-01-26  Wenson Hsieh  <wenson_hsieh@apple.com>
3893
3894         Add support for recognizing data interaction gestures in WebKit2
3895         https://bugs.webkit.org/show_bug.cgi?id=167444
3896
3897         Reviewed by Beth Dakin.
3898
3899         Minor tweaks to pasteboard code to support data interaction.
3900
3901         * WebCore.xcodeproj/project.pbxproj:
3902         * platform/PlatformPasteboard.h:
3903         * platform/ios/PasteboardIOS.mm:
3904         (WebCore::Pasteboard::read):
3905         * platform/ios/PlatformPasteboardIOS.mm:
3906         (WebCore::PlatformPasteboard::PlatformPasteboard):
3907
3908         If the pasteboard is the special data interaction type, use the shared item provider pasteboard; otherwise,
3909         fall back to the general pasteboard.
3910
3911         (WebCore::PlatformPasteboard::getTypes):
3912
3913         Actually populate the list of available types using available pasteboardTypes.
3914
3915         (WebCore::PlatformPasteboard::write):
3916
3917         Add UTF8 plaintext type (kUTTypeUTF8PlainText) when vending data representations of rich text.
3918
3919         * platform/ios/WebItemProviderPasteboard.mm:
3920         (-[WebItemProviderPasteboard setItems:]):
3921         (-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
3922         (-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):
3923
3924         Move off of deprecated methods when retrieving and supplying data to the item provider pasteboard.
3925
3926         * platform/spi/ios/UIKitSPI.h:
3927
3928 2017-01-26  Matt Rajca  <mrajca@apple.com>
3929
3930         Notify clients when the user plays media otherwise prevented from autoplaying
3931         https://bugs.webkit.org/show_bug.cgi?id=167390
3932
3933         Reviewed by Alex Christensen.
3934
3935         The API is tested.
3936
3937         * html/HTMLMediaElement.cpp:
3938         (WebCore::HTMLMediaElement::playInternal):
3939         * page/ChromeClient.h:
3940
3941 2017-01-26  Enrique Ocaña González  <eocanha@igalia.com>
3942
3943         [GStreamer] ASSERTION FAILED: !g_object_is_floating(ptr) in adoptGRef(GstContext* ptr)
3944         https://bugs.webkit.org/show_bug.cgi?id=167458
3945
3946         Reviewed by Xabier Rodriguez-Calvar.
3947
3948         GstContext is a mini_object, not a GObject. Therefore it shouldn't (and can't) be checked&