f56621cef17339eea7f42d33fc01aae8f728f7fd
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2018-07-24  Antoine Quint  <graouts@apple.com>
2
3         [Web Animations] Crash when setting "animation: none" after clearing an animation's effect
4         https://bugs.webkit.org/show_bug.cgi?id=187952
5
6         Reviewed by Dean Jackson.
7
8         Test: webanimations/setting-css-animation-none-after-clearing-effect.html
9
10         We need to ensure that the animation we're trying to remove has not had its effect cleared via the
11         Web Animations API since its creation before trying to check its phase.
12
13         * animation/AnimationTimeline.cpp:
14         (WebCore::AnimationTimeline::cancelOrRemoveDeclarativeAnimation):
15
16 2018-07-24  Antoine Quint  <graouts@apple.com>
17
18         [Web Animations] Crash accessing CSSAnimation::bindingsCurrentTime when effect has been set to null
19         https://bugs.webkit.org/show_bug.cgi?id=187950
20         <rdar://problem/42515747>
21
22         Reviewed by Dean Jackson.
23
24         Test: webanimations/accessing-current-time-after-clearing-css-animation-effect.html
25
26         While a CSSAnimation has an effect created for it by the implementation, the developer may yet manipulate
27         its effect via the Web Animations API and set it to null. As such, we must not assume it's always non-null.
28
29         * animation/CSSAnimation.cpp:
30         (WebCore::CSSAnimation::bindingsCurrentTime const):
31
32 2018-07-24  Zalan Bujtas  <zalan@apple.com>
33
34         [LFC][IFC] BlockContainer::establishesInlineFormattingContext should only check the first inflow child.
35         https://bugs.webkit.org/show_bug.cgi?id=187965
36
37         Reviewed by Antti Koivisto.
38
39         * layout/layouttree/LayoutBlockContainer.cpp:
40         (WebCore::Layout::BlockContainer::establishesInlineFormattingContext const):
41
42 2018-07-24  Myles C. Maxfield  <mmaxfield@apple.com>
43
44         [Cocoa] Stop crashing in lastResortFallbackFont()
45         https://bugs.webkit.org/show_bug.cgi?id=187936
46
47         Reviewed by Jon Lee.
48
49         CoreText can get into a state where both Times and Lucida Grande are inaccessible.
50         Instead of crashing, we should use the real LastResort, which is backed by a section
51         in the .rodata of the CoreText dylib, and as such should always exist.
52
53         * platform/graphics/FontCache.cpp:
54         (WebCore::FontCache::fontForFamily):
55         * platform/graphics/cocoa/FontCacheCoreText.cpp:
56         (WebCore::FontCache::lastResortFallbackFont):
57
58 2018-07-24  Daniel Bates  <dabates@apple.com>
59
60         Cannot view PDF's on my.gov.au: "Refused to load https://my.gov.au/attachment/viewAttachment because it
61         appears in neither the object-src directive nor the default-src directive of the Content Security Policy"
62         https://bugs.webkit.org/show_bug.cgi?id=187870
63         <rdar://problem/41190880>
64
65         Reviewed by Dean Jackson.
66
67         Fixes an issue where opening attachments on my.gov.au would show a "Blocked Plug-in" message.
68
69         Opening an attachment on my.gov.au opens a same-origin plugin document in a child window. Currently
70         same-origin plugin documents inherit their CSP policy from their opener. If the opener's CSP policy
71         disallows embedding plugins then the plugin document would be blocked from loading a plugin. For now
72         we relax the inheritance model such that we only inherit the plugin-types and report-uri directives
73         from the opener.
74
75         Developers that want to block plugin content from being loaded in a same-origin child window must now
76         serve such plugin content with a CSP policy that includes "object-src 'none'". This matches the behavior
77         described in the second Note in section object-src of the CSP 3 spec: <https://w3c.github.io/webappsec-csp/#directive-object-src>
78         (Editor's Draft, 10 July 2018). It also makes the behavior in WebKit more closely aligned with the
79         behavior of Chrome and Firefox.
80
81         Tests: http/tests/security/contentSecurityPolicy/same-origin-plugin-document-allowed-in-child-window.html
82                http/tests/security/contentSecurityPolicy/same-origin-plugin-document-blocked-in-child-window-report.php
83                http/tests/security/contentSecurityPolicy/same-origin-plugin-document-with-csp-blocked-in-child-window.html
84
85         * dom/Document.cpp:
86         (WebCore::Document::initContentSecurityPolicy): For plugin documents that have an opener call ContentSecurityPolicy::createPolicyForPluginDocumentFrom()
87         to only inherit the plugin-types and report-uri directives from its opener's CSP policy. Otherwise, call ContentSecurityPolicy::copyStateFrom()
88         to inherit all directives from the owner frame as we do now.
89         * page/csp/ContentSecurityPolicy.cpp:
90         (WebCore::ContentSecurityPolicy::createPolicyForPluginDocumentFrom): Create a new policy from the specified policy
91         inheriting only the plugin-types and report-uri directives.
92         * page/csp/ContentSecurityPolicy.h: Define a new PolicyFrom enumerator, InheritedForPluginDocument, for plugin documents
93         loaded in a child window.
94         * page/csp/ContentSecurityPolicyDirectiveList.cpp:
95         (WebCore::ContentSecurityPolicyDirectiveList::parse): When policyFrom is InheritedForPluginDocument then only
96         recognize the plugin-types and report-uri directives when parsing the policy.
97
98 2018-07-24  Daniel Bates  <dabates@apple.com>
99
100         Rename Document::firstPartyForSameSiteCookies() to siteForCookies()
101         https://bugs.webkit.org/show_bug.cgi?id=187892
102
103         Reviewed by Dean Jackson.
104
105         Standardize on the spec. language "site for cookies" for the names of the setter and getter
106         on Document. The latest description of Same-Site cookies is in <https://httpwg.org/http-extensions/rfc6265bis.html>.
107
108         No functionality changed. So, no new tests.
109
110         * dom/Document.h:
111         (WebCore::Document::siteForCookies const):
112         (WebCore::Document::setSiteForCookies):
113         (WebCore::Document::firstPartyForSameSiteCookies const): Deleted.
114         (WebCore::Document::setFirstPartyForSameSiteCookies): Deleted.
115         * loader/FrameLoader.cpp:
116         (WebCore::FrameLoader::setFirstPartyForCookies):
117         (WebCore::FrameLoader::addSameSiteInfoToRequestIfNeeded):
118         * workers/service/context/ServiceWorkerThreadProxy.cpp:
119         (WebCore::createPageForServiceWorker):
120         * xml/XSLTProcessor.cpp:
121         (WebCore::XSLTProcessor::createDocumentFromSource):
122
123 2018-07-24  Ross Kirsling  <ross.kirsling@sony.com>
124
125         WebCore::URL::hostIsIPAddress needs a Windows implementation
126         https://bugs.webkit.org/show_bug.cgi?id=187859
127
128         Reviewed by Fujii Hironori.
129
130         * platform/URL.cpp:
131         (WebCore::isIPv4Address): Added.
132         (WebCore::isIPv6Address): Added.
133         (WebCore::URL::hostIsIPAddress):
134         Turn this stub into a platform-agnostic default implementation.
135
136 2018-07-24  Eric Carlson  <eric.carlson@apple.com>
137
138         [MediaStream] Restructure getDisplayMedia classes
139         https://bugs.webkit.org/show_bug.cgi?id=187905
140
141         Reviewed by Dean Jackson.
142
143         No new tests, no functional changes.
144
145         * platform/mediastream/CaptureDeviceManager.h:
146         (WebCore::CaptureDeviceManager::refreshCaptureDevices): Deleted, no need for it to be a 
147         virtual method.
148         * platform/mediastream/mac/AVCaptureDeviceManager.h:
149
150         * platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.h: refreshCaptureDevices is
151         no longer virtual.
152
153         * platform/mediastream/mac/DisplayCaptureManagerCocoa.cpp:
154         (WebCore::DisplayCaptureManagerCocoa::captureDevices):
155         (WebCore::DisplayCaptureManagerCocoa::updateDisplayCaptureDevices): Moved functionality 
156         to ScreenDisplayCaptureSourceMac.
157         (WebCore::DisplayCaptureManagerCocoa::screenCaptureDeviceWithPersistentID): Ditto.
158         (WebCore::displayReconfigurationCallBack): Deleted, moved to ScreenDisplayCaptureSourceMac.
159         (WebCore::DisplayCaptureManagerCocoa::~DisplayCaptureManagerCocoa): Deleted.
160         (WebCore::DisplayCaptureManagerCocoa::refreshCaptureDevices): Deleted.
161         * platform/mediastream/mac/DisplayCaptureManagerCocoa.h:
162
163         * platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
164         (WebCore::roundUpToMacroblockMultiple): Moved from ScreenDisplayCaptureSourceMac.
165         (WebCore::DisplayCaptureSourceCocoa::applySize): Ditto.
166         (WebCore::DisplayCaptureSourceCocoa::sampleBufferFromPixelBuffer): Ditto.
167         (WebCore::DisplayCaptureSourceCocoa::pixelBufferFromIOSurface): Ditto.
168         * platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
169
170         * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h:
171         * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm:
172         (WebCore::updateDisplayID):
173         (WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream): Fix log message.
174         (WebCore::ScreenDisplayCaptureSourceMac::startDisplayStream): Ditto.
175         (WebCore::ScreenDisplayCaptureSourceMac::applySize): Update for base class changes.
176         (WebCore::ScreenDisplayCaptureSourceMac::applyFrameRate): Ditto.
177         (WebCore::ScreenDisplayCaptureSourceMac::frameAvailable): Ditto.
178         (WebCore::ScreenDisplayCaptureSourceMac::screenCaptureDeviceWithPersistentID): Moved from
179         DisplayCaptureManagerCocoa.
180         (WebCore::ScreenDisplayCaptureSourceMac::screenCaptureDevices): Ditto.
181         (WebCore::roundUpToMacroblockMultiple): Moved to DisplayCaptureSourceCocoa.
182         (WebCore::ScreenDisplayCaptureSourceMac::updateDisplayID): Ditto.
183         (WebCore::ScreenDisplayCaptureSourceMac::sampleBufferFromPixelBuffer): Ditto.
184         (WebCore::ScreenDisplayCaptureSourceMac::pixelBufferFromIOSurface): Ditto.
185
186 2018-07-24  Zalan Bujtas  <zalan@apple.com>
187
188         [LFC] Move geometry data structures to a dedicated file
189         https://bugs.webkit.org/show_bug.cgi?id=187939
190
191         Reviewed by Antti Koivisto.
192
193         * WebCore.xcodeproj/project.pbxproj:
194         * layout/FormattingContext.h:
195         (WebCore::Layout::FormattingContext::Geometry::Position::operator LayoutPoint const): Deleted.
196         * layout/FormattingContextGeometry.cpp:
197         (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry):
198         (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
199         (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
200         (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
201         (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin):
202         (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
203         (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin):
204         (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin):
205         (WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry):
206         (WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
207         (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
208         (WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
209         (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
210         (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
211         (WebCore::Layout::FormattingContext::Geometry::computedBorder):
212         (WebCore::Layout::FormattingContext::Geometry::computedPadding):
213         (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue):
214         (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue):
215         * layout/blockformatting/BlockFormattingContext.h:
216         * layout/blockformatting/BlockFormattingContextGeometry.cpp:
217         (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
218         (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
219         (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin):
220         (WebCore::Layout::BlockFormattingContext::Geometry::staticPosition):
221         (WebCore::Layout::BlockFormattingContext::Geometry::inFlowPositionedPosition):
222         (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
223         (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):
224         * layout/displaytree/DisplayBox.h:
225         (WebCore::Display::Box::setHorizontalMargin):
226         (WebCore::Display::Box::setVerticalMargin):
227         (WebCore::Display::Box::setVerticalNonCollapsedMargin):
228         (WebCore::Display::Box::setBorder):
229         (WebCore::Display::Box::setPadding):
230
231 2018-07-24  Thibault Saunier  <tsaunier@igalia.com>
232
233         [GStreamer] Implement bitrate modulation support in GStreamer based libwebrtc Encoders
234         https://bugs.webkit.org/show_bug.cgi?id=187643
235
236         Reviewed by Philippe Normand.
237
238         Problem being that we do not have a proper unified encoder API in GStreamer, some work
239         started at https://bugzilla.gnome.org/show_bug.cgi?id=796716 but it is quite controversial
240         and meanwhile we should just move forward working around that limitation.
241
242         Source/WebCore:
243         * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
244         (WebCore::GStreamerVideoEncoder::GStreamerVideoEncoder):
245         (WebCore::GStreamerVideoEncoder::InitEncode):
246         (WebCore::GStreamerVideoEncoder::getBitrateSetter):
247         (WebCore::GStreamerVideoEncoder::createEncoder):
248         (WebCore::GStreamerVideoEncoder::AddCodecIfSupported):
249         (WebCore::GStreamerVideoEncoder::SetRestrictionCaps):
250         (WebCore::GStreamerVideoEncoder::CreateEncoder): Deleted.
251
252 2018-07-24  Zan Dobersek  <zdobersek@igalia.com>
253
254         REGRESSION(r234055): inverted return values in MediaPlayer::wouldTaintOrigin()
255         https://bugs.webkit.org/show_bug.cgi?id=187944
256
257         Reviewed by Carlos Garcia Campos.
258
259         The MediaPlayer::wouldTaintOrigin(), as introduced in r234055, should
260         return false when the URL protocol is `data:`, and should return true
261         when the given SecurityOrigin cannot access the media URL.
262
263         This matches behavior of CanvasRenderingContext::wouldTaintOrigin()
264         which the new method falls back to when the MediaPlayerPrivate
265         implementation doesn't or can't determine the would-taint result.
266
267         This fixes a bunch of failing and timing-out WebGL test cases on ports
268         using GStreamer (on which the MediaPlayerPrivate derivate doesn't
269         implement the wouldTaintOrigin() method).
270
271         * platform/graphics/MediaPlayer.cpp:
272         (WebCore::MediaPlayer::wouldTaintOrigin const):
273
274 2018-07-24  Zan Dobersek  <zdobersek@igalia.com>
275
276         [TextureMapper] Separate repaint counter state from debug visuals
277         https://bugs.webkit.org/show_bug.cgi?id=187946
278
279         Reviewed by Carlos Garcia Campos.
280
281         Instead of managing the repaint counter visibility along with the
282         debug border visuals, do that together with the repaint count value.
283
284         TextureMapperLayer::setRepaintCount() is renamed to setRepaintCounter()
285         and now also sets the repaint counter visibility state instead of the
286         setDebugVisuals() method.
287
288         GraphicsLayerTextureMapper implementation is adjusted appropriately.
289         The unused setRepaintCount() method is also removed.
290
291         CoordinatedGraphicsLayerState now holds repaint counter state (both
292         visibility and count value) in a struct that's separate from debug
293         border state. CoordinatedGraphicsLayer implementation now updates
294         that state accordingly.
295
296         No new tests -- no change in behavior.
297
298         * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
299         (WebCore::GraphicsLayerTextureMapper::setShowRepaintCounter):
300         (WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
301         (WebCore::GraphicsLayerTextureMapper::setRepaintCount): Deleted.
302         * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
303         * platform/graphics/texmap/TextureMapperLayer.cpp:
304         (WebCore::TextureMapperLayer::setDebugVisuals):
305         (WebCore::TextureMapperLayer::setRepaintCounter):
306         (WebCore::TextureMapperLayer::setRepaintCount): Deleted.
307         * platform/graphics/texmap/TextureMapperLayer.h:
308         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
309         (WebCore::CoordinatedGraphicsLayer::didUpdateTileBuffers):
310         (WebCore::CoordinatedGraphicsLayer::setShowRepaintCounter):
311         (WebCore::CoordinatedGraphicsLayer::syncLayerState):
312         * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
313         (WebCore::CoordinatedGraphicsLayerState::CoordinatedGraphicsLayerState):
314         (WebCore::DebugVisuals::DebugVisuals): Deleted.
315
316 2018-07-24  Thibault Saunier  <tsaunier@igalia.com>
317
318         [WPE][GTK] Implement PeerConnection API on top of libwebrtc
319         https://bugs.webkit.org/show_bug.cgi?id=186932
320
321         Reviewed by Philippe Normand.
322
323         Enabled many webrtc tests.
324
325         * platform/GStreamer.cmake: Build new files
326         * platform/graphics/gstreamer/GStreamerCommon.cpp: Fix minor style issues
327         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: Add a way to give precise name to pipelines
328         and give useful names to pipelines with sources comming from a PeerConnection
329         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Ditto.
330         * platform/mediastream/gstreamer/GStreamerVideoFrameLibWebRTC.cpp: Added. Implement a subclass of webrtc::VideoFrame
331         to represent a kNative GStreamer video frame.
332         * platform/mediastream/gstreamer/GStreamerVideoFrameLibWebRTC.h: Added. Ditto.
333         * platform/mediastream/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp: Handle incoming audio samples from libwebrtc.
334         * platform/mediastream/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.h: Ditto.
335         * platform/mediastream/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.cpp: Handle incoming video frames from libwebrtc.
336         * platform/mediastream/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.h: Ditto.
337         * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp: Handle passing locally captured audio sample to libwebrtc.
338         * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h: Ditto.
339         * platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.cpp: Handle passing locally captured vidoe frames to libwebrtc.
340         * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp: Added. Implement a video decoder factory and LibWebRTC Video decoders based on GStreamer.
341         * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.h: Added. Ditto.
342         * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: Added. Implement a video encoder factory and LibWebRTC H264/VP8 Video encoders based on GStreamer.
343         * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.h: Added. Ditto.
344         * platform/mediastream/libwebrtc/LibWebRTCAudioFormat.h: Add information about signness of the LibWebRTC audio format.
345         * platform/mediastream/libwebrtc/LibWebRTCProviderGlib.cpp: Add support for newly added Encoder/Decoder factories.
346         * platform/mediastream/libwebrtc/LibWebRTCProviderGlib.h: Ditto.
347
348 2018-07-24  Dirk Schulze  <krit@webkit.org>
349
350         [css-masking] Black backdrop on -webkit-clip-path on SVG root
351         https://bugs.webkit.org/show_bug.cgi?id=187880
352
353         Reviewed by Simon Fraser.
354
355         For SVG document root elements, we currently clip twice:
356         In RenderLayer and SVGRenderSupport.
357         Avoid clipping in RenderLayer which currently clips before we established a
358         backdrop for an SVG document.
359
360         Tests: svg/clip-path/clip-path-on-svg-005-expected.svg
361                svg/clip-path/clip-path-on-svg-005.svg
362
363         * rendering/RenderLayer.cpp:
364         (WebCore::RenderLayer::setupClipPath): Skip actual clipping.
365
366 2018-07-24  Zan Dobersek  <zdobersek@igalia.com>
367
368         [Nicosia] Add TextureMapperAnimations member to CompositingLayer::LayerState
369         https://bugs.webkit.org/show_bug.cgi?id=187941
370
371         Reviewed by Carlos Garcia Campos.
372
373         Nicosia::CompositingLayer::LayerState gains a TextureMapperAnimations
374         member that will be assigned a list of all active animations during each
375         layer flush. Despite the name, TextureMapperAnimations doesn't depend on
376         any other TextureMapper class. It might be renamed and moved in the
377         future, but for now it's used as-is.
378
379         In CoordinatedGraphicsLayer, the syncAnimations() method now flips on
380         the animationsChanged flag in the LayerState::Delta struct. This causes
381         all the active animations to be copied over into the layer state in
382         flushCompositingStateForThisLayerOnly().
383
384         * platform/graphics/nicosia/NicosiaPlatformLayer.h:
385         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
386         (WebCore::CoordinatedGraphicsLayer::syncAnimations):
387         (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
388
389 2018-07-24  Zan Dobersek  <zdobersek@igalia.com>
390
391         [Nicosia] Add FilterOperations member to CompositionLayer::LayerState
392         https://bugs.webkit.org/show_bug.cgi?id=187901
393
394         Reviewed by Carlos Garcia Campos.
395
396         Nicosia::CompositionLayer::LayerState gains a FilterOperations member
397         that can be assigned the list of filter operations for a given layer.
398         The corresponding filtersChanged boolean is added to LayerState::Delta.
399
400         CoordinatedGraphicsLayer::syncFilters() flips on that delta member,
401         which in turn causes the FilterOperations value to be updated during
402         the layer flush, in flushCompositingStateForThisLayerOnly().
403
404         * platform/graphics/nicosia/NicosiaPlatformLayer.h:
405         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
406         (WebCore::CoordinatedGraphicsLayer::syncFilters):
407         (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
408
409 2018-07-24  Zan Dobersek  <zdobersek@igalia.com>
410
411         [CoordGraphics] Use adjusted position, anchor point, size values for Nicosia::CompositionLayer state
412         https://bugs.webkit.org/show_bug.cgi?id=187899
413
414         Reviewed by Carlos Garcia Campos.
415
416         As is done for the CoordinatedGraphicsLayerState, the scale-adjusted
417         position, anchor point and size values should be used when updating the
418         corresponding Nicosia::CompositionLayer::LayerState members.
419
420         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
421         (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
422
423 2018-07-23  Manuel Rego Casasnovas  <rego@igalia.com>
424
425         [css-grid] Add support for calc() in gutter properties
426         https://bugs.webkit.org/show_bug.cgi?id=187902
427
428         Reviewed by Simon Fraser.
429
430         The parsing was already accepting calc() in grid row and column gaps,
431         however the code was not taking that into account properly.
432         If the calc() had a percentage it was ignored and that's wrong.
433
434         The fix is just a change in the ceck at RenderGrid::availableSpaceForGutters().
435
436         Tests: imported/w3c/web-platform-tests/css/css-grid/abspos/grid-positioned-items-gaps-002-rtl.html
437                imported/w3c/web-platform-tests/css/css-grid/abspos/grid-positioned-items-gaps-002.html
438                imported/w3c/web-platform-tests/css/css-grid/alignment/grid-gutters-011.html
439                imported/w3c/web-platform-tests/css/css-grid/alignment/grid-gutters-012.html
440
441         * rendering/RenderGrid.cpp:
442         (WebCore::RenderGrid::availableSpaceForGutters const):
443
444 2018-07-23  Aditya Keerthi  <akeerthi@apple.com>
445
446         Remove extraneous #endif in html.css
447         https://bugs.webkit.org/show_bug.cgi?id=187934
448
449         Reviewed by Tim Horton.
450
451         * css/html.css: Remove extraneous #endif.
452
453 2018-07-23  Sihui Liu  <sihui_liu@apple.com>
454
455         CrashTracer: com.apple.WebKit.Storage at WebCore: WebCore::encodeKey
456         https://bugs.webkit.org/show_bug.cgi?id=187927
457
458         Reviewed by Chris Dumez.
459
460         IDBKeyData is valid only when each key of it is valid.
461
462         Test: LayoutTests/storage/indexeddb/index-multientry.html
463
464         * Modules/indexeddb/IDBKeyData.cpp:
465         (WebCore::IDBKeyData::isValid const):
466         * Modules/indexeddb/IDBKeyData.h:
467         (WebCore::IDBKeyData::isValid const): Deleted.
468
469 2018-07-23  Ben Richards  <benton_richards@apple.com>
470
471         We should cache the compiled sandbox profile in a data vault
472         https://bugs.webkit.org/show_bug.cgi?id=184991
473
474         Reviewed by Ryosuke Niwa.
475
476         Added functionality to FileHandle so that it can lock a file while open.
477         Added a function to FileSystem to delete non empty directories.
478
479         * platform/FileHandle.cpp:
480         (WebCore::FileHandle::FileHandle):
481         (WebCore::FileHandle::open):
482         (WebCore::FileHandle::close):
483         * platform/FileHandle.h:
484         * platform/FileSystem.h:
485         * platform/cocoa/FileSystemCocoa.mm:
486         (WebCore::FileSystem::deleteNonEmptyDirectory):
487
488 2018-07-23  Justin Fan  <justin_fan@apple.com>
489
490         [macOS] Ensure that WebGL contexts are always set to an accelerated virtual screen
491         https://bugs.webkit.org/show_bug.cgi?id=187923
492
493         Reviewed by Dean Jackson.
494
495         On eGPU displays, it is possible that CGL does not match the preferred renderer. 
496         In this case, and when the web process is blocked from accessing the window server, 
497         3D contexts *may* default to the software renderer. Ensure that even if this occurs,
498         we set the context to use a hardware-accelerated renderer/virtual screen.
499
500         No new tests. Existing behavior covered by existing tests.
501         Requires multiple screens, at least one attached to an eGPU, to stress. 
502
503         * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
504         (WebCore::identifyAndSetCurrentGPU):
505
506 2018-07-23  Sam Weinig  <sam@webkit.org>
507
508         Convert some obvious never-null pointers to references in the editing code
509         https://bugs.webkit.org/show_bug.cgi?id=187914
510
511         Reviewed by Dean Jackson.
512
513         Fixup trivial cases of never-null pointers that really should be references.
514
515         * editing/ApplyStyleCommand.cpp:
516         (WebCore::ApplyStyleCommand::shouldApplyInlineStyleToRun):
517         (WebCore::ApplyStyleCommand::removeInlineStyleFromElement):
518         (WebCore::ApplyStyleCommand::removeImplicitlyStyledElement):
519         (WebCore::ApplyStyleCommand::removeCSSStyle):
520         (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
521         (WebCore::ApplyStyleCommand::applyInlineStyleChange):
522         * editing/EditingStyle.cpp:
523         (WebCore::EditingStyle::overrideWithStyle):
524         (WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
525         (WebCore::EditingStyle::conflictsWithImplicitStyleOfElement const):
526         (WebCore::EditingStyle::conflictsWithImplicitStyleOfAttributes const):
527         (WebCore::EditingStyle::extractConflictingImplicitStyleOfAttributes const):
528         (WebCore::EditingStyle::styleIsPresentInComputedStyleOfNode const):
529         (WebCore::EditingStyle::elementIsStyledSpanOrHTMLEquivalent):
530         (WebCore::EditingStyle::mergeInlineStyleOfElement):
531         (WebCore::EditingStyle::wrappingStyleForSerialization):
532         (WebCore::EditingStyle::legacyFontSize const):
533         (WebCore::StyleChange::StyleChange):
534         (WebCore::StyleChange::extractTextStyles):
535         (WebCore::legacyFontSizeFromCSSValue):
536         * editing/EditingStyle.h:
537         (WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
538         * editing/Editor.cpp:
539         (WebCore::Editor::selectionStartCSSPropertyValue):
540         * editing/ReplaceSelectionCommand.cpp:
541         (WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
542         (WebCore::isInlineNodeWithStyle):
543         * editing/markup.cpp:
544         (WebCore::StyledMarkupAccumulator::appendElement):
545         (WebCore::StyledMarkupAccumulator::serializeNodes):
546
547 2018-07-23  Per Arne Vollan  <pvollan@apple.com>
548
549         WebCore::primaryScreenDisplayID() always return 0
550         https://bugs.webkit.org/show_bug.cgi?id=187922
551         <rdar://problem/42286933>
552
553         Reviewed by Geoffrey Garen.
554
555         This function should return a valid display ID.
556
557         No new tests. Testing this requires a dual monitor setup.
558
559         * platform/mac/PlatformScreenMac.mm:
560         (WebCore::primaryScreenDisplayID):
561
562 2018-07-23  Nan Wang  <n_wang@apple.com>
563
564         AX: Press tab to highlight items on a webpage is not working with voiceover enabled
565         https://bugs.webkit.org/show_bug.cgi?id=187824
566
567         Reviewed by Zalan Bujtas.
568
569         We are deferring posting focused element change notification when the document needs a
570         style recalculation. However, we only perform the cache update after a layout is completed.
571         Added a timer to perform the cache update in the next runloop when non-layout type of mutation
572         happens.
573         
574         Test: accessibility/mac/tab-focus-post-notification.html
575
576         * accessibility/AXObjectCache.cpp:
577         (WebCore::AXObjectCache::AXObjectCache):
578         (WebCore::AXObjectCache::~AXObjectCache):
579         (WebCore::AXObjectCache::deferFocusedUIElementChangeIfNeeded):
580         (WebCore::AXObjectCache::performCacheUpdateTimerFired):
581         * accessibility/AXObjectCache.h:
582         (WebCore::AXObjectCache::AXObjectCache):
583         (WebCore::AXObjectCache::performCacheUpdateTimerFired):
584
585 2018-07-23  Chris Dumez  <cdumez@apple.com>
586
587         WebResourceLoadStatisticsStore fails to unregister itself as a MessageReceiver in its destructor
588         https://bugs.webkit.org/show_bug.cgi?id=187910
589         <rdar://problem/42356526>
590
591         Reviewed by Brent Fulgham.
592
593         Add internals API that causes the ResourceLoadObserver to notify its observer, and avoid waiting
594         for the 5 second delay.
595
596         * testing/Internals.cpp:
597         (WebCore::Internals::notifyResourceLoadObserver):
598         * testing/Internals.h:
599         * testing/Internals.idl:
600
601 2018-07-23  Zalan Bujtas  <zalan@apple.com>
602
603         [LCF][IFC] Add support for hyphenation.
604         https://bugs.webkit.org/show_bug.cgi?id=187913
605
606         Reviewed by Antti Koivisto.
607
608         Move the hyphenation logic over from SimpleLineLayout::TextFragmentIterator.
609
610         * layout/inlineformatting/textlayout/Runs.h:
611         (WebCore::Layout::TextRun::hasHyphen const):
612         (WebCore::Layout::LayoutRun::setHasHyphen):
613         (WebCore::Layout::LayoutRun::hasHyphen const):
614         (WebCore::Layout::LayoutRun::LayoutRun):
615         (WebCore::Layout::TextRun::createNonWhitespaceRunWithHyphen):
616         (WebCore::Layout::TextRun::TextRun):
617         * layout/inlineformatting/textlayout/TextContentProvider.cpp:
618         (WebCore::Layout::TextContentProvider::findTextItemSlow const):
619         (WebCore::Layout::TextContentProvider::width const):
620         (WebCore::Layout::TextContentProvider::hyphenPositionBefore const):
621         * layout/inlineformatting/textlayout/TextContentProvider.h:
622         * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.cpp:
623         (WebCore::Layout::SimpleLineBreaker::Line::setTextAlign):
624         (WebCore::Layout::SimpleLineBreaker::Line::justifyRuns):
625         (WebCore::Layout::SimpleLineBreaker::Line::adjustRunsForTextAlign):
626         (WebCore::Layout::SimpleLineBreaker::Line::collectExpansionOpportunities):
627         (WebCore::Layout::SimpleLineBreaker::Line::closeLastRun):
628         (WebCore::Layout::SimpleLineBreaker::Line::append):
629         (WebCore::Layout::SimpleLineBreaker::Line::reset):
630         (WebCore::Layout::SimpleLineBreaker::Style::Style):
631         (WebCore::Layout::SimpleLineBreaker::handleLineEnd):
632         (WebCore::Layout::SimpleLineBreaker::createRunsForLine):
633         (WebCore::Layout::SimpleLineBreaker::hyphenPositionBefore const):
634         (WebCore::Layout::SimpleLineBreaker::adjustSplitPositionWithHyphenation const):
635         (WebCore::Layout::SimpleLineBreaker::split const):
636         * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.h:
637
638 2018-07-23  Antoine Quint  <graouts@apple.com>
639
640         [Web Animations] Querying the current time of a finished CSSAnimation after removing its target leads to a crash
641         https://bugs.webkit.org/show_bug.cgi?id=187906
642
643         Reviewed by Dean Jackson.
644
645         Test: webanimations/accessing-current-time-after-finished-css-animation-target-removal.html
646
647         Because we carelessly look at a CSSAnimation's effect's timing in DeclarativeAnimation::bindingsCurrentTime
648         without checking that the effect is non-null, we can crash in the case where the animation is finished and
649         its target element has been removed, which caused the effect to be set to null.
650
651         We do not actually fix the lack of a null check, which will be the scope of a different patch, but instead
652         ensure that we do _not_ set the animation's effect to null when its target is removed, which used to be
653         performed via a call to WebAnimation::remove(). Instead, we introduce AnimationTimeline::elementWasRemoved()
654         which notifies the timeline of an element being removed such that we may stop referencing any animation
655         targeting this element from the various data structures holding strong references to the animation in question,
656         and we then cancel the animation silently, which is a new option that ensures promises aren't resolved or
657         rejected as a result.
658
659         Finally, the WebAnimation and AnimationEffectReadOnly classes established a ref-cycle as WebAnimation has
660         `RefPtr<AnimationEffectReadOnly> m_effect` and AnimationEffectReadOnly has `RefPtr<WebAnimation> m_animation`.
661         While it is correct that WebAnimation owns its effect, which is established by the DOM API, the
662         reverse is not correct since we only hold the reverse internally for the benefit of our implementation.
663         As such, we change AnimationEffectReadOnly's m_animation to be a WeakPtr<WebAnimation>. This means not
664         calling WebAnimation::remove() and simply removing the animation from the animation maps on the timeline
665         is sufficient to guarantee that the document timeline will not leak (and with it the document).
666
667         * animation/AnimationEffectReadOnly.h:
668         (WebCore::AnimationEffectReadOnly::setAnimation):
669         * animation/AnimationTimeline.cpp:
670         (WebCore::AnimationTimeline::elementWasRemoved):
671         * animation/AnimationTimeline.h:
672         * animation/WebAnimation.cpp:
673         (WebCore::WebAnimation::cancel):
674         (WebCore::WebAnimation::resetPendingTasks):
675         * animation/WebAnimation.h:
676         * dom/Element.cpp:
677         (WebCore::Element::removedFromAncestor):
678         * rendering/updating/RenderTreeUpdater.cpp:
679         (WebCore::RenderTreeUpdater::tearDownRenderers):
680
681 2018-07-23  Aditya Keerthi  <akeerthi@apple.com>
682
683         [iOS] Add support for input[type=color]
684         https://bugs.webkit.org/show_bug.cgi?id=187871
685
686         Reviewed by Tim Horton.
687
688         * css/html.css: Remove unwanted styling for color inputs with a list attribute.
689         * html/ColorInputType.cpp: Make the element focusable.
690         (WebCore::ColorInputType::isMouseFocusable const):
691         (WebCore::ColorInputType::isKeyboardFocusable const):
692         * html/ColorInputType.h:
693         * html/HTMLInputElement.h: Expose isColorControl() to WebKit.
694         * page/Chrome.cpp:
695         (WebCore::Chrome::createColorChooser):
696
697 2018-07-22  Dean Jackson  <dino@apple.com>
698
699         fullscreen env() variables should have initial values
700         https://bugs.webkit.org/show_bug.cgi?id=187897
701         <rdar://problem/42485682>
702
703         Reviewed by Sam Weinig.
704
705         The env() values for fullscreen properties need to be
706         initialized, rather than wait for values to be set from WebKit.
707         Without this, feature detection doesn't work, and properties
708         won't parse correctly.
709
710         Test: fullscreen/fullscreen-env-initial.html
711
712         * dom/ConstantPropertyMap.cpp:
713         (WebCore::ConstantPropertyMap::buildValues): Initialize the fullscreen values.
714         (WebCore::ConstantPropertyMap::updateConstantsForFullscreen): Renamed function, because it
715         also updates the duration value.
716         (WebCore::ConstantPropertyMap::didChangeFullscreenInsets): Call new name.
717         (WebCore::ConstantPropertyMap::updateConstantsForFullscreenInsets): Deleted.
718         * dom/ConstantPropertyMap.h:
719         * page/Page.cpp:
720         (WebCore::Page::setFullscreenAutoHideDuration): Don't change the value if it doesn't need it.
721         * page/Page.h: Add accessor for fullscreenAutoHideDuration. Also add a member variable.
722         (WebCore::Page::fullscreenAutoHideDuration const):
723
724 2018-07-22  Zalan Bujtas  <zalan@apple.com>
725
726         [LFC][IFC] Add center/right/justify line alignment support.
727         https://bugs.webkit.org/show_bug.cgi?id=187890
728
729         Reviewed by Antti Koivisto.
730
731         Move over some more code from simple line layout.
732         (though text-align: justify is more preformant as now expansion opportunities are added as we process the text runs
733         -as opposed to iterting through the runs again when we reach the end of the line.) 
734
735         * layout/inlineformatting/textlayout/Runs.h:
736         (WebCore::Layout::LayoutRun::setLeft):
737         (WebCore::Layout::LayoutRun::setExpansion):
738         * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.cpp:
739         (WebCore::Layout::SimpleLineBreaker::Line::Line):
740         (WebCore::Layout::SimpleLineBreaker::Line::setTextAlign):
741         (WebCore::Layout::SimpleLineBreaker::Line::adjustedLeftForTextAlign const):
742         (WebCore::Layout::SimpleLineBreaker::Line::justifyRuns):
743         (WebCore::Layout::SimpleLineBreaker::Line::adjustRunsForTextAlign):
744         (WebCore::Layout::expansionOpportunity):
745         (WebCore::Layout::expansionBehavior):
746         (WebCore::Layout::SimpleLineBreaker::Line::collectExpansionOpportunities):
747         (WebCore::Layout::SimpleLineBreaker::Line::closeLastRun):
748         (WebCore::Layout::SimpleLineBreaker::Line::append):
749         (WebCore::Layout::SimpleLineBreaker::Line::collapseTrailingWhitespace):
750         (WebCore::Layout::SimpleLineBreaker::Line::reset):
751         (WebCore::Layout::SimpleLineBreaker::Style::Style):
752         (WebCore::Layout::SimpleLineBreaker::handleLineEnd):
753         (WebCore::Layout::SimpleLineBreaker::handleLineStart):
754         (WebCore::Layout::isTextAlignRight):
755         (WebCore::Layout::SimpleLineBreaker::createRunsForLine):
756         * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.h:
757         (WebCore::Layout::SimpleLineBreaker::Line::setAvailableWidth):
758         (WebCore::Layout::SimpleLineBreaker::Line::setCollapseWhitespace):
759
760 2018-07-21  Zalan Bujtas  <zalan@apple.com>
761
762         [LFC][IFC] Add verification for inline text runs.
763         https://bugs.webkit.org/show_bug.cgi?id=187879
764
765         Reviewed by Antti Koivisto.
766
767         * layout/Verification.cpp:
768         (WebCore::Layout::outputMismatchingSimpleLineInformationIfNeeded):
769         (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
770         (WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded):
771         (WebCore::Layout::verifyAndOutputSubtree):
772         (WebCore::Layout::outputMismatchingBoxInformationIfNeeded): Deleted.
773         * layout/inlineformatting/InlineFormattingContext.cpp:
774         (WebCore::Layout::InlineFormattingContext::layout const):
775         * layout/inlineformatting/InlineFormattingState.h:
776         (WebCore::Layout::InlineFormattingState::addLayoutRuns):
777         (WebCore::Layout::InlineFormattingState::layoutRuns const):
778         * layout/layouttree/LayoutTreeBuilder.cpp:
779         (WebCore::Layout::outputLayoutBox):
780         (WebCore::Layout::outputLayoutTree):
781         (WebCore::Layout::TreeBuilder::showLayoutTree):
782
783 2018-07-21  Zalan Bujtas  <zalan@apple.com>
784
785         [LFC] Do not use virtual methods to construct floating/formatting states.
786         https://bugs.webkit.org/show_bug.cgi?id=187875
787
788         Reviewed by Antti Koivisto.
789
790         LayoutContext::establishedFormattingState() does not require FormattingContext anymore only the root of the context.
791
792         * layout/FormattingContext.cpp:
793         (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
794         * layout/FormattingContext.h:
795         * layout/LayoutContext.cpp:
796         (WebCore::Layout::LayoutContext::layoutFormattingContextSubtree):
797         (WebCore::Layout::LayoutContext::formattingStateForBox const):
798         (WebCore::Layout::LayoutContext::establishedFormattingState):
799         * layout/LayoutContext.h:
800         * layout/blockformatting/BlockFormattingContext.cpp:
801         (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
802         (WebCore::Layout::BlockFormattingContext::instrinsicWidthConstraints const):
803         (WebCore::Layout::BlockFormattingContext::createFormattingState const): Deleted.
804         (WebCore::Layout::BlockFormattingContext::createOrFindFloatingState const): Deleted.
805         * layout/blockformatting/BlockFormattingContext.h:
806         * layout/inlineformatting/InlineFormattingContext.cpp:
807         (WebCore::Layout::InlineFormattingContext::createFormattingState const): Deleted.
808         (WebCore::Layout::InlineFormattingContext::createOrFindFloatingState const): Deleted.
809         * layout/inlineformatting/InlineFormattingContext.h:
810
811 2018-07-21  Zalan Bujtas  <zalan@apple.com>
812
813         [LFC][BFC] Do not collapse top/bottom margin with first/last inflow child from a non-block formatting context.
814         https://bugs.webkit.org/show_bug.cgi?id=187867
815
816         Reviewed by Antti Koivisto.
817
818         The box's top/bottom margin never collapses with a non-block inflow child.
819
820         * layout/blockformatting/BlockMarginCollapse.cpp:
821         (WebCore::Layout::isMarginTopCollapsedWithSibling):
822         (WebCore::Layout::isMarginBottomCollapsedWithSibling):
823         (WebCore::Layout::isMarginTopCollapsedWithParent):
824         (WebCore::Layout::isMarginBottomCollapsedThrough):
825         (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild):
826         (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop):
827         (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop):
828         (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom):
829         (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop):
830         (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom):
831         (WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent):
832         (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild):
833         (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom):
834         * layout/layouttree/LayoutBox.cpp:
835         (WebCore::Layout::Box::establishesBlockFormattingContextOnly const): <div style="overflow: hidden">foobar</div> establishes both inline and block formatting context (inline wins though).
836         * layout/layouttree/LayoutBox.h: establishesBlockFormattingContext() does not need to be virtual since we can determine it by looking at the box's style. -while in case
837         of inline formatting context, it is about the content.
838
839 2018-07-20  Jer Noble  <jer.noble@apple.com>
840
841         REGRESSION (r233974): Cannot close pip'd video; pops back into PiP.
842         https://bugs.webkit.org/show_bug.cgi?id=187873
843
844         Reviewed by Jon Lee.
845
846         When the PIP machinery on Mac wants to close the PIP window (due to the close button being clicked), it does
847         not consult our -shouldClosePiP handler; it just tells us that we're going to close. So we never setup the 
848         necessary state on the WebProcess side and still think that our "targetIsFullscreen". When we get the "stop"
849         action, just request exit fullscreen, but set up the _pipState to think we're already exiting (because we are).
850
851         * platform/mac/VideoFullscreenInterfaceMac.mm:
852         (-[WebVideoFullscreenInterfaceMacObjC pipActionStop:]):
853
854 2018-07-20  Justin Fan  <justin_fan@apple.com>
855
856         Safari WebGL does not consistently provide correct GPU context on eGPU systems
857         https://bugs.webkit.org/show_bug.cgi?id=187750
858         <rdar://problem/39531436>
859
860         Reviewed by Dean Jackson.
861
862         Move GraphicsContext3DManager into its own class, and notify it when page/Chrome receives a 
863         windowScreenDidChange message. Add a private data struct to track which hostWindow created each context.
864         Upon notification, Manager updates the contexts that match the hostWindow with the
865         provided displayID. Each context matches displayID to rendererID (set during process creation 
866         if window server is blocked), which is matched to a virtual screen, and updates its GPU accordingly.
867
868         No new tests. This requires multiple GPUs or eGPUs, each with attached display(s), to test.
869
870         * WebCore.xcodeproj/project.pbxproj:
871         * page/Chrome.cpp:
872         (WebCore::Chrome::windowScreenDidChange): Now calls GraphicsContext3DManager::screenDidChange().
873         * platform/PlatformScreen.h:
874         * platform/ScreenProperties.h: Add rendererID to struct.
875         (WebCore::ScreenData::encode const):
876         (WebCore::ScreenData::decode):
877         * platform/graphics/GraphicsContext3D.h:
878         * platform/graphics/GraphicsContext3DManager.cpp: Added (copied out of GraphicsContext3DCocoa.mm).
879         (WebCore::attachToAppleGraphicsControl):
880         (WebCore::hasMuxCapability):
881         (WebCore::hasMuxableGPU):
882         (WebCore::GraphicsContext3DManager::sharedManager):
883         (WebCore::displayWasReconfigured):
884         (WebCore::GraphicsContext3DManager::updateAllContexts):
885         (WebCore::GraphicsContext3DManager::screenDidChange):
886         (WebCore::GraphicsContext3DManager::addContext):
887         (WebCore::GraphicsContext3DManager::removeContext):
888         (WebCore::GraphicsContext3DManager::hostWindowForContext const):
889         (WebCore::GraphicsContext3DManager::addContextRequiringHighPerformance):
890         (WebCore::GraphicsContext3DManager::removeContextRequiringHighPerformance):
891         (WebCore::GraphicsContext3DManager::updateHighPerformanceState):
892         (WebCore::GraphicsContext3DManager::disableHighPerformanceGPUTimerFired):
893         (WebCore::GraphicsContext3DManager::recycleContextIfNecessary):
894         * platform/graphics/GraphicsContext3DManager.h: Added (copied out of GraphicsContext3DCocoa.mm).
895         (WebCore::GraphicsContext3DManager::hasTooManyContexts const):
896         (WebCore::GraphicsContext3DManager::GraphicsContext3DManager):
897         * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
898         (WebCore::GraphicsContext3D::create):
899         (WebCore::GraphicsContext3D::createShared):
900         (WebCore::identifyAndSetCurrentGPU): Now matches rendererIDs to determine virtual screen. 
901         (WebCore::GraphicsContext3D::GraphicsContext3D):
902         (WebCore::GraphicsContext3D::~GraphicsContext3D):
903         (WebCore::GraphicsContext3D::setContextVisibility):
904         (WebCore::GraphicsContext3D::simulateContextChanged):
905         (WebCore::GraphicsContext3D::screenDidChange):
906         (WebCore::attachToAppleGraphicsControl): Deleted.
907         (WebCore::hasMuxCapability): Deleted.
908         (WebCore::hasMuxableGPU): Deleted.
909         (WebCore::GraphicsContext3DManager::GraphicsContext3DManager): Deleted.
910         (WebCore::GraphicsContext3DManager::hasTooManyContexts const): Deleted.
911         (WebCore::manager): Deleted.
912         (WebCore::displayWasReconfigured): Deleted.
913         (WebCore::GraphicsContext3DManager::updateAllContexts): Deleted.
914         (WebCore::GraphicsContext3DManager::addContext): Deleted.
915         (WebCore::GraphicsContext3DManager::removeContext): Deleted.
916         (WebCore::GraphicsContext3DManager::addContextRequiringHighPerformance): Deleted.
917         (WebCore::GraphicsContext3DManager::removeContextRequiringHighPerformance): Deleted.
918         (WebCore::GraphicsContext3DManager::updateHighPerformanceState): Deleted.
919         (WebCore::GraphicsContext3DManager::disableHighPerformanceGPUTimerFired): Deleted.
920         (WebCore::GraphicsContext3DManager::recycleContextIfNecessary): Deleted.
921         * platform/mac/PlatformScreenMac.mm: Provide a display's rendererID.
922         (WebCore::rendererIDForDisplayMask):
923         (WebCore::collectScreenProperties):
924         (WebCore::rendererIDForDisplay):
925         (WebCore::primaryRendererID):
926
927 2018-07-19  Simon Fraser  <simon.fraser@apple.com>
928
929         Remove completed animations from GraphicsLayer, thus avoiding excessive backing store allocation
930         https://bugs.webkit.org/show_bug.cgi?id=187844
931         rdar://problem/40387294
932
933         Reviewed by Dean Jackson.
934         
935         A keyframe animation which animates 3D transforms, and is fill-forwards, currently
936         leaves the GraphicsLayer in a state where it has a "running" animation. However, the
937         logic that computes animation extent in RenderLayerBacking::updateGeometry() only does
938         so for running or paused animations. GraphicsLayer then thinks that it has an active
939         transform animation with unknown extent, and refuses to detach its backing store.
940         
941         This triggers excessive layer creation on some sites (e.g. https://www.kqed.org).
942         
943         Fix by always removing animations from the GraphicsLayer when they finish, whether
944         or not they fill forwards. This is done by having KeyframeAnimation::onAnimationEnd()
945         always call endAnimation().
946         
947         This change only fixes the non-Web Animation code path. webkit.org/b/187845 exists
948         to fix the other code path.
949         
950         Also improve some logging that would have revealed this problem sooner.
951
952         Test: compositing/backing/backing-store-attachment-fill-forwards-animation.html
953
954         * page/animation/AnimationBase.h:
955         (WebCore::AnimationBase::endAnimation):
956         * page/animation/ImplicitAnimation.cpp:
957         (WebCore::ImplicitAnimation::endAnimation):
958         * page/animation/ImplicitAnimation.h:
959         * page/animation/KeyframeAnimation.cpp:
960         (WebCore::KeyframeAnimation::endAnimation):
961         (WebCore::KeyframeAnimation::onAnimationEnd):
962         * page/animation/KeyframeAnimation.h:
963         * platform/graphics/ca/GraphicsLayerCA.cpp:
964         (WebCore::GraphicsLayerCA::addAnimation):
965         (WebCore::GraphicsLayerCA::updateCoverage):
966
967 2018-07-20  Ryosuke Niwa  <rniwa@apple.com>
968
969         Picking a color from the color panel for typing attributes needs to inverse transform through color-filter
970         https://bugs.webkit.org/show_bug.cgi?id=187846
971
972         Reviewed by Simon Fraser.
973
974         This patch refines the color inversion for editing introduced in r234005 so that font panels and WebKit embedders
975         can get and set inverted colors using attributed strings for a selected text in an editable region.
976
977         More specifically, when font panels or WebKit embedders set a font color or a background color via WebView's
978         _applyStyleToSelection and _applyEditingStyleToSelection, WebKit would automatically invert the color before inserting
979         into DOM so that the color visible to the user matches that's given to WebKit. Conversely,
980         [WebView attributedSubstringFromRange:nsRange] now return the color visible to the user, i.e. the color after
981         the color filter had been applied, so that some WebKit embedders can present the visually identical color to the user.
982
983         Because DOM never sees the color filter's effect in the computed style, etc... this patch reverts the change made to
984         StyleChange in r234005 to avoid inverting the color passed to execCommand. This makes editing apps which is unaware
985         of the dark mode or -apple-color-filter continue to function (because the color picker implemented in DOM will be
986         applied of the same color filter before being presented to the user).
987
988         Finally, this patch introduces a testing hook in applyCommandToFrame so that executing foreColor or backColor with
989         the soruce of CommandFromMenuOrKeyBinding would trigger the same code path as the one taken by Objective-C 
990
991         Tests: editing/execCommand/set-backColor-with-color-filter-from-scripts.html
992                editing/execCommand/set-foreColor-with-color-filter-from-scripts.html
993                editing/mac/attributed-string/attribute-string-for-copy-with-color-filter.html
994                editing/style/set-backColor-with-color-filter.html
995                editing/style/set-foreColor-with-color-filter.html
996
997         * editing/EditingStyle.cpp:
998         (WebCore::EditingStyle::inverseTransformColorIfNeeded): Added.
999         (WebCore::StyleChange::StyleChange): Revert the change made in r234005 since this code is also used by execCommand
1000         which is not desirable, and won't work for background color.
1001         (WebCore::StyleChange::extractTextStyles): Ditto.
1002         * editing/EditingStyle.h:
1003         * editing/Editor.cpp:
1004         (WebCore::Editor::applyStyle):
1005         (WebCore::Editor::applyStyleToSelection): Call EditingStyle::inverseTransformColorIfNeeded when ColorFilterMode is
1006         set to InvertColor.
1007         * editing/Editor.h:
1008         * editing/EditorCommand.cpp:
1009         (WebCore::applyCommandToFrame): Added the aforementioned testing hook.
1010         * editing/cocoa/HTMLConverter.mm:
1011         (WebCore::editingAttributedStringFromRange): Take the color filtr into account. Some WebKit embedders use this
1012         function to compute the font color in the selected text. Note that this function is mostly used for input methods
1013         so the color doesn't really matter, and its implementation is distinct from that of HTMLConverter.
1014
1015 2018-07-19  Jer Noble  <jer.noble@apple.com>
1016
1017         HLS resources with remote subresources will not taint canvasses.
1018         https://bugs.webkit.org/show_bug.cgi?id=187731
1019         <rdar://problem/42290703>
1020
1021         Reviewed by Brady Eidson.
1022
1023         Test: http/tests/security/canvas-remote-read-remote-video-hls.html
1024
1025         Most media sources are single-resource; they are accessed from a single origin. HLS manifests can contain many
1026         subresources from arbitrary origins, and canvases should be tainted when painted from media elements whose
1027         subresources were retrieved from tainting origins.
1028
1029         Add a new method to HTMLMediaElement, wouldTaintOrigin(), taking a SecurityOrigin, and returning whether the
1030         media element would taint that origin. This gets piped all the way down to MediaPlayerPrivateAVFoundationObjC
1031         which uses WebCoreNSURLSession to track all the origins of all the responses which resulted from the media
1032         element's load.
1033
1034         Drive-by fix: also fix this issue for media elements which render to an AudioContext.
1035
1036         Drive-by fix #2: CanvasRenderingContext2DBase::createPattern() needs to check the return value of
1037         ImageBuffer::create() before using it.
1038
1039         * Modules/webaudio/MediaElementAudioSourceNode.cpp:
1040         (WebCore::MediaElementAudioSourceNode::wouldTaintOrigin):
1041         * html/HTMLMediaElement.cpp:
1042         (WebCore::HTMLMediaElement::didAttachRenderers):
1043         (WebCore::HTMLMediaElement::didDetachRenderers):
1044         (WebCore::HTMLMediaElement::scheduleUpdateShouldAutoplay):
1045         * html/HTMLMediaElement.h:
1046         (WebCore::HTMLMediaElement::wouldTaintOrigin const):
1047         * html/canvas/CanvasRenderingContext.cpp:
1048         (WebCore::CanvasRenderingContext::wouldTaintOrigin):
1049         * html/canvas/CanvasRenderingContext2DBase.cpp:
1050         (WebCore::CanvasRenderingContext2DBase::createPattern):
1051         * platform/graphics/MediaPlayer.cpp:
1052         (WebCore::MediaPlayer::wouldTaintOrigin const):
1053         * platform/graphics/MediaPlayer.h:
1054         * platform/graphics/MediaPlayerPrivate.h:
1055         (WebCore::MediaPlayerPrivateInterface::hasSingleSecurityOrigin const):
1056         (WebCore::MediaPlayerPrivateInterface::wouldTaintOrigin const):
1057         * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
1058         (WebCore::CDMSessionAVContentKeySession::update):
1059         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
1060         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
1061         (WebCore::MediaPlayerPrivateAVFoundationObjC::wouldTaintOrigin const):
1062         * platform/network/cocoa/WebCoreNSURLSession.h:
1063         * platform/network/cocoa/WebCoreNSURLSession.mm:
1064         (-[WebCoreNSURLSession task:didReceiveResponseFromOrigin:]):
1065         (-[WebCoreNSURLSession wouldTaintOrigin:]):
1066         (-[WebCoreNSURLSessionDataTask resource:receivedResponse:]):
1067
1068 2018-07-20  Zalan Bujtas  <zalan@apple.com>
1069
1070         Update FrameView::paintContents to use release logging.
1071         https://bugs.webkit.org/show_bug.cgi?id=187854
1072         <rdar://problem/42432371>
1073
1074         Reviewed by Simon Fraser.
1075
1076         Adding release logging helps identifying blank content cases. 
1077
1078         * page/FrameView.cpp:
1079         (WebCore::FrameView::paintContents):
1080
1081 2018-07-20  Jer Noble  <jer.noble@apple.com>
1082
1083         First Auto-PiP from Fullscreen too small & animation blocks
1084         https://bugs.webkit.org/show_bug.cgi?id=187745
1085         <rdar://problem/42316583>
1086
1087         Reviewed by Jon Lee.
1088
1089         1) When Auto-PiPing, we don't have the luxury of setting up the fullscreen state
1090         ahead of time; we get notified that PiP has already started. The area of the code
1091         which does this just-in-time setup needs to set the video layer's frame so that the
1092         transform within the PiP window is correct.
1093
1094         2) We generate a placeholder image when going into fullscreen, but we need to do
1095         so synchronously. Create the AVPlayerItemVideoOutput up front at AVPlayerItem creation
1096         time wherever AVPIVO is available.
1097
1098         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
1099         (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
1100         * platform/ios/VideoFullscreenInterfaceAVKit.mm:
1101         (VideoFullscreenInterfaceAVKit::doSetup):
1102
1103 2018-07-20  Antoine Quint  <graouts@apple.com>
1104
1105         DeclarativeAnimation should suspend, resume, & stop m_eventQueue
1106         https://bugs.webkit.org/show_bug.cgi?id=187216
1107         <rdar://problem/41669739>
1108
1109         Reviewed by Ryosuke Niwa.
1110
1111         Suspend, resume and close the GenericEventQueue for DeclarativeAnimation as instructed through the DOMActiveObject protocol.
1112
1113         * animation/DeclarativeAnimation.cpp:
1114         (WebCore::DeclarativeAnimation::stop):
1115         (WebCore::DeclarativeAnimation::suspend):
1116         (WebCore::DeclarativeAnimation::resume):
1117         * animation/DeclarativeAnimation.h:
1118         * animation/WebAnimation.h:
1119
1120 2018-07-20  Zalan Bujtas  <zalan@apple.com>
1121
1122         [LFC][Inline formatting context] Add basic text content handling.
1123         https://bugs.webkit.org/show_bug.cgi?id=187860
1124
1125         Reviewed by Antti Koivisto.
1126
1127         InlineFormattingContext::layout() walks through the formatting root's descendant list in a post-order fashion and
1128         feeds the TextContentProvider.
1129         Eventually this would turn into a more generic loop where we stop and process the text content when finding a non-text content box (float, inline-box etc), but right now
1130         this is about text content only.
1131
1132         * layout/displaytree/DisplayBox.h:
1133         (WebCore::Display::Box::contentBoxBottom const):
1134         (WebCore::Display::Box::contentBoxRight const):
1135         * layout/inlineformatting/InlineFormattingContext.cpp:
1136         (WebCore::Layout::InlineFormattingContext::layout const):
1137         * layout/inlineformatting/textlayout/TextContentProvider.cpp:
1138         (WebCore::Layout::TextContentProvider::textRuns): Add a helper function to support the case when all we need is just the run list in one go.
1139         * layout/inlineformatting/textlayout/TextContentProvider.h:
1140         * layout/layouttree/LayoutBox.cpp:
1141         (WebCore::Layout::Box::isDescendantOf const):
1142         * layout/layouttree/LayoutBox.h:
1143         * layout/layouttree/LayoutInlineBox.h:
1144         (WebCore::Layout::InlineBox::textContent const):
1145
1146 2018-07-20  Youenn Fablet  <youenn@apple.com>
1147
1148         FetchResponse should close its stream when loading finishes
1149         https://bugs.webkit.org/show_bug.cgi?id=187790
1150
1151         Reviewed by Chris Dumez.
1152
1153         It simplifies for a FetchResponse to push all its data into its stream if already created at end of load time.
1154         Did some refactoring in FetchBodyOwner to have a cleaner relationship with the stream source.
1155         Did a minor refactoring to expose the error description when loading fails as part of the rejected promise.
1156         This is consistent to errors sent back through callbacks.
1157
1158         Covered by existing tests.
1159
1160         * Modules/fetch/FetchBodyOwner.cpp:
1161         (WebCore::FetchBodyOwner::~FetchBodyOwner):
1162         * Modules/fetch/FetchBodyOwner.h:
1163         * Modules/fetch/FetchBodySource.cpp:
1164         (WebCore::FetchBodySource::FetchBodySource):
1165         (WebCore::FetchBodySource::setActive):
1166         (WebCore::FetchBodySource::setInactive):
1167         (WebCore::FetchBodySource::doStart):
1168         (WebCore::FetchBodySource::doPull):
1169         (WebCore::FetchBodySource::doCancel):
1170         (WebCore::FetchBodySource::cleanBodyOwner):
1171         * Modules/fetch/FetchBodySource.h:
1172         * Modules/fetch/FetchResponse.cpp:
1173         (WebCore::FetchResponse::BodyLoader::didSucceed):
1174         (WebCore::FetchResponse::BodyLoader::didFail):
1175
1176 2018-07-20  Jer Noble  <jer.noble@apple.com>
1177
1178         REGRESSION(r233969): ASSERT in -[WebAVPlayerLayer setVideoGravity:]
1179         https://bugs.webkit.org/show_bug.cgi?id=187814
1180         <rdar://problem/42391869>
1181
1182         Reviewed by Eric Carlson.
1183
1184         After r233969 caused models to disassociate themselves from interfaces, it is now possible that an
1185         VideoFullscreenInterfaceAVKit can have a nil model. We should null-check, not ASSERT, now that the
1186         assertion no longer holds true.
1187
1188         * platform/ios/VideoFullscreenInterfaceAVKit.mm:
1189         (-[WebAVPlayerLayer layoutSublayers]):
1190         (-[WebAVPlayerLayer resolveBounds]):
1191         (-[WebAVPlayerLayer setVideoGravity:]):
1192
1193 2018-07-19  Antoine Quint  <graouts@apple.com>
1194
1195         Flaky crash in AnimationTimeline::cancelOrRemoveDeclarativeAnimation
1196         https://bugs.webkit.org/show_bug.cgi?id=187530
1197         <rdar://problem/42095186>
1198
1199         Reviewed by Dean Jackson.
1200
1201         We would crash in cancelOrRemoveDeclarativeAnimation() because updateCSSAnimationsForElement() would pass
1202         nullptr values due to the return value of cssAnimationsByName.take(nameOfAnimationToRemove). This is because
1203         we would create animations for animation names that may be empty or not match an existing @keyframes rule.
1204         Not only was that wasteful, but it was also non-compliant, and as a result of fixing this we're actually
1205         seeing a progression in the CSS Animations WPT tests.
1206
1207         * animation/AnimationTimeline.cpp:
1208         (WebCore::shouldConsiderAnimation): New function that performs all required steps to see if a provided animation
1209         is valid and has a name that is not "none", not the empty string and matches the name of a @keyframes rule.
1210         (WebCore::AnimationTimeline::updateCSSAnimationsForElement):
1211         * animation/KeyframeEffectReadOnly.cpp:
1212         (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): We no longer need to check whether we have
1213         an empty animation name since we're no longer creating CSSAnimation objects in that circumstance.
1214         * css/StyleResolver.cpp:
1215         (WebCore::StyleResolver::isAnimationNameValid): Add a new method that checks whether the provided animation name
1216         a known @keyframes rule.
1217         * css/StyleResolver.h:
1218
1219 2018-07-19  Chris Dumez  <cdumez@apple.com>
1220
1221         Crash under WebCore::DocumentWriter::addData()
1222         https://bugs.webkit.org/show_bug.cgi?id=187819
1223         <rdar://problem/41328743>
1224
1225         Reviewed by Brady Eidson.
1226
1227         When AppCache is used a DocumentLoader may start a NetworkLoad even though it has substitute data.
1228         In DocumentLoader::continueAfterContentPolicy(), if we have substitute data we commit this data
1229         and call finishLoad(). However, if the case where there was a NetworkLoad started, we'll send the
1230         ContinueDidReceiveResponse IPC back to the network process and it will start sending us data for
1231         the load. This could lead to crashes such as <rdar://problem/41328743> since the DocumentLoader
1232         has already committed data and finished loading when it gets the data from the network process.
1233
1234         To address the issue, we now call clearMainResource() in continueAfterContentPolicy(), after we've
1235         decided to commit the substitute data. This effectively removes the DocumentLoader as a client of
1236         the CachedResource so that its will not be notified of following load progress. We do not cancel
1237         the load as other CachedResourceClients may be interested in the load (ApplicationCacheResourceLoader
1238         in particular, in order to update its cached data).
1239
1240         * loader/DocumentLoader.cpp:
1241         (WebCore::DocumentLoader::continueAfterContentPolicy):
1242
1243 2018-07-19  Dean Jackson  <dino@apple.com>
1244
1245         CrashTracer: com.apple.WebKit.WebContent.Development at com.apple.WebCore: std::optional<WTF::Vector<WebCore::PluginInfo, 0ul, WTF::CrashOnOverflow, 16ul> >::operator* & + 73
1246         https://bugs.webkit.org/show_bug.cgi?id=187820
1247         <rdar://problem/42017759>
1248
1249         Reviewed by Antoine Quint.
1250
1251         Speculative fix for this crash, which is accessing an optional without checking
1252         if it exists. The crash logs didn't point to a reproducible test case.
1253
1254         * plugins/PluginData.cpp:
1255         (WebCore::PluginData::supportsWebVisibleMimeTypeForURL const): Return false if
1256         the optional doesn't exist.
1257
1258 2018-07-19  Antoine Quint  <graouts@apple.com>
1259
1260         Ensure DocumentTimeline is kept alive until the VM::whenIdle callback is called
1261         https://bugs.webkit.org/show_bug.cgi?id=187692
1262
1263         Reviewed by Ryosuke Niwa.
1264
1265         Ensure we keep the DocumentTimeline alive until the VM::whenIdle callback is called.
1266
1267         * animation/DocumentTimeline.cpp:
1268         (WebCore::DocumentTimeline::currentTime):
1269
1270 2018-07-18  Simon Fraser  <simon.fraser@apple.com>
1271
1272         Setting foreground color when editing should take color-filter into account, and report the correct foreground color for collapsed selections
1273         https://bugs.webkit.org/show_bug.cgi?id=187778
1274
1275         Reviewed by Ryosuke Niwa.
1276         
1277         Fix two aspects of editing with color-filter:
1278
1279         1. When setting foreground color, inverse-transform the color through -apple-color-filter so that the user gets the color
1280            they chose when in Dark Mode. Tested by editing/style/exec-command-foreColor-with-color-filter.html.
1281
1282         2. When retrieving the style of the collapsed selection, take color filter into account so that color picker
1283            reflects the color the users sees, instead of the content color. Tested by editing/mac/attributed-string/attributed-string-for-typing-with-color-filter.html
1284
1285         Add two additional tests that ensure that -apple-color-filter does not impact the NSAttributedString code
1286         path, since -apple-color-filter should not affect the behavior of Copy.
1287
1288         Tests: editing/mac/attributed-string/attrib-string-colors-with-color-filter.html
1289                editing/mac/attributed-string/attrib-string-range-with-color-filter.html
1290                editing/mac/attributed-string/attributed-string-for-typing-with-color-filter.html
1291                editing/style/exec-command-foreColor-with-color-filter.html
1292
1293         * editing/EditingStyle.cpp:
1294         (WebCore::StyleChange::StyleChange):
1295         (WebCore::StyleChange::extractTextStyles):
1296         * editing/EditingStyle.h:
1297         * editing/cocoa/EditorCocoa.mm:
1298         (WebCore::Editor::fontAttributesForSelectionStart const):
1299         * platform/graphics/filters/FilterOperation.cpp:
1300         (WebCore::InvertLightnessFilterOperation::inverseTransformColor const):
1301         * platform/graphics/filters/FilterOperation.h:
1302         (WebCore::FilterOperation::inverseTransformColor const):
1303         * platform/graphics/filters/FilterOperations.cpp:
1304         (WebCore::FilterOperations::transformColor const):
1305         (WebCore::FilterOperations::inverseTransformColor const):
1306         * platform/graphics/filters/FilterOperations.h:
1307
1308 2018-07-19  David Fenton  <david_fenton@apple.com>
1309
1310         Unreviewed, rolling out r233994.
1311
1312         Caused EWS and bot failures due to assertions added
1313
1314         Reverted changeset:
1315
1316         "FetchResponse should close its stream when loading finishes"
1317         https://bugs.webkit.org/show_bug.cgi?id=187790
1318         https://trac.webkit.org/changeset/233994
1319
1320 2018-07-19  Jer Noble  <jer.noble@apple.com>
1321
1322         REGRESSION(r233926): media/modern-media-controls/media-controller/media-controller-inline-to-fullscreen-to-pip-to-inline.html is a TIMEOUT failure
1323         https://bugs.webkit.org/show_bug.cgi?id=187813
1324
1325         Reviewed by Jon Lee.
1326
1327         In r233926, we changed the behavior of entering PiP to exit fullscreen only after entering PiP completes. The
1328         test in question will immediately request "inline" presentation mode once the PiP animation begins, and thus
1329         it's asking to "exit fullscreen" when both in standard fullscreen and also in PiP. The fix is not to bail out
1330         early if we're in standard (element) fullscreen, but to allow the remaining steps to complete and exit PiP as
1331         well.
1332
1333         * html/HTMLMediaElement.cpp:
1334         (WebCore::HTMLMediaElement::exitFullscreen):
1335
1336 2018-07-19  Zalan Bujtas  <zalan@apple.com>
1337
1338         [LFC] Introduce simple line breaker.
1339         https://bugs.webkit.org/show_bug.cgi?id=187688
1340
1341         Reviewed by Antti Koivisto.
1342
1343         This patch takes the simple line layout implementation and refactors it in a way it is no longer requires a RenderBlockFlow object to run on.
1344         Also this patch decouples text run generation and line breaking (and this implementation is going to replace the current simple line layout codebase)
1345
1346         TextContentProvider: Acts both as the container for all the text content (including hard line breaks) and as an iterator for the generated text runs.
1347         SimpleTextRunGenerator: TextContentProvider uses it as the text run generator for simple content (in the future we'll have a ComplexTextRunGenerator).
1348         SimpleLineBreaker: Input -> text runs + line constraints; Output -> layout runs after line breaking.
1349
1350         * Sources.txt:
1351         * WebCore.xcodeproj/project.pbxproj:
1352         * layout/inlineformatting/textlayout/ContentProvider.cpp: Added.
1353         (WebCore::Layout::TextContentProvider::TextItem::Style::Style):
1354         (WebCore::Layout::TextContentProvider::ContentProvider):
1355         (WebCore::Layout::TextContentProvider::~ContentProvider):
1356         (WebCore::Layout::TextContentProvider::appendText):
1357         (WebCore::Layout::TextContentProvider::appendLineBreak):
1358         (WebCore::Layout::TextContentProvider::width const):
1359         (WebCore::Layout::TextContentProvider::textWidth const):
1360         (WebCore::Layout::TextContentProvider::fixedPitchWidth const):
1361         (WebCore::Layout::TextContentProvider::toTextItemIndex const):
1362         (WebCore::Layout::TextContentProvider::length const):
1363         (WebCore::Layout::TextContentProvider::iterator):
1364         (WebCore::Layout::TextContentProvider::findNextRun):
1365         (WebCore::Layout::TextContentProvider::current const):
1366         * layout/inlineformatting/textlayout/ContentProvider.h: Added.
1367         (WebCore::Layout::TextContentProvider::textContent const):
1368         (WebCore::Layout::TextContentProvider::hardLineBreaks const):
1369         (WebCore::Layout::TextContentProvider::Iterator::current const):
1370         (WebCore::Layout::TextContentProvider::contains const):
1371         (WebCore::Layout::TextContentProvider::Iterator::Iterator):
1372         (WebCore::Layout::TextContentProvider::Iterator::operator++):
1373         * layout/inlineformatting/textlayout/Runs.h: Added.
1374         (WebCore::Layout::TextRun::isWhitespace const):
1375         (WebCore::Layout::TextRun::isNonWhitespace const):
1376         (WebCore::Layout::TextRun::isLineBreak const):
1377         (WebCore::Layout::TextRun::isSoftLineBreak const):
1378         (WebCore::Layout::TextRun::isHardLineBreak const):
1379         (WebCore::Layout::TextRun::isValid const):
1380         (WebCore::Layout::TextRun::isCollapsed const):
1381         (WebCore::Layout::TextRun::type const):
1382         (WebCore::Layout::TextRun::setIsCollapsed):
1383         (WebCore::Layout::TextRun::setWidth):
1384         (WebCore::Layout::LayoutRun::start const):
1385         (WebCore::Layout::LayoutRun::end const):
1386         (WebCore::Layout::LayoutRun::length const):
1387         (WebCore::Layout::LayoutRun::left const):
1388         (WebCore::Layout::LayoutRun::right const):
1389         (WebCore::Layout::LayoutRun::width const):
1390         (WebCore::Layout::LayoutRun::isEndOfLine const):
1391         (WebCore::Layout::LayoutRun::setEnd):
1392         (WebCore::Layout::LayoutRun::setRight):
1393         (WebCore::Layout::LayoutRun::setIsEndOfLine):
1394         (WebCore::Layout::LayoutRun::LayoutRun):
1395         (WebCore::Layout::TextRun::createWhitespaceRun):
1396         (WebCore::Layout::TextRun::createNonWhitespaceRun):
1397         (WebCore::Layout::TextRun::createSoftLineBreakRun):
1398         (WebCore::Layout::TextRun::createHardLineBreakRun):
1399         (WebCore::Layout::TextRun::TextRun):
1400         (WebCore::Layout::TextRun::start const):
1401         (WebCore::Layout::TextRun::end const):
1402         (WebCore::Layout::TextRun::length const):
1403         (WebCore::Layout::TextRun::width const):
1404         * layout/inlineformatting/textlayout/simple/SimpleContentProvider.cpp: Added.
1405         (WebCore::Layout::SimpleContentProvider::SimpleContentProvider):
1406         (WebCore::Layout::SimpleContentProvider::current const):
1407         (WebCore::Layout::SimpleContentProvider::reset):
1408         (WebCore::Layout::SimpleContentProvider::findNextRun):
1409         (WebCore::Layout::SimpleContentProvider::moveToNextBreakablePosition):
1410         (WebCore::Layout::SimpleContentProvider::moveToNextNonWhitespacePosition):
1411         (WebCore::Layout::SimpleContentProvider::isAtLineBreak const):
1412         (WebCore::Layout::SimpleContentProvider::isAtSoftLineBreak const):
1413         * layout/inlineformatting/textlayout/simple/SimpleContentProvider.h: Added.
1414         (WebCore::Layout::SimpleContentProvider::Iterator::reset):
1415         (WebCore::Layout::SimpleContentProvider::Position::operator== const):
1416         (WebCore::Layout::SimpleContentProvider::Position::operator< const):
1417         (WebCore::Layout::SimpleContentProvider::Position::operator ContentPosition const):
1418         (WebCore::Layout::SimpleContentProvider::Position::resetItemPosition):
1419         (WebCore::Layout::SimpleContentProvider::Position::contentPosition const):
1420         (WebCore::Layout::SimpleContentProvider::Position::itemPosition const):
1421         (WebCore::Layout::SimpleContentProvider::Iterator<T>::Iterator):
1422         (WebCore::Layout::SimpleContentProvider::Iterator<T>::current const):
1423         (WebCore::Layout::SimpleContentProvider::Iterator<T>::operator):
1424         (WebCore::Layout::SimpleContentProvider::Position::operator++):
1425         (WebCore::Layout::SimpleContentProvider::Position::operator+=):
1426         * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.cpp: Added.
1427         (WebCore::Layout::SimpleLineBreaker::TextRunList::TextRunList):
1428         (WebCore::Layout::SimpleLineBreaker::Line::Line):
1429         (WebCore::Layout::adjustedEndPosition):
1430         (WebCore::Layout::SimpleLineBreaker::Line::append):
1431         (WebCore::Layout::SimpleLineBreaker::Line::collapseTrailingWhitespace):
1432         (WebCore::Layout::SimpleLineBreaker::Line::reset):
1433         (WebCore::Layout::SimpleLineBreaker::Style::Style):
1434         (WebCore::Layout::SimpleLineBreaker::SimpleLineBreaker):
1435         (WebCore::Layout::SimpleLineBreaker::runs):
1436         (WebCore::Layout::SimpleLineBreaker::createRunsForLine):
1437         (WebCore::Layout::SimpleLineBreaker::handleOverflownRun):
1438         (WebCore::Layout::SimpleLineBreaker::collapseLeadingWhitespace):
1439         (WebCore::Layout::SimpleLineBreaker::collapseTrailingWhitespace):
1440         (WebCore::Layout::SimpleLineBreaker::splitTextRun):
1441         (WebCore::Layout::SimpleLineBreaker::split const):
1442         (WebCore::Layout::SimpleLineBreaker::availableWidth const):
1443         (WebCore::Layout::SimpleLineBreaker::verticalPosition const):
1444         * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.h: Added.
1445         (WebCore::Layout::SimpleLineBreaker::TextRunList::overrideCurrent):
1446         (WebCore::Layout::SimpleLineBreaker::TextRunList::isCurrentOverridden const):
1447         (WebCore::Layout::SimpleLineBreaker::Line::availableWidth const):
1448         (WebCore::Layout::SimpleLineBreaker::Line::hasContent const):
1449         (WebCore::Layout::SimpleLineBreaker::Line::setAvailableWidth):
1450         (WebCore::Layout::SimpleLineBreaker::Line::hasTrailingWhitespace const):
1451         (WebCore::Layout::SimpleLineBreaker::Line::isWhitespaceOnly const):
1452         (WebCore::Layout::SimpleLineBreaker::wrapContentOnOverflow const):
1453         (WebCore::Layout::SimpleLineBreaker::TextRunList::current const):
1454         (WebCore::Layout::SimpleLineBreaker::TextRunList::operator++):
1455
1456 2018-07-19  Keith Rollin  <krollin@apple.com>
1457
1458         Remove duplicate compilation of WebKitNSImageExtras.mm
1459         https://bugs.webkit.org/show_bug.cgi?id=187782
1460
1461         Reviewed by Alex Christensen.
1462
1463         WebKitNSImageExtras.mm gets compiled twice, once because it's in
1464         WebCore.xcodeproj/project.pbxproj and once because it's in
1465         Webcore/SourcesCocoa.txt. This can lead to duplicate definition
1466         errors, particularly when building with LTO enabled. Fix this by
1467         removing the entry from the Xcode project.
1468
1469         No new tests -- no change in WebKit functionality.
1470
1471         * WebCore.xcodeproj/project.pbxproj:
1472
1473 2018-07-19  Youenn Fablet  <youenn@apple.com>
1474
1475         FetchResponse should close its stream when loading finishes
1476         https://bugs.webkit.org/show_bug.cgi?id=187790
1477
1478         Reviewed by Chris Dumez.
1479
1480         It simplifies for a FetchResponse to push all its data into its stream if already created at end of load time.
1481         Did some refactoring in FetchBodyOwner to have a cleaner relationship with the stream source.
1482         Did a minor refactoring to expose the error description when loading fails as part of the rejected promise.
1483         This is consistent to errors sent back through callbacks.
1484
1485         Covered by existing tests.
1486
1487         * Modules/fetch/FetchBodyOwner.cpp:
1488         (WebCore::FetchBodyOwner::~FetchBodyOwner):
1489         * Modules/fetch/FetchBodyOwner.h:
1490         * Modules/fetch/FetchBodySource.cpp:
1491         (WebCore::FetchBodySource::FetchBodySource):
1492         (WebCore::FetchBodySource::setActive):
1493         (WebCore::FetchBodySource::setInactive):
1494         (WebCore::FetchBodySource::doStart):
1495         (WebCore::FetchBodySource::doPull):
1496         (WebCore::FetchBodySource::doCancel):
1497         (WebCore::FetchBodySource::cleanBodyOwner):
1498         * Modules/fetch/FetchBodySource.h:
1499         * Modules/fetch/FetchResponse.cpp:
1500         (WebCore::FetchResponse::BodyLoader::didSucceed):
1501         (WebCore::FetchResponse::BodyLoader::didFail):
1502
1503 2018-07-19  Jon Lee  <jonlee@apple.com>
1504
1505         Update iOS fullscreen alert text again
1506         https://bugs.webkit.org/show_bug.cgi?id=187797
1507         rdar://problem/42373783
1508
1509         Reviewed by Jer Noble.
1510
1511         * English.lproj/Localizable.strings:
1512
1513 2018-07-19  Keith Rollin  <krollin@apple.com>
1514
1515         Adjust WEBCORE_EXPORT annotations for LTO
1516         https://bugs.webkit.org/show_bug.cgi?id=187781
1517         <rdar://problem/42351124>
1518
1519         Reviewed by Alex Christensen.
1520
1521         Continuation of Bug 186944. This bug addresses issues not caught
1522         during the first pass of adjustments. The initial work focussed on
1523         macOS; this one addresses issues found when building for iOS. From
1524         186944:
1525
1526         Adjust a number of places that result in WebKit's
1527         'check-for-weak-vtables-and-externals' script reporting weak external
1528         symbols:
1529
1530             ERROR: WebCore has a weak external symbol in it (/Volumes/Data/dev/webkit/OpenSource/WebKitBuild/Release/WebCore.framework/Versions/A/WebCore)
1531             ERROR: A weak external symbol is generated when a symbol is defined in multiple compilation units and is also marked as being exported from the library.
1532             ERROR: A common cause of weak external symbols is when an inline function is listed in the linker export file.
1533             ...
1534
1535         These cases are caused by inline methods being marked with WTF_EXPORT
1536         (or related macro) or with an inline function being in a class marked
1537         as such, and when enabling LTO builds.
1538
1539         For the most part, address these by removing the WEBCORE_EXPORT
1540         annotation from inline methods. In some cases, move the implementation
1541         out-of-line because it's the class that has the WEBCORE_EXPORT on it
1542         and removing the annotation from the class would be too disruptive.
1543         Finally, in other cases, move the implementation out-of-line because
1544         check-for-weak-vtables-and-externals still complains when keeping the
1545         implementation inline and removing the annotation; this seems to
1546         typically (but not always) happen with destructors.
1547
1548         No new tests. There is no changed functionality. Only the annotation
1549         and treatment of inline methods are altered.
1550
1551         * platform/graphics/FourCC.h:
1552         (WebCore::FourCC::FourCC):
1553         * platform/graphics/IntPoint.h:
1554         (WebCore::IntPoint::IntPoint):
1555         * platform/mediastream/RealtimeMediaSource.cpp:
1556         (WebCore::RealtimeMediaSource::Observer::~Observer):
1557         (WebCore::RealtimeMediaSource::AudioCaptureFactory::~AudioCaptureFactory):
1558         (WebCore::RealtimeMediaSource::VideoCaptureFactory::~VideoCaptureFactory):
1559         * platform/mediastream/RealtimeMediaSource.h:
1560         * workers/service/ServiceWorkerProvider.cpp:
1561         (WebCore::ServiceWorkerProvider::~ServiceWorkerProvider):
1562         * workers/service/ServiceWorkerProvider.h:
1563
1564 2018-07-19  Charlie Turner  <cturner@igalia.com>
1565
1566         [GStreamer] Return a valid time values in unprerolled states
1567         https://bugs.webkit.org/show_bug.cgi?id=187111
1568
1569         Reviewed by Xabier Rodriguez-Calvar.
1570
1571         After r230584 in bug 180253, asserts were added in
1572         PlatformTimeRanges::add to check that both ends of the range were
1573         valid times. In the non-MSE GStreamer player, this assert was
1574         firing on https://www.w3.org/2010/05/video/mediaevents.html due to
1575         seekable being called in nonprerolled states. In this case
1576         MediaPlayerPrivateInterface::seekable was calling GStreamer's
1577         maxTimeSeekable, which calls in durationMediaTime. The guard
1578         against calling gst_element_query_duration when not prerolled was
1579         returning a different time value than when the duration query
1580         itself failed. Hence the assert firing.
1581
1582         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
1583         (WebCore::MediaPlayerPrivateGStreamer::durationMediaTime const):
1584
1585 2018-07-19  Antoine Quint  <graouts@apple.com>
1586
1587         Hitting RELEASE_ASSERT(!m_activeDOMObjectAdditionForbidden) under HTMLMediaElement::resume()
1588         https://bugs.webkit.org/show_bug.cgi?id=187793
1589         <rdar://problem/42308469>
1590
1591         Reviewed by Chris Dumez.
1592
1593         Ensure we do not call JS under resume(), which would happen as a result of calling configureMediaControls() in prepareForLoad().
1594
1595         * html/HTMLMediaElement.cpp:
1596         (WebCore::HTMLMediaElement::~HTMLMediaElement):
1597         (WebCore::HTMLMediaElement::contextDestroyed):
1598         (WebCore::HTMLMediaElement::stop):
1599         (WebCore::HTMLMediaElement::suspend):
1600         (WebCore::HTMLMediaElement::resume):
1601         * html/HTMLMediaElement.h:
1602
1603 2018-07-19  Philippe Normand  <pnormand@igalia.com>
1604
1605         [GStreamer][MSE] imported/w3c/web-platform-tests/media-source/mediasource-is-type-supported.html crashes
1606         https://bugs.webkit.org/show_bug.cgi?id=187469
1607
1608         Reviewed by Žan Doberšek.
1609
1610         * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
1611         (webKitMediaSrcFreeStream): Fix critical warning. The appsrc
1612         element is created only when a valid sourcebuffer is in use.
1613
1614 2018-07-19  Frederic Wang  <fwang@igalia.com>
1615
1616         Fix message of NotSupportedError exception thrown during custom element creation
1617         https://bugs.webkit.org/show_bug.cgi?id=187757
1618
1619         Reviewed by Yusuke Suzuki.
1620
1621         In bug 161528, some new exceptions were introduced for custom element creation [1] but the
1622         actual text has some issues. This patch fixes one typo and one wrong message.
1623
1624         [1] https://dom.spec.whatwg.org/#concept-create-element
1625
1626         Test: fast/custom-elements/exceptions-for-synchronous-custom-element-creation.html
1627
1628         * bindings/js/JSCustomElementInterface.cpp:
1629         (WebCore::constructCustomElementSynchronously):
1630
1631 2018-07-18  Jer Noble  <jer.noble@apple.com>
1632
1633         Unreviewed API Test fix; restored a line inadventantly removed in r233926.
1634
1635         * platform/mac/VideoFullscreenInterfaceMac.mm:
1636         (-[WebVideoFullscreenInterfaceMacObjC pipDidClose:]):
1637
1638 2018-07-18  Antoine Quint  <graouts@apple.com>
1639
1640         [Web Animations] Interpolation between font-styles with a keyword value should be discrete
1641         https://bugs.webkit.org/show_bug.cgi?id=187722
1642
1643         Reviewed by Myles Maxfield.
1644
1645         Animating between "font-style: normal" or "font-style: oblique" and any another value should yield a discrete
1646         interpolation where the from-value is used from 0 and up to (but excluding) 0.5, and the to-value from 0.5 to 1.
1647
1648         In order to be able to detect the "normal" value, we make the "slope" of a FontSelectionRequest an optional type
1649         where the std::nullopt value indicates "normal" and other values an "oblique" value. Since we also need to
1650         distinguish the "italic" value from an "oblique" value, we implement a custom PropertyWrapper for the "font-style"
1651         property where we ensure the fontStyleAxis property of the font description matches the value we're blending to.
1652         Indeed, in the case where we may animate from "normal" to "italic", the fontStyleAxis on the blended style would
1653         remain "slnt" since it is the base value for "normal".
1654
1655         * accessibility/AccessibilityRenderObject.cpp:
1656         (WebCore::AccessibilityRenderObject::hasPlainText const):
1657         * css/CSSComputedStyleDeclaration.cpp:
1658         (WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
1659         * css/CSSComputedStyleDeclaration.h:
1660         * css/CSSFontFace.cpp:
1661         (WebCore::calculateItalicRange):
1662         * css/CSSFontFaceSet.cpp:
1663         (WebCore::computeFontSelectionRequest):
1664         * css/FontSelectionValueInlines.h:
1665         (WebCore::fontStyleKeyword):
1666         (WebCore::fontStyleValue): Deleted.
1667         * css/StyleBuilderConverter.h:
1668         (WebCore::StyleBuilderConverter::convertFontStyleFromValue):
1669         * page/animation/CSSPropertyAnimation.cpp:
1670         (WebCore::blendFunc):
1671         (WebCore::PropertyWrapperFontStyle::PropertyWrapperFontStyle):
1672         (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
1673         * platform/graphics/FontCache.h:
1674         (WebCore::FontDescriptionKey::computeHash const):
1675         * platform/graphics/FontCascade.h:
1676         (WebCore::FontCascade::italic const):
1677         * platform/graphics/FontDescription.h:
1678         (WebCore::FontDescription::italic const):
1679         (WebCore::FontDescription::setItalic):
1680         (WebCore::FontDescription::setIsItalic):
1681         (WebCore::FontCascadeDescription::initialItalic):
1682         * platform/graphics/FontSelectionAlgorithm.cpp:
1683         (WebCore::FontSelectionAlgorithm::styleDistance const):
1684         * platform/graphics/FontSelectionAlgorithm.h:
1685         (WebCore::isItalic):
1686         (WebCore::FontSelectionRequest::tied const):
1687         (WebCore::operator<<): Implement the required stream operator.
1688         (WebCore::operator==): Mark this function as inline instead of constexpr since tied() is no longer constexpr
1689         due to taking an std::optional<>.
1690         (WebCore::operator!=):
1691         * platform/graphics/cocoa/FontCacheCoreText.cpp:
1692         (WebCore::preparePlatformFont):
1693         * platform/graphics/win/FontCacheWin.cpp:
1694         (WebCore::FontCache::createFontPlatformData):
1695         * rendering/style/RenderStyle.cpp:
1696         (WebCore::RenderStyle::setFontItalic):
1697         * rendering/style/RenderStyle.h:
1698         (WebCore::RenderStyle::fontItalic const):
1699
1700 2018-07-18  Jer Noble  <jer.noble@apple.com>
1701
1702         Unreviewed build fix after r233926; BOOL !== bool.
1703
1704         * platform/ios/VideoFullscreenInterfaceAVKit.mm:
1705         (VideoFullscreenInterfaceAVKit::pictureInPictureWasStartedWhenEnteringBackground const):
1706
1707 2018-07-18  Jer Noble  <jer.noble@apple.com>
1708
1709         PiP from Element Fullscreen should match AVKit's behavior
1710         https://bugs.webkit.org/show_bug.cgi?id=187623
1711
1712         Reviewed by Jon Lee.
1713
1714         PiP behavior should be defined at the WebKit2 level, and not in HTMLMediaElement:
1715
1716         * html/HTMLMediaElement.cpp:
1717         (WebCore::HTMLMediaElement::enterFullscreen):
1718
1719         Add an accessor for pictureInPictureWasStartedWhenEnteringBackground():
1720
1721         * platform/cocoa/VideoFullscreenModelVideoElement.mm:
1722         (VideoFullscreenInterfaceAVKit::pictureInPictureWasStartedWhenEnteringBackground const):
1723
1724         Add VideoFullscreenModelClient virutal methods for PiP change notifications:
1725
1726         * platform/cocoa/VideoFullscreenModel.h:
1727         (WebCore::VideoFullscreenModelClient::hasVideoChanged):
1728         (WebCore::VideoFullscreenModelClient::videoDimensionsChanged):
1729         (WebCore::VideoFullscreenModelClient::willEnterPictureInPicture):
1730         (WebCore::VideoFullscreenModelClient::didEnterPictureInPicture):
1731         (WebCore::VideoFullscreenModelClient::failedToEnterPictureInPicture):
1732         (WebCore::VideoFullscreenModelClient::willExitPictureInPicture):
1733         (WebCore::VideoFullscreenModelClient::didExitPictureInPicture):
1734         (WebCore::VideoFullscreenModelClient::failedToExitPictureInPicture):
1735         * platform/cocoa/VideoFullscreenModelVideoElement.h:
1736         * platform/cocoa/VideoFullscreenModelVideoElement.mm:
1737         (VideoFullscreenModelVideoElement::willEnterPictureInPicture):
1738         (VideoFullscreenModelVideoElement::didEnterPictureInPicture):
1739         (VideoFullscreenModelVideoElement::failedToEnterPictureInPicture):
1740         (VideoFullscreenModelVideoElement::willExitPictureInPicture):
1741         (VideoFullscreenModelVideoElement::didExitPictureInPicture):
1742         (VideoFullscreenModelVideoElement::failedToExitPictureInPicture):
1743         * platform/ios/VideoFullscreenInterfaceAVKit.h:
1744         * platform/ios/VideoFullscreenInterfaceAVKit.mm:
1745         (-[WebAVPlayerLayer layoutSublayers]):
1746         (-[WebAVPlayerLayer resolveBounds]):
1747         (-[WebAVPlayerLayer setVideoGravity:]):
1748         (VideoFullscreenInterfaceAVKit::setupFullscreen):
1749         (VideoFullscreenInterfaceAVKit::presentingViewController):
1750         (VideoFullscreenInterfaceAVKit::willStartPictureInPicture):
1751         (VideoFullscreenInterfaceAVKit::didStartPictureInPicture):
1752         (VideoFullscreenInterfaceAVKit::failedToStartPictureInPicture):
1753         (VideoFullscreenInterfaceAVKit::willStopPictureInPicture):
1754         (VideoFullscreenInterfaceAVKit::didStopPictureInPicture):
1755         (VideoFullscreenInterfaceAVKit::shouldExitFullscreenWithReason):
1756         (VideoFullscreenInterfaceAVKit::doSetup):
1757         * platform/ios/WebVideoFullscreenControllerAVKit.mm:
1758         (VideoFullscreenControllerContext::willEnterPictureInPicture):
1759         (VideoFullscreenControllerContext::didEnterPictureInPicture):
1760         (VideoFullscreenControllerContext::failedToEnterPictureInPicture):
1761         (VideoFullscreenControllerContext::willExitPictureInPicture):
1762         (VideoFullscreenControllerContext::didExitPictureInPicture):
1763         (VideoFullscreenControllerContext::failedToExitPictureInPicture):
1764         * platform/mac/VideoFullscreenInterfaceMac.h:
1765         (WebCore::VideoFullscreenInterfaceMac::requestHideAndExitFullscreen): Deleted.
1766         * platform/mac/VideoFullscreenInterfaceMac.mm:
1767         (-[WebVideoFullscreenInterfaceMacObjC invalidateFullscreenState]):
1768         (-[WebVideoFullscreenInterfaceMacObjC exitPIP]):
1769         (-[WebVideoFullscreenInterfaceMacObjC exitPIPAnimatingToRect:inWindow:]):
1770         (-[WebVideoFullscreenInterfaceMacObjC pipShouldClose:]):
1771         (-[WebVideoFullscreenInterfaceMacObjC pipDidClose:]):
1772         (WebCore::VideoFullscreenInterfaceMac::enterFullscreen):
1773         (WebCore::VideoFullscreenInterfaceMac::exitFullscreen):
1774         (WebCore::VideoFullscreenInterfaceMac::exitFullscreenWithoutAnimationToMode):
1775         (WebCore::VideoFullscreenInterfaceMac::requestHideAndExitFullscreen):
1776
1777 2018-07-18  Basuke Suzuki  <Basuke.Suzuki@sony.com>
1778
1779         [Curl] Disable CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST specified by setAllowsAnyHTTPSCertificate.
1780         https://bugs.webkit.org/show_bug.cgi?id=187611
1781
1782         Reviewed by Fujii Hironori.
1783
1784         Current interface for TLS certificate validation for Curl port are as follows:
1785
1786         - WEBCORE_EXPORT void setHostAllowsAnyHTTPSCertificate(const String&);
1787         - bool isAllowedHTTPSCertificateHost(const String&);
1788         - bool canIgnoredHTTPSCertificate(const String&, const Vector<CertificateInfo::Certificate>&);
1789
1790         First one registers a host to be ignored for any certificate check. Once it is registered, no
1791         further certificate validation check is executed.
1792         Second one checks the host is registered in the list above.
1793         Third one is weird. The method signature implies it checks the certificate for the host and detect
1794         whether we can ignore this certificate for the host, but actually it  just check only the host and
1795         register the certificate into the vector. Then in the next request for the host, the certificate
1796         will be checked with the previously stored certificate.
1797
1798         It's hard to understand, but in short,
1799         - We can register a host as an exception for any TLS certificate validation.
1800         - But only certificate arrived first is ignored, not any certificates for the host
1801           (which is rare, but possible for mis configured web cluster).
1802
1803         This behavior is incomplete. To ignore any certificates of the host, these two methods are enough:
1804
1805         - void allowAnyHTTPSCertificatesForHost(const String&)
1806         - bool canIgnoreAnyHTTPSCertificatesForHost(const String&)
1807
1808         No new tests. Covered by existing tests.
1809
1810         * platform/network/curl/CertificateInfo.h:
1811         * platform/network/curl/CurlContext.cpp:
1812         (WebCore::CurlHandle::enableSSLForHost): Ignore TLS verification for registered host.
1813         * platform/network/curl/CurlSSLHandle.cpp:
1814         (WebCore::CurlSSLHandle::allowAnyHTTPSCertificatesForHost): Added.
1815         (WebCore::CurlSSLHandle::canIgnoreAnyHTTPSCertificatesForHost const): Ditto.
1816         (WebCore::CurlSSLHandle::setClientCertificateInfo): Separate lock.
1817         (WebCore::CurlSSLHandle::getSSLClientCertificate const): Ditto and add const.
1818         (WebCore::CurlSSLHandle::setHostAllowsAnyHTTPSCertificate): Deleted.
1819         (WebCore::CurlSSLHandle::isAllowedHTTPSCertificateHost): Deleted.
1820         (WebCore::CurlSSLHandle::canIgnoredHTTPSCertificate): Deleted.
1821         (WebCore::CurlSSLHandle::getSSLClientCertificate): Deleted.
1822         * platform/network/curl/CurlSSLHandle.h:
1823         * platform/network/curl/CurlSSLVerifier.cpp:
1824         (WebCore::CurlSSLVerifier::CurlSSLVerifier):
1825         (WebCore::CurlSSLVerifier::collectInfo): Renamed from verify.
1826         (WebCore::CurlSSLVerifier::verifyCallback):
1827         (WebCore::CurlSSLVerifier::verify): Renamed to collectInfo.
1828         * platform/network/curl/CurlSSLVerifier.h:
1829         * platform/network/curl/ResourceHandleCurl.cpp:
1830         (WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Rename calling method.
1831
1832 2018-07-18  Myles C. Maxfield  <mmaxfield@apple.com>
1833
1834         Rename WordBreak::Break to WordBreak::BreakWord
1835         https://bugs.webkit.org/show_bug.cgi?id=187767
1836
1837         Reviewed by Simon Fraser.
1838
1839         These breaking properties are very confusing. There are:
1840
1841         1. word-break: break-all, a standard value that allows breaking after every
1842         character.
1843         2. word-break: break-word, a non-standard value which allows for breaking after
1844         every character, but only if the word is too long for the available width (otherwise
1845         it works the same as word-break: normal). This affects the min-content-size of the
1846         text (and makes it equal to what it would be if word-break: break-all was
1847         specified).
1848         3. word-wrap: break-word, which is the same as word-break: break-word, but doesn't
1849         affect the min-content-size of the text.
1850         4. overflow-wrap: break-word, which is the same as word-wrap: break-word.
1851
1852         Because this is so confusing it's valuable for our internal enums to match the names
1853         of the official CSS properties/values.
1854
1855         No new tests because there is no behavior change.
1856
1857         * css/CSSPrimitiveValueMappings.h:
1858         (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
1859         (WebCore::CSSPrimitiveValue::operator WordBreak const):
1860         * rendering/RenderText.cpp:
1861         (WebCore::RenderText::computePreferredLogicalWidths):
1862         * rendering/style/RenderStyle.h:
1863         (WebCore::RenderStyle::breakWords const):
1864         * rendering/style/RenderStyleConstants.h:
1865
1866 2018-07-18  Wenson Hsieh  <wenson_hsieh@apple.com>
1867
1868         Add SPI to defer running async script until after document load
1869         https://bugs.webkit.org/show_bug.cgi?id=187748
1870         <rdar://problem/42317378>
1871
1872         Reviewed by Ryosuke Niwa and Tim Horton.
1873
1874         On watchOS, we currently observe that time-consuming async scripts can block the first paint of Reader, leaving
1875         the user with a blank screen for tens of seconds. One way to mitigate this is to defer async script execution
1876         until after document load (i.e. the same timing as DOMContentLoaded).
1877
1878         This patch introduces an SPI configuration allowing internal clients to defer execution of asynchronous script
1879         until after document load; this, in combination with the parser yielding token introduced in r233891, allows
1880         Safari on watchOS to avoid being blocked on slow script execution before the first paint of the Reader page on
1881         most article-like pages. See below for more details.
1882
1883         Test: RunScriptAfterDocumentLoad.ExecutionOrderOfScriptsInDocument
1884
1885         * dom/Document.cpp:
1886         (WebCore::Document::shouldDeferAsynchronousScriptsUntilParsingFinishes const):
1887         (WebCore::Document::finishedParsing):
1888
1889         Notify ScriptRunner when the Document has finished parsing, and is about to fire DOMContentLoaded.
1890
1891         * dom/Document.h:
1892         * dom/ScriptRunner.cpp:
1893         (WebCore::ScriptRunner::documentFinishedParsing):
1894
1895         When the document is finished parsing, kick off the script execution timer if needed to run any async script
1896         that has been deferred.
1897
1898         (WebCore::ScriptRunner::notifyFinished):
1899         (WebCore::ScriptRunner::timerFired):
1900
1901         Instead of always taking from the list of async scripts to execute, check our document to see whether we should
1902         defer this until after document load. If so, ignore `m_scriptsToExecuteSoon`.
1903
1904         * dom/ScriptRunner.h:
1905         * page/Settings.yaml:
1906
1907         Add a WebCore setting for this behavior.
1908
1909 2018-07-18  Zan Dobersek  <zdobersek@igalia.com>
1910
1911         [Nicosia] Add debug border, repaint counter state tracking to Nicosia::CompositionLayer
1912         https://bugs.webkit.org/show_bug.cgi?id=187749
1913
1914         Reviewed by Carlos Garcia Campos.
1915
1916         Add the RepaintCounter and DebugBorder structs to
1917         Nicosia::CompositionLayer::LayerState, tracking visibility as well as
1918         repaint count or debug color and width.
1919
1920         Instances of RepaintCounter and DebugBorder types are kept in each
1921         CoordinatedGraphicsLayer object, updating the relevant data as it is
1922         changed (since the GraphicsLayer object isn't tracking these values on
1923         its own). During layer flush these values (if changed) are then copied
1924         over into the CompositionLayer state.
1925
1926         * platform/graphics/nicosia/NicosiaPlatformLayer.cpp:
1927         Also fix the year in the license header.
1928         * platform/graphics/nicosia/NicosiaPlatformLayer.h:
1929         Also fix the year in the license header.
1930         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
1931         (WebCore::CoordinatedGraphicsLayer::didUpdateTileBuffers):
1932         (WebCore::CoordinatedGraphicsLayer::setShowDebugBorder):
1933         (WebCore::CoordinatedGraphicsLayer::setShowRepaintCounter):
1934         (WebCore::CoordinatedGraphicsLayer::setDebugBorder):
1935         (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
1936         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
1937
1938 2018-07-18  Zan Dobersek  <zdobersek@igalia.com>
1939
1940         [CoordGraphics] Start tracking Nicosia layers in CoordinatedGraphicsState
1941         https://bugs.webkit.org/show_bug.cgi?id=187751
1942
1943         Reviewed by Carlos Garcia Campos.
1944
1945         Start including the Nicosia::CompositionLayer objects in the
1946         CoordinatedGraphicsState struct, under a separate NicosiaState struct.
1947         References to all the layers in a given scene are kept in a HashSet,
1948         and a separate reference to the root layer kept in a separate member
1949         variable.
1950
1951         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
1952         (WebCore::CoordinatedGraphicsLayer::compositionLayer const):
1953         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
1954         Add the getter method that returns internal Nicosia::CompositionLayer
1955         object. This can't be defined in the class definition because of
1956         WEBCORE_EXPORT used on the CoordinatedGraphicsLayer class.
1957         * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
1958
1959 2018-07-18  Simon Fraser  <simon.fraser@apple.com>
1960
1961         Shrink CompositeAnimation and AnimationBase
1962         https://bugs.webkit.org/show_bug.cgi?id=187683
1963
1964         Reviewed by Daniel Bates.
1965
1966         Reduce the size of CompositeAnimation and AnimationBase.
1967
1968         * page/animation/AnimationBase.h:
1969         * page/animation/CompositeAnimation.h:
1970
1971 2018-07-17  Antoine Quint  <graouts@apple.com>
1972
1973         Ensure timingFunctionForKeyframeAtIndex() can be used from setAnimatedPropertiesInStyle().
1974         https://bugs.webkit.org/show_bug.cgi?id=187637
1975         <rdar://problem/42157915>
1976
1977         Reviewed by Dean Jackson.
1978
1979         Test: webanimations/empty-keyframes-crash.html
1980
1981         Unlike what we assumed, it is possible to have a non-declarative animation without any parsed keyframes.
1982         This can happen as a result of calling `Element.animate({}, …)`. In this case, we want to return a null
1983         value in timingFunctionForKeyframeAtIndex() so we update the call site in setAnimatedPropertiesInStyle()
1984         which is the only place where we didn't check for a null value and didn't know for sure that there would
1985         be parsed keyframes to rely on in the case of a WebAnimation instance.
1986
1987         * animation/KeyframeEffectReadOnly.cpp:
1988         (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle):
1989         (WebCore::KeyframeEffectReadOnly::timingFunctionForKeyframeAtIndex):
1990
1991 2018-07-15  Jiewen Tan  <jiewen_tan@apple.com>
1992
1993         [WebCrypto] Crypto operations should copy their parameters before hoping to another thread
1994         https://bugs.webkit.org/show_bug.cgi?id=187501
1995         <rdar://problem/41438160>
1996
1997         Reviewed by Youenn Fablet.
1998
1999         This patch aims at making all captured variables in all crypto lambdas that need to be passed
2000         to a worker thread thread safe, which includes:
2001         1) changing ref counted objects to thread safe ref counted object.
2002         2) adding isolatedCopy methods to non ref counted classes, so they can be called by CrossThreadCopy().
2003
2004         In addition to above changes, this patch also does the following things:
2005         1) change the name CryptoAlgorithm::dispatchOperation => CryptoAlgorithm::dispatchOperationInWorkQueue
2006         to make it clear that lambdas will be passed to a secondary thread.
2007         2) make CryptoAlgorithmParameters as const parameters for all methods.
2008         3) add null checks on BufferSource.length() and .data().
2009
2010         Tests: crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html
2011                http/wpt/crypto/aes-cbc-crash.any.html
2012                http/wpt/crypto/aes-cbc-crash.any.worker.html
2013                http/wpt/crypto/aes-ctr-crash.any.html
2014                http/wpt/crypto/aes-ctr-crash.any.worker.html
2015                http/wpt/crypto/aes-gcm-crash.any.html
2016                http/wpt/crypto/aes-gcm-crash.any.worker.html
2017                http/wpt/crypto/derive-hmac-key-crash.any.html
2018                http/wpt/crypto/derive-hmac-key-crash.any.worker.html
2019                http/wpt/crypto/ecdsa-crash.any.html
2020                http/wpt/crypto/ecdsa-crash.any.worker.html
2021                http/wpt/crypto/hkdf-crash.any.html
2022                http/wpt/crypto/hkdf-crash.any.worker.html
2023                http/wpt/crypto/pbkdf2-crash.any.html
2024                http/wpt/crypto/pbkdf2-crash.any.worker.html
2025                http/wpt/crypto/rsa-oaep-crash.any.html
2026                http/wpt/crypto/rsa-oaep-crash.any.worker.html
2027                http/wpt/crypto/rsa-pss-crash.any.html
2028                http/wpt/crypto/rsa-pss-crash.any.worker.html
2029                http/wpt/crypto/unwrap-ec-key-crash.any.html
2030                http/wpt/crypto/unwrap-ec-key-crash.any.worker.html
2031                http/wpt/crypto/unwrap-rsa-key-crash.any.html
2032                http/wpt/crypto/unwrap-rsa-key-crash.any.worker.html
2033
2034         * bindings/js/BufferSource.h:
2035         (WebCore::BufferSource::data const):
2036         (WebCore::BufferSource::length const):
2037         * crypto/CryptoAlgorithm.cpp:
2038         (WebCore::CryptoAlgorithm::encrypt):
2039         (WebCore::CryptoAlgorithm::decrypt):
2040         (WebCore::CryptoAlgorithm::sign):
2041         (WebCore::CryptoAlgorithm::verify):
2042         (WebCore::CryptoAlgorithm::deriveBits):
2043         (WebCore::CryptoAlgorithm::importKey):
2044         (WebCore::dispatchAlgorithmOperation):
2045         (WebCore::CryptoAlgorithm::dispatchOperationInWorkQueue):
2046         (WebCore::CryptoAlgorithm::dispatchOperation): Deleted.
2047         * crypto/CryptoAlgorithm.h:
2048         * crypto/SubtleCrypto.cpp:
2049         (WebCore::crossThreadCopyImportParams):
2050         (WebCore::SubtleCrypto::encrypt):
2051         (WebCore::SubtleCrypto::decrypt):
2052         (WebCore::SubtleCrypto::sign):
2053         (WebCore::SubtleCrypto::verify):
2054         (WebCore::SubtleCrypto::deriveKey):
2055         (WebCore::SubtleCrypto::deriveBits):
2056         (WebCore::SubtleCrypto::importKey):
2057         (WebCore::SubtleCrypto::wrapKey):
2058         (WebCore::SubtleCrypto::unwrapKey):
2059         * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
2060         (WebCore::CryptoAlgorithmAES_CBC::encrypt):
2061         (WebCore::CryptoAlgorithmAES_CBC::decrypt):
2062         (WebCore::CryptoAlgorithmAES_CBC::importKey):
2063         * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
2064         * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
2065         (WebCore::CryptoAlgorithmAES_CFB::encrypt):
2066         (WebCore::CryptoAlgorithmAES_CFB::decrypt):
2067         (WebCore::CryptoAlgorithmAES_CFB::importKey):
2068         * crypto/algorithms/CryptoAlgorithmAES_CFB.h:
2069         * crypto/algorithms/CryptoAlgorithmAES_CTR.cpp:
2070         (WebCore::parametersAreValid):
2071         (WebCore::CryptoAlgorithmAES_CTR::encrypt):
2072         (WebCore::CryptoAlgorithmAES_CTR::decrypt):
2073         (WebCore::CryptoAlgorithmAES_CTR::importKey):
2074         * crypto/algorithms/CryptoAlgorithmAES_CTR.h:
2075         * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
2076         (WebCore::CryptoAlgorithmAES_GCM::encrypt):
2077         (WebCore::CryptoAlgorithmAES_GCM::decrypt):
2078         (WebCore::CryptoAlgorithmAES_GCM::importKey):
2079         * crypto/algorithms/CryptoAlgorithmAES_GCM.h:
2080         * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
2081         (WebCore::CryptoAlgorithmAES_KW::importKey):
2082         * crypto/algorithms/CryptoAlgorithmAES_KW.h:
2083         * crypto/algorithms/CryptoAlgorithmECDH.cpp:
2084         (WebCore::CryptoAlgorithmECDH::deriveBits):
2085         (WebCore::CryptoAlgorithmECDH::importKey):
2086         * crypto/algorithms/CryptoAlgorithmECDH.h:
2087         * crypto/algorithms/CryptoAlgorithmECDSA.cpp:
2088         (WebCore::CryptoAlgorithmECDSA::sign):
2089         (WebCore::CryptoAlgorithmECDSA::verify):
2090         (WebCore::CryptoAlgorithmECDSA::importKey):
2091         * crypto/algorithms/CryptoAlgorithmECDSA.h:
2092         * crypto/algorithms/CryptoAlgorithmHKDF.cpp:
2093         (WebCore::CryptoAlgorithmHKDF::deriveBits):
2094         (WebCore::CryptoAlgorithmHKDF::importKey):
2095         * crypto/algorithms/CryptoAlgorithmHKDF.h:
2096         * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
2097         (WebCore::CryptoAlgorithmHMAC::sign):
2098         (WebCore::CryptoAlgorithmHMAC::verify):
2099         (WebCore::CryptoAlgorithmHMAC::importKey):
2100         * crypto/algorithms/CryptoAlgorithmHMAC.h:
2101         * crypto/algorithms/CryptoAlgorithmPBKDF2.cpp:
2102         (WebCore::CryptoAlgorithmPBKDF2::deriveBits):
2103         (WebCore::CryptoAlgorithmPBKDF2::importKey):
2104         * crypto/algorithms/CryptoAlgorithmPBKDF2.h:
2105         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
2106         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
2107         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
2108         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
2109         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
2110         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
2111         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
2112         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
2113         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
2114         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
2115         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
2116         (WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
2117         (WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
2118         (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
2119         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
2120         * crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:
2121         (WebCore::CryptoAlgorithmRSA_PSS::sign):
2122         (WebCore::CryptoAlgorithmRSA_PSS::verify):
2123         (WebCore::CryptoAlgorithmRSA_PSS::importKey):
2124         * crypto/algorithms/CryptoAlgorithmRSA_PSS.h:
2125         * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
2126         (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
2127         (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
2128         * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp:
2129         (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
2130         (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
2131         * crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp:
2132         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
2133         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
2134         * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:
2135         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
2136         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
2137         * crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:
2138         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
2139         * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:
2140         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
2141         * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp:
2142         (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
2143         (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
2144         * crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp:
2145         (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
2146         (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
2147         * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
2148         (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
2149         (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
2150         * crypto/mac/CryptoAlgorithmAES_CFBMac.cpp:
2151         (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
2152         (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
2153         * crypto/mac/CryptoAlgorithmAES_CTRMac.cpp:
2154         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
2155         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
2156         * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
2157         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
2158         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
2159         * crypto/mac/CryptoAlgorithmHKDFMac.cpp:
2160         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
2161         * crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp:
2162         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
2163         * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
2164         (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
2165         (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
2166         * crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp:
2167         (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
2168         (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
2169         * crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h:
2170         * crypto/parameters/CryptoAlgorithmAesCtrParams.h:
2171         * crypto/parameters/CryptoAlgorithmAesGcmParams.h:
2172         * crypto/parameters/CryptoAlgorithmEcKeyParams.h:
2173         * crypto/parameters/CryptoAlgorithmEcdsaParams.h:
2174         * crypto/parameters/CryptoAlgorithmHkdfParams.h:
2175         * crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
2176         * crypto/parameters/CryptoAlgorithmPbkdf2Params.h:
2177         * crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h:
2178         * crypto/parameters/CryptoAlgorithmRsaOaepParams.h:
2179         * crypto/parameters/CryptoAlgorithmRsaPssParams.h:
2180
2181 2018-07-17  Antoine Quint  <graouts@apple.com>
2182
2183         [Web Animations] Interpolation between lengths with an "auto" value should be discrete
2184         https://bugs.webkit.org/show_bug.cgi?id=187721
2185
2186         Reviewed by Dean Jackson.
2187
2188         When interpolating between two Length values, if one is "auto", we should use the from-value
2189         from 0 and up to (but excluding) 0.5, and use the to-value from 0.5 to 1.
2190
2191         This change caused a regression in the legacy animation engine since it would create a CSS
2192         transition even when the underlying and target values were non-interpolable. As such, the
2193         underlying value would be used until the transition's mid-point and the tests at 
2194         legacy-animation-engine/imported/blink/transitions/transition-not-interpolable.html and
2195         legacy-animation-engine/fast/animation/height-auto-transition-computed-value.html would fail
2196         expecting the target value to be used immediately. We now ensure that no transition is actually
2197         started if two values for a given property cannot be interpolated.
2198
2199         * page/animation/CompositeAnimation.cpp:
2200         (WebCore::CompositeAnimation::updateTransitions):
2201         * platform/Length.cpp:
2202         (WebCore::blend):
2203
2204 2018-07-17  Wenson Hsieh  <wenson_hsieh@apple.com>
2205
2206         Add an SPI hook to allow clients to yield document parsing and script execution
2207         https://bugs.webkit.org/show_bug.cgi?id=187682
2208         <rdar://problem/42207453>
2209
2210         Reviewed by Ryosuke Niwa.
2211
2212         Using a single web process for both the Reader page and original web page on watchOS has multiple benefits,
2213         including: (1) allowing the user to bail out of Reader and view the original web page without having to load it
2214         again, and (2) improving the bringup time of the Reader page, since subresources are already cached in process
2215         and we don't eat the additional cost of a web process launch if prewarming fails.
2216
2217         However, this has some drawbacks as well, one of which is that main thread work being done on behalf of the
2218         original page may contend with work being done to load and render the Reader page. This is especially bad when
2219         the page is in the middle of executing heavy script after Safari has already detected that the Reader version of
2220         the page is available, but before it has finished loading the Reader page. The result is that script on the
2221         original page may block the first paint of the Reader page (on New York Times articles, this often leads to an
2222         apparent page load time of 25-35 seconds before the user sees anything besides a blank screen).
2223
2224         To mitigate this, we introduce a way for injected bundle clients to yield parsing and async script execution on
2225         a document. This capability is surfaced in the form of an opaque token which clients may request from a
2226         WKDOMDocument. Construction of the token causes the document to begin yielding and defer execution of previously
2227         scheduled scripts, only if there were no active tokens on the document already. Similarly, destruction of all
2228         active tokens on the document causes it to stop yielding and resume execution of scripts if needed.
2229
2230         Tests:  ParserYieldTokenTests.PreventDocumentLoadByTakingParserYieldToken
2231                 ParserYieldTokenTests.TakeMultipleParserYieldTokens
2232                 ParserYieldTokenTests.DeferredScriptExecutesBeforeDocumentLoadWhenTakingParserYieldToken
2233                 ParserYieldTokenTests.AsyncScriptRunsWhenFetched
2234
2235         * dom/Document.cpp:
2236         (WebCore::Document::implicitOpen):
2237
2238         If the parser yield token was taken before the document's parser was created, tell the parser's scheduler to
2239         start yielding immediately after creation.
2240
2241         (WebCore::DocumentParserYieldToken::DocumentParserYieldToken):
2242         (WebCore::DocumentParserYieldToken::~DocumentParserYieldToken):
2243         * dom/Document.h:
2244
2245         Introduce a parser yield count to Document; as long as this count is greater than 0, we consider the Document to
2246         have active yield tokens. When constructing or destroying a ParserYieldToken, we increment and decrement the
2247         parser yield count (respectively).
2248
2249         (WebCore::Document::createParserYieldToken):
2250         (WebCore::Document::hasActiveParserYieldToken const):
2251         * dom/DocumentParser.h:
2252         (WebCore::DocumentParser::didBeginYieldingParser):
2253         (WebCore::DocumentParser::didEndYieldingParser):
2254
2255         Hooks for Document to tell its parser that we've started or finished yielding. This updates a flag on the
2256         parser's scheduler which is consulted when we determine whether to yield before a pumping token or executing
2257         script.
2258
2259         * dom/ScriptRunner.cpp:
2260         (WebCore::ScriptRunner::resume):
2261         (WebCore::ScriptRunner::notifyFinished):
2262         * dom/ScriptRunner.h:
2263         (WebCore::ScriptRunner::didBeginYieldingParser):
2264         (WebCore::ScriptRunner::didEndYieldingParser):
2265
2266         Hooks for Document to tell its ScriptRunner that we've started or finished yielding. These wrap calls to suspend
2267         and resume.
2268
2269         * html/parser/HTMLDocumentParser.cpp:
2270         (WebCore::HTMLDocumentParser::didBeginYieldingParser):
2271         (WebCore::HTMLDocumentParser::didEndYieldingParser):
2272
2273         Plumb to didBegin/didEnd calls to the HTMLParserScheduler.
2274
2275         * html/parser/HTMLDocumentParser.h:
2276         * html/parser/HTMLParserScheduler.cpp:
2277         (WebCore::HTMLParserScheduler::shouldYieldBeforeExecutingScript):
2278         * html/parser/HTMLParserScheduler.h:
2279         (WebCore::HTMLParserScheduler::shouldYieldBeforeToken):
2280
2281         Consult a flag when determining whether to yield. This flag is set to true only while the document has an active
2282         parser yield token.
2283
2284         (WebCore::HTMLParserScheduler::isScheduledForResume const):
2285
2286         Consider the parser scheduler to be scheduled for resume if there are active tokens. Without this change, we
2287         incorrectly consider the document to be finished loading when we have yield tokens, since it appears that the
2288         parser is no longer scheduled to pump its tokenizer.
2289
2290         (WebCore::HTMLParserScheduler::didBeginYieldingParser):
2291         (WebCore::HTMLParserScheduler::didEndYieldingParser):
2292
2293         When the Document begins yielding due to the documet having active tokens or ends yielding after the document
2294         loses all of its yield tokens, update a flag on the parser scheduler. After we finish yielding, additionally
2295         reschedule the parser if needed to ensure that we continue parsing the document; without this additional change
2296         to resume, we'll never get the document load or load events after relinquishing the yield token.
2297
2298 2018-07-17  Dirk Schulze  <krit@webkit.org>
2299
2300         [clip-path] Implement support for margin-box as reference box and box shape
2301         https://bugs.webkit.org/show_bug.cgi?id=127984
2302
2303         Reviewed by Simon Fraser.
2304
2305         Compute the margin-box rectangle as needed for clip-path based on the actual
2306         computed values for the margin-top, *-left, *-bottom, *-right properties.
2307
2308         Test: css3/masking/clip-path-margin-box.html
2309
2310         * rendering/RenderBox.h:
2311         (WebCore::RenderBox::marginBoxRect const):
2312         * rendering/RenderBoxModelObject.h:
2313         * rendering/RenderLayer.cpp:
2314         (WebCore::computeReferenceBox):
2315
2316 2018-07-17  Javier Fernandez  <jfernandez@igalia.com>
2317
2318         Delete content of a single cell table should not delete the whole table
2319         https://bugs.webkit.org/show_bug.cgi?id=173117
2320
2321         Reviewed by Ryosuke Niwa.
2322
2323         We should not extend selection looking for special elements if the
2324         delete operation has been triggered by a caret based selection.
2325
2326         This change is based on a recent [1] resolution of the Editing TF,
2327         which acknowledges that behavior of single-cell tables must be the
2328         same that multi-cell tables and even if the last character is
2329         deleted, we should not delete the whole table structure.
2330
2331         A different case would be when the user actively selects the whole
2332         content of a table; in this case, as we do in multi-cell tables,
2333         the structure of single-cell tables should be deleted together
2334         with the content.
2335
2336         [1] https://github.com/w3c/editing/issues/163
2337
2338         Tests: editing/deleting/backspace-delete-last-char-in-table.html
2339                editing/deleting/forward-delete-last-char-in-table.html
2340                editing/deleting/select-and-delete-last-char-in-table.html
2341
2342         * editing/TypingCommand.cpp:
2343         (WebCore::TypingCommand::deleteKeyPressed):
2344         (WebCore::TypingCommand::forwardDeleteKeyPressed):
2345
2346 2018-07-16  Megan Gardner  <megan_gardner@apple.com>
2347
2348         Correctly adjust scroll offsets when a page is zoomed
2349         https://bugs.webkit.org/show_bug.cgi?id=187673
2350         <rdar://problem/41712829>
2351
2352         Reviewed by Wenson Hsieh.
2353
2354         Will add test later.
2355
2356         Make sure that distance is scaled by the pageScaleFactor, to 
2357         make sure that we scroll correctly when we are zoomed in.
2358
2359         * page/ios/EventHandlerIOS.mm:
2360         (WebCore::autoscrollAdjustmentFactorForScreenBoundaries):
2361         
2362 2018-07-16  Simon Fraser  <simon.fraser@apple.com>
2363
2364         Roll out r233873 and r233875 since they caused 8 new layout test crashes.
2365
2366         * crypto/CryptoAlgorithm.cpp:
2367         (WebCore::CryptoAlgorithm::encrypt):
2368         (WebCore::CryptoAlgorithm::decrypt):
2369         (WebCore::CryptoAlgorithm::sign):
2370         (WebCore::CryptoAlgorithm::verify):
2371         (WebCore::CryptoAlgorithm::deriveBits):
2372         (WebCore::CryptoAlgorithm::importKey):
2373         (WebCore::dispatchAlgorithmOperation):
2374         (WebCore::CryptoAlgorithm::dispatchOperation):
2375         (WebCore::CryptoAlgorithm::dispatchOperationInWorkQueue): Deleted.
2376         * crypto/CryptoAlgorithm.h:
2377         * crypto/SubtleCrypto.cpp:
2378         (WebCore::SubtleCrypto::encrypt):
2379         (WebCore::SubtleCrypto::decrypt):
2380         (WebCore::SubtleCrypto::sign):
2381         (WebCore::SubtleCrypto::verify):
2382         (WebCore::SubtleCrypto::deriveKey):
2383         (WebCore::SubtleCrypto::deriveBits):
2384         (WebCore::SubtleCrypto::importKey):
2385         (WebCore::SubtleCrypto::wrapKey):
2386         (WebCore::SubtleCrypto::unwrapKey):
2387         (WebCore::crossThreadCopyImportParams): Deleted.
2388         * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
2389         (WebCore::CryptoAlgorithmAES_CBC::encrypt):
2390         (WebCore::CryptoAlgorithmAES_CBC::decrypt):
2391         (WebCore::CryptoAlgorithmAES_CBC::importKey):
2392         * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
2393         * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
2394         (WebCore::CryptoAlgorithmAES_CFB::encrypt):
2395         (WebCore::CryptoAlgorithmAES_CFB::decrypt):
2396         (WebCore::CryptoAlgorithmAES_CFB::importKey):
2397         * crypto/algorithms/CryptoAlgorithmAES_CFB.h:
2398         * crypto/algorithms/CryptoAlgorithmAES_CTR.cpp:
2399         (WebCore::parametersAreValid):
2400         (WebCore::CryptoAlgorithmAES_CTR::encrypt):
2401         (WebCore::CryptoAlgorithmAES_CTR::decrypt):
2402         (WebCore::CryptoAlgorithmAES_CTR::importKey):
2403         * crypto/algorithms/CryptoAlgorithmAES_CTR.h:
2404         * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
2405         (WebCore::CryptoAlgorithmAES_GCM::encrypt):
2406         (WebCore::CryptoAlgorithmAES_GCM::decrypt):
2407         (WebCore::CryptoAlgorithmAES_GCM::importKey):
2408         * crypto/algorithms/CryptoAlgorithmAES_GCM.h:
2409         * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
2410         (WebCore::CryptoAlgorithmAES_KW::importKey):
2411         * crypto/algorithms/CryptoAlgorithmAES_KW.h:
2412         * crypto/algorithms/CryptoAlgorithmECDH.cpp:
2413         (WebCore::CryptoAlgorithmECDH::deriveBits):
2414         (WebCore::CryptoAlgorithmECDH::importKey):
2415         * crypto/algorithms/CryptoAlgorithmECDH.h:
2416         * crypto/algorithms/CryptoAlgorithmECDSA.cpp:
2417         (WebCore::CryptoAlgorithmECDSA::sign):
2418         (WebCore::CryptoAlgorithmECDSA::verify):
2419         (WebCore::CryptoAlgorithmECDSA::importKey):
2420         * crypto/algorithms/CryptoAlgorithmECDSA.h:
2421         * crypto/algorithms/CryptoAlgorithmHKDF.cpp:
2422         (WebCore::CryptoAlgorithmHKDF::deriveBits):
2423         (WebCore::CryptoAlgorithmHKDF::importKey):
2424         * crypto/algorithms/CryptoAlgorithmHKDF.h:
2425         * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
2426         (WebCore::CryptoAlgorithmHMAC::sign):
2427         (WebCore::CryptoAlgorithmHMAC::verify):
2428         (WebCore::CryptoAlgorithmHMAC::importKey):
2429         * crypto/algorithms/CryptoAlgorithmHMAC.h:
2430         * crypto/algorithms/CryptoAlgorithmPBKDF2.cpp:
2431         (WebCore::CryptoAlgorithmPBKDF2::deriveBits):
2432         (WebCore::CryptoAlgorithmPBKDF2::importKey):
2433         * crypto/algorithms/CryptoAlgorithmPBKDF2.h:
2434         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
2435         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
2436         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
2437         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
2438         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
2439         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
2440         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
2441         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
2442         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
2443         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
2444         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
2445         (WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
2446         (WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
2447         (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
2448         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
2449         * crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:
2450         (WebCore::CryptoAlgorithmRSA_PSS::sign):
2451         (WebCore::CryptoAlgorithmRSA_PSS::verify):
2452         (WebCore::CryptoAlgorithmRSA_PSS::importKey):
2453         * crypto/algorithms/CryptoAlgorithmRSA_PSS.h:
2454         * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
2455         (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
2456         (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
2457         * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp:
2458         (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
2459         (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
2460         * crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp:
2461         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
2462         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
2463         * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:
2464         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
2465         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
2466         * crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:
2467         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
2468         * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:
2469         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
2470         * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp:
2471         (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
2472         (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
2473         * crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp:
2474         (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
2475         (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
2476         * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
2477         (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
2478         (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
2479         * crypto/mac/CryptoAlgorithmAES_CFBMac.cpp:
2480         (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
2481         (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
2482         * crypto/mac/CryptoAlgorithmAES_CTRMac.cpp:
2483         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
2484         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
2485         * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
2486         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
2487         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
2488         * crypto/mac/CryptoAlgorithmHKDFMac.cpp:
2489         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
2490         * crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp:
2491         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
2492         * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
2493         (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
2494         (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
2495         * crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp:
2496         (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
2497         (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
2498         * crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h:
2499         * crypto/parameters/CryptoAlgorithmAesCtrParams.h:
2500         * crypto/parameters/CryptoAlgorithmAesGcmParams.h:
2501         * crypto/parameters/CryptoAlgorithmEcKeyParams.h:
2502         * crypto/parameters/CryptoAlgorithmEcdsaParams.h:
2503         * crypto/parameters/CryptoAlgorithmHkdfParams.h:
2504         * crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
2505         * crypto/parameters/CryptoAlgorithmPbkdf2Params.h:
2506         * crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h:
2507         * crypto/parameters/CryptoAlgorithmRsaOaepParams.h:
2508         * crypto/parameters/CryptoAlgorithmRsaPssParams.h:
2509
2510 2018-07-16  Ryosuke Niwa  <rniwa@webkit.org>
2511
2512         Release assert in ~TimerBase is getting hit in WK1 apps which uses JSC API directly
2513         https://bugs.webkit.org/show_bug.cgi?id=187713
2514         <rdar://problem/41759548>
2515
2516         Reviewed by Simon Fraser.
2517
2518         Turn this into a debug assertion in WebKit1 on iOS since JSC API doesn't grab the web thread lock,
2519         which means that Timer can get destroyed without the web thread lock in the main thread.
2520
2521         * platform/Timer.cpp:
2522         (WebCore::TimerBase::~TimerBase):
2523         (WebCore::TimerBase::setNextFireTime):
2524
2525 2018-07-16  Simon Fraser  <simon.fraser@apple.com>
2526
2527         Add color filter for transforming colors in Dark Mode
2528         https://bugs.webkit.org/show_bug.cgi?id=187717
2529         rdar://problem/41146650
2530
2531         Reviewed by Dean Jackson.
2532         
2533         Add a new filter function for use in -apple-color-filter for transforming colors
2534         when in Dark Mode. The filter is called apple-invert-lightness(), and takes no parameters.
2535         It's based on a lightness invert in HSL space, with some adjustments to improve the contrast
2536         of some colors on dark backgrounds, so does a much better job that using invert() with hue-rotate().
2537
2538         Test: css3/color-filters/color-filter-apple-invert-lightness.html
2539
2540         * css/CSSComputedStyleDeclaration.cpp:
2541         (WebCore::ComputedStyleExtractor::valueForFilter):
2542         * css/CSSValueKeywords.in:
2543         * css/StyleResolver.cpp:
2544         (WebCore::filterOperationForType):
2545         (WebCore::StyleResolver::createFilterOperations):
2546         * css/parser/CSSPropertyParser.cpp:
2547         (WebCore::CSSPropertyParser::parseSingleValue):
2548         * css/parser/CSSPropertyParserHelpers.cpp:
2549         (WebCore::CSSPropertyParserHelpers::consumeFilterImage):
2550         (WebCore::CSSPropertyParserHelpers::isPixelFilterFunction):
2551         (WebCore::CSSPropertyParserHelpers::isColorFilterFunction):
2552         (WebCore::CSSPropertyParserHelpers::consumeFilterFunction):
2553         (WebCore::CSSPropertyParserHelpers::consumeFilter):
2554         (WebCore::CSSPropertyParserHelpers::isValidPrimitiveFilterFunction): Deleted.
2555         * css/parser/CSSPropertyParserHelpers.h:
2556         * page/FrameView.cpp:
2557         (WebCore::FrameView::paintContents):
2558         * platform/graphics/Color.cpp:
2559         * platform/graphics/ColorUtilities.cpp:
2560         (WebCore::sRGBToLinearComponents):
2561         (WebCore::linearToSRGBComponents):
2562         (WebCore::sRGBToLinearColorComponentForLuminance):
2563         (WebCore::luminance):
2564         (WebCore::sRGBToHSL):
2565         (WebCore::calcHue):
2566         (WebCore::HSLToSRGB):
2567         (WebCore::ColorMatrix::ColorMatrix):
2568         * platform/graphics/ColorUtilities.h:
2569         * platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm:
2570         (PlatformCAFilters::filterValueForOperation):
2571         (PlatformCAFilters::colorMatrixValueForFilter):
2572         * platform/graphics/filters/FEColorMatrix.cpp:
2573         * platform/graphics/filters/FilterOperation.cpp:
2574         (WebCore::InvertLightnessFilterOperation::operator== const):
2575         (WebCore::InvertLightnessFilterOperation::blend):
2576         (WebCore::InvertLightnessFilterOperation::transformColor const):
2577         (WebCore::operator<<):
2578         * platform/graphics/filters/FilterOperation.h:
2579         * rendering/FilterEffectRenderer.cpp:
2580         (WebCore::FilterEffectRenderer::build):
2581
2582 2018-07-16  Jiewen Tan  <jiewen_tan@apple.com>
2583
2584         Unreviewed, build fix for r233873.
2585
2586         * crypto/SubtleCrypto.cpp:
2587         (WebCore::crossThreadCopyImportParams):
2588
2589 2018-07-15  Jiewen Tan  <jiewen_tan@apple.com>
2590
2591         [WebCrypto] Crypto operations should copy their parameters before hoping to another thread
2592         https://bugs.webkit.org/show_bug.cgi?id=187501
2593         <rdar://problem/41438160>
2594
2595         Reviewed by Youenn Fablet.
2596
2597         This patch aims at making all captured variables in all crypto lambdas that need to be passed
2598         to a worker thread thread safe, which includes:
2599         1) changing ref counted objects to thread safe ref counted object.
2600         2) adding isolatedCopy methods to non ref counted classes, so they can be called by CrossThreadCopy().
2601
2602         In addition to above changes, this patch also does the following things:
2603         1) change the name CryptoAlgorithm::dispatchOperation => CryptoAlgorithm::dispatchOperationInWorkQueue
2604         to make it clear that lambdas will be passed to a secondary thread.
2605         2) make CryptoAlgorithmParameters as const parameters for all methods.
2606
2607         Tests: crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html
2608                http/wpt/crypto/aes-cbc-crash.any.html
2609                http/wpt/crypto/aes-cbc-crash.any.worker.html
2610                http/wpt/crypto/aes-ctr-crash.any.html
2611                http/wpt/crypto/aes-ctr-crash.any.worker.html
2612                http/wpt/crypto/aes-gcm-crash.any.html
2613                http/wpt/crypto/aes-gcm-crash.any.worker.html
2614                http/wpt/crypto/derive-hmac-key-crash.any.html
2615                http/wpt/crypto/derive-hmac-key-crash.any.worker.html
2616                http/wpt/crypto/ecdsa-crash.any.html
2617                http/wpt/crypto/ecdsa-crash.any.worker.html
2618                http/wpt/crypto/hkdf-crash.any.html
2619                http/wpt/crypto/hkdf-crash.any.worker.html
2620                http/wpt/crypto/pbkdf2-crash.any.html
2621                http/wpt/crypto/pbkdf2-crash.any.worker.html
2622                http/wpt/crypto/rsa-oaep-crash.any.html
2623                http/wpt/crypto/rsa-oaep-crash.any.worker.html
2624                http/wpt/crypto/rsa-pss-crash.any.html
2625                http/wpt/crypto/rsa-pss-crash.any.worker.html
2626                http/wpt/crypto/unwrap-ec-key-crash.any.html
2627                http/wpt/crypto/unwrap-ec-key-crash.any.worker.html
2628                http/wpt/crypto/unwrap-rsa-key-crash.any.html
2629                http/wpt/crypto/unwrap-rsa-key-crash.any.worker.html
2630
2631         * crypto/CryptoAlgorithm.cpp:
2632         (WebCore::CryptoAlgorithm::encrypt):
2633         (WebCore::CryptoAlgorithm::decrypt):
2634         (WebCore::CryptoAlgorithm::sign):
2635         (WebCore::CryptoAlgorithm::verify):
2636         (WebCore::CryptoAlgorithm::deriveBits):
2637         (WebCore::CryptoAlgorithm::importKey):
2638         (WebCore::dispatchAlgorithmOperation):
2639         (WebCore::CryptoAlgorithm::dispatchOperationInWorkQueue):
2640         (WebCore::CryptoAlgorithm::dispatchOperation): Deleted.
2641         * crypto/CryptoAlgorithm.h:
2642         * crypto/SubtleCrypto.cpp:
2643         (WebCore::crossThreadCopyImportParams):
2644         (WebCore::SubtleCrypto::encrypt):
2645         (WebCore::SubtleCrypto::decrypt):
2646         (WebCore::SubtleCrypto::sign):
2647         (WebCore::SubtleCrypto::verify):
2648         (WebCore::SubtleCrypto::deriveKey):
2649         (WebCore::SubtleCrypto::deriveBits):
2650         (WebCore::SubtleCrypto::importKey):
2651         (WebCore::SubtleCrypto::wrapKey):
2652         (WebCore::SubtleCrypto::unwrapKey):
2653         * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
2654         (WebCore::CryptoAlgorithmAES_CBC::encrypt):
2655         (WebCore::CryptoAlgorithmAES_CBC::decrypt):
2656         (WebCore::CryptoAlgorithmAES_CBC::importKey):
2657         * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
2658         * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
2659         (WebCore::CryptoAlgorithmAES_CFB::encrypt):
2660         (WebCore::CryptoAlgorithmAES_CFB::decrypt):
2661         (WebCore::CryptoAlgorithmAES_CFB::importKey):
2662         * crypto/algorithms/CryptoAlgorithmAES_CFB.h:
2663         * crypto/algorithms/CryptoAlgorithmAES_CTR.cpp:
2664         (WebCore::parametersAreValid):
2665         (WebCore::CryptoAlgorithmAES_CTR::encrypt):
2666         (WebCore::CryptoAlgorithmAES_CTR::decrypt):
2667         (WebCore::CryptoAlgorithmAES_CTR::importKey):
2668         * crypto/algorithms/CryptoAlgorithmAES_CTR.h:
2669         * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
2670         (WebCore::CryptoAlgorithmAES_GCM::encrypt):
2671         (WebCore::CryptoAlgorithmAES_GCM::decrypt):
2672         (WebCore::CryptoAlgorithmAES_GCM::importKey):
2673         * crypto/algorithms/CryptoAlgorithmAES_GCM.h:
2674         * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
2675         (WebCore::CryptoAlgorithmAES_KW::importKey):
2676         * crypto/algorithms/CryptoAlgorithmAES_KW.h:
2677         * crypto/algorithms/CryptoAlgorithmECDH.cpp:
2678         (WebCore::CryptoAlgorithmECDH::deriveBits):
2679         (WebCore::CryptoAlgorithmECDH::importKey):
2680         * crypto/algorithms/CryptoAlgorithmECDH.h:
2681         * crypto/algorithms/CryptoAlgorithmECDSA.cpp:
2682         (WebCore::CryptoAlgorithmECDSA::sign):
2683         (WebCore::CryptoAlgorithmECDSA::verify):
2684         (WebCore::CryptoAlgorithmECDSA::importKey):
2685         * crypto/algorithms/CryptoAlgorithmECDSA.h:
2686         * crypto/algorithms/CryptoAlgorithmHKDF.cpp:
2687         (WebCore::CryptoAlgorithmHKDF::deriveBits):
2688         (WebCore::CryptoAlgorithmHKDF::importKey):
2689         * crypto/algorithms/CryptoAlgorithmHKDF.h:
2690         * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
2691         (WebCore::CryptoAlgorithmHMAC::sign):
2692         (WebCore::CryptoAlgorithmHMAC::verify):
2693         (WebCore::CryptoAlgorithmHMAC::importKey):
2694         * crypto/algorithms/CryptoAlgorithmHMAC.h:
2695         * crypto/algorithms/CryptoAlgorithmPBKDF2.cpp:
2696         (WebCore::CryptoAlgorithmPBKDF2::deriveBits):
2697         (WebCore::CryptoAlgorithmPBKDF2::importKey):
2698         * crypto/algorithms/CryptoAlgorithmPBKDF2.h:
2699         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
2700         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
2701         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
2702         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
2703         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
2704         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
2705         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
2706         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
2707         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
2708         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
2709         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
2710         (WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
2711         (WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
2712         (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
2713         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
2714         * crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:
2715         (WebCore::CryptoAlgorithmRSA_PSS::sign):
2716         (WebCore::CryptoAlgorithmRSA_PSS::verify):
2717         (WebCore::CryptoAlgorithmRSA_PSS::importKey):
2718         * crypto/algorithms/CryptoAlgorithmRSA_PSS.h:
2719         * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
2720         (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
2721         (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
2722         * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp:
2723         (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
2724         (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
2725         * crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp:
2726         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
2727         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
2728         * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:
2729         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
2730         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
2731         * crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:
2732         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
2733         * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:
2734         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
2735         * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp:
2736         (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
2737         (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
2738         * crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp:
2739         (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
2740         (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
2741         * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
2742         (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
2743         (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
2744         * crypto/mac/CryptoAlgorithmAES_CFBMac.cpp:
2745         (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
2746         (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
2747         * crypto/mac/CryptoAlgorithmAES_CTRMac.cpp:
2748         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
2749         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
2750         * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
2751         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
2752         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
2753         * crypto/mac/CryptoAlgorithmHKDFMac.cpp:
2754         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
2755         * crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp:
2756         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
2757         * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
2758         (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
2759         (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
2760         * crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp:
2761         (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
2762         (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
2763         * crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h:
2764         * crypto/parameters/CryptoAlgorithmAesCtrParams.h:
2765         * crypto/parameters/CryptoAlgorithmAesGcmParams.h:
2766         * crypto/parameters/CryptoAlgorithmEcKeyParams.h:
2767         * crypto/parameters/CryptoAlgorithmEcdsaParams.h:
2768         * crypto/parameters/CryptoAlgorithmHkdfParams.h:
2769         * crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
2770         * crypto/parameters/CryptoAlgorithmPbkdf2Params.h:
2771         * crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h:
2772         * crypto/parameters/CryptoAlgorithmRsaOaepParams.h:
2773         * crypto/parameters/CryptoAlgorithmRsaPssParams.h:
2774
2775 2018-07-16  Said Abou-Hallawa  <sabouhallawa@apple.com>
2776
2777         [iOS] When bringing MobileSafari to the foreground, images, which are pending decoding, won't be drawn into the flush immediate transaction
2778         https://bugs.webkit.org/show_bug.cgi?id=187375
2779
2780         Reviewed by Simon Fraser.
2781
2782         An immediate-paint transaction should force all the images which are pending
2783         decoding to be repainted.
2784
2785         To do that, FrameView::paintControlTints() will be re-factored to a new
2786         generic function such that it takes PaintInvalidationReasons. The new function
2787         which is named 'traverseForPaintInvalidation' will traverse the render tree
2788         for a specific PaintInvalidationReasons.
2789
2790         invalidateImagesWithAsyncDecodes() will stop the asynchronous decoding for
2791         the underlying image and repaint all the clients which are waiting for the
2792         decoding to finish.
2793
2794         * loader/cache/CachedImage.cpp:
2795         (WebCore::CachedImage::didRemoveClient):
2796         (WebCore::CachedImage::isClientWaitingForAsyncDecoding const):
2797         (WebCore::CachedImage::addClientWaitingForAsyncDecoding):
2798         (WebCore::CachedImage::removeAllClientsWaitingForAsyncDecoding):
2799         (WebCore::CachedImage::allClientsRemoved):
2800         (WebCore::CachedImage::clear):
2801         (WebCore::CachedImage::createImage):
2802         (WebCore::CachedImage::imageFrameAvailable):
2803         (WebCore::CachedImage::addPendingImageDrawingClient): Deleted.
2804         * loader/cache/CachedImage.h:
2805         * page/FrameView.cpp:
2806         (WebCore::FrameView::paintScrollCorner):
2807         (WebCore::FrameView::updateControlTints):
2808         (WebCore::FrameView::traverseForPaintInvalidation):
2809         (WebCore::FrameView::adjustPageHeightDeprecated):
2810         (WebCore::FrameView::paintControlTints): Deleted.
2811         * page/FrameView.h:
2812         * platform/ScrollView.cpp:
2813         (WebCore::ScrollView::paint):
2814         * platform/Scrollbar.cpp:
2815         (WebCore::Scrollbar::paint):
2816         * platform/graphics/BitmapImage.h:
2817         * platform/graphics/GraphicsContext.cpp:
2818         (WebCore::GraphicsContext::GraphicsContext):
2819         * platform/graphics/GraphicsContext.h:
2820         (WebCore::GraphicsContext::performingPaintInvalidation const):
2821         (WebCore::GraphicsContext::invalidatingControlTints const):
2822         (WebCore::GraphicsContext::invalidatingImagesWithAsyncDecodes const):
2823         (WebCore::GraphicsContext::updatingControlTints const): Deleted.
2824         * rendering/RenderBoxModelObject.cpp:
2825         (WebCore::RenderBoxModelObject::paintFillLayerExtended):
2826         * rendering/RenderImage.cpp:
2827         (WebCore::RenderImage::paintReplaced):
2828         (WebCore::RenderImage::paintAreaElementFocusRing):
2829         (WebCore::RenderImage::paintIntoRect):
2830         * rendering/RenderLayer.cpp:
2831         (WebCore::RenderLayer::paintScrollCorner):
2832         (WebCore::RenderLayer::paintResizer):
2833         (WebCore::RenderLayer::paintLayer):
2834         * rendering/RenderScrollbar.cpp:
2835         (WebCore::RenderScrollbar::paint):
2836         * rendering/RenderTheme.cpp:
2837         (WebCore::RenderTheme::paint):
2838         * testing/Internals.cpp:
2839         (WebCore::Internals::invalidateControlTints):
2840         (WebCore::Internals::paintControlTints): Deleted.
2841         * testing/Internals.h:
2842         * testing/Internals.idl:
2843
2844 2018-07-16  Ryan Haddad  <ryanhaddad@apple.com>
2845
2846         Unreviewed attempt to fix the build.
2847
2848         * rendering/RenderThemeMac.mm:
2849
2850 2018-07-11  Dean Jackson  <dino@apple.com>
2851
2852         Allow removal of white backgrounds
2853         https://bugs.webkit.org/show_bug.cgi?id=187574
2854         <rdar://problem/41146792>
2855
2856         Reviewed by Simon Fraser.
2857
2858         Add a drawing mode that turns white backgrounds into transparent
2859         regions, such that a hosting app can see through to its window.
2860
2861         Test: css3/color-filters/punch-out-white-backgrounds.html
2862
2863         * page/Settings.yaml: New Setting.
2864
2865         * rendering/InlineFlowBox.cpp: Draw with a destination out blend mode
2866         if the background is white and we are punching out backgrounds, which means
2867         that it will erase the destination.
2868         (WebCore::InlineFlowBox::paintBoxDecorations):
2869         * rendering/RenderBox.cpp:
2870         (WebCore::RenderBox::paintBackground): Ditto.
2871         * rendering/RenderTableCell.cpp:
2872         (WebCore::RenderTableCell::paintBackgroundsBehindCell): Ditto.
2873
2874         * rendering/RenderBoxModelObject.cpp:
2875         (WebCore::RenderBoxModelObject::paintFillLayerExtended): Save and restore
2876         the composition mode if necessary.
2877
2878 2018-07-16  David Fenton  <david_fenton@apple.com>
2879
2880         Unreviewed, rolling out r233867.
2881
2882         caused build failures on High Sierra, Sierra and iOS
2883
2884         Reverted changeset:
2885
2886         "[WebCrypto] Crypto operations should copy their parameters
2887         before hoping to another thread"
2888         https://bugs.webkit.org/show_bug.cgi?id=187501
2889         https://trac.webkit.org/changeset/233867
2890
2891 2018-07-15  Jiewen Tan  <jiewen_tan@apple.com>
2892
2893         [WebCrypto] Crypto operations should copy their parameters before hoping to another thread
2894         https://bugs.webkit.org/show_bug.cgi?id=187501
2895         <rdar://problem/41438160>
2896
2897         Reviewed by Youenn Fablet.
2898
2899         This patch aims at making all captured variables in all crypto lambdas that need to be passed
2900         to a worker thread thread safe, which includes:
2901         1) changing ref counted objects to thread safe ref counted object.
2902         2) adding isolatedCopy methods to non ref counted classes, so they can be called by CrossThreadCopy().
2903
2904         In addition to above changes, this patch also does the following things:
2905         1) change the name CryptoAlgorithm::dispatchOperation => CryptoAlgorithm::dispatchOperationInWorkQueue
2906         to make it clear that lambdas will be passed to a secondary thread.
2907         2) make CryptoAlgorithmParameters as const parameters for all methods.
2908
2909         Tests: crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html
2910                http/wpt/crypto/aes-cbc-crash.any.html
2911                http/wpt/crypto/aes-cbc-crash.any.worker.html
2912                http/wpt/crypto/aes-ctr-crash.any.html
2913                http/wpt/crypto/aes-ctr-crash.any.worker.html
2914                http/wpt/crypto/aes-gcm-crash.any.html
2915                http/wpt/crypto/aes-gcm-crash.any.worker.html
2916                http/wpt/crypto/derive-hmac-key-crash.any.html
2917                http/wpt/crypto/derive-hmac-key-crash.any.worker.html
2918                http/wpt/crypto/ecdsa-crash.any.html
2919                http/wpt/crypto/ecdsa-crash.any.worker.html
2920                http/wpt/crypto/hkdf-crash.any.html
2921                http/wpt/crypto/hkdf-crash.any.worker.html
2922                http/wpt/crypto/pbkdf2-crash.any.html
2923                http/wpt/crypto/pbkdf2-crash.any.worker.html
2924                http/wpt/crypto/rsa-oaep-crash.any.html
2925                http/wpt/crypto/rsa-oaep-crash.any.worker.html
2926                http/wpt/crypto/rsa-pss-crash.any.html
2927                http/wpt/crypto/rsa-pss-crash.any.worker.html
2928                http/wpt/crypto/unwrap-ec-key-crash.any.html
2929                http/wpt/crypto/unwrap-ec-key-crash.any.worker.html
2930                http/wpt/crypto/unwrap-rsa-key-crash.any.html
2931                http/wpt/crypto/unwrap-rsa-key-crash.any.worker.html
2932
2933         * crypto/CryptoAlgorithm.cpp:
2934         (WebCore::CryptoAlgorithm::encrypt):
2935         (WebCore::CryptoAlgorithm::decrypt):
2936         (WebCore::CryptoAlgorithm::sign):
2937         (WebCore::CryptoAlgorithm::verify):
2938         (WebCore::CryptoAlgorithm::deriveBits):
2939         (WebCore::CryptoAlgorithm::importKey):
2940         (WebCore::dispatchAlgorithmOperation):
2941         (WebCore::CryptoAlgorithm::dispatchOperationInWorkQueue):
2942         (WebCore::CryptoAlgorithm::dispatchOperation): Deleted.
2943         * crypto/CryptoAlgorithm.h:
2944         * crypto/SubtleCrypto.cpp:
2945         (WebCore::crossThreadCopyImportParams):
2946         (WebCore::SubtleCrypto::encrypt):
2947         (WebCore::SubtleCrypto::decrypt):
2948         (WebCore::SubtleCrypto::sign):
2949         (WebCore::SubtleCrypto::verify):
2950         (WebCore::SubtleCrypto::deriveKey):
2951         (WebCore::SubtleCrypto::deriveBits):
2952         (WebCore::SubtleCrypto::importKey):
2953         (WebCore::SubtleCrypto::wrapKey):
2954         (WebCore::SubtleCrypto::unwrapKey):
2955         * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
2956         (WebCore::CryptoAlgorithmAES_CBC::encrypt):
2957         (WebCore::CryptoAlgorithmAES_CBC::decrypt):
2958         (WebCore::CryptoAlgorithmAES_CBC::importKey):
2959         * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
2960         * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
2961         (WebCore::CryptoAlgorithmAES_CFB::encrypt):
2962         (WebCore::CryptoAlgorithmAES_CFB::decrypt):
2963         (WebCore::CryptoAlgorithmAES_CFB::importKey):
2964         * crypto/algorithms/CryptoAlgorithmAES_CFB.h:
2965         * crypto/algorithms/CryptoAlgorithmAES_CTR.cpp:
2966         (WebCore::parametersAreValid):
2967         (WebCore::CryptoAlgorithmAES_CTR::encrypt):
2968         (WebCore::CryptoAlgorithmAES_CTR::decrypt):
2969         (WebCore::CryptoAlgorithmAES_CTR::importKey):
2970         * crypto/algorithms/CryptoAlgorithmAES_CTR.h:
2971         * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
2972         (WebCore::CryptoAlgorithmAES_GCM::encrypt):
2973         (WebCore::CryptoAlgorithmAES_GCM::decrypt):
2974         (WebCore::CryptoAlgorithmAES_GCM::importKey):
2975         * crypto/algorithms/CryptoAlgorithmAES_GCM.h:
2976         * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
2977         (WebCore::CryptoAlgorithmAES_KW::importKey):
2978         * crypto/algorithms/CryptoAlgorithmAES_KW.h:
2979         * crypto/algorithms/CryptoAlgorithmECDH.cpp:
2980         (WebCore::CryptoAlgorithmECDH::deriveBits):
2981         (WebCore::CryptoAlgorithmECDH::importKey):
2982         * crypto/algorithms/CryptoAlgorithmECDH.h:
2983         * crypto/algorithms/CryptoAlgorithmECDSA.cpp:
2984         (WebCore::CryptoAlgorithmECDSA::sign):
2985         (WebCore::CryptoAlgorithmECDSA::verify):
2986         (WebCore::CryptoAlgorithmECDSA::importKey):
2987         * crypto/algorithms/CryptoAlgorithmECDSA.h:
2988         * crypto/algorithms/CryptoAlgorithmHKDF.cpp:
2989         (WebCore::CryptoAlgorithmHKDF::deriveBits):
2990         (WebCore::CryptoAlgorithmHKDF::importKey):
2991         * crypto/algorithms/CryptoAlgorithmHKDF.h:
2992         * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
2993         (WebCore::CryptoAlgorithmHMAC::sign):
2994         (WebCore::CryptoAlgorithmHMAC::verify):
2995         (WebCore::CryptoAlgorithmHMAC::importKey):
2996         * crypto/algorithms/CryptoAlgorithmHMAC.h:
2997         * crypto/algorithms/CryptoAlgorithmPBKDF2.cpp:
2998         (WebCore::CryptoAlgorithmPBKDF2::deriveBits):
2999         (WebCore::CryptoAlgorithmPBKDF2::importKey):
3000         * crypto/algorithms/CryptoAlgorithmPBKDF2.h:
3001         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
3002         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
3003         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
3004         (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
3005         * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
3006         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
3007         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
3008         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
3009         (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
3010         * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
3011         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
3012         (WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
3013         (WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
3014         (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
3015         * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
3016         * crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:
3017         (WebCore::CryptoAlgorithmRSA_PSS::sign):
3018         (WebCore::CryptoAlgorithmRSA_PSS::verify):
3019         (WebCore::CryptoAlgorithmRSA_PSS::importKey):
3020         * crypto/algorithms/CryptoAlgorithmRSA_PSS.h:
3021         * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
3022         (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
3023         (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
3024         * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp:
3025         (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
3026         (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
3027         * crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp:
3028         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
3029         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
3030         * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:
3031         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
3032         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
3033         * crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:
3034         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
3035         * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:
3036         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
3037         * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp:
3038         (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
3039         (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
3040         * crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp:
3041         (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
3042         (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
3043         * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
3044         (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
3045         (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
3046         * crypto/mac/CryptoAlgorithmAES_CFBMac.cpp:
3047         (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
3048         (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
3049         * crypto/mac/CryptoAlgorithmAES_CTRMac.cpp:
3050         (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
3051         (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
3052         * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
3053         (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
3054         (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
3055         * crypto/mac/CryptoAlgorithmHKDFMac.cpp:
3056         (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
3057         * crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp:
3058         (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
3059         * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
3060         (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
3061         (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
3062         * crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp:
3063         (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
3064         (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
3065         * crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h:
3066         * crypto/parameters/CryptoAlgorithmAesCtrParams.h:
3067         * crypto/parameters/CryptoAlgorithmAesGcmParams.h:
3068         * crypto/parameters/CryptoAlgorithmEcKeyParams.h:
3069         * crypto/parameters/CryptoAlgorithmEcdsaParams.h:
3070         * crypto/parameters/CryptoAlgorithmHkdfParams.h:
3071         * crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
3072         * crypto/parameters/CryptoAlgorithmPbkdf2Params.h:
3073         * crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h:
3074         * crypto/parameters/CryptoAlgorithmRsaOaepParams.h:
3075         * crypto/parameters/CryptoAlgorithmRsaPssParams.h:
3076
3077 2018-07-16  Aditya Keerthi  <akeerthi@apple.com>
3078
3079         [Datalist][macOS] Add suggestions UI for TextFieldInputTypes
3080         https://bugs.webkit.org/show_bug.cgi?id=186531
3081
3082         Reviewed by Tim Horton.
3083
3084         Tests: fast/forms/datalist/datalist-show-hide.html
3085                fast/forms/datalist/datalist-textinput-keydown.html
3086
3087         * html/TextFieldInputType.cpp:
3088         (WebCore::TextFieldInputType::handleKeydownEvent):
3089         (WebCore::TextFieldInputType::handleKeydownEventForSpinButton): The suggestions view takes precedence when handling arrow key events.
3090
3091 2018-07-16  Jeremy Jones  <jeremyj@apple.com>
3092
3093         Fullscreen requires active document.
3094         https://bugs.webkit.org/show_bug.cgi?id=186226
3095         rdar://problem/36187413
3096
3097         Reviewed by Jer Noble.
3098
3099         Test: media/no-fullscreen-when-hidden.html
3100
3101         This change guarantees the document to be visible for both element fullscreen and video fullscreen.
3102
3103         User gesture is not enough to guarantee that the document is visible when fullscreen is initiated
3104         because JavaScript can spin wait before initiating fullscreen. During that spin the page or window might
3105         be hidden.
3106
3107         Document::hidden() can't be relied upon because it won't update while JavaScript spins.
3108
3109         This change adds a sync call to the UI process to get the current UI visibility state.
3110
3111         * dom/Document.cpp:
3112         (WebCore::Document::requestFullScreenForElement):
3113         * html/HTMLMediaElement.cpp:
3114         (WebCore::HTMLMediaElement::enterFullscreen):
3115         * page/ChromeClient.h:
3116
3117 2018-07-16  Alex Christensen  <achristensen@webkit.org>
3118
3119         Reduce size of NetworkLoadMetrics and therefore ResourceResponse
3120         https://bugs.webkit.org/show_bug.cgi?id=187671
3121
3122         Reviewed by Darin Adler.
3123
3124         * inspector/agents/InspectorNetworkAgent.cpp:
3125         (WebCore::toProtocol):
3126         (WebCore::InspectorNetworkAgent::buildObjectForMetrics):
3127         * platform/network/NetworkLoadMetrics.h:
3128         (WebCore::NetworkLoadMetrics::isolatedCopy const):
3129         (WebCore::NetworkLoadMetrics::reset):
3130         (WebCore::NetworkLoadMetrics::clearNonTimingData):
3131
3132 2018-07-16  Chris Dumez  <cdumez@apple.com>
3133
3134         Make sure LibWebRTCMediaEndpoint is always destroyed on the main thread
3135         https://bugs.webkit.org/show_bug.cgi?id=187702
3136
3137         Reviewed by Youenn Fablet.
3138
3139         Make sure LibWebRTCMediaEndpoint is always constructed and destructed on the main thread since
3140         it has a Timer data member and it would not be safe otherwise. LibWebRTCMediaEndpoint is
3141         ThreadSafeRefCounted and frequently passed to other threads.
3142
3143         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
3144         (WebCore::LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint):
3145         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
3146
3147 2018-07-16  Sihui Liu  <sihui_liu@apple.com>
3148
3149         IndexedDB: closeAndDeleteDatabasesForOrigins should remove all databases for those origins
3150         https://bugs.webkit.org/show_bug.cgi?id=187631
3151         <rdar://problem/42164227>
3152
3153         Reviewed by Brady Eidson.
3154
3155         When asked to delete database for an origin, we deleted the databases whose mainFrameOrigin 
3156         is that origin. Given that the origin may create IndexedDB from subframes, we should delete 
3157         databases whose openingOrigin is that origin too.
3158
3159         Covered by modified API test: WebKit.WebsiteDataStoreCustomPaths. 
3160
3161         * Modules/indexeddb/server/IDBServer.cpp:
3162         (WebCore::IDBServer::IDBServer::performCloseAndDeleteDatabasesForOrigins):
3163
3164 2018-07-16  Simon Fraser  <simon.fraser@apple.com>
3165
3166         Shrink some font-related classes and enums
3167         https://bugs.webkit.org/show_bug.cgi?id=187686
3168
3169         Reviewed by Myles Maxfield.
3170         
3171         Use enum class for enums in TextFlags.h and make them one byte big.
3172
3173         Re-order members of Font to shrink it from 360 to 328 bytes.
3174
3175         * css/CSSPrimitiveValueMappings.h:
3176         (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
3177         (WebCore::CSSPrimitiveValue::operator FontSmoothingMode const):
3178         (WebCore::CSSPrimitiveValue::operator FontSmallCaps const):
3179         (WebCore::CSSPrimitiveValue::operator TextRenderingMode const):
3180         * platform/graphics/Font.cpp:
3181         (WebCore::Font::Font):
3182         (WebCore::Font::verticalRightOrientationFont const):
3183         * platform/graphics/Font.h:
3184         * platform/graphics/FontCascade.cpp:
3185         (WebCore::offsetToMiddleOfGlyph):
3186         * platform/graphics/FontCascade.h:
3187         (WebCore::FontCascade::advancedTextRenderingMode const):
3188         * platform/graphics/FontCascadeFonts.cpp:
3189         (WebCore::FontCascadeFonts::glyphDataForSystemFallback):
3190         (WebCore::FontCascadeFonts::glyphDataForVariant):
3191         (WebCore::glyphPageFromFontRanges):
3192         * platform/graphics/FontDescription.cpp:
3193         (WebCore::FontCascadeDescription::FontCascadeDescription):
3194         * platform/graphics/FontDescription.h:
3195         (WebCore::FontDescription::setTextRenderingMode):
3196         (WebCore::FontDescription::setOrientation):
3197         (WebCore::FontDescription::setWidthVariant):
3198         (WebCore::FontCascadeDescription::setFontSmoothing):
3199         (WebCore::FontCascadeDescription::initialSmallCaps):
3200         (WebCore::FontCascadeDescription::initialFontSmoothing):
3201         (WebCore::FontCascadeDescription::initialTextRenderingMode):
3202         * platform/graphics/FontPlatformData.h:
3203         (WebCore::FontPlatformData::isForTextCombine const):
3204         * platform/graphics/cocoa/FontCacheCoreText.cpp:
3205         (WebCore::preparePlatformFont):
3206         * platform/graphics/cocoa/FontCascadeCocoa.mm:
3207         (WebCore::showLetterpressedGlyphsWithAdvances):
3208         (WebCore::showGlyphsWithAdvances):
3209         (WebCore::FontCascade::drawGlyphs):
3210         (WebCore::FontCascade::fontForCombiningCharacterSequence const):
3211         * platform/graphics/cocoa/FontCocoa.mm:
3212         (WebCore::Font::platformInit):
3213         (WebCore::Font::platformBoundsForGlyph const):
3214         (WebCore::Font::platformWidthForGlyph const):
3215         * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
3216         (WebCore::FontPlatformData::hash const):
3217         (WebCore::mapFontWidthVariantToCTFeatureSelector):
3218         (WebCore::FontPlatformData::ctFont const):
3219         (WebCore::FontPlatformData::description const):
3220         * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
3221         (WebCore::FontPlatformData::buildScaledFont):
3222         * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
3223         (WebCore::Font::platformInit):
3224         (WebCore::Font::platformWidthForGlyph const):
3225         * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:
3226         (WebCore::fontFeatures):
3227         (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
3228         * platform/graphics/mac/SimpleFontDataCoreText.cpp:
3229         (WebCore::Font::getCFStringAttributes const):
3230         * platform/graphics/win/FontCGWin.cpp:
3231         (WebCore::FontCascade::drawGlyphs):
3232         * platform/graphics/win/FontCascadeDirect2D.cpp:
3233         (WebCore::FontCascade::drawGlyphs):
3234         * platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp:
3235         (WebCore::GlyphPage::fill):
3236         * platform/graphics/win/SimpleFontDataDirect2D.cpp:
3237         (WebCore::Font::platformInit):
3238         (WebCore::Font::platformBoundsForGlyph const):
3239         (WebCore::Font::platformWidthForGlyph const):
3240         * platform/text/TextFlags.h:
3241         * rendering/RenderCombineText.cpp:
3242         (WebCore::RenderCombineText::combineTextIfNeeded):
3243         * rendering/RenderLayer.cpp:
3244         (WebCore::RenderLayer::calculateClipRects const):
3245         * rendering/TextPainter.cpp:
3246         (WebCore::TextPainter::paintTextWithShadows):
3247         * rendering/TextPainter.h:
3248         * rendering/style/RenderStyle.cpp:
3249         (WebCore::RenderStyle::fontAndGlyphOrientation):
3250         * rendering/svg/RenderSVGInlineText.cpp:
3251         (WebCore::RenderSVGInlineText::computeNewScaledFontForStyle):
3252
3253 2018-07-16  Sergio Villar Senin  <svillar@igalia.com>
3254
3255         [WebVR] Add support for connect/disconnect and mount/unmount device events
3256         https://bugs.webkit.org/show_bug.cgi?id=187343
3257
3258         Reviewed by Žan Doberšek.
3259
3260         WebVR specs define a series of events as part of the Window Interface Extension. We're
3261         adding support for the connect/disconnect and mount/unmount events both at the module level
3262         and the platform level using OpenVR.
3263
3264         In order to do that we need to keep lists of VRPlatformDisplays at platform level and
3265         VRDisplays at bindings level. We then update those lists accordingly to detect potential
3266         additions/removals, and emit the corresponding signals. A new client interface
3267         VRPlatformDisplayClient was also defined so that VRPlatformDisplay implementations could
3268         notify their clients (typically a VRDisplay).
3269
3270         Last but not least, NavigatorWebVR was updated so it supplements Navigator instead of
3271         supplementing Page.
3272
3273         * Modules/webvr/NavigatorWebVR.cpp: Supplement Navigator not Page.
3274         (WebCore::NavigatorWebVR::getVRDisplays): Keep a list of VRDisplays and update them
3275         conveniently, also emitting the required events under certain conditions (like device
3276         disconnection).
3277         (WebCore::NavigatorWebVR::supplementName): New method.
3278         (WebCore::NavigatorWebVR::from): Ditto.
3279         * Modules/webvr/NavigatorWebVR.h: Supplement Navigator not Page.
3280         * Modules/webvr/VRDisplay.cpp:
3281         (WebCore::VRDisplay::create): Moved suspendIfNeeded() to constructor.
3282         (WebCore::VRDisplay::VRDisplay): Set itself as VRPlatformDisplay client.
3283         (WebCore::VRDisplay::~VRDisplay): Unset as  VRPlatformDisplay client.
3284         (WebCore::VRDisplay::VRPlatformDisplayConnected): Dispatch event on DOM window.
3285         (WebCore::VRDisplay::VRPlatformDisplayDisconnected): Ditto.
3286         (WebCore::VRDisplay::VRPlatformDisplayMounted): Ditto.
3287         (WebCore::VRDisplay::VRPlatformDisplayUnmounted): Ditto.
3288         * Modules/webvr/VRDisplay.h: Extend from VRPlatformDisplayClient.
3289         (WebCore::VRDisplay::document):
3290         * Modules/webvr/VRDisplayEvent.cpp: Updated Copyright.
3291         * Modules/webvr/VRDisplayEvent.h: Ditto.
3292         * Sources.txt: Added the two new files.
3293         * WebCore.xcodeproj/project.pbxproj: Ditto.
3294         * platform/vr/VRManager.cpp:
3295         (WebCore::VRManager::getVRDisplays): Keep a list of VRPlatformDisplays and update them conveniently,
3296         also emitting the required events under certain conditions (like device disconnection).
3297         * platform/vr/VRManager.h:
3298         * platform/vr/VRPlatformDisplay.cpp: New file with common implementations for VRPlatformDisplays.
3299         (WebCore::VRPlatformDisplay::setClient):
3300         (WebCore::VRPlatformDisplay::notifyVRPlatformDisplayEvent):
3301         * platform/vr/VRPlatformDisplay.h: Added a generic method to notify about different
3302         events. Added the client pointer.
3303         * platform/vr/VRPlatformDisplayClient.h: New file. VRPlatformDisplay implementations will
3304         call the client methods in the event of some circumstances happening.
3305         (WebCore::VRPlatformDisplayClient::VRPlatformDisplayConnected):
3306         (WebCore::VRPlatformDisplayClient::VRPlatformDisplayDisconnected):
3307         (WebCore::VRPlatformDisplayClient::VRPlatformDisplayMounted):
3308         (WebCore::VRPlatformDisplayClient::VRPlatformDisplayUnmounted):
3309         * platform/vr/openvr/VRPlatformDisplayOpenVR.cpp:
3310         (WebCore::VRPlatformDisplayOpenVR::updateDisplayInfo): Poll the device for new events to
3311         detect connection/disconnections or device activations/deactivations (HMD
3312         mounted/unmounted).
3313         * platform/vr/openvr/VRPlatformDisplayOpenVR.h:
3314
3315 2018-07-16  Zan Dobersek  <zdobersek@igalia.com>
3316
3317         [Nicosia] Add Nicosia::PlatformLayer, Nicosia::CompositionLayer classes
3318         https://bugs.webkit.org/show_bug.cgi?id=187693
3319
3320         Reviewed by Carlos Garcia Campos.
3321
3322         Add the Nicosia::PlatformLayer class. This will be the base platform
3323         layer class from which different derivatives will be created, addressing
3324         different use cases. The generic PlatformLayer type alias will point to
3325         this class in the future.
3326
3327         First class deriving from Nicosia::PlatformLayer is
3328         Nicosia::CompositionLayer, purpose of which will be to mirror the state
3329         that's stored in the platform-specific GraphicsLayer derivative. It will
3330         also allow making thread-safe updates to that state.
3331
3332         CoordinatedGraphicsLayer implementation now spawns a CompositionLayer
3333         object and tracks state changes in a separate
3334         CompositionLayer::LayerState::Delta object. During flushing, the changed
3335         state is applied to the layer's pending state before the delta is nulled
3336         out. The updated state isn't used anywhere yet, but future changes will
3337         implement committing this state into the rendering pipeline.
3338
3339         There's bits of state not yet being managed by CompositionLayer, e.g.
3340         debug visuals, filters and animations. These will be addressed later.
3341
3342         The m_solidColor member variable is added to CoordinatedGraphicsLayer in
3343         order to properly store the solid color value. Normally this would be
3344         contained by the parent GraphicsLayer class, but no such member variable
3345         exists there.
3346
3347         * platform/TextureMapper.cmake:
3348         * platform/graphics/nicosia/NicosiaPlatformLayer.cpp: Added.
3349         (Nicosia::PlatformLayer::PlatformLayer):
3350         (Nicosia::CompositionLayer::CompositionLayer):
3351         * platform/graphics/nicosia/NicosiaPlatformLayer.h: Added.
3352         (Nicosia::PlatformLayer::isCompositionLayer const):
3353         (Nicosia::PlatformLayer::id const):
3354         (Nicosia::CompositionLayer::create):
3355         (Nicosia::CompositionLayer::LayerState::Flags::Flags):
3356         (Nicosia::CompositionLayer::updateState):
3357         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
3358         (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
3359         (WebCore::CoordinatedGraphicsLayer::setPosition):
3360         (WebCore::CoordinatedGraphicsLayer::setAnchorPoint):
3361         (WebCore::CoordinatedGraphicsLayer::setSize):
3362         (WebCore::CoordinatedGraphicsLayer::setTransform):
3363         (WebCore::CoordinatedGraphicsLayer::setChildrenTransform):
3364         (WebCore::CoordinatedGraphicsLayer::setPreserves3D):
3365         (WebCore::CoordinatedGraphicsLayer::setMasksToBounds):
3366         (WebCore::CoordinatedGraphicsLayer::setDrawsContent):
3367         (WebCore::CoordinatedGraphicsLayer::setContentsVisible):
3368         (WebCore::CoordinatedGraphicsLayer::setContentsOpaque):
3369         (WebCore::CoordinatedGraphicsLayer::setBackfaceVisibility):
3370         (WebCore::CoordinatedGraphicsLayer::setOpacity):
3371         (WebCore::CoordinatedGraphicsLayer::setContentsRect):
3372         (WebCore::CoordinatedGraphicsLayer::setContentsTileSize):
3373         (WebCore::CoordinatedGraphicsLayer::setContentsTilePhase):
3374         (WebCore::CoordinatedGraphicsLayer::setContentsToSolidColor):
3375         (WebCore::CoordinatedGraphicsLayer::setMaskLayer):
3376         (WebCore::CoordinatedGraphicsLayer::setReplicatedByLayer):
3377         (WebCore::CoordinatedGraphicsLayer::syncChildren):
3378         (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
3379         * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
3380
3381 2018-07-15  Wenson Hsieh  <wenson_hsieh@apple.com>
3382
3383         [iOS apps on macOS] Playing embedded Twitter videos in the News app crashes the web process
3384         https://bugs.webkit.org/show_bug.cgi?id=187690
3385         <rdar://problem/41869703>
3386
3387         Reviewed by Tim Horton.
3388
3389         Work around unexpected behavior when soft-linking AVFoundation. After using `dlopen_preflight` to check for the
3390         existence of a library prior to loading the library using `dlopen`, `dlsym` subsequently returns null for some
3391         symbols that would otherwise be available. This causes us to RELEASE_ASSERT later down the road when we try to
3392         load AVAudioSessionModeDefault in AudioSessionIOS.mm.
3393
3394         To fix this for now, simply check for the library directly instead of using the more lightweight preflight
3395         check. See clone: <rdar://problem/42224780> for more detail.
3396
3397         * platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm:
3398         (WebCore::AVFoundationMIMETypeCache::isAvailable const):
3399
3400 2018-07-14  Simon Fraser  <simon.fraser@apple.com>
3401
3402         Shrink StyleFillData, StyleStrokeData and StyleMiscData
3403         https://bugs.webkit.org/show_bug.cgi?id=187681
3404
3405         Reviewed by Anders Carlsson.
3406
3407         Shrink these data structures by making more enum classes one byte in size, and
3408         re-ordering. StyleFillData goes from 56 to 48, StyleStrokeData from 80 to 72,
3409         StyleMiscData from 40 to 32 bytes.
3410
3411         * rendering/style/SVGRenderStyleDefs.cpp:
3412         (WebCore::StyleFillData::StyleFillData):
3413         (WebCore::StyleFillData::operator== const):
3414         (WebCore::StyleStrokeData::StyleStrokeData):
3415         (WebCore::StyleStrokeData::operator== const):
3416         (WebCore::StyleStopData::operator== const):
3417         (WebCore::StyleMiscData::StyleMiscData):
3418         * rendering/style/SVGRenderStyleDefs.h:
3419
3420 2018-07-14  Simon Fraser  <simon.fraser@apple.com>
3421
3422         Shrink CachedResource and subclasses
3423         https://bugs.webkit.org/show_bug.cgi?id=187546
3424
3425         Reviewed by Daniel Bates.
3426
3427         Shrink CachedResource down from 1384 to 1336 bytes, CachedImage from 1480 to
3428         1424 bytes, and CachedFont a little.
3429         
3430         This saves about 23KB on cnn.com.
3431
3432         * loader/ResourceLoaderOptions.h:
3433         * loader/cache/CachedFont.h:
3434         * loader/cache/CachedImage.h:
3435         * loader/cache/CachedResource.cpp:
3436         (WebCore::CachedResource::CachedResource):
3437         * loader/cache/CachedResource.h:
3438         * platform/network/CacheValidation.h:
3439         (WebCore::RedirectChainCacheStatus::RedirectChainCacheStatus):
3440         * platform/network/NetworkLoadMetrics.h:
3441         * platform/network/ParsedContentRange.h:
3442         * platform/network/ResourceRequestBase.h:
3443         * platform/network/ResourceResponseBase.h:
3444
3445 2018-07-14  Simon Fraser  <simon.fraser@apple.com>
3446
3447         Shrink some style-related classes and enums
3448         https://bugs.webkit.org/show_bug.cgi?id=187680
3449
3450         Reviewed by Antti Koivisto.
3451         
3452         Make all the enum classes in RenderStyleConstants be one byte big (all have less
3453         than 256 values).
3454         
3455         Shrink DocumentRuleSet from 384 to 368 bytes by re-ordering, which also helps shrink
3456         StyleResolver from 1024 to 952 bytes.
3457         
3458         Shrink BorderValue by re-ordering (now that the layout of Color has changed) which
3459         shrinks BorderData from 168 to 136 bytes.
3460         
3461         Convert a couple of other enums to enum class so that they can have explicit size.
3462
3463         * css/DocumentRuleSets.h:
3464         * css/MediaQueryMatcher.cpp:
3465         (WebCore::MediaQueryMatcher::documentElementUserAgentStyle const):
3466         * css/StyleMedia.cpp:
3467         (WebCore::StyleMedia::matchMedium const):
3468         * css/StyleResolver.cpp:
3469         (WebCore::StyleResolver::StyleResolver):
3470         (WebCore::StyleResolver::State::State):
3471         (WebCore::StyleResolver::styleForElement):
3472         (WebCore::StyleResolver::cascadedPropertiesForRollback):
3473         (WebCore::StyleResolver::applyProperty):
3474         (WebCore::cascadeLevelForIndex):
3475         * css/StyleResolver.h:
3476         * rendering/style/BorderValue.h:
3477         * rendering/style/RenderStyle.cpp:
3478         * rendering/style/RenderStyleConstants.h:
3479         * style/StyleTreeResolver.cpp:
3480         (WebCore::Style::TreeResolver::styleForElement):
3481         * svg/SVGElementRareData.h:
3482         (WebCore::SVGElementRareData::overrideComputedStyle):
3483
3484 2018-07-14  Kocsen Chung  <kocsen_chung@apple.com>
3485
3486         Ensure WebKit stack is ad-hoc signed
3487         https://bugs.webkit.org/show_bug.cgi?id=187667
3488
3489         Reviewed by Alexey Proskuryakov.
3490
3491         * Configurations/Base.xcconfig:
3492
3493 2018-07-14  Dirk Schulze  <krit@webkit.org>
3494
3495         [css-masking] Fully support -webkit-clip-path on SVG elements
3496         https://bugs.webkit.org/show_bug.cgi?id=185829
3497
3498         Reviewed by Simon Fraser.
3499
3500         -webkit-clip-path contributes to SVG elements with boxes, shapes and now with
3501         element references to <clipPath> elements as well. Make sure that all types
3502         contribute to hit-testing of the SVG element as well as they should.
3503
3504         Tests: svg/clip-path/webkit-clip-path-after-expected.svg
3505                svg/clip-path/webkit-clip-path-after.svg
3506                svg/clip-path/webkit-clip-path-before-expected.svg
3507                svg/clip-path/webkit-clip-path-before.svg
3508                svg/dynamic-updates/SVGClipPath-prefixed-influences-hitTesting.html
3509                svg/dynamic-updates/SVGClipPath-prefixed-path-influences-hitTesting.html
3510                svg/dynamic-updates/SVGClipPathElement-prefixed-css-transform-influences-hitTesting.html
3511                svg/dynamic-updates/SVGClipPathElement-prefixed-transform-influences-hitTesting.html
3512
3513         * rendering/svg/SVGRenderSupport.cpp: Share code as much as possible.
3514         (WebCore::clipPathReferenceBox):
3515         (WebCore::isPointInCSSClippingArea): Take -webkit-clip-path into account.
3516         (WebCore::SVGRenderSupport::clipContextToCSSClippingArea):
3517         (WebCore::SVGRenderSupport::pointInClippingArea):
3518         * rendering/svg/SVGRenderSupport.h:
3519         * rendering/svg/SVGRenderingContext.cpp: Clip to -webkit-clip-path boxes, shapes and references.
3520         (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
3521         * rendering/svg/SVGResources.cpp: Add -webkit-clip-path references to cached resources. Mimic SVG clip-path.
3522         (WebCore::SVGResources::buildCachedResources):
3523
3524 2018-07-13  Simon Fraser  <simon.fraser@apple.com>
3525
3526         Avoid fetching visitedDependentColor() so many times in editing code
3527         https://bugs.webkit.org/show_bug.cgi?id=187676
3528
3529         Reviewed by Zalan Bujtas.
3530         
3531         editingAttributedStringFromRange called style.visitedDependentColor() twice for each property,
3532         and fontAttributesForSelectionStart() called it two or three times. Use a local Color variable
3533         to avoid so many calls. Also replace a call to alpha() with isVisible() which makes the usage more clear.
3534
3535         No behavior change.
3536
3537         * editing/cocoa/EditorCocoa.mm:
3538         (WebCore::Editor::fontAttributesForSelectionStart const):
3539         * editing/cocoa/HTMLConverter.mm:
3540         (WebCore::editingAttributedStringFromRange):
3541
3542 2018-07-13  Youenn Fablet  <youenn@apple.com>
3543
3544         Support connecting a MediaStreamAudioDestinationNode to RTCPeerConnection
3545         https://bugs.webkit.org/show_bug.cgi?id=187627
3546         <rdar://problem/35334400>
3547
3548         Reviewed by Jer Noble.
3549
3550         When MediaStreamAudioSource is called to read new audio samples,
3551         convert these samples to a WebAudioBufferList and call RealtimeMediaSource::audioSamplesAvailable.
3552         This makes its observers to get the audio data.
3553
3554         Test: webrtc/peer-connection-createMediaStreamDestination.html
3555
3556         * Modules/mediastream/MediaStream.cpp:
3557         (WebCore::MediaStream::create): Minor refactoring.
3558         * Modules/webaudio/MediaStreamAudioDestinationNode.cpp:
3559         (WebCore::createMediaStream):
3560         (WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode):
3561         (WebCore::MediaStreamAudioDestinationNode::process):
3562         * Modules/webaudio/MediaStreamAudioDestinationNode.h:
3563         * Modules/webaudio/MediaStreamAudioSource.cpp:
3564         (WebCore::MediaStreamAudioSource::MediaStreamAudioSource):
3565         (WebCore::MediaStreamAudioSource::consumeAudio):
3566         * Modules/webaudio/MediaStreamAudioSource.h:
3567         * Modules/webaudio/MediaStreamAudioSourceCocoa.cpp: Added.
3568         (WebCore::streamDescription):
3569         (WebCore::MediaStreamAudioSource::consumeAudio):
3570         * WebCore.xcodeproj/project.pbxproj:
3571         * platform/audio/AudioDestinationConsumer.h: Removed.
3572         * platform/mediastream/MediaStreamPrivate.cpp:
3573         (WebCore::MediaStreamPrivate::create):
3574         * platform/mediastream/MediaStreamPrivate.h:
3575
3576 2018-07-13  Christopher Reid  <chris.reid@sony.com>
3577
3578         [WinCairo] Enable WebGL when Accelerated Compositing is disabled
3579         https://bugs.webkit.org/show_bug.cgi?id=187664
3580
3581         Reviewed by Fujii Hironori.
3582
3583         AC was disabled for WinCairo in r233725 but it can still run WebGL without AC.
3584
3585         * html/HTMLCanvasElement.cpp:
3586
3587 2018-07-13  Chris Dumez  <cdumez@apple.com>
3588
3589         Crash under ApplicationCacheGroup::didFailLoadingEntry()
3590         https://bugs.webkit.org/show_bug.cgi?id=187661
3591         <rdar://problem/42179755>
3592
3593         Reviewed by Youenn Fablet.
3594
3595         If ApplicationCacheResourceLoader::create() fails synchronously with
3596         ApplicationCacheResourceLoader::Error::CannotCreateResource error, then
3597         m_entryLoader will be null when didFailLoadingEntry() is called. However,
3598         didFailLoadingEntry() fails to null check m_entryLoader before using it.
3599
3600         * loader/appcache/ApplicationCacheGroup.cpp:
3601         (WebCore::ApplicationCacheGroup::didFailLoadingEntry):
3602         (WebCore::ApplicationCacheGroup::startLoadingEntry):
3603         * loader/appcache/ApplicationCacheGroup.h:
3604
3605 2018-07-13  Alex Christensen  <achristensen@webkit.org>
3606
3607         Add release assertion to check thread in TimerBase::setNextFireTime
3608         https://bugs.webkit.org/show_bug.cgi?id=187666
3609
3610         Reviewed by Ryosuke Niwa.
3611
3612         This should give us insight into what is causing <rdar://problem/33352721>
3613         
3614         * platform/Timer.cpp:
3615         (WebCore::TimerBase::setNextFireTime):
3616
3617 2018-07-13  Ryosuke Niwa  <rniwa@webkit.org>
3618
3619         [iOS] [WK1] Crash inside IOSurfacePool::platformGarbageCollectNow() in WebThread
3620         https://bugs.webkit.org/show_bug.cgi?id=187635
3621         <rdar://problem/34297065>
3622
3623         Reviewed by Simon Fraser.
3624
3625         r167717 added code to trigger a CA commit in the web process via platformGarbageCollectNow() in order to free IOSurface-related memory.
3626         However, that code is also running in the web thread in apps using WebKit1, causing unwanted UIView layout on the web thread.
3627
3628         Fix by not triggering this CA commit if it's called on the web thread.
3629
3630         * platform/graphics/cocoa/IOSurfacePoolCocoa.mm:
3631         (WebCore::IOSurfacePool::platformGarbageCollectNow):
3632
3633 2018-07-13  Antoine Quint  <graouts@apple.com>
3634
3635         Dark Mode: document markers are difficult to see
3636         https://bugs.webkit.org/show_bug.cgi?id=187632
3637         <rdar://problem/41099719>
3638
3639         Reviewed by Simon Fraser.
3640
3641         We update the way we draw the document markers for macOS and use more constrasting colors in dark mode.
3642         Paving the way for future improvements, we move the drawLineForDocumentMarker() method from GraphicsContext
3643         to RenderTheme and implement a first version in RenderThemeMac. The circles used for the underline are now
3644         drawn directly with Core Graphics and we no longer use an image resource. To allow both GraphicsContext
3645         and RenderTheme to have different versions of the drawLineForDocumentMarker() method, the DocumentMarkerLineStyle
3646         enum is now an "enum class".
3647
3648         No new test due to webkit.org/b/105616, webkit.org/b/187655 was raised to track the creation of new tests
3649         when it becomes possible again.
3650
3651         * platform/graphics/GraphicsContext.h:
3652         * platform/graphics/GraphicsContextImpl.h:
3653         * platform/graphics/cairo/CairoOperations.cpp:
3654         (WebCore::Cairo::drawLineForDocumentMarker):
3655         * platform/graphics/cairo/CairoOperations.h:
3656         * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
3657         (WebCore::GraphicsContextImplCairo::drawLineForDocumentMarker):
3658         * platform/graphics/cairo/GraphicsContextImplCairo.h:
3659         * platform/graphics/cocoa/GraphicsContextCocoa.mm:
3660         (WebCore::GraphicsContext::drawLineForDocumentMarker):
3661         * platform/graphics/displaylists/DisplayListItems.h:
3662         (WebCore::DisplayList::DrawLineForDocumentMarker::create):
3663         (WebCore::DisplayList::DrawLineForDocumentMarker::DrawLineForDocumentMarker):
3664         * platform/graphics/displaylists/DisplayListRecorder.cpp:
3665         (WebCore::DisplayList::Recorder::drawLineForDocumentMarker):
3666         * platform/graphics/displaylists/DisplayListRecorder.h:
3667         * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:
3668         (Nicosia::CairoOperationRecorder::drawLineForDocumentMarker):
3669         * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h:
3670         * platform/graphics/win/GraphicsContextCGWin.cpp:
3671         (WebCore::GraphicsContext::drawLineForDocumentMarker):
3672         * rendering/InlineTextBox.cpp:
3673         (WebCore::InlineTextBox::paintPlatformDocumentMarker): Call drawLineForDocumentMarker() on the RenderTheme on
3674         macOS and on GraphicsContext in all other cases.
3675         * rendering/RenderTheme.cpp:
3676         (WebCore::RenderTheme::drawLineForDocumentMarker):
3677         * rendering/RenderTheme.h:
3678         * rendering/RenderThemeMac.h:
3679         * rendering/RenderThemeMac.mm:
3680         (WebCore::colorForStyle): Provide different colors for light and dark modes.
3681         (WebCore::RenderThemeMac::drawLineForDocumentMarker): A new macOS-specific version of drawLineForDocumentMarker()
3682         where we paint circles using Core Graphics directly.
3683
3684 2018-07-13  Charlie Turner  <cturner@igalia.com>
3685
3686         [GStreamer] Use smart pointers for GstByteReader
3687         https://bugs.webkit.org/show_bug.cgi?id=187638
3688
3689         Reviewed by Xabier Rodriguez-Calvar.
3690
3691         * platform/graphics/gstreamer/GUniquePtrGStreamer.h: Add
3692         specialisation for GstByteReader.
3693         * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
3694         Use the new smart pointer class to avoid needing to remember where
3695         to call gst_byte_reader_free.
3696         (webKitMediaClearKeyDecryptorDecrypt):
3697
3698 2018-07-13  Basuke Suzuki  <Basuke.Suzuki@sony.com>
3699
3700         [Curl] Move HTTP Setup logic from CurlRequest to CurlHandle for reuse.
3701         https://bugs.webkit.org/show_bug.cgi?id=187427
3702
3703         Reviewed by Fujii Hironori.
3704
3705         CurlContext will be used by Secure WebSocket client, but HTTP setup code is
3706         in CurlRequest, which is only for regular HTTP/HTTPS transaction. This patch
3707         allows wss client to setup CurlHandle for HTTPS communication, such as TLS,
3708         proxy or authentication.
3709
3710         No new tests because there's no behavior change.
3711
3712         * platform/network/curl/CurlContext.cpp:
3713         (WebCore::CurlHandle::CurlHandle):
3714         (WebCore::CurlHandle::enableSSLForHost):
3715         (WebCore::CurlHandle::willSetupSslCtx):
3716         (WebCore::CurlHandle::willSetupSslCtxCallback):
3717         (WebCore::CurlHandle::sslErrors const):
3718         (WebCore::CurlHandle::setUrl):
3719         (WebCore::CurlHandle::enableHttp):
3720         (WebCore::CurlHandle::enableConnectionOnly):
3721         (WebCore::CurlHandle::certificateInfo const):
3722         (WebCore::CurlHandle::enableStdErrIfUsed):
3723         (WebCore::CurlHandle::initialize): Deleted.
3724         * platform/network/curl/CurlContext.h:
3725         (WebCore::CurlHandle::url const):
3726         * platform/network/curl/CurlRequest.cpp:
3727         (WebCore::CurlRequest::setupTransfer):
3728         (WebCore::CurlRequest::didReceiveHeader):
3729         (WebCore::CurlRequest::didCompleteTransfer):
3730         (WebCore::CurlRequest::finalizeTransfer):
3731         (WebCore::CurlRequest::willSetupSslCtx): Deleted.
3732         (WebCore::CurlRequest::willSetupSslCtxCallback): Deleted.
3733         * platform/network/curl/CurlRequest.h:
3734         * platform/network/curl/CurlSSLVerifier.cpp:
3735         (WebCore::CurlSSLVerifier::CurlSSLVerifier):
3736         (WebCore::CurlSSLVerifier::verify):
3737         * platform/network/curl/CurlSSLVerifier.h:
3738
3739 2018-07-13  Xabier Rodriguez Calvar  <calvaris@igalia.com>
3740
3741         [GStreamer][MSE] Add GstFlowCombiner to handle non-linked inactive branches
3742         https://bugs.webkit.org/show_bug.cgi?id=187636
3743
3744         Reviewed by Carlos Garcia Campos.
3745
3746         When we have more than one source buffer, only one will be
3747         rendered and the inactive branch will report linking errors that
3748         we have to deal with.
3749
3750         * platform/graphics/gstreamer/GUniquePtrGStreamer.h: Added GstFlowCombiner.
3751         * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
3752         (webkitMediaSrcChain): Combine the flow in the flow combiner.
3753         (webkit_media_src_init): Initialize the flow combiner.
3754         (webKitMediaSrcLinkStreamToSrcPad): Add the proxypad to the
3755         combiner and set the chain function.
3756         * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamerPrivate.h:
3757         Declare the flow combiner.
3758
3759 2018-07-13  Charlie Turner  <cturner@igalia.com>
3760
3761         [GStreamer] Add GstBufferMapped abstraction
3762         https://bugs.webkit.org/show_bug.cgi?id=187600
3763
3764         Reviewed by Xabier Rodriguez-Calvar.
3765
3766         There is a similar abstraction called `mapGstBuffer` and friends,
3767         which have a slightly different use-case: wanting a buffer that is
3768         mapped for a longer lifetime without have to keep track of the map
3769         infos separately. They could be subsumed by this abstraction, but
3770         everytime they need to write to the buffer, they'd have to remap
3771         the memory blocks.
3772
3773         This abstraction is more for one-short reads and writes saving the user
3774         from remembering to unmap the buffer and having to manage to
3775         auxiliary GstMapInfo structures.
3776
3777         * platform/graphics/gstreamer/GStreamerCommon.h:
3778         (WebCore::GstMappedBuffer::GstMappedBuffer):
3779         (WebCore::GstMappedBuffer::~GstMappedBuffer):
3780         (WebCore::GstMappedBuffer::data):
3781         (WebCore::GstMappedBuffer::size const):
3782         (WebCore::GstMappedBuffer::operator bool const):
3783         * platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp:
3784         (WebCore::InbandTextTrackPrivateGStreamer::notifyTrackOfSample):
3785         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
3786         (WebCore::MediaPlayerPrivateGStreamerBase::handleSyncMessage):
3787         (WebCore::MediaPlayerPrivateGStreamerBase::initializationDataEncountered):
3788         * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
3789         (webKitMediaClearKeyDecryptorSetupCipher):
3790         (webKitMediaClearKeyDecryptorDecrypt):
3791
3792 2018-07-12  Wenson Hsieh  <wenson_hsieh@apple.com>
3793
3794         Make it easier to hit the significant rendered text layout milestone on pages with main article elements
3795         https://bugs.webkit.org/show_bug.cgi?id=187578
3796         <rdar://problem/42104637>
3797
3798         Reviewed by Ryosuke Niwa.
3799
3800         Our current heuristics for triggering the significant rendered text layout milestone are very conservative, with
3801         the intention of avoiding false positives. In practice, we can relax some of these constraints when we've
3802         detected the presence of a main article element on the page. (e.g. in New York Times articles). See per-method
3803         changes below for more detail.
3804
3805         Test: RenderingProgressTests.DidRenderSignificantAmountOfText
3806
3807         * dom/Document.cpp:
3808         (WebCore::Document::registerArticleElement):
3809         (WebCore::Document::unregisterArticleElement):
3810         (WebCore::Document::updateMainArticleElementAfterLayout):
3811
3812         As a post layout task, update the main article element by looping through the articles (up to a maximum limit of
3813         10) in search of an article element that is several times larger than the second largest article element.
3814
3815         * dom/Document.h:
3816
3817         Store a set containing the article elements in the document, as well as the current main article on the page.
3818
3819         (WebCore::Document::hasMainArticleElement const):
3820         * html/Element.cpp:
3821         (WebCore::Element::insertedIntoAncestor):
3822         (WebCore::Element::removedFromAncestor):
3823
3824         Keep track of the article elements that exist in the document whenever elements with the article tag are added
3825         to or removed from the document.
3826
3827         * page/FrameView.cpp:
3828
3829         Add new minimum thresholds for firing the significant rendered text milestone when there exists a main article.
3830
3831         (WebCore::FrameView::performPostLayoutTasks):
3832         (WebCore::FrameView::updateSignificantRenderedTextMilestoneIfNeeded):
3833
3834         Take the main article element into consideration when determining whether to fire the significant text
3835         layout milestone.
3836
3837 2018-07-12  Daniel Bates  <dabates@apple.com>
3838
3839         JavaScript URL gives incorrect result when frame is navigated
3840         https://bugs.webkit.org/show_bug.cgi?id=187203
3841         <rdar://problem/41438443>
3842
3843         Reviewed by David Kilzer.
3844
3845         * loader/SubframeLoader.cpp:
3846         (WebCore::SubframeLoader::requestFrame):
3847
3848 2018-07-12  Alex Christensen  <achristensen@webkit.org>
3849
3850         Reduce size of WebCore::URL
3851         https://bugs.webkit.org/show_bug.cgi?id=186820
3852
3853         Reviewed by Yusuke Suzuki and Youenn Fablet.
3854
3855         We were using 32 bits for the length of the port, which is always between 0 and 5 inclusive
3856         because port numbers are missing or between 0 and 65535.  Let's just use 3 bits here.
3857         We were using 32 bits for the length of the scheme, which is usually 3-5 characters and can be
3858         longer for some custom schemes, but I've never seen one more than 20 characters.  If we assume
3859         schemes are always less than 64MB, we can save 8 bytes per URL!
3860
3861         No change in behavior, just less memory use!
3862         
3863         To restore the IPC encoding to how it was before r221165, I just encode the string and reparse it.
3864
3865         * platform/URL.cpp:
3866         (WebCore::URL::invalidate):
3867         (WebCore::URL::lastPathComponent const):
3868         (WebCore::URL::port const):
3869         (WebCore::URL::protocolHostAndPort const):
3870         (WebCore::URL::path const):
3871         (WebCore::URL::removePort):
3872         (WebCore::URL::setPort):
3873         (WebCore::URL::setHostAndPort):
3874         (WebCore::URL::setPath):
3875         * platform/URL.h:
3876         (WebCore::URL::encode const):
3877         (WebCore::URL::decode):
3878         (WebCore::URL::hasPath const):
3879         (WebCore::URL::pathStart const):
3880         * platform/URLParser.cpp:
3881         (WebCore::URLParser::copyBaseWindowsDriveLetter):
3882         (WebCore::URLParser::urlLengthUntilPart):
3883         (WebCore::URLParser::copyURLPartsUntil):
3884         (WebCore::URLParser::shouldPopPath):
3885         (WebCore::URLParser::popPath):
3886         (WebCore::URLParser::parse):
3887         (WebCore::URLParser::parsePort):
3888         (WebCore::URLParser::parseHostAndPort):
3889         (WebCore::URLParser::allValuesEqual):
3890         (WebCore::URLParser::internalValuesConsistent):
3891         * workers/service/server/RegistrationDatabase.cpp:
3892         Increment the service worker registration schema version because of the URL encoding change.
3893
3894 2018-07-12  Youenn Fablet  <youenn@apple.com>
3895