[MediaStream] apply constraints passed to getUserMedia()
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2016-11-10  Eric Carlson  <eric.carlson@apple.com>
2
3         [MediaStream] apply constraints passed to getUserMedia()
4         https://bugs.webkit.org/show_bug.cgi?id=164561
5
6         Reviewed by Youenn Fablet.
7         <rdar://problem/29191384>
8
9         No new tests, updated existing tests.
10
11         * Modules/mediastream/UserMediaRequest.cpp:
12         (WebCore::UserMediaRequest::allow): Pass constraints into createMediaStream instead of applying
13           them after the stream has been created.
14
15         * WebCore.xcodeproj/project.pbxproj: Remove MediaConstraintsMock.cpp/.h.
16
17         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
18         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updatePausedImage): Remove a bogus assert.
19         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::currentReadyState): Drive-by fix: a stream
20           that is receiving media data is as ready as it will ever be so it's readyState should be
21           at HAVE_ENOUGH_DATA.
22
23         Simplify CaptureDeviceManager by removing all code for constraint validation because some
24         constraints can't be validated without a live capture device. Ports that are able to resolve
25         constraints without creating a live source can do so in a derived capture device class.
26         * platform/mediastream/CaptureDeviceManager.cpp:
27         (CaptureDeviceManager::bestSourcesForTypeAndConstraints): Return a list of UIDs, not a list
28           of live sources, because that is all the caller will use. This will allows ports to avoid
29           source creation in some cases.
30         (CaptureDeviceManager::sourceWithUID): Add parameters for new source constraints and invalid
31           constraint.
32         (CaptureDeviceManager::verifyConstraintsForMediaType): Deleted.
33         (CaptureDeviceManager::bestDeviceForFacingMode): Deleted.
34         (facingModeFromString): Deleted.
35         (CaptureDeviceManager::sessionSupportsConstraint): Deleted.
36         (CaptureDeviceManager::isSupportedFrameRate): Deleted.
37         * platform/mediastream/CaptureDeviceManager.h:
38         (WebCore::CaptureDeviceManager::defaultCaptureSession): Deleted.
39
40         * platform/mediastream/MediaConstraints.cpp:
41         (WebCore::FlattenedConstraint::find): New, make it possible to examine resolved constraints.
42         * platform/mediastream/MediaConstraints.h:
43         (WebCore::NumericConstraint::fitnessDistance): Reject invalid constraints.
44         (WebCore::NumericConstraint::valueForCapabilityRange): New, resolve a constraint for a 
45           capability range.
46         (WebCore::MediaTrackConstraintSetMap::width): Expose constraints held in the map.
47         (WebCore::MediaTrackConstraintSetMap::height):
48         (WebCore::MediaTrackConstraintSetMap::sampleRate):
49         (WebCore::MediaTrackConstraintSetMap::sampleSize):
50         (WebCore::MediaTrackConstraintSetMap::aspectRatio):
51         (WebCore::MediaTrackConstraintSetMap::frameRate):
52         (WebCore::MediaTrackConstraintSetMap::volume):
53         (WebCore::MediaTrackConstraintSetMap::echoCancellation):
54         (WebCore::MediaTrackConstraintSetMap::facingMode):
55         (WebCore::MediaTrackConstraintSetMap::deviceId):
56         (WebCore::MediaTrackConstraintSetMap::groupId):
57
58         Resolve and apply width, height, and frameRate all at once because the ability to support
59         one may depend on the value of another.
60         * platform/mediastream/RealtimeMediaSource.cpp:
61         (WebCore::RealtimeMediaSource::supportsSizeAndFrameRate): 
62         (WebCore::applyNumericConstraint): Move the guts of the logic into valueForCapabilityRange.
63         (WebCore::RealtimeMediaSource::applySizeAndFrameRate):
64         (WebCore::RealtimeMediaSource::selectSettings):
65         (WebCore::RealtimeMediaSource::supportsConstraints):
66         (WebCore::RealtimeMediaSource::applyConstraints): Support null success/failure lambdas.
67         * platform/mediastream/RealtimeMediaSource.h:
68
69         * platform/mediastream/RealtimeMediaSourceCenter.h:
70         * platform/mediastream/mac/AVAudioCaptureSource.h:
71         * platform/mediastream/mac/AVAudioCaptureSource.mm:
72         (WebCore::AVAudioCaptureSource::create): Add parameter for creation constraints.
73         (WebCore::AVAudioCaptureSource::AVAudioCaptureSource): Ditto.
74
75         Remove all constraint validation code, it is done by the audio and video capture sources. Add
76         support for stream creation constraints.
77         * platform/mediastream/mac/AVCaptureDeviceManager.h:
78         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
79         (WebCore::AVCaptureDeviceManager::captureDeviceList):
80         (WebCore::AVCaptureDeviceManager::createMediaSourceForCaptureDeviceWithConstraints):
81         (WebCore::AVCaptureDeviceManager::bestSourcesForTypeAndConstraints): Deleted.
82         (WebCore::AVCaptureDeviceManager::sourceWithUID): Deleted.
83         (WebCore::AVCaptureDeviceManager::verifyConstraintsForMediaType): Deleted.
84         (WebCore::AVCaptureDeviceManager::defaultCaptureSession): Deleted.
85         (WebCore::AVCaptureDeviceManager::sessionSupportsConstraint): Deleted.
86         (WebCore::AVCaptureDeviceManager::isSupportedFrameRate): Deleted.
87         (WebCore::AVCaptureDeviceManager::supportedConstraints): Deleted.
88
89         * platform/mediastream/mac/AVMediaCaptureSource.h:
90         (WebCore::AVMediaCaptureSource::constraints): Deleted.
91         * platform/mediastream/mac/AVMediaCaptureSource.mm:
92         (WebCore::AVMediaCaptureSource::AVMediaCaptureSource):
93         (WebCore::AVMediaCaptureSource::~AVMediaCaptureSource):
94         (WebCore::AVMediaCaptureSource::startProducingData):
95         (WebCore::AVMediaCaptureSource::stopProducingData):
96         (WebCore::AVMediaCaptureSource::beginConfiguration):
97         (WebCore::AVMediaCaptureSource::commitConfiguration):
98         (WebCore::AVMediaCaptureSource::capabilities):
99         (WebCore::AVMediaCaptureSource::setupSession):
100         (WebCore::AVMediaCaptureSource::reset):
101
102         Validate and apply constraints, support source creation constraints, initialize capabilities
103         and supported constraints by examining device capabilities.
104         * platform/mediastream/mac/AVVideoCaptureSource.h:
105         * platform/mediastream/mac/AVVideoCaptureSource.mm:
106         (WebCore::AVVideoCaptureSource::create):
107         (WebCore::AVVideoCaptureSource::AVVideoCaptureSource):
108         (WebCore::updateSizeMinMax):
109         (WebCore::updateAspectRatioMinMax):
110         (WebCore::AVVideoCaptureSource::initializeCapabilities):
111         (WebCore::AVVideoCaptureSource::initializeSupportedConstraints):
112         (WebCore::AVVideoCaptureSource::applySize):
113         (WebCore::AVVideoCaptureSource::setPreset):
114         (WebCore::AVVideoCaptureSource::applyFrameRate):
115         (WebCore::AVVideoCaptureSource::applySizeAndFrameRate):
116         (WebCore::AVVideoCaptureSource::setupCaptureSession):
117         (WebCore::AVVideoCaptureSource::currentFrameCGImage):
118         (WebCore::AVVideoCaptureSource::bestSessionPresetForVideoDimensions):
119         (WebCore::AVVideoCaptureSource::supportsSizeAndFrameRate):
120
121         * platform/mediastream/mac/MockRealtimeVideoSourceMac.h:
122         * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
123         (WebCore::MockRealtimeVideoSource::create): Apply creation constraints, return null if they
124           can not be applied successfully.
125         (WebCore::MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac):
126         (WebCore::MockRealtimeVideoSource::createMuted):
127
128         Update RealtimeMediaSourceCenters for API changes.
129         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp:
130         (WebCore::RealtimeMediaSourceCenterMac::validateRequestConstraints):
131         (WebCore::RealtimeMediaSourceCenterMac::createMediaStream):
132         * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h:
133         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp:
134         (WebCore::RealtimeMediaSourceCenterOwr::validateRequestConstraints):
135         (WebCore::RealtimeMediaSourceCenterOwr::createMediaStream):
136         (WebCore::RealtimeMediaSourceCenterOwr::mediaSourcesAvailable):
137         * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.h:
138
139         Mock media sources support constraint validation and application directly so "mock constraints"
140         are no longer necessary.
141         * platform/mock/MediaConstraintsMock.cpp: Removed.
142         * platform/mock/MediaConstraintsMock.h: Removed.
143         * platform/mock/MockRealtimeAudioSource.cpp:
144         (WebCore::MockRealtimeAudioSource::create):
145         (WebCore::MockRealtimeAudioSource::createMuted):
146         (WebCore::MockRealtimeAudioSource::updateSettings):
147         (WebCore::MockRealtimeAudioSource::initializeCapabilities):
148         (WebCore::MockRealtimeAudioSource::initializeSupportedConstraints):
149         * platform/mock/MockRealtimeAudioSource.h:
150         * platform/mock/MockRealtimeMediaSourceCenter.cpp:
151         (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints):
152         (WebCore::MockRealtimeMediaSourceCenter::createMediaStream):
153         * platform/mock/MockRealtimeMediaSourceCenter.h:
154         * platform/mock/MockRealtimeVideoSource.cpp:
155         (WebCore::MockRealtimeVideoSource::create):
156         (WebCore::MockRealtimeVideoSource::createMuted):
157         * platform/mock/MockRealtimeVideoSource.h:
158         * platform/mock/RTCPeerConnectionHandlerMock.cpp:
159
160 2016-11-10  Alex Christensen  <achristensen@webkit.org>
161
162         Move SecurityOrigin::databaseIdentifier() to SecurityOriginData
163         https://bugs.webkit.org/show_bug.cgi?id=164573
164
165         Reviewed by Brady Eidson.
166
167         No change in behavior.
168
169         * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
170         (WebCore::WebKitMediaKeySession::mediaKeysStorageDirectory):
171         * Modules/indexeddb/IDBDatabaseIdentifier.cpp:
172         (WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot):
173         * Modules/indexeddb/server/IDBServer.cpp:
174         (WebCore::IDBServer::IDBServer::performCloseAndDeleteDatabasesForOrigins):
175         * Modules/webdatabase/DatabaseTracker.cpp:
176         (WebCore::DatabaseTracker::hasEntryForOriginNoLock):
177         (WebCore::DatabaseTracker::hasEntryForDatabase):
178         (WebCore::DatabaseTracker::originPath):
179         (WebCore::DatabaseTracker::fullPathForDatabaseNoLock):
180         (WebCore::DatabaseTracker::databaseNamesForOriginNoLock):
181         (WebCore::DatabaseTracker::detailsForNameAndOrigin):
182         (WebCore::DatabaseTracker::setDatabaseDetails):
183         (WebCore::DatabaseTracker::originLockFor):
184         (WebCore::DatabaseTracker::deleteOriginLockFor):
185         (WebCore::DatabaseTracker::quotaForOriginNoLock):
186         (WebCore::DatabaseTracker::setQuota):
187         (WebCore::DatabaseTracker::addDatabase):
188         (WebCore::DatabaseTracker::deleteOrigin):
189         (WebCore::DatabaseTracker::deleteDatabase):
190         (WebCore::DatabaseTracker::removeDeletedOpenedDatabases):
191         * Modules/webdatabase/SQLTransactionCoordinator.cpp:
192         (WebCore::getDatabaseIdentifier):
193         * dom/Document.cpp:
194         (WebCore::Document::origin):
195         * html/HTMLMediaElement.cpp:
196         (WebCore::HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory):
197         * loader/appcache/ApplicationCacheStorage.cpp:
198         (WebCore::ApplicationCacheStorage::calculateQuotaForOrigin):
199         (WebCore::ApplicationCacheStorage::calculateUsageForOrigin):
200         (WebCore::ApplicationCacheStorage::calculateRemainingSizeForOriginExcludingCache):
201         (WebCore::ApplicationCacheStorage::storeUpdatedQuotaForOrigin):
202         (WebCore::ApplicationCacheStorage::store):
203         (WebCore::ApplicationCacheStorage::ensureOriginRecord):
204         * page/SecurityOrigin.cpp:
205         (WebCore::SecurityOrigin::databaseIdentifier): Deleted.
206         * page/SecurityOrigin.h:
207         * page/SecurityOriginData.cpp:
208         (WebCore::SecurityOriginData::databaseIdentifier):
209         * page/SecurityOriginData.h:
210
211 2016-11-10  Zalan Bujtas  <zalan@apple.com>
212
213         RenderElement::invalidateFlowThreadContainingBlockIncludingDescendants should be on RenderBlock.
214         https://bugs.webkit.org/show_bug.cgi?id=164601
215
216         Reviewed by Simon Fraser.
217
218         FlowThread containing blocks are cached at RenderBlocks. It makes no sense to call the invalidate function on a RenderElement.
219         Move invalidateFlowThreadContainingBlockIncludingDescendants to RenderBlock.
220
221         No change in functionality.
222
223         * rendering/RenderBlock.cpp:
224         (WebCore::RenderBlock::invalidateFlowThreadContainingBlockIncludingDescendants):
225         * rendering/RenderBlock.h:
226         * rendering/RenderElement.cpp:
227         (WebCore::RenderElement::invalidateFlowThreadContainingBlockIncludingDescendants): Deleted.
228         * rendering/RenderElement.h:
229         * rendering/RenderInline.cpp:
230         (WebCore::RenderInline::splitInlines):
231
232 2016-11-10  Brent Fulgham  <bfulgham@apple.com>
233
234         Local file restrictions should not block sessionStorage access.
235         https://bugs.webkit.org/show_bug.cgi?id=155609
236         <rdar://problem/25229461> 
237
238         Reviewed by Andy Estes.
239
240         Re-landing this fix that was lost when the localStorage change was rolled out.
241
242         Use of 'sessionStorage' is governed by SecurityOrigin with third party access
243         set to 'ShouldAllowFromThirdParty::AlwaysAllowFromThirdParty'. We should not
244         reject local files for this combination of arguments.
245
246         Tested by storage/domstorage/sessionstorage/blocked-file-access.html.
247
248         * page/SecurityOrigin.cpp:
249         (WebCore::SecurityOrigin::canAccessStorage): For the case of sessionStorage,
250         allow local file access.
251
252 2016-11-10  Daniel Bates  <dabates@apple.com>
253
254         REGRESSION (r195004): Scripts and plugins blocked for subsequent loads in same WebContent
255         process after receiving HTTP 0.9 response
256         https://bugs.webkit.org/show_bug.cgi?id=164387
257         <rdar://problem/28987537>
258
259         Reviewed by Brent Fulgham.
260
261         Fixes an issue where the HTTP 0.9 sandbox persisted across subsequent loads in the same
262         WebContent process.
263
264         Currently when an HTTP 0.9 response is received for a request made to a default port
265         (e.g. 80) we apply a sandbox policy on the FrameLoader for the main resource that
266         disallows scripts and plugins. A FrameLoader may be re-used for navigations. Therefore,
267         the sandbox policy applied to one site may be applied to another site. Moreover the
268         sandbox policy was applied to the FrameLoader of the main resource regardless of whether
269         the HTTP response was for a subresource. Instead we should apply the sandbox on a per-
270         Document basis and only if we receive an HTTP 0.9 response for the document when the
271         corresponding HTTP request was made to a default port.
272
273         As a side benefit of this change, we emit exactly one console message to Web Inspector
274         when the HTTP 0.9 sandbox is applied to a document as opposed to three console messages.
275         Moreover, we only emit this console message when the document load is not blocked.
276
277         Test: http/tests/security/http-0.9/sandbox-should-not-persist-on-navigation.html
278
279         * dom/Document.cpp:
280         (WebCore::Document::initSecurityContext): Disallow scripts and plugins if an HTTP 0.9
281         response was received for this document. Note that if this function is called for a
282         document associated with an HTTP 0.9 response then the corresponding HTTP request was
283         made to a default port. DocumentLoader::responseReceived() blocks the load for a document
284         with an HTTP 0.9 response corresponding to an HTTP request made to a non-default port.
285         This invariant is covered by the tests LayoutTests/http/tests/security/http-0.9/default-port-{plugin, script}-blocked.html.
286         (WebCore::Document::shouldEnforceHTTP0_9Sandbox): Added. Returns whether an HTTP 0.9 response
287         was received for this document.
288         * dom/Document.h:
289         * loader/DocumentLoader.cpp:
290         (WebCore::DocumentLoader::responseReceived): Remove logic to apply sandbox policy to the
291         FrameLoader associated with the main resource. We will apply the sandbox during initialization
292         of the document.
293         * loader/ResourceLoader.cpp:
294         (WebCore::ResourceLoader::didReceiveResponse): Ditto.
295         * loader/SubresourceLoader.cpp:
296         (WebCore::SubresourceLoader::didReceiveResponse): Ditto.
297
298 2016-11-04  Jiewen Tan  <jiewen_tan@apple.com>
299
300         Update SubtleCrypto::importKey to match the latest spec
301         https://bugs.webkit.org/show_bug.cgi?id=164446
302         <rdar://problem/29123621>
303
304         Reviewed by Brent Fulgham.
305
306         This patch does following few things:
307         1. It updates the SubtleCrypto::importKey method to match the latest spec:
308            https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-importKey.
309            It also refers to the latest Editor's Draft at a certain degree:
310            https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-importKey.
311         2. It implements importKey operations of following algorithms: AES-CBC, AES-KW,
312            HMAC, RSAES-PKCS1-V1_5, RSASSA-PKCS1-V1_5, and RSA-OAEP.
313         3. It fixes some minor problems of SubtleCrypto::generateKey.
314         4. It addes move constructors for CryptoKeyAES, CryptoKeyHMAC, CryptoKeyRSA and
315            CryptoKeyDataRSAComponents.
316         5. It renames HmacKeyGenParams to HmacKeyParams to serve the purpose of both
317            HmacKeyGenParams and HmacImportParams which are essentially the same.
318         6. It enforces the key length in bits of CryptoKeyHMAC to be multiples of 8.
319         7. It also fixes the following bugs:
320            https://bugs.webkit.org/show_bug.cgi?id=126033,
321            https://bugs.webkit.org/show_bug.cgi?id=126034,
322            https://bugs.webkit.org/show_bug.cgi?id=151308.
323         P.S. We currently only support Raw and Jwk key format.
324
325         Tests: crypto/subtle/aes-cbc-import-jwk-key-length-128.html
326                crypto/subtle/aes-cbc-import-jwk-key-length-192.html
327                crypto/subtle/aes-cbc-import-jwk-key-length-256.html
328                crypto/subtle/aes-cbc-import-jwk-key-minimum.html
329                crypto/subtle/aes-cbc-import-jwk-key-non-extractable.html
330                crypto/subtle/aes-cbc-import-raw-key-length-128.html
331                crypto/subtle/aes-cbc-import-raw-key-length-192.html
332                crypto/subtle/aes-cbc-import-raw-key-length-256.html
333                crypto/subtle/aes-import-key-malformed-parameters.html
334                crypto/subtle/aes-kw-import-jwk-key-length-128.html
335                crypto/subtle/aes-kw-import-jwk-key-length-192.html
336                crypto/subtle/aes-kw-import-jwk-key-length-256.html
337                crypto/subtle/aes-kw-import-raw-key.html
338                crypto/subtle/generate-key-malformed-parameters.html
339                crypto/subtle/hmac-import-jwk-key-minimum.html
340                crypto/subtle/hmac-import-jwk-key-non-extractable.html
341                crypto/subtle/hmac-import-jwk-key-sha1.html
342                crypto/subtle/hmac-import-jwk-key-sha224.html
343                crypto/subtle/hmac-import-jwk-key-sha256.html
344                crypto/subtle/hmac-import-jwk-key-sha384.html
345                crypto/subtle/hmac-import-jwk-key-sha512.html
346                crypto/subtle/hmac-import-malformed-parameters.html
347                crypto/subtle/hmac-import-raw-key-customized-length.html
348                crypto/subtle/hmac-import-raw-key.html
349                crypto/subtle/import-key-malformed-parameters.html
350                crypto/subtle/rsa-import-key-malformed-parameters.html
351                crypto/subtle/rsa-oaep-import-jwk-private-key.html
352                crypto/subtle/rsa-oaep-import-jwk-public-key-sha1.html
353                crypto/subtle/rsa-oaep-import-jwk-public-key-sha224.html
354                crypto/subtle/rsa-oaep-import-jwk-public-key-sha256.html
355                crypto/subtle/rsa-oaep-import-jwk-public-key-sha384.html
356                crypto/subtle/rsa-oaep-import-jwk-public-key-sha512.html
357                crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-private-key.html
358                crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-leading-zero.html
359                crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-minimum.html
360                crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key-non-extractable.html
361                crypto/subtle/rsaes-pkcs1-v1_5-import-jwk-public-key.html
362                crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-private-key.html
363                crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha1.html
364                crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha224.html
365                crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha256.html
366                crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha384.html
367                crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-public-key-sha512.html
368                crypto/workers/subtle/aes-import-jwk-key.html
369                crypto/workers/subtle/aes-import-raw-key.html
370                crypto/workers/subtle/hmac-import-jwk-key.html
371                crypto/workers/subtle/hmac-import-raw-key.html
372                crypto/workers/subtle/rsa-import-jwk-private-key.html
373                crypto/workers/subtle/rsa-import-jwk-public-key.html
374
375         * CMakeLists.txt:
376         * DerivedSources.make:
377         * PlatformEfl.cmake:
378         * PlatformGTK.cmake:
379         * PlatformMac.cmake:
380         * WebCore.xcodeproj/project.pbxproj:
381         * bindings/js/JSSubtleCryptoCustom.cpp:
382         (WebCore::normalizeCryptoAlgorithmParameters):
383         (WebCore::cryptoKeyUsageFromString):
384         (WebCore::cryptoKeyUsagesFromJSValue):
385         (WebCore::toKeyData):
386         (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise):
387         (WebCore::jsSubtleCryptoFunctionImportKeyPromise):
388         (WebCore::JSSubtleCrypto::importKey):
389         * crypto/CryptoAlgorithm.cpp:
390         (WebCore::CryptoAlgorithm::importKey):
391         * crypto/CryptoAlgorithm.h:
392         * crypto/CryptoAlgorithmParameters.h:
393         * crypto/JsonWebKey.h: Added.
394         * crypto/JsonWebKey.idl: Added.
395         * crypto/RsaOtherPrimesInfo.h: Added.
396         * crypto/RsaOtherPrimesInfo.idl: Added.
397         * crypto/SubtleCrypto.h:
398         * crypto/SubtleCrypto.idl:
399         * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
400         (WebCore::CryptoAlgorithmAES_CBC::generateKey):
401         (WebCore::CryptoAlgorithmAES_CBC::importKey):
402         * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
403         * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
404         (WebCore::CryptoAlgorithmAES_KW::generateKey):
405         (WebCore::CryptoAlgorithmAES_KW::importKey):
406         * crypto/algorithms/CryptoAlgorithmAES_KW.h:
407         * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
408         (WebCore::CryptoAlgorithmHMAC::generateKey):
409         (WebCore::CryptoAlgorithmHMAC::importKey):
410         * crypto/algorithms/CryptoAlgorithmHMAC.h:
411         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
412         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
413         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
414         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
415         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
416         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
417         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
418         (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
419         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
420         * crypto/keys/CryptoKeyAES.cpp:
421         (WebCore::CryptoKeyAES::CryptoKeyAES):
422         (WebCore::CryptoKeyAES::generate):
423         (WebCore::CryptoKeyAES::importRaw):
424         (WebCore::CryptoKeyAES::importJwk):
425         * crypto/keys/CryptoKeyAES.h:
426         * crypto/keys/CryptoKeyDataRSAComponents.cpp:
427         (WebCore::CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents):
428         * crypto/keys/CryptoKeyDataRSAComponents.h:
429         * crypto/keys/CryptoKeyHMAC.cpp:
430         (WebCore::CryptoKeyHMAC::CryptoKeyHMAC):
431         (WebCore::CryptoKeyHMAC::generate):
432         (WebCore::CryptoKeyHMAC::importRaw):
433         (WebCore::CryptoKeyHMAC::importJwk):
434         (WebCore::CryptoKeyHMAC::buildAlgorithm):
435         * crypto/keys/CryptoKeyHMAC.h:
436         * crypto/keys/CryptoKeyRSA.cpp: Added.
437         (WebCore::CryptoKeyRSA::importJwk):
438         * crypto/keys/CryptoKeyRSA.h:
439         * crypto/parameters/CryptoAlgorithmHmacKeyParams.h: Renamed from Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyGenParams.h.
440         * crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h: Added.
441         * crypto/parameters/HmacKeyParams.idl: Renamed from Source/WebCore/crypto/parameters/HmacKeyGenParams.idl.
442         * crypto/parameters/RsaHashedImportParams.idl: Added.
443
444 2016-11-10  Brady Eidson  <beidson@apple.com>
445
446         IndexedDB 2.0: REGRESSION(r208467) Fix flaky crashes in IDB GC-related code.
447         https://bugs.webkit.org/show_bug.cgi?id=164596
448
449         Reviewed by Eric Carlson.
450
451         No new tests (Covered by existing tests).
452
453         We can't just WTFMove the pointers from the deleted-IDBObject maps...
454         We need to remove the entries, too.
455
456         * Modules/indexeddb/IDBObjectStore.cpp:
457         (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
458
459         * Modules/indexeddb/IDBTransaction.cpp:
460         (WebCore::IDBTransaction::internalAbort):
461
462 2016-11-10  Youenn Fablet  <youennf@gmail.com>
463
464         MediaStreamTrack should use more Ref<> and less RefPtr<>
465         https://bugs.webkit.org/show_bug.cgi?id=164560
466
467         Reviewed by Eric Carlson.
468
469         No change of behavior.
470
471         Make MediaStreamTrack take a Ref<>& instead of a reference.
472         Using Ref<>&& instead of RefPtr<>&& in MediaStreamTrackPrivate.
473         Updating constness of some methods accordingly.
474
475         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
476         (WebCore::MediaEndpointPeerConnection::createReceiver):
477         * Modules/mediastream/MediaStreamTrack.cpp:
478         (WebCore::MediaStreamTrack::create):
479         (WebCore::MediaStreamTrack::MediaStreamTrack):
480         (WebCore::MediaStreamTrack::clone):
481         * Modules/mediastream/MediaStreamTrack.h:
482         * Modules/webaudio/MediaStreamAudioSource.cpp:
483         (WebCore::MediaStreamAudioSource::capabilities):
484         (WebCore::MediaStreamAudioSource::settings):
485         * Modules/webaudio/MediaStreamAudioSource.h:
486         * platform/mediastream/MediaEndpoint.cpp:
487         * platform/mediastream/MediaStreamPrivate.cpp:
488         (WebCore::MediaStreamPrivate::create):
489         * platform/mediastream/MediaStreamTrackPrivate.cpp:
490         (WebCore::MediaStreamTrackPrivate::create):
491         (WebCore::MediaStreamTrackPrivate::MediaStreamTrackPrivate):
492         (WebCore::MediaStreamTrackPrivate::clone):
493         * platform/mediastream/MediaStreamTrackPrivate.h:
494         (WebCore::MediaStreamTrackPrivate::setMuted):
495         (WebCore::MediaStreamTrackPrivate::source):
496         * platform/mediastream/RealtimeMediaSource.h:
497         * platform/mediastream/mac/AVMediaCaptureSource.h:
498         * platform/mediastream/mac/AVMediaCaptureSource.mm:
499         (WebCore::AVMediaCaptureSource::initializeSettings):
500         (WebCore::AVMediaCaptureSource::settings):
501         (WebCore::AVMediaCaptureSource::initializeCapabilities):
502         (WebCore::AVMediaCaptureSource::capabilities):
503         * platform/mediastream/openwebrtc/RealtimeMediaSourceOwr.h:
504         (WebCore::RealtimeMediaSourceOwr::capabilities):
505         (WebCore::RealtimeMediaSourceOwr::settings):
506         * platform/mock/MockRealtimeMediaSource.cpp:
507         (WebCore::MockRealtimeMediaSource::initializeCapabilities):
508         (WebCore::MockRealtimeMediaSource::capabilities):
509         (WebCore::MockRealtimeMediaSource::initializeSettings):
510         (WebCore::MockRealtimeMediaSource::settings):
511         * platform/mock/MockRealtimeMediaSource.h:
512
513 2016-11-10  Per Arne Vollan  <pvollan@apple.com>
514
515         [Win32] Crash in layout tests.
516         https://bugs.webkit.org/show_bug.cgi?id=164411
517
518         Reviewed by Mark Lam.
519
520         Use the calling convention expected by the callers of the generated functions.
521
522         * bindings/scripts/CodeGeneratorJS.pm:
523         (GenerateImplementation):
524         * bindings/scripts/test/JS/JSTestDOMJIT.cpp:
525         (WebCore::unsafeJsTestDOMJITPrototypeFunctionGetAttribute):
526         (WebCore::unsafeJsTestDOMJITPrototypeFunctionItem):
527         (WebCore::unsafeJsTestDOMJITPrototypeFunctionHasAttribute):
528         (WebCore::unsafeJsTestDOMJITPrototypeFunctionGetElementById):
529         (WebCore::unsafeJsTestDOMJITPrototypeFunctionGetElementsByName):
530
531 2016-11-10  Aaron Chu  <aaron_chu@apple.com>
532
533         Web Inspector: AXI: clarify button roles (e.g. toggle or popup button)
534         https://bugs.webkit.org/show_bug.cgi?id=130726
535         <rdar://problem/16420420>
536
537         Reviewed by Brian Burg.
538
539         Test: accessibility/ax-differentiate-button-types.html
540
541         Added special case logic to make sure PopUpButtonRole and ToggleButtonRole to user ButtonRole as role.
542         Added an "isPopUpButton" property to be exposed to the Inspector's use.
543
544         * accessibility/AccessibilityObject.cpp:
545         (WebCore::AccessibilityObject::computedRoleString):
546         * inspector/InspectorDOMAgent.cpp:
547         (WebCore::InspectorDOMAgent::buildObjectForAccessibilityProperties):
548
549 2016-11-10  Zan Dobersek  <zdobersek@igalia.com>
550
551         [EME] Add no-op Web-facing APIs
552         https://bugs.webkit.org/show_bug.cgi?id=164028
553
554         Reviewed by Jer Noble.
555
556         Add no-op implementation of the Web-facing APIs as defined in
557         the EME specification. This will be the basis for implementing
558         the various algorithms the same specification defines, and for
559         implementing the relevant platform abstractions.
560
561         Dictionaries and enumerations defined by the specification are
562         defined in separate headers, and not in the implementation files
563         for the class where they are used. This will ease their use
564         across different implementation files.
565
566         BufferSource now exposes the Variant object it holds. This is
567         needed to support the iterable property on the MediaKeyStatusMap
568         class.
569
570         CodeGeneratorJS is fixed to support JS-to-native conversion of
571         sequences of dictionaries.
572
573         * CMakeLists.txt:
574         * DerivedSources.cpp:
575         * DerivedSources.make:
576         * Modules/encryptedmedia/MediaKeyMessageEvent.cpp: Added.
577         (WebCore::MediaKeyMessageEvent::MediaKeyMessageEvent):
578         (WebCore::MediaKeyMessageEvent::eventInterface):
579         * Modules/encryptedmedia/MediaKeyMessageEvent.h: Added.
580         * Modules/encryptedmedia/MediaKeyMessageEvent.idl: Added.
581         * Modules/encryptedmedia/MediaKeyMessageEventInit.h: Added.
582         (WebCore::MediaKeyMessageEventInit::MediaKeyMessageEventInit):
583         * Modules/encryptedmedia/MediaKeyMessageType.h: Added.
584         * Modules/encryptedmedia/MediaKeySession.cpp: Added.
585         (WebCore::MediaKeySession::create):
586         (WebCore::MediaKeySession::MediaKeySession):
587         (WebCore::MediaKeySession::sessionId):
588         (WebCore::MediaKeySession::expiration):
589         (WebCore::MediaKeySession::keyStatuses):
590         (WebCore::MediaKeySession::generateRequest):
591         (WebCore::MediaKeySession::load):
592         (WebCore::MediaKeySession::update):
593         (WebCore::MediaKeySession::close):
594         (WebCore::MediaKeySession::remove):
595         (WebCore::MediaKeySession::hasPendingActivity):
596         (WebCore::MediaKeySession::activeDOMObjectName):
597         (WebCore::MediaKeySession::canSuspendForDocumentSuspension):
598         (WebCore::MediaKeySession::stop):
599         * Modules/encryptedmedia/MediaKeySession.h: Added.
600         * Modules/encryptedmedia/MediaKeySession.idl: Added.
601         * Modules/encryptedmedia/MediaKeySessionType.h: Added.
602         * Modules/encryptedmedia/MediaKeyStatus.h: Added.
603         * Modules/encryptedmedia/MediaKeyStatusMap.cpp: Added.
604         (WebCore::MediaKeyStatusMap::size):
605         (WebCore::MediaKeyStatusMap::has):
606         (WebCore::MediaKeyStatusMap::get):
607         (WebCore::MediaKeyStatusMap::Iterator::Iterator):
608         (WebCore::MediaKeyStatusMap::Iterator::next):
609         * Modules/encryptedmedia/MediaKeyStatusMap.h: Added.
610         (WebCore::MediaKeyStatusMap::create):
611         (WebCore::MediaKeyStatusMap::createIterator):
612         * Modules/encryptedmedia/MediaKeyStatusMap.idl: Added.
613         * Modules/encryptedmedia/MediaKeySystemAccess.cpp: Added.
614         (WebCore::MediaKeySystemAccess::keySystem):
615         (WebCore::MediaKeySystemAccess::getConfiguration):
616         (WebCore::MediaKeySystemAccess::createMediaKeys):
617         * Modules/encryptedmedia/MediaKeySystemAccess.h: Added.
618         (WebCore::MediaKeySystemAccess::create):
619         * Modules/encryptedmedia/MediaKeySystemAccess.idl: Added.
620         * Modules/encryptedmedia/MediaKeySystemConfiguration.h: Added.
621         * Modules/encryptedmedia/MediaKeySystemConfiguration.idl: Added.
622         * Modules/encryptedmedia/MediaKeySystemMediaCapability.h: Added.
623         * Modules/encryptedmedia/MediaKeySystemMediaCapability.idl: Added.
624         * Modules/encryptedmedia/MediaKeys.cpp: Added.
625         (WebCore::MediaKeys::createSession):
626         (WebCore::MediaKeys::setServerCertificate):
627         * Modules/encryptedmedia/MediaKeys.h: Added.
628         (WebCore::MediaKeys::create):
629         * Modules/encryptedmedia/MediaKeys.idl: Added.
630         * Modules/encryptedmedia/MediaKeysRequirement.h: Added.
631         * Modules/encryptedmedia/NavigatorEME.cpp: Added.
632         (WebCore::NavigatorEME::requestMediaKeySystemAccess):
633         * Modules/encryptedmedia/NavigatorEME.h: Added.
634         * Modules/encryptedmedia/NavigatorEME.idl: Added.
635         * WebCore.xcodeproj/project.pbxproj:
636         * bindings/js/BufferSource.h:
637         (WebCore::BufferSource::BufferSource):
638         (WebCore::BufferSource::variant):
639         * bindings/js/JSMediaKeySessionCustom.cpp: Added.
640         (WebCore::JSMediaKeySession::closed):
641         * bindings/js/JSMediaKeySystemAccessCustom.cpp: Added.
642         (WebCore::JSMediaKeySystemAccess::getConfiguration):
643         * bindings/scripts/CodeGeneratorJS.pm:
644         (GetNativeVectorInnerType):
645         * dom/EventNames.h:
646         * dom/EventNames.in:
647         * dom/EventTargetFactory.in:
648         * html/HTMLMediaElement.cpp:
649         (WebCore::HTMLMediaElement::mediaKeys):
650         (WebCore::HTMLMediaElement::setMediaKeys):
651         * html/HTMLMediaElement.h:
652         * html/HTMLMediaElement.idl:
653         * html/MediaEncryptedEvent.cpp: Added.
654         (WebCore::MediaEncryptedEvent::MediaEncryptedEvent):
655         (WebCore::MediaEncryptedEvent::eventInterface):
656         (WebCore::MediaEncryptedEvent::initDataType):
657         (WebCore::MediaEncryptedEvent::initData):
658         * html/MediaEncryptedEvent.h: Added.
659         * html/MediaEncryptedEvent.idl: Added.
660         * html/MediaEncryptedEventInit.h: Added.
661         (WebCore::MediaEncryptedEventInit::MediaEncryptedEventInit):
662
663 2016-11-10  Antoine Quint  <graouts@apple.com>
664
665         [Modern Media Controls] Media Controller: update controls based on fullscreen playback on macOS
666         https://bugs.webkit.org/show_bug.cgi?id=164554
667         <rdar://problem/29183439>
668
669         Reviewed by Dean Jackson.
670
671         When toggling fullscreen on macOS, toggle between MacOSInlineMediaControls and MacOSFullscreenMediaControls.
672         To facilitate this, support objects are created and destroyed when changing the controls in order for the
673         right control objects to be hooked up to the media controller. A new destroy() method on MediaControllerSupport
674         subclasses can be overridden to remove event listeners added by support objects in their constructor.
675
676         Test: media/modern-media-controls/media-controller/media-controller-fullscreen-change.html
677
678         * Modules/modern-media-controls/media/fullscreen-support.js:
679         (FullscreenSupport.prototype.destroy):
680         * Modules/modern-media-controls/media/media-controller-support.js:
681         (MediaControllerSupport.prototype.destroy):
682         * Modules/modern-media-controls/media/media-controller.js:
683         (MediaController):
684         (MediaController.prototype.get layoutTraits):
685         (MediaController.prototype.handleEvent):
686         (MediaController.prototype._updateControlsIfNeeded):
687         (MediaController.prototype._controlsClass):
688
689 2016-11-10  Carlos Garcia Campos  <cgarcia@igalia.com>
690
691         [Linux] Memory values shown by memory pressure handler logger are not useful
692         https://bugs.webkit.org/show_bug.cgi?id=164589
693
694         Reviewed by Michael Catanzaro.
695
696         We are currently using the VmSize field from /proc/self/status which is the virtual memory size of the process
697         and doesn't normally change even when the memory pressure handler manages to release memory. So, most of the
698         time we see that there's no changes in memory usage in the logs.
699         We should use the actual memory used by the process, memory that the process can release and then it's relevant
700         for the memory pressure handler. Using other fields from /proc/self/status we could do something like VmRSS -
701         (RssFile + RssShme), but there's also /proc/self/statm that provides the same information in a single. The main
702         different is that statm provides both resident and shared memory directly, but in number of pages, so we need to
703         multiply by the size of the page.
704         This patch adds a method to parse /proc/self/statm in its given file, because I plan to use this for the linux
705         memory sampler that is incorrectly parsing /proc/self/statm.
706
707         * platform/Linux.cmake: Add new files to compilation.
708         * platform/linux/CurrentProcessMemoryStatus.cpp: Added.
709         (WebCore::systemPageSize): Return the page size.
710         (WebCore::currentProcessMemoryStatus): Parse /proc/self/statm and fill the given ProcessMemoryStatus.
711         * platform/linux/CurrentProcessMemoryStatus.h: Added.
712         * platform/linux/MemoryPressureHandlerLinux.cpp:
713         (WebCore::MemoryPressureHandler::processMemoryUsage(): Helper function to return the memory used by the process
714         in bytes.
715         (WebCore::MemoryPressureHandler::ReliefLogger::platformMemoryUsage): Use processMemoryUsage().
716
717 2016-10-14  Carlos Garcia Campos  <cgarcia@igalia.com>
718
719         MemoryPressureHandler shouldn't know how to release WebCore memory
720         https://bugs.webkit.org/show_bug.cgi?id=160497
721
722         Reviewed by Michael Catanzaro.
723
724         All processes should set their own low memory handler, instead of leaving the web process using the default one
725         that needs to access APIs that are not in platform layer. This patch fixes all the layering violations in the
726         MemoryPressureHandler. Since the default implementation, that releases the WebCore memory, is shared by the
727         WebProcess in WebKit2 and WebKit1 ports, it has been moved to its own file to the WebCore layer.
728
729         * CMakeLists.txt: Add new files to compilation.
730         * PlatformMac.cmake: Ditto.
731         * WebCore.xcodeproj/project.pbxproj: Ditto.
732         * loader/FrameLoader.cpp:
733         (WebCore::FrameLoader::commitProvisionalLoad): Use WebCore::jettisonExpensiveObjectsOnTopLevelNavigation().
734         * page/MemoryRelease.cpp: Added.
735         (WebCore::releaseNoncriticalMemory):
736         (WebCore::releaseCriticalMemory):
737         (WebCore::releaseMemory):
738         (WebCore::platformReleaseMemory):
739         (WebCore::jettisonExpensiveObjectsOnTopLevelNavigation):
740         (WebCore::registerMemoryReleaseNotifyCallbacks):
741         * page/MemoryRelease.h: Added.
742         * page/cocoa/MemoryReleaseCocoa.mm: Added.
743         (WebCore::platformReleaseMemory):
744         (WebCore::jettisonExpensiveObjectsOnTopLevelNavigation):
745         (WebCore::registerMemoryReleaseNotifyCallbacks):
746         * platform/MemoryPressureHandler.cpp:
747         (WebCore::MemoryPressureHandler::MemoryPressureHandler):
748         (WebCore::MemoryPressureHandler::beginSimulatedMemoryPressure):
749         (WebCore::MemoryPressureHandler::releaseMemory): Use the current handler if it has been set.
750         (WebCore::MemoryPressureHandler::platformReleaseMemory): Deleted.
751         * platform/MemoryPressureHandler.h:
752         (WebCore::MemoryPressureHandler::setLowMemoryHandler):
753         (WebCore::MemoryPressureHandler::m_releaseMemoryBlock):
754         * platform/cocoa/MemoryPressureHandlerCocoa.mm:
755         (WebCore::MemoryPressureHandler::respondToMemoryPressure): Call releaseMemory() instead of using the handler directly.
756         (WebCore::MemoryPressureHandler::platformReleaseMemory): Deleted.
757         * platform/linux/MemoryPressureHandlerLinux.cpp:
758         * platform/win/MemoryPressureHandlerWin.cpp:
759         (WebCore::MemoryPressureHandler::respondToMemoryPressure): Call releaseMemory() instead of using the handler directly.
760
761 2016-11-08  Sergio Villar Senin  <svillar@igalia.com>
762
763         [css-grid] Fix fr tracks sizing under min|max-size constraints
764         https://bugs.webkit.org/show_bug.cgi?id=150674
765
766         Reviewed by Darin Adler.
767
768         The min|max-sizes must be used to compute the flex fraction for indefinite free
769         spaces. According to the spec "If using this flex fraction would cause the grid to be
770         smaller than the grid container’s min-width/height (or larger than the grid container’s
771         max-width/height), then redo this step, treating the free space as definite and the
772         available grid space as equal to the grid container’s content box size when it’s sized to
773         its min-width/height (max-width/height)."
774
775         This only affects indefinite heights because during layout both definite sizes and any kind
776         of widths are properly constrained by min|max-width restrictions.
777
778         Tests: fast/css-grid-layout/flex-sizing-columns-min-max-width.html
779                fast/css-grid-layout/flex-sizing-rows-min-max-height.html
780
781         * rendering/RenderGrid.cpp:
782         (WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
783         (WebCore::RenderGrid::computeFlexSizedTracksGrowth):
784         * rendering/RenderGrid.h:
785
786 2016-11-10  Alejandro G. Castro  <alex@igalia.com>
787
788         [WebRTC] [OpenWebRTC] RTX default parameters broken after r207952
789         https://bugs.webkit.org/show_bug.cgi?id=164541
790
791         Reviewed by Philippe Normand.
792
793         Fixed typo in refactoring.
794
795         * platform/mediastream/openwebrtc/MediaEndpointOwr.cpp:
796         (WebCore::MediaEndpointOwr::getDefaultVideoPayloads):
797
798 2016-11-08  Philippe Normand  <pnormand@igalia.com>
799
800         [WebRTC] white-list turns urls from the RTCConfiguration
801         https://bugs.webkit.org/show_bug.cgi?id=164506
802
803         Reviewed by Alejandro G. Castro.
804
805         * Modules/mediastream/RTCConfiguration.cpp:
806         (WebCore::validateIceServerURL): Add the turns URL scheme to the
807         list of supported relay and signaling server protocols.
808
809 2016-11-09  Joseph Pecoraro  <pecoraro@apple.com>
810
811         Web Inspector: DebuggerManager.Event.Resumed introduces test flakiness
812         https://bugs.webkit.org/show_bug.cgi?id=161951
813         <rdar://problem/28295767>
814
815         Reviewed by Brian Burg.
816
817         Covered by existing tests that would ASSERT otherwise.
818
819         * inspector/InspectorClient.cpp:
820         (WebCore::InspectorClient::doDispatchMessageOnFrontendPage):
821         When paused on an exception in the inspected page and evaluating
822         commands in the inspector frontend page (which evaluates JavaScript)
823         we ASSERT when entering the Global DOM VM with an existing exception.
824         This makes it so when we evaluate JavaScript in the frontend we
825         suspend / ignore the state of the VM for the inspected page, and
826         restore it when we return from the inspector.
827
828 2016-11-09  Joseph Pecoraro  <pecoraro@apple.com>
829
830         Web Inspector: Associate Worker Resources with the Worker and not the Page
831         https://bugs.webkit.org/show_bug.cgi?id=164342
832         <rdar://problem/29075775>
833
834         Reviewed by Timothy Hatcher.
835
836         Test: inspector/worker/resources-in-worker.html
837
838         Provide a way to associate an initiator identifier with a ResourceRequest.
839         This will allow Web Inspector to identify who started particular resource
840         loads. This is important to associate Worker(...), importScript(...), and
841         XMLHttpRequest / Fetch loads with that specific Worker.
842
843         * platform/network/ResourceRequestBase.cpp:
844         (WebCore::ResourceRequestBase::setAsIsolatedCopy):
845         * platform/network/ResourceRequestBase.h:
846         (WebCore::ResourceRequestBase::initiatorIdentifier):
847         (WebCore::ResourceRequestBase::setInitiatorIdentifier):
848         Optional initiator identifier. Currently used only be Web Inspector.
849
850         * dom/ScriptExecutionContext.h:
851         (WebCore::ScriptExecutionContext::resourceRequestIdentifier):
852         Non-page execution contexts, like WorkerGlobalScope, should provide
853         a unique identifier that may be used to distinguish loads initiated
854         from within that context.
855
856         * xml/XMLHttpRequest.cpp:
857         (WebCore::XMLHttpRequest::createRequest):
858         * Modules/fetch/FetchLoader.cpp:
859         (WebCore::FetchLoader::start):
860         * Modules/fetch/FetchRequest.cpp:
861         (WebCore::FetchRequest::initializeWith):
862         XHR / Fetch loads should include the ScriptExecutionContext's
863         initiator identifier.
864
865         * workers/WorkerScriptLoader.cpp:
866         (WebCore::WorkerScriptLoader::WorkerScriptLoader):
867         (WebCore::WorkerScriptLoader::loadSynchronously):
868         (WebCore::WorkerScriptLoader::loadAsynchronously):
869         (WebCore::WorkerScriptLoader::createResourceRequest):
870         * workers/WorkerScriptLoader.h:
871         Provide a way to provide initiator identifier information for
872         Worker script loads. Currently this is `new Worker(...)` and
873         `importScripts(...)` resource loads.
874
875         * workers/Worker.cpp:
876         (WebCore::Worker::Worker):
877         (WebCore::Worker::create):
878         * workers/Worker.h:
879         * workers/WorkerGlobalScope.cpp:
880         (WebCore::WorkerGlobalScope::WorkerGlobalScope):
881         (WebCore::WorkerGlobalScope::importScripts):
882         * workers/WorkerGlobalScope.h:
883         Give Worker itself the unique identifier, because `new Worker(...)`
884         loads happen before the WorkerGlobalScript (ScriptExecutionContext)
885         is actually created, but we want to associate it with this Worker.
886
887         * workers/DedicatedWorkerGlobalScope.cpp:
888         (WebCore::DedicatedWorkerGlobalScope::create):
889         (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
890         * workers/DedicatedWorkerGlobalScope.h:
891         * workers/DedicatedWorkerThread.cpp:
892         (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
893         (WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
894         * workers/DedicatedWorkerThread.h:
895         * workers/WorkerInspectorProxy.cpp:
896         (WebCore::WorkerInspectorProxy::WorkerInspectorProxy):
897         * workers/WorkerInspectorProxy.h:
898         * workers/WorkerMessagingProxy.cpp:
899         (WebCore::WorkerMessagingProxy::WorkerMessagingProxy):
900         (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
901         * workers/WorkerThread.cpp:
902         (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
903         (WebCore::WorkerThread::WorkerThread):
904         (WebCore::WorkerThread::workerThread):
905         * workers/WorkerThread.h:
906         Pass the MainThread's Worker identifier through to the WorkerGlobalScope
907         created on the WorkerThread. They should be the same identifier.
908
909         * inspector/InspectorNetworkAgent.cpp:
910         (WebCore::InspectorNetworkAgent::willSendRequest):
911         * inspector/InspectorPageAgent.cpp:
912         (WebCore::InspectorPageAgent::buildObjectForFrameTree):
913         Pass the initiator identifier data to the frontend. This identifier is
914         equivalent to a "target identifier" in the frontend. Currently the only
915         non-Page targets are Workers.
916
917         * loader/cache/CachedResourceLoader.cpp:
918         (WebCore::CachedResourceLoader::shouldContinueAfterNotifyingLoadedFromMemoryCache):
919         When using the memory cache we create a new resource request. Be sure
920         to copy over useful inspector data, like the initiator identifier,
921         from the original request.
922
923         * platform/network/cf/ResourceRequestCFNet.cpp:
924         (WebCore::ResourceRequest::updateFromDelegatePreservingOldProperties):
925         When rebuilding a ResourceRequest from NSURLRequest, copy over the
926         initiator identifier property that wouldn't otherwise have survived
927         the transition.
928
929 2016-11-09  Brady Eidson  <beidson@apple.com>
930
931         IndexedDB 2.0: Clean up some exception ordering.
932         https://bugs.webkit.org/show_bug.cgi?id=164566
933
934         Reviewed by Alex Christensen.
935
936         No new tests (Covered by existing tests).
937
938         * Modules/indexeddb/IDBCursor.cpp:
939         (WebCore::IDBCursor::advance):
940         (WebCore::IDBCursor::continueFunction):
941
942         * Modules/indexeddb/IDBObjectStore.cpp:
943         (WebCore::IDBObjectStore::createIndex):
944
945 2016-11-09  Alex Christensen  <achristensen@webkit.org>
946
947         Unreviewed, rolling out r208438.
948
949         crashes
950
951         Reverted changeset:
952
953         "[WK2][NETWORK_SESSION] Add support for downloading file
954         backed blobs"
955         https://bugs.webkit.org/show_bug.cgi?id=164458
956         http://trac.webkit.org/changeset/208438
957
958 2016-11-09  Said Abou-Hallawa  <sabouhallawa@apple.com>
959
960         Change the decoding for some animated images to be asynchronous
961         https://bugs.webkit.org/show_bug.cgi?id=161566
962
963         Reviewed by Simon Fraser.
964
965         Tests: fast/images/slower-animation-than-decoding-image.html
966                fast/images/slower-decoding-than-animation-image.html
967                fast/images/stopped-animation-deleted-image.html
968                
969         Request the next frame before firing the animation timer. The asynchronous
970         image decoding work queue notifies the BitmapImage when the frame finishes
971         decoding. If the timer fires before the frame is decoded, no repaint will
972         be requested. Only when the image frame is ready, the animation will be
973         advanced and the image will be repainted.
974
975         * loader/cache/CachedImage.cpp:
976         (WebCore::CachedImage::load): Cache the image settings in CachedImage.
977         (WebCore::CachedImage::createImage): No need to pass allowSubsampling to BitmapImage. It can be retrieved through Image::imageObserver().
978         (WebCore::CachedImage::changedInRect): Change the parameter to notifyObservers() to be a pointer.
979         * loader/cache/CachedImage.h: Cache the settings: allowSubsampling, allowAsyncImageDecoding and showDebugBackground through m_loader.
980         * platform/graphics/BitmapImage.cpp:
981         (WebCore::BitmapImage::dataChanged): Fix a logging message.
982         (WebCore::BitmapImage::draw): Store the current SubsamplingLevel to be used when requesting decoding the image of the next frame.
983         Draw a debug rectangle if the next frame is missed because it is being decoded and the setting showDebugBackground is on.
984         (WebCore::BitmapImage::startAnimation): Deleted. Moved to the header file.
985         (WebCore::BitmapImage::internalStartAnimation): Added. Request asynchronous image decoding for the next frame if required. Return the
986         result of starting the animation.
987         (WebCore::BitmapImage::advanceAnimation): Call internalAdvanceAnimation() if the frame image is not being decoded. If it is being decoded
988         and the setting showDebugBackground is on, force repaint so the debug rectangle is drawn.
989         (WebCore::BitmapImage::internalAdvanceAnimation): This is the old body of advanceAnimation().
990         (WebCore::BitmapImage::stopAnimation): Stop the asynchronous image decoding if it is started.
991         (WebCore::BitmapImage::newFrameNativeImageAvailableAtIndex): This function is called from the async image decoding work queue when finishing decoding a native image frame.
992         * platform/graphics/BitmapImage.h:
993         (WebCore::BitmapImage::startAnimation): Added. It is now calls internalStartAnimation().
994         * platform/graphics/Color.h: Define a constant for the yellow color.
995         * platform/graphics/ImageFrameCache.cpp:
996         (WebCore::ImageFrameCache::clearMetadata): Delete unreferenced member.
997         (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Return true if the frame is requested for async decoding.
998         * platform/graphics/ImageFrameCache.h:
999         * platform/graphics/ImageObserver.h:  Add virtual functions for allowSubsampling, allowAsyncImageDecoding and showDebugBackground.
1000         * platform/graphics/ImageSource.cpp:
1001         (WebCore::ImageSource::maximumSubsamplingLevel): Move checking allowSubsampling() to the caller BitmapImage::draw().
1002         * platform/graphics/ImageSource.h: Remove the setting allowSubsampling(); it can be retrieved from imageObserver().
1003         (WebCore::ImageSource::setAllowSubsampling): Deleted.
1004         * rendering/RenderImageResource.cpp:
1005         (WebCore::RenderImageResource::shutdown): Stop the animation of an image when shutting down the resource.
1006         * rendering/RenderImageResourceStyleImage.cpp:
1007         (WebCore::RenderImageResourceStyleImage::shutdown): Ditto.
1008         svg/graphics/SVGImageClients.h: Change the parameter to ImageObserver::changedInRect() to be a pointer.
1009         (WebCore::SVGImageChromeClient::invalidateContentsAndRootView):
1010         * testing/Internals.cpp:
1011         (WebCore::Internals::setImageFrameDecodingDuration): Sets a fixed frame decoding duration for testing.
1012         * testing/Internals.h:
1013         * testing/Internals.idl: Adds an internal option for ImageFrameDecodingDuration.
1014
1015 2016-11-04  Brent Fulgham  <bfulgham@apple.com>
1016
1017         Local HTML should be blocked from localStorage access unless "Disable Local File Restrictions" is checked
1018         https://bugs.webkit.org/show_bug.cgi?id=155185
1019         <rdar://problem/11101440>
1020
1021         Reviewed by Brady Eidson.
1022
1023         Add a new quirk for localStorage that defaults to 'on'. When active, this quirk says that
1024         localStorage access should be granted, without needing to grant universal file access.
1025
1026         If the quirk is turned off, then localStorage is blocked unless the WebKit client explicitly
1027         grants universal file access.
1028
1029         Tests: storage/domstorage/localstorage/blocked-file-access-permitted-by-quirk.html
1030                storage/domstorage/localstorage/blocked-file-access.html
1031
1032         * dom/Document.cpp:
1033         (WebCore::Document::initSecurityContext): Set localStorage quirk mode based on settings.
1034         * page/SecurityOrigin.cpp:
1035         (WebCore::SecurityOrigin::SecurityOrigin): Use more C++11 initializers.
1036         (WebCore::SecurityOrigin::canAccessStorage): If the origin is a local file, and we are NOT in
1037         localStorage quirks mode, and we have not been granted universal file access, prevent access
1038         to DOM localStorage.
1039         (WebCore::SecurityOrigin::setNeedsLocalStorageQuirk): Added.
1040         * page/SecurityOrigin.h:
1041         (WebCore::SecurityOrigin::needsLocalStorageQuirk): Added.
1042         * page/Settings.in:
1043         * workers/WorkerGlobalScope.cpp:
1044         (WebCore::WorkerGlobalScope::WorkerGlobalScope): Make sure Workers know what the
1045         localStorage quirks mode is set to.
1046
1047 2016-11-09  Alex Christensen  <achristensen@webkit.org>
1048
1049         URLParser should not consider path of URLs with no host to start at the first slash after the colon
1050         https://bugs.webkit.org/show_bug.cgi?id=164555
1051
1052         Reviewed by Tim Horton.
1053
1054         When we see a url that is only scheme:// we treated the // as the path.  Firefox did this with unrecognized schemes,
1055         but based on https://github.com/whatwg/url/issues/148 they seem willing to change.  We had added similar behavior to
1056         URL::parse, and I added this to URLParser in r206783 which this effectively reverts.
1057
1058         Covered by API and layout tests.
1059
1060         * platform/URLParser.cpp:
1061         (WebCore::URLParser::parse):
1062         Don't move m_userStart to m_pathStart back by two when we see an empty host.
1063
1064 2016-11-09  Alex Christensen  <achristensen@webkit.org>
1065
1066         Simplify logic of SecurityOrigin::databaseIdentifier
1067         https://bugs.webkit.org/show_bug.cgi?id=164565
1068
1069         Reviewed by Brady Eidson.
1070
1071         No change in behavior.
1072
1073         SecurityOrigins with the file scheme need a special database identifier to be backwards-compatible with existing storage.
1074         Instead of determining whether this is a file SecurityOrigin at parsing time and only using that information when
1075         making the database identifier, just determine whether we need this quirk when making the database identifier.
1076         I'm planning to move this logic to SecurityOriginData in another patch.
1077
1078         * page/SecurityOrigin.cpp:
1079         (WebCore::SecurityOrigin::SecurityOrigin):
1080         (WebCore::SecurityOrigin::create):
1081         (WebCore::SecurityOrigin::databaseIdentifier):
1082         * page/SecurityOrigin.h:
1083
1084 2016-11-09  Jaehun Lim  <ljaehun.lim@samsung.com>
1085
1086         Unreviewed, build fix after r208460
1087
1088         isValidColorString() was renamed isValidSimpleColorString().
1089
1090         * html/ColorInputType.cpp:
1091         (WebCore::ColorInputType::suggestions):
1092
1093 2016-11-09  Anders Carlsson  <andersca@apple.com>
1094
1095         Fix STP build.
1096
1097         * WebCorePrefix.h:
1098
1099 2016-11-09  Simon Fraser  <simon.fraser@apple.com>
1100
1101         Implement visual-viewport based position:fixed handling for Mac async scrolling
1102         https://bugs.webkit.org/show_bug.cgi?id=164495
1103
1104         Reviewed by Tim Horton.
1105
1106         Educate the scrolling tree about visual and layout viewports. This is runtime-switchable,
1107         so we push the enable flag to via the root state node, then push the layout viewport,
1108         and the min/max scroll position that contstrain it, through frame state nodes.
1109
1110         When a scroll happens, we compute a new layout viewport when the visual viewport hits
1111         an edge, and push that down through setScrollLayerPosition() since it's used to position
1112         fixed and sticky layers.
1113
1114         When the main thread gets notified about an async scroll, we set the new layout viewport
1115         on the FrameView, but do so in such a way that does not trigger layout. This is OK because
1116         we do a RenderLayer update which udpates all the layoutViewport-dependent state, and is
1117         necessary to avoid repaints every main thread update.
1118
1119         The iOS code is made to compile, but not work yet.
1120
1121         Tests: compositing/tiling/visiblerect-accumulated-offset.html
1122                fast/visual-viewport/tiled-drawing/zoomed-fixed-scrolled-down-then-up.html
1123                fast/visual-viewport/tiled-drawing/zoomed-fixed-scrolled-down.html
1124                fast/visual-viewport/tiled-drawing/zoomed-fixed-scrolling-layers-state.html
1125
1126         * page/FrameView.cpp:
1127         (WebCore::FrameView::setLayoutViewportOrigin):
1128         (WebCore::FrameView::updateLayoutViewport):
1129         (WebCore::FrameView::visualViewportRect):
1130         (WebCore::FrameView::unscaledMinimumScrollPosition):
1131         (WebCore::FrameView::scrollPositionChanged):
1132         * page/FrameView.h:
1133         * page/scrolling/AsyncScrollingCoordinator.cpp:
1134         (WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated):
1135         (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
1136         (WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll):
1137         (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired):
1138         (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
1139         (WebCore::AsyncScrollingCoordinator::visualViewportEnabled):
1140         * page/scrolling/AsyncScrollingCoordinator.h:
1141         (WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::ScheduledScrollUpdate):
1142         * page/scrolling/ScrollingStateFrameScrollingNode.cpp:
1143         (WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
1144         (WebCore::ScrollingStateFrameScrollingNode::setLayoutViewport):
1145         (WebCore::ScrollingStateFrameScrollingNode::setMinLayoutViewportOrigin):
1146         (WebCore::ScrollingStateFrameScrollingNode::setMaxLayoutViewportOrigin):
1147         (WebCore::ScrollingStateFrameScrollingNode::setVisualViewportEnabled):
1148         (WebCore::ScrollingStateFrameScrollingNode::dumpProperties):
1149         * page/scrolling/ScrollingStateFrameScrollingNode.h:
1150         * page/scrolling/ScrollingTree.cpp:
1151         (WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling):
1152         (WebCore::ScrollingTree::scrollPositionChangedViaDelegatedScrolling):
1153         (WebCore::ScrollingTree::commitTreeState):
1154         * page/scrolling/ScrollingTree.h:
1155         (WebCore::ScrollingTree::visualViewportEnabled):
1156         (WebCore::ScrollingTree::setVisualViewportEnabled):
1157         * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
1158         (WebCore::ScrollingTreeFrameScrollingNode::commitStateBeforeChildren):
1159         (WebCore::ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition):
1160         * page/scrolling/ScrollingTreeFrameScrollingNode.h:
1161         (WebCore::ScrollingTreeFrameScrollingNode::layoutViewport):
1162         (WebCore::ScrollingTreeFrameScrollingNode::minLayoutViewportOrigin):
1163         (WebCore::ScrollingTreeFrameScrollingNode::maxLayoutViewportOrigin):
1164         * page/scrolling/ScrollingTreeScrollingNode.cpp:
1165         (WebCore::ScrollingTreeScrollingNode::setScrollPositionWithoutContentEdgeConstraints):
1166         * page/scrolling/ScrollingTreeScrollingNode.h:
1167         * page/scrolling/ThreadedScrollingTree.cpp:
1168         (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
1169         * page/scrolling/ThreadedScrollingTree.h:
1170         * page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.h:
1171         * page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm:
1172         (WebCore::ScrollingTreeFrameScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstraints):
1173         (WebCore::ScrollingTreeFrameScrollingNodeIOS::setScrollLayerPosition):
1174         * page/scrolling/ios/ScrollingTreeIOS.cpp:
1175         (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll):
1176         * page/scrolling/ios/ScrollingTreeIOS.h:
1177         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
1178         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
1179         (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):
1180         (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition):
1181
1182 2016-11-09  Brady Eidson  <beidson@apple.com>
1183
1184         IndexedDB 2.0: W3C test IndexedDB/idbtransaction_objectStoreNames.html fails.
1185         https://bugs.webkit.org/show_bug.cgi?id=164528
1186
1187         Reviewed by Alex Christensen.
1188
1189         No new tests (Covered by existing test).
1190
1191         * Modules/indexeddb/IDBDatabase.cpp:
1192         (WebCore::IDBDatabase::transaction): De-dupe the input names.
1193
1194 2016-11-09  Brady Eidson  <beidson@apple.com>
1195
1196         IndexedDB 2.0: Implement new IDBCursor.continuePrimaryKey function.
1197         https://bugs.webkit.org/show_bug.cgi?id=164404
1198
1199         Reviewed by Alex Christensen.
1200
1201         Tests: storage/indexeddb/modern/idbcursor-continue-primary-key-1-private.html
1202                storage/indexeddb/modern/idbcursor-continue-primary-key-1.html
1203                Also covered by existing tests.
1204
1205         * Modules/indexeddb/IDBCursor.cpp:
1206         (WebCore::IDBCursor::continuePrimaryKey):
1207         (WebCore::IDBCursor::uncheckedIterateCursor):
1208         * Modules/indexeddb/IDBCursor.h:
1209         * Modules/indexeddb/IDBCursor.idl:
1210
1211         * Modules/indexeddb/IDBKeyData.h:
1212         (WebCore::IDBKeyData::operator>):
1213         (WebCore::IDBKeyData::operator<=):
1214         (WebCore::IDBKeyData::operator>=):
1215
1216         * Modules/indexeddb/server/MemoryCursor.h:
1217
1218         * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
1219         (WebCore::IDBServer::MemoryIDBBackingStore::iterateCursor):
1220
1221         * Modules/indexeddb/server/MemoryIndexCursor.cpp:
1222         (WebCore::IDBServer::MemoryIndexCursor::iterate):
1223         * Modules/indexeddb/server/MemoryIndexCursor.h:
1224
1225         * Modules/indexeddb/server/MemoryObjectStoreCursor.cpp:
1226         (WebCore::IDBServer::MemoryObjectStoreCursor::iterate):
1227         * Modules/indexeddb/server/MemoryObjectStoreCursor.h:
1228
1229         * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
1230         (WebCore::IDBServer::SQLiteIDBBackingStore::iterateCursor):
1231
1232         * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
1233         (WebCore::IDBServer::SQLiteIDBCursor::iterate):
1234         * Modules/indexeddb/server/SQLiteIDBCursor.h:
1235
1236         * Modules/indexeddb/shared/IDBIterateCursorData.cpp:
1237         (WebCore::IDBIterateCursorData::isolatedCopy):
1238         * Modules/indexeddb/shared/IDBIterateCursorData.h:
1239         (WebCore::IDBIterateCursorData::encode):
1240         (WebCore::IDBIterateCursorData::decode):
1241
1242 2016-11-09  Antoine Quint  <graouts@apple.com>
1243
1244         [Modern Media Controls] Media Controller: set status label according to media state
1245         https://bugs.webkit.org/show_bug.cgi?id=164557
1246         <rdar://problem/29184097>
1247
1248         Reviewed by Dean Jackson.
1249
1250         Correctly set the StatusLabel text based on the media loading and network state.
1251
1252         Tests: http/tests/media/modern-media-controls/status-support/status-support-live-broadcast.html
1253                http/tests/media/modern-media-controls/status-support/status-support-loading.html
1254                media/modern-media-controls/status-support/status-support-error.html
1255
1256         * Modules/modern-media-controls/js-files:
1257         * Modules/modern-media-controls/media/media-controller.js:
1258         (MediaController):
1259         * Modules/modern-media-controls/media/status-support.js: Added.
1260         (StatusSupport.prototype.get control):
1261         (StatusSupport.prototype.get mediaEvents):
1262         (StatusSupport.prototype.syncControl):
1263         (StatusSupport):
1264         * WebCore.xcodeproj/project.pbxproj:
1265
1266 2016-11-09  Zalan Bujtas  <zalan@apple.com>
1267
1268         No need to set setFlowThreadState on RenderText in createTextRenderer.
1269         https://bugs.webkit.org/show_bug.cgi?id=164559
1270
1271         Reviewed by Antti Koivisto.
1272
1273        setFlowThreadState in create*Renderer ensures that by the time we issue the initial call to
1274        styleWillChange/styleDidChange through initializeStyle, the state is already set.
1275        However since RenderText does not have its own style, it's sufficient to have the flow state set
1276        through the normal RenderElement::insertChildInternal code path.
1277
1278         No change in functionality.
1279
1280         * style/RenderTreeUpdater.cpp:
1281         (WebCore::createTextRenderer):
1282
1283 2016-11-09  Brady Eidson  <beidson@apple.com>
1284
1285         IndexedDB 2.0: Encapsulate cursor iteration parameters for easy future expansion.
1286         https://bugs.webkit.org/show_bug.cgi?id=164504
1287
1288         Reviewed by Darin Adler.
1289
1290         No new tests (Refactor, no behavior change).
1291
1292         This patch literally just takes the "key" and "count" arguments and encapsulates them in a struct.
1293         That struct will then be easily expandable in the future (e.g. bug 164404).
1294
1295         * Modules/indexeddb/IDBCursor.cpp:
1296         (WebCore::IDBCursor::uncheckedIterateCursor):
1297         
1298         * Modules/indexeddb/IDBTransaction.cpp:
1299         (WebCore::IDBTransaction::iterateCursor):
1300         (WebCore::IDBTransaction::iterateCursorOnServer):
1301         * Modules/indexeddb/IDBTransaction.h:
1302         
1303         * Modules/indexeddb/client/IDBConnectionProxy.cpp:
1304         (WebCore::IDBClient::IDBConnectionProxy::iterateCursor):
1305         * Modules/indexeddb/client/IDBConnectionProxy.h:
1306         
1307         * Modules/indexeddb/client/IDBConnectionToServer.cpp:
1308         (WebCore::IDBClient::IDBConnectionToServer::iterateCursor):
1309         * Modules/indexeddb/client/IDBConnectionToServer.h:
1310         * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
1311         
1312         * Modules/indexeddb/server/IDBBackingStore.h:
1313         
1314         * Modules/indexeddb/server/IDBServer.cpp:
1315         (WebCore::IDBServer::IDBServer::iterateCursor):
1316         * Modules/indexeddb/server/IDBServer.h:
1317         
1318         * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
1319         (WebCore::IDBServer::MemoryIDBBackingStore::iterateCursor):
1320         * Modules/indexeddb/server/MemoryIDBBackingStore.h:
1321         
1322         * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
1323         (WebCore::IDBServer::SQLiteIDBBackingStore::iterateCursor):
1324         * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
1325         
1326         * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
1327         (WebCore::IDBServer::UniqueIDBDatabase::iterateCursor):
1328         (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor):
1329         * Modules/indexeddb/server/UniqueIDBDatabase.h:
1330         
1331         * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
1332         (WebCore::IDBServer::UniqueIDBDatabaseTransaction::iterateCursor):
1333         * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
1334         
1335         * Modules/indexeddb/shared/IDBIterateCursorData.cpp: Added.
1336         (WebCore::IDBIterateCursorData::isolatedCopy):
1337         * Modules/indexeddb/shared/IDBIterateCursorData.h: Added.
1338         (WebCore::IDBIterateCursorData::encode):
1339         (WebCore::IDBIterateCursorData::decode):
1340
1341         * Modules/indexeddb/shared/InProcessIDBServer.cpp:
1342         (WebCore::InProcessIDBServer::iterateCursor):
1343         * Modules/indexeddb/shared/InProcessIDBServer.h:
1344
1345         * CMakeLists.txt:
1346         * WebCore.xcodeproj/project.pbxproj:
1347
1348 2016-11-09  Ryosuke Niwa  <rniwa@webkit.org>
1349
1350         StyledElement::attributeChanged shouldn't do any work when the attribute value didn't change
1351         https://bugs.webkit.org/show_bug.cgi?id=129476
1352
1353         Reviewed by Andreas Kling.
1354
1355         Avoid calling styleAttributeChanged and setPresentationAttributeStyleIsDirty
1356         when the attribute value didn't change as in r164856.
1357
1358         * dom/StyledElement.cpp:
1359         (WebCore::StyledElement::attributeChanged):
1360
1361 2016-11-09  Yusuke Suzuki  <utatane.tea@gmail.com>
1362
1363         [DOMJIT] Implement Node::ownerDocument
1364         https://bugs.webkit.org/show_bug.cgi?id=164004
1365
1366         Reviewed by Darin Adler.
1367
1368         Test: js/dom/domjit-accessor-owner-document.html
1369
1370         Still I cannot reproduce this crash in x64 environment, according to the crash log, it accesses 0x8 address.
1371         This can happen if document() accidentally returns nullptr. In the C++ ownerDocument implementation,
1372         if document() returns nullptr, it just returns nullptr. But in the DOMJIT implementation, we assume that
1373         document() won't return nullptr and access the member of it.
1374
1375         This patch aligns the DOMJIT implementation strictly to the C++ one.
1376
1377         * dom/Node.idl:
1378         * domjit/JSNodeDOMJIT.cpp:
1379         (WebCore::NodeOwnerDocumentDOMJIT::checkDOM):
1380         (WebCore::NodeOwnerDocumentDOMJIT::callDOMGetter):
1381
1382 2016-11-09  Sam Weinig  <sam@webkit.org>
1383
1384         [SVG] Start moving special casing of SVG out of the bindings - SVGAngle
1385         https://bugs.webkit.org/show_bug.cgi?id=164496
1386
1387         Reviewed by Darin Adler.
1388
1389         There is quite a bit of special casing of SVG types in the bindings that adds
1390         a lot of complexity and is relatively fragile, as it is based on type naming.
1391
1392         Instead of keeping the complexity in the bindings, I am going to move it into
1393         the implementation, where it has also longed to be. 
1394
1395         Starting small, with just SVGAngle. It has been split in two, with the existing
1396         SVGAngle being renamed SVGAngleValue, and the bound instance, which used to be name
1397         SVGPropertyTearOff<SVGAngle>, taking the name SVGAngle (and inheriting from 
1398         SVGPropertyTearOff<SVGAngleValue>).
1399
1400         * CMakeLists.txt:
1401         * WebCore.xcodeproj/project.pbxproj:
1402         Add SVGAngleValue.cpp
1403
1404         * bindings/scripts/CodeGenerator.pm:
1405         Remove SVGAngle as a special case.
1406
1407         * svg/SVGAngle.cpp: Removed.
1408         * svg/SVGAngle.h:
1409         Added. Implements the SVGAngle interface explicitly, getting to
1410         the SVGAngleValue through propertyReference().
1411
1412         * svg/SVGAngle.idl:
1413         * svg/SVGAngleValue.cpp: Copied from Source/WebCore/svg/SVGAngle.cpp.
1414         * svg/SVGAngleValue.h: Copied from Source/WebCore/svg/SVGAngle.h.
1415         Move old SVGAngle implementation to SVGAngleValue.
1416
1417         * svg/SVGAnimatedAngle.cpp:
1418         Replace SVGAngle usage with SVGAngleValue.
1419
1420         * svg/SVGAnimatedAngle.h:
1421         Switch SVGAnimatedAngle to be a type alias. This remains SVGAnimatedPropertyTearOff<SVGAngle>
1422         as SVGAnimatedPropertyTearOff has been changed to take the TearOff type as its parameter.
1423
1424         * svg/SVGAnimatedLength.h:
1425         * svg/SVGAnimatedPreserveAspectRatio.h:
1426         * svg/SVGAnimatedRect.h:
1427         Switch to using type aliases and pass the TearOff to SVGAnimatedPropertyTearOff.
1428
1429         * svg/SVGAnimatedType.cpp:
1430         (WebCore::SVGAnimatedType::createAngleAndEnumeration):
1431         * svg/SVGAnimatedType.h:
1432         (WebCore::SVGAnimatedType::angleAndEnumeration):
1433         Use SVGAngleValue.
1434
1435         * svg/SVGComponentTransferFunctionElement.h:
1436         Add missing include of SVGElement.h (need because it removed from SVGPropertyTearOff).
1437
1438         * svg/SVGMarkerElement.cpp:
1439         (WebCore::SVGMarkerElement::parseAttribute):
1440         (WebCore::SVGMarkerElement::setOrient):
1441         Switch to take an SVGAngleValue.
1442
1443         (WebCore::SVGMarkerElement::setOrientToAngle):
1444         Update to pull the value out via propertyReference().
1445
1446         * svg/SVGMarkerElement.h:
1447         Switch to take an SVGAngleValue.
1448
1449         * svg/SVGLengthList.h:
1450         * svg/SVGNumberList.h:
1451         * svg/SVGPathSegList.h:
1452         * svg/SVGPointList.h:
1453         * svg/SVGStringList.h:
1454         * svg/SVGTransformList.h:
1455         Switch to using type aliases in SVGPropertyTraits and add an alias for
1456         ListItemTearOff.
1457
1458         * svg/SVGSVGElement.cpp:
1459         (WebCore::SVGSVGElement::createSVGAngle):
1460         * svg/SVGSVGElement.h:
1461         Change createSVGAngle to return a Ref<SVGAngle> and create one.
1462
1463         * svg/SVGSVGElement.idl:
1464         Annotate IDL to indicate that a new value is being returned.
1465
1466         * svg/SVGTransform.cpp:
1467         Remove unnecessary include of SVGAngle.h.
1468
1469         * svg/SVGViewSpec.cpp:
1470         Add missing include of SVGElement.h (need because it removed from SVGPropertyTearOff).
1471
1472         * svg/properties/SVGAnimatedPropertyTearOff.h:
1473         Change to be parameterized on the TearOffType, rather than the PropertyType itself. Get the
1474         Property type from the TearOffType.
1475
1476         * svg/properties/SVGListProperty.h:
1477         * svg/properties/SVGListPropertyTearOff.h:
1478         Fix assumption that all TearOffTypes are just a SVGPropertyTearOff templatized on a property
1479         type. This is no longer true for SVGAngle. Instead, get the TearOffType for lists via SVGPropertyTraits.
1480
1481         * svg/properties/SVGPropertyTearOff.h:
1482         Make the PropertyType available by exposing it as a type alias.
1483
1484 2016-11-09  Darin Adler  <darin@apple.com>
1485
1486         Move Range from ExceptionCode to ExceptionOr
1487         https://bugs.webkit.org/show_bug.cgi?id=164457
1488
1489         Reviewed by Alex Christensen.
1490
1491         * accessibility/AXObjectCache.cpp:
1492         (WebCore::AXObjectCache::rangeForNodeContents): Update to use ExceptionOr,
1493         keeping behavior the same.
1494         (WebCore::characterOffsetsInOrder): Ditto.
1495         (WebCore::setRangeStartOrEndWithCharacterOffset): Changed argument to a
1496         reference instead of a pointer. Use a boolean return value to indicate
1497         success rather than an exception, since the callers don't need to know
1498         which exception it is.
1499         (WebCore::AXObjectCache::rangeForUnorderedCharacterOffsets): Updated for
1500         the above.
1501         (WebCore::AXObjectCache::nextBoundary): Ditto.
1502         (WebCore::AXObjectCache::previousBoundary): Ditto.
1503
1504         * accessibility/AccessibilityObject.cpp:
1505         (WebCore::AccessibilityObject::rangeOfStringClosestToRangeInDirection):
1506         Update to use ExceptionOr, keeping behavior the same.
1507         * accessibility/AccessibilityRenderObject.cpp:
1508         (WebCore::AccessibilityRenderObject::documentBasedSelectedTextRange): Ditto.
1509         * accessibility/atk/WebKitAccessibleUtil.cpp:
1510         (selectionBelongsToObject): Ditto.
1511         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
1512         (-[WebAccessibilityObjectWrapper _convertToNSRange:]): Ditto.
1513         * dom/Node.cpp:
1514         (WebCore::Node::textRects): Ditto.
1515
1516         * dom/Range.cpp:
1517         (WebCore::Range::~Range): Remove old comment that no longer makes sense now
1518         that the detach function no longer does anything.
1519         (WebCore::checkForDifferentRootContainer): Updated to use ExceptionOr,
1520         keeping behavior the same.
1521         (WebCore::Range::setStart): Ditto.
1522         (WebCore::Range::setEnd): Ditto.
1523         (WebCore::Range::isPointInRange): Ditto.
1524         (WebCore::Range::comparePoint): Ditto.
1525         (WebCore::Range::compareNode): Ditto.
1526         (WebCore::top): Added helper function so that compareBoundaryPoints doesn't
1527         need to have two identical loops in it.
1528         (WebCore::Range::compareBoundaryPoints): Updated to use ExceptionOr,
1529         keeping behavior the same.
1530         (WebCore::Range::compareBoundaryPointsForBindings): Ditto. Also use a switch
1531         instead of relying on the order of the values to check for unsupported values.
1532         (WebCore::Range::boundaryPointsValid): Ditto.
1533         (WebCore::Range::deleteContents): Ditto.
1534         (WebCore::Range::intersectsNode): Ditto.
1535         (WebCore::Range::processContents): Ditto.
1536         (WebCore::deleteCharacterData): Ditto.
1537         (WebCore::processContentsBetweenOffsets): Ditto. Also changed to be a
1538         non-member function and private to this file instead of in the class.
1539         (WebCore::processNodes): Ditto. Also changed one argument to be a RefPtr
1540         since the code relies on using it after mutating the DOM.
1541         (WebCore::processAncestorsAndTheirSiblings): Ditto. Changed one argument type
1542         to use ExceptionOr so the caller doesn't have to check the exception first.
1543         (WebCore::Range::extractContents): Ditto.
1544         (WebCore::Range::cloneContents): Ditto.
1545         (WebCore::Range::insertNode): Ditto. Also fixed to only call nodeType once
1546         instead of three times.
1547         (WebCore::Range::toString): Ditto. Also fixed to call nodeType only once
1548         per node instead of twice, to use downcast instead of static_cast, and to
1549         use the word "node" instead of "n" for the local variable name.
1550         (WebCore::Range::createContextualFragment): Ditto.
1551         (WebCore::Range::checkNodeWOffset): Ditto.
1552         (WebCore::Range::setStartAfter): Ditto.
1553         (WebCore::Range::setEndBefore): Ditto.
1554         (WebCore::Range::setEndAfter): Ditto.
1555         (WebCore::Range::selectNode): Ditto.
1556         (WebCore::Range::selectNodeContents): Ditto.
1557         (WebCore::Range::surroundContents): Ditto.
1558         (WebCore::Range::setStartBefore): Ditto.
1559         (WebCore::Range::contains): Ditto. Except added code to handle exception
1560         case to return false without asserting because I saw at least one crash
1561         that seemed to imply this behavior was needed.
1562         (WebCore::rangesOverlap): Ditto.
1563         (WebCore::rangeOfContents): Ditto.
1564         (WebCore::Range::expand): Ditto.
1565         (WebCore::Range::getClientRects): Ditto.
1566         (WebCore::Range::getBoundingClientRect): Ditto.
1567         (WebCore::Range::borderAndTextQuads): Changed to use return value
1568         instead of out argument, since it's a private function used only
1569         within this class so it was easy to update all call sites.
1570         (WebCore::Range::boundingRect): Updated for above. Also renamed since
1571         there was no need for the name "internal" in this.
1572         (WebCore::Range::absoluteBoundingRect): Ditto.
1573         * dom/Range.h: Updated for above.
1574         * dom/Range.idl: Use non-legacy exceptions. Also changed the default value
1575         of the string argument to the expand function to the empty string rather
1576         than "undefined", because the function silently does nothing when passed
1577         any unrecognized string, and so this leaves behavior unchanged. I removed
1578         the comment saying that the "undefined" default is wrong.
1579
1580         * editing/AlternativeTextController.cpp:
1581         (WebCore::AlternativeTextController::applyAlternativeTextToRange): Updated
1582         to use ExceptionOr but behave the same.
1583         * editing/Editor.cpp:
1584         (WebCore::Editor::advanceToNextMisspelling): Ditto.
1585         (WebCore::Editor::markAndReplaceFor): Ditto.
1586         (WebCore::isFrameInRange): Ditto. Also made a few style tweaks.
1587         (WebCore::Editor::countMatchesForText): Ditto.
1588         * editing/EditorCommand.cpp:
1589         (WebCore::unionDOMRanges): Ditto.
1590         * editing/FrameSelection.cpp:
1591         (WebCore::FrameSelection::respondToNodeModification): Ditto.
1592         * editing/InsertListCommand.cpp:
1593         (WebCore::InsertListCommand::doApplyForSingleParagraph): Ditto.
1594         * editing/TextCheckingHelper.cpp:
1595         (WebCore::TextCheckingParagraph::offsetTo): Ditto.
1596         * editing/TextCheckingHelper.h: Updated for above and also deleted
1597         unneeded private function checkingRange, which just churned the
1598         reference count unnecessarily; instead use m_checkingRange directly.
1599         * editing/TextIterator.cpp:
1600         (WebCore::TextIterator::getLocationAndLengthFromRange): Ditto.
1601         * editing/VisiblePosition.cpp:
1602         (WebCore::setStart): Ditto.
1603         (WebCore::setEnd): Ditto.
1604         * editing/VisibleSelection.cpp:
1605         (WebCore::makeSearchRange): Ditto.
1606
1607         * editing/VisibleUnits.cpp:
1608         (WebCore::suffixLengthForRange): Changed argument from RefPtr to
1609         a reference.
1610         (WebCore::prefixLengthForRange): Ditto.
1611         (WebCore::previousBoundary): Updated for ExceptionOr and the change
1612         above.
1613         (WebCore::nextBoundary): Ditto.
1614         * editing/VisibleUnits.h: Updated for above.
1615
1616         * editing/htmlediting.cpp:
1617         (WebCore::comparePositions): Updated to use ExceptionOr but behave
1618         the same.
1619         (WebCore::visiblePositionForIndexUsingCharacterIterator): Ditto.
1620         (WebCore::isNodeVisiblyContainedWithin): Ditto.
1621         * editing/ios/EditorIOS.mm:
1622         (WebCore::Editor::setDictationPhrasesAsChildOfElement): Ditto.
1623         (WebCore::Editor::setTextAsChildOfElement): Ditto.
1624         * editing/mac/EditorMac.mm:
1625         (WebCore::Editor::adjustedSelectionRange): Ditto.
1626         * editing/markup.cpp:
1627         (WebCore::createMarkupInternal): Ditto.
1628         * page/ContextMenuController.cpp:
1629         (WebCore::ContextMenuController::contextMenuItemSelected): Ditto.
1630         * page/DOMSelection.cpp:
1631         (WebCore::DOMSelection::addRange): Ditto.
1632         (WebCore::DOMSelection::deleteFromDocument): Ditto.
1633         (WebCore::DOMSelection::containsNode): Ditto.
1634
1635         * page/EventHandler.cpp:
1636         (WebCore::EventHandler::dispatchMouseEvent): Updated for change to
1637         use ExceptionOr in Ragne::compareNode. Also refactored the function
1638         to make the logic a little mroe straightforward and nest less of it
1639         inside a loop.
1640
1641         * page/Page.cpp:
1642         (WebCore::Page::findStringMatchingRanges): Updated for ExceptionOr
1643         without changing behavior.
1644         * page/TextIndicator.cpp:
1645         (WebCore::hasNonInlineOrReplacedElements): Ditto.
1646         * rendering/RenderNamedFlowThread.cpp:
1647         (WebCore::RenderNamedFlowThread::getRanges): Ditto.
1648
1649 2016-11-09  Dave Hyatt  <hyatt@apple.com>
1650
1651         [CSS Parser] Fix grid layout parsing
1652         https://bugs.webkit.org/show_bug.cgi?id=164489
1653
1654         Reviewed by Dean Jackson.
1655
1656         * css/CSSValueKeywords.in:
1657         * css/parser/CSSPropertyParser.cpp:
1658         (WebCore::consumeFitContent):
1659         (WebCore::isGridTrackFixedSized):
1660         (WebCore::consumeGridTrackSize):
1661         (WebCore::consumeGridTrackRepeatFunction):
1662         (WebCore::consumeGridTrackList):
1663         (WebCore::isCustomIdentValue):
1664         (WebCore::CSSPropertyParser::consumeGridItemPositionShorthand):
1665         (WebCore::CSSPropertyParser::consumeGridAreaShorthand):
1666         (WebCore::consumeImplicitGridAutoFlow):
1667         (WebCore::CSSPropertyParser::consumeGridShorthand):
1668
1669 2016-11-09  Darin Adler  <darin@apple.com>
1670
1671         Move EventTarget from ExceptionCode to ExceptionOr
1672         https://bugs.webkit.org/show_bug.cgi?id=164465
1673
1674         Reviewed by Youenn Fablet.
1675
1676         * Modules/indexeddb/IDBRequest.h: Added now-needed forward
1677         class declarations.
1678         * Modules/webaudio/AudioContext.h: Ditto.
1679
1680         * bindings/js/JSEventListener.cpp:
1681         (WebCore::eventHandlerAttribute): Updated for name change of the
1682         attributeEventListener function.
1683         (WebCore::documentEventHandlerAttribute): Ditto.
1684         * dom/Document.cpp:
1685         (WebCore::Document::getWindowAttributeEventListener): Ditto.
1686
1687         * dom/EventTarget.cpp:
1688         (WebCore::EventTarget::setAttributeEventListener): Updated for
1689         name change.
1690         (WebCore::EventTarget::attributeEventListener): Ditto.
1691         (WebCore::EventTarget::dispatchEventForBindings): Use ExceptionOr.
1692         (WebCore::legacyType): Use null instead of empty for no type, since
1693         it's more efficient to check for null.
1694         (WebCore::EventTarget::fireEventListeners): Check for null.
1695         Also streamlined logic a little bit and removed a very old comment.
1696         (WebCore::EventTarget::eventListeners): Renamed from getEventListeners.
1697         * dom/EventTarget.h: Removed lots of unneeded declarations. Renamed
1698         some functions to remove get prefix. Updated for above changes.
1699         Moved one inline function out of the class header. Made the destructor
1700         for EventTarget be inline to make the destructors for derived classes
1701         slightly more efficient.
1702         * dom/EventTarget.idl: Use non-legacy exception.
1703
1704         * dom/Node.cpp:
1705         (WebCore::Node::didMoveToNewDocument): Updated for name change.
1706         * editing/ReplaceSelectionCommand.cpp:
1707         (WebCore::ReplacementFragment::ReplacementFragment): Ditto.
1708
1709         * inspector/InspectorCSSAgent.h: Added now-needed forward declaration.
1710
1711         * inspector/InspectorDOMAgent.cpp:
1712         (WebCore::InspectorDOMAgent::getEventListeners): Updated for name change.
1713
1714         * inspector/InspectorInstrumentation.h: Added now-needed forward declaration.
1715         * page/DOMWindow.h: Ditto.
1716         * xml/XMLHttpRequest.h: Ditto.
1717
1718 2016-11-09  Daniel Bates  <dabates@apple.com>
1719
1720         Add test infrastructure and tests for existing HTTP 0.9 sandbox machinery
1721         https://bugs.webkit.org/show_bug.cgi?id=164389
1722         <rdar://problem/29101072>
1723
1724         Reviewed by Alex Christensen.
1725
1726         Add test infrastructure to support registering an arbitrary port as the default port
1727         for a protocol. The behavior of various machinery, including the HTTP 0.9 machinery,
1728         can be effected by whether the resource request was made using the default port for
1729         the protocol. We expose window.internals.registerDefaultPortForProtocol() to allow
1730         a test to override the default port associated with a protocol so as to support
1731         testing these code paths using the existing port 8000 server started by run-webkit-httpd.
1732         Without window.internals.registerDefaultPortForProtocol() we would need to teach
1733         run-webkit-httpd to run a web server on port 80, which requires superuser privileges
1734         (since it is a privileged port number) and is more likely to interfere with an
1735         existing web server setup.
1736
1737         Tests: http/tests/security/http-0.9/default-port-plugin-blocked.html
1738                http/tests/security/http-0.9/default-port-script-blocked.html
1739                http/tests/security/http-0.9/iframe-blocked.html
1740                http/tests/security/http-0.9/image-blocked.html
1741                http/tests/security/http-0.9/image-on-HTTP-0.9-default-port-page-allowed-ref-test.html
1742                http/tests/security/http-0.9/image-on-HTTP-0.9-default-port-page-allowed.html
1743                http/tests/security/http-0.9/image-on-HTTP-0.9-page-blocked.html
1744                http/tests/security/http-0.9/worker-connect-src-blocked.html
1745                http/tests/security/http-0.9/worker-importScripts-blocked.html
1746                http/tests/security/http-0.9/xhr-asynchronous-blocked.html
1747
1748         * platform/URL.cpp:
1749         (WebCore::defaultPortForProtocolMapForTesting): Added.
1750         (WebCore::registerDefaultPortForProtocolForTesting): Adds the specified (protocol, port) to the
1751         mapping used for testing.
1752         (WebCore::clearDefaultPortForProtocolMapForTesting): Clears the protocol to default port testing map.
1753         We call this function from Internals::resetToConsistentState() so that the mapping is cleared between
1754         test runs.
1755         (WebCore::defaultPortForProtocol): Modified to check the protocol to default port map for testing
1756         before consulting URLParser::defaultPortForProtocol().
1757         * platform/URL.h:
1758         * testing/Internals.cpp:
1759         (WebCore::Internals::resetToConsistentState): Clear the default port mapping used for testing.
1760         (WebCore::Internals::registerDefaultPortForProtocol): Added.
1761         * testing/Internals.h:
1762         * testing/Internals.idl: Added declaration for registerDefaultPortForProtocol().
1763
1764 2016-11-09  Sam Weinig  <sam@webkit.org>
1765
1766         [WebIDL] Add proper parsing for Promises
1767         https://bugs.webkit.org/show_bug.cgi?id=164497
1768
1769         Reviewed by Tim Horton.
1770
1771         * bindings/scripts/IDLParser.pm:
1772         (parseNonAnyType):
1773         (parseStringType):
1774         Require Promise types to declare the type they resolve to.
1775         
1776         * bindings/js/JSDOMPromise.h:
1777         Allow DOMPromise to be be parameterized on void. Add an SFINAE guarded
1778         overload of resolve that takes no arguments when in a DOMPromise<void>.
1779
1780         * Modules/applepay/ApplePaySession.idl:
1781         * Modules/fetch/DOMWindowFetch.idl:
1782         * Modules/fetch/FetchBody.idl:
1783         * Modules/fetch/FetchResponse.idl:
1784         * Modules/fetch/WorkerGlobalScopeFetch.idl:
1785         * Modules/mediastream/MediaDevices.idl:
1786         * Modules/mediastream/MediaStreamTrack.idl:
1787         * Modules/mediastream/RTCPeerConnection.idl:
1788         * Modules/mediastream/RTCRtpSender.idl:
1789         * Modules/mediastream/RTCStatsReport.idl:
1790         * Modules/streams/ReadableStream.idl:
1791         * Modules/streams/ReadableStreamDefaultReader.idl:
1792         * Modules/streams/ReadableStreamSource.idl:
1793         * Modules/streams/WritableStream.idl:
1794         * Modules/webaudio/AudioContext.idl:
1795         * bindings/scripts/test/TestNode.idl:
1796         * bindings/scripts/test/TestObj.idl:
1797         * crypto/SubtleCrypto.idl:
1798         * crypto/WebKitSubtleCrypto.idl:
1799         * css/FontFace.idl:
1800         * css/FontFaceSet.idl:
1801         * dom/CustomElementRegistry.idl:
1802         * html/HTMLMediaElement.idl:
1803         Update IDLs to specify the resolve type of promise types.
1804
1805         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
1806         (WebCore::MediaEndpointPeerConnection::replaceTrack):
1807         (WebCore::MediaEndpointPeerConnection::replaceTrackTask):
1808         * Modules/mediastream/MediaStreamTrack.cpp:
1809         (WebCore::MediaStreamTrack::applyConstraints):
1810         * Modules/mediastream/MediaStreamTrack.h:
1811         * Modules/mediastream/PeerConnectionBackend.cpp:
1812         (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded):
1813         (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded):
1814         (WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
1815         * Modules/mediastream/PeerConnectionBackend.h:
1816         * Modules/streams/ReadableStreamSource.h:
1817         (WebCore::ReadableStreamSource::start):
1818         (WebCore::ReadableStreamSource::pull):
1819         (WebCore::ReadableStreamSource::startFinished):
1820         (WebCore::ReadableStreamSource::pullFinished):
1821         * Modules/webaudio/AudioContext.cpp:
1822         (WebCore::AudioContext::addReaction):
1823         (WebCore::AudioContext::setState):
1824         (WebCore::AudioContext::suspend):
1825         (WebCore::AudioContext::resume):
1826         (WebCore::AudioContext::close):
1827         * Modules/webaudio/AudioContext.h:
1828         * html/HTMLMediaElement.cpp:
1829         (WebCore::HTMLMediaElement::rejectPendingPlayPromises):
1830         (WebCore::HTMLMediaElement::resolvePendingPlayPromises):
1831         (WebCore::HTMLMediaElement::play):
1832         * html/HTMLMediaElement.h:
1833         Update implementations to use DOMPromise<void> rather than DOMPromise<nullptr_t>
1834         and use the new resolve() overload.
1835
1836 2016-11-07  Brady Eidson  <beidson@apple.com>
1837
1838         Followup to https://bugs.webkit.org/show_bug.cgi?id=164466 - Make an IDBTransaction* be an IDBTransaction&
1839
1840         Rubberstamped by Alex Christensen.
1841
1842         No new tests (No behavior change).
1843
1844         * Modules/indexeddb/IDBObjectStore.cpp:
1845         (WebCore::IDBObjectStore::IDBObjectStore):
1846         (WebCore::IDBObjectStore::~IDBObjectStore):
1847         (WebCore::IDBObjectStore::hasPendingActivity):
1848         (WebCore::IDBObjectStore::name):
1849         (WebCore::IDBObjectStore::setName):
1850         (WebCore::IDBObjectStore::keyPath):
1851         (WebCore::IDBObjectStore::indexNames):
1852         (WebCore::IDBObjectStore::transaction):
1853         (WebCore::IDBObjectStore::autoIncrement):
1854         (WebCore::IDBObjectStore::openCursor):
1855         (WebCore::IDBObjectStore::openKeyCursor):
1856         (WebCore::IDBObjectStore::get):
1857         (WebCore::IDBObjectStore::putOrAdd):
1858         (WebCore::IDBObjectStore::doDelete):
1859         (WebCore::IDBObjectStore::clear):
1860         (WebCore::IDBObjectStore::createIndex):
1861         (WebCore::IDBObjectStore::index):
1862         (WebCore::IDBObjectStore::deleteIndex):
1863         (WebCore::IDBObjectStore::doCount):
1864         (WebCore::IDBObjectStore::getAll):
1865         (WebCore::IDBObjectStore::getAllKeys):
1866         (WebCore::IDBObjectStore::markAsDeleted):
1867         (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
1868         (WebCore::IDBObjectStore::ref):
1869         (WebCore::IDBObjectStore::deref):
1870         * Modules/indexeddb/IDBObjectStore.h:
1871
1872 2016-11-09  Zalan Bujtas  <zalan@apple.com>
1873
1874         Move RenderNamedFlowThread nextRendererForElement logic to RenderTreeUpdater.
1875         https://bugs.webkit.org/show_bug.cgi?id=164503
1876
1877         Reviewed by Antti Koivisto.
1878
1879         When we insert a renderer into the render tree, we need to know both its parent
1880         and its next sibling. Normally the parent and the sibling are based on the DOM, but
1881         when this renderer is part of a flow thread, its insertion sibling is not necessarily the DOM sibling.
1882         To find the correct sibling, we call RenderNamedFlowThread's nextRendererForElement().
1883         RenderNamedFlowThread keeps track of its children so that it can compute the next sibling
1884         for the insertion point.
1885
1886         This patch eliminates the need for keeping track of the child renderers of each
1887         flow by moving the 'next sibling' logic to RenderTreePosition.
1888
1889         No change in functionality.
1890
1891         * rendering/RenderElement.cpp:
1892         (WebCore::RenderElement::insertedIntoTree):
1893         (WebCore::RenderElement::willBeDestroyed):
1894         (WebCore::RenderElement::removeFromRenderFlowThread):
1895         (WebCore::RenderElement::renderNamedFlowThreadWrapper): Deleted.
1896         * rendering/RenderElement.h:
1897         * rendering/RenderNamedFlowThread.cpp:
1898         (WebCore::RenderNamedFlowThread::nextRendererForElement): Deleted.
1899         (WebCore::RenderNamedFlowThread::addFlowChild): Deleted.
1900         (WebCore::RenderNamedFlowThread::removeFlowChild): Deleted.
1901         * rendering/RenderNamedFlowThread.h:
1902         * style/RenderTreePosition.cpp:
1903         (WebCore::RenderTreePosition::previousSiblingRenderer):
1904         (WebCore::RenderTreePosition::flowThreadInsertionContext):
1905         * style/RenderTreePosition.h:
1906         (WebCore::RenderTreePosition::RenderTreePosition):
1907         (WebCore::RenderTreePosition::parent):
1908         * style/RenderTreeUpdater.cpp:
1909         (WebCore::registerElementForFlowThreadIfNeeded): We need to registed the element even when it does not create renderer (display: none).
1910         (WebCore::RenderTreeUpdater::createRenderer):
1911         (WebCore::moveToFlowThreadIfNeeded): Deleted.
1912
1913 2016-11-09  Per Arne Vollan  <pvollan@apple.com>
1914
1915         [Win][Direct2D] Incomplete image decoding.
1916         https://bugs.webkit.org/show_bug.cgi?id=164511
1917
1918         Reviewed by Darin Adler.
1919
1920         Create native decoder when all image data has been received.
1921
1922         * platform/graphics/win/ImageDecoderDirect2D.cpp:
1923         (WebCore::ImageDecoder::setData):
1924
1925 2016-11-09  Beth Dakin  <bdakin@apple.com>
1926
1927         Attempted build fix.
1928
1929         * platform/spi/cocoa/AVKitSPI.h:
1930
1931 2016-11-09  Brady Eidson  <beidson@apple.com>
1932
1933         IndexedDB 2.0: Clean up more transaction abort behavior, including tweaks to Index/ObjectStore lifetime.
1934         https://bugs.webkit.org/show_bug.cgi?id=164466
1935
1936         Reviewed by Alex Christensen.
1937
1938         No new tests (Covered by existing tests that now pass).
1939         
1940         Previously, IDBIndex ref/deref didn't track a traditional ref count but instead kept the owning object store alive.
1941         Now, IDBObjectStore ref/deref do the same thing for the owning transaction.
1942         
1943         Now when a version change transaction is rolled back, some object stores and indexes get pulled out of the "deleted"
1944         set and get promoted back up into the "referenced" set.
1945         
1946         Now deleted object stores/indexes are considered opaque roots, as live objects in the deleted state *can* get back
1947         to the owning objects.
1948
1949         * CMakeLists.txt:
1950         * WebCore.xcodeproj/project.pbxproj:
1951
1952         * Modules/indexeddb/IDBIndex.cpp:
1953         (WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):
1954
1955         * Modules/indexeddb/IDBObjectStore.cpp:
1956         (WebCore::IDBObjectStore::IDBObjectStore):
1957         (WebCore::IDBObjectStore::indexNames):
1958         (WebCore::IDBObjectStore::transaction):
1959         (WebCore::IDBObjectStore::openCursor):
1960         (WebCore::IDBObjectStore::openKeyCursor):
1961         (WebCore::IDBObjectStore::deleteIndex):
1962         (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
1963         (WebCore::IDBObjectStore::visitReferencedIndexes):
1964         (WebCore::IDBObjectStore::ref):
1965         (WebCore::IDBObjectStore::deref):
1966         (WebCore::IDBObjectStore::create): Deleted.
1967         * Modules/indexeddb/IDBObjectStore.h:
1968
1969         * Modules/indexeddb/IDBTransaction.cpp:
1970         (WebCore::IDBTransaction::objectStore):
1971         (WebCore::IDBTransaction::transitionedToFinishing):
1972         (WebCore::IDBTransaction::internalAbort):
1973         (WebCore::IDBTransaction::createObjectStore):
1974         (WebCore::IDBTransaction::deleteObjectStore):
1975         (WebCore::IDBTransaction::visitReferencedObjectStores):
1976         * Modules/indexeddb/IDBTransaction.h:
1977         * Modules/indexeddb/IDBTransaction.idl:
1978
1979         * bindings/js/JSIDBTransactionCustom.cpp: Added.
1980         (WebCore::JSIDBTransaction::visitAdditionalChildren):
1981
1982 2016-11-09  Simon Fraser  <simon.fraser@apple.com>
1983
1984         Allow customization of TextStream-based logging for geometry types
1985         https://bugs.webkit.org/show_bug.cgi?id=164460
1986
1987         Reviewed by Zalan Bujtas.
1988
1989         TextStream-based logging was constrained by the requirement to maintain compatibility
1990         with DRT-style output, which includes cumbersome rect logging ("at (5,0) size 40x40")
1991         and dumping LayoutRects as IntRects.
1992         
1993         Add some formatting flags so that other TextStream clients (e.g. logging) can have
1994         more readable output, and opt into automatic FormatNumberRespectingIntegers behavior.
1995         
1996         TextStreams whose output appears in test results are given flags to avoid behavior
1997         changes, but in the longer term test results should be updated.
1998
1999         * html/canvas/CanvasRenderingContext2D.cpp:
2000         (WebCore::CanvasRenderingContext2D::replayDisplayListAsText):
2001         * page/scrolling/ScrollingStateNode.cpp:
2002         (WebCore::ScrollingStateNode::scrollingStateTreeAsText):
2003         * platform/graphics/FloatPoint.cpp:
2004         (WebCore::operator<<):
2005         * platform/graphics/FloatRect.cpp:
2006         (WebCore::operator<<):
2007         * platform/graphics/GraphicsLayer.cpp:
2008         (WebCore::GraphicsLayer::layerTreeAsText):
2009         * platform/graphics/IntRect.cpp:
2010         (WebCore::operator<<):
2011         * platform/graphics/LayoutPoint.cpp:
2012         (WebCore::operator<<):
2013         * platform/graphics/LayoutRect.cpp:
2014         (WebCore::operator<<):
2015         * platform/graphics/ca/GraphicsLayerCA.cpp:
2016         (WebCore::GraphicsLayerCA::replayDisplayListAsText):
2017         * platform/graphics/displaylists/DisplayList.cpp:
2018         (WebCore::DisplayList::DisplayList::asText):
2019         * platform/text/TextStream.cpp:
2020         (WebCore::TextStream::operator<<):
2021         * platform/text/TextStream.h:
2022         (WebCore::TextStream::TextStream):
2023         (WebCore::TextStream::formattingFlags):
2024         (WebCore::TextStream::setFormattingFlags):
2025         (WebCore::TextStream::hasFormattingFlag):
2026         (WebCore::TextStream::increaseIndent):
2027         (WebCore::TextStream::decreaseIndent):
2028         * rendering/RenderTreeAsText.cpp:
2029         (WebCore::externalRepresentation):
2030         (WebCore::counterValueForElement):
2031
2032 2016-11-09  Zalan Bujtas  <zalan@apple.com>
2033
2034         RenderFlowThread::flowThreadRelativeWillBeRemoved should take RenderObject& instead of RenderObject*
2035         https://bugs.webkit.org/show_bug.cgi?id=164543
2036
2037         Reviewed by Simon Fraser.
2038
2039         No change in functionality.
2040
2041         * rendering/RenderBlockFlow.cpp:
2042         (WebCore::RenderBlockFlow::removeChild):
2043         * rendering/RenderFlowThread.h:
2044         * rendering/RenderMultiColumnFlowThread.cpp:
2045         (WebCore::RenderMultiColumnFlowThread::handleSpannerRemoval):
2046         (WebCore::RenderMultiColumnFlowThread::flowThreadRelativeWillBeRemoved):
2047         * rendering/RenderMultiColumnFlowThread.h:
2048
2049 2016-11-09  Jer Noble  <jer.noble@apple.com>
2050
2051         REGRESSION (r208149): Media scrubber is not displayed in media controls
2052         https://bugs.webkit.org/show_bug.cgi?id=164514
2053
2054         Reviewed by Darin Adler.
2055
2056         Fixes broken Media Controls API tests.
2057
2058         Added a new PlatformMediaSessionType; need to add that same type to the TYPE_TRAITS section of 
2059         MediaElementSession.h so that is<> and downcast<> work correctly.
2060
2061         * html/MediaElementSession.h:
2062         (isType):
2063
2064 2016-11-09  Wenson Hsieh  <wenson_hsieh@apple.com>
2065
2066         When editing IME, `compositionend` events should fire after input events
2067         https://bugs.webkit.org/show_bug.cgi?id=164324
2068         <rdar://problem/29050438>
2069
2070         Reviewed by Darin Adler.
2071
2072         Moves where we dispatch `compositionend` events to after applying editing commands that fire `beforeinput` or
2073         `input` events. Also augments existing layout tests to verify the change.
2074
2075         * editing/Editor.cpp:
2076         (WebCore::Editor::setComposition):
2077
2078 2016-11-09  Wenson Hsieh  <wenson_hsieh@apple.com>
2079
2080         Setting foreground color when text is selected should fire an input event with color data
2081         https://bugs.webkit.org/show_bug.cgi?id=164241
2082         <rdar://problem/29032759>
2083
2084         Reviewed by Darin Adler.
2085
2086         Refactors Editor::applyStyle and Editor::applyParagraphStyle to handle beforeinput and input event dispatch.
2087         Instead of going through the ApplyStyleCommand to dispatch input events, override shouldDispatchInputEvents to
2088         return false. This strategy also has the effect of unifying the way input events are dispatched in applyStyle,
2089         in both codepaths where we computeAndSetTypingStyle and where we create and then apply a style command.
2090
2091         Test: fast/events/input-events-selection-forecolor-data.html
2092
2093         * editing/ApplyStyleCommand.h:
2094         * editing/Editor.cpp:
2095         (WebCore::inputEventDataForEditingStyleAndAction):
2096         (WebCore::Editor::applyStyle):
2097         (WebCore::Editor::applyParagraphStyle):
2098         (WebCore::Editor::computeAndSetTypingStyle):
2099
2100 2016-11-08  Dean Jackson  <dino@apple.com>
2101
2102         Rendering support for ExtendedColors
2103         https://bugs.webkit.org/show_bug.cgi?id=164443
2104         <rdar://problems/29123243>
2105
2106         Reviewed by Simon Fraser and Darin Adler.
2107
2108         Add support for rendering the new color() syntax, which
2109         ends up as an ExtendedColor.
2110
2111         In order to make rendering code a little more readable, I
2112         changed Color::hasAlpha to Color::isOpaque (since an alpha
2113         of 100% is still an alpha), and added a Color::isVisible
2114         helper (the color isn't completely transparent). These new
2115         helpers support ExtendedColor forms.
2116
2117         Support for painting gradients and blending between colors
2118         is still to come. I also added some FIXME comments
2119         to show other places that don't handle ExtendedColors yet.
2120
2121         Tests: css3/color/backgrounds-and-borders.html
2122                css3/color/box-shadows.html
2123                css3/color/canvas.html
2124                css3/color/composited-solid-backgrounds.html
2125                css3/color/text.html
2126
2127         * css/CSSGradientValue.cpp: Add some notes that this is broken.
2128         (WebCore::interpolate):
2129         (WebCore::CSSGradientValue::knownToBeOpaque):
2130
2131         * editing/EditingStyle.cpp: Use new Color helpers.
2132         (WebCore::isTransparentColorValue):
2133
2134         * editing/mac/EditorMac.mm: Use new Color helpers.
2135         (WebCore::Editor::fontAttributesForSelectionStart):
2136
2137         * html/ColorInputType.cpp: No need to use the Color class at all here.
2138         (WebCore::isValidSimpleColorString): Renamed from isValidColorString.
2139         (WebCore::ColorInputType::sanitizeValue):
2140         (WebCore::ColorInputType::typeMismatchFor):
2141         (WebCore::isValidColorString): Deleted.
2142
2143         * html/canvas/CanvasRenderingContext2D.cpp: New helpers.
2144         (WebCore::CanvasRenderingContext2D::shouldDrawShadows):
2145         (WebCore::CanvasRenderingContext2D::didDraw):
2146
2147         * page/FrameView.cpp: Ditto.
2148         (WebCore::FrameView::recalculateScrollbarOverlayStyle):
2149         (WebCore::FrameView::hasOpaqueBackground):
2150         (WebCore::FrameView::setBaseBackgroundColor):
2151
2152         * platform/graphics/Color.cpp:
2153         (WebCore::differenceSquared): Support ExtendedColor, but also
2154         add a note to indicate that this method and its call sites
2155         should use floats.
2156         (WebCore::Color::serialized): New helper.
2157         (WebCore::Color::cssText): Ditto.
2158         (WebCore::Color::blend): Ditto.
2159         (WebCore::Color::blendWithWhite):
2160         (WebCore::Color::colorWithAlphaMultipliedBy): Implementation of new function.
2161         (WebCore::Color::colorWithAlpha): Ditto.
2162         (WebCore::Color::opaqueColor): New method to return an opaque version of the given color.
2163         (WebCore::blend):
2164         * platform/graphics/Color.h:
2165         (WebCore::Color::isOpaque): New helper that is !hasAlpha().
2166         (WebCore::Color::isVisible): New helper.
2167         (WebCore::Color::alphaAsFloat): Gets the alpha value as a float. This replaces
2168         a bunch of places that were calculating it manually each time. Meanwhile, we
2169         might consider always exposing the primaries as floats... or at least
2170         have that option.
2171         (WebCore::isBlackColor): New helper - it was used in a couple of places.
2172         (WebCore::isWhiteColor): Ditto.
2173         (WebCore::Color::hasAlpha): Deleted.
2174
2175         * platform/graphics/Gradient.cpp: Add FIXME.
2176         (WebCore::Gradient::addColorStop):
2177         * platform/graphics/Gradient.h:
2178
2179         * platform/graphics/GraphicsContext.cpp: Use new helpers.
2180         (WebCore::GraphicsContext::computeLineBoundsAndAntialiasingModeForText):
2181         * platform/graphics/GraphicsContext.h:
2182         (WebCore::GraphicsContext::hasVisibleShadow):
2183
2184         * platform/graphics/Image.cpp: Ditto.
2185         (WebCore::Image::fillWithSolidColor):
2186
2187         * platform/graphics/ShadowBlur.cpp: Ditto.
2188         (WebCore::ShadowBlur::updateShadowBlurValues):
2189
2190         * platform/graphics/ca/GraphicsLayerCA.cpp: Ditto.
2191         (WebCore::GraphicsLayerCA::setContentsToSolidColor):
2192
2193         * platform/graphics/cg/GradientCG.cpp:
2194         (WebCore::Gradient::platformGradient): Add a FIXME to note that we can
2195         add ExtendedColor support simply by using CGColors, rather than fetching
2196         the components ourselves.
2197
2198         * platform/graphics/cg/GraphicsContextCG.cpp: New helpers.
2199         (WebCore::calculateDrawingMode):
2200
2201         * platform/graphics/cocoa/FontCascadeCocoa.mm: New helpers.
2202         (WebCore::FontCascade::drawGlyphs):
2203
2204         * platform/graphics/mac/ColorMac.mm: Use the new helpers and Color::hash().
2205         (WebCore::nsColor):
2206
2207         * platform/graphics/texmap/TextureMapperGL.cpp: New helpers.
2208         (WebCore::TextureMapperGL::drawBorder):
2209
2210         * rendering/BorderEdge.cpp: Ditto.
2211         (WebCore::BorderEdge::obscuresBackgroundEdge):
2212         (WebCore::BorderEdge::obscuresBackground):
2213
2214         * rendering/RenderBox.cpp: Ditto.
2215         (WebCore::RenderBox::getBackgroundPaintedExtent):
2216         (WebCore::RenderBox::backgroundIsKnownToBeOpaqueInRect):
2217         (WebCore::RenderBox::backgroundHasOpaqueTopLayer):
2218
2219         * rendering/RenderBoxModelObject.cpp: Ditto.
2220         (WebCore::RenderBoxModelObject::paintFillLayerExtended):
2221         (WebCore::colorNeedsAntiAliasAtCorner):
2222         (WebCore::willBeOverdrawn):
2223         (WebCore::RenderBoxModelObject::paintTranslucentBorderSides):
2224         (WebCore::RenderBoxModelObject::paintBorder):
2225         (WebCore::RenderBoxModelObject::boxShadowShouldBeAppliedToBackground):
2226         (WebCore::RenderBoxModelObject::paintBoxShadow):
2227         * rendering/RenderElement.cpp:
2228         (WebCore::RenderElement::paintOutline):
2229         * rendering/RenderInline.cpp:
2230         (WebCore::RenderInline::paintOutline):
2231         * rendering/RenderLayerBacking.cpp:
2232         (WebCore::canCreateTiledImage):
2233         * rendering/RenderLayerCompositor.cpp:
2234         (WebCore::RenderLayerCompositor::viewHasTransparentBackground):
2235         * rendering/RenderMenuList.cpp:
2236         (RenderMenuList::getItemBackgroundColor):
2237         * rendering/RenderTheme.cpp:
2238         (WebCore::RenderTheme::disabledTextColor):
2239         * rendering/RenderView.cpp:
2240         (WebCore::RenderView::paintBoxDecorations):
2241         * rendering/TextDecorationPainter.cpp:
2242         (WebCore::TextDecorationPainter::paintTextDecoration):
2243         * rendering/TextPainter.cpp:
2244         (WebCore::TextPainter::paintTextWithShadows):
2245         * rendering/style/BorderValue.h:
2246         (WebCore::BorderValue::isTransparent):
2247         * rendering/style/RenderStyle.cpp:
2248         (WebCore::RenderStyle::visitedDependentColor):
2249         * rendering/style/RenderStyle.h:
2250         (WebCore::RenderStyle::hasBackground):
2251         * rendering/svg/RenderSVGResource.cpp:
2252         (WebCore::requestPaintingResource):
2253         * rendering/svg/SVGInlineTextBox.cpp:
2254         (WebCore::SVGInlineTextBox::paintSelectionBackground):
2255
2256         * svg/SVGAnimatedColor.cpp: Add a FIXME to note this is broken.
2257         (WebCore::SVGAnimatedColorAnimator::calculateAnimatedValue):
2258
2259 2016-11-09  Antoine Quint  <graouts@apple.com>
2260
2261         [Modern Media Controls] UI Library: StatusLabel
2262         https://bugs.webkit.org/show_bug.cgi?id=164544
2263         <rdar://problem/29179541>
2264
2265         Reviewed by Dean Jackson.
2266
2267         We add a new StatusLabel class to display a string of text in place of the TimeControl.
2268         A followup patch will add the logic to display "Error", "Loading" and "Live Broadcast"
2269         test under the right media state.
2270
2271         Tests: media/modern-media-controls/macos-inline-media-controls/macos-inline-media-controls-status-label.html
2272                media/modern-media-controls/status-label/status-label.html
2273
2274         * Modules/modern-media-controls/controls/macos-inline-media-controls.css:
2275         (.media-controls.mac.inline .time-label,):
2276         (.media-controls.mac.inline .time-label): Deleted.
2277         * Modules/modern-media-controls/controls/macos-inline-media-controls.js:
2278         (MacOSInlineMediaControls.prototype.layout):
2279         * Modules/modern-media-controls/controls/media-controls.js:
2280         (MediaControls.):
2281         * Modules/modern-media-controls/controls/status-label.css: Added.
2282         (.status-label):
2283         * Modules/modern-media-controls/controls/status-label.js: Added.
2284         (StatusLabel.prototype.get text):
2285         (StatusLabel.prototype.set text):
2286         (StatusLabel.prototype.commitProperty):
2287         * Modules/modern-media-controls/js-files:
2288         * WebCore.xcodeproj/project.pbxproj:
2289
2290 2016-11-09  Chris Dumez  <cdumez@apple.com>
2291
2292         [Mac] Stop using deprecated AppKit enumeration values
2293         https://bugs.webkit.org/show_bug.cgi?id=164494
2294
2295         Reviewed by Darin Adler.
2296
2297         Stop using deprecated AppKit enumeration values.
2298
2299         * editing/cocoa/HTMLConverter.mm:
2300         (HTMLConverter::computedAttributesForElement):
2301         (HTMLConverter::_processElement):
2302         (HTMLConverter::_addMarkersToList):
2303         * page/mac/EventHandlerMac.mm:
2304         (WebCore::EventHandler::keyEvent):
2305         (WebCore::lastEventIsMouseUp):
2306         (WebCore::EventHandler::passSubframeEventToSubframe):
2307         (WebCore::EventHandler::widgetDidHandleWheelEvent):
2308         (WebCore::EventHandler::sendFakeEventsAfterWidgetTracking):
2309         * page/mac/TextIndicatorWindow.mm:
2310         (WebCore::TextIndicatorWindow::setTextIndicator):
2311         * platform/graphics/mac/IconMac.mm:
2312         (WebCore::Icon::paint):
2313         * platform/mac/CursorMac.mm:
2314         (WebCore::createCustomCursor):
2315         * platform/mac/DragImageMac.mm:
2316         (WebCore::dissolveDragImageToFraction):
2317         (WebCore::createDragImageFromImage):
2318         * platform/mac/EventLoopMac.mm:
2319         (WebCore::EventLoop::cycle):
2320         * platform/mac/PasteboardMac.mm:
2321         (WebCore::Pasteboard::setDragImage):
2322         * platform/mac/PlatformEventFactoryMac.mm:
2323         (WebCore::globalPointForEvent):
2324         (WebCore::pointForEvent):
2325         (WebCore::mouseButtonForEvent):
2326         (WebCore::mouseEventTypeForEvent):
2327         (WebCore::clickCountForEvent):
2328         (WebCore::isKeypadEvent):
2329         (WebCore::windowsKeyCodeForKeyEvent):
2330         (WebCore::isKeyUpEvent):
2331         (WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):
2332         * platform/mac/ScrollbarThemeMac.mm:
2333         (WebCore::scrollbarControlSizeToNSControlSize):
2334         * platform/mac/ThemeMac.mm:
2335         (-[WebCoreThemeView window]):
2336         (WebCore::controlSizeForFont):
2337         (WebCore::controlSizeFromPixelSize):
2338         (WebCore::setUpButtonCell):
2339         (WebCore::stepperControlSizeForFont):
2340         (WebCore::paintStepper):
2341         (WebCore::ThemeMac::minimumControlSize):
2342         * platform/mac/WebVideoFullscreenHUDWindowController.mm:
2343         (-[WebVideoFullscreenHUDWindow initWithContentRect:styleMask:backing:defer:]):
2344         (-[WebVideoFullscreenHUDWindow performKeyEquivalent:]):
2345         (-[WebVideoFullscreenHUDWindowController init]):
2346         (-[WebVideoFullscreenHUDWindowController keyDown:]):
2347         (-[WebVideoFullscreenHUDWindowController windowDidLoad]):
2348         * platform/mac/WebWindowAnimation.mm:
2349         (WebWindowAnimationDurationFromDuration):
2350         * rendering/RenderThemeMac.mm:
2351         (WebCore::RenderThemeMac::updateCachedSystemFontDescription):
2352         (WebCore::RenderThemeMac::controlSizeForFont):
2353         (WebCore::RenderThemeMac::controlSizeForCell):
2354         (WebCore::RenderThemeMac::controlSizeForSystemFont):
2355         (WebCore::RenderThemeMac::paintProgressBar):
2356         (WebCore::RenderThemeMac::popupMenuSize):
2357         (WebCore::RenderThemeMac::sliderThumbHorizontal):
2358         (WebCore::RenderThemeMac::sliderThumbVertical):
2359
2360 2016-11-08  Antoine Quint  <graouts@apple.com>
2361
2362         [Modern Media Controls] UI Library: iOS inline controls
2363         https://bugs.webkit.org/show_bug.cgi?id=164513
2364         <rdar://problem/27989475>
2365
2366         Reviewed by Dean Jackson.
2367
2368         We introduce a new IOSInlineMediaControls class which can be used to instantiate media controls
2369         for inline playback on iOS.
2370
2371         Tests: media/modern-media-controls/ios-inline-media-controls/ios-inline-media-controls-buttons-styles.html
2372                media/modern-media-controls/ios-inline-media-controls/ios-inline-media-controls-constructor.html
2373                media/modern-media-controls/ios-inline-media-controls/ios-inline-media-controls-controls-bar-styles.html
2374                media/modern-media-controls/ios-inline-media-controls/ios-inline-media-controls-layout.html
2375                media/modern-media-controls/ios-inline-media-controls/ios-inline-media-controls-time-control-styles.html
2376                media/modern-media-controls/ios-inline-media-controls/ios-inline-media-dropping-controls.html
2377
2378         * Modules/modern-media-controls/controls/ios-inline-media-controls.css: Added.
2379         (.media-controls.ios.inline > .controls-bar):
2380         (.media-controls.ios.inline .time-control):
2381         (.media-controls.ios.inline button):
2382         (.media-controls.ios.inline button:active):
2383         (.media-controls.ios.inline > .controls-bar button):
2384         (.media-controls.ios.inline .buttons-container.right):
2385         (.media-controls.ios.inline button.play-pause):
2386         (.media-controls.ios.inline button.skip-back):
2387         (.media-controls.ios.inline .scrubber.slider):
2388         (.media-controls.ios.inline button.airplay):
2389         (.media-controls.ios.inline button.pip):
2390         (.media-controls.ios.inline button.fullscreen):
2391         (.media-controls.ios.inline .time-label):
2392         (.media-controls.ios.inline .scrubber.slider > .fill):
2393         (.media-controls.ios.inline .scrubber.slider > input::-webkit-slider-thumb):
2394         * Modules/modern-media-controls/controls/ios-inline-media-controls.js: Added.
2395         (IOSInlineMediaControls.prototype.layout):
2396         (IOSInlineMediaControls):
2397         * Modules/modern-media-controls/images/iOS/slider-thumb@2x.png: Added.
2398         * Modules/modern-media-controls/js-files:
2399         * WebCore.xcodeproj/project.pbxproj:
2400
2401 2016-11-09  Beth Dakin  <bdakin@apple.com>
2402
2403         Support TouchBar in WebKit
2404         https://bugs.webkit.org/show_bug.cgi?id=164437
2405         -and corresponding-
2406         rdar://problem/28876524
2407
2408         Reviewed by Darin Adler.
2409
2410         * WebCore.xcodeproj/project.pbxproj:
2411         * platform/spi/cocoa/AVKitSPI.h:
2412         * platform/spi/cocoa/NSTouchBarSPI.h: Added.
2413         * platform/spi/mac/NSSpellCheckerSPI.h:
2414
2415 2016-11-09  Chris Dumez  <cdumez@apple.com>
2416
2417         Use Blob URL instead of webkit-fake-url when pasting an image
2418         https://bugs.webkit.org/show_bug.cgi?id=49141
2419
2420         Reviewed by Darin Adler.
2421
2422         Use Blob URL instead of webkit-fake-url when pasting an image.
2423
2424         Tests: editing/pasteboard/paste-image-as-blob-url.html
2425                editing/pasteboard/paste-image-using-image-data.html
2426
2427         * editing/Editor.h:
2428         * editing/mac/EditorMac.mm:
2429         (WebCore::Editor::WebContentReader::readImage):
2430         (WebCore::Editor::createFragmentForImageAndURL):
2431
2432 2016-11-09  Michael Catanzaro  <mcatanzaro@igalia.com>
2433
2434         Fix error message when SQLite initialization fails
2435         https://bugs.webkit.org/show_bug.cgi?id=164462
2436
2437         Reviewed by Darin Adler.
2438
2439         * platform/sql/SQLiteDatabase.cpp:
2440         (WebCore::initializeSQLiteIfNecessary):
2441
2442 2016-11-08  Antoine Quint  <graouts@apple.com>
2443
2444         [Modern Media Controls] UI Library: macOS fullscreen controls
2445         https://bugs.webkit.org/show_bug.cgi?id=164414
2446         <rdar://problem/27989474>
2447
2448         Reviewed by Dean Jackson.
2449
2450         We introduce a new MacOSFullscreenMediaControls class which can be used to instantiate media controls
2451         for fullscreen playback on macOS. These controls can be dragged by the user.
2452
2453         Tests: media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-containers-styles.html
2454                media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-styles.html
2455                media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-constructor.html
2456                media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-controls-bar-styles.html
2457                media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-right-container-margin.html
2458                media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-time-control-styles.html
2459                media/modern-media-controls/macos-fullscreen-media-controls/macos-fullscreen-media-controls-volume-styles.html
2460
2461         * Modules/modern-media-controls/controls/button.js:
2462         (Button.prototype.set enabled):
2463
2464             Correctly notify the layoutDelegate when the enabled property changes, regardless of whether
2465             the flag is on.
2466
2467         * Modules/modern-media-controls/controls/icon-button.js:
2468         (IconButton.prototype._updateImage):
2469         (IconButton):
2470
2471             Correctly notify the layout delegate when the image metrics have changed so that it may perform
2472             a layout. This issues became apparent with the new tests on Yosemite and caused some flakyness.
2473
2474         * Modules/modern-media-controls/controls/icon-service.js:
2475         (const.iconService.new.IconService.prototype._fileNameAndPlatformForIconNameAndLayoutTraits):
2476         (const.iconService.new.IconService):
2477
2478             Fix a typo.
2479
2480         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.css: Added.
2481         (.media-controls.mac.fullscreen > .controls-bar):
2482         (.media-controls.mac.fullscreen .volume.slider):
2483         (.media-controls.mac.fullscreen .buttons-container):
2484         (.media-controls.mac.fullscreen .buttons-container.center):
2485         (.media-controls.mac.fullscreen > .controls-bar button):
2486         (.media-controls.mac.fullscreen button.rewind):
2487         (.media-controls.mac.fullscreen button.play-pause):
2488         (.media-controls.mac.fullscreen button.forward):
2489         (.media-controls.mac.fullscreen .buttons-container.right):
2490         (.media-controls.mac.fullscreen button.airplay):
2491         (.media-controls.mac.fullscreen button.aspect-ratio):
2492         (.media-controls.mac.fullscreen button.pip):
2493         (.media-controls.mac.fullscreen button.tracks):
2494         (.media-controls.mac.fullscreen button.fullscreen):
2495         (.media-controls.mac.fullscreen .time-control):
2496         (.media-controls.mac.fullscreen .time-label):
2497         (.media-controls.mac.fullscreen .scrubber):
2498         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js: Added.
2499         (MacOSFullscreenMediaControls.prototype.layout):
2500         (MacOSFullscreenMediaControls):
2501         * Modules/modern-media-controls/controls/macos-media-controls.js:
2502         (MacOSMediaControls):
2503         
2504             Allow the layoutTraits property to be set to something other than just LayoutTraits.macOS
2505             so that MacOSFullscreenMediaControls may set the LayoutTraits.Fullscreen bit.
2506         
2507         * Modules/modern-media-controls/js-files:
2508         
2509             Add a reference to the new macos-fullscreen-media-controls.js file.
2510         
2511         * WebCore.xcodeproj/project.pbxproj:
2512
2513             Add references to the new macos-fullscreen-media-controls.js and
2514             macos-fullscreen-media-controls.css files.
2515
2516 2016-11-09  Chris Dumez  <cdumez@apple.com>
2517
2518         Shave 16 bytes off HTMLInputElement
2519         https://bugs.webkit.org/show_bug.cgi?id=164488
2520
2521         Reviewed by Sam Weinig.
2522
2523         Shave 16 bytes off HTMLInputElement (232 -> 216) by packing data members
2524         better.
2525
2526         * html/HTMLFormControlElement.h:
2527         * html/HTMLTextFormControlElement.cpp:
2528         (WebCore::HTMLTextFormControlElement::HTMLTextFormControlElement):
2529         * html/HTMLTextFormControlElement.h:
2530
2531 2016-11-09  Youenn Fablet  <youenn@apple.com>
2532
2533         [WebRTC] Introduce asynchronous backend for other RTCPeerConnection API
2534         https://bugs.webkit.org/show_bug.cgi?id=164409
2535
2536         Reviewed by Eric Carlson.
2537
2538         Covered by existing tests.
2539
2540         Following on createOffer changes, applying the same changes to createAnswer, setLocalDescription, setRemoteDescription and addIceCandidate.
2541         Also refactored ICE candidate event generation (done at PeerConnectionBackend).
2542         Updated stop implementation to clean any promise that may be stored in PeerConnectionBackend.
2543
2544         The goal of this is to be more aligned with https://www.w3.org/TR/webrtc/.
2545         Implementation of the various functions such as //www.w3.org/TR/webrtc/#set-description would be done in PeerConnectionBackend.
2546         This will require additional code moved from MediaEndpointPeerConnection up to PeerConnectionBackend.
2547
2548         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
2549         (WebCore::MediaEndpointPeerConnection::createOfferTask):
2550         (WebCore::MediaEndpointPeerConnection::doCreateAnswer):
2551         (WebCore::MediaEndpointPeerConnection::createAnswerTask):
2552         (WebCore::MediaEndpointPeerConnection::doSetLocalDescription):
2553         (WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask):
2554         (WebCore::MediaEndpointPeerConnection::doSetRemoteDescription):
2555         (WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask):
2556         (WebCore::MediaEndpointPeerConnection::doAddIceCandidate):
2557         (WebCore::MediaEndpointPeerConnection::addIceCandidateTask):
2558         (WebCore::MediaEndpointPeerConnection::doStop):
2559         (WebCore::MediaEndpointPeerConnection::gotIceCandidate):
2560         (WebCore::MediaEndpointPeerConnection::doneGatheringCandidates):
2561         (WebCore::MediaEndpointPeerConnection::createAnswer): Deleted.
2562         (WebCore::MediaEndpointPeerConnection::setLocalDescription): Deleted.
2563         (WebCore::MediaEndpointPeerConnection::setRemoteDescription): Deleted.
2564         (WebCore::MediaEndpointPeerConnection::addIceCandidate): Deleted.
2565         (WebCore::MediaEndpointPeerConnection::stop): Deleted.
2566         (WebCore::MediaEndpointPeerConnection::localDescriptionTypeValidForState): Deleted.
2567         (WebCore::MediaEndpointPeerConnection::remoteDescriptionTypeValidForState): Deleted.
2568         * Modules/mediastream/MediaEndpointPeerConnection.h:
2569         * Modules/mediastream/PeerConnectionBackend.cpp:
2570         (WebCore::PeerConnectionBackend::createOffer):
2571         (WebCore::PeerConnectionBackend::createOfferFailed):
2572         (WebCore::PeerConnectionBackend::createAnswer):
2573         (WebCore::PeerConnectionBackend::createAnswerSucceeded):
2574         (WebCore::PeerConnectionBackend::createAnswerFailed):
2575         (WebCore::isLocalDescriptionTypeValidForState):
2576         (WebCore::PeerConnectionBackend::setLocalDescription):
2577         (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded):
2578         (WebCore::PeerConnectionBackend::setLocalDescriptionFailed):
2579         (WebCore::isRemoteDescriptionTypeValidForState):
2580         (WebCore::PeerConnectionBackend::setRemoteDescription):
2581         (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded):
2582         (WebCore::PeerConnectionBackend::setRemoteDescriptionFailed):
2583         (WebCore::PeerConnectionBackend::addIceCandidate):
2584         (WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
2585         (WebCore::PeerConnectionBackend::addIceCandidateFailed):
2586         (WebCore::PeerConnectionBackend::fireICECandidateEvent):
2587         (WebCore::PeerConnectionBackend::doneGatheringCandidates):
2588         (WebCore::PeerConnectionBackend::stop):
2589         * Modules/mediastream/PeerConnectionBackend.h:
2590
2591 2016-11-09  Eric Carlson  <eric.carlson@apple.com>
2592
2593         [MediaStream][Mac] Mark captured video frames as ready for display immediately
2594         https://bugs.webkit.org/show_bug.cgi?id=164482
2595         <rdar://problem/29139073>
2596
2597         Reviewed by Jer Noble.
2598
2599         * platform/cf/CoreMediaSoftLink.cpp: Add new constant.
2600         * platform/cf/CoreMediaSoftLink.h:
2601
2602         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
2603         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
2604         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::requestNotificationWhenReadyForMediaData):
2605           New, ask register for a callback when the sample buffer display layer is ready
2606           for more media data.
2607         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSampleBuffer): Don't change
2608           the sample timestamps, assume the caller has configured the sample correctly.
2609         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::prepareVideoSampleBufferFromTrack): Don't
2610           drop frames when the display layer isn't ready.
2611         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::destroyLayer): Call stopRequestingMediaData.
2612         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::sampleBufferUpdated):
2613         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSampleBufferFromTrack): Deleted.
2614
2615         * platform/mediastream/mac/AVVideoCaptureSource.mm:
2616         (WebCore::AVVideoCaptureSource::setupCaptureSession): Tell the video output to always discard
2617           late video frames, we don't need them.
2618         (WebCore::AVVideoCaptureSource::processNewFrame): Add a kCMSampleAttachmentKey_DisplayImmediately
2619           attachment.
2620
2621 2016-11-09  Joanmarie Diggs  <jdiggs@igalia.com>
2622
2623         AX: [ATK] Wrong selected element at a given index in a list box (redux)
2624         https://bugs.webkit.org/show_bug.cgi?id=164430
2625
2626         Reviewed by Darin Adler.
2627
2628         This essentially undoes the implementation change resulting from r164577.
2629         As stated in the ATK documentation, atk_selection_ref_selection() takes
2630         "a gint specifying the index in the selection set. (e.g. the ith selection
2631         as opposed to the ith child)." r164577 deliberately modified that, causing
2632         atk_selection_ref_selection() to treat the index as if it were the position
2633         with respect to all of the children. There is different API in ATK, namely
2634         atk_object_ref_accessible_child(), when the ith child from the set of all
2635         children is sought.
2636
2637         Tests: accessibility/aria-listbox-no-selection.html
2638                accessibility/native-listbox-no-selection.html
2639
2640         * accessibility/atk/WebKitAccessibleInterfaceSelection.cpp:
2641         (optionFromSelection):
2642
2643 2016-11-09  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
2644
2645         [EFL] Use libgcrypt instead of GnuTLS for CryptoDigest
2646         https://bugs.webkit.org/show_bug.cgi?id=164461
2647
2648         Reviewed by Michael Catanzaro.
2649
2650         As GTK port in r208297, EFL port starts to use libgcrypt instead of GnuTLS as well.
2651
2652         No new tests, no behavior change.
2653
2654         * PlatformEfl.cmake:
2655
2656 2016-11-09  Ryan Haddad  <ryanhaddad@apple.com>
2657
2658         Unreviewed, rolling out r208422.
2659
2660         Roll r208382 back in since it was not responsible for the API
2661         test failures seen on macOS.
2662
2663         Reverted changeset:
2664
2665         "Unreviewed, rolling out r208382."
2666         https://bugs.webkit.org/show_bug.cgi?id=164319
2667         http://trac.webkit.org/changeset/208422
2668
2669 2016-11-09  Csaba Osztrogonác  <ossy@webkit.org>
2670
2671         One more URTBF after r208361.
2672
2673         * PlatformMac.cmake:
2674
2675 2016-11-09  Csaba Osztrogonác  <ossy@webkit.org>
2676
2677         Typo fix after r162782
2678         https://bugs.webkit.org/show_bug.cgi?id=164473
2679
2680         Unreviewed trivial fix.
2681
2682         * platform/ThreadGlobalData.cpp:
2683
2684 2016-11-07  Ryan Haddad  <ryanhaddad@apple.com>
2685
2686         Unreviewed, rolling out r208382.
2687
2688         This change appears to have caused 3
2689         SerializedCryptoKeyWrapTest API tests to fail on macOS.
2690
2691         Reverted changeset:
2692
2693         "[Readable Streams API] Implement ByteStreamController
2694         error()"
2695         https://bugs.webkit.org/show_bug.cgi?id=164319
2696         http://trac.webkit.org/changeset/208382
2697
2698 2016-11-04  Filip Pizlo  <fpizlo@apple.com>
2699
2700         WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows
2701         https://bugs.webkit.org/show_bug.cgi?id=152045
2702
2703         Reviewed by Andy Estes.
2704
2705         No new layout tests because no new behavior. The new WTF time classes have some unit tests
2706         in TestWebKitAPI.
2707
2708         * fileapi/ThreadableBlobRegistry.cpp:
2709         (WebCore::ThreadableBlobRegistry::blobSize):
2710         * platform/MainThreadSharedTimer.h:
2711         * platform/SharedTimer.h:
2712         * platform/ThreadTimers.cpp:
2713         (WebCore::ThreadTimers::updateSharedTimer):
2714         * platform/cf/MainThreadSharedTimerCF.cpp:
2715         (WebCore::MainThreadSharedTimer::setFireInterval):
2716         * platform/efl/MainThreadSharedTimerEfl.cpp:
2717         (WebCore::MainThreadSharedTimer::setFireInterval):
2718         * platform/glib/MainThreadSharedTimerGLib.cpp:
2719         (WebCore::MainThreadSharedTimer::setFireInterval):
2720         * platform/win/MainThreadSharedTimerWin.cpp:
2721         (WebCore::MainThreadSharedTimer::setFireInterval):
2722         * workers/WorkerRunLoop.cpp:
2723         (WebCore::WorkerRunLoop::runInMode):
2724
2725 2016-11-04  Zalan Bujtas  <zalan@apple.com>
2726
2727         RenderFlowThread state reset cleanup.
2728         https://bugs.webkit.org/show_bug.cgi?id=164426
2729
2730         Reviewed by Simon Fraser.
2731
2732         RenderFlowThread state reset is spread across several functions. This patch groups them
2733         together in RenderObject::resetFlowThreadState().
2734
2735         No change in functionality.
2736
2737         * rendering/RenderBlock.cpp:
2738         (WebCore::RenderBlock::removeLeftoverAnonymousBlock):
2739         (WebCore::RenderBlock::dropAnonymousBoxChild): This is now part of resetFlowThreadState() since resetFlowThreadState
2740         gets called even when NotifyChildren is false.
2741         * rendering/RenderElement.cpp:
2742         (WebCore::RenderElement::insertChildInternal): Initialize the thread state before we notify the child.
2743         (WebCore::RenderElement::removeChildInternal): Reset the state even when NotifyChildren is false.
2744         (WebCore::RenderElement::willBeRemovedFromTree): This code is moved to removeFromRenderFlowThread().
2745         (WebCore::RenderElement::removeFromRenderFlowThread):
2746         * rendering/RenderObject.cpp:
2747         (WebCore::RenderObject::initializeFlowThreadState): This is in transition for webkit.org/b/164428 (RenderFlowThread state initialization cleanup.)
2748         (WebCore::RenderObject::resetFlowThreadState):
2749         (WebCore::RenderObject::setParent): This was seemingly a random place to put flow state initialization. 
2750         (WebCore::RenderObject::willBeRemovedFromTree): resetFlowThreadState() takes care of it now.
2751         * rendering/RenderObject.h:
2752
2753 2016-11-04  Yusuke Suzuki  <utatane.tea@gmail.com>
2754
2755         [DOMJIT] Add DOMJIT::Signature annotation to Document::getElementById
2756         https://bugs.webkit.org/show_bug.cgi?id=164356
2757
2758         Reviewed by Filip Pizlo.
2759
2760         This patch implements DOMJIT::Signature annotation for getElementById.
2761         Since getElementById is also implemented in DocumentFragment, we implement
2762         the branchIfDocumentFragment/branchIfNotDocumentFragment for that.
2763
2764         In dromaeo, we have a test like this.
2765
2766         test( "getElementById", function(){
2767             for ( var i = 0; i < num * 30; i++ ) {
2768                 ret = document.getElementById("testA" + num).nodeType;
2769                 ret = document.getElementById("testB" + num).nodeType;
2770                 ret = document.getElementById("testC" + num).nodeType;
2771                 ret = document.getElementById("testD" + num).nodeType;
2772                 ret = document.getElementById("testE" + num).nodeType;
2773                 ret = document.getElementById("testF" + num).nodeType;
2774             }
2775         });
2776
2777         In the above test, JSC already knows the following things.
2778
2779         1. Since nodeType is now handled as CallDOMGetter, we know that it is pure.
2780         2. getElementById look up becomes PureGetById since document is impure object. But it is kept as PureGetById. So it does not write DOMState.
2781         3. `"testA" + num` will be converted to constant string.
2782         4. CallDOM for getElementById said it just reads(DOMState:DOM). And it saids that it returns the same value as long as DOMState is not clobbered.
2783         5. CheckCell leading CallDOM ensures the inlined getElementById node. (CallDOM node).
2784
2785         The key thing is that no node clobbers DOMState during the loop. So CallDOM & CallDOMGetter can be hoisted.
2786         This improves dom-query significantly. Dromaeo dom-query getElementById becomes 40x faster (247796 v.s. 6197).
2787         Dromaeo dom-query getElementById (not in document) becomes 89x faster (630317.8 v.s. 7066.).
2788
2789         Tests: js/dom/domjit-function-get-element-by-id-changed.html
2790                js/dom/domjit-function-get-element-by-id-licm.html
2791                js/dom/domjit-function-get-element-by-id.html
2792
2793         * dom/NonElementParentNode.idl:
2794         * domjit/DOMJITCheckDOM.h:
2795         (WebCore::DOMJIT::TypeChecker<DocumentFragment>::branchIfFail):
2796         * domjit/DOMJITHelpers.h:
2797         (WebCore::DOMJIT::branchIfDocumentFragment):
2798         (WebCore::DOMJIT::branchIfNotDocumentFragment):
2799
2800 2016-11-04  Simon Fraser  <simon.fraser@apple.com>
2801
2802         Rename unscaledUnobscuredVisibleContentSize and unscaledVisibleContentSizeIncludingObscuredArea for attempted clarity
2803         https://bugs.webkit.org/show_bug.cgi?id=164438
2804
2805         Reviewed by Tim Horton.
2806
2807         unscaledUnobscuredVisibleContentSize() and unscaledVisibleContentSizeIncludingObscuredArea() were an endless source
2808         of confusion.
2809         
2810         Functions with "VisibleContent" in the name are usually expected to return document coordinates (affected by zooming),
2811         so unscaledUnobscuredVisibleContentSize caused cognitive dissonance because of "unscaled" vs "visibleContent", and
2812         "unobscured" vs "visible".
2813         
2814         So rename:
2815             unscaledUnobscuredVisibleContentSize -> sizeForUnobscuredContent
2816             unscaledVisibleContentSizeIncludingObscuredArea -> sizeForVisibleContent
2817         
2818         sizeForUnobscuredContent() can also be private to ScrollView.
2819
2820         * inspector/InspectorOverlay.cpp:
2821         (WebCore::InspectorOverlay::update):
2822         * platform/ScrollView.cpp:
2823         (WebCore::ScrollView::unobscuredContentRectInternal):
2824         (WebCore::ScrollView::sizeForVisibleContent):
2825         (WebCore::ScrollView::sizeForUnobscuredContent): Don't compute unscaledVisibleContentSizeIncludingObscuredArea
2826         before testing whether we have a platform widget.
2827         (WebCore::ScrollView::layoutSize):
2828         (WebCore::ScrollView::unscaledVisibleContentSizeIncludingObscuredArea): Deleted.
2829         (WebCore::ScrollView::unscaledUnobscuredVisibleContentSize): Deleted.
2830         * platform/ScrollView.h:
2831         * rendering/RenderBoxModelObject.cpp:
2832         (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
2833         * rendering/RenderLayerCompositor.cpp:
2834         (WebCore::RenderLayerCompositor::flushPendingLayerChanges):
2835         (WebCore::RenderLayerCompositor::frameViewDidChangeSize):
2836         (WebCore::RenderLayerCompositor::updateRootLayerPosition):
2837         (WebCore::RenderLayerCompositor::ensureRootLayer):
2838
2839 2016-11-04  Simon Fraser  <simon.fraser@apple.com>
2840
2841         Layout viewport wrong with RTL documents
2842         https://bugs.webkit.org/show_bug.cgi?id=164434
2843
2844         Reviewed by Tim Horton.
2845
2846         The layoutViewportRect was computed incorrectly in RTL documents, because 
2847         FrameView::unscaledMaximumScrollPosition() was wrong; it erroneously mapped
2848         what it thought was a scrollOffset to a scrollPosition.
2849
2850         Unscaled scroll positions are in the same coordinate space as unscaledDocumentRect,
2851         so we should not call scrollPositionFromOffset() in FrameView::unscaledMaximumScrollPosition().
2852
2853         Changed FrameView::unscaledMinimumScrollPosition() to also just grab the location of
2854         unscaledDocumentRect, for symmetry.
2855
2856         Finally fixed the tiled scrolling indicator's viewport rect for zoomed RTL documents
2857         by using the unscaled scroll origin.
2858
2859         Tests: fast/visual-viewport/rtl-nonzoomed-rects.html
2860                fast/visual-viewport/rtl-zoomed-rects.html
2861
2862         * page/FrameView.cpp:
2863         (WebCore::FrameView::setLayoutViewportOrigin):
2864         (WebCore::FrameView::unscaledScrollOrigin):
2865         (WebCore::FrameView::unscaledMinimumScrollPosition):
2866         (WebCore::FrameView::unscaledMaximumScrollPosition):
2867         * page/FrameView.h:
2868
2869 2016-11-04  Sam Weinig  <sam@webkit.org>
2870
2871         [WebIDL] Add support for modern callback syntax
2872         https://bugs.webkit.org/show_bug.cgi?id=164435
2873
2874         Reviewed by Chris Dumez.
2875
2876         Support new callback syntax:
2877             callback Function = void (DOMString arg1, long arg2);
2878
2879         This replaces "callback interface" types with a Callback=FunctionOnly
2880         extended attribute.
2881
2882         * Modules/geolocation/PositionCallback.idl:
2883         * Modules/geolocation/PositionErrorCallback.idl:
2884         * Modules/notifications/NotificationPermissionCallback.idl:
2885         * Modules/quota/StorageErrorCallback.idl:
2886         * Modules/quota/StorageQuotaCallback.idl:
2887         * Modules/quota/StorageUsageCallback.idl:
2888         * Modules/webaudio/AudioBufferCallback.idl:
2889         * Modules/webdatabase/DatabaseCallback.idl:
2890         * Modules/webdatabase/SQLStatementCallback.idl:
2891         * Modules/webdatabase/SQLStatementErrorCallback.idl:
2892         * Modules/webdatabase/SQLTransactionCallback.idl:
2893         * Modules/webdatabase/SQLTransactionErrorCallback.idl:
2894         * dom/RequestAnimationFrameCallback.idl:
2895         * dom/StringCallback.idl:
2896         * html/VoidCallback.idl:
2897         * page/IntersectionObserverCallback.idl:
2898         * css/MediaQueryListListener.idl:
2899         Update to new syntax.
2900
2901         * css/MediaQueryListListener.h:
2902         * css/MediaQueryMatcher.cpp:
2903         (WebCore::MediaQueryMatcher::styleResolverChanged):
2904         Switch to using the now required 'handleEvent' name. This is an implementation detail
2905         that we should change.
2906
2907         * bindings/scripts/CodeGenerator.pm:
2908         Update document processing to allow a callback only file. Update callback
2909         type checks to look for a regex that matches in the new format.
2910
2911         * bindings/scripts/CodeGeneratorJS.pm:
2912         (AddToImplIncludesForIDLType):
2913         (AddToIncludesForIDLType):
2914         (AddToImplIncludes):
2915         (AddToIncludes):
2916         Abstract includes functions to allow passing in an include hash.
2917
2918         (GenerateCallbackFunctionHeader):
2919         (GenerateCallbackFunctionImplementation):
2920         (GenerateCallbackInterfaceHeader):
2921         (GenerateCallbackInterfaceImplementation):
2922         (GenerateCallbackHeaderContent):
2923         (GenerateCallbackImplementationContent):
2924         Refactor callback generation code into GenerateCallbackHeaderContent and GenerateCallbackImplementationContent
2925         to allow using it for both the new callbacks as well as the old callback interfaces.
2926
2927         * bindings/scripts/IDLParser.pm:
2928         (Parse):
2929         (applyTypedefs):
2930         (applyTypedefsToOperation):
2931         (parseCallbackRest):
2932         Parse callbacks into the new IDLCallbackFunction type. Ensure that typedefs are applied as well.
2933
2934         * bindings/scripts/IDLAttributes.txt:
2935         Remove support for Callback=FunctionOnly.
2936
2937         * bindings/scripts/test/JS/JSTestCallback.cpp: Removed.
2938         * bindings/scripts/test/JS/JSTestCallback.h: Removed.
2939         * bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
2940         * bindings/scripts/test/JS/JSTestCallbackFunction.h:
2941         * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp: Added.
2942         * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h: Added.
2943         * bindings/scripts/test/JS/JSTestCallbackInterface.cpp: Copied from Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp.
2944         * bindings/scripts/test/JS/JSTestCallbackInterface.h: Copied from Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h.
2945         * bindings/scripts/test/JS/JSTestObj.cpp:
2946         * bindings/scripts/test/JS/JSTestTypedefs.cpp:
2947         * bindings/scripts/test/TestCallback.idl: Removed.
2948         * bindings/scripts/test/TestCallbackFunction.idl:
2949         * bindings/scripts/test/TestCallbackFunctionWithTypedefs.idl: Added.
2950         * bindings/scripts/test/TestCallbackInterface.idl: Copied from Source/WebCore/bindings/scripts/test/TestCallback.idl.
2951         * bindings/scripts/test/TestObj.idl:
2952         * bindings/scripts/test/TestTypedefs.idl:
2953         Update existing tests and add new ones to test callback functions specifically.
2954
2955 2016-11-04  Alex Christensen  <achristensen@webkit.org>
2956
2957         Move isDefaultPortForProtocol from URLParser.cpp back to URL.cpp
2958         https://bugs.webkit.org/show_bug.cgi?id=164439
2959
2960         Reviewed by Daniel Bates.
2961
2962         No change in behaviour.
2963
2964         * platform/URL.cpp:
2965         (WebCore::defaultPortForProtocol):
2966         (WebCore::isDefaultPortForProtocol):
2967         * platform/URLParser.cpp:
2968         (WebCore::URLParser::defaultPortForProtocol):
2969         (WebCore::URLParser::parsePort):
2970         (WebCore::defaultPortForProtocol): Deleted.
2971         (WebCore::isDefaultPortForProtocol): Deleted.
2972         * platform/URLParser.h:
2973
2974 2016-11-04  Wenson Hsieh  <wenson_hsieh@apple.com>
2975
2976         Safari does not emit composition end if blurred for dead key / Japanese IME
2977         https://bugs.webkit.org/show_bug.cgi?id=164369
2978         <rdar://problem/29050439>
2979
2980         Reviewed by Ryosuke Niwa.
2981
2982         On Mac, _before_ changing selection, try to finalize the composition by calling Editor::cancelComposition early.
2983         This is because the focused element may have changed after performing the selection change, so we would
2984         otherwise be dispatching the `compositionend` to the new focused element (or no compositionend at all) instead
2985         of the element with the composition.
2986
2987         Doing this allows us to match Chrome and Firefox behavior. After canceling the composition, we then need to also
2988         clear the system IME state. We do this on Mac WK1/WK2 through the cancelComposition() codepath, which ends up
2989         calling into -discardMarkedText, which resets the marked text state. Some minor refactoring was performed to
2990         accomplish this -- currently, discardedComposition sends a CompositionWasCanceled message over to the UI process
2991         that discards the marked text, and then updates the editor state. This patch splits this into two separate
2992         steps -- see the WebKit2 ChangeLog for more details.
2993
2994         Test: fast/events/ime-compositionend-on-selection-change.html
2995
2996         * editing/Editor.cpp:
2997         (WebCore::Editor::selectionWillChange):
2998         * editing/Editor.h:
2999         * editing/FrameSelection.cpp:
3000         (WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance):
3001         * editing/mac/EditorMac.mm:
3002         (WebCore::Editor::selectionWillChange):
3003         * loader/EmptyClients.h:
3004         * page/EditorClient.h:
3005
3006 2016-11-04  Brady Eidson  <beidson@apple.com>
3007
3008         IndexedDB 2.0: Clean up more transaction abort and exception throwing behavior from IDBObjectStore.
3009         https://bugs.webkit.org/show_bug.cgi?id=164424
3010
3011         Reviewed by Alex Christensen.
3012
3013         No new tests (Covered by existing tests).
3014
3015         This patch actually turns a handful of PASS to FAIL in the imported tests, but those are parts of the
3016         spec in flux/under discussion.
3017
3018         We'll update either source or the tests as things are resolved.
3019
3020         * Modules/indexeddb/IDBIndex.cpp:
3021         (WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):
3022
3023         * Modules/indexeddb/IDBObjectStore.cpp:
3024         (WebCore::IDBObjectStore::get):
3025         (WebCore::IDBObjectStore::putOrAdd):
3026         (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
3027
3028 2016-11-04  Ryosuke Niwa  <rniwa@webkit.org>
3029
3030         Load stylesheets in link elements inside a connected shadow tree
3031         https://bugs.webkit.org/show_bug.cgi?id=160683
3032         <rdar://problem/29040652>
3033
3034         Reviewed by Antti Koivisto.
3035
3036         Allow external stylesheets within a shadow tree by storing the appropriate style scope in HTMLLinkElement
3037         when it's connected to a document instead of always talking to document's style scope.
3038
3039         Tests: fast/shadow-dom/link-element-in-shadow-tree.html
3040                fast/shadow-dom/selected-stylesheet-in-shadow-tree.html
3041
3042        * html/HTMLLinkElement.cpp:
3043        (WebCore::HTMLLinkElement::HTMLLinkElement):
3044        (WebCore::HTMLLinkElement::~HTMLLinkElement):
3045        (WebCore::HTMLLinkElement::setDisabledState): Exit early when the element is not in a document as invoking
3046        didChangeActiveStyleSheetCandidates would require having a valid m_styleScope and process() already exits
3047        early when inDocument() is false.
3048        (WebCore::HTMLLinkElement::parseAttribute):
3049        (WebCore::HTMLLinkElement::process): Removed the early exit for when the element is in a shadow tree.
3050        (WebCore::HTMLLinkElement::insertedInto): Exit early unless this element has just become connected to
3051        a document instead of whenever its self-inclusive ancestor is inserted into a container.
3052        (WebCore::HTMLLinkElement::removedFrom): Ditto for removal. Also call removeStyleSheetCandidateNode after
3053        calling removePendingSheet since the latter depends on m_styleScope being not null.
3054        (WebCore::HTMLLinkElement::addPendingSheet):
3055        (WebCore::HTMLLinkElement::removePendingSheet):
3056        * html/HTMLLinkElement.h:
3057        * html/HTMLStyleElement.cpp:
3058        (WebCore::HTMLStyleElement::insertedInto): Only call inline style owner's insertedIntoDocument if this
3059        element has just become connected to a document.
3060        (WebCore::HTMLStyleElement::removedFrom): Ditto for the removal.
3061        * style/StyleScope.h:
3062        * svg/SVGStyleElement.cpp:
3063        (WebCore::SVGStyleElement::insertedInto): Ditto.
3064        (WebCore::SVGStyleElement::removedFrom): Ditto for the removal.
3065
3066 2016-11-04  Said Abou-Hallawa  <sabouhallawa@apple.com>
3067
3068         Add a setting and preferences to enable/disable async image decoding
3069         https://bugs.webkit.org/show_bug.cgi?id=164417
3070
3071         Reviewed by Simon Fraser.
3072
3073         Add an asyncImageDecodingEnabled setting. This setting controls whether an
3074         image "can" be asynchronously decoded on a separate thread or not. The
3075         function ImageSource::isAsyncDecodingRequired() will be used in conjunction
3076         with this setting to decide whether an image "should" be asynchronously
3077         decoded or not.
3078
3079         * page/Settings.in:
3080
3081 2016-11-04  Tim Horton  <timothy_horton@apple.com>
3082
3083         Apply post-landing review comments for r208347
3084
3085         * dom/Element.cpp:
3086         (WebCore::Element::findAnchorElementForLink):
3087         Use attributeWithoutSynchronization.
3088
3089         * page/PrintContext.cpp:
3090         (WebCore::PrintContext::spoolPage):
3091         (WebCore::PrintContext::spoolRect):
3092         (WebCore::PrintContext::collectLinkedDestinations):
3093         (WebCore::PrintContext::outputLinkedDestinations):
3094         * page/PrintContext.h:
3095         Pass Document by reference instead of Node by pointer,
3096         use ElementTraversal instead of NodeTraversal to avoid
3097         having to locally check the type, and null-check renderers.
3098
3099 2016-11-04  Myles C. Maxfield  <mmaxfield@apple.com>
3100
3101         Implement WebGL2RenderingContext::copyBufferSubData()
3102         https://bugs.webkit.org/show_bug.cgi?id=164008
3103
3104         Reviewed by Dean Jackson.
3105
3106         Similar to previous work regarding WebGL 2 buffers, this method implements
3107         the ability to copy from one buffer to another without the data leaving
3108         the GPU.
3109
3110         Test: fast/canvas/webgl/copyBufferSubData.html
3111
3112         * html/canvas/WebGL2RenderingContext.cpp:
3113         (WebCore::WebGL2RenderingContext::copyBufferSubData):
3114         * html/canvas/WebGLBuffer.cpp:
3115         (WebCore::WebGLBuffer::associateCopyBufferSubData):
3116         * html/canvas/WebGLBuffer.h:
3117         * platform/graphics/GraphicsContext3D.h:
3118         * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
3119         (WebCore::GraphicsContext3D::copyBufferSubData):
3120
3121 2016-11-04  Simon Fraser  <simon.fraser@apple.com>
3122
3123         Rename some ScrollingTree/Node-related functions to reduce the number of uses of "update"
3124         https://bugs.webkit.org/show_bug.cgi?id=164420
3125
3126         Reviewed by Tim Horton.
3127
3128         Rename:
3129             commitNewTreeState -> commitTreeState ("new" was redundant)
3130             updateBeforeChildren -> commitStateBeforeChildren
3131             updateAfterChildren -> commitStateAfterChildren
3132
3133         * page/scrolling/ScrollingTree.cpp:
3134         (WebCore::ScrollingTree::commitTreeState):
3135         (WebCore::ScrollingTree::updateTreeFromStateNode):
3136         (WebCore::ScrollingTree::commitNewTreeState): Deleted.
3137         * page/scrolling/ScrollingTree.h:
3138         * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
3139         (WebCore::ScrollingTreeFrameScrollingNode::commitStateBeforeChildren):
3140         (WebCore::ScrollingTreeFrameScrollingNode::updateBeforeChildren): Deleted.
3141         * page/scrolling/ScrollingTreeFrameScrollingNode.h:
3142         * page/scrolling/ScrollingTreeNode.h:
3143         (WebCore::ScrollingTreeNode::commitStateAfterChildren):
3144         (WebCore::ScrollingTreeNode::updateAfterChildren): Deleted.
3145         * page/scrolling/ScrollingTreeScrollingNode.cpp:
3146         (WebCore::ScrollingTreeScrollingNode::commitStateBeforeChildren):
3147         (WebCore::ScrollingTreeScrollingNode::commitStateAfterChildren):
3148         (WebCore::ScrollingTreeScrollingNode::updateBeforeChildren): Deleted.
3149         (WebCore::ScrollingTreeScrollingNode::updateAfterChildren): Deleted.
3150         * page/scrolling/ScrollingTreeScrollingNode.h:
3151         * page/scrolling/ThreadedScrollingTree.cpp:
3152         (WebCore::ThreadedScrollingTree::commitTreeState):
3153         (WebCore::ThreadedScrollingTree::commitNewTreeState): Deleted.
3154         * page/scrolling/ThreadedScrollingTree.h:
3155         * page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.h:
3156         * page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm:
3157         (WebCore::ScrollingTreeFrameScrollingNodeIOS::commitStateBeforeChildren):
3158         (WebCore::ScrollingTreeFrameScrollingNodeIOS::commitStateAfterChildren):
3159         (WebCore::ScrollingTreeFrameScrollingNodeIOS::updateBeforeChildren): Deleted.
3160         (WebCore::ScrollingTreeFrameScrollingNodeIOS::updateAfterChildren): Deleted.
3161         * page/scrolling/ios/ScrollingTreeIOS.cpp:
3162         (WebCore::ScrollingTreeIOS::commitNewTreeState): Deleted.
3163         * page/scrolling/ios/ScrollingTreeIOS.h:
3164         * page/scrolling/mac/ScrollingCoordinatorMac.mm:
3165         (WebCore::ScrollingCoordinatorMac::commitTreeState):
3166         * page/scrolling/mac/ScrollingTreeFixedNode.h:
3167         * page/scrolling/mac/ScrollingTreeFixedNode.mm:
3168         (WebCore::ScrollingTreeFixedNode::commitStateBeforeChildren):
3169         (WebCore::ScrollingTreeFixedNode::updateBeforeChildren): Deleted.
3170         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
3171         * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
3172         (WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateBeforeChildren):
3173         (WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateAfterChildren):
3174         (WebCore::ScrollingTreeFrameScrollingNodeMac::updateBeforeChildren): Deleted.
3175         (WebCore::ScrollingTreeFrameScrollingNodeMac::updateAfterChildren): Deleted.
3176         * page/scrolling/mac/ScrollingTreeStickyNode.h:
3177         * page/scrolling/mac/ScrollingTreeStickyNode.mm:
3178         (WebCore::ScrollingTreeStickyNode::commitStateBeforeChildren):
3179         (WebCore::ScrollingTreeStickyNode::updateBeforeChildren): Deleted.
3180
3181 2016-11-03  Anders Carlsson  <andersca@apple.com>
3182
3183         Add new 'other' Apple Pay button style
3184         https://bugs.webkit.org/show_bug.cgi?id=164384
3185         rdar://problem/28302528
3186
3187         Reviewed by Dean Jackson.
3188
3189         * DerivedSources.make:
3190         * WebCorePrefix.h:
3191         Add extension points.
3192
3193         * css/CSSPrimitiveValueMappings.h:
3194         (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
3195         Add ApplePayButtonType::Other.
3196
3197         (WebCore::CSSPrimitiveValue::operator ApplePayButtonType):
3198         Add CSSValueOther.
3199
3200         * css/CSSValueKeywords.in:
3201         Add other.
3202
3203         * css/parser/CSSParser.cpp:
3204         (WebCore::isValidKeywordPropertyAndValue):
3205         Add CSSValueOther.
3206
3207         * css/parser/CSSParserFastPaths.cpp:
3208         (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
3209         Add CSSValueOther.
3210
3211         * rendering/RenderThemeCocoa.mm:
3212         (WebCore::toPKPaymentButtonType):
3213         Handle ApplePayButtonType::Other.
3214
3215         * rendering/style/RenderStyleConstants.h:
3216         Add ApplePayButtonType::Other.
3217
3218 2016-11-04  Antti Koivisto  <antti@apple.com>
3219
3220         slotted() pseudo does not work with ID selector
3221         https://bugs.webkit.org/show_bug.cgi?id=160538
3222         <rdar://problem/28534529>
3223
3224         Reviewed by Andreas Kling.
3225
3226         When we saw an id selector while addin rules we immediately threw it into the m_idRules
3227         optimization bucket and bailed out. However selectors containing ::slotted must always end
3228         up in m_slottedPseudoElementRules list no matter what else is there.
3229
3230         Fix by treating id like other selectors and only choosing the bucket after analysing all
3231         the selector components.
3232
3233         Test: fast/shadow-dom/css-scoping-slot-with-id.html
3234
3235         * css/RuleSet.cpp:
3236         (WebCore::RuleSet::addRule): Also made this use switch instead of a series of ifs.
3237
3238 2016-11-04  Brady Eidson  <beidson@apple.com>
3239
3240         IndexedDB 2.0: Handle IDBObjectStore rename behavior properly when version change transaction aborts.
3241         https://bugs.webkit.org/show_bug.cgi?id=164416
3242
3243         Reviewed by Beth Dakin.
3244
3245         No new tests (Covered by existing tests).
3246
3247         * Modules/indexeddb/IDBObjectStore.cpp:
3248         (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
3249
3250 2016-11-04  Keith Rollin  <krollin@apple.com>
3251
3252         NetworkSession: Add NetworkDataTask implementation for blobs
3253         https://bugs.webkit.org/show_bug.cgi?id=163939
3254
3255         Reviewed by Alex Christensen.
3256
3257         * WebCore.xcodeproj/project.pbxproj: Mark HTTPParsers.h and AsyncFileStream.h as private.
3258         * fileapi/AsyncFileStream.h: Add WEBCORE_EXPORT to AsyncFileStream class.
3259         * platform/network/BlobData.h: Add WEBCORE_EXPORT to length().
3260         * platform/network/HTTPParsers.h: Add WEBCORE_EXPORT to parseRange().
3261         * platform/network/ResourceResponseBase.h: Add WEBCORE_EXPORT to setHTTPHeaderField().
3262
3263 2016-11-04  Brady Eidson  <beidson@apple.com>
3264
3265         IndexedDB 2.0: Use IDB-specific exceptions in places where the generic exceptions are currently used.
3266         https://bugs.webkit.org/show_bug.cgi?id=164406
3267
3268         Reviewed by Alex Christensen.
3269
3270         No new tests (Covered by existing tests).
3271
3272         * Modules/indexeddb/IDBIndex.cpp:
3273         (WebCore::IDBIndex::setName):
3274
3275         * Modules/indexeddb/IDBObjectStore.cpp:
3276         (WebCore::IDBObjectStore::setName):
3277
3278 2016-11-04  Joanmarie Diggs  <jdiggs@igalia.com>
3279
3280         AX: [ATK] Attempting to clear selection on ARIA listboxes results in crash
3281         https://bugs.webkit.org/show_bug.cgi?id=164331
3282
3283         Reviewed by Chris Fleizach.
3284
3285         The ATK code is using is<AccessibilityListBox>() to identify native listboxes.
3286         But is<AccessibilityListBox>() returns the value of isListBox() which returns
3287         true both for AccessibilityListBox instances as well as for AccessibilityObject
3288         instances which have an AccessibilityRole value of ListBoxRole. Because only
3289         native listboxes should be AccessibilityListBoxes, add isNativeListBox() so
3290         that we can distinguish native and ARIA listboxes.
3291
3292         Tests: accessibility/aria-listbox-clear-selection-crash.html
3293                accessibility/listbox-clear-selection.html
3294
3295         * accessibility/AccessibilityListBox.h:
3296         * accessibility/AccessibilityObject.h:
3297         (WebCore::AccessibilityObject::isNativeListBox):
3298         (WebCore::AccessibilityObject::isListBox):
3299
3300 2016-11-04  Brady Eidson  <beidson@apple.com>
3301
3302         IndexedDB 2.0: Throw the correct exceptions during IDBObjectStore/IDBIndex renaming.
3303         https://bugs.webkit.org/show_bug.cgi?id=164405
3304
3305         Reviewed by Alex Christensen.
3306
3307         No new tests (Covered by existing tests).
3308
3309         * Modules/indexeddb/IDBIndex.cpp:
3310         (WebCore::IDBIndex::setName):
3311
3312         * Modules/indexeddb/IDBObjectStore.cpp:
3313         (WebCore::IDBObjectStore::setName):
3314
3315 2016-11-04  Romain Bellessort  <romain.bellessort@crf.canon.fr>
3316
3317         [Readable Streams API] Implement ByteStreamController error()
3318         https://bugs.webkit.org/show_bug.cgi?id=164319
3319
3320         Reviewed by Youenn Fablet.
3321
3322         Implemented error() method of ReadableByteStreamController.
3323
3324         Updated test expectations for error() and added IDL-related tests.
3325
3326         * Modules/streams/ReadableByteStreamController.js:
3327         (error): Implemented.
3328         * Modules/streams/ReadableByteStreamInternals.js:
3329         (privateInitializeReadableByteStreamController):
3330         (isReadableByteStreamController): Added.
3331         (readableByteStreamControllerError): Added.
3332         (readableByteStreamControllerClearPendingPullIntos): Added.
3333         * Modules/streams/ReadableStream.js:
3334         (initializeReadableStream): More detailed error message.
3335         * Modules/streams/ReadableStreamDefaultController.js:
3336         (error): Removed unnecessary variable declaration.
3337         * bindings/js/WebCoreBuiltinNames.h: Added totalQueuedBytes.
3338
3339 2016-11-03  Brady Eidson  <beidson@apple.com>
3340
3341         IndexedDB 2.0: Handle IDBIndex rename behavior properly when version change transaction aborts.
3342         https://bugs.webkit.org/show_bug.cgi?id=164403
3343
3344         Reviewed by Alex Christensen.
3345
3346         No new tests (Covered by existing test).
3347
3348         * Modules/indexeddb/IDBIndex.cpp:
3349         (WebCore::IDBIndex::rollbackInfoForVersionChangeAbort): Only rollback the info if this index
3350           already existed before this version change transaction.
3351
3352 2016-11-03  Youenn Fablet  <youenn@apple.com>
3353
3354         [WebRTC] Introduce asynchronous backend createOffer API
3355         https://bugs.webkit.org/show_bug.cgi?id=164365
3356
3357         Reviewed by Sam Weinig.
3358
3359         Covered by existing tests.
3360
3361         Removing PeerEndpointBackendClient as it is only RTCPeerConnection.
3362         This allows removing virtual for some functions.
3363
3364         Moving MediaEndpointPeerClient::m_client to PeerEndpointBackendClient::m_peerConnection and making it a reference.
3365
3366         Implementing createOffer at PeerConnectionBackend by splitting it in four sub-functions:
3367         - main createOffer, implemented at PeerConnectionBackend.
3368         - doCreateOffer implemented by subclasses (MediaEndpointPeerConnection).
3369         - createOfferSucceeded/createOfferFailed implemented by PeerConnectionBackend.
3370
3371         * CMakeLists.txt:
3372         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
3373         (WebCore::createMediaEndpointPeerConnection):
3374         (WebCore::MediaEndpointPeerConnection::MediaEndpointPeerConnection):
3375         (WebCore::MediaEndpointPeerConnection::doCreateOffer):
3376         (WebCore::MediaEndpointPeerConnection::createOfferTask):
3377         (WebCore::MediaEndpointPeerConnection::createAnswerTask):
3378         (WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask):
3379         (WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask):
3380         (WebCore::MediaEndpointPeerConnection::addIceCandidateTask):
3381         (WebCore::MediaEndpointPeerConnection::createReceiver):
3382         (WebCore::MediaEndpointPeerConnection::replaceTrack):
3383         (WebCore::MediaEndpointPeerConnection::replaceTrackTask):
3384         (WebCore::MediaEndpointPeerConnection::markAsNeedingNegotiation):
3385         (WebCore::MediaEndpointPeerConnection::localDescriptionTypeValidForState):
3386         (WebCore::MediaEndpointPeerConnection::remoteDescriptionTypeValidForState):
3387         (WebCore::MediaEndpointPeerConnection::gotIceCandidate):
3388         (WebCore::MediaEndpointPeerConnection::doneGatheringCandidates):
3389         (WebCore::MediaEndpointPeerConnection::iceTransportStateChanged):
3390         (WebCore::MediaEndpointPeerConnection::createOffer): Deleted.
3391         * Modules/mediastream/MediaEndpointPeerConnection.h:
3392         * Modules/mediastream/PeerConnectionBackend.cpp:
3393         (WebCore::PeerConnectionBackend::createOffer):
3394         (WebCore::PeerConnectionBackend::createOfferSucceeded):
3395         (WebCore::PeerConnectionBackend::createOfferFailed):
3396         (WebCore::createPeerConnectionBackend): Deleted.
3397         * Modules/mediastream/PeerConnectionBackend.h:
3398         (WebCore::PeerConnectionBackend::PeerConnectionBackend):
3399         (WebCore::PeerConnectionBackendClient::~PeerConnectionBackendClient): Deleted.
3400         * Modules/mediastream/RTCPeerConnection.cpp:
3401         (WebCore::RTCPeerConnection::RTCPeerConnection):
3402         * Modules/mediastream/RTCPeerConnection.h:
3403         * WebCore.xcodeproj/project.pbxproj:
3404
3405 2016-11-03  Antti Koivisto  <antti@apple.com>
3406
3407         REGRESSION (r207717): DumpRenderTree crashed in com.apple.WebCore: WebCore::Style::Scope::flushPendingUpdate + 16
3408         https://bugs.webkit.org/show_bug.cgi?id=164397
3409         <rdar://problem/29100135>
3410
3411         Reviewed by Ryosuke Niwa.
3412
3413         The problem here was that we were leaving stale pointers to Document::m_inDocumentShadowRoots set when
3414         using fast-path document teardown.
3415
3416         (Patch and stories mostly by rniwa).
3417
3418         * dom/Document.cpp:
3419         (WebCore::Document::~Document):
3420         (WebCore::Document::didInsertInDocumentShadowRoot):
3421         (WebCore::Document::didRemoveInDocumentShadowRoot):
3422
3423             Improve asserts.
3424
3425         * dom/Element.cpp:
3426         (WebCore::Element::removeShadowRoot):
3427
3428             Remove the superfluous call to notifyChildNodeRemoved in Element::removeShadowRoot to
3429             avoid invoking notifyChildNodeRemoved during a document teardown, which is incorrect. It's sufficient that
3430             ~ShadowRoot calls ContainerNode::removeDetachedChildren(), and in turn removeDetachedChildrenInContainer()
3431             since the latter function tears down nodes via the deletion queue during a document destruction and use
3432             notifyChildNodeRemoved() on nodes that outlive the shadow root.
3433
3434         * dom/ShadowRoot.cpp:
3435         (WebCore::ShadowRoot::~ShadowRoot):
3436
3437             Take care to clean up inDocumentShadowRoots for fast-pathed destruction too.
3438
3439         (WebCore::ShadowRoot::insertedInto):
3440         (WebCore::ShadowRoot::removedFrom):
3441
3442             Improve ShadowRoot's insertedInto and removedFrom so that they only try to add and remove itself from
3443             m_inDocumentShadowRoots when the connected-ness changes.
3444
3445 2016-11-03  Simon Fraser  <simon.fraser@apple.com>
3446
3447         Give all the geometry classes a single-argument scale() function for consistency
3448         https://bugs.webkit.org/show_bug.cgi?id=164400
3449
3450         Reviewed by Zalan Bujtas.
3451
3452         Add single-argument scale() to FloatPoint, FloatQuad, FloatSize and LayoutPoint, as well
3453         as adding one to GraphicsContext. Switch callers who passed the same value for sx and sy
3454         to the new functions.
3455
3456         * dom/Document.cpp:
3457         (WebCore::Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale):
3458         * dom/MouseRelatedEvent.cpp:
3459         (WebCore::MouseRelatedEvent::init):
3460         (WebCore::MouseRelatedEvent::computeRelativePosition):
3461         * dom/TreeScope.cpp:
3462         (WebCore::TreeScope::nodeFromPoint):
3463         * page/PrintContext.cpp:
3464         (WebCore::PrintContext::spoolPage):
3465         * platform/cocoa/ThemeCocoa.mm:
3466         (WebCore::fitContextToBox):
3467         * platform/graphics/FloatPoint.h:
3468         (WebCore::FloatPoint::scale):
3469         * platform/graphics/FloatQuad.h:
3470         (WebCore::FloatQuad::scale):
3471         * platform/graphics/FloatSize.h:
3472         (WebCore::FloatSize::scale):
3473         * platform/graphics/GraphicsContext.cpp:
3474         (WebCore::GraphicsContext::applyDeviceScaleFactor):
3475         * platform/graphics/GraphicsContext.h:
3476         (WebCore::GraphicsContext::scale):
3477         * platform/graphics/LayoutPoint.h:
3478         (WebCore::LayoutPoint::scale):
3479         * platform/graphics/ca/TileCoverageMap.cpp:
3480         (WebCore::TileCoverageMap::update):
3481         * platform/graphics/ca/TileGrid.cpp:
3482         (WebCore::TileGrid::platformCALayerPaintContents):
3483         * platform/graphics/cg/ImageBufferCG.cpp:
3484         (WebCore::ImageBuffer::drawConsuming):
3485         (WebCore::ImageBuffer::draw):
3486         (WebCore::ImageBuffer::drawPattern):
3487         * platform/mac/ThemeMac.mm:
3488         (WebCore::paintToggleButton):
3489         (WebCore::paintButton):
3490         (WebCore::paintStepper):
3491         * rendering/RenderImage.cpp:
3492         (WebCore::RenderImage::nodeAtPoint):
3493         * rendering/RenderMediaControls.cpp:
3494         (WebCore::getUnzoomedRectAndAdjustCurrentContext):
3495         * rendering/RenderThemeMac.mm:
3496         (WebCore::RenderThemeMac::paintMenuList):
3497         (WebCore::RenderThemeMac::paintSliderThumb):
3498         (WebCore::RenderThemeMac::paintSearchField):
3499         (WebCore::RenderThemeMac::paintSearchFieldCancelButton):
3500         (WebCore::RenderThemeMac::paintSearchFieldResultsButton):
3501         * rendering/svg/SVGInlineTextBox.cpp:
3502         (WebCore::SVGInlineTextBox::selectionRectForTextFragment):
3503         (WebCore::SVGInlineTextBox::paintDecorationWithStyle):
3504         (WebCore::SVGInlineTextBox::paintTextWithShadows):
3505         * svg/SVGPathBlender.cpp:
3506         (WebCore::SVGPathBlender::blendAnimatedFloatPoint):
3507         (WebCore::SVGPathBlender::blendArcToSegment):
3508         * svg/SVGPathParser.cpp:
3509         (WebCore::SVGPathParser::parseCurveToCubicSmoothSegment):
3510         (WebCore::SVGPathParser::parseCurveToQuadraticSegment):
3511         (WebCore::SVGPathParser::parseCurveToQuadraticSmoothSegment):
3512         (WebCore::SVGPathParser::decomposeArcToCubic):
3513         * svg/SVGSVGElement.cpp:
3514         (WebCore::SVGSVGElement::localCoordinateSpaceTransform):
3515
3516 2016-11-03  Antti Koivisto  <antti@apple.com>
3517
3518         REGRESSION (r207669): Crash under media controls shadow root construction
3519         https://bugs.webkit.org/show_bug.cgi?id=164381
3520         <rdar://problem/28935401>
3521
3522         Reviewed by Simon Fraser.
3523
3524         The problem is that we are running a script for media control UA shadow tree in HTMLMediaElement::insertedInto.
3525         It is not safe to run scripts in insertedInto as the tree is in inconsistent state. Instead finishedInsertingSubtree
3526         callback should be used.
3527
3528         Test: media/media-controls-shadow-construction-crash.html
3529
3530         Seen on https://www.theguardian.com/artanddesign/video/2013/oct/14/banksy-central-park-new-york-video
3531
3532         * html/HTMLMediaElement.cpp:
3533         (WebCore::HTMLMediaElement::insertedInto):
3534         (WebCore::HTMLMediaElement::finishedInsertingSubtree):
3535
3536             Move configureMediaControls() to finishedInsertingSubtree().
3537
3538         * html/HTMLMediaElement.h:
3539         * style/StyleTreeResolver.cpp:
3540         (WebCore::Style::TreeResolver::resolveComposedTree):
3541
3542             Add an assert to make the bad state easier to hit in tests.
3543
3544 2016-11-03  Ryosuke Niwa  <rniwa@webkit.org>
3545
3546         Add an assertion to diagnose stress GC bots test failures
3547         https://bugs.webkit.org/show_bug.cgi?id=164396
3548
3549         Reviewed by Antti Koivisto.
3550
3551         Added an assertion for calling ElementQueue::add while ElementQueue::invokeAll is in progress.
3552         This should never happen as long as all DOM API has an appropriate CEReactions IDL attribute.
3553
3554         * dom/CustomElementReactionQueue.cpp:
3555         (WebCore::CustomElementReactionStack::ElementQueue::add):
3556         (WebCore::CustomElementReactionStack::ElementQueue::invokeAll):
3557         * dom/CustomElementReactionQueue.h:
3558
3559 2016-11-03  Said Abou-Hallawa  <sabouhallawa@apple.com>
3560
3561         Add the asynchronous image decoding mode
3562         https://bugs.webkit.org/show_bug.cgi?id=155546
3563
3564         Reviewed by Simon Fraser.
3565
3566         The asynchronous image decoding feature targets enhancing the rendering
3567         in two scenarios: the animated images and scrolling a page which large
3568         images. Enabling this feature for these two scenarios will be landed
3569         separately. 
3570
3571         The goal of the asynchronous image decoding is to have the decoded image
3572         frame ready before it has to be drawn. Drawing an image does not have to
3573         wait the image frame to be decoded.
3574
3575         * platform/graphics/BitmapImage.cpp:
3576         (WebCore::BitmapImage::frameImageAtIndex): Use the negation of frameHasValidNativeImageAtIndex().
3577         * platform/graphics/BitmapImage.h:
3578         (WebCore::BitmapImage::frameIsBeingDecodedAtIndex): Answers whether a frame is being decoded.
3579         (WebCore::BitmapImage::frameHasValidNativeImageAtIndex): Checks the validity of a frame.
3580         (WebCore::BitmapImage::frameHasInvalidNativeImageAtIndex): Deleted.
3581         * platform/graphics/Image.h:
3582         (WebCore::Image::newFrameNativeImageAvailableAtIndex): Notifies the image with the availability of a frame NativeImage.
3583         * platform/graphics/ImageFrame.h:
3584         (WebCore::ImageFrame::isBeingDecoded): Answers whether the frame is being decoded.
3585         (WebCore::ImageFrame::hasValidNativeImage): Checks the validity of the frame.
3586         (WebCore::ImageFrame::hasInvalidNativeImage): Deleted.
3587         * platform/graphics/ImageFrameCache.cpp:
3588         (WebCore::ImageFrameCache::~ImageFrameCache): Asserts the decoding loop was ended before deleting the ImageFrameCache.
3589         (WebCore::ImageFrameCache::setFrameNativeImageAtIndex): Rename this function to matches the other which take the frame index.
3590         (WebCore::ImageFrameCache::setFrameMetadataAtIndex): Ditto.
3591         (WebCore::ImageFrameCache::replaceFrameNativeImageAtIndex): It setts the ImageFrame's members and updates the decoded size.
3592         (WebCore::ImageFrameCache::cacheFrameNativeImageAtIndex): Replaces the frame NativeImage and notifies the Image with the new frame.
3593         (WebCore::ImageFrameCache::decodingQueue): Ensures the decoding WorkQueue is created and returns it.
3594         (WebCore::ImageFrameCache::startAsyncDecodingQueue): Starts a decoding WorkQueue which loops until m_frameRequestQueue is closed.
3595         (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Allows ImageSource to send a request to start asynchronous frame image decoding.
3596         (WebCore::ImageFrameCache::stopAsyncDecodingQueue): Stops the decoding WorkQueue by closing m_frameRequestQueue.
3597         (WebCore::ImageFrameCache::frameAtIndex): Call replaceFrameNativeImageAtIndex().
3598         (WebCore::ImageFrameCache::frameIsBeingDecodedAtIndex): Returns true if a request for the image frame is issued but not finished yet.
3599         (WebCore::ImageFrameCache::frameHasValidNativeImageAtIndex): Checks the validity of a frame.
3600         (WebCore::ImageFrameCache::setFrameNativeImage): Deleted. Was renamed to be setFrameNativeImageAtIndex.
3601         (WebCore::ImageFrameCache::setFrameMetadata): Deleted. Was renamed to be setFrameMetadataAtIndex
3602         (WebCore::ImageFrameCache::frameHasInvalidNativeImageAtIndex): Deleted. Was renamed to be frameHasValidNativeImageAtIndex.
3603         * platform/graphics/ImageFrameCache.h:
3604         (WebCore::ImageFrameCache::create): The decoding queue needs to hold a reference to this class so it can stop decoding safely without blocking.
3605         (WebCore::ImageFrameCache::hasDecodingQueue): Returns true if a decoding queue has started.
3606         * platform/graphics/ImageSource.cpp:
3607         (WebCore::ImageSource::ImageSource): Call ImageFrameCache::create().
3608         (WebCore::ImageSource::clear): Deleting the decoder is unnecessary for asynchronous decoding because ImageFrameCache manages all the memory.
3609         
3610         (WebCore::ImageSource::destroyDecodedData):
3611         (WebCore::ImageSource::destroyDecodedDataIfNecessary):
3612         (WebCore::ImageSource::ensureDecoderAvailable):
3613         (WebCore::ImageSource::dataChanged):
3614         (WebCore::ImageSource::isAllDataReceived):
3615         (WebCore::ImageSource::isAsyncDecodingRequired): Answers the question whether the async image decoding is required for this ImageSource.
3616         (WebCore::ImageSource::frameImageAtIndex):
3617         * platform/graphics/ImageSource.h:
3618         (WebCore::ImageSource::decodedSize):
3619         (WebCore::ImageSource::requestFrameAsyncDecodingAtIndex):
3620         (WebCore::ImageSource::stopAsyncDecodingQueue):
3621         (WebCore::ImageSource::isSizeAvailable):
3622         (WebCore::ImageSource::frameCount):
3623         (WebCore::ImageSource::repetitionCount):
3624         (WebCore::ImageSource::filenameExtension):
3625         (WebCore::ImageSource::hotSpot):
3626         (WebCore::ImageSource::size):
3627         (WebCore::ImageSource::sizeRespectingOrientation):
3628         (WebCore::ImageSource::singlePixelSolidColor):
3629         (WebCore::ImageSource::frameIsBeingDecodedAtIndex):
3630         (WebCore::ImageSource::frameIsCompleteAtIndex):
3631         (WebCore::ImageSource::frameHasAlphaAtIndex):
3632         (WebCore::ImageSource::frameHasImageAtIndex):
3633         (WebCore::ImageSource::frameSubsamplingLevelAtIndex):
3634         (WebCore::ImageSource::frameSizeAtIndex):
3635         (WebCore::ImageSource::frameBytesAtIndex):
3636         (WebCore::ImageSource::frameDurationAtIndex):
3637         (WebCore::ImageSource::frameOrientationAtIndex):
3638          Make m_frameCache a type Ref<ImageFrameCache>. Use '->' instead of '.' when accessing its members.
3639
3640         (WebCore::ImageSource::frameHasValidNativeImageAtIndex): Checks the validity of a frame.
3641         (WebCore::ImageSource::frameHasInvalidNativeImageAtIndex): Deleted. Was renamed to be frameHasValidNativeImageAtIndex.
3642
3643 2016-11-03  Myles C. Maxfield  <mmaxfield@apple.com>
3644
3645         [WebGL2] Implement getBufferSubData()
3646         https://bugs.webkit.org/show_bug.cgi?id=164111
3647
3648         Reviewed by Dean Jackson.
3649
3650         The call exists in OpenGL 3.2 but in order to have parity with
3651         OpenGL ES 3 we back it with glMapBufferRange() instead.
3652
3653         This patch simply adds surface area to GraphicsContext3D
3654         until we can get an ANGLE implementation of it.
3655
3656         When testing this patch I discovered that r207649 incorrectly
3657         interpreted arguments to bufferData() and bufferSubData() as
3658         byte offsets. Instead, they should be element indices. This
3659         patch fixes those functions to work correctly so that
3660         getBufferSubData() can be tested correctly.
3661
3662         Tests: fast/canvas/webgl/webgl2-buffers.html
3663                fast/canvas/webgl/getBufferSubData-webgl1.html
3664
3665         * html/canvas/WebGL2RenderingContext.cpp:
3666         (WebCore::arrayBufferViewElementSize):
3667         (WebCore::WebGL2RenderingContext::bufferData):
3668         (WebCore::WebGL2RenderingContext::bufferSubData):
3669         (WebCore::WebGL2RenderingContext::getBufferSubData):
3670         * html/canvas/WebGL2RenderingContext.h:
3671         * html/canvas/WebGL2RenderingContext.idl:
3672         * platform/graphics/GraphicsContext3D.h:
3673         * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
3674         (WebCore::GraphicsContext3D::getBufferSubData):
3675         (WebCore::GraphicsContext3D::mapBufferRange):
3676         (WebCore::GraphicsContext3D::unmapBuffer):
3677
3678 2016-11-03  Chris Dumez  <cdumez@apple.com>
3679
3680         Unreviewed, mark support for the 'download' attribute as 'Done'.
3681
3682         * features.json:
3683
3684 2016-11-03  Chris Dumez  <cdumez@apple.com>
3685
3686         [WK2][Cocoa] Implement user interface for HTML form validation
3687         https://bugs.webkit.org/show_bug.cgi?id=164143
3688         <rdar://problem/28944652>
3689
3690         Reviewed by Simon Fraser.
3691
3692         Add ValidationBubble class to show HTML form validation messages
3693         using native dialogs. It currently has an implementation for both
3694         Mac and iOS. It is in WebCore under platform/ so that it can be
3695         used by both WebKit1 and WebKit2.
3696
3697         Update ownership of ValidationMessageClient so that is is owned
3698         by the Page using a unique_ptr<>, which seems to be the modern
3699         way of handling lifetime for page clients.
3700
3701         Test: fast/forms/validation-messages.html
3702
3703         * WebCore.xcodeproj/project.pbxproj:
3704         * html/HTMLFormControlElement.cpp:
3705         (WebCore::HTMLFormControlElement::focusAndShowValidationMessage):
3706         * html/ValidationMessage.cpp:
3707         (WebCore::ValidationMessage::updateValidationMessage):
3708         * page/Page.cpp:
3709         (WebCore::Page::Page):
3710         (WebCore::Page::~Page):
3711         * page/Page.h:
3712         (WebCore::Page::validationMessageClient):
3713         * page/PageConfiguration.cpp:
3714         * page/PageConfiguration.h:
3715         * platform/ValidationBubble.h: Copied from Tools/DumpRenderTree/mac/UIScriptControllerMac.mm.
3716         (WebCore::ValidationBubble::message):
3717         * platform/ios/ValidationBubbleIOS.mm: Added.
3718         (-[WebValidationBubbleDelegate adaptivePresentationStyleForPresentationController:traitCollection:]):
3719         (WebCore::ValidationBubble::ValidationBubble):
3720         (WebCore::ValidationBubble::~ValidationBubble):
3721         (WebCore::ValidationBubble::show):
3722         (WebCore::ValidationBubble::setAnchorRect):
3723         * platform/mac/ValidationBubbleMac.mm: Added.
3724         (WebCore::ValidationBubble::ValidationBubble):
3725         (WebCore::ValidationBubble::~ValidationBubble):
3726         (WebCore::ValidationBubble::showRelativeTo):
3727
3728 2016-11-03  Brady Eidson  <beidson@apple.com>
3729
3730         IndexedDB 2.0: Rename IDBKeyRange.contains to IDBKeyRange.includes.
3731         https://bugs.webkit.org/show_bug.cgi?id=164383
3732
3733         Reviewed by Beth Dakin.
3734
3735         No new tests (Updated existing tests).
3736
3737         * Modules/indexeddb/IDBKeyRange.cpp:
3738         (WebCore::IDBKeyRange::includes):
3739         (WebCore::IDBKeyRange::contains): Deleted.
3740         * Modules/indexeddb/IDBKeyRange.h:
3741         * Modules/indexeddb/IDBKeyRange.idl:
3742
3743 2016-11-03  Ryan Haddad  <ryanhaddad@apple.com>
3744
3745         Unreviewed, rolling out r208302.
3746
3747         This change causes LayoutTest crashes under GuardMalloc.
3748
3749         Reverted changeset:
3750
3751         "Load stylesheets in link elements inside a connected shadow
3752         tree"
3753         https://bugs.webkit.org/show_bug.cgi?id=160683
3754         http://trac.webkit.org/changeset/208302
3755
3756 2016-11-03  Chris Dumez  <cdumez@apple.com>
3757
3758         Unreviewed, add HTML5 specification for HTML Interactive Form Validation feature.
3759
3760         * features.json:
3761
3762 2016-11-03  Chris Dumez  <cdumez@apple.com>
3763
3764         Unreviewed, add HTML Interactive Form Validation to features.json
3765
3766         * features.json:
3767
3768 2016-11-03  Yusuke Suzuki  <utatane.tea@gmail.com>
3769
3770         Unreviewed, rolling out due to crash in Amazon web site
3771         https://bugs.webkit.org/show_bug.cgi?id=164380
3772         <rdar://problem/29094221>
3773
3774         * dom/Node.idl:
3775         * domjit/JSNodeDOMJIT.cpp:
3776         (WebCore::NodeOwnerDocumentDOMJIT::checkDOM): Deleted.
3777         (WebCore::NodeOwnerDocumentDOMJIT::callDOMGetter): Deleted.
3778
3779 2016-11-03  Brady Eidson  <beidson@apple.com>
3780
3781         IndexedDB 2.0: Support binary keys.
3782         <rdar://problem/28806927> and https://bugs.webkit.org/show_bug.cgi?id=164359
3783
3784         Reviewed by Alex Christensen.
3785
3786         Tests: storage/indexeddb/modern/binary-keys-1-private.html
3787                storage/indexeddb/modern/binary-keys-1.html
3788                Changes to other existing tests.
3789
3790         * Modules/indexeddb/IDBKey.cpp:
3791         (WebCore::IDBKey::createBinary):
3792         (WebCore::IDBKey::IDBKey):
3793         (WebCore::IDBKey::compare):
3794         * Modules/indexeddb/IDBKey.h:
3795         (WebCore::IDBKey::binary):
3796         (WebCore::compareBinaryKeyData):
3797
3798         * Modules/indexeddb/IDBKeyData.cpp:
3799         (WebCore::IDBKeyData::IDBKeyData):
3800         (WebCore::IDBKeyData::maybeCreateIDBKey):
3801         (WebCore::IDBKeyData::isolatedCopy):
3802         (WebCore::IDBKeyData::encode):
3803         (WebCore::IDBKeyData::decode):
3804         (WebCore::IDBKeyData::compare):
3805         (WebCore::IDBKeyData::loggingString):
3806         (WebCore::IDBKeyData::operator==):
3807         * Modules/indexeddb/IDBKeyData.h:
3808         (WebCore::IDBKeyData::hash):
3809         (WebCore::IDBKeyData::encode):
3810         (WebCore::IDBKeyData::decode):
3811
3812         * Modules/indexeddb/IndexedDB.h: Add new enum for the new key type.
3813
3814         * bindings/js/IDBBindingUtilities.cpp:
3815         (WebCore::toJS):
3816         (WebCore::createIDBKeyFromValue):
3817
3818         * platform/ThreadSafeDataBuffer.h:
3819         (WebCore::ThreadSafeDataBufferImpl::ThreadSafeDataBufferImpl):
3820         (WebCore::ThreadSafeDataBuffer::copyData):
3821         (WebCore::ThreadSafeDataBuffer::size):
3822         (WebCore::ThreadSafeDataBuffer::operator==):
3823         (WebCore::ThreadSafeDataBuffer::ThreadSafeDataBuffer):
3824
3825 2016-11-03  Tim Horton  <timothy_horton@apple.com>
3826
3827         Printing to PDF should produce internal links when HTML has internal links
3828         https://bugs.webkit.org/show_bug.cgi?id=112081
3829         <rdar://problem/5955705>
3830
3831         Reviewed by Simon Fraser.
3832         Patch originally by David Lattimore.
3833
3834         No new tests, as it's unclear how to test PDF output.
3835
3836         * dom/Element.cpp:
3837         (WebCore::Element::findAnchorElementForLink):
3838         * dom/Element.h:
3839         Add findAnchorElementForLink, which looks up the anchor element corresponding
3840         to the current element's href, and also returns the fragment name as an out parameter.
3841
3842         * page/PrintContext.cpp:
3843         (WebCore::PrintContext::PrintContext):
3844         (WebCore::PrintContext::spoolPage):
3845         (WebCore::PrintContext::spoolRect):
3846         (WebCore::PrintContext::end):
3847         (WebCore::PrintContext::collectLinkedDestinations):
3848         (WebCore::PrintContext::outputLinkedDestinations):
3849         * rendering/RenderObject.cpp:
3850         (WebCore::RenderObject::addPDFURLRect):
3851         Plumb internal links (fragment links) through to GraphicsContext, using
3852         the fragment name from the page.
3853
3854         * page/PrintContext.h:
3855         * platform/graphics/GraphicsContext.cpp:
3856         (WebCore::GraphicsContext::supportsInternalLinks):
3857         (WebCore::GraphicsContext::setDestinationForRect):
3858         (WebCore::GraphicsContext::addDestinationAtPoint):
3859         * platform/graphics/GraphicsContext.h:
3860         * platform/graphics/cg/GraphicsContextCG.cpp:
3861         (WebCore::GraphicsContext::supportsInternalLinks):
3862         (WebCore::GraphicsContext::setDestinationForRect):
3863         (WebCore::GraphicsContext::addDestinationAtPoint):
3864         Plumb internal links through to the CGContext. Apply the CTM, because
3865         these functions expect positions in global coordinates.
3866
3867         * platform/graphics/win/GraphicsContextDirect2D.cpp:
3868         (WebCore::GraphicsContext::setURLForRect):
3869         * platform/graphics/cairo/GraphicsContextCairo.cpp:
3870         (WebCore::GraphicsContext::setURLForRect):
3871         Adjust setURLForRect to take a FloatRect, like everything else, and
3872         stop rounding.
3873
3874 2016-11-03  Alex Christensen  <achristensen@webkit.org>
3875
3876         Unreviewed, rolling out r208298.
3877         https://bugs.webkit.org/show_bug.cgi?id=163939
3878
3879         caused asan crashes
3880
3881         Reverted changeset:
3882
3883         "NetworkSession: Add NetworkDataTask implementation for blobs"
3884         https://bugs.webkit.org/show_bug.cgi?id=163939
3885         http://trac.webkit.org/changeset/208298
3886
3887 2016-11-03  Brent Fulgham  <bfulgham@apple.com>
3888
3889         [Win][Direct2D] Native Windows widgets are drawn upside-down
3890         https://bugs.webkit.org/show_bug.cgi?id=164370
3891
3892         Reviewed by Alex Christensen.
3893
3894         When we return from drawing in GDI code, we need to flip the resulting
3895         bitmap so that it draws in the proper orientation in Direct2D.
3896
3897         Tested by existing widget tests.
3898
3899         * platform/graphics/win/GraphicsContextDirect2D.cpp:
3900         (WebCore::GraphicsContext::releaseWindowsContext): Flip before drawing
3901         to our Direct2D context.
3902
3903 2016-11-01  Gavin Barraclough  <barraclough@apple.com>
3904
3905         Remove PageThrottler & all related code
3906         https://bugs.webkit.org/show_bug.cgi?id=164302
3907
3908         Reviewed by Ryosuke Niwa.
3909
3910         All relevant information now available from the ActivityState.
3911
3912         * CMakeLists.txt:
3913         * WebCore.xcodeproj/project.pbxproj:
3914         * html/HTMLMediaElement.cpp:
3915         (WebCore::HTMLMediaElement::setMuted):
3916         (WebCore::HTMLMediaElement::updateVolume):
3917         (WebCore::HTMLMediaElement::updatePlayState):
3918         (WebCore::HTMLMediaElement::updateAudioAssertionState): Deleted.
3919         * html/HTMLMediaElement.h:
3920         * loader/FrameLoader.cpp:
3921         (WebCore::FrameLoader::completed):
3922         (WebCore::FrameLoader::started):
3923         * loader/FrameLoader.h:
3924         * page/ChromeClient.h:
3925         * page/Page.cpp:
3926         (WebCore::Page::Page):
3927         * page/Page.h:
3928         (WebCore::Page::pageActivityStateChanged): Deleted.
3929         (WebCore::Page::pageThrottler): Deleted.
3930         * page/PageThrottler.cpp: Removed.
3931         * page/PageThrottler.h: Removed.
3932
3933 2016-11-03  Dan Bernstein  <mitz@apple.com>
3934
3935         REGRESSION (r206247): Painting milestones can be delayed until the next layer flush
3936         https://bugs.webkit.org/show_bug.cgi?id=164340
3937         <rdar://problem/29074344>
3938
3939         Reviewed by&