[GCrypt] Implement CryptoKeyRSA::generatePair()
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-04-07  Zan Dobersek  <zdobersek@igalia.com>
2
3         [GCrypt] Implement CryptoKeyRSA::generatePair()
4         https://bugs.webkit.org/show_bug.cgi?id=170350
5
6         Reviewed by Michael Catanzaro.
7
8         Start implementing the libgcrypt-based platform bits of CryptoKeyRSA.
9
10         Implement generatePair() by constructing a genkey s-expression
11         that requests a generation of an RSA key that should use a modulus
12         of the specified bit-length and the specified exponent. The exponent
13         is extracted from an uint8_t array through a helper function. The
14         modulus length value is checked to be at least 16, since libgcrypt
15         does not support generating primes of less than that length in bits.
16
17         The returned s-expression upon request will contain the data for
18         both the public and the private key. gcry_sexp_t handles representing
19         those s-expressions are then passed to CryptoKeyRSA::create() before
20         invoking the success callback with a new CryptoKeyPair object in a
21         separate ScriptExecutionContext task.
22
23         The CryptoKeyRSA constructor simply has the notImplemented() call
24         removed. The destructor now invokes the HandleDeleter<gcry_sexp_t>
25         object instance to destroy the object represented by the
26         m_platformKey handle.
27
28         The methods in CryptoKeyRSA.cpp are also reordered to follow the
29         declaration order used in the header.
30
31         No new tests -- current ones cover this sufficiently, but are not yet
32         enabled due to other missing platform-specific SUBTLE_CRYPTO
33         implementations.
34
35         * crypto/gcrypt/CryptoKeyRSAGCrypt.cpp:
36         (WebCore::CryptoKeyRSA::CryptoKeyRSA):
37         (WebCore::CryptoKeyRSA::~CryptoKeyRSA):
38         (WebCore::exponentVectorToUInt32):
39         (WebCore::CryptoKeyRSA::generatePair):
40         (WebCore::CryptoKeyRSA::importSpki):
41         (WebCore::CryptoKeyRSA::importPkcs8):
42         (WebCore::CryptoKeyRSA::exportPkcs8):
43         (WebCore::CryptoKeyRSA::buildAlgorithm):
44         (WebCore::CryptoKeyRSA::exportData):
45         * crypto/keys/CryptoKeyRSA.h:
46
47 2017-04-06  Youenn Fablet  <youenn@apple.com>
48
49         [Debug] ASSERT(!throwScope.exception()) on imported/w3c/web-platform-tests/fetch/api/cors/cors-preflight-status-worker.html
50         https://bugs.webkit.org/show_bug.cgi?id=170395
51         <rdar://problem/31394017>
52
53         Reviewed by Mark Lam.
54
55         * bindings/js/JSDOMPromise.cpp:
56         (WebCore::DeferredPromise::reject): Exiting early in case of scope having an exception.
57         Adding an assertion to ensure this is a worker termination exception.
58
59 2017-04-06  Andreas Kling  <akling@apple.com>
60
61         Inaudible background tabs should become eligible for memory kill after 8 minutes
62         https://bugs.webkit.org/show_bug.cgi?id=170574
63         <rdar://problem/31488686>
64
65         Reviewed by Gavin Barraclough.
66
67         Lower the delay for potentially marking background tabs as inactive from 60 minutes to 8 minutes.
68         Letting a tab misbehave in the background for an entire hour was overly charitable.
69
70         * page/PerformanceMonitor.cpp:
71
72 2017-04-06  Wenson Hsieh  <wenson_hsieh@apple.com>
73
74         Scroll offset jumps after a programmatic scroll in an overflow container with scroll snapping
75         https://bugs.webkit.org/show_bug.cgi?id=170560
76         <rdar://problem/31484693>
77
78         Reviewed by Tim Horton.
79
80         Test: css3/scroll-snap/scroll-snap-programmatic-overflow-scroll.html
81
82         Logic for maintaining the scroll snap state in ScrollController was previously removed from iOS when refactoring
83         ScrollController. This was done because scroll snapping on iOS is driven not by the ScrollController (as it is
84         on Mac) but rather by sending scroll snap offsets to the UI process and hooking into UIScrollView delegates to
85         handle retargeted scrolling.
86
87         However, on iOS, this ScrollController state is still important for the purposes of keeping the last active
88         snap point index in sync with the UI process when the scroll offset changes outside of a user gesture (i.e.
89         programmatic scrolling). Since the UI process does not get a chance to update the active snap offset during a
90         programmatic scroll, our last active snap offset state was only being updated to the last snap position that the
91         user manually scrolled to, making programmatic scrolling jump to this offset.
92
93         To fix this, we need to update scroll snap state on iOS within ScrollController. Also adds a new Layout test
94         that exercises programmatic scrolling in an overflow scrolling container on all platforms.
95
96         * platform/cocoa/ScrollController.mm:
97         (WebCore::otherScrollEventAxis):
98         (WebCore::ScrollController::updateScrollSnapState):
99         (WebCore::ScrollController::updateScrollSnapPoints):
100
101 2017-04-05  Simon Fraser  <simon.fraser@apple.com>
102
103         Throttle requestAnimationFrame in cross-origin iframes to 30fps
104         https://bugs.webkit.org/show_bug.cgi?id=170534
105
106         Reviewed by Dan Bates.
107
108         Add a throttling reason to ScriptedAnimationController which is NonInteractedCrossOriginFrame,
109         set on cross-origin iframes whose documents have never seen a user interaction. It's cleared
110         as soon as an interaction on this frame or a child frame is detected.
111
112         Move the initialization of the LowPowerMode throttling reason to Document::requestAnimationFrame(),
113         since it's more appropriate to compute NonInteractedCrossOriginFrame here than down in ScriptedAnimationController,
114         and best to do both in the same place.
115
116         Tests: http/tests/frame-throttling/raf-throttle-in-cross-origin-subframe.html
117
118         * dom/Document.cpp:
119         (WebCore::Document::requestAnimationFrame):
120         (WebCore::Document::updateLastHandledUserGestureTimestamp):
121         * dom/Document.h:
122         (WebCore::Document::hasHadUserInteraction):
123         * dom/ScriptedAnimationController.cpp:
124         (WebCore::ScriptedAnimationController::ScriptedAnimationController):
125         (WebCore::throttlingReasonToString):
126         (WebCore::ScriptedAnimationController::interval):
127         * dom/ScriptedAnimationController.h:
128         * loader/FrameLoader.cpp:
129         (WebCore::shouldAskForNavigationConfirmation):
130
131 2017-04-05  Simon Fraser  <simon.fraser@apple.com>
132
133         Use the Accelerate framework to optimize FEColorMatrix operations
134         https://bugs.webkit.org/show_bug.cgi?id=170518
135
136         Reviewed by Tim Horton.
137
138         On macOS and iOS, we can use the Accelerate framework (vImage) to do color matrix
139         math to optimize color matrix, hue rotate, saturation and luminosity to alpha filters.
140         
141         Change ImageBuffer::getUnmultipliedImageData() and getPremultipliedImageData() to
142         return the size of the returned Uint8ClampedArray in physical pixels, because we
143         need to pass that to vImage.
144
145         * html/canvas/CanvasRenderingContext2D.cpp:
146         (WebCore::CanvasRenderingContext2D::getImageData):
147         * platform/graphics/ImageBuffer.h:
148         * platform/graphics/cairo/ImageBufferCairo.cpp:
149         (WebCore::ImageBuffer::getUnmultipliedImageData):
150         (WebCore::ImageBuffer::getPremultipliedImageData):
151         * platform/graphics/cg/ImageBufferCG.cpp:
152         (WebCore::ImageBuffer::getUnmultipliedImageData):
153         (WebCore::ImageBuffer::getPremultipliedImageData):
154         * platform/graphics/filters/FEColorMatrix.cpp:
155         (WebCore::effectApplyAccelerated):
156         (WebCore::effectType):
157         (WebCore::FEColorMatrix::platformApplySoftware):
158         * platform/graphics/filters/FEDropShadow.cpp:
159         (WebCore::FEDropShadow::platformApplySoftware):
160         * platform/graphics/win/ImageBufferDirect2D.cpp:
161         (WebCore::ImageBuffer::getUnmultipliedImageData):
162         (WebCore::ImageBuffer::getPremultipliedImageData):
163
164 2017-04-04  Simon Fraser  <simon.fraser@apple.com>
165
166         Do some minor FEColorMatrix code cleanup and optimization
167         https://bugs.webkit.org/show_bug.cgi?id=170474
168
169         Reviewed by Dean Jackson.
170
171         Don't switch inside of a pixel processing loop; repeat the loop inside switch (filterType).
172         
173         Change matrix() and saturateAndHueRotate() to dereference the source pixels once, instead
174         of multiple times, which is faster.
175         
176         This kind of code benefits from aligning things with spaces for readability, so do so,
177         violating webkit style.
178         
179         Add some off-by-default performance logging code.
180
181         Increases pixel processing performance from about 86ms per megapixel to 65ms per megapixel.
182
183         * platform/graphics/filters/FEColorMatrix.cpp:
184         (WebCore::matrix):
185         (WebCore::saturateAndHueRotate):
186         (WebCore::effectType):
187         (WebCore::FEColorMatrix::platformApplySoftware):
188
189 2017-04-06  Ryan Haddad  <ryanhaddad@apple.com>
190
191         Unreviewed, rolling out r215041.
192
193         The LayoutTest for this change is failing on ios-simulator.
194
195         Reverted changeset:
196
197         "Rendering flexbox children across columns"
198         https://bugs.webkit.org/show_bug.cgi?id=164166
199         http://trac.webkit.org/changeset/215041
200
201 2017-04-06  Ryan Haddad  <ryanhaddad@apple.com>
202
203         Unreviewed, rolling out r215046.
204
205         This change broke internal builds.
206
207         Reverted changeset:
208
209         "WebRTC tests gardening"
210         https://bugs.webkit.org/show_bug.cgi?id=170508
211         http://trac.webkit.org/changeset/215046
212
213 2017-04-06  Joseph Pecoraro  <pecoraro@apple.com>
214
215         Web Inspector: Only Capture Extra Network Load Metrics when there is a Web Inspector Frontend
216         https://bugs.webkit.org/show_bug.cgi?id=170525
217
218         Reviewed by Youenn Fablet.
219
220         Covered by existing tests that when Web Inspector is open we enable collecting the extra data.
221
222         * inspector/InspectorInstrumentation.cpp:
223         (WebCore::InspectorInstrumentation::firstFrontendCreated):
224         (WebCore::InspectorInstrumentation::lastFrontendDeleted):
225         * inspector/InspectorInstrumentation.h:
226         (WebCore::InspectorInstrumentation::frontendCreated):
227         (WebCore::InspectorInstrumentation::frontendDeleted):
228         When the first frontend is created enable a new loader strategy to
229         collect extra network load metrics. When the last frontend is closed
230         disable the extra metrics.
231
232         * loader/LoaderStrategy.h:
233         * platform/PlatformStrategies.h:
234         New load strategy to enable/disable new metrics.
235
236 2017-04-06  Joseph Pecoraro  <pecoraro@apple.com>
237
238         Web Inspector: Show all headers in the Request Headers section of the Resource details sidebar
239         https://bugs.webkit.org/show_bug.cgi?id=16531
240         <rdar://problem/5712895>
241
242         Reviewed by Timothy Hatcher.
243
244         Test: http/tests/inspector/network/resource-request-headers.html
245
246         * loader/ResourceTiming.cpp:
247         (WebCore::ResourceTiming::ResourceTiming):
248         Eliminate unnecessary data from the NetworkLoadTiming object
249         when it is used for ResourceTiming. This clears up some memory
250         that will otherwise never be used.
251
252         * platform/network/NetworkLoadMetrics.h:
253         (WebCore::NetworkLoadMetrics::isolatedCopy):
254         (WebCore::NetworkLoadMetrics::reset):
255         (WebCore::NetworkLoadMetrics::clearNonTimingData):
256         (WebCore::NetworkLoadMetrics::operator==):
257         (WebCore::NetworkLoadMetrics::encode):
258         (WebCore::NetworkLoadMetrics::decode):
259         Include an optional HTTPHeaderMap for a refined list of
260         request headers for this network load.
261
262         * inspector/InspectorNetworkAgent.cpp:
263         (WebCore::InspectorNetworkAgent::buildObjectForMetrics):
264         Include request headers with other optional metrics data
265         when the load is completed.
266
267 2017-04-06  Tim Horton  <timothy_horton@apple.com>
268
269         Follow up to r209304, remove line numbers from one more StyleRule construction
270         https://bugs.webkit.org/show_bug.cgi?id=170564
271
272         Reviewed by Simon Fraser.
273
274         * css/StyleRule.cpp:
275         (WebCore::StyleRuleViewport::StyleRuleViewport):
276         This one was missed in r209304.
277
278 2017-04-06  Timothy Horton  <timothy_horton@apple.com>
279
280         Remove an unused member and constructor parameter from CSSPropertyParser
281         https://bugs.webkit.org/show_bug.cgi?id=170562
282
283         Reviewed by Simon Fraser.
284
285         * css/parser/CSSParser.cpp:
286         (WebCore::CSSParser::parseSingleValue):
287         (WebCore::CSSParser::parseValueWithVariableReferences):
288         * css/parser/CSSParserImpl.cpp:
289         (WebCore::CSSParserImpl::consumeDeclarationValue):
290         * css/parser/CSSPropertyParser.cpp:
291         (WebCore::CSSPropertyParser::CSSPropertyParser):
292         (WebCore::CSSPropertyParser::parseValue):
293         (WebCore::CSSPropertyParser::parseSingleValue):
294         * css/parser/CSSPropertyParser.h:
295         It is possible to get Clang to complain about the unused member, though
296         I'm not sure why it doesn't in the build today.
297
298 2017-04-06  Zalan Bujtas  <zalan@apple.com>
299
300         Simple line layout: Hittest always returns the first renderer in the block.
301         https://bugs.webkit.org/show_bug.cgi?id=170520
302         <rdar://problem/30979175>
303
304         Reviewed by Antti Koivisto.
305
306         This is incorrect now with <br> support (multiple renderers within the same block flow).
307
308         Test: fast/dom/Document/CaretRangeFromPoint/simple-line-layout-hittest-with-caret-range-from-point.html
309
310         * rendering/RenderText.cpp:
311         (WebCore::RenderText::positionForPoint): Related fix. We don't yet support positionForPoint with multiple renderes. 
312         * rendering/SimpleLineLayoutFlowContents.h:
313         (WebCore::SimpleLineLayout::FlowContents::segmentForRun): Empty runs are all valid.
314         * rendering/SimpleLineLayoutFunctions.cpp:
315         (WebCore::SimpleLineLayout::hitTestFlow):
316         (WebCore::SimpleLineLayout::collectFlowOverflow):
317         * rendering/SimpleLineLayoutResolver.cpp:
318         (WebCore::SimpleLineLayout::LineResolver::Iterator::operator*): This should eventually return a list of renderes.
319         * rendering/SimpleLineLayoutResolver.h:
320         (WebCore::SimpleLineLayout::RunResolver::flowContents):
321
322 2017-04-06  Jon Davis  <jond@apple.com>
323
324         Updates feature status for recently shipped features
325         https://bugs.webkit.org/show_bug.cgi?id=170359
326
327         Reviewed by Brian Burg.
328
329         Added missing Gamepad entry.
330         Changed "Done" status to "Supported".
331         Also changed status from "In Development" to "Supported" for:
332         
333         - CSS Grid Layout Level 1
334         - CSS Inline Layout Module Level 3
335         - CSS Scroll Snap Points Module Level 1
336         - CSS Color Level 4
337         - Fetch API
338         - Indexed Database 2.0
339         - Media Capture and Streams
340         - Pointer Lock
341         - Preload
342         - Input Events
343
344         * features.json:
345
346 2017-03-31  Jiewen Tan  <jiewen_tan@apple.com>
347
348         [WebCrypto] Add support for AES-CTR
349         https://bugs.webkit.org/show_bug.cgi?id=169761
350         <rdar://problem/31331321>
351
352         Reviewed by Brent Fulgham.
353
354         This patch adds support for AES-CTR. Operations of AES-CTR include: encrypt, decrypt, generateKey,
355         importKey, exportKey, wrapKey, and unwrapKey. This implementation follows the latest WebCryptoAPI
356         spec: https://www.w3.org/TR/WebCryptoAPI/#aes-ctr.
357
358         Tests: crypto/subtle/aes-ctr-encrypt-malformed-parameters.html
359                crypto/subtle/aes-ctr-encrypt-overflow.html
360                crypto/subtle/aes-ctr-generate-export-key-jwk-length-128.html
361                crypto/subtle/aes-ctr-generate-export-key-jwk-length-192.html
362                crypto/subtle/aes-ctr-generate-export-key-jwk-length-256.html
363                crypto/subtle/aes-ctr-generate-export-raw-key.html
364                crypto/subtle/aes-ctr-generate-key-encrypt-decrypt.html
365                crypto/subtle/aes-ctr-generate-key.html
366                crypto/subtle/aes-ctr-import-jwk-key-length-128.html
367                crypto/subtle/aes-ctr-import-jwk-key-length-192.html
368                crypto/subtle/aes-ctr-import-jwk-key-length-256.html
369                crypto/subtle/aes-ctr-import-key-decrypt.html
370                crypto/subtle/aes-ctr-import-key-encrypt.html
371                crypto/subtle/aes-ctr-import-key-unwrap-jwk-key.html
372                crypto/subtle/aes-ctr-import-key-unwrap-raw-key.html
373                crypto/subtle/aes-ctr-import-key-wrap-jwk-key.html
374                crypto/subtle/aes-ctr-import-key-wrap-raw-key.html
375                crypto/subtle/aes-ctr-import-raw-key.html
376                crypto/workers/subtle/aes-ctr-import-key-decrypt.html
377                crypto/workers/subtle/aes-ctr-import-key-encrypt.html
378                crypto/workers/subtle/aes-ctr-import-key-unwrap-key.html
379                crypto/workers/subtle/aes-ctr-import-key-wrap-key.html
380
381         * CMakeLists.txt:
382         * DerivedSources.make:
383         * PlatformGTK.cmake:
384         * PlatformMac.cmake:
385         * WebCore.xcodeproj/project.pbxproj:
386         * bindings/js/JSSubtleCryptoCustom.cpp:
387         (WebCore::normalizeCryptoAlgorithmParameters):
388         * crypto/CryptoAlgorithmParameters.h:
389         * crypto/algorithms/CryptoAlgorithmAES_CTR.cpp: Added.
390         (WebCore::usagesAreInvalidForCryptoAlgorithmAES_CTR):
391         (WebCore::parametersAreValid):
392         (WebCore::CryptoAlgorithmAES_CTR::create):
393         (WebCore::CryptoAlgorithmAES_CTR::identifier):
394         (WebCore::CryptoAlgorithmAES_CTR::encrypt):
395         (WebCore::CryptoAlgorithmAES_CTR::decrypt):
396         (WebCore::CryptoAlgorithmAES_CTR::generateKey):
397         (WebCore::CryptoAlgorithmAES_CTR::importKey):
398         (WebCore::CryptoAlgorithmAES_CTR::exportKey):
399         (WebCore::CryptoAlgorithmAES_CTR::getKeyLength):
400         * crypto/algorithms/CryptoAlgorithmAES_CTR.h: Added.
401         * crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp: Added.
402         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
403         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
404         * crypto/mac/CryptoAlgorithmAES_CTRMac.cpp: Added.
405         (WebCore::bigIntegerToSize):
406         (WebCore::transformAES_CTR):
407         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
408         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
409         * crypto/mac/CryptoAlgorithmRegistryMac.cpp:
410         (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
411         * crypto/parameters/AesCtrParams.idl: Added.
412         * crypto/parameters/CryptoAlgorithmAesCtrParams.h: Added.
413
414 2017-04-06  Youenn Fablet  <youenn@apple.com>
415
416         WebRTC tests gardening
417         https://bugs.webkit.org/show_bug.cgi?id=170508
418
419         Reviewed by Eric Carlson.
420
421         * Configurations/FeatureDefines.xcconfig: Changing webrtc enabling for ios.
422
423 2017-04-06  Andreas Kling  <akling@apple.com>
424
425         Stop forcing CA commit when memory pressure changes.
426         https://bugs.webkit.org/show_bug.cgi?id=170522
427         <rdar://problem/31460236>
428
429         Reviewed by Antti Koivisto.
430
431         Don't force a CA commit when reaching critical memory pressure. We're already doing a ton
432         of work in response to the pressure, and this was really a hack to try to react quickly on
433         512 MB devices which we don't support anymore.
434
435         * page/MemoryRelease.cpp:
436         (WebCore::releaseCriticalMemory):
437
438 2017-04-06  Romain Bellessort  <romain.bellessort@crf.canon.fr>
439
440         [Readable Streams API] Implement ReadableStreamBYOBRequest respondWithNewView()
441         https://bugs.webkit.org/show_bug.cgi?id=170339
442
443         Reviewed by Youenn Fablet.
444
445         Implemented ReadableStreamBYOBRequest respondWithNewView().
446
447         Added new tests to check respondWithNewView() behaviour.
448
449         * Modules/streams/ReadableByteStreamInternals.js:
450         (readableByteStreamControllerRespondWithNewView): Added.
451         * Modules/streams/ReadableStreamBYOBRequest.js:
452         (respondWithNewView): Updated.
453
454 2017-04-06  Eric Carlson  <eric.carlson@apple.com>
455
456         [MediaStream] Host application should be able to mute and unmute media streams
457         https://bugs.webkit.org/show_bug.cgi?id=170519
458         <rdar://problem/31174326>
459
460         Unreviewed, fix crash introduced in r214980.
461
462         * Modules/mediastream/MediaStream.cpp:
463         (WebCore::MediaStream::MediaStream): NULL-check page.
464
465 2017-04-06  Dave Hyatt  <hyatt@apple.com>
466
467         Rendering flexbox children across columns
468         https://bugs.webkit.org/show_bug.cgi?id=164166
469         <rdar://problem/29055587>
470
471         Reviewed by Zalan Bujtas.
472
473         Added fast/multicol/flexbox-rows.html.
474
475         * rendering/RenderBlockFlow.cpp:
476         (WebCore::RenderBlockFlow::adjustForUnsplittableChild):
477         Treat block-level flexboxes that occur inside block flows the same as replaced
478         and unsplittable elements and push them to the next page if they don't fit. We don't
479         update the minimum page height though, since the flexbox is not really unsplittable.
480
481 2017-04-05  Simon Fraser  <simon.fraser@apple.com>
482
483         Set lastHandledUserGestureTimestamp on all ancestor documents, not just the top document
484         https://bugs.webkit.org/show_bug.cgi?id=170479
485
486         Reviewed by Sam Weinig.
487
488         When interacting with a subframe document, set lastHandledUserGestureTimestamp on all ancestor
489         documents up to the root.
490
491         This will be used in future for requestAnimationFrame throttling.
492
493         Test: fast/frames/user-gesture-timestamp-propagation.html
494
495         * dom/Document.cpp:
496         (WebCore::Document::updateLastHandledUserGestureTimestamp):
497         * dom/Document.h:
498         * dom/UserGestureIndicator.cpp:
499         (WebCore::UserGestureIndicator::UserGestureIndicator):
500         * testing/Internals.cpp:
501         (WebCore::Internals::lastHandledUserGestureTimestamp):
502         * testing/Internals.h:
503         * testing/Internals.idl:
504
505 2017-04-05  Eric Carlson  <eric.carlson@apple.com>
506
507         [MediaStream] Host application should be able to mute and unmute media streams
508         https://bugs.webkit.org/show_bug.cgi?id=170519
509         <rdar://problem/31174326>
510
511         Unreviewed, address review comments missed in the initial checkin.
512
513         * Modules/mediastream/MediaStream.cpp:
514         (WebCore::MediaStream::MediaStream): Mute the private stream if the page doesn't allow
515         capture.
516         (WebCore::MediaStream::pageMutedStateDidChange): setMuted -> setCaptureTracksMuted.
517
518         * platform/mediastream/MediaStreamPrivate.cpp:
519         (WebCore::MediaStreamPrivate::addTrack): Don't track muted state, the capture source already does.
520         (WebCore::MediaStreamPrivate::startProducingData):  Ditto.
521         (WebCore::MediaStreamPrivate::setCaptureTracksMuted): Renamed from setMuted.
522         (WebCore::MediaStreamPrivate::setMuted): Deleted.
523         * platform/mediastream/MediaStreamPrivate.h:
524
525 2017-04-05  Eric Carlson  <eric.carlson@apple.com>
526
527         [MediaStream] Host application should be able to mute and unmute media streams
528         https://bugs.webkit.org/show_bug.cgi?id=170519
529         <rdar://problem/31174326>
530
531         Reviewed by Youenn Fablet.
532
533         No new tests, fast/mediastream/MediaStream-page-muted.html was updated.
534
535         * Modules/mediastream/MediaStream.cpp:
536         (WebCore::MediaStream::~MediaStream): Fix a typo.
537         (WebCore::MediaStream::pageMutedStateDidChange): Don't store muted state, let the private
538         stream store it.
539         (WebCore::MediaStream::mediaState): Deal with new muted state flags.
540         * Modules/mediastream/MediaStream.h:
541
542         * dom/Document.cpp:
543         (WebCore::Document::prepareForDestruction): Clear media state before the frame is cleared.
544
545         * page/MediaProducer.h: Add muted flags.
546
547         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
548         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::checkSelectedVideoTrack): The display layer
549         should not be visible when the video track is muted.
550
551         * platform/mediastream/MediaStreamPrivate.cpp:
552         (WebCore::MediaStreamPrivate::addTrack): Mute the new track if necessary.
553         (WebCore::MediaStreamPrivate::startProducingData): Do nothing when muted.
554         (WebCore::MediaStreamPrivate::setExternallyMuted): New, mute/unmute tracks.
555         * platform/mediastream/MediaStreamPrivate.h:
556
557         * platform/mediastream/RealtimeMediaSource.cpp:
558         (WebCore::RealtimeMediaSource::setMuted): Start/stop producing data.
559
560         * testing/Internals.cpp:
561         (WebCore::Internals::pageMediaState): Support new media stream muted flags.
562
563 2017-04-05  Andreas Kling  <akling@apple.com>
564
565         Make inactive web processes behave as though under memory pressure.
566         https://bugs.webkit.org/show_bug.cgi?id=170042
567         <rdar://problem/31038445>
568
569         Reviewed by Antti Koivisto.
570
571         Prevent PerformanceMonitor from marking the process as inactive at startup.
572         This fixes the API test failure that caused this patch to get rolled out.
573
574         * page/PerformanceMonitor.h:
575
576 2017-04-05  Youenn Fablet  <youenn@apple.com>
577
578         Switch to kCVPixelFormatType_420YpCbCr8BiPlanarFullRange for Mac video capture format
579         https://bugs.webkit.org/show_bug.cgi?id=170509
580
581         Reviewed by Eric Carlson.
582
583         Covered by existing tests.
584
585         * platform/mediastream/mac/AVVideoCaptureSource.mm:
586
587 2017-04-05  Javier Fernandez  <jfernandez@igalia.com>
588
589         [css-align] Implement the place-items shorthand
590         https://bugs.webkit.org/show_bug.cgi?id=168847
591
592         Reviewed by David Hyatt.
593
594         The CSS Box Alignment specification defines a new shorthand to set the
595         Content Alignment properties (align-items and justify-items) at the
596         same time.
597
598         This patch provides the implementation of the CSS parsing logic and the
599         required regression tests. For the time being, as it happens with the
600         rest of the new alignment properties, the new parsing logic is
601         implemented behind the CSS Grid Layout runtime flag.
602
603         Test: css3/parse-place-items.html
604
605         * css/CSSComputedStyleDeclaration.cpp:
606         (WebCore::ComputedStyleExtractor::propertyValue):
607         * css/CSSProperties.json:
608         * css/StyleProperties.cpp:
609         (WebCore::StyleProperties::getPropertyValue):
610         (WebCore::StyleProperties::getAlignmentShorthandValue):
611         * css/StyleProperties.h:
612         * css/parser/CSSPropertyParser.cpp:
613         (WebCore::isAutoOrNormalOrStretch):
614         (WebCore::consumeSelfPositionOverflowPosition):
615         (WebCore::consumeSimplifiedItemPosition):
616         (WebCore::CSSPropertyParser::consumePlaceItemsShorthand):
617         * css/parser/CSSPropertyParser.h:
618
619 2017-04-05  Ryan Haddad  <ryanhaddad@apple.com>
620
621         Unreviewed, rolling out r214932.
622
623         This change broke an internal build.
624
625         Reverted changeset:
626
627         "[ios-simulator] API test WebKit2.DataDetectionReferenceDate
628         timing out"
629         https://bugs.webkit.org/show_bug.cgi?id=161967
630         http://trac.webkit.org/changeset/214932
631
632 2017-04-05  Ryan Haddad  <ryanhaddad@apple.com>
633
634         Unreviewed, rolling out r214962.
635
636         Roll r214937 back in because it wasn't at fault for the build
637         breakage.
638
639         Reverted changeset:
640
641         "Unreviewed, rolling out r214937."
642         https://bugs.webkit.org/show_bug.cgi?id=170365
643         http://trac.webkit.org/changeset/214962
644
645 2017-04-05  Ryan Haddad  <ryanhaddad@apple.com>
646
647         Unreviewed, rolling out r214937.
648
649         This change broke an internal build.
650
651         Reverted changeset:
652
653         "REGRESSION (r202472): Data Detection overwrites existing
654         links in detected ranges"
655         https://bugs.webkit.org/show_bug.cgi?id=170365
656         http://trac.webkit.org/changeset/214937
657
658 2017-04-05  Carlos Alberto Lopez Perez  <clopez@igalia.com>
659
660         [WebRTC][OpenWebRTC] Add support for SDP BUNDLE ("a:group:BUNDLE" and "a=bundle-only" lines)
661         https://bugs.webkit.org/show_bug.cgi?id=170157
662
663         Reviewed by Alejandro G. Castro.
664
665         This implements support on the SDPProcessor for generating an "a=group:BUNDLE"
666         attribute with the MID identifiers specified in the bundle group in the most
667         recent answer.
668         It also implements support for generating "a=bundle-only" attributes on the
669         "m=" sections of the SDP according to the bundlePolicy defined.
670
671         Test: fast/mediastream/RTCPeerConnection-inspect-offer-bundlePolicy-bundle-only.html
672
673         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
674         (WebCore::MediaEndpointPeerConnection::createOfferTask):
675         (WebCore::MediaEndpointPeerConnection::createAnswerTask):
676         * Modules/mediastream/SDPProcessor.cpp:
677         (WebCore::getBundlePolicyName):
678         (WebCore::configurationToJSON):
679         * Modules/mediastream/sdp.js:
680         (SDP.generate):
681         * platform/mediastream/MediaEndpointSessionConfiguration.h:
682         (WebCore::MediaEndpointSessionConfiguration::bundlePolicy):
683         (WebCore::MediaEndpointSessionConfiguration::setBundlePolicy):
684         (WebCore::MediaEndpointSessionConfiguration::clone):
685
686 2017-04-05  Jer Noble  <jer.noble@apple.com>
687
688         [MSE] Seeks to currentTime=0 will fail if currentTime is already 0.
689         https://bugs.webkit.org/show_bug.cgi?id=170510
690         <rdar://problem/30988403>
691
692         Reviewed by Eric Carlson.
693
694         Test: media/media-source/media-source-unnecessary-seek-seeked.html
695
696         The AVSampleBufferRenderSynchronizer won't fire a time jumped notification if no seek is actully
697         necessary. So short circuit the seek logic if the seek time is identical to the current synchronizer
698         time.
699
700         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
701         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal):
702
703 2017-04-05  Chris Dumez  <cdumez@apple.com>
704
705         <input type="range"> changing to disabled while active breaks all pointer events
706         https://bugs.webkit.org/show_bug.cgi?id=170447
707         <rdar://problem/31442875>
708
709         Reviewed by Geoffrey Garen.
710
711         When a range's slider is being moved, we set SliderThumbElement's m_inDragMode flag
712         to true and mark the range elements as the CapturingMouseEventsElement. When we get
713         the mouseUp event, we are supposed to exit drag mode. However, when the range element
714         gets disabled while dragging, we do not get the mouseUp event and we need to make
715         sure we exit dragging mode anyway. r112547 tried to fix this by calling stopDragging()
716         in SliderThumbElement::defaultEventHandler() when the input element is disabled.
717         While this often works, this is fragile and we sometimes fail to exit dragging mode
718         when we should.
719
720         This patch addressed the issue by calling stopDragging() in
721         SliderThumbElement::disabledAttributeChanged() instead. This is much safer as we
722         guarantee will exit dragging mode whenever the range element gets disabled, even
723         if SliderThumbElement::defaultEventHandler() does not get called after that.
724
725         Test: fast/forms/range/disabled-while-dragging.html
726
727         * html/RangeInputType.cpp:
728         (WebCore::RangeInputType::disabledAttributeChanged):
729         * html/RangeInputType.h:
730         * html/shadow/SliderThumbElement.cpp:
731         (WebCore::SliderThumbElement::defaultEventHandler):
732         (WebCore::SliderThumbElement::disabledAttributeChanged):
733         * html/shadow/SliderThumbElement.h:
734
735 2017-04-05  Eric Carlson  <eric.carlson@apple.com>
736
737         [MediaStream] Video doesn't render in fullscreen on iOS
738         https://bugs.webkit.org/show_bug.cgi?id=170404
739
740         Reviewed by Youenn Fablet.
741         
742         No new tests, filed https://bugs.webkit.org/show_bug.cgi?id=170512.
743
744         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
745         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
746         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC): Include
747         video fullscreen manager on iOS too.
748         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::videoTransformationMatrix): Add paramater
749         to force transform recalculation.
750         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample): Restructure code since
751         the display layer resize happens elsewhere.
752         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::ensureLayers): Include video fullscreen
753         manager on iOS too.
754         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::destroyLayers): Ditto.
755         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::platformLayer): Ditto.
756         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer): Ditto.
757         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::backgroundLayerBoundsChanged): Change the
758         display layer size and position immediately instead of waiting for the next sample buffer
759         so the display is correct when fullscreen mode changes when paused.
760
761 2017-04-05  Youenn Fablet  <youenn@apple.com>
762
763         Deprecate and remove URL.createObjectURL(mediastream)
764         https://bugs.webkit.org/show_bug.cgi?id=167518
765         <rdar://problem/31149607>
766
767         Reviewed by Eric Carlson.
768
769         Covered by updated tests.
770
771         * CMakeLists.txt:
772         * DerivedSources.cpp:
773         * DerivedSources.make:
774         * Modules/mediastream/DOMURLMediaStream.cpp: Removed.
775         * Modules/mediastream/DOMURLMediaStream.h: Removed.
776         * Modules/mediastream/DOMURLMediaStream.idl: Removed.
777         * WebCore.xcodeproj/project.pbxproj:
778         * html/DOMURL.idl:
779
780 2017-04-05  Alejandro G. Castro  <alex@igalia.com>
781
782         [Webrtc] Mock realtime sources factories should be static after r213941
783         https://bugs.webkit.org/show_bug.cgi?id=170282
784
785         Reviewed by Alex Christensen.
786
787         If we don't make the variables static we would be returning a
788         local variable.
789
790         * platform/mock/MockRealtimeAudioSource.cpp:
791         (WebCore::MockRealtimeAudioSource::factory):
792         * platform/mock/MockRealtimeVideoSource.cpp:
793         (WebCore::MockRealtimeVideoSource::factory):
794
795 2017-04-05  Alex Christensen  <achristensen@webkit.org>
796
797         Fix CMake build.
798
799         * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
800         Some JavaScript inline functions were not being accessed from this file with different enable flags.
801         * platform/spi/cf/CFNetworkSPI.h:
802         * platform/spi/cocoa/NSURLConnectionSPI.h:
803         Moved NSURLSession-specific SPI from NSURLConnectionSPI.h to CFNetworkSPI.h.
804
805 2017-04-05  Chris Dumez  <cdumez@apple.com>
806
807         _blank / _self / _parent / _top browsing context names should be case-insensitive
808         https://bugs.webkit.org/show_bug.cgi?id=169747
809
810         Reviewed by Alex Christensen.
811
812         _blank / _self / _parent / _top browsing context names should be case-insensitive
813         as per the HTML specification:
814         - https://html.spec.whatwg.org/#browsing-context-names
815
816         This aligns our behavior with Firefox as well. See discussion at:
817         - https://github.com/whatwg/html/issues/2443
818
819         Tests: imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-names/browsing-context-_blank.html
820                imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-names/browsing-context-choose-parent-001.html
821                imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-names/browsing-context-choose-parent-002.html
822                imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-names/browsing-context-choose-parent-003.html
823                imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-names/browsing-context-choose-parent-004.html
824
825         * loader/FrameLoader.cpp:
826         (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
827         (WebCore::createWindow):
828         * page/DOMWindow.cpp:
829         (WebCore::DOMWindow::open):
830         * page/FrameTree.cpp:
831         (WebCore::FrameTree::uniqueChildName):
832         (WebCore::FrameTree::find):
833
834 2017-04-05  Miguel Gomez  <magomez@igalia.com>
835
836         [GTK+] PNG animations that should run once are not played at all
837         https://bugs.webkit.org/show_bug.cgi?id=170499
838
839         Reviewed by Carlos Garcia Campos.
840
841         The repetition count reported bu the PNGImageDecoder is wrong. It's returning m_playCount - 1, which
842         means 0 for the animations that need to be played once. Change it to return an appropriate value.
843
844         Covered by existent tests.
845
846         * platform/image-decoders/png/PNGImageDecoder.cpp:
847         (WebCore::PNGImageDecoder::repetitionCount):
848         * platform/image-decoders/png/PNGImageDecoder.h:
849
850 2017-04-05  Andy Estes  <aestes@apple.com>
851
852         REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
853         https://bugs.webkit.org/show_bug.cgi?id=170365
854         <rdar://problem/29205721>
855
856         Reviewed by Tim Horton.
857
858         r202472 changed the node traversal in searchForLinkRemovingExistingDDLinks() to only
859         consider nodes that are descendants of startNode, but we need to traverse all nodes between
860         startNode and endNode to find existing non-DD links.
861
862         As a result, we'd add a Data Detector link to the following snippet and make the original
863         links un-clickable:
864
865             <a href='#'>tomorrow</a> <a href='#'>night</a>
866
867         Fix this by not specifying a stayWithin node when calling NodeTraversal::next(). The loop
868         will terminate when we reach endNode.
869
870         Updated WebKit2.DataDetectionReferenceDate API test.
871
872         * editing/cocoa/DataDetection.mm:
873         (WebCore::searchForLinkRemovingExistingDDLinks):
874
875 2017-04-04  Carlos Garcia Campos  <cgarcia@igalia.com>
876
877         Move WebErrors from WebProcess to Shared and get rid of ErrorsGtk in WebCore
878         https://bugs.webkit.org/show_bug.cgi?id=156974
879
880         Reviewed by Sam Weinig.
881
882         Remove ErrorsGtk.
883
884         * PlatformGTK.cmake:
885         * platform/gtk/ErrorsGtk.cpp: Removed.
886         * platform/gtk/ErrorsGtk.h: Removed.
887
888 2017-04-05  Andy Estes  <aestes@apple.com>
889
890         [ios-simulator] API test WebKit2.DataDetectionReferenceDate timing out
891         https://bugs.webkit.org/show_bug.cgi?id=161967
892
893         Reviewed by Alexey Proskuryakov.
894
895         DataDetectorsCoreSPI.h defined DDQueryOffset as a struct of two CFIndexes, which is 16 bytes
896         on LP64, but the struct is actually defined as two CFIndex-typed 32-bit bitfields, which is
897         8 bytes on LP64. This breaks the ABI on Public SDK builds when calling functions that take
898         or return DDQueryOffsets.
899
900         * platform/spi/cocoa/DataDetectorsCoreSPI.h: Updated the DDQueryOffset definition for
901         Public SDK builds, and added a static_assert to detect future size changes at compile time.
902
903 2017-04-04  Jer Noble  <jer.noble@apple.com>
904
905         Move AVSampleBufferDisplayLayer declarations into AVFoundationSPI.h
906         https://bugs.webkit.org/show_bug.cgi?id=170471
907
908         Reviewed by Eric Carlson.
909
910         Move the declaration of AVSampleBufferDisplayLayer (and related classes) into AVFoundationSPI.
911
912         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
913         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
914         * platform/spi/mac/AVFoundationSPI.h:
915
916 2017-04-04  Youenn Fablet  <youenn@apple.com>
917
918         Canvas is tainted when painting a video with MediaStreamTrack
919         https://bugs.webkit.org/show_bug.cgi?id=170486
920
921         Reviewed by Eric Carlson.
922
923         Test: http/tests/media/media-stream/getusermedia-with-canvas.html
924
925         Adding the notion of isolated source so that we can later on implement WebRTC isolated tracks.
926         For now, canvas will not be tainted if painted from a MediaStreamTrack.
927
928         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
929         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
930         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::didPassCORSAccessCheck):
931         * platform/mediastream/MediaStreamTrackPrivate.h:
932         (WebCore::MediaStreamTrackPrivate::isIsolated):
933         * platform/mediastream/RealtimeMediaSource.h:
934
935 2017-04-04  Commit Queue  <commit-queue@webkit.org>
936
937         Unreviewed, rolling out r214894, r214895, r214907, r214912,
938         and r214918.
939         https://bugs.webkit.org/show_bug.cgi?id=170491
940
941         Caused build failures on Mac (Requested by rniwa on #webkit).
942
943         Reverted changesets:
944
945         "Build fix."
946         http://trac.webkit.org/changeset/214894
947
948         "Rolling back the build fix, as it broke other builds."
949         http://trac.webkit.org/changeset/214895
950
951         "Move AVSampleBufferDisplayLayer declarations into
952         AVFoundationSPI.h"
953         https://bugs.webkit.org/show_bug.cgi?id=170471
954         http://trac.webkit.org/changeset/214907
955
956         "Unreviewed build fix: fix compilation error on Sierra."
957         http://trac.webkit.org/changeset/214912
958
959         "More build fixing."
960         http://trac.webkit.org/changeset/214918
961
962 2017-04-04  Youenn Fablet  <youenn@apple.com>
963
964         [Mac] Add back web audio support for getUserMedia MediaStreamTrack
965         https://bugs.webkit.org/show_bug.cgi?id=170482
966
967         Reviewed by Eric Carlson.
968
969         ´Covered by reenabled test.
970
971         Exporting method and class used in WebKit2.
972
973         * WebCore.xcodeproj/project.pbxproj:
974         * platform/audio/mac/CAAudioStreamDescription.h:
975         * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h:
976
977 2017-04-04  Alexey Proskuryakov  <ap@apple.com>
978
979         More build fixing.
980
981         * platform/spi/mac/AVFoundationSPI.h:
982
983 2017-04-04  Simon Fraser  <simon.fraser@apple.com>
984
985         Do some minor FEColorMatrix code cleanup and optimization
986         https://bugs.webkit.org/show_bug.cgi?id=170474
987
988         Reviewed by Dean Jackson.
989
990         Don't switch inside of a pixel processing loop; repeat the loop inside switch (filterType).
991         
992         Change matrix() and saturateAndHueRotate() to dereference the source pixels once, instead
993         of multiple times, which is faster.
994         
995         This kind of code benefits from aligning things with spaces for readability, so do so,
996         violating webkit style.
997         
998         Add some off-by-default performance logging code.
999
1000         Increases pixel processing performance from about 86ms per megapixel to 65ms per megapixel.
1001
1002         * platform/graphics/filters/FEColorMatrix.cpp:
1003         (WebCore::matrix):
1004         (WebCore::saturateAndHueRotate):
1005         (WebCore::effectType):
1006         (WebCore::FEColorMatrix::platformApplySoftware):
1007
1008 2017-04-04  Brent Fulgham  <bfulgham@apple.com>
1009
1010         Do not assert when CharacterData representing an Attr fires events
1011         https://bugs.webkit.org/show_bug.cgi?id=170454
1012         <rdar://problem/30979320>
1013
1014         Reviewed by Ryosuke Niwa.
1015
1016         Make the NoEventDispatchAssertion in CharacterData::notifyParentAfterChange conditional
1017         since Attr elements should be allowed to fire events.
1018
1019         Tests: fast/dom/no-assert-for-malformed-js-url-attribute.html
1020
1021         * dom/CharacterData.cpp:
1022         (WebCore::CharacterData::notifyParentAfterChange):
1023
1024 2017-04-04  Youenn Fablet  <youenn@apple.com>
1025
1026         LayoutTest webrtc/libwebrtc/descriptionGetters.html is a flaky failure
1027         https://bugs.webkit.org/show_bug.cgi?id=169481
1028
1029         Reviewed by Eric Carlson.
1030
1031         No need to enumerate all network interfaces in most layout tests.
1032         Adding an Internals API for that in case we want to use TCP localhost candidates.
1033
1034         * testing/Internals.cpp:
1035         (WebCore::Internals::Internals):
1036         (WebCore::Internals::setEnumeratingAllNetworkInterfacesEnabled):
1037         * testing/Internals.h:
1038         * testing/Internals.idl:
1039
1040
1041 2017-04-04  Jer Noble  <jer.noble@apple.com>
1042
1043         Unreviewed build fix: fix compilation error on Sierra.
1044
1045         * platform/spi/mac/AVFoundationSPI.h:
1046
1047 2017-04-04  Jer Noble  <jer.noble@apple.com>
1048
1049         Move AVSampleBufferDisplayLayer declarations into AVFoundationSPI.h
1050         https://bugs.webkit.org/show_bug.cgi?id=170471
1051
1052         Reviewed by Eric Carlson.
1053
1054         Move the declaration of AVSampleBufferDisplayLayer (and related classes) into AVFoundationSPI.
1055
1056         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
1057         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer): Deleted.
1058         (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer): Deleted.
1059         * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
1060         * platform/spi/mac/AVFoundationSPI.h:
1061
1062 2017-04-04  Saam Barati  <sbarati@apple.com>
1063
1064         WebAssembly: JSWebAssemblyCallee should not be a JSCell
1065         https://bugs.webkit.org/show_bug.cgi?id=170135
1066
1067         Reviewed by Michael Saboff.
1068
1069         * bindings/js/JSDOMWindowBase.cpp:
1070         (WebCore::callerDOMWindow):
1071
1072 2017-04-04  Simon Fraser  <simon.fraser@apple.com>
1073
1074         Change Document's lastHandledUserGestureTimestamp to be a MonotonicTime
1075         https://bugs.webkit.org/show_bug.cgi?id=170468
1076
1077         Reviewed by Zalan Bujtas.
1078         
1079         Change the double to MonotonicTime. No behavior change.
1080
1081         * dom/Document.cpp:
1082         (WebCore::Document::updateLastHandledUserGestureTimestamp):
1083         * dom/Document.h:
1084         (WebCore::Document::lastHandledUserGestureTimestamp):
1085         * html/HTMLPlugInImageElement.cpp:
1086         (WebCore::documentHadRecentUserGesture):
1087         * loader/FrameLoader.cpp:
1088         (WebCore::shouldAskForNavigationConfirmation):
1089
1090 2017-04-04  Youenn Fablet  <youenn@apple.com>
1091
1092         [Debug] ASSERT(!throwScope.exception()) on imported/w3c/web-platform-tests/fetch/api/cors/cors-preflight-status-worker.html
1093         https://bugs.webkit.org/show_bug.cgi?id=170395
1094         <rdar://problem/31394017>
1095
1096         Reviewed by Mark Lam.
1097
1098         No change of behavior.
1099
1100         * bindings/js/JSDOMPromise.cpp:
1101         (WebCore::DeferredPromise::reject): Adding early ASSERT that creating an exception is happening correctly.
1102
1103 2017-04-04  Alexey Proskuryakov  <ap@apple.com>
1104
1105         Rolling back the build fix, as it broke other builds.
1106
1107         * platform/spi/mac/AVFoundationSPI.h:
1108
1109 2017-04-04  Alexey Proskuryakov  <ap@apple.com>
1110
1111         Build fix.
1112
1113         Rubber-stamped by Jer Noble.
1114
1115         * platform/spi/mac/AVFoundationSPI.h:
1116
1117 2017-04-04  Tim Horton  <timothy_horton@apple.com>
1118
1119         [Mac] -[WKWebView findMatchesForString:relativeToMatch:findOptions:maxResults:resultCollector:] invokes the resultCollector with didWrap = NO even when it wraps
1120         https://bugs.webkit.org/show_bug.cgi?id=165801
1121         <rdar://problem/29649535>
1122
1123         Reviewed by Wenson Hsieh.
1124
1125         New API tests: WebKit2.FindInPageWrapping*
1126
1127         * page/FrameTree.cpp:
1128         (WebCore::FrameTree::traverseNextWithWrap):
1129         (WebCore::FrameTree::traversePreviousWithWrap):
1130         (WebCore::FrameTree::traverseNextInPostOrderWithWrap):
1131         * page/FrameTree.h:
1132         Add CanWrap and DidWrap boolean enums, and add an optional out argument
1133         to traverse*WithWrap indicating whether a wrap actually occurred.
1134
1135         * history/CachedPage.cpp:
1136         (WebCore::firePageShowAndPopStateEvents):
1137         * history/PageCache.cpp:
1138         (WebCore::destroyRenderTree):
1139         Adjust to the new CanWrap enum.
1140         
1141         * page/Page.cpp:
1142         (WebCore::incrementFrame):
1143         (WebCore::Page::findString):
1144         (WebCore::Page::findStringMatchingRanges):
1145         (WebCore::Page::rangeOfString):
1146         (WebCore::Page::findMatchesForText):
1147         (WebCore::Page::unmarkAllTextMatches):
1148         * page/Page.h:
1149         Adjust to the new CanWrap enum, and optionally plumb DidWrap through
1150         to callers of findString().
1151
1152 2017-04-04  Carlos Garcia Campos  <cgarcia@igalia.com>
1153
1154         [GTK] PLATFORM(GTK) && !USE(COORDINATED_GRAPHICS_THREADED) is no longer possible
1155         https://bugs.webkit.org/show_bug.cgi?id=170458
1156
1157         Reviewed by Carlos Alberto Lopez Perez.
1158
1159         That is not supported anymore, so we can remove dead code from VideoSinkGStreamer.cpp
1160
1161         * platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
1162         (VideoRenderRequestScheduler::VideoRenderRequestScheduler):
1163
1164 2017-04-04  Per Arne Vollan  <pvollan@apple.com>
1165
1166         Unreviewed Windows build fix.
1167
1168         * bindings/js/JSDOMGuardedObject.h:
1169
1170 2017-04-03  Wenson Hsieh  <wenson_hsieh@apple.com>
1171
1172         Data interaction should register type identifiers in order of priority
1173         https://bugs.webkit.org/show_bug.cgi?id=170428
1174         <rdar://problem/30633296>
1175
1176         Reviewed by Tim Horton.
1177
1178         Currently, due to the shared logic for writing to a UIPasteboard (in the case of copy/paste) and the shared
1179         UIItemProvider-based pasteboard wrapper (in the case of data interaction), we don't enforce any particular
1180         ordering in which type identifiers are registered in the generated item provider. This is because
1181         -[UIPasteboard setItems:] only takes an unordered mapping of type identifiers to objects.
1182
1183         To fix this, we introduce a separate way to set pasteboard data that first writes a list of object
1184         representations in order of priority (which is dependent on the content being interacted with) and then register
1185         individual type-data mappings at the end.
1186
1187         Augmented existing API tests in DataInteractionTests to check for the existence and priority of type identifiers
1188         in the UIItemProviders created upon starting data interaction. Also adds a new unit test:
1189         DataInteractionTests.TextAreaToInput.
1190
1191         * WebCore.xcodeproj/project.pbxproj:
1192         * editing/cocoa/EditorCocoa.mm:
1193         (WebCore::archivedDataForAttributedString):
1194         (WebCore::Editor::writeSelectionToPasteboard):
1195         (WebCore::Editor::writeSelection):
1196         * platform/Pasteboard.h:
1197         * platform/PasteboardWriterData.h:
1198         * platform/PlatformPasteboard.h:
1199         * platform/ios/AbstractPasteboard.h:
1200         * platform/ios/AbstractPasteboard.mm: Copied from Source/WebCore/platform/ios/AbstractPasteboard.h.
1201
1202         Introduce WebPasteboardItemData, a wrapper around a list of objects representating the pasteboard data in order
1203         of priority, and a dictionary containing additional NSData blobs that contain data useful for private clients.
1204
1205         (+[WebPasteboardItemData itemWithRepresentingObjects:additionalData:]):
1206         (-[WebPasteboardItemData initWithRepresentingObjects:additionalData:]):
1207         (-[WebPasteboardItemData representingObjects]):
1208         (-[WebPasteboardItemData additionalData]):
1209         * platform/ios/PlatformPasteboardIOS.mm:
1210         (WebCore::richTextRepresentationsForPasteboardWebContent):
1211         (WebCore::PlatformPasteboard::writeObjectRepresentations):
1212         (WebCore::PlatformPasteboard::write):
1213
1214         Tweaked to check whether the pasteboard responds to -setItemsFromObjectRepresentations:. If so, uses the
1215         PlatformPasteboard::writeObjectRepresentations codepath to write data to the pasteboard, respecting type
1216         priority.
1217
1218         * platform/ios/WebItemProviderPasteboard.mm:
1219         (-[WebItemProviderPasteboard pasteboardTypes]):
1220         (-[WebItemProviderPasteboard setItemProviders:]):
1221         (-[WebItemProviderPasteboard setItemsFromObjectRepresentations:]):
1222
1223         Replaces -setItems: with -setItemsFromObjectRepresentations:, which respects the priority of each object
1224         representation of the data in the pasteboard.
1225
1226         (-[WebItemProviderPasteboard setItems:]): Deleted.
1227
1228 2017-04-03  Javier Fernandez  <jfernandez@igalia.com>
1229
1230         [css-align] Adapt place-content alignment shorthand to the new baseline syntax
1231         https://bugs.webkit.org/show_bug.cgi?id=170340
1232
1233         Reviewed by David Hyatt.
1234
1235         Now that the align-content and justify-content CSS properties are
1236         adapted to the new baseline-position CSS values syntax we can adapt the
1237         shorthand that controls such properties to the new syntax as well.
1238
1239         No new tests, just adding some additional cases to the tests we already have.
1240
1241         * css/StyleProperties.cpp:
1242         (WebCore::StyleProperties::getPropertyValue):
1243         (WebCore::StyleProperties::placeContentPropertyValue):
1244         * css/StyleProperties.h:
1245         * css/parser/CSSPropertyParser.cpp:
1246         (WebCore::isContentDistributionKeyword):
1247         (WebCore::isContentPositionKeyword):
1248         (WebCore::isOverflowKeyword):
1249         (WebCore::getBaselineKeyword):
1250         (WebCore::consumeContentDistributionOverflowPosition):
1251         (WebCore::consumeSimplifiedContentPosition):
1252
1253 2017-04-03  Nan Wang  <n_wang@apple.com>
1254
1255         AX: Expose link children when doing search predication on iOS
1256         https://bugs.webkit.org/show_bug.cgi?id=170424
1257         <rdar://problem/31413335>
1258
1259         The children of links are accessible elements on iOS instead of the link itself, 
1260         so we should expose the children when doing predicated searches as well.
1261
1262         Reviewed by Chris Fleizach.
1263
1264         Test: accessibility/ios-simulator/ios-search-predicate-link-children.html
1265
1266         * accessibility/AccessibilityObject.cpp:
1267         (WebCore::AccessibilityObject::isAccessibilityObjectSearchMatchAtIndex):
1268
1269 2017-04-03  Jer Noble  <jer.noble@apple.com>
1270
1271         No audio output for MediaStream-backed audio elements on iOS
1272         https://bugs.webkit.org/show_bug.cgi?id=170427
1273
1274         Reviewed by Eric Carlson.
1275
1276         The logic for setting the output timestamp offset in AudioSampleDataSource was reversed; instead of
1277         subtracting out the timestamp of the first pull request, it effectively doubled it.
1278
1279         * platform/audio/mac/AudioSampleDataSource.mm:
1280         (WebCore::AudioSampleDataSource::pullSamplesInternal):
1281
1282 2017-04-03  Dave Hyatt  <hyatt@apple.com>
1283
1284         Japanese fonts in vertical text should support synthesized italics
1285         https://bugs.webkit.org/show_bug.cgi?id=169301
1286
1287         Reviewed by Simon Fraser.
1288
1289         Updated test in fast/text/international.
1290
1291         * platform/graphics/Font.cpp:
1292         (WebCore::Font::nonSyntheticItalicFont): Deleted.
1293         * platform/graphics/Font.h:
1294         Removed the non-synthetic italic font member, since it's not used.
1295
1296         * platform/graphics/FontCascadeFonts.cpp:
1297         (WebCore::glyphDataForNonCJKCharacterWithGlyphOrientation):
1298         Patched to ensure that a text-orientation-fallback font data is always
1299         returned in the synthetic oblique case, so that non-CJK and CJK are
1300         guaranteed to be broken up so that their slants can be applied differently.
1301
1302         (WebCore::FontCascadeFonts::glyphDataForSystemFallback):
1303         (WebCore::FontCascadeFonts::glyphDataForNormalVariant):
1304         (WebCore::glyphDataForCJKCharacterWithoutSyntheticItalic): Deleted.
1305         Patched to no longer turn off synthetic oblique for CJK.
1306
1307         * platform/graphics/cocoa/FontCascadeCocoa.mm:
1308         (WebCore::FontCascade::drawGlyphs):
1309         Apply the correct italic transform to CJK when in vertical text.
1310
1311 2017-04-03  Chris Dumez  <cdumez@apple.com>
1312
1313         REGRESSION (r206744): CSS background-image in style attribute ignored when using createHTMLDocument method of DOM parsing
1314         https://bugs.webkit.org/show_bug.cgi?id=170285
1315         <rdar://problem/31378543>
1316
1317         Reviewed by Andy Estes.
1318
1319         r206744 caused up to stop trying to resolve relative URLs when trying to load an image
1320         referred to by CSS. We already try to resolve the relative URL when parsing the CSS
1321         property so this will usually work fine. However, in the case when the CSS property
1322         is parsed in detached document and then moved to another document, we will not have
1323         the complete URL.
1324
1325         Test: fast/images/background-image-relative-url-changes-document.html
1326
1327         * css/CSSImageValue.cpp:
1328         (WebCore::CSSImageValue::loadImage):
1329
1330 2017-04-03  Jeremy Jones  <jeremyj@apple.com>
1331
1332         Do not set WebAVPlayerLayerView background to black in fullscreen.
1333         https://bugs.webkit.org/show_bug.cgi?id=170132
1334         rdar://problem/30839278
1335
1336         Reviewed by Tim Horton.
1337
1338         No new tests because no behavior change.
1339
1340         The black background on WebAVPlayerLayerView interferes with the fullscreen animation
1341         and has been removed.
1342
1343         * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
1344         (WebVideoFullscreenInterfaceAVKit::enterFullscreen):
1345         (WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard):
1346
1347 2017-04-03  Antti Koivisto  <antti@apple.com>
1348
1349         REGRESSION (r207669): FileMaker Pro Help pages do not render correctly
1350         https://bugs.webkit.org/show_bug.cgi?id=170402
1351         <rdar://problem/31004344>
1352
1353         Reviewed by Simon Fraser.
1354
1355         If a new stylesheet load is started from the load event the document.styleSheets does not
1356         always reflect the already loaded stylesheets.
1357
1358         Test: fast/css/document-stylesheets-dynamic.html
1359
1360         * style/StyleScope.cpp:
1361         (WebCore::Style::Scope::updateActiveStyleSheets):
1362
1363             Remove an old optimization where we would not update active stylesheets if there were pending
1364             (head) stylesheet loads and they had not been updated already.
1365             This is probably not a valuable optimization anymore with the new lazy stylesheet update strategy.
1366
1367         * style/StyleScope.h:
1368
1369 2017-04-03  Anders Carlsson  <andersca@apple.com>
1370
1371         Tweak ApplePaySession API
1372         https://bugs.webkit.org/show_bug.cgi?id=170409
1373         rdar://problem/31405459
1374
1375         Reviewed by Tim Horton.
1376
1377         Rename "address" to "addressLines". Add "postalAddress". Reorder the ApplePayError constructor parameters.
1378
1379         * Modules/applepay/ApplePayError.cpp:
1380         (WebCore::ApplePayError::create):
1381         (WebCore::ApplePayError::ApplePayError):
1382         * Modules/applepay/ApplePayError.h:
1383         * Modules/applepay/ApplePayError.idl:
1384         * Modules/applepay/PaymentRequest.h:
1385
1386 2017-04-03  Zan Dobersek  <zdobersek@igalia.com>
1387
1388         [GCrypt] Implement CryptoKeyEC::keySizeInBits(), ::platformGeneratePair()
1389         https://bugs.webkit.org/show_bug.cgi?id=170345
1390
1391         Reviewed by Michael Catanzaro.
1392
1393         Start implementing the libgcrypt-based platform bits of CryptoKeyEC.
1394
1395         Implement keySizeInBits() by returning the appropriate size for this
1396         object's curve type. An assertion is added to ensure that this size
1397         matches the one that's returned by gcry_pk_get_nbits() for this
1398         object's EC key as represented by the m_platformKey gcry_sexp_t object.
1399
1400         Implement platformGeneratePair() by constructing a genkey s-expression
1401         that requests a generation of an EC key for the specified curve type.
1402         The s-expression is then passed to gcry_pk_genkey(), and the public
1403         and private key data is then retrieved from the returned s-expression
1404         upon success and used to create the public and private CryptoKeyEC
1405         objects.
1406
1407         The PlatformECKey type alias is changed to match gcry_sexp_t. The
1408         CryptoKeyEC destructor releases the gcry_sexp_t object through
1409         a PAL::GCrypt::HandleDeleter<gcry_sexp_t> instance.
1410
1411         The method definitions in the CryptoKeyECGCrypt.cpp file are also
1412         sorted to match the declaration order in the header.
1413
1414         No new tests -- current ones cover this sufficiently, but are not yet
1415         enabled due to other missing platform-specific SUBTLE_CRYPTO
1416         implementations.
1417
1418         * crypto/gcrypt/CryptoKeyECGCrypt.cpp:
1419         (WebCore::curveSize):
1420         (WebCore::curveName):
1421         (WebCore::CryptoKeyEC::~CryptoKeyEC):
1422         (WebCore::CryptoKeyEC::keySizeInBits):
1423         (WebCore::CryptoKeyEC::platformGeneratePair):
1424         (WebCore::CryptoKeyEC::platformImportSpki):
1425         (WebCore::CryptoKeyEC::platformImportPkcs8):
1426         (WebCore::CryptoKeyEC::platformExportRaw):
1427         (WebCore::CryptoKeyEC::platformAddFieldElements):
1428         (WebCore::CryptoKeyEC::platformExportSpki):
1429         * crypto/keys/CryptoKeyEC.h:
1430
1431 2017-04-03  Zan Dobersek  <zdobersek@igalia.com>
1432
1433         [GCrypt] Implement AES_KW support
1434         https://bugs.webkit.org/show_bug.cgi?id=170274
1435
1436         Reviewed by Michael Catanzaro.
1437
1438         Implement the CryptoAlgorithmAES_KW::platform{Wrap,Unwrap}Key()
1439         functionality for configurations that use libgcrypt. This is done
1440         by leveraging the gcry_cipher_* APIs for the AES algorithm that's
1441         deducted appropriately from the key size and the AESWRAP cipher mode.
1442
1443         No new tests -- current ones cover this sufficiently, but are not yet
1444         enabled due to other missing platform-specific SUBTLE_CRYPTO
1445         implementations.
1446
1447         * crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp:
1448         (WebCore::gcryptWrapKey):
1449         (WebCore::gcryptUnwrapKey):
1450         (WebCore::CryptoAlgorithmAES_KW::platformWrapKey):
1451         (WebCore::CryptoAlgorithmAES_KW::platformUnwrapKey):
1452
1453 2017-04-03  Zan Dobersek  <zdobersek@igalia.com>
1454
1455         [GCrypt] Implement AES_GCM support
1456         https://bugs.webkit.org/show_bug.cgi?id=170271
1457
1458         Reviewed by Michael Catanzaro.
1459
1460         Implement the CryptoAlgorithmAES_GCM::platform{Encrypt,Decrypt}
1461         functionality for configurations that use libgcrypt. This is done
1462         by leveraging the gcry_cipher_* APIs for the AES algorithm that's
1463         deducted appropriately from the key size and the GCM cipher mode.
1464
1465         No new tests -- current ones cover this sufficiently, but are not yet
1466         enabled due to other missing platform-specific SUBTLE_CRYPTO
1467         implementations.
1468
1469         * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:
1470         (WebCore::gcryptEncrypt):
1471         (WebCore::gcryptDecrypt):
1472         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
1473         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
1474
1475 2017-04-03  Zan Dobersek  <zdobersek@igalia.com>
1476
1477         [GCrypt] Implement PBKDF2 support
1478         https://bugs.webkit.org/show_bug.cgi?id=170270
1479
1480         Reviewed by Michael Catanzaro.
1481
1482         Implement the CryptoAlgorithmPBKDF2::platformDeriveBits() functionality
1483         for configurations that use libgcrypt. This is done by leveraging the
1484         gcry_kdf_derive() API, using GCRY_KDF_PBKDF2 as the preferred KDF
1485         along with the properly deducted SHA algorithm.
1486
1487         No new tests -- current ones cover this sufficiently, but are not yet
1488         enabled due to other missing platform-specific SUBTLE_CRYPTO
1489         implementations.
1490
1491         * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:
1492         (WebCore::gcryptDeriveBits):
1493         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
1494
1495 2017-04-01  Simon Fraser  <simon.fraser@apple.com>
1496
1497         Clean up touch event handler registration when moving nodes between documents
1498         https://bugs.webkit.org/show_bug.cgi?id=170384
1499         rdar://problem/30816694
1500
1501         Reviewed by Chris Dumez.
1502
1503         Make sure that Node::didMoveToNewDocument() does the correct unregistration on the
1504         old document, and registration on the new document for nodes with touch event listeners,
1505         and gesture event listeners. Touch "handler" nodes (those for overflow and sliders) are
1506         already correctly moved via renderer-related teardown.
1507
1508         Add assertions that fire when removal was not complete.
1509
1510         Use references in more places.
1511
1512         Tests: fast/events/touch/ios/gesture-node-move-between-documents.html
1513                fast/events/touch/ios/overflow-node-move-between-documents.html
1514                fast/events/touch/ios/slider-node-move-between-documents.html
1515                fast/events/touch/ios/touch-node-move-between-documents.html
1516
1517         * dom/EventNames.h:
1518         (WebCore::EventNames::gestureEventNames):
1519         * dom/Node.cpp:
1520         (WebCore::Node::willBeDeletedFrom):
1521         (WebCore::Node::didMoveToNewDocument):
1522         (WebCore::tryAddEventListener):
1523         (WebCore::tryRemoveEventListener):
1524         * html/shadow/SliderThumbElement.cpp:
1525         (WebCore::SliderThumbElement::registerForTouchEvents):
1526         (WebCore::SliderThumbElement::unregisterForTouchEvents):
1527         * rendering/RenderLayer.cpp:
1528         (WebCore::RenderLayer::registerAsTouchEventListenerForScrolling):
1529         (WebCore::RenderLayer::unregisterAsTouchEventListenerForScrolling):
1530
1531 2017-04-03  Youenn Fablet  <youenn@apple.com>
1532
1533         captureStream is getting black frames with webgl canvas
1534         https://bugs.webkit.org/show_bug.cgi?id=170325
1535
1536         Reviewed by Dean Jackson.
1537
1538         Test: fast/mediastream/captureStream/canvas3d.html
1539
1540         Changing the webgl context to save buffers in case the canvas is captured.
1541         Adding a canvas changed notification in case of clear.
1542         In the future, we might want to change this notification and do it when endPaint or similar is called.
1543
1544         Adding an Internals API to grab the RGBA equivalent of the next track frame.
1545         For that purpose, adding a bunch of WEBCORE_EXPORT.
1546
1547         * Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp:
1548         (WebCore::CanvasCaptureMediaStreamTrack::Source::Source): Adding constraints support so that track settings
1549         getter actually transmits the width and height of the source.
1550         (WebCore::CanvasCaptureMediaStreamTrack::Source::canvasChanged): ensuring webgl canvas context keep their drawing buffer.
1551         * Modules/mediastream/MediaStreamTrack.h:
1552         * bindings/js/JSDOMGuardedObject.h:
1553         * bindings/js/JSDOMPromise.h:
1554         (WebCore::DeferredPromise::resolve):
1555         (WebCore::DeferredPromise::reject):
1556         * dom/ActiveDOMCallback.h:
1557         * html/HTMLCanvasElement.cpp:
1558         (WebCore::HTMLCanvasElement::captureStream):
1559         * html/ImageData.h:
1560         * html/ImageData.idl:
1561         * html/canvas/WebGLRenderingContext.cpp:
1562         (WebCore::WebGLRenderingContext::clear): ensuring canvas observers get notified in case of clear calls.
1563         * html/canvas/WebGLRenderingContextBase.h:
1564         (WebCore::WebGLRenderingContextBase::preserveDrawingBuffer): Added to allow canvas capture to update this property.
1565         * platform/MediaSample.h:
1566         (WebCore::MediaSample::getRGBAImageData): Added for internals API.
1567         * platform/graphics/avfoundation/MediaSampleAVFObjC.h:
1568         * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
1569         (WebCore::MediaSampleAVFObjC::getRGBAImageData):
1570         * platform/graphics/cv/PixelBufferConformerCV.cpp:
1571         (WebCore::PixelBufferConformerCV::convert): Helper routine for getRGBAImageData.
1572         * platform/graphics/cv/PixelBufferConformerCV.h:
1573         * platform/mediastream/RealtimeMediaSourceSettings.h:
1574         (WebCore::RealtimeMediaSourceSettings::setSupportedConstraints):
1575         (WebCore::RealtimeMediaSourceSettings::setSupportedConstraits): Deleted.
1576         * platform/mediastream/mac/AVMediaCaptureSource.mm:
1577         (WebCore::AVMediaCaptureSource::initializeSettings):
1578         * platform/mediastream/openwebrtc/RealtimeAudioSourceOwr.h:
1579         * platform/mediastream/openwebrtc/RealtimeVideoSourceOwr.h:
1580         * platform/mock/MockRealtimeMediaSource.cpp:
1581         (WebCore::MockRealtimeMediaSource::initializeSettings):
1582         * testing/Internals.cpp:
1583         (WebCore::Internals::grabNextMediaStreamTrackFrame):
1584         (WebCore::Internals::videoSampleAvailable):
1585         * testing/Internals.h:
1586         * testing/Internals.idl:
1587
1588 2017-04-03  Per Arne Vollan  <pvollan@apple.com>
1589
1590         Implement stroke-miterlimit.
1591         https://bugs.webkit.org/show_bug.cgi?id=169078
1592
1593         Reviewed by Dean Jackson.
1594
1595         Support stroke-miterlimit for text rendering, see https://drafts.fxtf.org/paint/.
1596
1597         Tests: fast/css/stroke-miterlimit-default.html
1598                fast/css/stroke-miterlimit-large.html
1599                fast/css/stroke-miterlimit-zero.html
1600
1601         * css/CSSComputedStyleDeclaration.cpp:
1602         (WebCore::ComputedStyleExtractor::propertyValue):
1603         * css/CSSProperties.json:
1604         * css/SVGCSSComputedStyleDeclaration.cpp:
1605         (WebCore::ComputedStyleExtractor::svgPropertyValue):
1606         * rendering/TextPaintStyle.cpp:
1607         (WebCore::computeTextPaintStyle):
1608         (WebCore::updateGraphicsContext):
1609         * rendering/TextPaintStyle.h:
1610         * rendering/style/RenderStyle.cpp:
1611         (WebCore::RenderStyle::diff):
1612         * rendering/style/RenderStyle.h:
1613         (WebCore::RenderStyle::strokeMiterLimit):
1614         (WebCore::RenderStyle::setStrokeMiterLimit):
1615         (WebCore::RenderStyle::initialStrokeMiterLimit):
1616         (WebCore::RenderStyle::setStrokeDashOffset):
1617         * rendering/style/RenderStyleConstants.cpp:
1618         * rendering/style/RenderStyleConstants.h:
1619         * rendering/style/SVGRenderStyle.cpp:
1620         (WebCore::SVGRenderStyle::diff):
1621         * rendering/style/SVGRenderStyle.h:
1622         (WebCore::SVGRenderStyle::initialStrokeDashArray):
1623         (WebCore::SVGRenderStyle::strokeDashArray):
1624         (WebCore::SVGRenderStyle::initialStrokeMiterLimit): Deleted.
1625         (WebCore::SVGRenderStyle::strokeMiterLimit): Deleted.
1626         (WebCore::SVGRenderStyle::setStrokeMiterLimit): Deleted.
1627         * rendering/style/SVGRenderStyleDefs.cpp:
1628         (WebCore::StyleStrokeData::StyleStrokeData):
1629         (WebCore::StyleStrokeData::operator==):
1630         * rendering/style/SVGRenderStyleDefs.h:
1631         * rendering/style/StyleRareInheritedData.cpp:
1632         (WebCore::StyleRareInheritedData::StyleRareInheritedData):
1633         (WebCore::StyleRareInheritedData::operator==):
1634         * rendering/style/StyleRareInheritedData.h:
1635         * rendering/svg/RenderSVGShape.cpp:
1636         (WebCore::RenderSVGShape::hasSmoothStroke):
1637         * rendering/svg/SVGRenderSupport.cpp:
1638         (WebCore::SVGRenderSupport::applyStrokeStyleToContext):
1639         * rendering/svg/SVGRenderTreeAsText.cpp:
1640         (WebCore::writeStyle):
1641
1642 2017-04-03  Alejandro G. Castro  <alex@igalia.com>
1643
1644         [OWR] Fix class structure for the OWR mock classes after last modifications
1645         https://bugs.webkit.org/show_bug.cgi?id=170173
1646
1647         Reviewed by Youenn Fablet.
1648
1649         In case of OWR MockRealtimeMediaSource inherits from
1650         RealtimeMediaSourceOwr, so we have to change some of the function
1651         interfaces.
1652
1653         * platform/mock/MockRealtimeMediaSource.h:
1654
1655 2017-04-02  Alexey Proskuryakov  <ap@apple.com>
1656
1657         Build fix for
1658         Add missing text styles
1659         https://bugs.webkit.org/show_bug.cgi?id=170295
1660
1661         * rendering/RenderThemeIOS.mm:
1662         (WebCore::RenderThemeIOS::cachedSystemFontDescription):
1663         (WebCore::RenderThemeIOS::updateCachedSystemFontDescription):
1664
1665 2017-04-01  Zalan Bujtas  <zalan@apple.com>
1666
1667         Long Arabic text in ContentEditable with css white-space=pre hangs Safari
1668         https://bugs.webkit.org/show_bug.cgi?id=170245
1669
1670         Reviewed by Myles C. Maxfield.
1671
1672         While searching for mid-word break, we measure the text by codepoints in a loop until the accumulated width > available width.
1673         When we see that the accumulated width for the individual codepoints overflows, we join the codepoints and re-measure them.
1674         These 2 widths could be considerably different for number of reasons (ligatures is a prime example). When we figure that
1675         the run still fits, we go back to the main loop (since we are not supposed to wrap the line here) and take the next codepoint.
1676         However this time we start the measurement from the last whitespace, so we end up remeasuring a potentially long chuck of text
1677         until we hit the wrapping point. This is way too expensive.
1678         This patch changes the logic so that we just go back to measuring individual codepoints until we hit the constrain again.  
1679
1680         Covered by existing tests.
1681
1682         * rendering/line/BreakingContext.h:
1683         (WebCore::BreakingContext::handleText): canUseSimpleFontCodePath() is just to mitigate the potential risk of regression and
1684         complex text is more likely to fall into this category. 
1685
1686 2017-04-01  Jon Lee  <jonlee@apple.com>
1687
1688         Add missing text styles
1689         https://bugs.webkit.org/show_bug.cgi?id=170295
1690         rdar://problem/30219503
1691
1692         Reviewed by Dean Jackson.
1693
1694         Updated existing test to include new text styles.
1695
1696         * css/CSSValueKeywords.in: Add title0 and title4.
1697         * platform/spi/cocoa/CoreTextSPI.h:
1698         * rendering/RenderThemeIOS.mm:
1699         (WebCore::RenderThemeIOS::cachedSystemFontDescription):
1700         (WebCore::RenderThemeIOS::updateCachedSystemFontDescription):
1701
1702 2017-04-01  Dan Bernstein  <mitz@apple.com>
1703
1704         [iOS] <input type=file> label should be specified using plural rules
1705         https://bugs.webkit.org/show_bug.cgi?id=170388
1706
1707         Reviewed by Alexey Proskuryakov.
1708
1709         * English.lproj/Localizable.strings: Updated using update-webkit-localizable-strings.
1710
1711         * English.lproj/Localizable.stringsdict: Added an entry for the new key "%lu photo(s) and
1712           %lu video(s)", with plural rules covering all the different combinations in English.
1713           Other localizations may specify additional combinations as needed.
1714
1715 2017-04-01  Alexey Proskuryakov  <ap@apple.com>
1716
1717         Rolling back <https://trac.webkit.org/r214697>, as it made WebKit2.DataDetectionReferenceDate time out.
1718
1719         Was REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
1720         https://bugs.webkit.org/show_bug.cgi?id=170365
1721
1722         * editing/cocoa/DataDetection.mm:
1723         (WebCore::searchForLinkRemovingExistingDDLinks):
1724
1725 2017-04-01  Chris Dumez  <cdumez@apple.com>
1726
1727         We should pause silent WebAudio rendering in background tabs
1728         https://bugs.webkit.org/show_bug.cgi?id=170299
1729         <rdar://problem/31289132>
1730
1731         Reviewed by Eric Carlson.
1732
1733         We should pause silent WebAudio rendering in background tabs since it uses CPU and is
1734         not observable by the user. Such silent WebAudio rendering seems to be used by
1735         doubleclick ads.
1736
1737         Test: webaudio/silent-audio-interrupted-in-background.html
1738
1739         * Modules/webaudio/AudioContext.cpp:
1740         (WebCore::AudioContext::lazyInitialize):
1741         (WebCore::AudioContext::uninitialize):
1742         Have AudioContext register / unregister itself with the Document to get
1743         visibility change notifications, similarly to what HTMLMediaElement was
1744         already doing.
1745
1746         (WebCore::AudioContext::visibilityStateChanged):
1747         Begin / End session interruption whenever the page visiblity changes.
1748
1749         * Modules/webaudio/AudioContext.h:
1750         * WebCore.xcodeproj/project.pbxproj:
1751
1752         * dom/Document.cpp:
1753         (WebCore::Document::registerForVisibilityStateChangedCallbacks):
1754         (WebCore::Document::unregisterForVisibilityStateChangedCallbacks):
1755         (WebCore::Document::visibilityStateChanged):
1756         * dom/Document.h:
1757         * dom/Element.h:
1758         * dom/VisibilityChangeClient.h: Added.
1759         (WebCore::VisibilityChangeClient::~VisibilityChangeClient):
1760         * html/HTMLMediaElement.h:
1761         Introduce a new VisibilityChangeClient interface and have both AudioContext
1762         and HTMLMediaElement subclass it. Previously, the visibilityStateChanged()
1763         function was on Element but this prevented AudioContext from registering
1764         itself since AudioContext is not an Element.
1765
1766 2017-04-01  Dan Bernstein  <mitz@apple.com>
1767
1768         [Cocoa] A couple of UI strings use three periods instead of an ellipsis
1769         https://bugs.webkit.org/show_bug.cgi?id=170386
1770
1771         Reviewed by Tim Horton.
1772
1773         * English.lproj/Localizable.strings: Updated using update-webkit-localizable-strings.
1774
1775         * platform/LocalizedStrings.cpp:
1776         (WebCore::mediaElementLoadingStateText): Changed "Loading..." to "Loading…".
1777
1778         * platform/cocoa/LocalizedStringsCocoa.mm:
1779         (WebCore::contextMenuItemTagStyles): Changed "Styles..." to "Styles…".
1780
1781 2017-04-01  Dan Bernstein  <mitz@apple.com>
1782
1783         Localizable strings files are out of date
1784         https://bugs.webkit.org/show_bug.cgi?id=170383
1785
1786         Reviewed by Tim Horton.
1787
1788         Ran update-webkit-localizable-strings.
1789
1790         * English.lproj/Localizable.strings:
1791
1792 2017-04-01  Dan Bernstein  <mitz@apple.com>
1793
1794         [Xcode] In engineering builds, linker warns about libwebrtc.dylib’s install name being invalid
1795         https://bugs.webkit.org/show_bug.cgi?id=170385
1796
1797         Reviewed by Tim Horton.
1798
1799         * Configurations/DebugRelease.xcconfig: Set WK_RELOCATABLE_FRAMEWORKS to YES like we do
1800           in some other projects’ DebugRelease.xcconfig. Engineering builds are always relocatable.
1801         * Configurations/WebCore.xcconfig: When WebCore is relocatable, tell the linker that it’s
1802           not going to be in the shared cache, even if its install name implies that it might be.
1803
1804 2017-04-01  Alexey Proskuryakov  <ap@apple.com>
1805
1806         Rolling back http://trac.webkit.org/r214663 - memory corruption
1807
1808         * Modules/streams/ReadableByteStreamInternals.js:
1809         (cloneArrayBuffer):
1810         * bindings/js/JSDOMGlobalObject.cpp:
1811         (WebCore::JSDOMGlobalObject::addBuiltinGlobals):
1812         * bindings/js/StructuredClone.cpp:
1813         (WebCore::structuredCloneArrayBuffer):
1814         (WebCore::cloneArrayBufferImpl): Deleted.
1815         (WebCore::cloneArrayBuffer): Deleted.
1816         * bindings/js/StructuredClone.h:
1817         * bindings/js/WebCoreBuiltinNames.h:
1818         * testing/Internals.cpp:
1819         (WebCore::markerTypeFrom):
1820         (WebCore::Internals::resetToConsistentState):
1821         (WebCore::Internals::isLoadingFromMemoryCache):
1822         (WebCore::Internals::setImageFrameDecodingDuration):
1823         (WebCore::deferredStyleRulesCountForList):
1824         (WebCore::deferredGroupRulesCountForList):
1825         (WebCore::deferredKeyframesRulesCountForList):
1826         (WebCore::Internals::eventThrottlingBehaviorOverride):
1827         (WebCore::Internals::enableMockSpeechSynthesizer):
1828         (WebCore::Internals::rangeForDictionaryLookupAtLocation):
1829         (WebCore::Internals::nodesFromRect):
1830         (WebCore::Internals::layerIDForElement):
1831         (WebCore::Internals::setElementUsesDisplayListDrawing):
1832         (WebCore::Internals::setElementTracksDisplayListReplay):
1833         (WebCore::Internals::styleRecalcCount):
1834         (WebCore::Internals::compositingUpdateCount):
1835         (WebCore::Internals::setCaptionDisplayMode):
1836         (WebCore::Internals::endMediaSessionInterruption):
1837         (WebCore::Internals::postRemoteControlCommand):
1838         (WebCore::appendOffsets):
1839         (WebCore::Internals::scrollSnapOffsets):
1840         (WebCore::Internals::setShowAllPlugins):
1841         (WebCore::Internals::cloneArrayBuffer): Deleted.
1842         * testing/Internals.h:
1843         * testing/Internals.idl:
1844
1845 2017-03-31  Zalan Bujtas  <zalan@apple.com>
1846
1847         <table>: Including <caption>, <thead> or <tbody> causes clipping across page breaks
1848         https://bugs.webkit.org/show_bug.cgi?id=170348
1849         <rdar://problem/24727151>
1850
1851         Reviewed by David Hyatt.
1852
1853         1. In RenderFlowThread::offsetFromLogicalTopOfFirstRegion() we need to take table section offset into account (they are skipped
1854         during the containing block traversal).
1855         2. Trigger paginated relayout when body is moved vertically due to caption/thead etc.
1856
1857         Test: fast/multicol/table-section-page-break.html
1858
1859         * rendering/RenderFlowThread.cpp:
1860         (WebCore::RenderFlowThread::offsetFromLogicalTopOfFirstRegion):
1861         * rendering/RenderTable.cpp:
1862         (WebCore::RenderTable::layout):
1863
1864 2017-03-31  Simon Fraser  <simon.fraser@apple.com>
1865
1866         Rename DOMWindow's m_touchEventListenerCount to m_touchAndGestureEventListenerCount
1867         https://bugs.webkit.org/show_bug.cgi?id=170371
1868
1869         Reviewed by Tim Horton.
1870
1871         This count tracks touch and gesture event listeners, so name it appropriately.
1872
1873         * page/DOMWindow.cpp:
1874         (WebCore::DOMWindow::addEventListener):
1875         (WebCore::DOMWindow::removeEventListener):
1876         (WebCore::DOMWindow::removeAllEventListeners):
1877         * page/DOMWindow.h:
1878
1879 2017-03-31  Simon Fraser  <simon.fraser@apple.com>
1880
1881         When destroying a Node, assert that it's been removed from all the touch handler maps
1882         https://bugs.webkit.org/show_bug.cgi?id=170363
1883         rdar://problem/31377469
1884
1885         Reviewed by Tim Horton.
1886
1887         Assert that the Node has been removed from the touch handler maps in all documents on destruction.
1888
1889         * dom/Document.h:
1890         (WebCore::Document::hasTouchEventHandlers):
1891         (WebCore::Document::touchEventTargetsContain):
1892         * dom/Node.cpp:
1893         (WebCore::Node::~Node):
1894
1895 2017-03-31  Alexey Proskuryakov  <ap@apple.com>
1896
1897         Rolling back https://trac.webkit.org/r214689, as it caused many crashes.
1898
1899         Was:
1900         Fix memory leak in CreateSessionDescriptionObserver::OnSuccess
1901         https://bugs.webkit.org/show_bug.cgi?id=170357
1902
1903         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
1904         (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionSucceeded):
1905
1906 2017-03-31  Youenn Fablet  <youenn@apple.com>
1907
1908         Fix memory leak in RealtimeVideoIncomingSource
1909         https://bugs.webkit.org/show_bug.cgi?id=170356
1910
1911         Reviewed by Eric Carlson.
1912
1913         No change of behavior.
1914
1915         * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
1916         (WebCore::RealtimeIncomingVideoSource::OnFrame): Adopting the newly created pointer.
1917
1918 2017-03-31  Andy Estes  <aestes@apple.com>
1919
1920         REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
1921         https://bugs.webkit.org/show_bug.cgi?id=170365
1922         <rdar://problem/29205721>
1923
1924         Reviewed by Tim Horton.
1925
1926         r202472 changed the node traversal in searchForLinkRemovingExistingDDLinks() to only
1927         consider nodes that are descendants of startNode, but we need to traverse all nodes between
1928         startNode and endNode to find existing non-DD links.
1929
1930         As a result, we'd add a Data Detector link to the following snippet and make the original
1931         links un-clickable:
1932
1933             <a href='#'>tomorrow</a> <a href='#'>night</a>
1934
1935         Fix this by not specifying a stayWithin node when calling NodeTraversal::next(). The loop
1936         will terminate when we reach endNode.
1937
1938         Updated WebKit2.DataDetectionReferenceDate API test.
1939
1940         * editing/cocoa/DataDetection.mm:
1941         (WebCore::searchForLinkRemovingExistingDDLinks):
1942
1943 2017-03-31  Eric Carlson  <eric.carlson@apple.com>
1944
1945         Incoming video source doesn't propogate frame rotation
1946         https://bugs.webkit.org/show_bug.cgi?id=170364
1947
1948         Reviewed by Youenn Fablet.
1949
1950         No new tests, the mock video source doesn't support rotation. Test will be added when
1951         this is fixed in https://bugs.webkit.org/show_bug.cgi?id=169822. The changes were 
1952         verified manually.
1953
1954         * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
1955         (WebCore::RealtimeIncomingVideoSource::OnFrame): Convert frame rotation to sample
1956         orientation and swap width and height when necessary.
1957         (WebCore::RealtimeIncomingVideoSource::processNewSample):
1958         * platform/mediastream/mac/RealtimeIncomingVideoSource.h:
1959
1960 2017-03-31  Chris Dumez  <cdumez@apple.com>
1961
1962         Possible null dereference under SourceBuffer::sourceBufferPrivateDidReceiveSample()
1963         https://bugs.webkit.org/show_bug.cgi?id=159639
1964
1965         Reviewed by Eric Carlson.
1966
1967         Add a null check for trackBuffer.description before dereferencing as it seems
1968         it can be null.
1969
1970         * Modules/mediasource/SourceBuffer.cpp:
1971         (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
1972
1973 2017-03-31  Youenn Fablet  <youenn@apple.com>
1974
1975         Fix memory leak in CreateSessionDescriptionObserver::OnSuccess
1976         https://bugs.webkit.org/show_bug.cgi?id=170357
1977
1978         Reviewed by Geoffrey Garen.
1979
1980         No change of behavior.
1981
1982         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
1983         (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionSucceeded): Adopting the raw pointer parameter.
1984
1985 2017-03-31  Fujii Hironori  <Hironori.Fujii@sony.com>
1986
1987         [WinCairo] WebCore::PlatformDisplay::terminateEGLDisplay causes a crash in libGLESv2.dll while processing atexit
1988         https://bugs.webkit.org/show_bug.cgi?id=170331
1989
1990         Reviewed by Michael Catanzaro.
1991
1992         WebCore::PlatformDisplay uses atexit to destruct EGL displays
1993         while exiting process. But, when the atexit will be processed,
1994         heap of libGLESv2.dll would be already destructed and causing a
1995         crash on Windows. Do not use atexit for Windows.
1996
1997         AppleWin port does not use PlatformDisplay. Thus, it does not have
1998         this bug.
1999
2000         * platform/graphics/PlatformDisplay.cpp:
2001         (WebCore::PlatformDisplay::initializeEGLDisplay): Do not use atexit for Windows.
2002         (WebCore::PlatformDisplay::shutDownEglDisplays): Added.
2003         * platform/graphics/PlatformDisplay.h: Added a declaration of shutDownEglDisplays.
2004
2005 2017-03-31  Yoav Weiss  <yoav@yoav.ws>
2006
2007         Remove PRELOAD_DEBUG related code.
2008         https://bugs.webkit.org/show_bug.cgi?id=170352
2009
2010         Reviewed by Youenn Fablet.
2011
2012         As the PRELOAD_DEBUG related code stopped building and it seems like no one noticed,
2013         it seems safe to assume that we can remove that code. This patch removes it.
2014
2015         No new tests as there's no functional change.
2016
2017         * loader/cache/CachedResourceLoader.cpp:
2018         (WebCore::CachedResourceLoader::preload):
2019         (WebCore::CachedResourceLoader::clearPreloads):
2020         (WebCore::CachedResourceLoader::printPreloadStats): Deleted.
2021
2022 2017-03-31  Brady Eidson  <beidson@apple.com>
2023
2024         Clean up the "StorageType" enum.
2025         https://bugs.webkit.org/show_bug.cgi?id=170349
2026
2027         Reviewed by Tim Horton.
2028
2029         - Make this `enum` into an `enum class`
2030         - Add a new type specific for "transient local storage"
2031
2032         No new tests (No behavior change).
2033
2034         * WebCore.xcodeproj/project.pbxproj:
2035         
2036         * inspector/InspectorDOMStorageAgent.cpp:
2037         (WebCore::InspectorDOMStorageAgent::didDispatchDOMStorageEvent):
2038         
2039         * inspector/InspectorInstrumentation.h:
2040         
2041         * loader/EmptyClients.cpp:
2042         
2043         * storage/Storage.cpp:
2044         (WebCore::Storage::isDisabledByPrivateBrowsing):
2045         
2046         * storage/StorageArea.h:
2047         (): Deleted.
2048         
2049         * storage/StorageEventDispatcher.cpp:
2050         (WebCore::StorageEventDispatcher::dispatchSessionStorageEventsToFrames):
2051         (WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames):
2052         
2053         * storage/StorageType.h:
2054         (WebCore::isLocalStorage):
2055
2056 2017-03-31  Chris Dumez  <cdumez@apple.com>
2057
2058         Unreviewed, Mark "HTML interactive form validation" as done.
2059
2060         It is shipping in Safari 10.1.
2061  
2062         * features.json:
2063
2064 2017-03-31  Csaba Osztrogonác  <ossy@webkit.org>
2065
2066         Mac cmake buildfix after r214666
2067         https://bugs.webkit.org/show_bug.cgi?id=170342
2068
2069         Unreviewed buildfix.
2070
2071         * PlatformMac.cmake:
2072         * testing/MockPreviewLoaderClient.h:
2073
2074 2017-03-31  Sam Weinig  <sam@webkit.org>
2075
2076         Remove unneeded custom constructors include.
2077
2078         * WebCore.xcodeproj/project.pbxproj:
2079         * bindings/js/ios: Removed.
2080         * bindings/js/ios/TouchConstructors.cpp: Removed.
2081
2082 2017-03-31  John Wilander  <wilander@apple.com>
2083
2084         Resource Load Statistics: Check if the store exists before clearing it
2085         https://bugs.webkit.org/show_bug.cgi?id=170324
2086         <rdar://problem/31258505>
2087
2088         Reviewed by Brent Fulgham.
2089
2090         No new tests. Added a null check.
2091
2092         * loader/ResourceLoadObserver.cpp:
2093         (WebCore::ResourceLoadObserver::clearInMemoryAndPersistentStore):
2094             Added a null check.
2095
2096 2017-03-31  Romain Bellessort  <romain.bellessort@crf.canon.fr>
2097
2098         [Readable Streams API] Implement cloneArrayBuffer in WebCore
2099         https://bugs.webkit.org/show_bug.cgi?id=170008
2100
2101         Reviewed by Youenn Fablet.
2102
2103         Implemented cloneArrayBuffer based on existing structuredCloneArrayBuffer
2104         implementation. The code has been factorized so that both cloneArrayBuffer
2105         and structuredCloneArrayBuffer rely on the same code (which is basically
2106         the previous implementation of structuredCloneArrayBuffer + the ability
2107         to clone only a part of considered buffer).
2108
2109         Added test to check cloneArrayBuffer behaviour.
2110
2111         * Modules/streams/ReadableByteStreamInternals.js: Deleted cloneArrayBuffer JS implementation.
2112         * bindings/js/JSDOMGlobalObject.cpp:
2113         (WebCore::JSDOMGlobalObject::addBuiltinGlobals): Add cloneArrayBuffer private declaration.
2114         * bindings/js/StructuredClone.cpp:
2115         (WebCore::cloneArrayBufferImpl): Added (mostly based on previous structuredCloneArrayBuffer).
2116         (WebCore::cloneArrayBuffer): Added.
2117         (WebCore::structuredCloneArrayBuffer): Updated.
2118         * bindings/js/StructuredClone.h: Added cloneArrayBuffer declaration.
2119         * bindings/js/WebCoreBuiltinNames.h: Added cloneArrayBuffer declaration.
2120         * testing/Internals.cpp: Added support for testing cloneArrayBuffer.
2121         * testing/Internals.h: Added support for testing cloneArrayBuffer.
2122         * testing/Internals.idl: Added support for testing cloneArrayBuffer.
2123
2124 2017-03-31  Antoine Quint  <graouts@apple.com>
2125
2126         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
2127         https://bugs.webkit.org/show_bug.cgi?id=168409
2128         <rdar://problem/30799198>
2129
2130         Unreviewed. Yet more logging to determine under what circumstance ScriptedAnimationController gets suspended.
2131
2132         * dom/Document.cpp:
2133         (WebCore::Document::requestAnimationFrame):
2134
2135 2017-03-30  Zan Dobersek  <zdobersek@igalia.com>
2136
2137         Unreviewed GTK+ build fix. Add missing ANGLE build targets
2138         to the build.
2139
2140         * CMakeLists.txt:
2141
2142 2017-03-30  Simon Fraser  <simon.fraser@apple.com>
2143
2144         Ensure that Node::willBeDeletedFrom() always removes touch event handlers from the document
2145         https://bugs.webkit.org/show_bug.cgi?id=170323
2146         rdar://problem/23647630
2147
2148         Reviewed by Chris Dumez.
2149
2150         There are two instances where nodes are registered as touch event handlers without
2151         having normal touch event listeners: slider thumb elements, and elements with overflow scrolling,
2152         on iOS.
2153
2154         For such nodes, hasEventTargetData() will be false, but we want to ensure
2155         that they are removed from the Document's touchEventHandler set, so move the
2156         call to document.removeTouchEventHandler() outside of the conditional block.
2157
2158         This should be cheap in most cases when the touchEventHandler is empty.
2159
2160         * dom/Node.cpp:
2161         (WebCore::Node::willBeDeletedFrom):
2162
2163 2017-03-30  Simon Fraser  <simon.fraser@apple.com>
2164
2165         Minor cleanup checking for gesture event names
2166         https://bugs.webkit.org/show_bug.cgi?id=170319
2167
2168         Reviewed by Tim Horton.
2169
2170         Just use isGestureEventType() in a couple of places.
2171
2172         * dom/Node.cpp:
2173         (WebCore::tryAddEventListener):
2174         (WebCore::tryRemoveEventListener):
2175
2176 2017-03-30  Simon Fraser  <simon.fraser@apple.com>
2177
2178         Rename a touch event function, and new touch region test results
2179         https://bugs.webkit.org/show_bug.cgi?id=170309
2180         rdar://problem/31329520
2181
2182         Reviewed by Chris Dumez.
2183
2184         Adapt to a naming change in WebKitAdditions.
2185
2186         * dom/Document.cpp:
2187         (WebCore::Document::removeAllEventListeners):
2188         * page/FrameView.cpp:
2189         (WebCore::FrameView::layout):
2190         * rendering/RenderElement.cpp:
2191         (WebCore::RenderElement::styleWillChange):
2192         * rendering/RenderLayer.cpp:
2193         (WebCore::RenderLayer::scrollTo):
2194         (WebCore::RenderLayer::calculateClipRects):
2195
2196 2017-03-30  Matt Rajca  <mrajca@apple.com>
2197
2198         YouTube sometimes does not respect "user gesture" restriction for videos.
2199         https://bugs.webkit.org/show_bug.cgi?id=170297
2200
2201         I discovered a code path that does not honor the "user gesture" requirement and playback is able to begin
2202         even though we have a restriction in place. When using Media Source Extensions, which YouTube does, we transition
2203         from a "Have Metadata" to a "Future Data" state that causes playback to begin, however, we never check
2204         if we have a playback restriction in place.
2205
2206         Reviewed by Eric Carlson.
2207
2208         * html/HTMLMediaElement.cpp:
2209         (WebCore::HTMLMediaElement::setReadyState):
2210
2211 2017-03-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
2212
2213         REGRESSION (r213764): Background image from sprite sheet incorrectly scaled
2214         https://bugs.webkit.org/show_bug.cgi?id=169547
2215
2216         Reviewed by Simon Fraser.
2217
2218         The bug happens when drawing only a rectangle of an image not the whole
2219         image. In BitmapImage::draw(), sizeForDrawing was calculated as the destRect
2220         scaled by the transformation which is applied to the GraphicsContext. Two
2221         problems with this approach. The first one is destRect can be only part of
2222         the image. The second problem is, the ratio destRect / srcRect is another
2223         scaling that needs to be considered.
2224
2225         To fix this issue, first the base size has to be size of the image and not
2226         destRect.size(). Secondly, we need to scale this base size with the context
2227         transformation multiplied by the ratio destRect / srcRect. This scaling is
2228         exactly the same scaling which is calculated in subsamplingScale(). Finally
2229         we use this scaled size as the sizeForDrawing to send to the ImageDecoder.
2230
2231         Test: fast/images/sprite-sheet-image-draw.html
2232
2233         * platform/graphics/BitmapImage.cpp:
2234         (WebCore::BitmapImage::draw): Fix the bug.
2235         (WebCore::BitmapImage::stopAnimation): Stops the async image decoding for animated images only.
2236         The decoding for large images will be stopped when BitmapImage::newFrameNativeImageAvailableAtIndex()
2237         is called and the decoding queue is idle.
2238         (WebCore::BitmapImage::newFrameNativeImageAvailableAtIndex): Add image logging.
2239         * platform/graphics/BitmapImage.h: Move sourceURL() to the Image class.
2240         * platform/graphics/GraphicsContext.cpp: Pass imagePaintingOptions.m_decodingMode to Image::drawTiled().
2241         (WebCore::GraphicsContext::drawTiledImage): Pass imagePaintingOptions.m_decodingMode) to Image::drawTiled().
2242         * platform/graphics/Image.cpp:
2243         (WebCore::Image::sourceURL): Moved from BitmapImage.
2244         (WebCore::Image::drawTiled): Add a DecodingMode argument instead of calling always with DecodingMode::Synchronous.
2245         * platform/graphics/Image.h:
2246         * platform/graphics/ImageFrameCache.cpp:
2247         (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex): Add image logging.
2248         (WebCore::ImageFrameCache::startAsyncDecodingQueue): Ditto,
2249         (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Ditto.
2250         (WebCore::ImageFrameCache::stopAsyncDecodingQueue): Ditto.
2251         (WebCore::ImageFrameCache::sourceURL): A helper function to avoid checking the value of m_image.
2252         * platform/graphics/ImageFrameCache.h:
2253         * platform/graphics/NativeImage.h: Rename subsamplingScale() to nativeImageDrawingScale() and return image scaling instead.
2254         * platform/graphics/cairo/NativeImageCairo.cpp:
2255         (WebCore::nativeImageDrawingScale): Ditto.
2256         (WebCore::subsamplingScale): Deleted.
2257         * platform/graphics/cg/NativeImageCG.cpp:
2258         (WebCore::nativeImageDrawingScale): Ditto.
2259         (WebCore::subsamplingScale): Deleted.
2260         * platform/graphics/win/NativeImageDirect2D.cpp:
2261         (WebCore::nativeImageDrawingScale): Ditto.
2262         (WebCore::subsamplingScale): Deleted.
2263
2264 2017-03-30  Matt Baker  <mattbaker@apple.com>
2265
2266         Web Inspector: Assertion failure in InspectorStyleProperty::setRawTextFromStyleDeclaration
2267         https://bugs.webkit.org/show_bug.cgi?id=170279
2268         <rdar://problem/30200492>
2269
2270         Reviewed by David Hyatt.
2271
2272         The SourceRange for a CSSPropertySourceData should be relative to the start
2273         of the declaration body, not the start of the StyleSheetHandler’s parsed
2274         text. This only affected the ranges of unparsed (parsedOK == false) properties
2275         lacking a trailing semi-colon.
2276
2277         This patch doesn't change the behavior of InspectorStyleSheet other than
2278         silencing an irksome assert, as String::substring does a safety check on
2279         the passed in length.
2280
2281         * inspector/InspectorStyleSheet.cpp:
2282         (WebCore::fixUnparsedProperties):
2283
2284 2017-03-30  Youenn Fablet  <youenn@apple.com> and Jon Lee <jonlee@apple.com>
2285
2286         Clean up RTCDataChannel
2287         https://bugs.webkit.org/show_bug.cgi?id=169732
2288
2289         Reviewed by Chris Dumez.
2290
2291         Test: webrtc/datachannel/datachannel-event.html
2292               webrtc/datachannel/bufferedAmountLowThreshold.html
2293
2294         Making RTCDataChannel interface closer to the spec updating implementation accordingly.
2295         See https://w3c.github.io/webrtc-pc/#rtcdatachannel.
2296         In particular adding RTCDataChannelEvent constructor, and missing bufferedAmount related attributes.
2297         Doing some additional cleaning refactoring.
2298
2299         Making bufferedAmountIsDecreasing take a bufferedAmount argument so that we get the actual value passed by
2300         libwebrtc without needing to get it from the libwebrtc network thread again.
2301         In the future, we should store the bufferedAmount value in RTCDataChannel and update its value on each libwebrtc
2302         OnBufferedAmountChange. Special treatment may be needed when the data channel is closed, in which case the bufferedAmount should just be
2303         updated to increase in the send method.
2304
2305         Added some FIXMEs as RTCDataChannel is not aligned with the spec related to send and bufferedAmount.
2306
2307         * Modules/mediastream/RTCDataChannel.cpp:
2308         (WebCore::RTCDataChannel::send):
2309         (WebCore::RTCDataChannel::close):
2310         (WebCore::RTCDataChannel::didChangeReadyState):
2311         (WebCore::RTCDataChannel::bufferedAmountIsDecreasing):
2312         * Modules/mediastream/RTCDataChannel.h:
2313         * Modules/mediastream/RTCDataChannel.idl:
2314         * Modules/mediastream/RTCDataChannelEvent.cpp:
2315         (WebCore::RTCDataChannelEvent::create):
2316         (WebCore::RTCDataChannelEvent::RTCDataChannelEvent):
2317         (WebCore::RTCDataChannelEvent::channel):
2318         * Modules/mediastream/RTCDataChannelEvent.h:
2319         * Modules/mediastream/RTCDataChannelEvent.idl:
2320         * Modules/mediastream/RTCPeerConnection.idl:
2321         * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
2322         (WebCore::LibWebRTCDataChannelHandler::OnStateChange):
2323         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
2324         (WebCore::LibWebRTCMediaEndpoint::addDataChannel):
2325         * WebCore.xcodeproj/project.pbxproj:
2326         * dom/EventNames.h:
2327         * platform/mediastream/RTCDataChannelHandler.h:
2328         * platform/mediastream/RTCDataChannelHandlerClient.h:
2329         * platform/mediastream/RTCDataChannelState.h: Added.
2330         * platform/mediastream/RTCPeerConnectionHandlerClient.h:
2331         * platform/mock/RTCDataChannelHandlerMock.cpp:
2332         (WebCore::RTCDataChannelHandlerMock::setClient):
2333         (WebCore::RTCDataChannelHandlerMock::close):
2334         * platform/mock/RTCNotifiersMock.cpp:
2335         (WebCore::IceConnectionNotifier::IceConnectionNotifier):
2336         (WebCore::SignalingStateNotifier::SignalingStateNotifier):
2337         (WebCore::DataChannelStateNotifier::DataChannelStateNotifier):
2338         * platform/mock/RTCNotifiersMock.h:
2339
2340 2017-03-30  Javier Fernandez  <jfernandez@igalia.com>
2341
2342         [css-align] Adapt content-alignment properties to the new baseline syntax
2343         https://bugs.webkit.org/show_bug.cgi?id=170262
2344
2345         Reviewed by David Hyatt.
2346
2347         The baseline-position syntax has changed recently, so we need to update
2348         the CSS properties using the old syntax. This patch address only the
2349         content-alignment (align-content and justify-content).
2350
2351         I used this patch to adapt the implementation of the parsing logic for
2352         these properties to the new Blink's CSS Parsing Design.
2353
2354         The new baseline syntax is "[first | last ]? baseline" which implies
2355         modifying the parsing and computed value logic.
2356
2357         There are several layout tests affected by this change, so I'll update
2358         them accordingly.
2359
2360         No new tests, just added/modified some cases to the tests we
2361         already have using the new baseline values.
2362
2363         * css/CSSComputedStyleDeclaration.cpp:
2364         (WebCore::valueForContentPositionAndDistributionWithOverflowAlignment):
2365         * css/CSSContentDistributionValue.cpp:
2366         (WebCore::CSSContentDistributionValue::customCSSText):
2367         * css/CSSPrimitiveValueMappings.h:
2368         (WebCore::CSSPrimitiveValue::operator ItemPosition):
2369         (WebCore::CSSPrimitiveValue::operator ContentPosition):
2370         * css/CSSValueKeywords.in:
2371         * css/parser/CSSPropertyParser.cpp:
2372         (WebCore::isBaselineKeyword):
2373         (WebCore::consumeBaselineKeyword):
2374         (WebCore::consumeContentDistributionOverflowPosition):
2375         (WebCore::consumeSelfPositionOverflowPosition):
2376
2377 2017-03-30  James Craig  <jcraig@apple.com>
2378
2379         AX: Expose a new AXSubrole for explicit ARIA "group" role
2380         https://bugs.webkit.org/show_bug.cgi?id=169810
2381         <rdar://problem/31039693>
2382
2383         Reviewed by Chris Fleizach.
2384
2385         Split GroupRole into generics (GroupRole) and explicit groups 
2386         (ApplicationGroupRole) so we can expose a subrole on the explicit 
2387         groups. Account for the change in ARIA Tree and Menu hierachies. 
2388         Update the computedRoleValue for WebKit Inspector usage, too.
2389
2390         Updated existing tests.
2391
2392         Test: accessibility/list-detection2.html:
2393         Test: accessibility/roles-computedRoleString.html:
2394         Test: inspector/dom/getAccessibilityPropertiesForNode.html:
2395         Test: inspector/dom/highlightFrame.html:
2396         Test: inspector/dom/highlightSelector.html:
2397
2398         * accessibility/AccessibilityNodeObject.cpp:
2399         (WebCore::AccessibilityNodeObject::helpText):
2400         (WebCore::AccessibilityNodeObject::hierarchicalLevel):
2401         (WebCore::AccessibilityNodeObject::remapAriaRoleDueToParent):
2402         * accessibility/AccessibilityObject.cpp:
2403         (WebCore::AccessibilityObject::accessibleNameDerivesFromContent):
2404         (WebCore::AccessibilityObject::ariaTreeItemContent):
2405         (WebCore::initializeRoleMap):
2406         (WebCore::AccessibilityObject::computedRoleString):
2407         * accessibility/AccessibilityObject.h:
2408         * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
2409         (atkRole):
2410         * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
2411         (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
2412         * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
2413         (createAccessibilityRoleMap):
2414         (-[WebAccessibilityObjectWrapper subrole]):
2415
2416 2017-03-30  Chris Dumez  <cdumez@apple.com>
2417
2418         We are spending a lot of time bzero'ing AudioChannel buffers on uni-watch.com
2419         https://bugs.webkit.org/show_bug.cgi?id=170288
2420         <rdar://problem/31289132>
2421
2422         Reviewed by Eric Carlson.
2423
2424         We are spending a lot of time bzero'ing AudioChannel buffers on uni-watch.com due
2425         to doubleclick ads using WebAudio with a 0-gain GainNode. We should optimize the
2426         0-gain case as much as possible.
2427
2428         No new tests, only an optimization.
2429
2430         * Modules/webaudio/AudioNode.cpp:
2431         (WebCore::AudioNode::processIfNecessary):
2432         Drop call to unsilenceOutputs() before calling AudioNode::process(). The AudioChannel
2433         API already takes care of clearing its 'silent' flag whenever its buffer changes so
2434         there should be no need to explicitly clearing the 'silent' flag before calling
2435         process(). This was causing us to zero out buffers that were already filled with
2436         zeros because AudioChannel::zero() would no longer return early, not knowing the
2437         channel is already silent. This reduces the number of bzero() calls by ~3.5x on
2438         uni-watch.com (from 100 calls every ~20ms to 100 calls every ~70ms.
2439
2440         * Modules/webaudio/AudioNode.h:
2441         * platform/audio/mac/AudioDestinationMac.cpp:
2442         (WebCore::AudioDestinationMac::render):
2443         Avoid clamping the values in the channel buffer if the channel is silent since this
2444         will have no effect (given that the buffer only contains zeros).
2445
2446 2017-03-30  Eric Carlson  <eric.carlson@apple.com>
2447
2448         [Crash] WebCore::AudioBuffer::AudioBuffer don't checking illegal value
2449         https://bugs.webkit.org/show_bug.cgi?id=169956
2450
2451         Reviewed by Youenn Fablet.
2452
2453         Test: webaudio/audiobuffer-crash.html
2454
2455         * Modules/webaudio/AudioBuffer.cpp:
2456         (WebCore::AudioBuffer::AudioBuffer): Invalidate the object and return early if the channel 
2457         array allocation fails.
2458         (WebCore::AudioBuffer::AudioBuffer): Ditto.
2459         (WebCore::AudioBuffer::invalidate): Invalidate the object.
2460         * Modules/webaudio/AudioBuffer.h:
2461
2462 2017-03-30  Antoine Quint  <graouts@apple.com>
2463
2464         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
2465         https://bugs.webkit.org/show_bug.cgi?id=168409
2466         <rdar://problem/30799198>
2467
2468         Unreview. Print the backtrace when we suspend scripted animations.
2469
2470         * page/Page.cpp:
2471         (WebCore::Page::suspendScriptedAnimations):
2472
2473 2017-03-30  Antoine Quint  <graouts@apple.com>
2474
2475         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
2476         https://bugs.webkit.org/show_bug.cgi?id=168409
2477         <rdar://problem/30799198>
2478
2479         Unreview. Pring the backtrace when we suspend ScriptedAnimationController.
2480
2481         * dom/ScriptedAnimationController.cpp:
2482         (WebCore::ScriptedAnimationController::suspend):
2483
2484 2017-03-30  Antoine Quint  <graouts@apple.com>
2485
2486         [Modern Media Controls] Invalid placard icon is not visible for short video
2487         https://bugs.webkit.org/show_bug.cgi?id=170277
2488         <rdar://problem/31327955>
2489
2490         Reviewed by Eric Carlson.
2491
2492         Make the minimum dimension needed to display a placard icon configurable and let the
2493         invalid placard use a 50pt dimension. We also make a drive-by fix to reset "text-align"
2494         for media controls as having a "text-align: center" inherited value would mess up
2495         positioning of the placard icon and make it flush to the right of the placard.
2496
2497         Test: media/modern-media-controls/invalid-placard/invalid-placard-constrained-metrics.html
2498
2499         * Modules/modern-media-controls/controls/invalid-placard.js:
2500         (InvalidPlacard):
2501         * Modules/modern-media-controls/controls/media-controls.css:
2502         (.media-controls):
2503         * Modules/modern-media-controls/controls/placard.js:
2504         (Placard.prototype.layout):
2505
2506 2017-03-30  Zan Dobersek  <zdobersek@igalia.com>
2507
2508         [GCrypt] Register missing algorithms in CryptoAlgorithmRegistry::platformRegisterAlgoritmhs()
2509         https://bugs.webkit.org/show_bug.cgi?id=170273
2510
2511         Reviewed by Michael Catanzaro.
2512
2513         * crypto/gcrypt/CryptoAlgorithmRegistryGCrypt.cpp:
2514         (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
2515         Add registerAlgorithm<> calls for AES_CFB, AES_GCM, ECDH and
2516         PBKDF2 algorithms.
2517
2518 2017-03-30  Brent Fulgham  <bfulgham@apple.com>
2519
2520         Remove unused MediaControlsApple implementation
2521         https://bugs.webkit.org/show_bug.cgi?id=170258
2522         <rdar://problem/31331056>
2523
2524         Reviewed by Eric Carlson.
2525
2526         Remove dead code related to old media controls. We switched to HTML5-based media controls
2527         several years ago.
2528
2529         No new tests. Removing this dead code should have no change in behavior.
2530
2531         * WebCore.xcodeproj/project.pbxproj: Remove unused files.
2532         * dom/EventListener.h: Remove unused event type.
2533         * html/shadow/MediaControlsApple.cpp: Removed.
2534         * html/shadow/MediaControlsApple.h: Removed.
2535
2536 2017-03-30  Fujii Hironori  <Hironori.Fujii@sony.com>
2537
2538         [WinCairo] ImageCairoWin.cpp: error C2660: 'WebCore::BitmapImage::draw': function does not take 6 arguments
2539         https://bugs.webkit.org/show_bug.cgi?id=170275
2540
2541         Reviewed by Said Abou-Hallawa.
2542
2543         Apply the similar change of ImageCGWin.cpp of r214450 to ImageCairoWin.cpp.
2544
2545         * platform/graphics/win/ImageCairoWin.cpp:
2546         (WebCore::BitmapImage::getHBITMAPOfSize): Pass DecodingMode::Synchronous to Image::draw().
2547         (WebCore::BitmapImage::drawFrameMatchingSourceSize): Ditto.
2548
2549 2017-03-27  Sergio Villar Senin  <svillar@igalia.com>
2550
2551         [css-grid] Clamp the number of autorepeat tracks
2552         https://bugs.webkit.org/show_bug.cgi?id=170120
2553
2554         Reviewed by Manuel Rego Casasnovas.
2555
2556         As suggested by the specs we do clamp the maximum number of tracks per grid in order to
2557         minimize potential OOM situations. However we were not considering the case of the recently
2558         added auto repeat syntax. Abnormally huge values for the width/height on the grid container
2559         could lead to a number of auto repeat tracks higher than the maximum.
2560
2561         A new API was added to Internals in order to test limits without having to create huge
2562         grids. This new API allows clients to set an arbitrary limit to the number of tracks. The
2563         addition of this new API forced us to add GridPosition.cpp to the project to define the
2564         global variable we use for testing. We took the chance to move part of the implementation
2565         from the header file to the source file.
2566
2567         Last but not least, several new ASSERTs were added to Grid.cpp implementation to ensure that
2568         we do not surpass the grid track limits.
2569
2570         Test: fast/css-grid-layout/grid-auto-repeat-huge-grid.html
2571
2572         * CMakeLists.txt:
2573         * WebCore.xcodeproj/project.pbxproj:
2574         * css/parser/CSSPropertyParser.cpp:
2575         (WebCore::consumeGridTrackRepeatFunction):
2576         * rendering/Grid.cpp:
2577         (WebCore::Grid::ensureGridSize): Added ASSERT.
2578         (WebCore::Grid::setSmallestTracksStart): Ditto.
2579         (WebCore::Grid::setAutoRepeatTracks): Ditto.
2580         (WebCore::Grid::setAutoRepeatEmptyColumns): Ditto.
2581         (WebCore::Grid::setAutoRepeatEmptyRows): Ditto.
2582         * rendering/RenderGrid.cpp:
2583         (WebCore::RenderGrid::clampAutoRepeatTracks): New method.
2584         (WebCore::RenderGrid::placeItemsOnGrid): Clamp the number of auto repeat tracks before
2585         passing them to the Grid.
2586         * rendering/RenderGrid.h:
2587         * rendering/style/GridArea.h:
2588         (WebCore::GridSpan::GridSpan):
2589         * rendering/style/GridPosition.cpp: Added.
2590         (WebCore::GridPosition::setExplicitPosition):
2591         (WebCore::GridPosition::setAutoPosition):
2592         (WebCore::GridPosition::setSpanPosition):
2593         (WebCore::GridPosition::setNamedGridArea):
2594         (WebCore::GridPosition::integerPosition):
2595         (WebCore::GridPosition::namedGridLine):
2596         (WebCore::GridPosition::spanPosition):
2597         (WebCore::GridPosition::operator==):
2598         * rendering/style/GridPosition.h:
2599         (WebCore::GridPosition::shouldBeResolvedAgainstOppositePosition):
2600         (WebCore::GridPosition::max):
2601         (WebCore::GridPosition::min):
2602         (WebCore::GridPosition::setMaxPositionForTesting):
2603         (WebCore::GridPosition::setExplicitPosition): Deleted.
2604         (WebCore::GridPosition::setAutoPosition): Deleted.
2605         (WebCore::GridPosition::setSpanPosition): Deleted.
2606         (WebCore::GridPosition::setNamedGridArea): Deleted.
2607         (WebCore::GridPosition::integerPosition): Deleted.
2608         (WebCore::GridPosition::namedGridLine): Deleted.
2609         (WebCore::GridPosition::spanPosition): Deleted.
2610         (WebCore::GridPosition::operator==): Deleted.
2611         * rendering/style/GridPositionsResolver.cpp:
2612         (WebCore::GridPositionsResolver::explicitGridColumnCount):
2613         (WebCore::GridPositionsResolver::explicitGridRowCount):
2614         * testing/Internals.cpp:
2615         (WebCore::Internals::setGridMaxTracksLimit):
2616         * testing/Internals.h:
2617         * testing/Internals.idl:
2618
2619 2017-03-29  Ryosuke Niwa  <rniwa@webkit.org>
2620
2621         Disconnecting a HTMLObjectElement does not always unload its content document
2622         https://bugs.webkit.org/show_bug.cgi?id=169606
2623
2624         Reviewed by Andy Estes.
2625
2626         When removing a node, we first disconnect all subframes then update the focused element as we remove each child.
2627         However, when the removed element is a focused object element with a content document, removeFocusedNodeOfSubtree
2628         can update the style tree synchronously inside Document::setFocusedElement, and reload the document.
2629
2630         Avoid this by instantiating a SubframeLoadingDisabler on the parent of the focused element.
2631
2632         Test: fast/dom/removing-focused-object-element.html
2633
2634         * dom/Document.cpp:
2635         (WebCore::Document::removeFocusedNodeOfSubtree):
2636
2637 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
2638
2639         Migrate to kCTFontCSSWidthAttribute
2640         https://bugs.webkit.org/show_bug.cgi?id=170265
2641
2642         Reviewed by Darin Adler.
2643
2644         Previously, we were mapping from Core Text widths to CSS widths in WebKit.
2645         However, on some OSes, Core Text can directly tell us what the CSS width
2646         value is.
2647
2648         No new tests because there is no behavior change.
2649
2650         * platform/graphics/cocoa/FontCacheCoreText.cpp:
2651         (WebCore::getCSSAttribute):
2652         (WebCore::capabilitiesForFontDescriptor):
2653         * platform/spi/cocoa/CoreTextSPI.h:
2654
2655 2017-03-28  Simon Fraser  <simon.fraser@apple.com>
2656
2657         Make it possible to dump touch event regions for testing
2658         https://bugs.webkit.org/show_bug.cgi?id=170209
2659         <rdar://problem/31309258>
2660
2661         Reviewed by Tim Horton.
2662
2663         Expose internals.touchEventRectsForEvent() and internals.passiveTouchEventListenerRects(), which
2664         fetch data via Page.
2665
2666         Because the regions are normally updated on a timer, we have to force an eager update via Document::updateTouchEventRegions().
2667
2668         Test: fast/events/touch/ios/touch-event-regions.html
2669
2670         * page/Page.cpp:
2671         (WebCore::Page::nonFastScrollableRects):
2672         (WebCore::Page::touchEventRectsForEvent):
2673         (WebCore::Page::passiveTouchEventListenerRects):
2674         * page/Page.h:
2675         * testing/Internals.cpp:
2676         (WebCore::Internals::touchEventRectsForEvent):
2677         (WebCore::Internals::passiveTouchEventListenerRects):
2678         * testing/Internals.h:
2679         * testing/Internals.idl:
2680
2681 2017-03-29  Zalan Bujtas  <zalan@apple.com>
2682
2683         RenderBlockFlow::addFloatsToNewParent should check if float is already added to the object list.
2684         https://bugs.webkit.org/show_bug.cgi?id=170259
2685         <rdar://problem/31300584>
2686
2687         Reviewed by Simon Fraser.
2688
2689         r210145 assumed that m_floatingObjects would simply ignore the floating box if it was already in the list.  
2690
2691         Test: fast/block/float/placing-multiple-floats-crash.html
2692
2693         * rendering/RenderBlockFlow.cpp:
2694         (WebCore::RenderBlockFlow::addFloatsToNewParent):
2695
2696 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
2697
2698         Try to normalize variation ranges
2699         https://bugs.webkit.org/show_bug.cgi?id=170119
2700
2701         Unreviewed.
2702
2703         Addressing post-review comment.
2704
2705         * platform/graphics/cocoa/FontCacheCoreText.cpp:
2706         (WebCore::isGXVariableFont):
2707
2708 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
2709
2710         Try to normalize variation ranges
2711         https://bugs.webkit.org/show_bug.cgi?id=170119
2712
2713         Reviewed by Simon Fraser.
2714
2715         TrueType GX-style variation fonts use one particular scale for values on their
2716         weight/width/slope axes - usually the values lie between -1 and 1 on that scale.
2717         However, OpenType 1.8-style fonts use the CSS scale for values on these axes.
2718         For the purposes of font selection, these values need to lie on the same scale.
2719         However, when font selection is completed and the variation values are actually
2720         being applied to the fonts, values which lie on the font's actual scale need to
2721         be applied. This patch adds normalize*() and denormalize*() functions to perform
2722         both of these operations. 
2723
2724         The conversion itself between the two scales isn't an exact mapping. Mapping
2725         slope is just a linear relationship with 0deg <=> 0 and 20deg <=> 1 (as per the
2726         CSS Fonts spec). Mapping widths is similar, it uses a 2-component piecewise
2727         linear relationship which includes the values given in the Microsoft OpenType
2728         spec for the OS/2 table's usWidthClass field. Weights are more difficult, so I
2729         plotted the CSS weights and the GX-style weights for every style of San
2730         Francisco, saw that the relationship appears to be linear, and ran a linear
2731         regression to compute the line equation.
2732
2733         As for the actual discrimination of determining whether a font is a GX-style
2734         font or not, we can use the presence of the 'STAT' table. This table didn't
2735         exist when GX fonts were being created, and OpenType 1.8 variable fonts are
2736         required to have this table.
2737
2738         Facebook uses the string ".SFNSText" in their @font-face blocks. This font is
2739         a variation font, but uses the GX-style values. Facebook asks us to create
2740         this font with a weight of 700, and because the values in the font are around
2741         1.0, we were erroneously thinking that the font wasn't bold, so we were then
2742         applying synthetic bold. This was causing text on facebook to look fuzzy and
2743         ugly.
2744
2745         Test: fast/text/variations/font-selection-properties-expected.html
2746
2747         * platform/graphics/cocoa/FontCacheCoreText.cpp:
2748         (WebCore::isGXVariableFont):
2749         (WebCore::normalizeWeight):
2750         (WebCore::normalizeSlope):
2751         (WebCore::denormalizeWeight):
2752         (WebCore::denormalizeWidth):
2753         (WebCore::denormalizeSlope):
2754         (WebCore::normalizeWidth):
2755         (WebCore::preparePlatformFont): Instead of using FontSelectionValues for the
2756         intermediate values, we should use floats instead. This is because
2757         FontSelectionValues are fixed-point numbers with the denominator having 2 bits.
2758         When using this data type to represent values on the GX scale, which are usually
2759         between 0 and 1, you lose a lot of fidelity. Instead, our intermediate
2760         calculations should be done with floats, and converted to FontSelectionValues at
2761         the end when they are representative of values on the CSS scale.
2762         (WebCore::stretchFromCoreTextTraits):
2763         (WebCore::fontWeightFromCoreText):
2764         (WebCore::extractVariationBounds):
2765         (WebCore::variationCapabilitiesForFontDescriptor):
2766         (WebCore::capabilitiesForFontDescriptor):
2767
2768 2017-03-29  Saam Barati  <sbarati@apple.com>
2769
2770         LinkBuffer and ExecutableAllocator shouldn't have anything to do with VM
2771         https://bugs.webkit.org/show_bug.cgi?id=170210
2772
2773         Reviewed by Mark Lam.
2774
2775         * cssjit/SelectorCompiler.cpp:
2776         (WebCore::SelectorCompiler::compileSelector):
2777         (WebCore::SelectorCompiler::SelectorCodeGenerator::compile):
2778
2779 2017-03-29  Javier Fernandez  <jfernandez@igalia.com>
2780
2781         [css-align] Adapt self-alignment properties to the new baseline syntax
2782         https://bugs.webkit.org/show_bug.cgi?id=170235
2783
2784         Reviewed by David Hyatt.
2785
2786         The baseline-position syntax has changed recently, so we need to update
2787         the CSS properties using the old syntax. This patch address only the
2788         self-alignment (align-self and justify-self) and default-alignment
2789         (align-items and justify-items).
2790
2791         The content-distribution properties (align-content and justify-content)
2792         will be updated in a follow up patch.
2793
2794         The new baseline syntax is "[first | last ]? baseline" which implies
2795         modifying the parsing and computed value logic.
2796
2797         There are several layout tests affected by this change, so I'll update
2798         them accordingly.
2799
2800         No new tests, just added/modified some cases to the tests we already have using the new baseline values.
2801
2802         * css/CSSComputedStyleDeclaration.cpp:
2803         (WebCore::valueForItemPositionWithOverflowAlignment):
2804         * css/CSSValueKeywords.in:
2805         * css/StyleBuilderConverter.h:
2806         (WebCore::StyleBuilderConverter::convertSelfOrDefaultAlignmentData):
2807         * css/parser/CSSPropertyParser.cpp:
2808         (WebCore::consumeBaselineKeyword):
2809         (WebCore::consumeSelfPositionOverflowPosition):
2810
2811 2017-03-29  Chris Dumez  <cdumez@apple.com>
2812
2813         Animated SVG images are not paused in pages loaded in the background
2814         https://bugs.webkit.org/show_bug.cgi?id=170043
2815         <rdar://problem/31234412>
2816
2817         Reviewed by Simon Fraser.
2818
2819         Animated SVG images are not paused in pages loaded in the background. We rely
2820         on FrameView::isOffscreen() to stop images animations in background tab (See
2821         logic in RenderElement's shouldRepaintForImageAnimation()). This works fine
2822         if a tab is visble and then becomes hidden (i.e. by switching to another
2823         tab). However, in the case where the tab gets loaded while in the background
2824         (e.g. opening link in new background tab, or session restore), then the
2825         animations would not be paused, due to FrameView::isOffscreen() erroneously
2826         returning false in this case.
2827
2828         Normally, the following chain of events happens:
2829         - Page is visible, we construct a main frame and its FrameView for loading
2830           the page. When a FrameView is constructed, we call FrameView::show() to
2831           make it visible. Then, if the page becomes non-visible, we call
2832           Page::setIsVisibleInternal(false) which calls FrameView::hide(). After
2833           that, FrameView::isOffscreen() correctly returns true because we properly
2834           called FrameView::hide().
2835
2836         However, when doing a load while the Page is hidden, the following was
2837         happening:
2838         - Page is not visible, we call Page::setIsVisibleInternal(false) which tries
2839           to call FrameView::hide() for the main frame but it does not have a FrameView
2840           yet (because the load has not started). We start the load and end up creating
2841           a FrameView. The FrameView constructor was calling FrameView::show()
2842           unconditionally, thus making the FrameView think is visible, even though its
2843           page isn't. At this point, FrameView::isOffscreen() was returning false
2844           and animations would keep running, even though the page is not visible.
2845
2846         To address the issue, we now call FrameView::show() in FrameView::create() only
2847         if the Page is actually visible, instead of calling it unconditionally. If the
2848         page ever becomes visible, Page::setIsVisibleInternal(true) will be called and
2849         it will take care of calling FrameView::show() then.
2850
2851         Tests: svg/animations/animations-paused-in-background-page-iframe.html
2852                svg/animations/animations-paused-in-background-page.html
2853
2854         * page/FrameView.cpp:
2855         (WebCore::FrameView::create):
2856
2857 2017-03-29  Wenson Hsieh  <wenson_hsieh@apple.com>
2858
2859         Links with empty hrefs should not be drag sources
2860         https://bugs.webkit.org/show_bug.cgi?id=170241
2861         <rdar://problem/31305505>
2862
2863         Reviewed by Tim Horton.
2864
2865         The m_dragSouceAction member of DragController represents the drag source actions that are available to the
2866         document, rather than the available actions given the dragging element. Thus, it is not correct to only check
2867         that (m_dragSourceAction & DragSourceActionAttachment) before proceeding down the attachment dragging codepath.
2868         This should be additionally guarded with a check that the element being dragged is, in fact, an attachment
2869         element.
2870
2871         New API test (see Tools/ChangeLog).
2872
2873         * page/DragController.cpp:
2874         (WebCore::DragController::startDrag):
2875
2876 2017-03-29  Jeremy Jones  <jeremyj@apple.com>
2877
2878         WebVideoFullscreenInterfaceAVKit needs a strong self ref before dispatching to the main thread.
2879         https://bugs.webkit.org/show_bug.cgi?id=170129
2880
2881         Reviewed by David Kilzer.
2882
2883         No new tests becuase no new behavior.
2884
2885         Hold a strong reference to WebVideoFullscreenInterfaceAVKit when dispatching to the main thread.
2886         Make WebVideoFullscreenInterfaceAVKit safe to retain from non-main thread.
2887
2888         * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
2889         * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
2890         (WebVideoFullscreenInterfaceAVKit::exitFullscreen):
2891
2892 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
2893
2894         [GCrypt] Add a Handle<> class to help with GCrypt object lifetime control
2895         https://bugs.webkit.org/show_bug.cgi?id=170238
2896
2897         Reviewed by Michael Catanzaro.
2898
2899         The platform-specific CryptoAlgorithmHMAC implementation is modified
2900         to showcase the GCrypt::Handle<> use. HandleDeleter<gcry_mac_hd_t>
2901         is added accordingly.
2902
2903         * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
2904         (WebCore::calculateSignature):
2905
2906 2017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
2907
2908         Variation fonts: Make sure that feature detection and preprocessor macros are right
2909         https://bugs.webkit.org/show_bug.cgi?id=169518
2910
2911         Reviewed by Simon Fraser.
2912
2913         When I added variable fonts support, I made all OSes parse the newly accepted values,
2914         instead of just the OSes which support variable fonts.
2915
2916         Test: fast/text/font-variations-feature-detection.html
2917
2918         * css/parser/CSSPropertyParser.cpp:
2919         (WebCore::consumeFontStretch):
2920         (WebCore::consumeFontStyle):
2921         * css/parser/CSSPropertyParserHelpers.cpp:
2922         (WebCore::CSSPropertyParserHelpers::divisibleBy100):
2923         (WebCore::CSSPropertyParserHelpers::consumeFontWeightNumber):
2924
2925 2017-03-29  Antoine Quint  <graouts@apple.com>
2926
2927         [Modern Media Controls] Controls bar may disappear while captions menu is visible (redux)
2928         https://bugs.webkit.org/show_bug.cgi?id=170239
2929         <rdar://problem/31320685>
2930
2931         Reviewed by Dean Jackson.
2932
2933         We did some work in webkit.org/b/168751 to prevent the controls bar from disappearing while the
2934         captions menu is visible. But there were two cases where the behavior was not as intended:
2935
2936             1. the controls bar would hide upon exiting the video.
2937             2. clicking on the controls bar while the caption panel is up would hide the controls bar
2938                as well as the captions panel.
2939
2940         Instead of determining that the "userInteractionEnabled" property being set to "false" is indicative
2941         of secondary UI, such as the tracks panel, being attached to the controls bar, we now have an
2942         explicit property to specify this. Now, when "hasSecondaryUIAttached" is "true", we prevent the
2943         controls bar from fading when exiting the media.
2944
2945         Additionally, when dismissing the tracks panel, we check whether a mouse event lead to this and check
2946         if the mouse was positioned over the controls bar. If that is the case, we no longer hide the controls
2947         bar and only dismiss the tracks panel.
2948
2949         Test: media/modern-media-controls/tracks-panel/tracks-panel-controls-bar-remains-visible-after-clicking-over-it.html
2950
2951         * Modules/modern-media-controls/controls/controls-bar.js:
2952         (ControlsBar.prototype.set userInteractionEnabled):
2953         (ControlsBar.prototype.handleEvent):
2954         (ControlsBar.prototype._autoHideTimerFired):
2955         * Modules/modern-media-controls/controls/macos-media-controls.js:
2956         (MacOSMediaControls.prototype.showTracksPanel):
2957         (MacOSMediaControls.prototype.hideTracksPanel):
2958
2959 2017-03-29  Antoine Quint  <graouts@apple.com>
2960
2961         [Modern Media Controls] Volume slider is initially empty
2962         https://bugs.webkit.org/show_bug.cgi?id=170237
2963         <rdar://problem/31319077>
2964
2965         Reviewed by Dean Jackson.
2966
2967         Fixing fallout from https://bugs.webkit.org/show_bug.cgi?id=167935 where we changed the behavior
2968         of layout() to happen prior to a commit. In this one instance, we were overriding layout() to run
2969         after a commit, so we now override commit(). Otherwise, the <canvas> that we draw the volume slider
2970         into would have its "width" and "height" properties set after we drew, which would clear the <canvas>.
2971
2972         * Modules/modern-media-controls/controls/slider.js:
2973         (Slider.prototype.commit):
2974         (Slider.prototype.layout): Deleted.
2975
2976 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
2977
2978         [GCrypt] Move over empty GnuTLS-based SUBTLE_CRYPTO implementation files
2979         https://bugs.webkit.org/show_bug.cgi?id=170232
2980
2981         Reviewed by Michael Catanzaro.
2982
2983         Migrate the GnuTLS SUBTLE_CRYPTO implementation files to the gcrypt/
2984         directory. The implementation files themselves are no-op, so this is
2985         a simple move-and-rename operation that will enable proceeding with
2986         the libgcrypt-based implementation of SUBTLE_CRYPTO functionality.
2987
2988         No change in behavior. The SUBTLE_CRYPTO feature should build as it
2989         did before, and the implementations are empty anyway.
2990
2991         * PlatformGTK.cmake:
2992         * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp.
2993         * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CFBGnuTLS.cpp.
2994         * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_GCMGnuTLS.cpp.
2995         * crypto/gcrypt/CryptoAlgorithmAES_KWGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_KWGnuTLS.cpp.
2996         * crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmECDHGnuTLS.cpp.
2997         * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmPBKDF2GnuTLS.cpp.
2998         * crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp.
2999         * crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp: This one already exists.
3000         * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp.
3001         * crypto/gcrypt/CryptoAlgorithmRegistryGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoAlgorithmRegistryGnuTLS.cpp.
3002         * crypto/gcrypt/CryptoKeyECGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp.
3003         * crypto/gcrypt/CryptoKeyRSAGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp.
3004         * crypto/gcrypt/SerializedCryptoKeyWrapGCrypt.cpp: Renamed from Source/WebCore/crypto/gnutls/SerializedCryptoKeyWrapGnuTLS.cpp.
3005         * crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp: Removed.
3006
3007 2017-03-29  Zan Dobersek  <zdobersek@igalia.com>
3008
3009         [GnuTLS] Remove unused CryptoDigestGnuTLS, CryptoAlgorithmHMACGnuTLS implementation files
3010         https://bugs.webkit.org/show_bug.cgi?id=170231
3011
3012         Reviewed by Michael Catanzaro.
3013
3014         * crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp: Removed. The GCrypt counterpart
3015         is already in use, and this file wasn't even being built.
3016
3017 2017-03-29  Youenn Fablet  <youenn@apple.com>
3018
3019         Move DTMF WebRTC extension behind its own compile flag
3020         https://bugs.webkit.org/show_bug.cgi?id=170226
3021
3022         Reviewed by Eric Carlson.
3023
3024         Moving RTCDTMFSender and RTCDTMFToneChangeEvent behinf a WEB_RTC_DTMF compile flag.
3025         This compile flag is not set on any supported platform yet.
3026         Disabling related test and updated test expectations.
3027
3028         * Modules/mediastream/RTCDTMFSender.cpp:
3029         * Modules/mediastream/RTCDTMFSender.h:
3030         * Modules/mediastream/RTCDTMFSender.idl:
3031         * Modules/mediastream/RTCDTMFToneChangeEvent.cpp:
3032         * Modules/mediastream/RTCDTMFToneChangeEvent.h:
3033         * Modules/mediastream/RTCDTMFToneChangeEvent.idl:
3034         * dom/EventNames.in:
3035         * dom/EventTargetFactory.in:
3036         * platform/mediastream/RTCDTMFSenderHandler.h:
3037         * platform/mediastream/RTCDTMFSenderHandlerClient.h:
3038
3039 2017-03-29  Antoine Quint  <graouts@apple.com>
3040
3041         [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
3042         https://bugs.webkit.org/show_bug.cgi?id=168409
3043         <rdar://problem/30799198>
3044
3045         Reviewed by Dean Jackson.
3046
3047         Add a new internals setting to opt into ScriptedAnimationController logging through DOM events dispatched
3048         through the document. This should allow this flaky test to get information as to why the frame isn't
3049         firing when it times out.
3050
3051         * dom/ScriptedAnimationController.cpp:
3052         (WebCore::ScriptedAnimationController::suspend):
3053         (WebCore::ScriptedAnimationController::resume):
3054         (WebCore::ScriptedAnimationController::addThrottlingReason):
3055         (WebCore::ScriptedAnimationController::removeThrottlingReason):
3056         (WebCore::ScriptedAnimationController::registerCallback):
3057         (WebCore::ScriptedAnimationController::cancelCallback):
3058         (WebCore::ScriptedAnimationController::serviceScriptedAnimations):
3059         (WebCore::ScriptedAnimationController::scheduleAnimation):
3060         (WebCore::ScriptedAnimationController::dispatchLoggingEventIfRequired):
3061         * dom/ScriptedAnimationController.h:
3062         * page/Settings.in:
3063         * testing/InternalSettings.cpp:
3064         (WebCore::InternalSettings::resetToConsistentState):
3065         (WebCore::InternalSettings::shouldDispatchRequestAnimationFrameEvents):
3066         (WebCore::InternalSettings::setShouldDispatchRequestAnimationFrameEvents):
3067         * testing/InternalSettings.h:
3068         * testing/InternalSettings.idl:
3069
3070 2017-03-28  Youenn Fablet  <youenn@apple.com>
3071
3072         [WebRTC] After r214441 addIceCandidate no longer accepts an RTCIceCandidateInit dictionary
3073         https://bugs.webkit.org/show_bug.cgi?id=170192
3074
3075         Reviewed by Jon Lee.
3076
3077         Covered by updated tests.
3078
3079         * Modules/mediastream/RTCIceCandidate.idl: Candidate is no longer a required field in RTCIceCandidateInit.
3080         * Modules/mediastream/RTCPeerConnectionInternals.js: Reworking defaultsToNull to handle both undefined and null cases.
3081
3082 2017-03-28  Youenn Fablet  <youenn@apple.com>
3083
3084         LibWebRTCProvider should allow setting encoder and decoder factories
3085         https://bugs.webkit.org/show_bug.cgi?id=170212
3086
3087         Reviewed by Eric Carlson.
3088
3089         No change of behavior.
3090         Adding the ability to set encoder/decoder libwebrtc factory getters.
3091         Setting default cocoa factory getters.
3092
3093         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
3094         (WebCore::staticFactoryAndThreads):
3095         (WebCore::initializePeerConnectionFactoryAndThreads):
3096         (WebCore::LibWebRTCProvider::setDecoderFactoryGetter):
3097         (WebCore::LibWebRTCProvider::setEncoderFactoryGetter):
3098         (WebCore::LibWebRTCProvider::setPeerConnectionFactory):
3099         * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
3100
3101 2017-03-27  Brent Fulgham  <bfulgham@apple.com>
3102
3103         Only attach Attributes to a given element one time
3104         https://bugs.webkit.org/show_bug.cgi?id=170125
3105         <rdar://problem/31279676>
3106
3107         Reviewed by Chris Dumez.
3108
3109         Attach the attribute node to the Element before calling 'setAttributeInternal', since that method may cause
3110         arbitrary JavaScript events to fire. 
3111
3112         Test: fast/dom/Attr/only-attach-attr-once.html
3113
3114         * dom/Element.cpp:
3115         (WebCore::Element::attachAttributeNodeIfNeeded): Added.
3116         (WebCore::Element::setAttributeNode): Use new method. Revise to attach attribute before calling 'setAttributeInternal'. 
3117         (WebCore::Element::setAttributeNodeNS): Ditto.
3118         * dom/Element.h:
3119
3120 2017-03-28  Youenn Fablet  <youenn@apple.com>
3121
3122         Stop RTCDataChannel when closing page
3123         https://bugs.webkit.org/show_bug.cgi?id=170166
3124
3125         Reviewed by Eric Carlson.
3126
3127         Test: webrtc/datachannel/datachannel-gc.html
3128
3129         Making RTCDataChannel an ActiveDOMObject.
3130         Closing the data channel backend and freeing upon close and stop.
3131
3132         * Modules/mediastream/RTCDataChannel.cpp:
3133         (WebCore::RTCDataChannel::create):
3134         (WebCore::RTCDataChannel::RTCDataChannel):
3135         (WebCore::RTCDataChannel::close):
3136         (WebCore::RTCDataChannel::stop):
3137         * Modules/mediastream/RTCDataChannel.h:
3138         * Modules/mediastream/RTCDataChannel.idl:
3139         * Modules/mediastream/RTCPeerConnection.h:
3140
3141 2017-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
3142
3143         Ranges for variation font properties are not enforced
3144         https://bugs.webkit.org/show_bug.cgi?id=169979
3145
3146         Reviewed by David Hyatt.
3147
3148         The spec specifies that:
3149         - Font weights less than or equal to 0, or greater than or equal to 1000 are parse errors
3150         - Font stretch values less than or equal to 0% are parse errors
3151         - Font style values less than or equal to -90deg or greater than or equal to 90deg are parse errors
3152
3153         Test: fast/text/variations/out-of-bounds-selection-properties.html
3154
3155         * css/parser/CSSPropertyParser.cpp:
3156         (WebCore::consumeFontWeightRange):
3157         (WebCore::fontStretchIsWithinRange):
3158         (WebCore::consumeFontStretch):
3159         (WebCore::consumeFontStretchRange):
3160         (WebCore::fontStyleIsWithinRange):
3161         (WebCore::consumeFontStyle):
3162         (WebCore::consumeFontStyleRange):
3163
3164 2017-03-28  Andy Estes  <aestes@apple.com>
3165
3166         [iOS] Crash in -[WebPreviewLoader failed] when running http/tests/multipart/policy-ignore-crash.php
3167         https://bugs.webkit.org/show_bug.cgi?id=170197
3168         <rdar://problem/30314067>
3169
3170         Reviewed by Brady Eidson.
3171
3172         If QuickLook conversion fails, we call ResourceLoader::didFail() with the NSError from
3173         QuickLook, which will call back into PreviewLoader::didFail(). We only care about network
3174         failures in PreviewLoader, not conversion failures, so check if
3175         m_finishedLoadingDataIntoConverter is set before continuing (like we do in
3176         PreviewLoader::didFinishLoading()).
3177
3178         Fixes crash in http/tests/multipart/policy-ignore-crash.php.
3179
3180         * loader/ios/PreviewLoader.mm:
3181         (WebCore::PreviewLoader::didFail):
3182
3183 2017-03-28  Chris Dumez  <cdumez@apple.com>
3184
3185         Audio indicator is visible on uni-watch.com but there is no audible audio
3186         https://bugs.webkit.org/show_bug.cgi?id=170200
3187         <rdar://problem/31289132>
3188
3189         Reviewed by Eric Carlson.
3190
3191         Cherry-pick the following patch from Blink by <rtoy@chromium.org>:
3192         - https://chromium.googlesource.com/chromium/src.git/+/439de5bb2a31384666db1a0e2dadb2b97d2f3ce4
3193
3194         When the gain of a GainNode is 0 or 1, the operation of the node can
3195         be optimized.  When gain = 1, just copy the input to the output.  When
3196         gain = 0; just zero out the output.  Currently, the input is
3197         multiplied by the gain to produce the output.  This just optimizes the
3198         multiplication away for the two special cases.
3199
3200         Also, have the GainNode set the silence hint if the gain is 0.
3201
3202         And fix a bug in processIfNecessary when unsilenceOutputs was causing the
3203         silence hint to be cleared after the node's process method was finished
3204         and may have set the silence hint.  The processing should come after
3205         unsilenceOutputs to preserve any hints from processing the node.
3206
3207         * Modules/webaudio/AudioNode.cpp:
3208         (WebCore::AudioNode::processIfNecessary):
3209         * Modules/webaudio/GainNode.cpp:
3210         (WebCore::GainNode::process):
3211         * platform/audio/AudioBus.cpp:
3212         (WebCore::AudioBus::copyWithGainFrom):
3213
3214 2017-03-28  Chris Dumez  <cdumez@apple.com>
3215
3216         Animated SVG images are not paused when outside viewport
3217         https://bugs.webkit.org/show_bug.cgi?id=170155
3218         <rdar://problem/31288893>
3219
3220         Reviewed by Antti Koivisto.
3221
3222         Make sure animated SVG images get paused when outside the viewport,
3223         similarly to what was already done for animated GIF images. Also
3224         make sure they are paused when they no longer have any renderers
3225         using them.
3226
3227         Tests: svg/animations/animated-svg-image-outside-viewport-paused.html
3228                svg/animations/animated-svg-image-removed-from-document-paused.html
3229
3230         * loader/cache/CachedImage.cpp:
3231         (WebCore::CachedImage::didAddClient):
3232         Restart the animation whenever a new CachedImage client is added. This
3233         will cause us the re-evaluate if the animation should run. The animation
3234         will pause again if the new renderer is not inside the viewport.
3235
3236         (WebCore::CachedImage::animationAdvanced):
3237         Add a flag to newImageAnimationFrameAvailable() so that the renderers can
3238         let us know if we can pause the animation. Pause the animation if all no
3239         renderer requires it (i.e. they are all outside the viewport, or there
3240         are no renderers).
3241
3242         * loader/cache/CachedImageClient.h:
3243         (WebCore::CachedImageClient::newImageAnimationFrameAvailable):
3244         By default, the CachedImageClients allow pausing. Only renderer will
3245         potentially prevent pausing if they are inside the viewport.
3246
3247         * platform/graphics/BitmapImage.cpp:
3248         (WebCore::BitmapImage::isAnimating):
3249         * platform/graphics/BitmapImage.h:
3250         * platform/graphics/Image.h:
3251         (WebCore::Image::isAnimating):
3252         Add isAnimating() flag on Image for layout testing purposes.
3253
3254         * rendering/RenderElement.cpp:
3255         (WebCore::RenderElement::newImageAnimationFrameAvailable):
3256         Set canPause flag to true if the renderer is not inside the viewport.
3257
3258         (WebCore::RenderElement::repaintForPausedImageAnimationsIfNeeded):
3259         Call startAnimation() if the renderer is now visible to resume SVG
3260         animations. Repainting is enough for GIF animations but not for SVG
3261         animations, we have to explicitly resume them.
3262
3263         * rendering/RenderElement.h:
3264         * rendering/RenderView.cpp:
3265         (WebCore::RenderView::addRendererWithPausedImageAnimations):
3266         (WebCore::RenderView::removeRendererWithPausedImageAnimations):
3267         (WebCore::RenderView::resumePausedImageAnimationsIfNeeded):
3268         * rendering/RenderView.h:
3269         Store CachedImages with the renderers that have paused animations.
3270         This is required for SVG where we need to explicitly resume the
3271         animation on the CachedImage when the renderer becomes visible
3272         again. Having access to the Image will also allow us to do smarter
3273         visibility checks in RenderElement's shouldRepaintForImageAnimation(),
3274         in the future.
3275
3276         * svg/SVGSVGElement.cpp:
3277         (WebCore::SVGSVGElement::hasActiveAnimation):
3278         * svg/SVGSVGElement.h:
3279         Add hasActiveAnimation() method.
3280
3281         * svg/graphics/SVGImage.cpp:
3282         (WebCore::SVGImage::startAnimation):
3283         Check that animations are paused before starting them. This avoid
3284         jumping due to unnecessary calls to rootElement->setCurrentTime(0).
3285
3286         (WebCore::SVGImage::isAnimating):
3287         Add isAnimating() method for layout tests purposes.
3288
3289         * svg/graphics/SVGImage.h:
3290         * svg/graphics/SVGImageClients.h:
3291         Call animationAdvanced() on the observer instead of the generic
3292         changedInRect() when the SVGImage is animating. This way, we go
3293         through the same code path as GIF animations and we end up calling
3294         CachedImage::animationAdvanced() which calls newImageAnimationFrameAvailable()
3295         on RenderElement, which determines if the animation should keep
3296         running or not.
3297
3298         * testing/Internals.cpp:
3299         (WebCore::Internals::isImageAnimating):
3300         * testing/Internals.h:
3301         * testing/Internals.idl:
3302         Add layout testing infrastructure.
3303
3304 2017-03-28  Antti Koivisto  <antti@apple.com>
3305
3306         Missing render tree position invalidation when tearing down renderers for display:contents subtree
3307         https://bugs.webkit.org/show_bug.cgi?id=170199
3308         <rdar://problem/31260856>
3309
3310         Reviewed by Zalan Bujtas.
3311
3312         Test: fast/shadow-dom/slot-renderer-teardown.html
3313
3314         * style/RenderTreeUpdater.cpp:
3315         (WebCore::RenderTreeUpdater::updateElementRenderer):
3316
3317             Invalidate the render tree position in case we do a teardown for an element without renderer.
3318
3319 2017-03-28  Ryan Haddad  <ryanhaddad@apple.com>
3320
3321         Unreviewed, rolling out r214485.
3322
3323         This change caused LayoutTest crashes.
3324
3325         Reverted changeset:
3326
3327         "Stop RTCDataChannel when closing page"
3328         https://bugs.webkit.org/show_bug.cgi?id=170166
3329         http://trac.webkit.org/changeset/214485
3330
3331 2017-03-28  Anders Carlsson  <andersca@apple.com>
3332
3333         ApplePayShippingContactUpdate.idl shouldn't have status field
3334         https://bugs.webkit.org/show_bug.cgi?id=170202
3335         rdar://problem/31307106
3336
3337         Reviewed by Beth Dakin.
3338
3339         * Modules/applepay/ApplePaySession.cpp:
3340         (WebCore::convertAndValidate):
3341         If status isn't set, infer it based on whether there are errors present or not.
3342
3343         * Modules/applepay/ApplePayShippingContactUpdate.h:
3344         Make status optional here; it's still used by the old code path.
3345
3346         * Modules/applepay/ApplePayShippingContactUpdate.idl:
3347         Remove status here.
3348
3349 2017-03-28  Brian Burg  <bburg@apple.com>
3350
3351         Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
3352         https://bugs.webkit.org/show_bug.cgi?id=169865
3353         <rdar://problem/31250573>
3354
3355         Reviewed by Joseph Pecoraro.
3356
3357         Rewrite the network agent's command for disabling resource caching to use Page::setResourceCachingEnabled.
3358         The old implementation was doing weird stuff like setting no-cache headers and evicting the
3359         contents of the memory cache, neither of which is correct. The new approach has no side effects
3360         on the network, disk, or memory cache so it can be turned on temporarily without causing problems.
3361
3362         New tests:
3363         - http/tests/inspector/network/set-resource-caching-disabled-disk-cache.html
3364         - http/tests/inspector/network/set-resource-caching-disabled-memory-cache.html
3365
3366         * inspector/InspectorNetworkAgent.h:
3367         * inspector/InspectorNetworkAgent.cpp:
3368         (WebCore::InspectorNetworkAgent::setCacheDisabled): Deleted.
3369         (WebCore::InspectorNetworkAgent::setResourceCachingDisabled): Added.
3370         Implement new command.
3371
3372         (WebCore::InspectorNetworkAgent::willSendRequest):
3373         (WebCore::InspectorNetworkAgent::mainFrameNavigated):
3374         Remove crufty attempts to break caches. I believe these are intended to defeat caching
3375         proxies and similar middlemen, but this is just as likely to cause unusual loading behavior.
3376
3377         * page/Page.h:
3378         (WebCore::Page::isResourceCachingDisabled):
3379         (WebCore::Page::setResourceCachingDisabledOverride):
3380         Add an override setting so that Web Inspector's override does not mess up the value
3381         of isResourceCachingDisabled that may have been set by a WebKit API client.
3382
3383 2017-03-28  Youenn Fablet  <youenn@apple.com>
3384
3385         Fix addIceCandidate after r214441
3386         https://bugs.webkit.org/show_bug.cgi?id=170146
3387
3388         Reviewed by Chris Dumez.
3389
3390         Covered by rebased test.
3391
3392         * Modules/mediastream/RTCPeerConnection.js:
3393         (addIceCandidate): Setting function length to 1 and throwing if no parameter is passed.
3394
3395 2017-03-28  Youenn Fablet  <youenn@apple.com>
3396
3397         Stop RTCDataChannel when closing page
3398         https://bugs.webkit.org/show_bug.cgi?id=170166
3399
3400         Reviewed by Eric Carlson.
3401
3402         Test: webrtc/datachannel/datachannel-gc.html
3403
3404         Making RTCDataChannel an ActiveDOMObject.
3405         Closing the data channel backend and freeing upon close and stop.
3406
3407         * Modules/mediastream/RTCDataChannel.cpp:
3408         (WebCore::RTCDataChannel::create):
3409         (WebCore::RTCDataChannel::RTCDataChannel):
3410         (WebCore::RTCDataChannel::close):
3411         (WebCore::RTCDataChannel::stop):
3412         * Modules/mediastream/RTCDataChannel.h:
3413         * Modules/mediastream/RTCDataChannel.idl:
3414         * Modules/mediastream/RTCPeerConnection.h:
3415
3416 2017-03-27  Simon Fraser  <simon.fraser@apple.com>
3417
3418         Enhance the touch region debug overlay to show regions for the different events
3419         https://bugs.webkit.org/show_bug.cgi?id=170162
3420
3421         Reviewed by Tim Horton.
3422
3423         Have NonFastScrollableRegionOverlay use a different color for each region in EventTrackingRegions,
3424         and to draw a legend showing what the colors mean.
3425         
3426         On Mac, this overlay displays the non-fast scrollable region (which we don't keep separate from the wheel event
3427         region).
3428
3429         * page/DebugPageOverlays.cpp:
3430         (WebCore::NonFastScrollableRegionOverlay::updateRegion):
3431         (WebCore::touchEventRegionColors):
3432         (WebCore::drawRightAlignedText):
3433         (WebCore::NonFastScrollableRegionOverlay::drawRect):
3434         (WebCore::RegionOverlay::drawRect):
3435         (WebCore::RegionOverlay::drawRegion):
3436
3437 2017-03-27  Simon Fraser  <simon.fraser@apple.com>
3438
3439         Make sure the non-fast scrolling debug overlay is correctly updated
3440         https://bugs.webkit.org/show_bug.cgi?id=170142
3441
3442         Reviewed by Tim Horton.
3443
3444         AsyncScrollingCoordinator::frameViewEventTrackingRegionsChanged() is called on a timer
3445         from Document code, so the existing DebugPageOverlays::didLayout() call at the end
3446         of FrameView::layout() wasn't sufficient to keep the non-fast scrollable region up-to-date
3447         on iOS.
3448
3449         * page/scrolling/AsyncScrollingCoordinator.cpp:
3450         (WebCore::AsyncScrollingCoordinator::frameViewEventTrackingRegionsChanged):
3451
3452 2017-03-28  Antoine Quint  <graouts@apple.com>
3453
3454         [Modern Media Controls] AirPlay placard text looks bad on 1x displays
3455         https://bugs.webkit.org/show_bug.cgi?id=170183
3456         <rdar://problem/30663416>
3457
3458         Reviewed by Dean Jackson.
3459
3460         Use subpixel antialiasing for all text in modern media controls.
3461
3462         * Modules/modern-media-controls/controls/media-controls.css:
3463         (.media-controls-container,):
3464
3465 2017-03-28  Antoine Quint  <graouts@apple.com>
3466
3467         [Modern Media Controls] Improve appearance of tracks panel on macOS
3468         https://bugs.webkit.org/show_bug.cgi?id=168929
3469         <rdar://problem/30741589>
3470
3471         Reviewed by Eric Carlson.
3472
3473         We use a solid color for the focus state that matches the style used on macOS
3474         and blend the titles the same way we blend other non-solid labels in the controls bar.
3475
3476         * Modules/modern-media-controls/controls/tracks-panel.css:
3477         (.tracks-panel section):
3478         (.tracks-panel section > h3):
3479         (.tracks-panel section > ul > li:focus):
3480
3481 2017-03-28  Yoav Weiss  <yoav@yoav.ws>
3482
3483         Add a warning for unused link preloads.
3484         https://bugs.webkit.org/show_bug.cgi?id=165670
3485
3486         Reviewed by Youenn Fablet.
3487
3488         Tests: http/tests/preload/single_download_preload_headers_charset.php
3489                http/tests/preload/unused_preload_warning.html
3490
3491         * dom/Document.cpp:
3492         (WebCore::Document::prepareForDestruction): Stop the timer once the document is destructed.
3493         * loader/LinkPreloadResourceClients.h: Add shouldMarkAsReferenced overides for the LinkPreloadResourceClient classes.
3494         * loader/cache/CachedResource.cpp:
3495         (WebCore::CachedResource::addClientToSet): Make sure LinkPreloadResourceClients don't set resource to be referenced.
3496         * loader/cache/CachedResourceClient.h:
3497         (WebCore::CachedResourceClient::shouldMarkAsReferenced): Make sure that ResourceClients mark preloads as referenced by default.
3498         * loader/cache/CachedResourceLoader.cpp:
3499         (WebCore::CachedResourceLoader::CachedResourceLoader): Initialize timer.
3500         (WebCore::CachedResourceLoader::~CachedResourceLoader): Stop timer.
3501         (WebCore::CachedResourceLoader::documentDidFinishLoadEvent): Trigger a timer if preloads weren't cleared at load time.
3502         (WebCore::CachedResourceLoader::stopUnusedPreloadsTimer): Stop the timer.
3503         (WebCore::CachedResourceLoader::warnUnusedPreloads): Iterate over m_preloads and issue a warning for non-referenced preloads.
3504         * loader/cache/CachedResourceLoader.h:
3505         * page/DOMWindow.cpp:
3506         (WebCore::DOMWindow::willDetachDocumentFromFrame): Clear Resource Timing buffer when document detaches, to avoid test flakiness.
3507
3508 2017-03-28  Antoine Quint  <graouts@apple.com>
3509
3510         REGRESSION: Double-clicking the captions button while the captions popover is open prevents the popover from being opened again
3511         https://bugs.webkit.org/show_bug.cgi?id=170171
3512         <rdar://problem/31095500>
3513
3514         Reviewed by Dean Jackson.
3515
3516         We used to consider that the tracks panel was presented as long as it had a parent, but since we were using for the animated
3517         transition to complete before actually removing the panel from the node hierarchy, consecutive calls to hide then present
3518         would fail to present the panel. We now use a private instance variable to track the presented state which is set immediately
3519         as presentInParent() and hide() are called.
3520
3521         Test: media/modern-media-controls/tracks-support/tracks-support-show-panel-then-double-click-on-tracks-button.html
3522
3523         * Modules/modern-media-controls/controls/tracks-panel.js:
3524         (TracksPanel.prototype.get presented):
3525         (TracksPanel.prototype.presentInParent):
3526         (TracksPanel.prototype.hide):
3527
3528 2017-03-28  Aaron Chu  <aaron_chu@apple.com>
3529
3530         AX: Media controls should be able to be re-activated after faded away
3531         https://bugs.webkit.org/show_bug.cgi?id=170048
3532         <rdar://problem/30157179>
3533
3534         Reviewed by Antoine Quint.
3535
3536         Added a "foucsin" listener for the controls bar so that when an element
3537         within fires a "focusin" event, the controls bar reappears if it is faded.
3538
3539         Test: media/modern-media-controls/media-controls/media-controls-appear-when-focus.html
3540
3541         * Modules/modern-media-controls/controls/controls-bar.js:
3542         (ControlsBar.prototype.handleEvent):
3543
3544 2017-03-28  Antoine Quint  <graouts@apple.com>
3545
3546         [Modern Media Controls] Improve media documents across macOS, iPhone and iPad
3547         https://bugs.webkit.org/show_bug.cgi?id=169145
3548         <rdar://problem/17048858>
3549
3550         Reviewed by Dean Jackson.
3551
3552         There were a variety of issues with media documents, some longstanding, and some specifically
3553         about modern media controls.
3554
3555         One issue was that fullscreen and picture-in-picture buttons would show for audio media documents,
3556         due to using a <video> element to load the audio file. We now have additional logic in MediaController
3557         to identify if the loaded media is really an audio file, and using this information to hide the
3558         fullscreen and picture-in-picture buttons.
3559
3560         Another issue was that we would inject style in MediaDocument.cpp that was specific to modern media
3561         controls when we could have the modern-media-controls module injected CSS handle this styling. We now
3562         use the injected style in the shadow root to size media documents based on the device characteristics
3563         and ensuring that page styles are overridden.
3564
3565         We also simplify how MediaDocument.cpp sets the source of the media element to simply use the "src"
3566         attribute and not a <source> element.
3567
3568         Finally, we introduce a MediaDocumentController class that is instantiated when we're dealing with
3569         a media document to hide the controls while we determine the type of media we're loading (audio vs.
3570         video) in order to apply the appropriate styling without flashes.
3571
3572         As a result of the new styles applied by the modern-media-controls module, media documents have a
3573         similar behavior on macOS and iPad, where we only enforce a min-width for video allowing them
3574         to play at their natural size otherwise, and enforcing a fixed width for audio. On iPhone however,
3575         we want to always play the media at full width, with some padding in the case of audio.
3576
3577         Tests: media/modern-media-controls/fullscreen-support/fullscreen-support-disabled-video-with-audio-tracks-only.html
3578                media/modern-media-controls/media-documents/ipad/media-document-audio-ios-sizing.html
3579                media/modern-media-controls/media-documents/ipad/media-document-video-ios-sizing.html
3580                media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html
3581                media/modern-media-controls/media-documents/media-document-audio-mac-sizing.html
3582                media/modern-media-controls/media-documents/media-document-video-ios-sizing.html
3583                media/modern-media-controls/media-documents/media-document-video-mac-sizing.html
3584                media/modern-media-controls/pip-support/pip-support-disabled-video-with-audio-tracks-only.html
3585
3586         * Modules/modern-media-controls/controls/ios-inline-media-controls.css:
3587         (:host(audio) .media-controls.ios.inline > .controls-bar:before,):
3588         (:host(audio) .media-controls.ios.inline > .controls-bar:before): Deleted.
3589         * Modules/modern-media-controls/controls/macos-media-controls.css:
3590         (:host(audio) .media-controls.mac.inline > .controls-bar,):
3591         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint,):
3592         (:host(audio) .media-controls.mac.inline > .controls-bar): Deleted.
3593         (:host(audio) .media-controls.mac.inline > .controls-bar > .background-tint): Deleted.
3594         * Modules/modern-media-controls/controls/media-document.css: Copied from Source/WebCore/Modules/modern-media-controls/controls/macos-media-controls.css.
3595         (:host(.media-document)):
3596         (:host(.media-document.ready)):
3597         (:host(.media-document.audio.mac)):
3598         (:host(.media-document.audio.ipad)):
3599         (:host(.media-document.audio.iphone)):
3600         (:host(.media-document.video.mac)):
3601         (:host(.media-document.video.ipad)):
3602         (:host(.media-document.video.iphone)):
3603         * Modules/modern-media-controls/js-files:
3604         * Modules/modern-media-controls/media/fullscreen-support.js:
3605         (FullscreenSupport.prototype.syncControl):
3606         (FullscreenSupport):
3607         * Modules/modern-media-controls/media/media-controller.js:
3608         (MediaController):
3609         (MediaController.prototype.get isAudio):
3610         * Modules/modern-media-controls/media/media-document-controller.js: Copied from Source/WebCore/Modules/modern-media-controls/media/fullscreen-support.js.
3611         (MediaDocumentController):
3612         (MediaDocumentController.prototype.handleEvent):
3613         (MediaDocumentController.prototype._mediaDocumentHasMetadata):
3614         (MediaDocumentController.prototype._mediaDocumentHasSize):
3615         * Modules/modern-media-controls/media/pip-support.js:
3616         (PiPSupport.prototype.syncControl):
3617         (PiPSupport):
3618         * html/MediaDocument.cpp:
3619         (WebCore::MediaDocumentParser::createDocumentStructure):
3620
3621 2017-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
3622
3623         Follow-up patch after r214364.
3624         https://bugs.webkit.org/show_bug.cgi?id=168895
3625
3626         Unreviewed.
3627
3628         * platform/graphics/FontDescription.cpp:
3629         (WebCore::FontDescription::FontDescription):
3630
3631 2017-03-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
3632
3633         REGRESSION(213764): Large images should not be decoded asynchronously when they are drawn on a canvas
3634         https://bugs.webkit.org/show_bug.cgi?id=169771
3635
3636         Reviewed by Simon Fraser.
3637
3638         Sometimes we have to draw the image immediately like when a canvas calls  
3639         drawImage. In this case we have to decode the image synchronously to guarantee
3640         the drawing. Other times we need to decode with the native size of the image.
3641         The animated images have to be decoded with native size always. Otherwise
3642         the frame cache will be messed up if the same image is animated with different
3643         sizes. Currently we always decode asynchronously with sizeForDrawing. We need
3644         to decouple the decoding mode from the sizeForDrawing.
3645
3646         This patch introduce the DecodingOptions class which can store and compare the
3647         following four cases:
3648             -- Synchronous: The frame has be decoded with native size only.
3649             -- Asynchronous + anySize: This is passed from the Image::draw() callers.
3650             -- Asynchronous + fullSize: The image has to be decoded with its full size.
3651             -- Asynchronous + sizeForDrawing: The image can be decoded with sizeForDrawing unless
3652             it was decoded with either a full size or sizeForDrawing which is larger than the
3653             requested sizeForDrawing.
3654             
3655         A new argument of type DecodingMode will be added to Image::draw() function.
3656         Only when the drawing comes from the render tree, it will be Asynchronous.
3657         Otherwise it will be Synchronous.
3658
3659         Tests: fast/images/animated-image-different-dest-size.html
3660                fast/images/async-image-background-image.html
3661                fast/images/async-image-canvas-draw-image.html
3662
3663         * WebCore.xcodeproj/project.pbxproj:
3664         * platform/graphics/BitmapImage.cpp:
3665         (WebCore::BitmapImage::frameImageAtIndexCacheIfNeeded): Gets the frame image, cache it synchronously if
3666         the current one is invalid. frameImageAtIndex() returns whatever stored in the cache.
3667         (WebCore::BitmapImage::nativeImage): Call frameImageAtIndexCacheIfNeeded() instead of frameImageAtIndex().
3668         (WebCore::BitmapImage::nativeImageForCurrentFrame): Ditto.
3669         (WebCore::BitmapImage::nativeImageOfSize): Ditto.
3670         (WebCore::BitmapImage::framesNativeImages): Ditto.
3671         (WebCore::BitmapImage::draw): Change the logic to do the following:
3672         -- The animated image has to be decoded with its full size.
3673         -- The animated image expects the current frame to be ready for drawing.
3674         -- The large image decoding does not need to call internalStartAnimation().
3675         -- The large image has to request async image decoding but draw the current one if it exists.
3676         (WebCore::BitmapImage::drawPattern): Draw the pattern synchronously.
3677         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImages): Delete the call to shouldUseAsyncDecodingForTesting()
3678         since it is only applied for animated images.
3679         (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages): Call shouldUseAsyncDecodingForAnimatedImageForTesting().
3680         (WebCore::BitmapImage::internalStartAnimation): Request decoding with the full size.
3681         (WebCore::BitmapImage::advanceAnimation): Call shouldUseAsyncDecodingForAnimatedImageForTesting().
3682         (WebCore::BitmapImage::internalAdvanceAnimation): Assert the current frame is not being decoding asynchronously for any size.
3683         (WebCore::BitmapImage::frameImageAtIndex): Deleted. Moved to the header file but with a new purpose: return
3684         the current frame from the frame cache as is; do not cache a new one.
3685         (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImage): Deleted. Function was renamed to shouldUseAsyncDecodingForLargeImages.
3686         (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImage): Deleted. Function was renamed to shouldUseAsyncDecodingForAnimatedImages.
3687         * platform/graphics/BitmapImage.h:
3688         * platform/graphics/CrossfadeGeneratedImage.cpp:
3689         (WebCore::CrossfadeGeneratedImage::draw): Add a new argument of type DecodingMode.
3690         * platform/graphics/CrossfadeGeneratedImage.h:
3691         * platform/graphics/DecodingOptions.h: Added.
3692         (WebCore::DecodingOptions::DecodingOptions): Default constructor: Synchronous mode.
3693         (WebCore::DecodingOptions::operator==): Compares two DecodingOptions for equality.
3694         (WebCore::DecodingOptions::isSynchronous): Is the frame decoded synchronously?
3695         (WebCore::DecodingOptions::isAsynchronous): Is the frame decoded asynchronously?
3696         (WebCore::DecodingOptions::isAsynchronousCompatibleWith): Is this DecodingOptions compatible with another one?
3697         (WebCore::DecodingOptions::hasFullSize): Is the decoding mode asynchronous but for the image full size?
3698         (WebCore::DecodingOptions::hasSizeForDrawing): Is this decoding mode asynchronous but for a sizeForDrawing?
3699         (WebCore::DecodingOptions::sizeForDrawing): Returns the sizeForDrawing. m_decodingModeOrSize has to hold an IntSize.
3700         (WebCore::DecodingOptions::maxDimension): Moved form ImageFrame.cpp.
3701         (WebCore::DecodingOptions::has): A helper function.
3702         (WebCore::DecodingOptions::hasDecodingMode): Does m_decodingModeOrSize a DecodingMode?
3703         (WebCore::DecodingOptions::hasSize): Does m_decodingModeOrSize an IntSize?
3704         * platform/graphics/GeneratedImage.h: Add a new argument of type DecodingMode.
3705         * platform/graphics/GradientImage.cpp:
3706         (WebCore::GradientImage::draw): Ditto.
3707         * platform/graphics/GradientImage.h: Ditto.
3708         * platform/graphics/GraphicsContext.cpp:
3709         (WebCore::GraphicsContext::drawImage): Pass the ImagePaintingOptions::m_DecodingMode to Image::draw().
3710         * platform/graphics/GraphicsContext.h:
3711         (WebCore::ImagePaintingOptions::ImagePaintingOptions): Add a new member of type DecodingMode to ImagePaintingOptions.
3712         * platform/graphics/Image.cpp:
3713         (WebCore::Image::drawTiled): Pass DecodingMode::Synchronous to Image::draw().
3714         * platform/graphics/Image.h: Add a new argument of type DecodingMode to Image::draw().
3715         * platform/graphics/ImageFrame.cpp:
3716         (WebCore::ImageFrame::operator=): Replace m_sizeForDrawing by m_decodingOptions.
3717         (WebCore::ImageFrame::hasNativeImage): Check if m_nativeImage is valid and the subsamplingLevels match.
3718         (WebCore::ImageFrame::hasFullSizeNativeImage): Checks hasNativeImage() and whether the image frame was
3719         decoded for the image full size.
3720         (WebCore::ImageFrame::hasDecodedNativeImageCompatibleWithOptions): Checks hasNativeImage() and the DecodingOptions match.
3721         (WebCore::maxDimension): Deleted. Moved to DecodingOptions.h.
3722         (WebCore::ImageFrame::isBeingDecoded): Deleted. The check for having an ImageFrame being decoded is
3723         moved to ImageFrameCache.
3724         (WebCore::ImageFrame::hasValidNativeImage): Deleted. No need to this function.
3725         * platform/graphics/ImageFrame.h:
3726         (WebCore::ImageFrame::hasNativeImage): Add an std::optional<SubsamplingLevel> argument.
3727         (WebCore::ImageFrame::hasFullSizeNativeImage): Checks whether the ImageFrame was decoded for the image full size.
3728         (WebCore::ImageFrame::enqueueSizeForDecoding): Deleted.
3729         (WebCore::ImageFrame::dequeueSizeForDecoding): Deleted.
3730         (WebCore::ImageFrame::clearSizeForDecoding): Deleted.
3731         (WebCore::ImageFrame::isBeingDecoded): Deleted.
3732         (WebCore::ImageFrame::sizeForDrawing): Deleted.
3733         (WebCore::ImageFrame::hasDecodedNativeImage): Deleted.
3734         The logic of knowing whether an ImageFrame is being decoded is moved to ImageFrameCache.
3735         * platform/graphics/ImageFrameCache.cpp:
3736         (WebCore::ImageFrameCache::cacheFrameMetadataAtIndex): Caches the metadata of an ImageFrame. If the NativeImage
3737         was decoded for a sizeForDrawing, the size of the ImageFrame will be the nativeImageSize(). Otherwise, the
3738         frameSizeAtIndex() will be called.
3739         (WebCore::ImageFrameCache::cacheFrameNativeImageAtIndex): Cache a new NativeImage which involves caching new
3740         metadata and updating the memory cache. No need to check if the existing native image is valid or not for the
3741         DecodingOptions. Actually it would be a bug if it happens. This is why cacheNativeImageForFrameRequest() asserts
3742         !frame.hasAsyncNativeImage() before calling cacheFrameNativeImageAtIndex().
3743         (WebCore::ImageFrameCache::cacheAsyncFrameNativeImageAtIndex): Cache new NativeImage which was decoded asynchronously.
3744         (WebCore::ImageFrameCache::startAsyncDecodingQueue): Call cacheAsyncFrameNativeImageAtIndex() instead of
3745         cacheNativeImageForFrameRequest() for clarity.
3746         (WebCore::ImageFrameCache::requestFrameAsyncDecodingAtIndex): Call hasAsyncNativeImage() instead of hasValidNativeImage()
3747         Call frameIsDecodingCompatibleWithOptionsAtIndex() instead of frame.isBeingDecoded(). Replace the call to enqueueSizeForDecoding()
3748         by appending the same ImageFrameRequest to m_frameCommitQueue.
3749         (WebCore::ImageFrameCache::isAsyncDecodingQueueIdle): Use m_frameCommitQueue to answer the question whether the decodingQueue is idle.
3750         (WebCore::ImageFrameCache::stopAsyncDecodingQueue): Use m_frameCommitQueue to loop through all the ImageFrames which are currently being decoded.
3751         (WebCore::ImageFrameCache::frameAtIndexCacheIfNeeded): For getting the metadata, this function needs a valid frame. If it is requested
3752         to decode the nativeImage, it has to do it synchronously.
3753         (WebCore::ImageFrameCache::singlePixelSolidColor): Don't cache the frame if it is an animated image or the size is not a single pixel.
3754         (WebCore::ImageFrameCache::frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex): Use m_frameCommitQueue to answer the question whether an ImageFrame
3755         is being decoded and is compatible with DecodingOptions.
3756         (WebCore::ImageFrameCache::frameHasFullSizeNativeImageAtIndex): Calls ImageFrame::hasFullNativeImage() for a frame. 
3757         (WebCore::ImageFrameCache::frameHasDecodedNativeImageCompatibleWithOptionsAtIndex): Calls ImageFrame::hasDecodedNativeImageCompatibleWithOptions() for a frame.
3758         (WebCore::ImageFrameCache::frameImageAtIndex): Returns the current NativeImage without caching.
3759         (WebCore::ImageFrameCache::frameImageAtIndexCacheIfNeeded): Returns the current NativeImage but cache it synchronously if needed.
3760         (WebCore::ImageFrameCache::setFrameNativeImageAtIndex): Deleted.
3761         (WebCore::ImageFrameCache::setFrameMetadataAtIndex): Deleted.
3762         (WebCore::ImageFrameCache::replaceFrameNativeImageAtIndex): Deleted.
3763         (WebCore::ImageFrameCache::frameIsBeingDecodedAtIndex): Deleted.
3764         (WebCore::ImageFrameCache::frameHasImageAtIndex): Deleted.
3765         (WebCore::ImageFrameCache::frameHasValidNativeImageAtIndex): Deleted.
3766         (WebCore::ImageFrameCache::frameHasDecodedNativeImage): Deleted.
3767         * platform/graphics/ImageFrameCache.h: Two ImageFrameRequest queues will be used.
3768         -- The existing one m_frameRequestQueue which is shared between the main thread and decoding thread. The requests will be
3769         dequeued from it before starting the decoding. The decoded NativeImage will be cached only on the main thread. The decoding
3770         thread is not blocked by the callOnMainThread(). This means there might be multiple ImageFrameRequests which were dequeued
3771         while their NativeImages have not been cached yet.
3772         -- A new one m_frameCommitQueue which is track all the ImageFrameRequests whose NativeImages have not been cached yet.
3773         (WebCore::ImageFrameCache::frameAtIndexCacheIfNeeded): Be explicit about caching the image frame. frameImageAtIndex()
3774         returns the current image frame without caching. frameAtIndexCacheIfNeeded(). returns the current image frame but cache
3775         it if needed.
3776         (WebCore::ImageFrameCache::ImageFrameRequest::operator==): Compares two ImageFrameRequests for equality.
3777         * platform/graphics/ImageSource.cpp:
3778         (WebCore::ImageSource::frameImageAtIndexCacheIfNeeded): 
3779         (WebCore::ImageSource::frameImageAtIndex): Deleted.
3780         * platform/graphics/ImageSource.h:
3781         (WebCore::ImageSource::requestFrameAsyncDecodingAtIndex): Change the type of the argument from IntSize to be const std::optional<IntSize>.
3782         (WebCore::ImageSource::frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex): Rename of frameIsBeingDecodedAtIndex(). Replace the argument of type
3783         std::optional<IntSize> by an argument of type DecodingOptions.
3784         (WebCore::ImageSource::frameHasFullSizeNativeImageAtIndex): A wrapper around the ImageFrameCache function.
3785         (WebCore::ImageSource::frameHasDecodedNativeImageCompatibleWithOptionsAtIndex): Ditto.
3786         (WebCore::ImageSource::frameImageAtIndex): Ditto.
3787         (WebCore::ImageSource::frameIsBeingDecodedAtIndex): Deleted.
3788         (WebCore::ImageSource::frameHasValidNativeImageAtIndex): Deleted.
3789         (WebCore::ImageSource::frameHasDecodedNativeImage): Deleted.
3790         * platform/graphics/NamedImageGeneratedImage.cpp:
3791         (WebCore::NamedImageGeneratedImage::draw): Add a new argument of type DecodingMode.
3792         * platform/graphics/NamedImageGeneratedImage.h: Ditto.
3793         * platform/graphics/cairo/ImageBufferCairo.cpp:
3794         (WebCore::ImageBuffer::draw): Add a new argument of type DecodingMode.
3795         * platform/graphics/cg/ImageDecoderCG.cpp:
3796         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument. Add a new handling
3797         for decoding asynchronously for the image full size.
3798         * platform/graphics/cg/ImageDecoderCG.h: Change the prototype of the function.
3799         * platform/graphics/cg/PDFDocumentImage.cpp:
3800         (WebCore::PDFDocumentImage::draw): Add a new argument of type DecodingMode.
3801         * platform/graphics/cg/PDFDocumentImage.h:
3802         * platform/graphics/win/ImageCGWin.cpp:
3803         (WebCore::BitmapImage::getHBITMAPOfSize): Pass DecodingMode::Synchronous to Image::draw().
3804         (WebCore::BitmapImage::drawFrameMatchingSourceSize): Ditto.
3805         * platform/graphics/win/ImageDecoderDirect2D.cpp:
3806         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument.
3807         * platform/graphics/win/ImageDecoderDirect2D.h: Change the prototype of the function.
3808         * platform/image-decoders/ImageDecoder.cpp: 
3809         (WebCore::ImageDecoder::createFrameImageAtIndex): Replace the sizeForDrawing argument by a DecodingMode argument.
3810         * platform/image-decoders/ImageDecoder.h: Change the prototype of the function.
3811         * rendering/RenderBoxModelObject.cpp:
3812         (WebCore::RenderBoxModelObject::paintFillLayerExtended): Draw the background image asynchronously if the image size is large.
3813         * rendering/RenderImage.cpp:
3814         (WebCore::RenderImage::paintIntoRect): Draw the background image element asynchronously if the image size is large.
3815         * svg/graphics/SVGImage.cpp:
3816         (WebCore::SVGImage::drawForContainer): Pass DecodingMode::Synchronous to draw().
3817         (WebCore::SVGImage::nativeImageForCurrentFrame): Ditto.
3818         (WebCore::SVGImage::nativeImage): Ditto.
3819         (WebCore::SVGImage::draw): Add a new argument of type DecodingMode.
3820         * svg/graphics/SVGImage.h: Change the prototype of the function.
3821         * svg/graphics/SVGImageForContainer.cpp:
3822         (WebCore::SVGImageForContainer::draw): Add a new argument of type DecodingMode.
3823         * svg/graphics/SVGImageForContainer.h: Change the prototype of the function.
3824
3825 2017-03-27  Youenn Fablet  <youenn@apple.com>
3826
3827         Activate release libwebrtc logging when WebRTC log channel is on
3828         https://bugs.webkit.org/show_bug.cgi?id=169659
3829
3830         Reviewed by Alex Christensen.
3831
3832         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
3833         (WebCore::initializePeerConnectionFactoryAndThreads):
3834
3835 2017-03-27  Antti Koivisto  <antti@apple.com>
3836
3837         Move visibleInViewportStateChanged callback from Element to render tree
3838         https://bugs.webkit.org/show_bug.cgi?id=170039
3839
3840         Reviewed by Zalan Bujtas.
3841
3842         Make it easier to use from the render tree.
3843
3844         Also for simplicity move the bits from RenderObject rare data to RenderElement.
3845         There is plenty of space there.
3846
3847         * dom/Element.h:
3848         (WebCore::Element::isVisibleInViewportChanged): Deleted.
3849         * html/HTMLMediaElement.h:
3850         * rendering/RenderElement.cpp:
3851         (WebCore::RenderElement::RenderElement):
3852         (WebCore::RenderElement::willBeDestroyed):
3853         (WebCore::RenderElement::registerForVisibleInViewportCallback):
3854         (WebCore::RenderElement::unregisterForVisibleInViewportCallback):
3855         (WebCore::RenderElement::setVisibleInViewportState):
3856         (WebCore::RenderElement::visibleInViewportStateChanged):
3857         * rendering/RenderElement.h:
3858         (WebCore::RenderElement::visibleInViewportState):
3859         * rendering/RenderObject.cpp:
3860         (WebCore::RenderObject::setIsRegisteredForVisibleInViewportCallback): Deleted.
3861         (WebCore::RenderObject::setVisibleInViewportState): Deleted.
3862         * rendering/RenderObject.h:
3863         (WebCore::RenderObject::hasOutlineAutoAncestor):
3864         (WebCore::RenderObject::RenderObjectRareData::RenderObjectRareData):
3865         (WebCore::RenderObject::isRegisteredForVisibleInViewportCallback): Deleted.
3866         (WebCore::RenderObject::visibleInViewportState): Deleted.
3867         * rendering/RenderVideo.cpp:
3868         (WebCore::RenderVideo::visibleInViewportStateChanged):
3869         * rendering/RenderVideo.h:
3870         * rendering/RenderView.cpp:
3871         (WebCore::RenderView::updateVisibleViewportRect):
3872
3873 2017-03-27  Youenn Fablet  <youenn@apple.com>
3874
3875         addIceCandidate should not throw if passed null or undefined
3876         https://bugs.webkit.org/show_bug.cgi?id=170118
3877
3878         Reviewed by Eric Carlson.
3879
3880         Covered by updated test.
3881
3882         A null/undefined candidate passed to addIceCandidate means end of Ice candidate..
3883
3884         * Modules/mediastream/PeerConnectionBackend.cpp:
3885         (WebCore::PeerConnectionBackend::addIceCandidate):
3886         * Modules/mediastream/PeerConnectionBackend.h:
3887         (WebCore::PeerConnectionBackend::endOfIceCandidates):
3888         * Modules/mediastream/RTCPeerConnection.cpp:
3889         (WebCore::RTCPeerConnection::queuedAddIceCandidate):
3890         * Modules/mediastream/RTCPeerConnection.h:
3891         * Modules/mediastream/RTCPeerConnection.idl:
3892         * Modules/mediastream/RTCPeerConnection.js:
3893         (addIceCandidate):
3894
3895 2017-03-27  Antti Koivisto  <antti@apple.com>
3896
3897         Allow the page to render before <link> stylesheet tags in body
3898         https://bugs.webkit.org/show_bug.cgi?id=149157
3899         <rdar://problem/24658830>
3900
3901         Reviewed by Simon Fraser.
3902
3903         Currently we block style and renderer building completely if document has any loading
3904         stylesheets. In case a script queries something layout dependent we construct the render
3905         tree with whatever style we have but block painting in it.
3906
3907         This patch changes behavior so that a loading stylesheet in body only blocks rendering for elements
3908         that are after it. The expectation is that such stylesheets rarely affect elements before them
3909         and the elements can be rendered without causing ugly visible styling changes.
3910
3911         The patch replaces the old flash-of-unstyled-content (FOUC) preventation mechanism with a more
3912         fine-grained one. Paint blocking is now done on per-renderer basis with based on isNonFinal flag in
3913         RenderStyle.
3914
3915         For stylesheets in head the behavior should be largely unchanged.
3916
3917         Test: http/tests/incremental/stylesheet-body-incremental-rendering.html
3918
3919         * css/StyleResolver.cpp:
3920         (WebCore::StyleResolver::pseudoStyleRulesForElement):
3921         * dom/Document.cpp:
3922         (WebCore::Document::Document):
3923         (WebCore::Document::resolveStyle):
3924         (WebCore::Document::updateLayoutIgnorePendingStylesheets):
3925
3926             Remove the old FOUC preventation state tracking.
3927
3928         (WebCore::Document::shouldScheduleLayout):
3929         (WebCore::Document::didRemoveAllPendingStylesheet):
3930
3931             Repaints will now get triggered by the normal style mechanism.
3932
3933         * dom/Document.h:
3934         (WebCore::Document::hasNodesWithNonFinalStyle):
3935         (WebCore::Document::setHasNodesWithNonFinalStyle):
3936
3937             Track if we need to recompute the style later because non-final or unstyled elements.
3938
3939         (WebCore::Document::didLayoutWithPendingStylesheets): Deleted.
3940         (WebCore::Document::hasNodesWithPlaceholderStyle): Deleted.
3941         (WebCore::Document::setHasNodesWithPlaceholderStyle): Deleted.
3942         * html/HTMLFrameSetElement.cpp:
3943         (WebCore::HTMLFrameSetElement::rendererIsNeeded):
3944         * page/FrameView.cpp:
3945         (WebCore::FrameView::qualifiesAsVisuallyNonEmpty):
3946
3947             Don't qualify as visually non-empty if we have loading stylesheets in head (even if there is
3948             a fouc-prevented render tree).
3949
3950         (WebCore::FrameView::fireLayoutRelatedMilestonesIfNeeded):
3951         * rendering/RenderBlock.cpp:
3952         (WebCore::RenderBlock::paintContents):
3953
3954             Instead of a global test, block painting if isNonFinal is set in the renderer's style.
3955
3956         * rendering/RenderLayer.cpp:
3957         (WebCore::shouldSuppressPaintingLayer):
3958         * rendering/style/RenderStyle.cpp:
3959         (WebCore::RenderStyle::changeRequiresRepaint):
3960
3961             The isNonFinal flag prevents painting so we need to trigger repaint when it gets cleared.
3962
3963         * rendering/style/RenderStyle.h:
3964         (WebCore::RenderStyle::isNotFinal):
3965         (WebCore::RenderStyle::setIsNotFinal):
3966         (WebCore::RenderStyle::isPlaceholderStyle): Deleted.
3967         (WebCore::RenderStyle::setIsPlaceholderStyle): Deleted.
3968
3969             There is no need for placeholder styles anymore. Reuse the bit for isNotFinal.
3970
3971         * rendering/style/StyleRareNonInheritedData.cpp:
3972         (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
3973         (WebCore::StyleRareNonInheritedData::operator==):
3974         * rendering/style/StyleRareNonInheritedData.h:
3975         * style/StyleScope.cpp:
3976         (WebCore::Style::Scope::analyzeStyleSheetChange):
3977         (WebCore::Style::Scope::updateActiveStyleSheets):
3978         * style/StyleTreeResolver.cpp:</