Execute pending scripts asynchronously after stylesheet loads complete
[WebKit-https.git] / Source / WebCore / ChangeLog
1 2017-02-16  Antti Koivisto  <antti@apple.com>
2
3         Execute pending scripts asynchronously after stylesheet loads complete
4         https://bugs.webkit.org/show_bug.cgi?id=168367
5         rdar://problem/30561379
6
7         Reviewed by Andreas Kling.
8
9         The current synchronous execution is fragile and creates various problems.
10
11         * css/StyleSheetContents.cpp:
12         (WebCore::StyleSheetContents::checkLoaded):
13         * dom/ContainerNode.cpp:
14         (WebCore::ContainerNode::takeAllChildrenFrom):
15         (WebCore::ContainerNode::notifyChildInserted):
16         (WebCore::ContainerNode::removeChild):
17         (WebCore::ContainerNode::parserRemoveChild):
18         (WebCore::ContainerNode::removeChildren):
19
20             Remove various places where we would trigger delayed synchronous execution.
21
22         * dom/Document.cpp:
23         (WebCore::Document::Document):
24         (WebCore::Document::recalcStyle):
25
26             Trigger scroll to anchor at the end of style resolution instead of when style sheet load completes.
27
28         (WebCore::Document::didRemoveAllPendingStylesheet):
29
30             Call asynchronous script execution function.
31
32         * dom/Document.h:
33         (WebCore::Document::setNeedsNotifyRemoveAllPendingStylesheet): Deleted.
34         (WebCore::Document::notifyRemovePendingSheetIfNeeded): Deleted.
35         * dom/ScriptableDocumentParser.cpp:
36         (WebCore::ScriptableDocumentParser::ScriptableDocumentParser):
37         (WebCore::ScriptableDocumentParser::executeScriptsWaitingForStylesheetsSoon):
38         (WebCore::ScriptableDocumentParser::scriptsWaitingForStylesheetsExecutionTimerFired):
39
40             Add a timer for executing pending scripts.
41
42         (WebCore::ScriptableDocumentParser::detach):
43         * dom/ScriptableDocumentParser.h:
44         (WebCore::ScriptableDocumentParser::executeScriptsWaitingForStylesheets):
45         * html/HTMLLinkElement.cpp:
46         (WebCore::HTMLLinkElement::removedFrom):
47         (WebCore::HTMLLinkElement::removePendingSheet):
48         * html/HTMLLinkElement.h:
49         * html/parser/HTMLDocumentParser.cpp:
50         (WebCore::HTMLDocumentParser::detach):
51         * loader/DocumentLoader.cpp:
52         (WebCore::DocumentLoader::isLoadingInAPISense):
53
54             Stay in loading state if we have a pending script. This matches existing behavior.
55
56         * style/StyleScope.cpp:
57         (WebCore::Style::Scope::removePendingSheet):
58         * style/StyleScope.h:
59
60 2017-02-16  Anders Carlsson  <andersca@apple.com>
61
62         Set the DHTML drag image in the DHTML type check
63         https://bugs.webkit.org/show_bug.cgi?id=168451
64
65         Reviewed by Wenson Hsieh.
66
67         * page/DragController.cpp:
68         (WebCore::DragController::startDrag):
69
70 2017-02-16  Anders Carlsson  <andersca@apple.com>
71
72         Begin removing EFL code from WebCore.
73
74         Rubber-stamped by Alex Christensen.
75
76         * PlatformEfl.cmake: Removed.
77         * editing/efl/EditorEfl.cpp: Removed.
78         * page/efl/DragControllerEfl.cpp: Removed.
79         * page/efl/EventHandlerEfl.cpp: Removed.
80         * platform/audio/efl/AudioBusEfl.cpp: Removed.
81         * platform/efl/CursorEfl.cpp: Removed.
82         * platform/efl/DefaultTheme/CMakeLists.txt: Removed.
83         * platform/efl/DefaultTheme/default.edc: Removed.
84         * platform/efl/DefaultTheme/widget/button/button.edc: Removed.
85         * platform/efl/DefaultTheme/widget/button/img_button_focus.png: Removed.
86         * platform/efl/DefaultTheme/widget/button/img_button_hover.png: Removed.
87         * platform/efl/DefaultTheme/widget/button/img_button_normal.png: Removed.
88         * platform/efl/DefaultTheme/widget/button/img_button_press.png: Removed.
89         * platform/efl/DefaultTheme/widget/check/check.edc: Removed.
90         * platform/efl/DefaultTheme/widget/check/img_check_bg_disabled.png: Removed.
91         * platform/efl/DefaultTheme/widget/check/img_check_bg_enabled.png: Removed.
92         * platform/efl/DefaultTheme/widget/check/img_check_off.png: Removed.
93         * platform/efl/DefaultTheme/widget/check/img_check_off_focus.png: Removed.
94         * platform/efl/DefaultTheme/widget/check/img_check_off_hover.png: Removed.
95         * platform/efl/DefaultTheme/widget/check/img_check_on.png: Removed.
96         * platform/efl/DefaultTheme/widget/check/img_check_on_focus.png: Removed.
97         * platform/efl/DefaultTheme/widget/check/img_check_on_hover.png: Removed.
98         * platform/efl/DefaultTheme/widget/combo/combo.edc: Removed.
99         * platform/efl/DefaultTheme/widget/combo/combo_focus.png: Removed.
100         * platform/efl/DefaultTheme/widget/combo/combo_focus_button.png: Removed.
101         * platform/efl/DefaultTheme/widget/combo/combo_focus_button_transparent.png: Removed.
102         * platform/efl/DefaultTheme/widget/combo/combo_focus_transparent.png: Removed.
103         * platform/efl/DefaultTheme/widget/combo/combo_hover.png: Removed.
104         * platform/efl/DefaultTheme/widget/combo/combo_hover_button.png: Removed.
105         * platform/efl/DefaultTheme/widget/combo/combo_hover_button_transparent.png: Removed.
106         * platform/efl/DefaultTheme/widget/combo/combo_hover_transparent.png: Removed.
107         * platform/efl/DefaultTheme/widget/combo/combo_normal.png: Removed.
108         * platform/efl/DefaultTheme/widget/combo/combo_normal_button.png: Removed.
109         * platform/efl/DefaultTheme/widget/combo/combo_normal_button_transparent.png: Removed.
110         * platform/efl/DefaultTheme/widget/combo/combo_normal_transparent.png: Removed.
111         * platform/efl/DefaultTheme/widget/combo/combo_press.png: Removed.
112         * platform/efl/DefaultTheme/widget/combo/combo_press_button.png: Removed.
113         * platform/efl/DefaultTheme/widget/combo/combo_press_button_transparent.png: Removed.
114         * platform/efl/DefaultTheme/widget/combo/combo_press_transparent.png: Removed.
115         * platform/efl/DefaultTheme/widget/combo/icon.png: Removed.
116         * platform/efl/DefaultTheme/widget/entry/entry.edc: Removed.
117         * platform/efl/DefaultTheme/widget/entry/img_focused.png: Removed.
118         * platform/efl/DefaultTheme/widget/entry/img_hovered.png: Removed.
119         * platform/efl/DefaultTheme/widget/entry/img_normal.png: Removed.
120         * platform/efl/DefaultTheme/widget/progressbar/bt_base.png: Removed.
121         * platform/efl/DefaultTheme/widget/progressbar/progressbar.edc: Removed.
122         * platform/efl/DefaultTheme/widget/progressbar/shelf_inset.png: Removed.
123         * platform/efl/DefaultTheme/widget/radio/img_radio_bg_disabled.png: Removed.
124         * platform/efl/DefaultTheme/widget/radio/img_radio_bg_enabled.png: Removed.
125         * platform/efl/DefaultTheme/widget/radio/img_radio_off.png: Removed.
126         * platform/efl/DefaultTheme/widget/radio/img_radio_off_focus.png: Removed.
127         * platform/efl/DefaultTheme/widget/radio/img_radio_off_hover.png: Removed.
128         * platform/efl/DefaultTheme/widget/radio/img_radio_on.png: Removed.
129         * platform/efl/DefaultTheme/widget/radio/img_radio_on_focus.png: Removed.
130         * platform/efl/DefaultTheme/widget/radio/img_radio_on_hover.png: Removed.
131         * platform/efl/DefaultTheme/widget/radio/radio.edc: Removed.
132         * platform/efl/DefaultTheme/widget/scrollbar/scrollbar.edc: Removed.
133         * platform/efl/DefaultTheme/widget/scrollbar/scrollbar_bg_horizontal.png: Removed.
134         * platform/efl/DefaultTheme/widget/scrollbar/scrollbar_bg_vertical.png: Removed.
135         * platform/efl/DefaultTheme/widget/scrollbar/scrollbar_thumb_horizontal.png: Removed.
136         * platform/efl/DefaultTheme/widget/scrollbar/scrollbar_thumb_vertical.png: Removed.
137         * platform/efl/DefaultTheme/widget/search/cancel/cancel_normal_button.png: Removed.
138         * platform/efl/DefaultTheme/widget/search/cancel/cancel_normal_button2.png: Removed.
139         * platform/efl/DefaultTheme/widget/search/cancel/search_cancel.edc: Removed.
140         * platform/efl/DefaultTheme/widget/search/decoration/decoration_normal_button.png: Removed.
141         * platform/efl/DefaultTheme/widget/search/decoration/search_decoration.edc: Removed.
142         * platform/efl/DefaultTheme/widget/search/field/field_focused.png: Removed.
143         * platform/efl/DefaultTheme/widget/search/field/field_hovered.png: Removed.
144         * platform/efl/DefaultTheme/widget/search/field/field_normal.png: Removed.
145         * platform/efl/DefaultTheme/widget/search/field/search_field.edc: Removed.
146         * platform/efl/DefaultTheme/widget/slider/slider.edc: Removed.
147         * platform/efl/DefaultTheme/widget/slider/slider_fill_h.png: Removed.
148         * platform/efl/DefaultTheme/widget/slider/slider_fill_v.png: Removed.
149         * platform/efl/DefaultTheme/widget/slider/slider_h.png: Removed.
150         * platform/efl/DefaultTheme/widget/slider/slider_thumb_h.png: Removed.
151         * platform/efl/DefaultTheme/widget/slider/slider_thumb_press_h.png: Removed.
152         * platform/efl/DefaultTheme/widget/slider/slider_thumb_press_v.png: Removed.
153         * platform/efl/DefaultTheme/widget/slider/slider_thumb_v.png: Removed.
154         * platform/efl/DefaultTheme/widget/slider/slider_v.png: Removed.
155         * platform/efl/DefaultTheme/widget/spinner/sp_bg.png: Removed.
156         * platform/efl/DefaultTheme/widget/spinner/sp_down_default.png: Removed.
157         * platform/efl/DefaultTheme/widget/spinner/sp_down_hover.png: Removed.
158         * platform/efl/DefaultTheme/widget/spinner/sp_down_pressed.png: Removed.
159         * platform/efl/DefaultTheme/widget/spinner/sp_up_default.png: Removed.
160         * platform/efl/DefaultTheme/widget/spinner/sp_up_hover.png: Removed.
161         * platform/efl/DefaultTheme/widget/spinner/sp_up_pressed.png: Removed.
162         * platform/efl/DefaultTheme/widget/spinner/spinner.edc: Removed.
163         * platform/efl/DragDataEfl.cpp: Removed.
164         * platform/efl/DragImageEfl.cpp: Removed.
165         * platform/efl/EflInspectorUtilities.cpp: Removed.
166         * platform/efl/EflInspectorUtilities.h: Removed.
167         * platform/efl/EflKeyboardUtilities.cpp: Removed.
168         * platform/efl/EflKeyboardUtilities.h: Removed.
169         * platform/efl/EflScreenUtilities.cpp: Removed.
170         * platform/efl/EflScreenUtilities.h: Removed.
171         * platform/efl/ErrorsEfl.cpp: Removed.
172         * platform/efl/ErrorsEfl.h: Removed.
173         * platform/efl/EventLoopEfl.cpp: Removed.
174         * platform/efl/FileSystemEfl.cpp: Removed.
175         * platform/efl/LocalizedStringsEfl.cpp: Removed.
176         * platform/efl/MIMETypeRegistryEfl.cpp: Removed.
177         * platform/efl/MainThreadSharedTimerEfl.cpp: Removed.
178         * platform/efl/PasteboardEfl.cpp: Removed.
179         * platform/efl/PlatformKeyboardEventEfl.cpp: Removed.
180         * platform/efl/PlatformMouseEventEfl.cpp: Removed.
181         * platform/efl/PlatformScreenEfl.cpp: Removed.
182         * platform/efl/PlatformSpeechSynthesisProviderEfl.cpp: Removed.
183         * platform/efl/PlatformSpeechSynthesisProviderEfl.h: Removed.
184         * platform/efl/PlatformSpeechSynthesizerEfl.cpp: Removed.
185         * platform/efl/PlatformWheelEventEfl.cpp: Removed.
186         * platform/efl/ScrollbarThemeEfl.cpp: Removed.
187         * platform/efl/ScrollbarThemeEfl.h: Removed.
188         * platform/efl/SoundEfl.cpp: Removed.
189         * platform/efl/TemporaryLinkStubs.cpp: Removed.
190         * platform/efl/UserAgentEfl.cpp: Removed.
191         * platform/efl/WidgetEfl.cpp: Removed.
192         * platform/gamepad/efl/GamepadsEfl.cpp: Removed.
193         * platform/graphics/efl/CairoUtilitiesEfl.cpp: Removed.
194         * platform/graphics/efl/CairoUtilitiesEfl.h: Removed.
195         * platform/graphics/efl/EvasGLContext.cpp: Removed.
196         * platform/graphics/efl/EvasGLContext.h: Removed.
197         * platform/graphics/efl/EvasGLSurface.cpp: Removed.
198         * platform/graphics/efl/EvasGLSurface.h: Removed.
199         * platform/graphics/efl/GraphicsContext3DEfl.cpp: Removed.
200         * platform/graphics/efl/GraphicsContext3DPrivate.cpp: Removed.
201         * platform/graphics/efl/GraphicsContext3DPrivate.h: Removed.
202         * platform/graphics/efl/IconEfl.cpp: Removed.
203         * platform/graphics/efl/ImageBufferEfl.cpp: Removed.
204         * platform/graphics/efl/ImageEfl.cpp: Removed.
205         * platform/graphics/efl/IntPointEfl.cpp: Removed.
206         * platform/graphics/efl/IntRectEfl.cpp: Removed.
207         * platform/graphics/surfaces/efl/GraphicsSurfaceCommon.cpp: Removed.
208         * platform/network/efl/NetworkStateNotifierEfl.cpp: Removed.
209         * rendering/RenderThemeEfl.cpp: Removed.
210         * rendering/RenderThemeEfl.h: Removed.
211
212 2017-02-16  Joseph Pecoraro  <pecoraro@apple.com>
213
214         [Resource Timing] Support Resource Timing in Workers
215         https://bugs.webkit.org/show_bug.cgi?id=168086
216         <rdar://problem/30430117>
217
218         Reviewed by Alex Christensen.
219
220         Worker's load resources through the Document that loaded them. However,
221         their PerformanceResourceTiming entries should be added to the Performance
222         object inside the Worker context, not the Document's context.
223
224         This change adds an InitiatorContext to ResourceLoadOptions so that loaders
225         can determine if the load was initiated by the Document or a Worker. This
226         allows loaders to then know if the ResourceTiming data they collect should
227         be added to the Document's Performance object or forwarded on to the Worker's.
228
229         This adds a new ThreadableLoaderClient method intended only for the purpose
230         of adding the ResourceTiming information to the Worker's Performance object.
231         Unlike other ThreadableLoaderClient methods that are bridged and forwarded
232         on to a client inside the worker (e.g. XMLHttpRequest or FetchLoader) this
233         method never needs to be handled by clients and can be uniformly handled by
234         the WorkerThreadableLoader itself.
235
236         We also add a new ResourceTiming object that encapsulates all of the data
237         ultimately needed for a PerformanceResourceTimingEntry object. This allows
238         for all of the information to be gathered while loading on the Document
239         before serializing across to the Worker. That includes the Timing-Allow-Origin
240         check which uses the SecurityOrigin of the Worker.
241
242         This also modernizes and addresses issues in the Resource Timing implementation.
243         Better handling cases like loading from the Cache, Synchronous Loads, and
244         improving initiatorType information.
245
246         Tests: imported/w3c/web-platform-tests/resource-timing/rt-cors.html
247                imported/w3c/web-platform-tests/resource-timing/rt-cors.worker.html
248                imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-css.html
249                imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-element.html
250                imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-fetch.html
251                imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-media.html
252                imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-other.html
253                imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-script-module.html
254                imported/w3c/web-platform-tests/resource-timing/rt-initiatorType-xmlhttprequest.html
255                imported/w3c/web-platform-tests/resource-timing/rt-initiatorType.worker.html
256                imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.html
257                imported/w3c/web-platform-tests/resource-timing/rt-performance-extensions.worker.html
258                imported/w3c/web-platform-tests/resource-timing/rt-resource-errors.html
259                imported/w3c/web-platform-tests/resource-timing/rt-resource-ignored.html
260                imported/w3c/web-platform-tests/resource-timing/rt-resources-per-frame.html
261                imported/w3c/web-platform-tests/resource-timing/rt-resources-per-worker.html
262                imported/w3c/web-platform-tests/resource-timing/rt-serialization.html
263                imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-frames.html
264                imported/w3c/web-platform-tests/resource-timing/rt-shared-resource-in-workers.html
265                performance-api/resource-timing-apis.html
266
267         * CMakeLists.txt:
268         * WebCore.xcodeproj/project.pbxproj:
269         New files.
270
271         * platform/network/NetworkLoadTiming.h:
272         (WebCore::NetworkLoadTiming::reset): Deleted.
273         We no longer need to reset.
274
275         * loader/ResourceTiming.cpp: Added.
276         (WebCore::passesTimingAllowCheck):
277         (WebCore::ResourceTiming::fromCache):
278         (WebCore::ResourceTiming::fromLoad):
279         (WebCore::ResourceTiming::fromSynchronousLoad):
280         (WebCore::ResourceTiming::ResourceTiming):
281         (WebCore::ResourceTiming::isolatedCopy):
282         * loader/ResourceTiming.h: Added.
283         (WebCore::ResourceTiming::url):
284         (WebCore::ResourceTiming::initiator):
285         (WebCore::ResourceTiming::loadTiming):
286         (WebCore::ResourceTiming::networkLoadTiming):
287         (WebCore::ResourceTiming::allowTimingDetails):
288         (WebCore::ResourceTiming::overrideInitiatorName):
289         (WebCore::ResourceTiming::ResourceTiming):
290         Class that encapsulates all of the data needed for a PerformanceResourceTiming entry.
291         There are three static constructors indicating the different ways this object can
292         be constructed and the different data available at the time of construction.
293
294         * loader/ResourceLoaderOptions.h:
295         Add the new InitiatorContext, default to Document.
296
297         * loader/ThreadableLoaderClient.h:
298         (WebCore::ThreadableLoaderClient::didFinishTiming):
299         New client method only used by WorkerThreadableLoader.
300
301         * loader/WorkerThreadableLoader.h:
302         * loader/WorkerThreadableLoader.cpp:
303         (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
304         (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming):
305         All loads initiated in a WorkerThreadableLoader get identified as InitiatorContext::Worker.
306         Add timing information to the Performance object when received. No need to inform clients.
307
308         * loader/DocumentThreadableLoader.h:
309         * loader/DocumentThreadableLoader.cpp:
310         (WebCore::DocumentThreadableLoader::finishedTimingForWorkerLoad):
311         (WebCore::DocumentThreadableLoader::loadRequest):
312         Provide APIs to pass timing data on to a WorkerThreadableLoader.
313         Create ResourceTiming data for synchronous loads.
314
315         * loader/LoadTiming.h:
316         * loader/LoadTiming.cpp:
317         (WebCore::LoadTiming::isolatedCopy):
318         Add isolatedCopy to allow this data to be passed across to a Worker.
319
320         * loader/ResourceTimingInformation.h:
321         * loader/ResourceTimingInformation.cpp:
322         (WebCore::ResourceTimingInformation::shouldAddResourceTiming):
323         (WebCore::ResourceTimingInformation::addResourceTiming):
324         (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation):
325         Refactor to remove unused / unnecessary bits. Extract out some helpful code.
326         Changed this to match when Blink decides when to add or ignore entries, however
327         this may change over time.
328
329         * loader/SubresourceLoader.cpp:
330         (WebCore::SubresourceLoader::didFinishLoading):
331         (WebCore::SubresourceLoader::notifyDone):
332         (WebCore::SubresourceLoader::reportResourceTiming):
333         * loader/SubresourceLoader.h:
334         * loader/cache/CachedRawResource.cpp:
335         (WebCore::CachedRawResource::finishedTimingForWorkerLoad):
336         * loader/cache/CachedRawResource.h:
337         * loader/cache/CachedRawResourceClient.h:
338         (WebCore::CachedRawResourceClient::finishedTimingForWorkerLoad):
339         Plumbing to report timing information to Worker if this resource was loaded for a Worker.
340
341         * loader/cache/CachedResource.cpp:
342         (WebCore::CachedResource::CachedResource):
343         * loader/cache/CachedResource.h:
344         (WebCore::CachedResource::initiatorName):
345         Store the initiator name on the CachedResource like other data added to the original
346         CachedResourceRequest. This is a bit of a hack but follows an existing pattern, and
347         cleans up other hacks that worked around this later on.
348
349         * loader/cache/CachedResourceLoader.h:
350         * loader/cache/CachedResourceLoader.cpp:
351         (WebCore::CachedResourceLoader::requestResource):
352         (WebCore::CachedResourceLoader::revalidateResource):
353         (WebCore::CachedResourceLoader::loadResource):
354         Simply the creation of a ResourceTiming object for cache hits.
355         Report timing information to Worker if this resource was loaded for a Worker.
356
357         (WebCore::CachedResourceLoader::loadDone):
358         Eliminate this redundant point attempting to add a ResourceTiming entry.
359
360         * loader/cache/CachedResourceRequest.cpp:
361         (WebCore::CachedResourceRequest::initiatorName):
362         Update to match the spec. The fallback is "other".
363
364         * page/Performance.h:
365         * page/Performance.cpp:
366         (WebCore::Performance::setResourceTimingBufferSize):
367         (WebCore::Performance::addResourceTiming):
368         Update to support PerformanceObservers.
369         Update to match spec (event should bubble).
370
371         * page/PerformanceResourceTiming.h:
372         * page/PerformanceResourceTiming.cpp:
373         (WebCore::PerformanceResourceTiming::create):
374         (WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
375         (WebCore::PerformanceResourceTiming::fetchStart):
376         (WebCore::PerformanceResourceTiming::domainLookupStart):
377         (WebCore::PerformanceResourceTiming::domainLookupEnd):
378         (WebCore::PerformanceResourceTiming::connectStart):
379         (WebCore::PerformanceResourceTiming::connectEnd):
380         (WebCore::PerformanceResourceTiming::secureConnectionStart):
381         (WebCore::PerformanceResourceTiming::requestStart):
382         (WebCore::PerformanceResourceTiming::responseStart):
383         (WebCore::PerformanceResourceTiming::responseEnd):
384         (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp):
385         Construct with a ResourceTiming object containing all the data we need for the entry.
386         Update to match spec for what is required, should fallback, should be zero, etc.
387
388         (WebCore::passesTimingAllowCheck): Deleted.
389         Extracted this to ResourceTiming creation time in the loading context,
390         since this can't be determined on the Worker context without also having
391         all of the header information from each resource response.
392
393         * page/PerformanceResourceTiming.idl:
394         Expose to Workers!
395
396 2017-02-16  Yusuke Suzuki  <utatane.tea@gmail.com>
397
398         [JSC] Drop PassRefPtr in inspector/
399         https://bugs.webkit.org/show_bug.cgi?id=168420
400
401         Reviewed by Alex Christensen.
402
403         Use Ref<Inspector::ScriptArguments> and Ref<ScriptCallStack> as much as possible.
404         It drops some unnecessary null checks.
405
406         * bindings/scripts/CodeGeneratorJS.pm:
407         (GenerateCallWith):
408         * bindings/scripts/test/JS/JSTestObj.cpp:
409         (WebCore::jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStackCaller):
410         * dom/ScriptExecutionContext.cpp:
411         (WebCore::ScriptExecutionContext::PendingException::PendingException):
412         * inspector/InspectorInstrumentation.cpp:
413         (WebCore::InspectorInstrumentation::consoleCountImpl):
414         (WebCore::InspectorInstrumentation::stopConsoleTimingImpl):
415         (WebCore::InspectorInstrumentation::consoleTimeStampImpl):
416         * inspector/InspectorInstrumentation.h:
417         (WebCore::InspectorInstrumentation::consoleCount):
418         (WebCore::InspectorInstrumentation::stopConsoleTiming):
419         (WebCore::InspectorInstrumentation::consoleTimeStamp):
420         * inspector/InspectorNetworkAgent.cpp:
421         (WebCore::InspectorNetworkAgent::buildInitiatorObject):
422         * inspector/TimelineRecordFactory.cpp:
423         (WebCore::TimelineRecordFactory::createGenericRecord):
424         * inspector/WebInjectedScriptManager.cpp:
425         (WebCore::WebInjectedScriptManager::WebInjectedScriptManager):
426         * inspector/WebInjectedScriptManager.h:
427         * page/DOMWindow.cpp:
428         (WebCore::DOMWindow::postMessageTimerFired):
429         We dispatch appropriate addMessage function according to whether
430         `timer.stackTrace()` is nullptr.
431
432         * page/PageConsoleClient.cpp:
433         (WebCore::PageConsoleClient::addMessage):
434         (WebCore::PageConsoleClient::messageWithTypeAndLevel):
435         (WebCore::PageConsoleClient::count):
436         (WebCore::PageConsoleClient::timeEnd):
437         (WebCore::PageConsoleClient::timeStamp):
438         * page/PageConsoleClient.h:
439         * workers/WorkerConsoleClient.cpp:
440         (WebCore::WorkerConsoleClient::messageWithTypeAndLevel):
441         (WebCore::WorkerConsoleClient::count):
442         (WebCore::WorkerConsoleClient::timeEnd):
443         (WebCore::WorkerConsoleClient::timeStamp):
444         * workers/WorkerConsoleClient.h:
445         * workers/WorkerGlobalScope.cpp:
446         (WebCore::WorkerGlobalScope::addMessage):
447
448 2017-02-16  Chris Fleizach  <cfleizach@apple.com>
449
450         AX: Make form validation accessible on iOS
451         https://bugs.webkit.org/show_bug.cgi?id=168400
452
453         Reviewed by Chris Dumez.
454
455         Hide the popover content of form validation from accessibility (since its not interactable)
456         and instead announce the message.
457
458         * platform/ios/ValidationBubbleIOS.mm:
459         (WebCore::ValidationBubble::show):
460
461 2017-02-16  Simon Fraser  <simon.fraser@apple.com>
462
463         Clean up use of some CALayer-related SPI
464         https://bugs.webkit.org/show_bug.cgi?id=168401
465
466         Reviewed by Tim Horton.
467
468         Use -setDrawsAsynchronously: rather than the old -setAcceleratesDrawing: SPI.
469
470         Remove CATiledLayer-related stuff from QuartzCoreSPI.h, since we don't use it any more.
471
472         * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
473         (PlatformCALayerCocoa::acceleratesDrawing):
474         (PlatformCALayerCocoa::setAcceleratesDrawing):
475         * platform/graphics/ca/cocoa/WebTiledBackingLayer.mm:
476         (-[WebTiledBackingLayer setDrawsAsynchronously:]): This override passes the state
477         onto the TileController.
478         (-[WebTiledBackingLayer setAcceleratesDrawing:]): Deleted.
479         * platform/ios/LegacyTileGridTile.mm:
480         (WebCore::LegacyTileGridTile::LegacyTileGridTile):
481         * platform/spi/cocoa/QuartzCoreSPI.h:
482
483 2017-02-16  Yusuke Suzuki  <utatane.tea@gmail.com>
484
485         Web Inspector: allow import() inside the inspector
486         https://bugs.webkit.org/show_bug.cgi?id=167457
487
488         Reviewed by Ryosuke Niwa.
489
490         When evaluating `import("...")`, we need the caller's context to resolve
491         the module specifier correctly. For example, if `import("./cocoa.js")` is
492         evaluated in the script "drinks/hot.js", this module name is resolved to
493         "drinks/cocoa.js". If the same import operator is evaluated in the script
494         "menu/all.js", the module specifier becomes "menu/cocoa.js".
495
496         Previously we reject the import operator if the caller does not have such
497         a context. These context is SourceOrigin and its ScriptFetcher. While they
498         are offered in the script tag and other code evaluations, the inspector
499         console does not offer that. These class are offered in the WebCore side
500         and we should not touch these classes in the JSC's inspector code.
501
502         Now we relax the above restriction. If the above caller information is not
503         offered, we fallback to the default one. In the web page, we use the page's
504         URL as the caller's source origin. This allows us to evaluate the import
505         operator in the inspector console.
506
507         And as of r167698, the console recognizes `await import("...")` form. We use
508         this to test this `import()` in the console functionality.
509
510         Test: inspector/controller/runtime-controller-import.html
511
512         * bindings/js/ScriptModuleLoader.cpp:
513         (WebCore::ScriptModuleLoader::importModule):
514
515 2017-02-16  Miguel Gomez  <magomez@igalia.com>
516
517         [GTK] scroll with transparent background not repainted after scrollY >= 32768
518         https://bugs.webkit.org/show_bug.cgi?id=154283
519
520         Reviewed by Carlos Garcia Campos.
521
522         Due to a limitation of the pixman backend, which uses 16 bits to hold signed integers, cairo is
523         not able to draw anything when using transformation matrices with values bigger than 32768. When
524         drawing patterns into large pages, the matrices values can overflow those 16 bits, so cairo doesn't
525         draw anything in, which causes the reported transparent backgrounds.
526
527         The patch modifies the transformation matrices both from the current context and the pattern we
528         are painting, to avoid them to hold values that cannot stored in 16 bits.
529
530         There's still the possibility that this happens, but it would require using a pattern with a size
531         bigger than 32768.
532
533         Based on a previous patch by Gwang Yoon Hwang  <yoon@igalia.com>.
534
535         Test: fast/backgrounds/background-repeat-long-scroll.html
536
537         * platform/graphics/cairo/CairoUtilities.cpp:
538         (WebCore::drawPatternToCairoContext):
539
540 2017-02-16  Carlos Garcia Campos  <cgarcia@igalia.com>
541
542         [GTK] Images are never read from the clipboard
543         https://bugs.webkit.org/show_bug.cgi?id=168419
544
545         Reviewed by Sergio Villar Senin.
546
547         We write images in the clipboard, but we don't read them.
548
549         Fixes: editing/pasteboard/paste-image-using-image-data.html
550
551         * editing/Editor.cpp:
552         (WebCore::Editor::createFragmentForImageAndURL): Moved from EditorMac.mm since it's cross-platform code.
553         * editing/Editor.h:
554         * editing/gtk/EditorGtk.cpp:
555         (WebCore::createFragmentFromPasteboardData): Check if there's an image in the selection, and use
556         Editor::createFragmentForImageAndURL in that case.
557         * editing/mac/EditorMac.mm:
558         (WebCore::Editor::createFragmentForImageAndURL): Deleted.
559         * platform/gtk/PasteboardHelper.cpp:
560         (WebCore::PasteboardHelper::getClipboardContents): Check also if there's an image in the clipboard.
561
562 2017-02-15  Jer Noble  <jer.noble@apple.com>
563
564         REGRESSION (r212311): NULL-dereference in HTMLMediaElement::prepareToPlay()
565         https://bugs.webkit.org/show_bug.cgi?id=168404
566         <rdar://problem/30547188>
567
568         Reviewed by Brian Weinstein.
569
570         Prior to r212311, m_player was always guaranteed to be initialized when calling
571         prepareToPlay(). r212311 began calling prepareToPlay() on a subsequent run-loop iteration
572         after creating m_player. So now check whether m_player is NULL before calling methods on it.
573
574         * html/HTMLMediaElement.cpp:
575         (WebCore::HTMLMediaElement::prepareToPlay):
576
577 2017-02-15  Eric Carlson  <eric.carlson@apple.com>
578
579         [MediaStream] delete CaptureDeviceInfo struct
580         https://bugs.webkit.org/show_bug.cgi?id=168395
581
582         The CaptureDeviceInfo struct and CaptureDevice class were almost identical, so
583         add an "enabled" field to the later, delete the former, and switch all uses of
584         CaptureDeviceInfo to CaptureDevice.
585
586         Do some minor drive-by cleanup of AVCaptureDeviceManager::refreshCaptureDevices
587         and CaptureDeviceManager::captureDeviceFromDeviceID.
588         
589         Reviewed by Sam Weinig.
590
591         No new tests, no behavior change.
592
593         * Modules/mediastream/MediaDevicesRequest.cpp:
594         (WebCore::MediaDevicesRequest::start): SourceKind -> DeviceType
595         * platform/mediastream/CaptureDevice.h:
596         (WebCore::CaptureDevice::CaptureDevice):
597         (WebCore::CaptureDevice::type): Renamed from kind.
598         (WebCore::CaptureDevice::setType):
599         (WebCore::CaptureDevice::enabled): Added.
600         (WebCore::CaptureDevice::setEnabled):
601         (WebCore::CaptureDevice::kind): Deleted.
602         (WebCore::CaptureDevice::setKind): Deleted.
603
604         * platform/mediastream/CaptureDeviceManager.cpp:
605         (CaptureDeviceManager::getSourcesInfo):
606         (CaptureDeviceManager::captureDeviceFromDeviceID): Don't call sourceWithUID.
607         (CaptureDeviceManager::bestSourcesForTypeAndConstraints):
608         (CaptureDeviceManager::sourceWithUID):
609         * platform/mediastream/CaptureDeviceManager.h:
610         (WebCore::CaptureDeviceManager::refreshCaptureDevices):
611         (WebCore::CaptureDeviceManager::refreshCaptureDeviceList): Deleted.
612
613         * platform/mediastream/mac/AVCaptureDeviceManager.h:
614         * platform/mediastream/mac/AVCaptureDeviceManager.mm:
615         (WebCore::AVCaptureDeviceManager::captureDevices):
616         (WebCore::deviceIsAvailable):
617         (WebCore::AVCaptureDeviceManager::refreshCaptureDevices):
618         (WebCore::AVCaptureDeviceManager::createMediaSourceForCaptureDeviceWithConstraints):
619         (WebCore::AVCaptureDeviceManager::deviceConnected):
620         (WebCore::AVCaptureDeviceManager::deviceDisconnected):
621         (WebCore::AVCaptureDeviceManager::captureDeviceList): Deleted.
622         (WebCore::shouldConsiderDeviceInDeviceList): Deleted.
623         (WebCore::AVCaptureDeviceManager::refreshCaptureDeviceList): Deleted.
624         * platform/mock/MockRealtimeMediaSource.cpp:
625         (WebCore::MockRealtimeMediaSource::audioDeviceInfo):
626         (WebCore::MockRealtimeMediaSource::videoDeviceInfo):
627
628 2017-02-15  Sam Weinig  <sam@webkit.org>
629
630         [WebIDL] Remove custom conversion from FontFace code by using a Variant
631         https://bugs.webkit.org/show_bug.cgi?id=168384
632
633         Reviewed by Alex Christensen.
634
635         Match the font face spec and use a union rather than any in the FontFace constructor.
636
637         Test: Added additional cases to fast/text/font-face-javascript.html.
638
639         * css/FontFace.cpp:
640         (WebCore::FontFace::create):
641         * css/FontFace.h:
642         * css/FontFace.idl:
643
644 2017-02-15  Jer Noble  <jer.noble@apple.com>
645
646         Disabled Media Sources should render black/silence
647         https://bugs.webkit.org/show_bug.cgi?id=168281
648
649         Reviewed by Eric Carlson.
650
651         Test: webrtc/video-disabled-black.html
652
653         Pass the enabled flag setting down from the MediaStreamTrackPrivate to its underlying
654         source, including RealtimeMediaSource and RealtimeOutgoingAudio/VideoSource. When either
655         enabled is cleared or muted is set, generate empty (black or silent) media, as opposed to
656         pausing media or (worse) continuing to send generated media.
657
658         * platform/mediastream/MediaStreamTrackPrivate.cpp:
659         (WebCore::MediaStreamTrackPrivate::setEnabled):
660         (WebCore::MediaStreamTrackPrivate::sourceEnabledChanged):
661         * platform/mediastream/MediaStreamTrackPrivate.h:
662         * platform/mediastream/RealtimeMediaSource.cpp:
663         (WebCore::RealtimeMediaSource::setEnabled):
664         * platform/mediastream/RealtimeMediaSource.h:
665         (WebCore::RealtimeMediaSource::enabled):
666         * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h:
667         * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
668         (WebCore::MockRealtimeAudioSourceMac::render):
669         * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
670         (WebCore::RealtimeOutgoingAudioSource::sourceMutedChanged):
671         (WebCore::RealtimeOutgoingAudioSource::sourceEnabledChanged):
672         (WebCore::RealtimeOutgoingAudioSource::pullAudioData):
673         * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
674         * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
675         (WebCore::RealtimeOutgoingVideoSource::sourceMutedChanged):
676         (WebCore::RealtimeOutgoingVideoSource::sourceEnabledChanged):
677         (WebCore::RealtimeOutgoingVideoSource::videoSampleAvailable):
678         * platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
679         * platform/mock/MockRealtimeVideoSource.cpp:
680         (WebCore::MockRealtimeVideoSource::generateFrame):
681
682 2017-02-15  Wenson Hsieh  <wenson_hsieh@apple.com>
683
684         Editing history scripts should not add the contenteditable attribute or override key events
685         https://bugs.webkit.org/show_bug.cgi?id=168389
686         <rdar://problem/30529945>
687
688         Reviewed by Dan Bernstein.
689
690         Clients that hook into editing history tracking should handle setting the contenteditable attribute on the body
691         rather than have the script add it to the body. Additionally, this script should NOT be overriding any keydown
692         events. These were initially added for compatibility with a test harness early on, and should have been removed
693         earlier.
694
695         * Scripts/DumpEditingHistory.js:
696
697 2017-02-15  Jer Noble  <jer.noble@apple.com>
698
699         Pass "RequiresCustomURLLoading" in AVURLAsset options dictionary
700         https://bugs.webkit.org/show_bug.cgi?id=168381
701
702         Reviewed by Eric Carlson.
703
704         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
705         (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
706
707 2017-02-15  Anders Carlsson  <andersca@apple.com>
708
709         Fix build.
710
711         * page/DragController.cpp:
712         (WebCore::DragController::doSystemDrag):
713
714 2017-02-15  Anders Carlsson  <andersca@apple.com>
715
716         Modernize DragClient::startDrag somewhat
717         https://bugs.webkit.org/show_bug.cgi?id=168379
718
719         Reviewed by Tim Horton.
720
721         Change DragClient::startDrag to take a DragImage instead of a DragImageRef, and to pass along the source action
722         instead of whether it's a link or not.
723
724         * loader/EmptyClients.cpp:
725         * page/DragClient.h:
726         * page/DragController.cpp:
727         (WebCore::DragController::startDrag):
728         (WebCore::DragController::doImageDrag):
729         (WebCore::DragController::doSystemDrag):
730         * page/DragController.h:
731
732 2017-02-15  Chris Dumez  <cdumez@apple.com>
733
734         Expose Symbol.toPrimitive / valueOf on Location instances
735         https://bugs.webkit.org/show_bug.cgi?id=168295
736
737         Reviewed by Geoffrey Garen, Keith Miller and Mark Lam.
738
739         Expose Symbol.toPrimitive / valueOf on Location instances as per:
740         - https://html.spec.whatwg.org/#the-location-interface
741
742         Firefox and Chrome already comply with the specification.
743
744         Tests: fast/dom/location-valueOf-after-object-prototype-update.html
745                fast/dom/location-valueOf-after-object-prototype-update2.html
746                imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-symbol-toprimitive.html
747                imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-valueof.html
748
749         * bindings/scripts/CodeGeneratorJS.pm:
750         (GenerateImplementation):
751
752 2017-02-15  Aakash Jain  <aakash_jain@apple.com>
753
754         Remove WebIOSEvent interface
755         https://bugs.webkit.org/show_bug.cgi?id=168368
756
757         Reviewed by Tim Horton.
758
759         * platform/ios/WebEvent.h: Removed WebIOSEvent.
760
761 2017-02-15  Chris Dumez  <cdumez@apple.com>
762
763         [iOS] Form Validation Bubble should be sensitive to Dynamic Type
764         https://bugs.webkit.org/show_bug.cgi?id=168291
765         <rdar://problem/30508593>
766
767         Reviewed by Tim Horton.
768
769         Update ValidationBubble implementation on iOS to stop obeying the
770         minimum font size setting, given that this setting is not exposed
771         on iOS. Instead, we now rely on
772         [UIFont preferredFontForTextStyle:UIFontTextStyleCallout], which
773         will give us a font whose size obeys Dynamic Type [1] setting on iOS.
774
775         [1] https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/
776
777         No new tests, no easily testable.
778
779         * platform/ios/ValidationBubbleIOS.mm:
780         (WebCore::ValidationBubble::ValidationBubble):
781
782 2017-02-15  Yusuke Suzuki  <utatane.tea@gmail.com>
783
784         [JSC] Drop PassRefPtr
785         https://bugs.webkit.org/show_bug.cgi?id=168320
786
787         Reviewed by Saam Barati.
788
789         * bindings/js/ScriptSourceCode.h:
790         (WebCore::ScriptSourceCode::ScriptSourceCode):
791         Use Ref and pass it to SourceCode.
792
793         * replay/ReplayController.cpp:
794         (WebCore::ReplayController::frameNavigated):
795         Pass reference.
796
797 2017-02-15  Xabier Rodriguez Calvar  <calvaris@igalia.com>
798
799         [GStreamer][MSE][EME] Handle protection event also at decryptor level
800         https://bugs.webkit.org/show_bug.cgi?id=168316
801
802         Reviewed by Žan Doberšek.
803
804         So far in MSE pipeline we were handling the encryption events
805         only when they arrived at the demuxer but this won't work in any
806         kind of key renegotiation as the event will never arrive. Now we
807         connect to the element messages, check for the drm id and send it
808         to the private player for processing.
809
810         * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
811         (WebCore::appendPipelineElementMessageCallback):
812         (WebCore::AppendPipeline::AppendPipeline):
813         (WebCore::AppendPipeline::handleElementMessage):
814         * platform/graphics/gstreamer/mse/AppendPipeline.h:
815
816 2017-02-15  Zan Dobersek  <zdobersek@igalia.com>
817
818         [EME] MediaKeys::setServerCertificate() must resolve with 'false' when certificates aren't supported
819         https://bugs.webkit.org/show_bug.cgi?id=168362
820
821         Reviewed by Xabier Rodriguez-Calvar.
822
823         In MediaKeys::setServerCertificate(), when the CDM implementation
824         doesn't support server certificates, it should resolve the promise
825         with the 'false' value, as mandated by the specification, and not
826         reject it.
827
828         A test case in mock-MediaKeys-setServerCertificate.html is updated.
829
830         * Modules/encryptedmedia/MediaKeys.cpp:
831         (WebCore::MediaKeys::setServerCertificate):
832
833 2017-02-15  Carlos Garcia Campos  <cgarcia@igalia.com>
834
835         REGRESSION (r206014): HTTPHeaderMap does not consistently use comma without space to separate values of header fields
836         https://bugs.webkit.org/show_bug.cgi?id=168115
837
838         Reviewed by Darin Adler.
839
840         In r206014 HTTPHeaderMap::add() was updated to combine common headers with ',' instead of ", " to match the
841         fetch specification, but the uncommon headers are still combined with ", ".
842
843         * platform/network/HTTPHeaderMap.cpp:
844         (WebCore::HTTPHeaderMap::add):
845
846 2017-02-14  Ryosuke Niwa  <rniwa@webkit.org>
847
848         An assertion failure inside removeChildren
849         https://bugs.webkit.org/show_bug.cgi?id=168069
850
851         Reviewed by Brent Fulgham.
852
853         The bug was caused by notifyRemovePendingSheet executing scripts synchronously where it shouldn't.
854
855         Removed the call to notifyRemovePendingSheetIfNeeded in notifyChildNodeRemoved. Instead, invoke it
856         in its call sites when they're safe.
857
858         Test: http/tests/security/move-iframe-within-focus-handler-inside-removal.html
859
860         * dom/ContainerNode.cpp:
861         (WebCore::ContainerNode::takeAllChildrenFrom):
862         (WebCore::ContainerNode::notifyChildInserted):
863         (WebCore::ContainerNode::removeChild):
864         (WebCore::ContainerNode::parserRemoveChild):
865         (WebCore::ContainerNode::replaceAllChildren):
866         (WebCore::ContainerNode::removeChildren):
867         * dom/ContainerNodeAlgorithms.cpp:
868         (WebCore::notifyChildNodeRemoved):
869
870 2017-02-15  Carlos Garcia Campos  <cgarcia@igalia.com>
871
872         [GStreamer] Several tests are timing out after r212349
873         https://bugs.webkit.org/show_bug.cgi?id=168359
874
875         Reviewed by Žan Doberšek.
876
877         This is because they are failing the cross origin check. Those tests are not using WebKitWebSrc, but
878         GstFileSrc. I didn't consider the case of source not being a WebKitWebSrc.
879
880         Fixes several timeout instroduced in r212349.
881
882         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
883         (WebCore::MediaPlayerPrivateGStreamer::hasSingleSecurityOrigin): Split the source check in two. First check if
884         it's nullptr, and return false. Then check if it's a WebKitWebSrc and return true if it isn't.
885
886 2017-02-14  Brent Fulgham  <bfulgham@apple.com>
887
888         Revalidate URL after events that could trigger navigations
889         https://bugs.webkit.org/show_bug.cgi?id=168071
890         <rdar://problem/30450379>
891
892         Reviewed by Ryosuke Niwa.
893
894         When arbitary javascript runs during a load, we should revalidate
895         the URLs involved to make sure they are still valid.
896
897         Tests: http/tests/plugins/navigation-during-load-embed.html
898                http/tests/plugins/navigation-during-load.html
899
900         * html/HTMLEmbedElement.cpp:
901         (WebCore::HTMLEmbedElement::updateWidget): Confirm we are still allowed to
902         load the URL after executing JS callbacks.
903         * html/HTMLFrameElementBase.cpp:
904         (WebCore::HTMLFrameElementBase::isURLAllowed): Split existing function into
905         existing protected method, and a new public method that checks a passed URL
906         for validity.
907         * html/HTMLFrameElementBase.h:
908         * html/HTMLFrameOwnerElement.h:
909         (WebCore::HTMLFrameOwnerElement::isURLAllowed):
910         * html/HTMLObjectElement.cpp:
911         (WebCore::HTMLObjectElement::updateWidget): Confirm we are still allowed to
912         load the URL after executing JS callbacks.
913         * loader/SubframeLoader.cpp:
914         (WebCore::SubframeLoader::requestFrame): Ditto.
915
916 2017-02-14  Carlos Garcia Campos  <cgarcia@igalia.com>
917
918         [GStreamer] Implement MediaPlayerPrivate::hasSingleSecurityOrigin()
919         https://bugs.webkit.org/show_bug.cgi?id=168322
920
921         Reviewed by Žan Doberšek.
922
923         It currently returns true unconditionally. Add resolved-location property to WebKitWebSourceGStreamer to track
924         the resolved url returned by the server and use that from MediaPlayerPrivate to check if there was a cross
925         origin redirection.
926
927         Fixes: http/tests/security/canvas-remote-read-remote-video-redirect.html
928
929         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
930         (WebCore::MediaPlayerPrivateGStreamer::hasSingleSecurityOrigin):
931         * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
932         * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
933         (webKitWebSrcFinalize):
934         (webKitWebSrcGetProperty):
935         (webKitWebSrcStart):
936         (webKitWebSrcQueryWithParent):
937         (webKitWebSrcGetUri):
938         (webKitWebSrcSetUri):
939         (StreamingClient::handleResponseReceived):
940         (ResourceHandleStreamingClient::wasBlocked):
941         (ResourceHandleStreamingClient::cannotShowURL):
942
943 2017-02-14  Carlos Garcia Campos  <cgarcia@igalia.com>
944
945         Unreviewed, rolling out r211967.
946
947         Caused rendering issues in HiDPI
948
949         Reverted changeset:
950
951         "[GTK] scroll with transparent background not repainted after
952         scrollY >= 32768"
953         https://bugs.webkit.org/show_bug.cgi?id=154283
954         http://trac.webkit.org/changeset/211967
955
956 2017-02-14  Carlos Garcia Campos  <cgarcia@igalia.com>
957
958         [GTK] Update cookie manager API to properly work with ephemeral sessions
959         https://bugs.webkit.org/show_bug.cgi?id=168230
960
961         Reviewed by Michael Catanzaro.
962
963         Add implementation for deleteAllCookiesModifiedSince. Note that this only works when the timespan is 0, we need
964         new libsoup API to support removing recently modified cookies.
965
966         * platform/network/soup/CookieJarSoup.cpp:
967         (WebCore::deleteAllCookiesModifiedSince):
968
969 2017-02-14  Joseph Pecoraro  <pecoraro@apple.com>
970
971         [WebIDL] Improve serializer = { inherit }
972         https://bugs.webkit.org/show_bug.cgi?id=168293
973
974         Reviewed by Youenn Fablet.
975
976         * bindings/scripts/CodeGeneratorJS.pm:
977         (GenerateHeader):
978         Expose a serialize() method on the interface.
979
980         (GenerateSerializerFunction):
981         (GenerateSerializerAttributesForInterface): Deleted.
982         Subclasses that have `serializer = { inherit }` can use
983         their parent's serialize() method to get the initial object.
984         We can now collapse everything back into a single function
985         because we only generate code for our own attributes.
986
987         * bindings/scripts/test/JS/JSTestNode.cpp:
988         (WebCore::JSTestNode::serialize):
989         (WebCore::jsTestNodePrototypeFunctionToJSONCaller):
990         * bindings/scripts/test/JS/JSTestNode.h:
991         * bindings/scripts/test/JS/JSTestObj.cpp:
992         (WebCore::JSTestObj::serialize):
993         (WebCore::jsTestObjPrototypeFunctionToJSONCaller):
994         * bindings/scripts/test/JS/JSTestObj.h:
995         * bindings/scripts/test/JS/JSTestSerialization.cpp:
996         (WebCore::JSTestSerialization::serialize):
997         (WebCore::jsTestSerializationPrototypeFunctionToJSONCaller):
998         * bindings/scripts/test/JS/JSTestSerialization.h:
999         * bindings/scripts/test/JS/JSTestSerializationInherit.cpp:
1000         (WebCore::JSTestSerializationInherit::serialize):
1001         (WebCore::jsTestSerializationInheritPrototypeFunctionToJSONCaller):
1002         * bindings/scripts/test/JS/JSTestSerializationInherit.h:
1003         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp:
1004         (WebCore::JSTestSerializationInheritFinal::serialize):
1005         (WebCore::jsTestSerializationInheritFinalPrototypeFunctionToJSONCaller):
1006         * bindings/scripts/test/JS/JSTestSerializationInheritFinal.h:
1007         Updated results.
1008
1009 2017-02-14  Aakash Jain  <aakash_jain@apple.com>
1010
1011         Move methods from WebCoreThread.h to WebCoreThreadInternal.h
1012         https://bugs.webkit.org/show_bug.cgi?id=168326
1013
1014         Reviewed by Alexey Proskuryakov.
1015
1016         * platform/ios/wak/WebCoreThread.h: Move methods WebThreadRunLoop and WebThreadCurrentContext to WebCoreThreadInternal.h
1017         * platform/ios/wak/WebCoreThreadInternal.h: Ditto.
1018         * platform/ios/wak/WebCoreThreadRun.cpp: Removed WebCoreThread.h as it is already included by WebCoreThreadInternal.h
1019         * platform/ios/wak/WKGraphics.mm: Included WebCoreThreadInternal.h, it subsequently includes WebCoreThread.h
1020         * inspector/InspectorTimelineAgent.cpp: Ditto.
1021         * page/mac/PageMac.mm: Ditto.
1022         * platform/cf/MainThreadSharedTimerCF.cpp: Ditto.
1023         * platform/cocoa/MemoryPressureHandlerCocoa.mm: Ditto.
1024         * platform/graphics/ca/cocoa/LayerFlushSchedulerMac.cpp: Ditto.
1025         * platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp: Ditto.
1026         * bindings/js/CommonVM.cpp: included WebCoreThreadInternal.h
1027
1028 2017-02-14  Wenson Hsieh  <wenson_hsieh@apple.com>
1029
1030         [WK2] Support data interaction on links
1031         https://bugs.webkit.org/show_bug.cgi?id=168331
1032         <rdar://problem/30200837>
1033
1034         Reviewed by Tim Horton.
1035
1036         Adds support for data interaction on links at the WebCore layer, refactoring some drag-and-drop code on the Mac
1037         along the way. Also adds two new TestWebKitAPI unit tests in DataInteractionTests.mm: LinkToInput and
1038         BackgroundImageLinkToInput (see Tools/ChangeLog for more information).
1039
1040         * page/DragController.cpp:
1041         (WebCore::DragController::startDrag):
1042         (WebCore::DragController::doImageDrag):
1043         (WebCore::DragController::doSystemDrag):
1044
1045         Introduce platformAdjustDragImageForDeviceScaleFactor, and special-case drag images for links to anchor at the
1046         bottom center.
1047
1048         * platform/DragImage.cpp:
1049         (WebCore::platformAdjustDragImageForDeviceScaleFactor):
1050
1051         Scale the drag image up by the device scale factor. In WebDragClient, we scale the image back down to the
1052         original size. It seems the reason we do this extra dance is because the image sizing heuristic in between
1053         assumes that the image dimensions are for a non-retina device, but this work should really not be necessary if
1054         we tweak the heuristic to account for deviceScaleFactor. We should address this in a separate patch.
1055
1056         * platform/DragImage.h:
1057         * platform/graphics/Path.h:
1058
1059 2017-02-14  Basuke Suzuki  <Basuke.Suzuki@am.sony.com>
1060
1061         [CURL] ResourceError created with error information should have default type Type::General
1062         https://bugs.webkit.org/show_bug.cgi?id=168345
1063
1064         Reviewed by Alex Christensen.
1065
1066         ResourceError has separate implementaion for each platform
1067         so that the interface should be same.
1068         On CURL port, the constructor with error information has
1069         different default value on `type` parameter. It is Type::Null but other implementaitons have Type::General.
1070         This causes some ResourceError is created inconsistent. 
1071
1072         * platform/network/curl/ResourceError.h:
1073         (WebCore::ResourceError::ResourceError):
1074
1075 2017-02-14  Youenn Fablet  <youennf@gmail.com>
1076
1077         [WebRTC] Add support for libwebrtc negotiation needed event
1078         https://bugs.webkit.org/show_bug.cgi?id=168267
1079
1080         Reviewed by Eric Carlson.
1081
1082         Test: webrtc/negotiatedneeded-event-addStream.html
1083
1084         Moving generic code (markAsNeedingNegotiation) from MediaEndpointPeerConnection to PeerConnectionBackend.
1085         This code handles the control of sending or not the negotiationneeded event.
1086
1087         Updating mock to use markAsNeedingNegotiation when streams are changed.
1088         Updating libwebrtc backend to call markAsNeedingNegotiation when required by libwebrtc implementation.
1089
1090         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
1091         (WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask):
1092         * Modules/mediastream/MediaEndpointPeerConnection.h:
1093         * Modules/mediastream/PeerConnectionBackend.cpp:
1094         (WebCore::PeerConnectionBackend::markAsNeedingNegotiation):
1095         * Modules/mediastream/PeerConnectionBackend.h:
1096         (WebCore::PeerConnectionBackend::isNegotiationNeeded):
1097         (WebCore::PeerConnectionBackend::clearNegotiationNeededState):
1098         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
1099         (WebCore::LibWebRTCMediaEndpoint::OnRenegotiationNeeded):
1100         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
1101         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
1102         * testing/MockLibWebRTCPeerConnection.cpp:
1103         (WebCore::MockLibWebRTCPeerConnection::AddStream):
1104         (WebCore::MockLibWebRTCPeerConnection::RemoveStream):
1105
1106 2017-02-14  Brady Eidson  <beidson@apple.com>
1107
1108         Unreviewed followup to r212330 to fix Debug builds
1109
1110         * loader/DocumentThreadableLoader.cpp:
1111         (WebCore::DocumentThreadableLoader::DocumentThreadableLoader): Add call to relaxAdoptionRequirement().
1112
1113 2017-02-14  Matt Rajca  <mrajca@apple.com>
1114
1115         Website policies: iframes should respect the autoplay policy of the top-level document
1116         https://bugs.webkit.org/show_bug.cgi?id=168333
1117
1118         Reviewed by Alex Christensen.
1119
1120         API tests were added.
1121
1122         * html/HTMLMediaElement.cpp:
1123         (WebCore::HTMLMediaElement::HTMLMediaElement):
1124
1125 2017-02-14  Dean Jackson  <dino@apple.com>
1126
1127         Rename preferLowPowerWebGLRendering setting to forceWebGLUsesLowPower
1128         https://bugs.webkit.org/show_bug.cgi?id=168339
1129         <rdar://problem/30522092>
1130
1131         Reviewed by Simon Fraser.
1132
1133         Use a setting name that more clearly reflects what it is doing. It's not
1134         preferring to use the low-power GPU, it's forcing it.
1135
1136         * html/canvas/WebGLRenderingContextBase.cpp:
1137         (WebCore::WebGLRenderingContextBase::create):
1138         * page/Settings.in:
1139
1140 2017-02-14  Brady Eidson  <beidson@apple.com>
1141
1142         Speculative fix for: Crash in DocumentThreadableLoader::redirectReceived.
1143         <rdar://problem/29899473> and https://bugs.webkit.org/show_bug.cgi?id=168337
1144
1145         Reviewed by Geoffrey Garen.
1146
1147         No new tests (Unable to find a reproduction).
1148
1149         * loader/DocumentThreadableLoader.cpp:
1150         (WebCore::DocumentThreadableLoader::loadRequest):
1151
1152 2017-02-14  Youenn Fablet  <youenn@apple.com>
1153
1154         [WebRTC] Remove obsolete WebRTC stats API
1155         https://bugs.webkit.org/show_bug.cgi?id=167910
1156
1157         Reviewed by Alex Christensen.
1158
1159         No change of behavior as removed constructs are not functional.
1160         Removing RTCStatsResponse which no longer exists and made RTCStatsReport an empty container for now.
1161
1162         * CMakeLists.txt:
1163         * DerivedSources.cpp:
1164         * DerivedSources.make:
1165         * Modules/mediastream/MediaEndpointPeerConnection.cpp:
1166         (WebCore::MediaEndpointPeerConnection::getStats):
1167         * Modules/mediastream/MediaEndpointPeerConnection.h:
1168         * Modules/mediastream/PeerConnectionBackend.h:
1169         * Modules/mediastream/RTCPeerConnection.cpp:
1170         (WebCore::RTCPeerConnection::getStats):
1171         * Modules/mediastream/RTCStatsReport.cpp:
1172         (WebCore::RTCStatsReport::create): Deleted.
1173         (WebCore::RTCStatsReport::RTCStatsReport): Deleted.
1174         (WebCore::RTCStatsReport::names): Deleted.
1175         (WebCore::RTCStatsReport::local): Deleted.
1176         (WebCore::RTCStatsReport::remote): Deleted.
1177         (WebCore::RTCStatsReport::addStatistic): Deleted.
1178         * Modules/mediastream/RTCStatsReport.h:
1179         (WebCore::RTCStatsReport::create):
1180         (WebCore::RTCStatsReport::timestamp): Deleted.
1181         (WebCore::RTCStatsReport::id): Deleted.
1182         (WebCore::RTCStatsReport::type): Deleted.
1183         (WebCore::RTCStatsReport::stat): Deleted.
1184         * Modules/mediastream/RTCStatsReport.idl:
1185         * Modules/mediastream/RTCStatsResponse.cpp: Removed.
1186         * Modules/mediastream/RTCStatsResponse.h: Removed.
1187         * Modules/mediastream/RTCStatsResponse.idl: Removed.
1188         * WebCore.xcodeproj/project.pbxproj:
1189         * platform/mediastream/MediaEndpoint.h:
1190         (WebCore::MediaEndpoint::getStats):
1191         * platform/mediastream/RTCStatsRequest.h: Removed.
1192         * platform/mediastream/RTCStatsResponseBase.h: Removed.
1193
1194 2017-02-14  Karim H  <karim@karhm.com>
1195
1196         Removed unused methods of WebCore::FileStream
1197         https://bugs.webkit.org/show_bug.cgi?id=168025
1198
1199         Reviewed by Michael Catanzaro.
1200
1201         * fileapi/AsyncFileStream.cpp:
1202         (WebCore::AsyncFileStream::openForWrite): Deleted.
1203         (WebCore::AsyncFileStream::write): Deleted.
1204         (WebCore::AsyncFileStream::truncate): Deleted.
1205         * fileapi/AsyncFileStream.h:
1206         * platform/FileStream.cpp:
1207         (WebCore::FileStream::openForWrite): Deleted.
1208         (WebCore::FileStream::write): Deleted.
1209         (WebCore::FileStream::truncate): Deleted.
1210         * platform/FileStream.h:
1211
1212 2017-02-14  Chris Dumez  <cdumez@apple.com>
1213
1214         HTML Form Validation bubble should take minimum font size setting into consideration
1215         https://bugs.webkit.org/show_bug.cgi?id=168271
1216         <rdar://problem/29869869>
1217
1218         Reviewed by Simon Fraser.
1219
1220         HTML Form Validation bubble should take minimum font size setting into consideration
1221         for better accessibility.
1222
1223         Test: fast/forms/validation-message-minimum-font-size.html
1224
1225         * platform/ValidationBubble.h:
1226         (WebCore::ValidationBubble::create):
1227         (WebCore::ValidationBubble::fontSize):
1228         * platform/ios/ValidationBubbleIOS.mm:
1229         (WebCore::ValidationBubble::ValidationBubble):
1230         * platform/mac/ValidationBubbleMac.mm:
1231         (WebCore::ValidationBubble::ValidationBubble):
1232         Update the ValidationBubble constructor to take in Settings. For now, there is a
1233         single setting that is the minimum font size and that is taken into account when
1234         setting the font size of the validation bubble text.
1235
1236 2017-02-14  Eric Carlson  <eric.carlson@apple.com>
1237
1238         [MediaStream] add navigator.getUserMedia for compatibility with legacy content
1239         https://bugs.webkit.org/show_bug.cgi?id=168324
1240         <rdar://problem/30513125>
1241
1242         Reviewed by Youenn Fablet.
1243
1244         Tests: fast/mediastream/argument-types.html
1245                fast/mediastream/getusermedia.html
1246                fast/mediastream/webkitGetUserMedia-shadowing-then.html
1247
1248         * CMakeLists.txt:
1249         * DerivedSources.cpp:
1250         * DerivedSources.make:
1251         * Modules/mediastream/MediaDevices.idl:
1252         * Modules/mediastream/NavigatorUserMedia.idl: Added.
1253         * Modules/mediastream/NavigatorUserMedia.js: Added.
1254         * WebCore.xcodeproj/project.pbxproj:
1255         * bindings/js/WebCoreBuiltinNames.h:
1256         * page/Navigator.idl:
1257
1258 2017-02-14  Chris Dumez  <cdumez@apple.com>
1259
1260         Fallback to legacy type only when event is trusted
1261         https://bugs.webkit.org/show_bug.cgi?id=168301
1262
1263         Reviewed by Ryosuke Niwa.
1264
1265         Fallback to legacy type only when event is trusted as per a recent
1266         DOM specification change:
1267         - https://github.com/whatwg/dom/issues/404
1268         - https://github.com/whatwg/dom/pull/406
1269
1270         No new tests, rebaselined existing test.
1271
1272         * dom/EventTarget.cpp:
1273         (WebCore::legacyType):
1274         (WebCore::EventTarget::fireEventListeners):
1275
1276 2017-02-13  Dean Jackson  <dino@apple.com>
1277
1278         Rename preferLowPowerToHighPerformance to powerPreference
1279         https://bugs.webkit.org/show_bug.cgi?id=168269
1280         <rdar://problem/30504444>
1281
1282         Reviewed by Chris Dumez.
1283
1284         Based on the discussion in https://github.com/KhronosGroup/WebGL/pull/2283.
1285
1286         Change WebGLContextAttributes's preferLowPowerToHighPerformance boolean
1287         into a powerPreference enum taking three values. The implementation
1288         of the enum is in GraphicsContext3DAttributes.
1289
1290         While the name and values have changed, there should be no change in
1291         behaviour caused by this patch.
1292
1293         * html/canvas/WebGLContextAttributes.h: Use GraphicsContext3DAttributes
1294         enum GraphicsContext3DPowerPreference.
1295         * html/canvas/WebGLContextAttributes.idl: Rename and add the WebIDL enum.
1296         * html/canvas/WebGLRenderingContextBase.cpp: Use the new values.
1297         (WebCore::WebGLRenderingContextBase::create):
1298         (WebCore::WebGLRenderingContextBase::registerWithWebGLStateTracker):
1299         * platform/WebGLStateTracker.cpp:
1300         * platform/WebGLStateTracker.h: Update the state tracker to use the new
1301         values.
1302         * platform/graphics/GraphicsContext3DAttributes.h:
1303         * platform/graphics/mac/GraphicsContext3DMac.mm:
1304         (WebCore::setPixelFormat): Accept GraphicsContext3DPowerPreference as a parameter.
1305         (WebCore::GraphicsContext3D::GraphicsContext3D):
1306
1307 2017-02-14  Youenn Fablet  <youennf@gmail.com>
1308
1309         [WebRTC] Implement description getters for libwebrtc RTCPeerConnection
1310         https://bugs.webkit.org/show_bug.cgi?id=168234
1311
1312         Reviewed by Alex Christensen.
1313
1314         Allows passing W3C webrtc tests.
1315
1316         Implementing localDescription/remoteDescription using libwebrtc backend.
1317         current and pending description getters are made the same as local/remote getters for the moment.
1318         This should be fixed when upgrading to latest libwebrtc revision.
1319
1320         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
1321         (WebCore::toSessionDescriptionType):
1322         (WebCore::fromSessionDescriptionType):
1323         (WebCore::fromSessionDescription):
1324         (WebCore::LibWebRTCMediaEndpoint::localDescription):
1325         (WebCore::LibWebRTCMediaEndpoint::remoteDescription):
1326         (WebCore::LibWebRTCMediaEndpoint::doSetLocalDescription):
1327         (WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription):
1328         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
1329         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
1330         (WebCore::LibWebRTCPeerConnectionBackend::localDescription):
1331         * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
1332
1333 2017-02-14  Jeremy Jones  <jeremyj@apple.com>
1334
1335         When playing inline after fullscreen, set a flag instead of adding attribute plays inline, and use in requiresFullscreenForVideoPlayback.
1336         https://bugs.webkit.org/show_bug.cgi?id=167815
1337         rdar://problem/27685077
1338
1339         Reviewed by Jer Noble.
1340
1341         Test: media/media-fullscreen-loop-inline.html
1342
1343         When video is allowed to play inline after fullscreen. Looped video causes play state to update, which can send video back to fullscreen when
1344         allowsInline is false. This change will set a new flag when allowsInlineMediaPlaybackAfterFullscreen allows inline playback that can be tested
1345         in requiresFullscreenForVideoPlayback to prevent sending video back into fullscreen when video loops.
1346
1347         * html/HTMLMediaElement.cpp:
1348         (WebCore::HTMLMediaElement::enterFullscreen):
1349         (WebCore::HTMLMediaElement::exitFullscreen):
1350         * html/HTMLMediaElement.h:
1351         (WebCore::HTMLMediaElement::isTemporarilyAllowingInlinePlaybackAfterFullscreen): Added.
1352         * html/MediaElementSession.cpp:
1353         (WebCore::MediaElementSession::requiresFullscreenForVideoPlayback):
1354
1355 2017-02-14  Jer Noble  <jer.noble@apple.com>
1356
1357         Video elements with MediaSource objects set by srcObject are not cleared when srcObject is set to null
1358         https://bugs.webkit.org/show_bug.cgi?id=168268
1359
1360         Reviewed by Eric Carlson.
1361
1362         Test: fast/mediastream/MediaStream-MediaElement-setObject-null.html
1363
1364         Make the setSrcObject() operation compliant with the HTML spec. Since the specification defines
1365         srcObject in terms of either a MediaSource, MediaStream, or Blob object, add the variant typedef
1366         to HTMLMediaElement and move the definition out of the Modules/mediastream extension IDL and into
1367         HTMLMediaElement.idl. Then bring the "media elements load" and "resource selection" algorithms up
1368         to their most recent definitions in the HTML5 spec.
1369
1370         Drive-by fix: Allow the (admittedly weird) single-element-union type in IDL.
1371
1372         * CMakeLists.txt:
1373         * DerivedSources.cpp:
1374         * DerivedSources.make:
1375         * Modules/mediastream/HTMLMediaElementMediaStream.cpp: Removed.
1376         * Modules/mediastream/HTMLMediaElementMediaStream.h: Removed.
1377         * Modules/mediastream/HTMLMediaElementMediaStream.idl: Removed.
1378         * WebCore.xcodeproj/project.pbxproj:
1379         * bindings/scripts/IDLParser.pm:
1380         (parseUnionType):
1381         * html/HTMLAudioElement.cpp:
1382         (WebCore::HTMLAudioElement::createForJSConstructor):
1383         * html/HTMLMediaElement.cpp:
1384         (WebCore::actionName):
1385         (WebCore::HTMLMediaElement::parseAttribute):
1386         (WebCore::HTMLMediaElement::insertedInto):
1387         (WebCore::HTMLMediaElement::scheduleDelayedAction):
1388         (WebCore::HTMLMediaElement::scheduleNextSourceChild):
1389         (WebCore::HTMLMediaElement::pendingActionTimerFired):
1390         (WebCore::HTMLMediaElement::setSrcObject):
1391         (WebCore::HTMLMediaElement::load):
1392         (WebCore::HTMLMediaElement::prepareForLoad):
1393         (WebCore::HTMLMediaElement::selectMediaResource):
1394         (WebCore::HTMLMediaElement::loadResource):
1395         (WebCore::HTMLMediaElement::playInternal):
1396         (WebCore::HTMLMediaElement::pauseInternal):
1397         (WebCore::HTMLMediaElement::sourceWasAdded):
1398         (WebCore::HTMLMediaElement::clearMediaPlayer):
1399         (WebCore::HTMLMediaElement::resume):
1400         (WebCore::HTMLMediaElement::mediaCanStart):
1401         (WebCore::HTMLMediaElement::createMediaPlayer):
1402         (WebCore::HTMLMediaElement::loadInternal): Deleted.
1403         * html/HTMLMediaElement.h:
1404         (WebCore::HTMLMediaElement::srcObject):
1405         * html/HTMLMediaElement.idl:
1406         * platform/ContentType.h:
1407
1408 2017-02-14  Aakash Jain  <aakash_jain@apple.com>
1409
1410         Remove unused WebThreadContextIsCurrent method from WebCoreThread.h
1411         https://bugs.webkit.org/show_bug.cgi?id=168254
1412
1413         Reviewed by Dan Bernstein.
1414
1415         * platform/ios/wak/WebCoreThread.h: Removed unused WebThreadContextIsCurrent.
1416         * platform/ios/wak/WebCoreThread.mm:
1417         (WebThreadContextIsCurrent): Deleted.
1418
1419 2017-02-14  Alexey Proskuryakov  <ap@apple.com>
1420
1421         WebCore shouldn't export SystemMemory.h
1422         https://bugs.webkit.org/show_bug.cgi?id=168285
1423
1424         Reviewed by Alex Christensen.
1425
1426         * WebCore.xcodeproj/project.pbxproj:
1427
1428 2017-02-13  Filip Pizlo  <fpizlo@apple.com>
1429
1430         worker.postMessage should throw a TypeError if a SharedArrayBuffer is in the transfer list
1431         https://bugs.webkit.org/show_bug.cgi?id=168277
1432
1433         Reviewed by Mark Lam.
1434
1435         Test: workers/sab/postMessage-transfer-type-error.html
1436         
1437         This is a simple spec compliance change. The title says it all.
1438
1439         * bindings/js/SerializedScriptValue.cpp:
1440         (WebCore::SerializedScriptValue::create):
1441
1442 2017-02-14  Zan Dobersek  <zdobersek@igalia.com>
1443
1444         HTMLMediaElement: WebKitMediaKeys member name should be prefixed
1445         https://bugs.webkit.org/show_bug.cgi?id=168297
1446
1447         Reviewed by Xabier Rodriguez-Calvar.
1448
1449         Rename the LEGACY_ENCRYPTED_MEDIA m_mediaKeys variable to m_webkitMediaKeys
1450         so that it contains the legacy prefix, just like the API. This will make
1451         room for the MediaKeys member variable that will be implemented under
1452         the ENCRYPTED_MEDIA guards.
1453
1454         * html/HTMLMediaElement.cpp:
1455         (WebCore::HTMLMediaElement::mediaPlayerCachedKeyForKeyId):
1456         (WebCore::HTMLMediaElement::webkitSetMediaKeys):
1457         * html/HTMLMediaElement.h:
1458         (WebCore::HTMLMediaElement::webkitKeys):
1459
1460 2017-02-14  Carlos Garcia Campos  <cgarcia@igalia.com>
1461
1462         [GTK] Make DragImageRef a RefPtr instead of a plain pointer
1463         https://bugs.webkit.org/show_bug.cgi?id=168296
1464
1465         Reviewed by Sergio Villar Senin.
1466
1467         Use RefPtr<cairo_surface_t> as DragImageRef for GTK+ port to avoid memory leaks.
1468
1469         * platform/DragImage.h:
1470         * platform/gtk/DragImageGtk.cpp:
1471         (WebCore::dragImageSize):
1472         (WebCore::deleteDragImage):
1473         (WebCore::scaleDragImage):
1474         (WebCore::dissolveDragImageToFraction):
1475         (WebCore::createDragImageFromImage):
1476         (WebCore::createDragImageIconForCachedImageFilename):
1477
1478 2017-02-14  Vanessa Chipirrás Navalón  <vchipirras@igalia.com>
1479
1480         [GStreamer][MSE] Some GStreamer log messages are generated with the 'default' category
1481         https://bugs.webkit.org/show_bug.cgi?id=168015
1482
1483         Reviewed by Xabier Rodriguez-Calvar.
1484
1485         The elements AppendPipeline, PlaybackPipeline, MediaSourceClientGstreamerMSE do not have
1486         a defined Gstreamer log category, then the webkitmse category has been added to them.
1487         WebKitMediaSourceGstreamer has its own category but was not declared at the beginning of
1488         the .cpp file.
1489
1490         * platform/graphics/gstreamer/mse/AppendPipeline.cpp: Added webkitmse category.
1491         * platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp:
1492         Added webkitmse category and gst header.
1493         * platform/graphics/gstreamer/mse/PlaybackPipeline.cpp: Added webkitmse category.
1494         * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
1495         Added webkitmediasrc category.
1496
1497 2017-02-14  Carlos Garcia Campos  <cgarcia@igalia.com>
1498
1499         CookieManager only works with the default session
1500         https://bugs.webkit.org/show_bug.cgi?id=168229
1501
1502         Reviewed by Alex Christensen.
1503
1504         Update cookie observer API to use a std::function instead of a function pointer and make it work with multiple
1505         sessions in the backends that support it.
1506
1507         * platform/network/CookieStorage.h:
1508         * platform/network/cf/CookieStorageCFNet.cpp:
1509         (WebCore::cookieChangeCallbackMap):
1510         (WebCore::notifyCookiesChanged):
1511         (WebCore::startObservingCookieChanges):
1512         (WebCore::stopObservingCookieChanges):
1513         * platform/network/mac/CookieStorageMac.mm:
1514         (-[WebCookieStorageObjCAdapter startListeningForCookieChangeNotificationsWithCallback:]):
1515         (-[WebCookieStorageObjCAdapter stopListeningForCookieChangeNotifications]):
1516         (WebCore::startObservingCookieChanges):
1517         (WebCore::stopObservingCookieChanges):
1518         * platform/network/soup/CookieStorageSoup.cpp:
1519         (WebCore::cookieChangeCallbackMap):
1520         (WebCore::soupCookiesChanged):
1521         (WebCore::startObservingCookieChanges):
1522         (WebCore::stopObservingCookieChanges):
1523
1524 2017-02-13  Antoine Quint  <graouts@apple.com>
1525
1526         REGRESSION: Update volume and scrubbing slider to match HI designs
1527         https://bugs.webkit.org/show_bug.cgi?id=168170
1528         <rdar://problem/28095266>
1529
1530         Reviewed by Dean Jackson.
1531
1532         We bring the designs of the control's background materials, scrubber and
1533         volume slider up to spec.
1534
1535         The first important set of changes is that, on macOS, the materials and colors
1536         were incorrect. Buttons and time labels now set a mix-blend-mode to correctly
1537         appear vibrant against the media, and the controls bar, volume container
1538         and tracks menu now use a new BackgroundTint node to correctly apply both
1539         a backdrop-filter and blended tint above it.
1540
1541         The second important set of changes is the rendering of the sliders. Up to now
1542         we would simply style the <input type="range"> track and thumb, applying solid
1543         fills and strokes. We now draw sliders in two ways depending on the platform.
1544         
1545         On macOS, we draw the whole slider with a <canvas> element with "mix-blend-mode"
1546         set to "plus-lighter". On iOS, we draw the track as a <div> with "mix-blend-mode"
1547         set to "plus-darker" and draw the fill (up to the thumb) in the <canvas> with
1548         no blend mode to obtain a pure white color, finally the thumb is rendered by the
1549         <input> element. We couldn't draw the pure white color with the track in the
1550         same <canvas> due to the "plus-darker" blend mode.
1551
1552         Test: media/modern-media-controls/background-tint/background-tint.html
1553
1554         * Modules/modern-media-controls/controls/airplay-button.css:
1555         (button.airplay.on):
1556         * Modules/modern-media-controls/controls/background-tint.css: Added.
1557         (.background-tint):
1558         (.background-tint,):
1559         (.background-tint > .blur):
1560         (.background-tint > .tint):
1561         * Modules/modern-media-controls/controls/background-tint.js: Added.
1562         (BackgroundTint):
1563         * Modules/modern-media-controls/controls/ios-inline-media-controls.css:
1564         (.media-controls.ios.inline .scrubber.slider):
1565         (.media-controls.ios.inline .scrubber.slider > div):
1566         (.media-controls.ios.inline .scrubber.slider > input::-webkit-slider-thumb):
1567         (.media-controls.ios.inline .scrubber.slider > .fill): Deleted.
1568         * Modules/modern-media-controls/controls/macos-compact-inline-media-controls.css:
1569         (.media-controls.mac.inline.compact .volume-slider-container):
1570         (.media-controls.mac.inline.compact .volume.slider):
1571         (.media-controls.mac.inline.compact .scrubber.slider > input::-webkit-slider-thumb): Deleted.
1572         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.css:
1573         (.media-controls.mac.fullscreen > .controls-bar):
1574         (.media-controls.mac.fullscreen > .controls-bar > .background-tint > div):
1575         (.media-controls.mac.fullscreen .volume.slider):
1576         (.media-controls.mac.fullscreen button.volume-up):
1577         (.media-controls.mac.fullscreen button.rewind):
1578         (.media-controls.mac.fullscreen button.forward):
1579         (.media-controls.mac.fullscreen .buttons-container.right button):
1580         (.media-controls.mac.fullscreen .scrubber):
1581         (.media-controls.mac.fullscreen > .controls-bar button): Deleted.
1582         (.media-controls.mac.fullscreen button.airplay): Deleted.
1583         (.media-controls.mac.fullscreen button.aspect-ratio): Deleted.
1584         (.media-controls.mac.fullscreen button.pip): Deleted.
1585         (.media-controls.mac.fullscreen button.tracks): Deleted.
1586         (.media-controls.mac.fullscreen button.fullscreen): Deleted.
1587         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js:
1588         * Modules/modern-media-controls/controls/macos-inline-media-controls.css:
1589         (.media-controls.mac.inline .scrubber.slider):
1590         (.media-controls.mac.inline .volume-slider-container):
1591         (.media-controls.mac.inline .volume-slider-container > .background-tint):
1592         (.media-controls.mac.inline .volume-slider-container > .background-tint > div):
1593         (.media-controls.mac.inline .volume.slider):
1594         (.media-controls.mac.inline button): Deleted.
1595         (.media-controls.mac.inline button:active): Deleted.
1596         (.media-controls.mac.inline > .controls-bar button): Deleted.
1597         (.media-controls.mac.inline > .controls-bar,): Deleted.
1598         (.media-controls.mac.inline .volume-slider-container:before): Deleted.
1599         * Modules/modern-media-controls/controls/macos-inline-media-controls.js:
1600         (MacOSInlineMediaControls.prototype.layout):
1601         * Modules/modern-media-controls/controls/macos-media-controls.css: Added.
1602         (.media-controls.mac button:active):
1603         (.media-controls.mac > .controls-bar button):
1604         (.media-controls.mac > .controls-bar .time-label):
1605         (.media-controls.mac > .controls-bar .slider > canvas):
1606         (.media-controls.mac > .controls-bar .slider > input::-webkit-slider-thumb):
1607         * Modules/modern-media-controls/controls/scrubber.css: Removed.
1608         * Modules/modern-media-controls/controls/scrubber.js:
1609         (Scrubber):
1610         (Scrubber.prototype.get buffered):
1611         (Scrubber.prototype.set buffered):
1612         (Scrubber.prototype.draw):
1613         (Scrubber.prototype._drawMacOS):
1614         (Scrubber.prototype._drawiOS):
1615         * Modules/modern-media-controls/controls/slider.css:
1616         (.slider):
1617         (.slider > canvas,):
1618         (.slider > canvas):
1619         (.slider > input):
1620         (.slider > input,): Deleted.
1621         (.slider > .fill): Deleted.
1622         (.slider > input::-webkit-slider-thumb): Deleted.
1623         * Modules/modern-media-controls/controls/slider.js:
1624         (Slider.prototype.set value):
1625         (Slider.prototype.set width):
1626         (Slider.prototype.commitProperty):
1627         (Slider.prototype.layout):
1628         (Slider.prototype.draw):
1629         (Slider.prototype._handleInputEvent):
1630         (Slider.prototype._handleChangeEvent):
1631         (addRoundedRect):
1632         (Slider.prototype._updateFill): Deleted.
1633         * Modules/modern-media-controls/controls/start-button.css:
1634         (button.start):
1635         * Modules/modern-media-controls/controls/time-control.js:
1636         * Modules/modern-media-controls/controls/time-label.css:
1637         (.time-label):
1638         * Modules/modern-media-controls/controls/tracks-panel.css:
1639         (.tracks-panel):
1640         (.tracks-panel > .background-tint > div):
1641         (.tracks-panel > section):
1642         (.tracks-panel > section:first-of-type):
1643         (.tracks-panel > section > h3):
1644         (.tracks-panel > section > ul):
1645         (.tracks-panel > section > ul > li):
1646         (.tracks-panel > section > ul > li:focus):
1647         (.tracks-panel > section > ul > li.selected:before):
1648         (.tracks-panel > section > ul > li.animated):
1649         (.tracks-panel-section): Deleted.
1650         (.tracks-panel-section:first-of-type): Deleted.
1651         (.tracks-panel-section > h3): Deleted.
1652         (.tracks-panel-section > ul): Deleted.
1653         (.tracks-panel-section > ul > li): Deleted.
1654         (.tracks-panel-section > ul > li:focus): Deleted.
1655         (.tracks-panel-section > ul > li.selected:before): Deleted.
1656         (.tracks-panel-section > ul > li.animated): Deleted.
1657         * Modules/modern-media-controls/controls/tracks-panel.js:
1658         (TracksPanel.prototype._childrenFromDataSource):
1659         (TracksPanel.prototype._childrenFromDataSource.): Deleted.
1660         * Modules/modern-media-controls/controls/volume-slider.js:
1661         (VolumeSlider):
1662         (VolumeSlider.prototype.handleEvent):
1663         (VolumeSlider.prototype.draw):
1664         * Modules/modern-media-controls/js-files:
1665         * Modules/modern-media-controls/media/scrubbing-support.js:
1666         (ScrubbingSupport.prototype.get mediaEvents):
1667         (ScrubbingSupport.prototype.syncControl):
1668         (ScrubbingSupport):
1669
1670 2017-02-13  Alex Christensen  <achristensen@webkit.org>
1671
1672         URLs with an invalid IPv4 address should be invalid
1673         https://bugs.webkit.org/show_bug.cgi?id=168260
1674
1675         Reviewed by Tim Horton.
1676
1677         All URL hosts are fed through the IPv4 parser.  https://webkit.org/ doesn't
1678         look enough like an IPv4 address to be considered an invalid IPv4 address, so 
1679         we continue to the String host processing.  http://127.0.0.257 does, though, and
1680         according to https://url.spec.whatwg.org/#concept-ipv4-parser parsing that URL
1681         should fail.
1682
1683         Covered by newly passing web platform tests.
1684
1685         * platform/URLParser.cpp:
1686         (WebCore::URLParser::parseIPv4Host):
1687         (WebCore::URLParser::parseHostAndPort):
1688         * platform/URLParser.h:
1689
1690 2017-02-13  Dan Bernstein  <mitz@apple.com>
1691
1692         Reverted r212275. It still breaks some Apple-internal builds.
1693
1694         * platform/spi/mac/TUCallSPI.h:
1695
1696 2017-02-13  Joseph Pecoraro  <pecoraro@apple.com>
1697
1698         Address ESLint warnings in modern-media-controls
1699         https://bugs.webkit.org/show_bug.cgi?id=168224
1700
1701         Reviewed by Alexey Proskuryakov.
1702
1703         * Modules/modern-media-controls/controls/controls-bar.js:
1704         * Modules/modern-media-controls/controls/fullscreen-button.js:
1705         * Modules/modern-media-controls/controls/layout-node.js:
1706         * Modules/modern-media-controls/controls/macos-fullscreen-media-controls.js:
1707         * Modules/modern-media-controls/controls/media-controls.js:
1708         * Modules/modern-media-controls/controls/scheduler.js:
1709         * Modules/modern-media-controls/controls/seek-button.js:
1710         * Modules/modern-media-controls/controls/tracks-panel.js:
1711         * Modules/modern-media-controls/controls/volume-slider.js:
1712         * Modules/modern-media-controls/gesture-recognizers/gesture-recognizer.js:
1713         * Modules/modern-media-controls/gesture-recognizers/pinch.js:
1714         * Modules/modern-media-controls/media/fullscreen-support.js:
1715         * Modules/modern-media-controls/media/media-controller.js:
1716         * Modules/modern-media-controls/media/placard-support.js:
1717         * Modules/modern-media-controls/media/status-support.js:
1718         Address pedantic warnings.
1719
1720 2017-02-13  Dan Bernstein  <mitz@apple.com>
1721
1722         Restored changes from r212210 in a way that does not break the build.
1723
1724         * platform/spi/mac/TUCallSPI.h:
1725
1726 2017-02-13  Zalan Bujtas  <zalan@apple.com>
1727
1728         FontCascade::widthForSimpleText should skip applyTransforms() when kerning and ligatures are off.
1729         https://bugs.webkit.org/show_bug.cgi?id=168251
1730         <rdar://problem/30498102>
1731
1732         Reviewed by Antti Koivisto.
1733
1734         Covered by existing (perf)tests.
1735
1736         * platform/graphics/FontCascade.cpp:
1737         (WebCore::FontCascade::widthForSimpleText):
1738
1739 2017-02-12  Brian Burg  <bburg@apple.com>
1740
1741         Web Inspector: expose system user interface layout direction through InspectorFrontendHost
1742         https://bugs.webkit.org/show_bug.cgi?id=168209
1743         <rdar://problem/11573736>
1744
1745         Reviewed by Joseph Pecoraro.
1746
1747         Forward the UserInterfaceLayoutDirection of the inspector page. If the WebKit client has
1748         properly set the UI directionality from system settings in PageClient, this will get inherited
1749         automatically by the Inspector's WebPage instance.
1750
1751         * inspector/InspectorFrontendClient.h:
1752         * inspector/InspectorFrontendClientLocal.cpp:
1753         (WebCore::InspectorFrontendClientLocal::userInterfaceLayoutDirection):
1754         * inspector/InspectorFrontendClientLocal.h:
1755
1756         * inspector/InspectorFrontendHost.h:
1757         * inspector/InspectorFrontendHost.idl:
1758         * inspector/InspectorFrontendHost.cpp:
1759         (WebCore::InspectorFrontendHost::userInterfaceLayoutDirection):
1760         Expose the directionality to the frontend as "ltr" or "rtl" strings.
1761
1762 2017-02-13  Zalan Bujtas  <zalan@apple.com>
1763
1764         Simple line layout: Do not measure runs with trailing whitespace when kerning and ligatures are off.
1765         https://bugs.webkit.org/show_bug.cgi?id=168247
1766         <rdar://problem/30497288>
1767
1768         Reviewed by Antti Koivisto.
1769
1770         The width of the run is supposed to be the same with or without the trailing whitespace.
1771
1772         Covered by performance test.
1773
1774         * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
1775         (WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style):
1776         (WebCore::SimpleLineLayout::TextFragmentIterator::textWidth):
1777         * rendering/SimpleLineLayoutTextFragmentIterator.h:
1778
1779 2017-02-13  Karim H  <karim@karhm.com>
1780
1781         Added the other missing BSTR roles tag names.
1782         https://bugs.webkit.org/show_bug.cgi?id=165545
1783
1784         Reviewed by Chris Fleizach.
1785
1786         Test: accessibility/win/bstr-elements-role.html
1787
1788         * accessibility/AccessibilityRenderObject.cpp:
1789         (WebCore::shouldReturnTagNameAsRoleForMSAA):
1790
1791 2017-02-13  Youenn Fablet  <youennf@gmail.com>
1792
1793         [WebRTC] Creating RTCPeerConnection with libwebrtc backend is crashing on rwt
1794         https://bugs.webkit.org/show_bug.cgi?id=168250
1795
1796         Reviewed by Alex Christensen.
1797
1798         Covered by webrtc tests in LayoutTests and in web-platform-tests.
1799         Making mock peer connection factory keep a ref of the real libwebrtc peer connection factory.
1800         That way, it can create real libwebrtc backends whenever requested by tests.
1801
1802         Moving LibWebRTCUtils.h routines as static LibWebRTCProvider methods.
1803         In the future, we should make them no longer static.
1804
1805         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
1806         (WebCore::LibWebRTCMediaEndpoint::doCreateOffer):
1807         (WebCore::LibWebRTCMediaEndpoint::doCreateAnswer):
1808         * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
1809         * WebCore.xcodeproj/project.pbxproj:
1810         * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp: Renamed from Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCUtils.cpp.
1811         (WebCore::LibWebRTCProvider::callOnWebRTCNetworkThread):
1812         (WebCore::LibWebRTCProvider::callOnWebRTCSignalingThread):
1813         (WebCore::LibWebRTCProvider::factory):
1814         (WebCore::LibWebRTCProvider::setPeerConnectionFactory):
1815         (WebCore::createActualPeerConnection):
1816         (WebCore::LibWebRTCProvider::createPeerConnection):
1817         * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
1818         * platform/mediastream/libwebrtc/LibWebRTCUtils.h: Removed.
1819         * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
1820         (WebCore::RealtimeOutgoingAudioSource::audioSamplesAvailable):
1821         * testing/Internals.cpp:
1822         * testing/MockLibWebRTCPeerConnection.cpp:
1823         (WebCore::useMockRTCPeerConnectionFactory):
1824         (WebCore::MockLibWebRTCPeerConnectionForIceCandidates::gotLocalDescription):
1825         (WebCore::releaseInNetworkThread):
1826         (WebCore::MockLibWebRTCPeerConnection::SetLocalDescription):
1827         (WebCore::MockLibWebRTCPeerConnection::SetRemoteDescription):
1828         (WebCore::MockLibWebRTCPeerConnection::CreateOffer):
1829         (WebCore::MockLibWebRTCPeerConnection::CreateAnswer):
1830
1831 2017-02-13  Anders Carlsson  <andersca@apple.com>
1832
1833         Simplify DragController::startDrag
1834         https://bugs.webkit.org/show_bug.cgi?id=168240
1835
1836         Reviewed by Tim Horton.
1837
1838         Use early returns instead of assigning to a variable that's returned at the end of the function.
1839
1840         * page/DragController.cpp:
1841         (WebCore::DragController::startDrag):
1842
1843 2017-02-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
1844
1845         The current frame of an image should not deleted if another frame is asynchronously being decoded
1846         https://bugs.webkit.org/show_bug.cgi?id=167618
1847
1848         Reviewed by Simon Fraser.
1849
1850         Test: fast/images/animated-image-draw-while-decode.html
1851
1852         If the memory cache asks the BitmapImage to destroy all its frames while
1853         the next frame is being decoded, a thread contention may happen. This can
1854         happen when BitmapImage::draw() is called and the next frame is not ready
1855         yet for drawing, so the current frame has to be drawn. This will invoke
1856         a frame decoding in the same image from the drawing committing thread.
1857
1858         We can avoid that by destroying all the frames except the current frame if
1859         the image is asynchronously decoding its frames. This should not add extra
1860         memory overhead because building the image frame cache and then destroying
1861         it, when needed, is an on-going process. The frames will be allocated and
1862         decoded all the time and all of them can be destroyed except the current one.
1863         
1864         * platform/graphics/BitmapImage.cpp:
1865         (WebCore::BitmapImage::destroyDecodedData):
1866         (WebCore::BitmapImage::destroyDecodedDataIfNecessary):
1867         The logic of destroying the ImageFrames was split among BitmapImage, ImageSource
1868         and ImageFrameCache. Move all the logic to BitmapImage and have ImageFrameCache
1869         be responsible only for destroying a range of ImageFrames.
1870
1871         (WebCore::BitmapImage::draw): add an ASSERT_IMPLIES to ensure the current frame
1872         is ready to be rendered if the next frame is being decoded.
1873         
1874         * platform/graphics/BitmapImage.h: Move a const from ImageFrameCache.h to BitmapImage.h.
1875
1876         * platform/graphics/ImageFrameCache.cpp:
1877         (WebCore::ImageFrameCache::destroyDecodedData):
1878         (WebCore::ImageFrameCache::destroyDecodedDataIfNecessary): Deleted.
1879         * platform/graphics/ImageFrameCache.h:
1880         (WebCore::ImageFrameCache::destroyAllDecodedData):
1881         (WebCore::ImageFrameCache::destroyAllDecodedDataExcludeFrame):
1882         (WebCore::ImageFrameCache::destroyDecodedDataBeforeFrame):
1883         Make ImageFrameCache be responsible for destroying a range of ImageFrames.
1884         This range might include all the frames, all the frames but up to a specific
1885         frame, or all the frames but exclude one frame in the middle.
1886         
1887         * platform/graphics/ImageSource.cpp:
1888         (WebCore::ImageSource::clear): No need to call clearFrameBufferCache() from clear().
1889         The decision to call clearFrameBufferCache() or clear() is moved to
1890         BitmapImage::destroyDecodedData().
1891          
1892         (WebCore::ImageSource::destroyDecodedData): Deleted.
1893         (WebCore::ImageSource::destroyDecodedDataIfNecessary): Deleted.
1894         These functions are replaced by another set of functions in ImageSource.h.
1895         
1896         * platform/graphics/ImageSource.h:
1897         (WebCore::ImageSource::destroyAllDecodedData):
1898         (WebCore::ImageSource::destroyAllDecodedDataExcludeFrame):
1899         (WebCore::ImageSource::destroyDecodedDataBeforeFrame):
1900         (WebCore::ImageSource::hasDecodingQueue):
1901         These are new wrappers which call the corresponding ImageFrameCache functions.
1902
1903 2017-02-13  Myles C. Maxfield  <mmaxfield@apple.com>
1904
1905         [Cocoa] Stop soft-linking CTRunGetBaseAdvancesAndOrigins()
1906         https://bugs.webkit.org/show_bug.cgi?id=168256
1907
1908         Reviewed by Alex Christensen.
1909
1910         Use of this function is already behind a platform guard.
1911
1912         No new tests because there is no behavior change.
1913
1914         * platform/graphics/mac/ComplexTextControllerCoreText.mm:
1915         (SOFT_LINK): Deleted.
1916
1917 2017-02-13  Jiewen Tan  <jiewen_tan@apple.com>
1918
1919         [WebCrypto] WebInspector should indicate webkitSubtle is deprecated
1920         https://bugs.webkit.org/show_bug.cgi?id=165913
1921         <rdar://problem/30477222>
1922
1923         Reviewed by Joseph Pecoraro.
1924
1925         Covered by existing tests.
1926
1927         * page/Crypto.cpp:
1928         (WebCore::Crypto::webkitSubtle):
1929
1930 2017-02-13  Simon Fraser  <simon.fraser@apple.com>
1931
1932         Call WKDestroyRenderingResources() on iOS when tabs are backgrounded
1933         https://bugs.webkit.org/show_bug.cgi?id=168261
1934         rdar://problem/30481079
1935
1936         Reviewed by Tim Horton.
1937
1938         Add CABackingStoreCollectBlocking() to QuartzCoreSPI.h, and fix files in WebCore
1939         that do a framework include.
1940
1941         * platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:
1942         * platform/graphics/cocoa/WebActionDisablingCALayerDelegate.h:
1943         * platform/spi/cocoa/QuartzCoreSPI.h:
1944         * platform/spi/mac/NSViewSPI.h:
1945
1946 2017-02-13  Youenn Fablet  <youenn@apple.com>
1947
1948         ASSERTION FAILED: !m_bodyLoader
1949         https://bugs.webkit.org/show_bug.cgi?id=166986
1950
1951         Reviewed by Sam Weinig.
1952
1953         Refactoring to make the unset/set pending activity part of body loader.
1954         This allows ensuring to not forget to do that by simply deleting the body loader.
1955
1956         * Modules/fetch/FetchResponse.cpp:
1957         (WebCore::FetchResponse::fetch):
1958         (WebCore::FetchResponse::BodyLoader::didSucceed):
1959         (WebCore::FetchResponse::BodyLoader::didFail):
1960         (WebCore::FetchResponse::BodyLoader::BodyLoader):
1961         (WebCore::FetchResponse::BodyLoader::~BodyLoader):
1962         (WebCore::FetchResponse::stop):
1963         * Modules/fetch/FetchResponse.h:
1964
1965 2017-02-13  Aakash Jain  <aakash_jain@apple.com>
1966
1967         Remove unused WebCoreThreadSafe.h
1968         https://bugs.webkit.org/show_bug.cgi?id=168236
1969
1970         Reviewed by Dan Bernstein.
1971
1972         * platform/ios/wak/WebCoreThreadSafe.h: Removed.
1973         * WebCore.xcodeproj/project.pbxproj: Removed WebCoreThreadSafe.h
1974         * platform/ios/wak/WebCoreThread.mm: Removed WebCoreThreadSafe.h and included WAKWindow.h directly
1975
1976 2017-02-13  Anders Carlsson  <andersca@apple.com>
1977
1978         Fix iOS build.
1979
1980         * platform/ios/DragImageIOS.mm:
1981         (WebCore::deleteDragImage):
1982
1983 2017-02-13  Sam Weinig  <sam@webkit.org>
1984
1985         Rename MediaQueryExp.h/cpp to MediaQueryExpression.h/cpp
1986         https://bugs.webkit.org/show_bug.cgi?id=168249
1987
1988         Reviewed by Dean Jackson.
1989
1990         Fix a FIXME and rename MediaQueryExp.h/cpp to match the class it contains, MediaQueryExpression.
1991
1992         * CMakeLists.txt:
1993         * WebCore.xcodeproj/project.pbxproj:
1994         * css/CSSAllInOne.cpp:
1995         * css/MediaQuery.h:
1996         * css/MediaQueryEvaluator.h:
1997         * css/MediaQueryExp.cpp: Removed.
1998         * css/MediaQueryExp.h: Removed.
1999         * css/MediaQueryExpression.cpp: Copied from Source/WebCore/css/MediaQueryExp.cpp.
2000         * css/MediaQueryExpression.h: Copied from Source/WebCore/css/MediaQueryExp.h.
2001         * css/parser/MediaQueryParser.h:
2002
2003 2017-02-13  Aakash Jain  <aakash_jain@apple.com>
2004
2005         WAKResponder should be exported from WebCore
2006         https://bugs.webkit.org/show_bug.cgi?id=168245
2007
2008         Reviewed by Dan Bernstein.
2009
2010         * platform/ios/wak/WAKResponder.h:
2011
2012 2017-02-13  Simon Fraser  <simon.fraser@apple.com>
2013
2014         Log to the History Channel in a few more places
2015         https://bugs.webkit.org/show_bug.cgi?id=168252
2016
2017         Reviewed by Brady Eidson.
2018
2019         *** Aliens ***
2020
2021         * loader/HistoryController.cpp:
2022         (WebCore::HistoryController::restoreScrollPositionAndViewState):
2023         (WebCore::HistoryController::updateForReload):
2024         * loader/NavigationScheduler.cpp:
2025         (WebCore::NavigationScheduler::scheduleHistoryNavigation):
2026         (WebCore::NavigationScheduler::timerFired):
2027         (WebCore::NavigationScheduler::cancel):
2028         * page/History.cpp:
2029         (WebCore::History::go):
2030
2031 2017-02-13  Alex Christensen  <achristensen@webkit.org>
2032
2033         Percent should be allowed in non-special URL hosts
2034         https://bugs.webkit.org/show_bug.cgi?id=168255
2035
2036         Reviewed by Tim Horton.
2037
2038         In the last few weeks, the spec has consolidated its sets of code points.
2039         Now forbidden host code points replace the old invalid host code points with
2040         the modification that percents are allowed in non-special hosts because we
2041         percent-encode non-ascii code points in non-special hosts.
2042         See https://url.spec.whatwg.org/#concept-opaque-host-parser
2043
2044         Covered by newly passing web platform tests.
2045
2046         * platform/URLParser.cpp:
2047         (WebCore::isC0Control):
2048         (WebCore::isInUserInfoEncodeSet):
2049         (WebCore::URLParser::hasForbiddenHostCodePoint):
2050         (WebCore::URLParser::parseHostAndPort):
2051         (WebCore::isInvalidDomainCharacter): Deleted.
2052         (WebCore::URLParser::hasInvalidDomainCharacter): Deleted.
2053         * platform/URLParser.h:
2054
2055 2017-02-13  Anders Carlsson  <andersca@apple.com>
2056
2057         Fix Windows build.
2058
2059         * platform/win/PasteboardWin.cpp:
2060         (WebCore::Pasteboard::setDragImage):
2061
2062 2017-02-13  Alex Christensen  <achristensen@webkit.org>
2063
2064         Fix Yosemite build after r211765
2065         https://bugs.webkit.org/show_bug.cgi?id=168246
2066         <rdar://problem/30494174>
2067
2068         Reviewed by Brady Eidson.
2069
2070         * platform/graphics/mac/ComplexTextControllerCoreText.mm:
2071         (SOFT_LINK):
2072
2073 2017-02-13  Anders Carlsson  <andersca@apple.com>
2074
2075         Add a DragImage class that wraps a DragImageRef
2076         https://bugs.webkit.org/show_bug.cgi?id=168131
2077
2078         Reviewed by Beth Dakin.
2079
2080         This allows us to get rid of the explicit deleteDragImage calls and will make additional cleanup of the
2081         various drag code paths possible. No functionality change.
2082
2083         * dom/DataTransfer.cpp:
2084         (WebCore::DataTransfer::updateDragImage):
2085         * page/DragController.cpp:
2086         (WebCore::DragController::startDrag):
2087         (WebCore::DragController::doImageDrag):
2088         (WebCore::DragController::doSystemDrag):
2089         * page/DragController.h:
2090         * platform/DragImage.cpp:
2091         (WebCore::DragImage::DragImage):
2092         (WebCore::DragImage::operator=):
2093         (WebCore::DragImage::~DragImage):
2094         * platform/DragImage.h:
2095         * platform/Pasteboard.h:
2096         * platform/StaticPasteboard.h:
2097         * platform/mac/PasteboardMac.mm:
2098         (WebCore::Pasteboard::setDragImage):
2099
2100 2017-02-13  Chris Dumez  <cdumez@apple.com>
2101
2102         Regression(r211455): ASSERTION FAILED: frameView || pageCacheState() == InPageCache in com.apple.WebCore: WebCore::Document::destroyRenderTree
2103         https://bugs.webkit.org/show_bug.cgi?id=168237
2104         <rdar://problem/30494165>
2105
2106         Reviewed by Gavin Barraclough.
2107
2108         Drop bad assertion under document::destroyRenderTree() that was introduced in r211455.
2109         The assertion seemed like a good idea but the issue is that CachedFrame::destroy()
2110         reset's the document's pageCacheState before calling Document::prepareForDestruction().
2111
2112         No new tests, this fixes assertion hits on our bots.
2113
2114         * dom/Document.cpp:
2115         (WebCore::Document::destroyRenderTree):
2116
2117 2017-02-13  Myles C. Maxfield  <mmaxfield@apple.com>
2118
2119         Update custom line breaking iterators to the latest version of Unicode
2120         https://bugs.webkit.org/show_bug.cgi?id=168182
2121
2122         Reviewed by Zalan Bujtas.
2123
2124         Clean up our breaking code to be more descriptive about the difference between
2125         line-break: auto vs line-break: loose | normal | strict. The only difference is
2126         that we have some hardcoded tables to speed up character iteration for
2127         line-break: auto.
2128
2129         Tests: TestWebKitAPI WebKit2.LineBreaking
2130
2131         * rendering/BreakLines.h:
2132         (WebCore::nextBreakablePosition):
2133         (WebCore::nextBreakablePositionIgnoringNBSP):
2134         (WebCore::nextBreakablePositionWithoutShortcut):
2135         (WebCore::nextBreakablePositionIgnoringNBSPWithoutShortcut):
2136         (WebCore::isBreakable):
2137         (WebCore::nextBreakablePositionNonLoosely): Deleted.
2138         (WebCore::nextBreakablePositionLoosely): Deleted.
2139         (WebCore::nextBreakablePositionLoose): Deleted.
2140         (WebCore::nextBreakablePositionIgnoringNBSPLoose): Deleted.
2141         * rendering/RenderText.cpp:
2142         (WebCore::RenderText::computePreferredLogicalWidths):
2143         * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
2144         (WebCore::SimpleLineLayout::nextBreakablePositionInSegment):
2145         * rendering/line/BreakingContext.h:
2146         (WebCore::BreakingContext::handleText):
2147         (WebCore::BreakingContext::optimalLineBreakLocationForTrailingWord):
2148
2149 2017-02-13  Youenn Fablet  <youenn@apple.com>
2150
2151         Remove @getUserMedia identifier
2152         https://bugs.webkit.org/show_bug.cgi?id=168216
2153
2154         Reviewed by Sam Weinig.
2155
2156         No change of behavior.
2157
2158         * Modules/mediastream/MediaDevices.idl:
2159         * bindings/js/WebCoreBuiltinNames.h:
2160
2161 2017-02-13  Carlos Garcia Campos  <cgarcia@igalia.com>
2162
2163         [GTK] Non-accelerated drawing is broken with HiDPI
2164         https://bugs.webkit.org/show_bug.cgi?id=168128
2165
2166         Reviewed by Michael Catanzaro.
2167
2168         When device scale factor changes, the page notifies the page overlay controller about it. Then overlay root
2169         layers are created to be notified about the device scale factor. That causes us to enter in accelerated
2170         compositing mode, because the graphics layer factory is called. But the render layer compositor doesn't really
2171         enter in accelerated mode, because there aren't page overlays, the accelerated mode is not forced and the website
2172         doesn't require acceleration either. This leaves our drawing area in an inconsistent state, it thinks it's in AC
2173         mode because it has a layer tree host, but without a root layer attached, so nothing is rendered. The page
2174         overlay controller doesn't need to create the layers when device scale factor changes, when an overlay is
2175         installed, layers will be created with the current device scale factor anyway.
2176
2177         * page/PageOverlayController.cpp:
2178         (WebCore::PageOverlayController::didChangeDeviceScaleFactor): Return early if not initialized yet.
2179
2180 2017-02-13  Csaba Osztrogonác  <ossy@webkit.org>
2181
2182         REGRESSION(r210845) Build broken with ENABLE_MHTML disabled
2183         https://bugs.webkit.org/show_bug.cgi?id=167771
2184
2185         Reviewed by Daniel Bates.
2186
2187         * loader/DocumentLoader.cpp:
2188         (WebCore::DocumentLoader::commitData):
2189
2190 2017-02-12  Dan Bernstein  <mitz@apple.com>
2191
2192         Tried to fix USE(APPLE_INTERNAL_SDK) builds after r212211.
2193
2194         * platform/spi/mac/TUCallSPI.h: Reverted to r212210.
2195
2196 2017-02-12  Dan Bernstein  <mitz@apple.com>
2197
2198         Tried to fix USE(APPLE_INTERNAL_SDK) builds after r212211.
2199
2200         * platform/spi/mac/TUCallSPI.h:
2201
2202 2017-02-12  Dan Bernstein  <mitz@apple.com>
2203
2204         Tried to fix USE(APPLE_INTERNAL_SDK) builds after r212211.
2205
2206         * platform/spi/mac/TUCallSPI.h:
2207
2208 2017-02-12  Dan Bernstein  <mitz@apple.com>
2209
2210         Tried to fix USE(APPLE_INTERNAL_SDK) builds after r212211.
2211
2212         * platform/spi/mac/NSMenuSPI.h: Replaced declaration of deprecated method with its current
2213           equivalent.
2214
2215 2017-02-12  Dan Bernstein  <mitz@apple.com>
2216
2217         Tried to fix USE(APPLE_INTERNAL_SDK) builds after r212211.
2218
2219         * platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h:
2220
2221 2017-02-12  Ryosuke Niwa  <rniwa@webkit.org>
2222
2223         parserRemoveChild should unload subframes
2224         https://bugs.webkit.org/show_bug.cgi?id=168151
2225
2226         Reviewed by Darin Adler.
2227
2228         Fix the bug that the adoption agency algorithm does not unload subframes as it disconnects nodes.
2229
2230         Also moved calls to nodeWillBeRemoved inside NoEventDispatchAssertion to expand on r211965.
2231
2232         Tests: fast/parser/adoption-agency-clear-focus-range.html
2233                fast/parser/adoption-agency-unload-iframe-1.html
2234                fast/parser/adoption-agency-unload-iframe-2.html
2235
2236         * dom/ContainerNode.cpp:
2237         (WebCore::ContainerNode::takeAllChildrenFrom): Rewritten using idioms used in removeChildren and parserAppendChild.
2238
2239         Disconnect all subframes first since this can synchronously dispatch an unload event. Then update DOM ranges,
2240         the focused element, and other states in the document.
2241
2242         Second, use the regular removeBetween, notifyChildNodeRemoved, childrenChanged sequence of calls to disconnect nodes
2243         instead of a single call to removeDetachedChildren to properly disconnect child nodes since those nodes may have
2244         already come live due to execution of synchronous scripts prior to the adoption agency algorithm has run, or in
2245         response to the unload event we just dispatched.
2246
2247         Third, append these nodes using parserAppendChild to avoid dispatching mutation events.
2248
2249         (WebCore::willRemoveChild): Removed the call to nodeWillBeRemoved. It's now called within NoEventDispatchAssertion
2250         in each call site of willRemoveChild and willRemoveChildren.
2251         (WebCore::willRemoveChildren): Ditto.
2252         (WebCore::ContainerNode::removeChild): Call nodeWillBeRemoved inside NoEventDispatchAssertion.
2253         (WebCore::ContainerNode::replaceAllChildren): Call nodeWillBeRemoved inside NoEventDispatchAssertion.
2254         (WebCore::ContainerNode::parserRemoveChild): Disconnect subframes and update document's states.
2255
2256         * html/parser/HTMLConstructionSite.cpp:
2257         (WebCore::executeTakeAllChildrenAndReparentTask): Add a release assert that new parent does not already have a parent. 
2258
2259 2017-02-12  Ryosuke Niwa  <rniwa@webkit.org>
2260
2261         REGRESSION (r179497): Crash inside setAttributeNode
2262         https://bugs.webkit.org/show_bug.cgi?id=168161
2263         <rdar://problem/30451581>
2264
2265         Reviewed by Andreas Kling.
2266
2267         The bug was caused by setAttributeNode calling setAttributeInternal with the same element data as the one used
2268         to call removeAttributeInternal despite of the fact removeAttributeInternal could have invoked arbitrary scripts
2269         and mutated element's m_elementData.
2270
2271         Fixed the bug by calling with setAttributeInternal with the result of new invocation of ensureUniqueElementData().
2272
2273         Test: fast/dom/Attr/make-unique-element-data-while-replacing-attr.html
2274
2275         * dom/Element.cpp:
2276         (WebCore::Element::setAttributeNode):
2277
2278 2017-02-12  Ryosuke Niwa  <rniwa@webkit.org>
2279
2280         Rebaseline bindings tests after r212207.
2281
2282         * bindings/scripts/test/JS/JSTestObj.cpp:
2283         * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
2284
2285 2017-02-12  Dan Bernstein  <mitz@apple.com>
2286
2287         [Cocoa] Some -respondsToSelector: checks are unnecessary
2288         https://bugs.webkit.org/show_bug.cgi?id=168183
2289
2290         Reviewed by Tim Horton.
2291
2292         * English.lproj/Localizable.strings: Removed a string that’s no longer needed after the
2293           change to WebKit2/Platform/mac/MenuUtilities.mm.
2294
2295         * editing/mac/DictionaryLookup.mm:
2296         (WebCore::showPopupOrCreateAnimationController): Removed check whether
2297           LULookupDefinitionModule responds to +showDefinitionForTerm:relativeToRect:ofView:options:.
2298
2299         * platform/cocoa/NetworkExtensionContentFilter.mm:
2300         (WebCore::NetworkExtensionContentFilter::initialize): Changed to use
2301           -[NEFilterSource setSourceAppIdentifier:], without checking, instead of
2302           -setSourceAppBundleID:, which does not exist.
2303
2304         * platform/cocoa/ScrollController.mm:
2305         (systemUptime): Deleted.
2306         (WebCore::ScrollController::snapRubberBand): Use -[NSProcessInfo systemUptime] directly.
2307
2308         * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
2309         (WebCore::MediaPlaybackTargetPickerMac::showPlaybackTargetPicker): Remove unnecessary check.
2310
2311         * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
2312         (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer): Ditto.
2313         (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenMode): Ditto.
2314         (WebCore::MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck): Replaced
2315           -respondsToSelector: check with -isKindOfClass: check corresponding to the above cast.
2316         (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep): Removed unnecessary
2317           check.
2318
2319         * platform/graphics/avfoundation/objc/VideoFullscreenLayerManager.mm:
2320         (WebCore::VideoFullscreenLayerManager::setVideoFullscreenLayer): Removed unnecessary checks.
2321
2322         * platform/graphics/mac/WebGLLayer.mm:
2323         (-[WebGLLayer initWithGraphicsContext3D:]): Ditto.
2324
2325         * platform/mac/PlatformEventFactoryMac.mm:
2326         (WebCore::typeForEvent): Removed check whether NSMenu responds to +menuTypeForEvent: and
2327           all code to handle that case that it doesn’t.
2328
2329         * platform/mac/WebVideoFullscreenController.mm:
2330         (-[WebVideoFullscreenController applicationDidResignActive:]): Removed check whether
2331           NSWindow responds to -isOnActiveSpace.
2332         (-[WebVideoFullscreenController updateMenuAndDockForFullscreen]): Removed check whether
2333           NSApplication responds to -setPresentationOptions:
2334
2335         * platform/mac/WebVideoFullscreenInterfaceMac.mm:
2336         (-[WebVideoFullscreenInterfaceMacObjC updateIsPlaying:newPlaybackRate:]): Removed
2337           unnecessary -respondsToSelector: check.
2338         (-[WebVideoFullscreenInterfaceMacObjC setVideoDimensions:]): Ditto.
2339         (-[WebVideoFullscreenInterfaceMacObjC setUpPIPForVideoView:withFrame:inWindow:]): Ditto.
2340
2341         * platform/spi/cf/CFNetworkSPI.h: Moved declarations of
2342           -[NSURLCache _initWithMemoryCapacity:diskCapacity:relativePath:] and
2343           -[NSURLCache _CFURLCache] to the !USE(APPLE_INTERNAL_SDK) section.
2344
2345         * platform/spi/cocoa/NEFilterSourceSPI.h: Added declaration of NEFilterSource’
2346           sourceAppIdentifier property to the !USE(APPLE_INTERNAL_SDK) section and deleted
2347           unconditional declaration of sourceAppBundleID property, which doesn’t exist.
2348
2349         * platform/spi/cocoa/QuartzCoreSPI.h: Removed redundant declarations.
2350
2351         * platform/spi/ios/DataDetectorsUISPI.h: Moved declarations of DDDetectionController methods
2352           from WebKit2/UIProcess/ios/{WKActionSheetAssistant,WKContentViewInteraction}.mm to here.
2353           Removed an unused declaration.
2354
2355         * platform/spi/mac/LookupSPI.h: Moved redundant declarations into the
2356           !USE(APPLE_INTERNAL_SDK) section.
2357
2358         * platform/spi/mac/NSMenuSPI.h: Changed to import NSMenu_Private.h when using the
2359           Apple internal SDK. Cleaned up the declarations for the other case.
2360
2361         * platform/spi/mac/TUCallSPI.h: Changed to import TUCall_Strings.h when use the Apple
2362           internal SDK.
2363
2364 2017-02-11  Sam Weinig  <sam@webkit.org>
2365
2366         Remove the remaining functions out of JSDOMBinding
2367         https://bugs.webkit.org/show_bug.cgi?id=168179
2368
2369         Reviewed by Darin Adler.
2370
2371         Move utility functions into more appropriate locations.
2372         - Move hasIteratorMethod to runtime/IteratorOperations.h
2373         - Move nonCachingStaticFunctionGetter to runtime/Lookup.h
2374         - Move addImpureProperty to CommonVM
2375
2376         Remove toJS overload that took a Vector<T>. Replace it's usage
2377         with toJS<IDLSequence<T>> usage. To make this work, added two
2378         new types, IDLIDBKeyData and IDLIDBValue.
2379
2380         * Modules/indexeddb/IDBCursor.cpp:
2381         (WebCore::IDBCursor::setGetResult):
2382         * Modules/indexeddb/IDBRequest.cpp:
2383         (WebCore::IDBRequest::setResult):
2384         (WebCore::IDBRequest::setResultToStructuredClone):
2385         Adopt JSDOMConvert infrastructure for conversions using new types.
2386
2387         * bindings/IDLTypes.h:
2388         * bindings/js/JSDOMConvertIndexedDB.h:
2389         (WebCore::JSConverter<IDLIDBKeyData>::convert):
2390         (WebCore::JSConverter<IDLIDBValue>::convert):
2391         Add new types for IDBKeyData and IDBValue.
2392
2393         * bindings/js/CommonVM.cpp:
2394         (WebCore::addImpureProperty):
2395         * bindings/js/CommonVM.h:
2396         Move addImpureProperty here from JSDOMBinding.
2397
2398         * bindings/js/IDBBindingUtilities.cpp:
2399         (WebCore::idbKeyDataToScriptValue): Deleted.
2400         * bindings/js/IDBBindingUtilities.h:
2401         Remove unused idbKeyDataToScriptValue, and group like functions
2402         together.
2403
2404         * bindings/js/JSDOMBinding.cpp: Removed.
2405         * bindings/js/JSDOMBinding.h:
2406         (WebCore::nonCachingStaticFunctionGetter): Deleted.
2407         (WebCore::toJS): Deleted.
2408         Move/remove functions.
2409
2410         * bindings/js/JSDOMConvertUnion.h:
2411         Update for move of hasIteratorMethod to runtime/IteratorOperations.h
2412
2413         * bindings/js/JSDOMWindowCustom.cpp:
2414         * bindings/js/JSHTMLDocumentCustom.cpp:
2415         * bindings/js/JSLocationCustom.cpp:
2416         Update for move of nonCachingStaticFunctionGetter to runtime/Lookup.h
2417
2418         * bindings/js/JSSubtleCryptoCustom.cpp:
2419         Remove unneeded include of runtime/IteratorOperations.h
2420
2421         * bindings/scripts/CodeGeneratorJS.pm:
2422         (GenerateOverloadedFunctionOrConstructor):
2423         Include runtime/IteratorOperations when needing to distinguish a sequence.
2424
2425         * html/HTMLDocument.cpp:
2426         Replace include of JSDOMBinding.h with CommonVM.h for addImpureProperty.
2427
2428 2017-02-12  Carlos Garcia Campos  <cgarcia@igalia.com>
2429
2430         [GTK] Handle caps lock indicator in event modifiers
2431         https://bugs.webkit.org/show_bug.cgi?id=168186
2432
2433         Reviewed by Michael Catanzaro.
2434
2435         Add helper function to check if caps lock is present in the given modifiers. We need this because in GDK
2436         GDK_LOCK_MASK might be either CapsLock or ShiftLock in X11. We use this new method in all platform event
2437         implementations to add the appropriate modifiers.
2438
2439         Fixes: fast/events/special-key-events-in-input-text.html
2440
2441         * platform/PlatformKeyboardEvent.h:
2442         * platform/gtk/PlatformKeyboardEventGtk.cpp:
2443         (WebCore::modifiersForGdkKeyEvent):
2444         (WebCore::PlatformKeyboardEvent::modifiersContainCapsLock):
2445         * platform/gtk/PlatformMouseEventGtk.cpp:
2446         (WebCore::PlatformMouseEvent::PlatformMouseEvent):
2447         * platform/gtk/PlatformWheelEventGtk.cpp:
2448         (WebCore::PlatformWheelEvent::PlatformWheelEvent):
2449
2450 2017-02-11  Sam Weinig  <sam@webkit.org>
2451
2452         Remove custom bindings for XSLTProcessor.idl
2453         https://bugs.webkit.org/show_bug.cgi?id=168174
2454
2455         Reviewed by Andreas Kling.
2456
2457         * CMakeLists.txt:
2458         * WebCore.xcodeproj/project.pbxproj:
2459         * bindings/js/JSBindingsAllInOne.cpp:
2460         * bindings/js/JSXSLTProcessorCustom.cpp: Removed.
2461         Remove file.
2462  
2463         * bindings/js/JSDOMBinding.cpp:
2464         (WebCore::jsStringOrUndefined): Deleted.
2465         * bindings/js/JSDOMBinding.h:
2466         Remove now unused jsStringOrUndefined.
2467
2468         * xml/XSLTProcessor.cpp:
2469         (WebCore::XSLTProcessor::setParameter):
2470         (WebCore::XSLTProcessor::getParameter):
2471         (WebCore::XSLTProcessor::removeParameter):
2472         * xml/XSLTProcessor.idl:
2473         Replace custom bindings bindings with early returns. One subtle difference
2474         between the custom bindings and this, is that getParameter will return 
2475         jsNull() rather than jsUndefined() for null String returns. This matches
2476         all other bindings.
2477
2478 2017-02-11  Olivier Blin  <olivier.blin@softathome.com>
2479
2480         [GStreamer][MSE][EME] Fix decryptor assignment
2481         https://bugs.webkit.org/show_bug.cgi?id=168122
2482
2483         Reviewed by Michael Catanzaro.
2484
2485         The new decryptor is a floating reference so we should not use the
2486         adopt GRefPtr constructor, but use the regular assignment operator
2487         that will sink the object (clear the floating flag).
2488
2489         This fixes assertions in debug build.
2490
2491         See previous pipeline fix in r210851 and WPE commit
2492         06020b18831e1c0eead34e2c1a5a4b7d026c227d.
2493
2494         * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
2495         (WebCore::AppendPipeline::parseDemuxerSrcPadCaps):
2496         Do not use adoptGRef(), it prevented the object from being sunk.
2497
2498 2017-02-11  Simon Fraser  <simon.fraser@apple.com>
2499
2500         Avoid a redundant scroll to 0,0 when navigating back to a url with no fragment
2501         https://bugs.webkit.org/show_bug.cgi?id=168177
2502
2503         Reviewed by Sam Weinig.
2504
2505         FrameView::scrollToFragment() is called from FrameLoader::scrollToFragmentWithParentBoundary()
2506         when navigating within the page. If the URL had no fragment identifier, this code would
2507         call into FrameView::scrollToAnchor() with an empty name, where maintainScrollPositionAtAnchor()
2508         used the document as the anchor, thus scrolling to 0,0. Later, history().restoreScrollPositionAndViewState()
2509         the restores the scroll position from history.
2510         
2511         This scroll to 0,0 happened to be not visible to the page because of scroll event
2512         coalescing, but it makes implementation of history.scrollRestoration harder, so avoid it
2513         by just returning early from FrameView::scrollToFragment() if there is no fragment,
2514         making sure to clear the document's CSSTarget.
2515
2516         * dom/Document.cpp:
2517         (WebCore::Document::setCSSTarget):
2518         * page/FrameView.cpp:
2519         (WebCore::FrameView::scrollToFragment):
2520         (WebCore::FrameView::scrollToAnchor):
2521
2522 2017-02-11  Chris Dumez  <cdumez@apple.com>
2523
2524         Implement URL's toJSON()
2525         https://bugs.webkit.org/show_bug.cgi?id=167979
2526
2527         Reviewed by Sam Weinig.
2528
2529         Implement URL's toJSON() as per:
2530         - https://url.spec.whatwg.org/#dom-url-tojson
2531
2532         This is already supported by Firefox.
2533
2534         Also, drop URLUtils.idl as it is no longer in the specification.
2535         Merge its content to DOMURL.idl as per the URL specification.
2536
2537         Finally, mark href attribute as stringifier and drop the toString()
2538         operation to match the specification. This fixes a bug where our
2539         toString property was not enumerable but should have been.
2540
2541         Tests: fast/url/url-tojson.html
2542                imported/w3c/web-platform-tests/url/url-tojson.html
2543
2544         * CMakeLists.txt:
2545         * DerivedSources.make:
2546         * WebCore.xcodeproj/project.pbxproj:
2547         * html/DOMURL.idl:
2548         * html/URLUtils.h:
2549         (WebCore::URLUtils<T>::toJSON):
2550         * html/URLUtils.idl: Removed.
2551
2552 2017-02-11  Carlos Garcia Campos  <cgarcia@igalia.com>
2553
2554         [GTK][EFL] Implement MIMETypeRegistry::getPreferredExtensionForMIMEType
2555         https://bugs.webkit.org/show_bug.cgi?id=168163
2556
2557         Reviewed by Michael Catanzaro.
2558
2559         It's missing causing several HTML anchor download tests to fail because the suggested filename missed the
2560         extension. This patch moves MIMETypeRegistry::appendFileExtensionIfNecessary() from the cocoa specific file to the
2561         common file because it's not actually platform specific. MIMETypeRegistry::getPreferredExtensionForMIMEType() is
2562         what platforms should implement.
2563
2564         Fixes: fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html
2565                fast/dom/HTMLAnchorElement/anchor-download.html
2566                fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html
2567                fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
2568
2569         * platform/MIMETypeRegistry.cpp:
2570         (WebCore::MIMETypeRegistry::appendFileExtensionIfNecessary):
2571         * platform/cocoa/MIMETypeRegistryCocoa.mm:
2572         (WebCore::MIMETypeRegistry::appendFileExtensionIfNecessary): Deleted.
2573         * platform/efl/MIMETypeRegistryEfl.cpp:
2574         (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType):
2575         * platform/gtk/MIMETypeRegistryGtk.cpp:
2576         (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType):
2577
2578 2017-02-11  Carlos Garcia Campos  <cgarcia@igalia.com>
2579
2580         Unreviewed. Update imageTitle translatable string.
2581
2582         To match mac port. Fixes fast/images/imageDocument-title.html.
2583
2584         * platform/gtk/LocalizedStringsGtk.cpp:
2585         (WebCore::imageTitle):
2586
2587 2017-02-10  John Wilander  <wilander@apple.com>
2588
2589         Updates to Resource Load Statistics: Get the right website data store and introduce timeout for user interaction
2590         https://bugs.webkit.org/show_bug.cgi?id=167474
2591         <rdar://problem/24681808>
2592         <rdar://problem/24703286>
2593         <rdar://problem/30290270>
2594
2595         This patch does the following:
2596         1. Gets the right website data store. API::WebsiteDataStore::defaultDataStore()
2597             does not provide the right data store.
2598         2. Introduces timeout for user interaction. A domain needs interaction every 30
2599             days to stay in that category.
2600         3. Adds grandfathered to the statistics model in preparation for grandfathering of
2601             existing data records.
2602         4. Adds test infrastructure to allow testing of the various rules in place for
2603             data records removal.
2604         5. Fixes various smaller bugs that were found as part of setting up the tests.
2605         6. Regresses the data records removal counting. We need to come up with a thread
2606             safe way of gathering removal statistics from more than one data store now
2607             that we potentially interact with multiple stores.
2608         7. Adds a first set of layout tests for resource load statistics.
2609
2610         Reviewed by Andy Estes.
2611
2612         Tests: http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html
2613                http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html
2614                http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
2615                http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html
2616                http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html
2617
2618         * dom/Document.cpp:
2619         (WebCore::Document::updateLastHandledUserGestureTimestamp):
2620             This now calls ResourceLoadObserver::logUserInteraction() every time since
2621             we want to keep track of the most recent user interaction.
2622         * loader/ResourceLoadObserver.cpp:
2623         (WebCore::ResourceLoadObserver::statisticsStore):
2624             New getter used by WebResourceLoadStatisticsManager::resetToConsistentState().
2625         (WebCore::reduceTimeResolutionToOneDay):
2626             Convenience function.
2627         (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
2628             Reduces time resolution for privacy reasons.
2629         (WebCore::ResourceLoadObserver::logUserInteraction):
2630         (WebCore::ResourceLoadObserver::clearUserInteraction):
2631         (WebCore::ResourceLoadObserver::hasHadUserInteraction):
2632         (WebCore::ResourceLoadObserver::setPrevalentResource):
2633         (WebCore::ResourceLoadObserver::isPrevalentResource):
2634         (WebCore::ResourceLoadObserver::clearPrevalentResource):
2635         (WebCore::ResourceLoadObserver::setTimeToLiveUserInteraction):
2636         (WebCore::ResourceLoadObserver::fireDataModificationHandler):
2637             New functions that allow WebKitTestRunner to stage exact
2638             statistics, fire the handler, and test the outcome.
2639         * loader/ResourceLoadObserver.h:
2640         * loader/ResourceLoadStatistics.cpp:
2641         (WebCore::ResourceLoadStatistics::encode):
2642         (WebCore::ResourceLoadStatistics::decode):
2643         (WebCore::ResourceLoadStatistics::toString):
2644         (WebCore::ResourceLoadStatistics::merge):
2645             Support for statistics mostRecentUserInteraction, grandfathered, and
2646             dataRecordsRemoved.
2647         * loader/ResourceLoadStatistics.h:
2648         * loader/ResourceLoadStatisticsStore.cpp:
2649         (WebCore::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
2650             New function that allows WebKitTestRunner to test 
2651             aging out of user interaction.
2652         (WebCore::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
2653             Now takes into account the timestamp and ages
2654             out user interaction.
2655         (WebCore::ResourceLoadStatisticsStore::prevalentResourceDomainsWithoutUserInteraction):
2656             Now makes use of ResourceLoadStatisticsStore::hasHadRecentUserInteraction().
2657         * loader/ResourceLoadStatisticsStore.h:
2658
2659 2017-02-10  Sam Weinig  <sam@webkit.org>
2660
2661         [WebIDL] Cleanup XMLHttpRequest's bindings
2662         https://bugs.webkit.org/show_bug.cgi?id=168067
2663
2664         Reviewed by Chris Dumez.
2665
2666         * bindings/js/JSDOMBinding.cpp:
2667         (WebCore::jsOwnedStringOrNull): Deleted.
2668         * bindings/js/JSDOMBinding.h:
2669         Remove jsOwnedStringOrNull and inline it into it's one use
2670         in JSXMLHttpRequestCustom.
2671
2672         * bindings/js/JSXMLHttpRequestCustom.cpp:
2673         (WebCore::JSXMLHttpRequest::responseText):
2674         (WebCore::SendFunctor::SendFunctor): Deleted.
2675         (WebCore::SendFunctor::line): Deleted.
2676         (WebCore::SendFunctor::column): Deleted.
2677         (WebCore::SendFunctor::url): Deleted.
2678         (WebCore::SendFunctor::operator()): Deleted.
2679         (WebCore::JSXMLHttpRequest::send): Deleted.
2680         * xml/XMLHttpRequest.cpp:
2681         (WebCore::XMLHttpRequest::send):
2682         * xml/XMLHttpRequest.h:
2683         Remove custom send, replacing it with a single send implementation that
2684         takes a variant.
2685
2686         * xml/XMLHttpRequest.idl:
2687         Cleanup the IDL to better match the spec. Update correct types where trivial.
2688
2689 2017-02-10  Chris Dumez  <cdumez@apple.com>
2690
2691         document.origin doesn't match spec
2692         https://bugs.webkit.org/show_bug.cgi?id=168022
2693
2694         Reviewed by Sam Weinig.
2695
2696         Update document.origin to return the origin in the expected format:
2697         - https://dom.spec.whatwg.org/#dom-document-origin
2698
2699         Change: "https_webkit.org_0 -> "https://webkit.org".
2700
2701         The new behavior matches Firefox and Chrome.
2702
2703         No new tests, updated existing tests.
2704
2705         * dom/Document.cpp:
2706         (WebCore::Document::origin):
2707
2708 2017-02-10  Daniel Bates  <dabates@apple.com>
2709
2710         Attempt to fix the build following <https://trac.webkit.org/changeset/212173>
2711         (https://bugs.webkit.org/show_bug.cgi?id=166774)
2712
2713         * dom/Document.cpp:
2714         (WebCore::Document::detachFromCachedFrame): Use ASSER_UNUSED() instead of ASSERT() since
2715         the parameter cachedFrame is unused in non-debug build.
2716
2717 2017-02-10  Daniel Bates  <dabates@apple.com>
2718
2719         Detach frame from document when entering page cache
2720         https://bugs.webkit.org/show_bug.cgi?id=166774
2721         <rdar://problem/29904368>
2722
2723         Reviewed by Chris Dumez.
2724
2725         When a page enters the page cache it is unnecessary for it to hold a reference to its
2726         associated frame because subsequent interactions with the page do not need to make use
2727         of it. Once a page exits the page cache we associate it with its frame.
2728
2729         * dom/Document.cpp:
2730         (WebCore::Document::frameDestroyed): Update comment to reflect the renaming of disconnectFromFrame().
2731         (WebCore::Document::attachToCachedFrame): Added.
2732         (WebCore::Document::detachFromCachedFrame): Added.
2733         (WebCore::Document::prepareForDestruction): Only call CSSAnimationController::detachFromDocument() if
2734         we have a frame. Substitute detachFromFrame() for disconnectFromFrame() as the latter was renamed to
2735         the former.
2736         (WebCore::Document::hasEverCalledWindowOpen): Deleted.
2737         (WebCore::Document::markHasCalledWindowOpen): Deleted.
2738         (WebCore::Document::disconnectFromFrame): Renamed to detachFromFrame.
2739         * dom/Document.h:
2740         (WebCore::Document::detachFromFrame): Renamed; formerly named disconnectFromFrame(). Changed
2741         visibility from public to private and made this function inline.
2742         * history/CachedFrame.cpp:
2743         (WebCore::CachedFrameBase::pruneDetachedChildFrames): Remove cached child frames that were
2744         removed from the page when it was in the page cache as there is no need to restore such frames.
2745         (WebCore::CachedFrameBase::restore): Call pruneDetachedChildFrames() before restoring the
2746         frame tree.
2747         (WebCore::CachedFrame::CachedFrame): Detach from the frame.
2748         (WebCore::CachedFrame::open): Assert that we have a document and re-attach the frame.
2749         (WebCore::CachedFrame::destroy): Update assertion as this function should only be called for a
2750         frameless document. Only detach the FrameView, DocumentLoader, and Page when the cached frame is for
2751         subframe and is associated with a Page object. Call CSSAnimationController::detachFromDocument() to
2752         detach the animation controller from the document as it is being destroyed. We have to do this here
2753         because the document does not have a frame. And Document::prepareForDestruction() only calls
2754         CSSAnimationController::detachFromDocument() if the document has a frame.
2755         * history/CachedFrame.h:
2756         * history/PageCache.cpp:
2757         (WebCore::canCachePage): Remove logic that prevents caching of a page that called window.open()
2758         or has an opener as it is feasible to keep such pages in the page cache.
2759         * html/HTMLFrameElementBase.cpp:
2760         (WebCore::HTMLFrameElementBase::finishedInsertingSubtree): Fix style nit.
2761         * loader/FrameLoader.cpp:
2762         (WebCore::FrameLoader::frameDetached): Only stop all loaders and stop active DOM objects if the
2763         page is not in- or about to enter- the page cache. A page in the page cache has finished loading
2764         and its active DOM objects are suspended. Also fix style nit in comment.
2765         (WebCore::FrameLoader::detachFromParent): Only stop all loaders if the page is not in- or about to
2766         enter- the page cache. A page in the page cache has finished loading. Also added a comment to explain
2767         that we protect the frame because stopAllLoaders() can cause the frame to be deallocated.
2768         * page/DOMWindow.cpp:
2769         (WebCore::DOMWindow::createWindow): Remove logic to call markHasCalledWindowOpen() as this
2770         function will be removed.
2771         * page/DiagnosticLoggingKeys.cpp:
2772         (WebCore::DiagnosticLoggingKeys::hasCalledWindowOpenKey): Deleted.
2773         (WebCore::DiagnosticLoggingKeys::hasOpenerKey): Deleted.
2774         * page/DiagnosticLoggingKeys.h:
2775         * page/Page.cpp:
2776         (WebCore::Page::openedByWindowOpen): Deleted.
2777         * page/Page.h:
2778         * page/Settings.in: Remove setting allowsPageCacheWithWindowOpener.
2779
2780 2017-02-10  Simon Fraser  <simon.fraser@apple.com>
2781
2782         REGRESSION (r211845): [ios-simulator] LayoutTest compositing/masks/solid-color-masked.html is a flaky failure
2783         https://bugs.webkit.org/show_bug.cgi?id=168054
2784
2785         Reviewed by Tim Horton.
2786
2787         When adding mask layers, there was an ordering dependency. There was a hack in GraphicsLayerCA::setVisibleAndCoverageRects()
2788         to propagate m_intersectsCoverageRect to masks. However, if GraphicsLayerCA::setVisibleAndCoverageRects()
2789         ran on the masked layer before the mask was added, nothing updated the "m_intersectsCoverageRect" state of the mask layer.
2790
2791         Fix by explicitly calling setVisibleAndCoverageRects() on the mask layer, passing the same rects and
2792         viewport-constrained state as for its host layer (we already assume that their geometry matches).
2793
2794         Tested by compositing/masks/solid-color-masked.html
2795
2796         * platform/graphics/ca/GraphicsLayerCA.cpp:
2797         (WebCore::GraphicsLayerCA::setVisibleAndCoverageRects):
2798         (WebCore::GraphicsLayerCA::recursiveCommitChanges):
2799
2800 2017-02-10  Commit Queue  <commit-queue@webkit.org>
2801
2802         Unreviewed, rolling out r212154, r212154, and r212156.
2803         https://bugs.webkit.org/show_bug.cgi?id=168156
2804
2805         broke internal builds (Requested by smfr on #webkit).
2806
2807         Reverted changesets:
2808
2809         "Add a DragImage class that wraps a DragImageRef"
2810         https://bugs.webkit.org/show_bug.cgi?id=168131
2811         http://trac.webkit.org/changeset/212154
2812
2813         "Add a DragImage class that wraps a DragImageRef"
2814         https://bugs.webkit.org/show_bug.cgi?id=168131
2815         http://trac.webkit.org/changeset/212154
2816
2817         "Try to fix the iOS and Windows builds."
2818         http://trac.webkit.org/changeset/212156
2819
2820 2017-02-10  Csaba Osztrogonác  <ossy@webkit.org>
2821
2822         Fix the !ENABLE(WEBGL) build
2823         https://bugs.webkit.org/show_bug.cgi?id=168112
2824
2825         Reviewed by Alex Christensen.
2826
2827         * html/canvas/WebGLRenderingContextBase.h:
2828
2829 2017-02-10  Youenn Fablet  <youenn@apple.com>
2830
2831         [Fetch API] fetch fails when undefined is passed as headers
2832         https://bugs.webkit.org/show_bug.cgi?id=168043
2833
2834         Reviewed by Geoffrey Garen.
2835
2836         Covered by updated test.
2837
2838         * Modules/fetch/FetchInternals.js:
2839         (fillFetchHeaders): Exit early in case of undefined headers, since it is an optional parameter.
2840
2841 2017-02-10  Csaba Osztrogonác  <ossy@webkit.org>
2842
2843         Fix the !ENABLE(WEB_TIMING) build
2844         https://bugs.webkit.org/show_bug.cgi?id=168113
2845
2846         Reviewed by Alex Christensen.
2847
2848         * workers/WorkerGlobalScope.cpp:
2849         (WebCore::WorkerGlobalScope::WorkerGlobalScope):
2850
2851 2017-02-10  Joseph Pecoraro  <pecoraro@apple.com>
2852
2853         Update features.json for Performance Timing APIs
2854         https://bugs.webkit.org/show_bug.cgi?id=168148
2855
2856         Reviewed by Simon Fraser.
2857
2858         * features.json:
2859
2860 2017-02-10  Anders Carlsson  <andersca@apple.com>
2861
2862         Try to fix the iOS and Windows builds.
2863
2864         * platform/ios/DragImageIOS.mm:
2865         (WebCore::deleteDragImage):
2866         * platform/win/PasteboardWin.cpp:
2867         (WebCore::Pasteboard::setDragImage):
2868
2869 2017-02-10  Anders Carlsson  <andersca@apple.com>
2870
2871         Add a DragImage class that wraps a DragImageRef
2872         https://bugs.webkit.org/show_bug.cgi?id=168131
2873
2874         Reviewed by Beth Dakin.
2875
2876         This allows us to get rid of the explicit deleteDragImage calls and will make additional cleanup of the
2877         various drag code paths possible. No functionality change.
2878
2879         * dom/DataTransfer.cpp:
2880         (WebCore::DataTransfer::updateDragImage):
2881         * page/DragController.cpp:
2882         (WebCore::DragController::startDrag):
2883         (WebCore::DragController::doImageDrag):
2884         (WebCore::DragController::doSystemDrag):
2885         * page/DragController.h:
2886         * platform/DragImage.cpp:
2887         (WebCore::DragImage::DragImage):
2888         (WebCore::DragImage::operator=):
2889         (WebCore::DragImage::~DragImage):
2890         * platform/DragImage.h:
2891         * platform/Pasteboard.h:
2892         * platform/StaticPasteboard.h:
2893         * platform/mac/PasteboardMac.mm:
2894         (WebCore::Pasteboard::setDragImage):
2895
2896 2017-02-10  Simon Fraser  <simon.fraser@apple.com>
2897
2898         Make sure the "inwindow" flag propagates to TiledBackings for masks and reflections
2899         https://bugs.webkit.org/show_bug.cgi?id=168127
2900         rdar://problem/30467120
2901
2902         Reviewed by Tim Horton.
2903         
2904         Replace the special-case, but wrong, GraphicsLayer traversal in setIsInWindowIncludingDescendants()
2905         which forgot to hit masks and replica layers with a generic traverse() function, which
2906         is then used for setting 'inWindow' as well as resetting tracked repaints.
2907
2908         Tests: compositing/tiling/tiled-mask-inwindow.html
2909                compositing/tiling/tiled-reflection-inwindow.html
2910
2911         * page/PageOverlayController.cpp:
2912         (WebCore::PageOverlayController::layerWithDocumentOverlays):
2913         (WebCore::PageOverlayController::layerWithViewOverlays):
2914         * platform/graphics/GraphicsLayer.cpp:
2915         (WebCore::GraphicsLayer::setIsInWindow):
2916         (WebCore::GraphicsLayer::setReplicatedByLayer):
2917         (WebCore::GraphicsLayer::traverse):
2918         (WebCore::GraphicsLayer::setIsInWindowIncludingDescendants): Deleted.
2919         * platform/graphics/GraphicsLayer.h:
2920         * rendering/RenderLayerCompositor.cpp:
2921         (WebCore::RenderLayerCompositor::setIsInWindow):
2922         (WebCore::RenderLayerCompositor::resetTrackedRepaintRects):
2923         (WebCore::resetTrackedRepaintRectsRecursive): Deleted.
2924
2925 2017-02-09  Simon Fraser  <simon.fraser@apple.com>
2926
2927         Tiled layers are sometimes left with some tiles when outside the viewport
2928         https://bugs.webkit.org/show_bug.cgi?id=168104
2929         rdar://problem/30459055
2930
2931         Reviewed by Tim Horton.
2932
2933         When the coverage rect of a TiledBacking goes from a non-empty rect to an empty rect, we
2934         shouldn't just early return from TileGrid::revalidateTiles(), otherwise we are left with some
2935         tiles. Run through the function as normal, which will remove all the tiles for an empty coverage rect.
2936         
2937         Minor logging changes.
2938
2939         Test: tiled-drawing/tile-coverage-iframe-to-zero-coverage.html
2940
2941         * platform/graphics/ca/TileGrid.cpp:
2942         (WebCore::TileGrid::revalidateTiles):
2943
2944 2017-02-10  Zalan Bujtas  <zalan@apple.com>
2945
2946         Mail hangs when removing multiple rows from large table.
2947         https://bugs.webkit.org/show_bug.cgi?id=168103
2948         <rdar://problem/30090186>
2949
2950         Reviewed by Ryosuke Niwa.
2951
2952         DeleteSelectionCommand::removeNode doesn't actually destroy table structure items,
2953         but instead it removes their content. In order to be able to continue editing the table after
2954         the delete, we need to ensure that its cells' width and height are > 0. Currently we issue layout on
2955         each table item recursively.
2956         This patch delays the layout until after we've finished with the entire subtree delete (10x progression).
2957
2958         Performance test added.
2959
2960         * editing/DeleteSelectionCommand.cpp:
2961         (WebCore::DeleteSelectionCommand::insertBlockPlaceholderForTableCellIfNeeded):
2962         (WebCore::DeleteSelectionCommand::removeNodeUpdatingStates):
2963         (WebCore::shouldRemoveContentOnly):
2964         (WebCore::DeleteSelectionCommand::removeNode):
2965         * editing/DeleteSelectionCommand.h:
2966
2967 2017-02-10  Joseph Pecoraro  <pecoraro@apple.com>
2968
2969         [Resource Timing] Enable Resource Timing by default in Tests
2970         https://bugs.webkit.org/show_bug.cgi?id=168145
2971
2972         Reviewed by Ryosuke Niwa.
2973
2974         * loader/ResourceTimingInformation.cpp:
2975         (WebCore::ResourceTimingInformation::addResourceTiming):
2976         * testing/InternalSettings.cpp:
2977         (WebCore::InternalSettings::Backup::Backup):
2978         (WebCore::InternalSettings::Backup::restoreTo):
2979         (WebCore::InternalSettings::setResourceTimingEnabled): Deleted.
2980         * testing/InternalSettings.h:
2981         * testing/InternalSettings.idl:
2982         No longer needed for tests.
2983
2984 2017-02-10  Dan Bernstein  <mitz@apple.com>
2985
2986         [Cocoa] Add shouldChangeSelectedRange to WKWebProcessPlugInEditingDelegate
2987         https://bugs.webkit.org/show_bug.cgi?id=168097
2988
2989         Reviewed by Tim Horton.
2990
2991         Added a userTriggered argument to FrameSelection::setSelectedRange so that WebKit2 can
2992         indicate that changes should be agreed to by the delegate.
2993
2994         * editing/FrameSelection.cpp:
2995         (WebCore::FrameSelection::setSelectedRange): If the change is user-triggered, check with
2996           shouldChangeSelection.
2997         * editing/FrameSelection.h:
2998
2999 2017-02-10  Jonathan Bedard  <jbedard@apple.com>
3000
3001         Removing LayoutTestRelay
3002         https://bugs.webkit.org/show_bug.cgi?id=165927
3003
3004         Reviewed by Daniel Bates.
3005         Part 2
3006
3007         LayoutTestRelay uses SPI, since recent versions of the iOS SDK allow for installing apps on
3008         simulators through simctl (iOS 10 and later), use this functionality instead.
3009
3010         * platform/RuntimeApplicationChecks.mm:
3011         (WebCore::IOSApplication::isDumpRenderTree): Update comment to reflect removal of LayoutTestRelay.
3012
3013 2017-02-10  Youenn Fablet  <youenn@apple.com>
3014
3015         [WebRTC] Implement Outgoing libwebrtc audio source support
3016         https://bugs.webkit.org/show_bug.cgi?id=168118
3017
3018         Reviewed by Eric Carlson.
3019
3020         No new automated tests as we need the audio rendering to work to test the whole loop.
3021
3022         Using an AudioSampleDataSource to convert the captured data to libwebrtc expected format.
3023         Capturing and pushing data happens in the capture thread.
3024         Pulling of converted data happens in libwebrtc thread.
3025
3026         Introducing LibWebRTCAudioFormat.h to centralize libwbebrtc expected audio format.
3027
3028         * WebCore.xcodeproj/project.pbxproj:
3029         * platform/audio/WebAudioBufferList.cpp:
3030         (WebCore::WebAudioBufferList::WebAudioBufferList): Missing initialization leads to assertion failure.
3031         * platform/audio/mac/AudioSampleBufferList.cpp:
3032         (WebCore::AudioSampleBufferList::copyFrom): In case of interleaved channels, there is one buffer but two channels.
3033         * platform/audio/mac/AudioSampleDataSource.cpp:
3034         (WebCore::AudioSampleDataSource::pushSamples):
3035         (WebCore::AudioSampleDataSource::pullAvalaibleSamplesAsChunks):
3036         * platform/audio/mac/AudioSampleDataSource.h:
3037         * platform/mediastream/libwebrtc/LibWebRTCAudioFormat.h: Added.
3038         * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
3039         (WebCore::libwebrtcAudioFormat):
3040         (WebCore::RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource):
3041         (WebCore::RealtimeOutgoingAudioSource::sourceMutedChanged):
3042         (WebCore::RealtimeOutgoingAudioSource::audioSamplesAvailable):
3043         (WebCore::RealtimeOutgoingAudioSource::pullAudioData):
3044         * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
3045
3046 2017-02-10  Ryosuke Niwa  <rniwa@webkit.org>
3047
3048         HTMLConstructionSiteTask::Insert should never be called on a node with a parent
3049         https://bugs.webkit.org/show_bug.cgi?id=168099
3050
3051         Reviewed by Sam Weinig.
3052
3053         insertAlreadyParsedChild always use HTMLConstructionSiteTask::InsertAlreadyParsedChild instead
3054         of using HTMLConstructionSiteTask::Insert when fostering a child.
3055
3056         Also combine the step to take all children and re-parenting into a single task instead of
3057         separately issuing TakeAllChildren and Reparent tasks.
3058
3059         No new tests since this is a refactoring.
3060
3061         * html/parser/HTMLConstructionSite.cpp:
3062         (WebCore::insert): Now asserts that the child node never have a parent.
3063         (WebCore::executeInsertAlreadyParsedChildTask): Moved the code to remove the parent here.
3064         (WebCore::executeTakeAllChildrenAndReparentTask): Renamed from executeTakeAllChildrenTask
3065         now that this function also does the reparenting.
3066         (WebCore::executeTask):
3067         (WebCore::HTMLConstructionSite::reparent): Removed the variant only used with takeAllChildren.
3068         (WebCore::HTMLConstructionSite::insertAlreadyParsedChild): Always use InsertAlreadyParsedChild
3069         instead of calling fosterParent which uses Insert when fostering parents.
3070         (WebCore::HTMLConstructionSite::takeAllChildrenAndReparent): Renamed from takeAllChildren.
3071         * html/parser/HTMLConstructionSite.h:
3072         (WebCore::HTMLConstructionSiteTask:Operation):
3073         * html/parser/HTMLTreeBuilder.cpp:
3074         (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
3075
3076 2017-02-10  Dave Hyatt  <hyatt@apple.com>
3077
3078         [CSS Parser] Make intercap property values serialize correctly
3079         https://bugs.webkit.org/show_bug.cgi?id=168073
3080
3081         Reviewed by Zalan Bujtas.
3082
3083         Fix CSS value keywords to preserve case when the value contains capital
3084         letters. Examples include optimizeSpeed, translateX, scaleY, etc.
3085
3086         * css/CSSPrimitiveValueMappings.h:
3087         (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
3088         (WebCore::CSSPrimitiveValue::operator EPointerEvents):
3089         (WebCore::CSSPrimitiveValue::operator TextRenderingMode):
3090         (WebCore::CSSPrimitiveValue::operator EImageRendering):
3091         (WebCore::CSSPrimitiveValue::operator EColorInterpolation):
3092         (WebCore::CSSPrimitiveValue::operator EColorRendering):
3093         (WebCore::CSSPrimitiveValue::operator EShapeRendering):
3094         * css/MediaQueryEvaluator.cpp:
3095         (WebCore::colorGamutEvaluate):
3096         * css/SVGCSSValueKeywords.in:
3097         * css/TransformFunctions.cpp:
3098         (WebCore::transformOperationType):
3099         (WebCore::transformsForValue):
3100         * css/makevalues.pl:
3101         * css/parser/CSSParserFastPaths.cpp:
3102         (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
3103         (WebCore::parseTransformTranslateArguments):
3104         (WebCore::parseSimpleTransformValue):
3105         * css/parser/CSSPropertyParser.cpp:
3106         (WebCore::consumeTransformValue):
3107         * css/parser/CSSPropertyParserHelpers.cpp:
3108         (WebCore::CSSPropertyParserHelpers::parseColorFunctionParameters):
3109
3110 2017-02-10  Zan Dobersek  <zdobersek@igalia.com>
3111
3112         [EME] Implement MediaKeySession::load()
3113         https://bugs.webkit.org/show_bug.cgi?id=168041
3114
3115         Reviewed by Xabier Rodriguez-Calvar.
3116
3117         Implement the MediaKeySession::load() method, tracing the steps as they
3118         are defined in the EME specification. The only exception is step 8.3,
3119         which requires additional facility that tracks currently open sessions
3120         and provides information whether for a given session ID there's already
3121         a MediaKeySession that's not yet been closed.
3122
3123         Session ID sanitization is done through the CDM::sanitizeSessionId()
3124         method, which relays the task to the CDMPrivate implementation.
3125
3126         The CDMInstance::loadSession() virtual method is called with the session
3127         type, sanitized ID, the Document's origin (in string form) and the
3128         callback that's invoked upon completion of the task. The callback
3129         checks whether the operation was successful, or examines the reason for
3130         the load failure in case it wasn't, rejecting the promise in the latter
3131         case either immediately or in the following task at the latest.
3132
3133         When the load was successful, the optional known keys, expiration time
3134         and message are handled appropriately, and the promise is resolved.
3135
3136         MockCDM::sanitizeSessionId() implementation only treats
3137         'valid-loaded-session' as a valid session ID.
3138         MockCDMInstance::loadSession() implementation is kept slim for now, only
3139         providing the 'license-renewal' message when invoking the passed-in
3140         callback. Known keys and expiration time will also be tested once the
3141         relevant MediaKeySession algorithms are implemented.
3142
3143         Test: media/encrypted-media/mock-MediaKeySession-load.html
3144
3145         * Modules/encryptedmedia/CDM.cpp:
3146         (WebCore::CDM::sanitizeSessionId):
3147         * Modules/encryptedmedia/CDM.h:
3148         * Modules/encryptedmedia/CDMInstance.h:
3149         * Modules/encryptedmedia/CDMPrivate.h:
3150         * Modules/encryptedmedia/MediaKeySession.cpp:
3151         (WebCore::MediaKeySession::load):
3152         * testing/MockCDMFactory.cpp:
3153         (WebCore::MockCDM::sanitizeSessionId):
3154         (WebCore::MockCDMInstance::loadSession):
3155         * testing/MockCDMFactory.h:
3156
3157 2017-02-10  Zan Dobersek  <zdobersek@igalia.com>
3158
3159         [EME] Implement MediaKeySession::sessionClosed()
3160         https://bugs.webkit.org/show_bug.cgi?id=168039
3161
3162         Reviewed by Xabier Rodriguez-Calvar.
3163
3164         Implement the 'session closed' algorithm for MediaKeySession by
3165         following the specified steps. After this algorithm is run, the
3166         session should be considered closed, which we track via the m_closed
3167         member variable on the class. This is set to true before the promise
3168         that's accessible through the 'closed' attribute is resolved.
3169
3170         Because the algorithm requires the CDM instance to store any record
3171         of key usage when the session's type is 'persistent-usage-record', the
3172         storeRecordOfKeyUsage() virtual method is added to the CDMInstance
3173         interface. MockCDMInstance implementation is left unimplemented for now.
3174
3175         JSMediaKeySession::closed() accessor now has a custom implementation
3176         that creates a deferred promise for that object if there's none yet, and
3177         shares it with the wrapped class through the registerClosedPromise()
3178         method, storing a reference to the promise in the m_closedPromise
3179         member variable, or resolving the promise immediately if the session was
3180         already closed.
3181
3182         Test cases added to media/encrypted-media/mock-MediaKeySession-close.html.
3183
3184         * Modules/encryptedmedia/CDMInstance.h:
3185         * Modules/encryptedmedia/MediaKeySession.cpp:
3186         (WebCore::MediaKeySession::registerClosedPromise):
3187         (WebCore::MediaKeySession::sessionClosed):
3188         * Modules/encryptedmedia/MediaKeySession.h:
3189         * bindings/js/JSMediaKeySessionCustom.cpp:
3190         (WebCore::JSMediaKeySession::closed):
3191         * testing/MockCDMFactory.cpp:
3192         (WebCore::MockCDMInstance::storeRecordOfKeyUsage):
3193         * testing/MockCDMFactory.h:
3194
3195 2017-02-10  Zan Dobersek  <zdobersek@igalia.com>
3196
3197         [EME] Implement MediaKeySession::updateKeyStatuses(), MediaKeyStatusMap
3198         https://bugs.webkit.org/show_bug.cgi?id=167888
3199
3200         Reviewed by Xabier Rodriguez-Calvar.
3201
3202         Implement MediaKeySession::updateKeyStatuses(), transforming the passed-in
3203         KeyStatusVector into a Vector mapping the key IDs to MediaKeyStatus values.
3204         A keystatuseschange event is fired on the MediaKeySession object afterwards.
3205         The queueing of the task that runs the 'attemp to resume playback' on the
3206         related HTMLMediaElement objects isn't done yet since that algorithm isn't
3207         implemented yet.
3208
3209         The statuses Vector is stored on the MediaKeySession object. That Vector is
3210         then exposed through the MediaKeyStatusMap object, each such object being
3211         unique to one MediaKeySession object. The implementation of MediaKeyStatusMap
3212         thus keeps a reference to the session object as long as that object is alive,
3213         and queries the MediaKeySession::statuses() getter to access the Vector that
3214         contains status information for all the key IDs.
3215
3216         MediaKeyStatusMap::Iterator object keeps a reference to the MediaKeyStatusMap
3217         object and accesses the statuses by indexing into the status Vector of the
3218         related MediaKeySession object.
3219
3220         CDMInstance::updateLicense() now accepts the session ID string as the first
3221         argument, making it possible to specify which session should be updated.
3222
3223         MockCDMFactory::keysForSessionWithID() returns an optional reference to the
3224         Vector value in the session map that lists all the key IDs that are being
3225         stored for that session.
3226
3227         MockCDMInstance::updateLicense() now detects the 'keys-changed' entry in the
3228         passed-in response data, and upon detecting that constructs a KeyStatusVector
3229         object containing all the keys for that session. KeyStatus::Usable is returned
3230         for each object at the moment, but this should be adjustable in the future
3231         through additional parameters passed through the response data. The Vector
3232         object is then passed to the callback and is then passed to the 'update key
3233         statuses' algorithm in MediaKeySession.
3234
3235         Covered by a test case in media/encrypted-media/mock-MediaKeySession-update.html.
3236
3237         * Modules/encryptedmedia/CDMInstance.h:
3238         * Modules/encryptedmedia/MediaKeySession.cpp:
3239         (WebCore::MediaKeySession::MediaKeySession):
3240         (WebCore::MediaKeySession::~MediaKeySession):
3241         (WebCore::MediaKeySession::update):
3242         (WebCore::MediaKeySession::updateKeyStatuses):
3243         * Modules/encryptedmedia/MediaKeySession.h:
3244         * Modules/encryptedmedia/MediaKeyStatusMap.cpp:
3245         (WebCore::MediaKeyStatusMap::MediaKeyStatusMap):
3246         (WebCore::MediaKeyStatusMap::detachSession):
3247         (WebCore::MediaKeyStatusMap::size):
3248         (WebCore::keyIdsMatch):
3249         (WebCore::MediaKeyStatusMap::has):
3250         (WebCore::MediaKeyStatusMap::get):
3251         (WebCore::MediaKeyStatusMap::Iterator::Iterator):
3252         (WebCore::MediaKeyStatusMap::Iterator::next):
3253         * Modules/encryptedmedia/MediaKeyStatusMap.h:
3254         (WebCore::MediaKeyStatusMap::create):
3255         * Modules/encryptedmedia/MediaKeyStatusMap.idl:
3256         * testing/MockCDMFactory.cpp:
3257         (WebCore::MockCDMFactory::keysForSessionWithID):
3258         (WebCore::MockCDMInstance::updateLicense):
3259         * testing/MockCDMFactory.h:
3260
3261 2017-02-09  Simon Fraser  <simon.fraser@apple.com>
3262
3263         Improve IOSurfacePool logging
3264         https://bugs.webkit.org/show_bug.cgi?id=168098
3265
3266         Reviewed by Tim Horton.
3267
3268         Pass a string to DUMP_POOL_STATISTICS so we can tell what's triggering the
3269         logging.
3270
3271         * platform/graphics/cg/IOSurfacePool.cpp:
3272         (WebCore::IOSurfacePool::takeSurface):
3273         (WebCore::IOSurfacePool::addSurface):
3274         (WebCore::IOSurfacePool::evict):
3275         (WebCore::IOSurfacePool::collectionTimerFired):
3276         (WebCore::IOSurfacePool::showPoolStatistics):
3277         * platform/graphics/cg/IOSurfacePool.h:
3278
3279 2017-02-09  Alex Christensen  <achristensen@webkit.org>
3280
3281         Unreviewed, rolling out r212040.
3282
3283         Broke build.  I'm not surprised
3284
3285         Reverted changeset:
3286
3287         "[WebRTC][Mac] Activate libwebrtc"
3288         https://bugs.webkit.org/show_bug.cgi?id=167293
3289         http://trac.webkit.org/changeset/212040
3290
3291 2017-02-09  Chris Dumez  <cdumez@apple.com>
3292
3293         [Mac][WK2] Use MIME type to add file extension to downloads' suggested filenames when missing
3294         https://bugs.webkit.org/show_bug.cgi?id=168077
3295         <rdar://problem/30412595>
3296
3297         Reviewed by Alex Christensen.
3298
3299         Add utility function to MIMETypeRegistry that appends an extension to
3300         a filename if necessary, based on a provided MIME type.
3301
3302         Tests: fast/dom/HTMLAnchorElement/anchor-file-blob-download-no-extension.html
3303                http/tests/download/anchor-download-no-extension.html
3304
3305         * platform/MIMETypeRegistry.cpp:
3306         (WebCore::MIMETypeRegistry::appendFileExtensionIfNecessary):
3307         * platform/MIMETypeRegistry.h:
3308         * platform/cocoa/MIMETypeRegistryCocoa.mm:
3309         (WebCore::MIMETypeRegistry::appendFileExtensionIfNecessary):
3310
3311 2017-02-09  Youenn Fablet  <youenn@apple.com>
3312
3313         [WebRTC][Mac] Activate libwebrtc
3314         https://bugs.webkit.org/show_bug.cgi?id=167293
3315
3316         Reviewed by Alex Christensen.
3317
3318         * Configurations/WebCore.xcconfig:
3319         * Configurations/WebCoreTestSupport.xcconfig:
3320
3321 2017-02-09  Philip Rogers  <pdr@google.com>
3322
3323         SVG clip-path references can clip out later content
3324         https://bugs.webkit.org/show_bug.cgi?id=164181
3325
3326         Reviewed by Said Abou-Hallawa.
3327
3328         RenderSVGResourceClipper can modify the GraphicsContext state (through the path-only
3329         clipping codepath) so we need to ensure RenderLayer::setupClipPath saves the context
3330         and its caller restores it back so later content is not clipped as well.
3331
3332         This patch is based on a chromium patch by fs@opera.com:
3333         https://chromium.googlesource.com/chromium/src/+/b3f7e7d2c4afb3c7e5c7eb438ff5933cbe2109b3
3334
3335         Test: css3/masking/clip-path-reference-restore.html
3336
3337         * rendering/RenderLayer.cpp:
3338         (WebCore::RenderLayer::setupClipPath): Add a GC save and return true to restore. Also switch to downcast instead of static_cast.
3339
3340 2017-02-09  Filip Pizlo  <fpizlo@apple.com>
3341
3342         SharedArrayBuffer does not need to be in the transfer list
3343         https://bugs.webkit.org/show_bug.cgi?id=168079
3344
3345         Reviewed by Geoffrey Garen and Keith Miller.
3346
3347         Tests: workers/sab/multi-memory-multi-buffer.html
3348                workers/sab/multi-memory.html
3349                workers/sab/no-transfer.html
3350                workers/sab/postMessage-clones.html
3351                workers/sab/sent-from-worker-no-transfer.html
3352                workers/sab/sent-from-worker-transfer.html
3353
3354         The SAB API that we originally implemented required that SABs get put in transfer lists
3355         when they are sent to workers.
3356         
3357         The new SAB API that everyone is converging towards requires that you do not put the
3358         SAB in the transfer list. That's supposed to be an error. Instead, anytime that a SAB
3359         is part of any message to or from a dedicated worker then it is automatically shared.
3360         
3361         The new API provides a lot more clarity about what is supposed to happen in contexts
3362         that support transfering but don't support sharing.
3363         
3364         Right now this patch allows both styles to work, but I hope we can disable the transfer
3365         list capability soon.
3366
3367         * bindings/js/IDBBindingUtilities.cpp:
3368         (WebCore::deserializeIDBValueToJSValue):
3369         * bindings/js/JSMessageEventCustom.cpp:
3370         (WebCore::JSMessageEvent::data):
3371         * bindings/js/SerializedScriptValue.cpp:
3372         (WebCore::CloneSerializer::serialize):
3373         (WebCore::CloneSerializer::CloneSerializer):
3374         (WebCore::CloneSerializer::dumpIfTerminal):
3375         (WebCore::CloneDeserializer::deserialize):
3376         (WebCore::CloneDeserializer::CloneDeserializer):
3377         (WebCore::CloneDeserializer::readTerminal):
3378         (WebCore::SerializedScriptValue::SerializedScriptValue):
3379         (WebCore::SerializedScriptValue::create):
3380         (WebCore::SerializedScriptValue::deserialize):
3381         * bindings/js/SerializedScriptValue.h:
3382         (): Deleted.
3383         * dom/CustomEvent.cpp:
3384         (WebCore::CustomEvent::trySerializeDetail):
3385         * dom/ErrorEvent.cpp:
3386         (WebCore::ErrorEvent::trySerializeError):
3387         * dom/MessageEvent.cpp:
3388         (WebCore::MessageEvent::trySerializeData):
3389         * dom/PopStateEvent.cpp:
3390         (WebCore::PopStateEvent::trySerializeState):
3391         * workers/DedicatedWorkerGlobalScope.cpp:
3392         (WebCore::DedicatedWorkerGlobalScope::postMessage):
3393         * workers/Worker.cpp:
3394         (WebCore::Worker::postMessage):
3395
3396 2017-02-09  Brent Fulgham  <bfulgham@apple.com>
3397
3398         Unreviewed build fix after r212025.
3399
3400         inDocument -> isConnected
3401
3402         * html/FormAssociatedElement.cpp:
3403         (WebCore::FormAssociatedElement::didMoveToNewDocument):
3404         (WebCore::FormAssociatedElement::resetFormAttributeTargetObserver):
3405         * html/HTMLFormElement.cpp:
3406         (WebCore::HTMLFormElement::formElementIndex):
3407
3408 2017-02-09  Chris Dumez  <cdumez@apple.com>
3409
3410         Make sure Event keeps its current target element alive
3411         https://bugs.webkit.org/show_bug.cgi?id=167885
3412         <rdar://problem/30376972>
3413
3414         Reviewed by Brent Fulgham.
3415
3416         Make sure Event keeps its current target element alive to avoid
3417         crashes if it is accessed by JS after it has been garbage collected.
3418
3419         Test: fast/events/currentTarget-gc-crash.html
3420
3421         * dom/Event.cpp:
3422         (WebCore::Event::setCurrentTarget):
3423         * dom/Event.h:
3424         (WebCore::Event::currentTarget):
3425
3426 2017-02-09  Ryosuke Niwa  <rniwa@webkit.org>
3427
3428         Crash in render tree after dynamically mutating the slot value
3429         https://bugs.webkit.org/show_bug.cgi?id=167502
3430
3431         Reviewed by Antti Koivisto.
3432
3433         The crash was caused by attributeChanged not destructing the render tree after an assigned element had been
3434         removed from its slot. Since the style resolver can no longer find this element in the flat tree, we need to
3435         delete its render object as if the element had been removed from the DOM tree.
3436
3437         Tests: fast/html/details-summary-slot.html
3438                fast/shadow-dom/shadow-slot-attribute-change-crash.html
3439
3440         * dom/Element.cpp:
3441         (WebCore::Element::attributeChanged):
3442         * html/HTMLSummaryElement.cpp:
3443         (WebCore::SummarySlotElement): Added. Always use the default slot regardless of the slot attribute's value.
3444         (WebCore::HTMLSummaryElement::create): Use SummarySlotElement
3445
3446 2017-02-09  Antti Koivisto  <antti@apple.com>
3447
3448         Details element doesn't work correctly when mutating content between closing and opening
3449         https://bugs.webkit.org/show_bug.cgi?id=167310
3450
3451         Reviewed by Ryosuke Niwa.
3452
3453         Tests: fast/html/details-close-modify-open.html
3454                fast/shadow-dom/slot-remove-mutate-add.html
3455
3456         * dom/SlotAssignment.cpp:
3457         (WebCore::SlotAssignment::didChangeSlot):
3458
3459             Always reset the slot assignment when content is mutated.
3460
3461 2017-02-09  Chris Dumez  <cdumez@apple.com>
3462
3463         Crash under FormSubmission::create()
3464         https://bugs.webkit.org/show_bug.cgi?id=167200
3465         <rdar://problem/30096323>
3466
3467         Reviewed by Darin Adler.
3468
3469         The issue is that FormSubmission::create() was iterating over
3470         form.associatedElements() as was calling Element::appendFormData()
3471         in the loop. HTMLObjectElement::appendFormData() was calling
3472         pluginWidget(PluginLoadingPolicy::Load) which causes a synchronous
3473         layout and can fire events (such as focus event) synchronously.
3474         Firing those events synchronously allows the JS to modify the
3475         form.associatedElements() vector we are currently iterating on.
3476
3477         To avoid this issue, we now call pluginWidget(PluginLoadingPolicy::DoNotLoad)
3478         in HTMLObjectElement::appendFormData() as we are not allowed to fire
3479         synchronous events at this point. I also added a security assertion
3480         in FormSubmission::create() to catch cases where we fire JS events
3481         while iterating over the form associated elements to more easily
3482         notice these things in the future.
3483
3484         Test: fast/forms/formsubmission-appendFormData-crash.html
3485
3486         * html/HTMLObjectElement.cpp:
3487         (WebCore::HTMLObjectElement::appendFormData):
3488         * loader/FormSubmission.cpp:
3489         (WebCore::FormSubmission::create):
3490
3491 2017-02-09  Chris Dumez  <cdumez@apple.com>
3492
3493         Crash under HTMLFormElement::registerFormElement()
3494         https://bugs.webkit.org/show_bug.cgi?id=167162
3495
3496         Reviewed by Ryosuke Niwa.
3497
3498         didMoveToNewDocument() was re-registering FormAttributeTargetObserver
3499         even if the element's inDocument was not set yet. As a result, it was
3500         possible for FormAssociatedElement::resetFormOwner() to be called
3501         when the element was in the tree but with its inDocument still being
3502         false (because insertedInto() has not been called yet). This could
3503         end up calling HTMLFormElement::registerFormElement() even though
3504         the element is still recognized as detached. This is an issue because
3505         HTMLFormElement::m_associatedElements's order and its corresponding
3506         indexes (m_associatedElementsBeforeIndex / m_associatedElementsAfterIndex)
3507         rely on the position of the element with regards to the form element
3508         (before / inside / after).
3509
3510         To address the issue, we now only register the FormAttributeTargetObserver
3511         in didMoveToNewDocument() if the inDocument flag is set to true. This
3512         is similar to what is done at other call sites of
3513         resetFormAttributeTargetObserver(). We also ignore the form content
3514         attribute in HTMLFormElement::formElementIndex() if the element is
3515         not connected.
3516
3517         As per the HTML specification [1], the form content attribute is only
3518         taken if the element is connected (i.e. inDocument flag is true).
3519
3520         Note that FormAssociatedElement::findAssociatedForm() was already
3521         ignoring the form content attribute if the element is disconnected.
3522
3523         [1] https://html.spec.whatwg.org/#reset-the-form-owner (step 3)
3524
3525         Test: fast/forms/registerFormElement-crash.html
3526
3527         * html/FormAssociatedElement.cpp:
3528         (WebCore::FormAssociatedElement::didMoveToNewDocument):
3529         Only call resetFormAttributeTargetObserver() if inDocument flag is set,
3530         similarly to what is done at other call sites.
3531
3532         (WebCore::FormAssociatedElement::resetFormAttributeTargetObserver):
3533         Add an assertion to make sure no one call this method on an element that
3534         is not connected.
3535
3536         * html/HTMLFormElement.cpp:
3537         (WebCore::HTMLFormElement::formElementIndex):
3538         Ignore the form content attribute if the element is not connected, as
3539         per the HTML specification [1].
3540
3541 2017-02-09  Antti Koivisto  <antti@apple.com>
3542
3543         Tear down existing renderers when adding a shadow root.
3544         https://bugs.webkit.org/show_bug.cgi?id=167117
3545
3546         Reviewed by Andreas Kling.
3547
3548         Adding a shadow root may cause children no longer be part of the flat tree. If they had renderers
3549         tear down code would no longer reach them.
3550
3551         Test: fast/shadow-dom/attach-shadow-teardown.html
3552
3553         * dom/Element.cpp:
3554         (WebCore::Element::addShadowRoot):
3555
3556             Tear down existing render tree when adding a shadow root.
3557
3558 2017-02-09  Brent Fulgham  <bfulgham@apple.com>
3559
3560         Handle synchronous layout when setting a selection range
3561         https://bugs.webkit.org/show_bug.cgi?id=167092
3562         <rdar://problem/30041640>
3563
3564         Reviewed by Antti Koivisto.
3565
3566         The 'innerTextElement' of a form control can change during layout due
3567         to arbitrary JavaScript executing. Handle the case where the inner text
3568         element has changed so that current render box height is while setting
3569         a selection range.
3570
3571         Test: fast/forms/input-type-change-during-selection.html
3572
3573         * html/HTMLTextFormControlElement.cpp:
3574         (WebCore::HTMLTextFormControlElement::setSelectionRange):
3575
3576 2017-02-09  Alex Christensen  <achristensen@webkit.org>
3577
3578         Fix CMake build.
3579
3580         * PlatformMac.cmake:
3581
3582 2017-02-09  Brent Fulgham  <bfulgham@apple.com>
3583
3584         Disconnect shadow children of root when detaching a frame
3585         https://bugs.webkit.org/show_bug.cgi?id=166851
3586         <rdar://problem/29930443>
3587
3588         Reviewed by Andy Estes.
3589
3590         If the root of the tree we are disconnecting has a shadow element, include it in the set of
3591         things to disconnect.
3592
3593         Tests: fast/shadow-dom/shadow-at-root-during-disconnect.html
3594
3595         * dom/ContainerNodeAlgorithms.cpp:
3596         (WebCore::disconnectSubframes):
3597
3598 2017-02-09  Alexey Proskuryakov  <ap@apple.com>
3599
3600         Remove unused WebThreadRunSync
3601         https://bugs.webkit.org/show_bug.cgi?id=168024
3602
3603         Reviewed by Tim Horton.
3604
3605         * platform/ios/wak/WebCoreThreadRun.cpp:
3606         * platform/ios/wak/WebCoreThreadRun.h:
3607         * platform/ios/wak/WebCoreThreadSystemInterface.cpp:
3608         (InitWebCoreThreadSystemInterface):
3609
3610 2017-02-09  Ryan Haddad  <ryanhaddad@apple.com>
3611
3612         Unreviewed, rolling out r211802.
3613
3614         This change caused fast/regions/inline-block-inside-anonymous-
3615         overflow-with-covered-controls.html to be a flaky failure.
3616
3617         Reverted changeset:
3618
3619         "[Modern Media Controls] Improve handling of <video> with only
3620         audio tracks"
3621         https://bugs.webkit.org/show_bug.cgi?id=167836
3622         http://trac.webkit.org/changeset/211802
3623
3624 2017-02-09  Alex Christensen  <achristensen@webkit.org>
3625
3626         Fix i386 libwebrtc build
3627         https://bugs.webkit.org/show_bug.cgi?id=168038
3628
3629         * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
3630         DataChannelInterface::buffered_amount returns a uint64_t, and we want a size_t.
3631         If this overflows, then we've run out of memory and crashed a long time ago.
3632
3633 2017-02-09  Andreas Kling  <akling@apple.com>
3634
3635         Document::settings() should return a const Settings&.
3636         <https://webkit.org/b/168061>
3637
3638         Reviewed by Geoffrey Garen.
3639
3640         - Make Document::settings() return a const reference.
3641         - Added Document::mutableSettings() for all your non-const needs.
3642         - Fixed up settings generator to produce const getters.
3643         - Simplify a few settings() call sites that exposed themselves.
3644
3645         * Modules/applepay/ApplePaySession.cpp:
3646         (WebCore::shouldDiscloseApplePayCapability):
3647         * Modules/mediastream/UserMediaRequest.cpp:
3648         (WebCore::canCallGetUserMedia):
3649         * css/CSSFontFace.cpp:
3650         (WebCore::CSSFontFace::appendSources):
3651         * css/CSSFontSelector.cpp:
3652         (WebCore::resolveGenericFamily):
3653         * css/StyleResolver.h:
3654         (WebCore::StyleResolver::settings):
3655         * dom/Document.h:
3656         (WebCore::Document::settings):
3657         (WebCore::Document::mutableSettings):
3658         * html/FTPDirectoryDocument.cpp:
3659         (WebCore::createTemplateDocumentData):
3660         * html/HTMLCanvasElement.cpp:
3661         (WebCore::shouldEnableWebGL):
3662         * html/HTMLEmbedElement.cpp:
3663         (WebCore::HTMLEmbedElement::rendererIsNeeded):
3664         * html/HTMLSelectElement.cpp:
3665         (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
3666         * html/ImageDocument.cpp:
3667         (WebCore::ImageDocument::updateDuringParsing):
3668         * page/csp/ContentSecurityPolicy.cpp:
3669         (WebCore::ContentSecurityPolicy::allowContentSecurityPolicySourceStarToMatchAnyProtocol):
3670         * page/make_settings.pl:
3671         (printGetterAndSetter):
3672         * rendering/SimpleLineLayout.cpp:
3673         (WebCore::SimpleLineLayout::toggleSimpleLineLayout):
3674
3675 2017-02-09  Jer Noble  <jer.noble@apple.com>
3676
3677         Make passing PlatformAudioData in audioSamplesAvaliable const-correct.
3678         https://bugs.webkit.org/show_bug.cgi?id=168051
3679
3680         Reviewed by Eric Carlson.
3681
3682         Modify all the functions which take a (conceptually) read-only audio buffer const-correct.
3683
3684         Drive-by fix: AudioSampleBufferList::copyFrom() set a ivar pointer to the passed in
3685         AudioBufferList. Ensure that the ivar is reset when copyFrom() returns by using a
3686         SetForScope.
3687
3688         * platform/audio/mac/AudioSampleBufferList.cpp:
3689         (WebCore::AudioSampleBufferList::copyFrom):
3690         * platform/audio/mac/AudioSampleBufferList.h:
3691         * platform/audio/mac/AudioSampleDataSource.cpp:
3692         (WebCore::AudioSampleDataSource::pushSamplesInternal):
3693         (WebCore::AudioSampleDataSource::pushSamples):
3694         * platform/audio/mac/AudioSampleDataSource.h:
3695         * platform/mediastream/RealtimeMediaSource.cpp:
3696         (WebCore::RealtimeMediaSource::audioSamplesAvailable):
3697         * platform/mediastream/RealtimeMediaSource.h:
3698         (WebCore::RealtimeMediaSource::Observer::audioSamplesAvailable):
3699         * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp:
3700         (WebCore::AudioTrackPrivateMediaStreamCocoa::audioSamplesAvailable):
3701         * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h:
3702         * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
3703         (WebCore::RealtimeOutgoingAudioSource::audioSamplesAvailable):
3704         * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
3705
3706 2017-02-09  Jer Noble  <jer.noble@apple.com>
3707
3708         Fix some logging statements in MediaPlayerPrivateMediaStreamAVFObjC
3709         https://bugs.webkit.org/show_bug.cgi?id=168063
3710
3711         Reviewed by Eric Carlson.
3712
3713         Make the format string match the types passed in (i.e., floats, not strings).
3714
3715         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
3716         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateSampleTimes):
3717
3718 2017-02-09  Eric Carlson  <eric.carlson@apple.com>
3719
3720         [MediaStream Mac] Handle NULL m_sampleBufferDisplayLayer
3721         https://bugs.webkit.org/show_bug.cgi?id=168060
3722
3723         Reviewed by Jer Noble.
3724
3725         No new tests, this avoids an occasional crash on the bots.
3726
3727         * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
3728         (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::layerStatusDidChange): Don't assume
3729         m_sampleBufferDisplayLayer is valid.
3730
3731 2017-02-09  Chris Dumez  <cdumez@apple.com>
3732
3733         Object.getPrototypeOf(NodeFilter) should be Function.prototype, not Object.prototype
3734         https://bugs.webkit.org/show_bug.cgi?id=167964
3735
3736         Reviewed by Youenn Fablet.
3737
3738         Object.getPrototypeOf(NodeFilter) should be Function.prototype, not Object.prototype
3739         after the following WebIDL spec change:
3740         - https://github.com/heycam/webidl/issues/96
3741
3742         This aligns our behavior with other browsers as the spec has been updated to match
3743         the majority.
3744
3745         No new tests, rebaselined existing test.
3746
3747         * bindings/scripts/CodeGeneratorJS.pm:
3748         (GenerateConstructorHelperMethods):
3749         * bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
3750         (WebCore::JSTestCallbackInterfaceConstructor::prototypeForStructure):
3751
3752 2017-02-09  Miguel Gomez  <magomez@igalia.com>
3753
3754         [GTK] scroll with transparent background not repainted after scrollY >= 32768
3755         https://bugs.webkit.org/show_bug.cgi?id=154283
3756
3757         Reviewed by Carlos Garcia Campos.
3758
3759         Due to a limitation of the pixman backend, which uses 16 bits to hold signed integers, cairo is
3760         not able to draw anything when using transformation matrices with values bigger than 32768. When
3761         drawing patterns into large pages, the matrices values can overflow those 16 bits, so cairo doesn't
3762         draw anything in, which causes the reported transparent backgrounds.
3763
3764         The patch modifies the transformation matrices both from the current context and the pattern we
3765         are painting, to avoid them to hold values that cannot stored in 16 bits.
3766
3767         There's still the possibility that this happens, but it would require using a pattern with a size
3768         bigger than 32768.
3769
3770         Based on a previous patch by Gwang Yoon Hwang  <yoon@igalia.com>.
3771
3772         No new tests.
3773
3774         * platform/graphics/cairo/CairoUtilities.cpp:
3775         (WebCore::drawPatternToCairoContext):
3776
3777 2017-02-09  Brent Fulgham  <bfulgham@apple.com>
3778
3779         Unreviewed build fix after r211965.
3780
3781         * dom/Document.cpp:
3782         (WebCore::Document::adoptNode): inDocument -> isConnected
3783
3784 2017-02-09  Ryosuke Niwa  <rniwa@webkit.org>
3785
3786         Adopting a child node of a script element can run script
3787         https://bugs.webkit.org/show_bug.cgi?id=167318
3788
3789         Reviewed by Darin Adler.
3790
3791         The bug was caused by ScriptElement::childrenChanged indiscriminately running the script.
3792         Do this only if some node has been inserted as spec'ed:
3793
3794         https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model
3795         "The script element is connected and a node or document fragment is inserted into
3796         the script element, after any script elements inserted at that time."
3797
3798         Split NonContentsChildChanged into NonContentsChildInserted and NonContentsChildRemoved to disambiguate
3799         non-contents child such as text and element being removed or inserted. New behavior matches that of
3800         Gecko and Chrome as well as the latest HTML5 specification.
3801
3802         Also deploy NoEventDispatchAssertion in more places. Unfortunately, this results in some DOM trees
3803         internal to WebKit to be mutated while there is NoEventDispatchAssertion in the stack. Added a new RAII
3804         object "EventAllowedScope" to temporarily disable this assertion within such a tree. CachedSVGFont's
3805         ensureCustomFontData used to completely disable this assertion but we no longer have to do this either.
3806
3807         To clarify the new semantics, renamed isEventDispatchForbidden to isEventAllowedInMainThread with
3808         the negated boolean value, and added a new variant isEventDispatchAllowedInSubtree, which checks
3809         isEventDispatchForbidden() is true or if the node was one of an internal DOM node or its descendent
3810         held by EventAllowedScope.
3811
3812         Inspired by https://chromium.googlesource.com/chromium/src/+/604e798ec6ee30f44d57a5c4a44ce3dab3a871ed
3813
3814         Tests: fast/html/script-must-not-run-when-child-is-adopted.html
3815                fast/html/script-must-not-run-when-child-is-removed.html
3816
3817         * dom/CharacterData.cpp:
3818         (WebCore::CharacterData::notifyParentAfterChange): Added NoEventDispatchAssertion.
3819         * dom/ContainerNode.cpp:
3820         (WebCore::ContainerNode::insertBefore): Added NoEventDispatchAssertion around TreeScope's adoptIfNeeded
3821         and insertBeforeCommon as done elsewhere.
3822         (WebCore::ContainerNode::appendChildCommon): Added NoEventDispatchAssertion.
3823         (WebCore::ContainerNode::changeForChildInsertion): Use NonContentsChildInserted here.
3824         (WebCore::ContainerNode::notifyChildRemoved): Added NoEventDispatchAssertion.
3825         (WebCore::ContainerNode::replaceChild): Moved adoptIfNeeded into NoEventDispatchAssertion.
3826         (WebCore::ContainerNode::removeChild): Added NoEventDispatchAssertion.
3827         (WebCore::ContainerNode::parserRemoveChild): Added NoEventDispatchAssertion.
3828         (WebCore::ContainerNode::removeChildren): Call childrenChanged in NoEventDispatchAssertion.
3829         (WebCore::ContainerNode::appendChildWithoutPreInsertionValidityCheck): Moved adoptIfNeeded into
3830         NoEventDispatchAssertion.
3831         (WebCore::dispatchChildInsertionEvents): Check the forbidden-ness more precisely.
3832         (WebCore::dispatchChildRemovalEvents): Ditto.
3833         * dom/ContainerNode.h:
3834         (WebCore::ContainerNode::ChildChange::isInsertion): Added.
3835         * dom/ContainerNodeAlgorithms.cpp:
3836         (WebCore::notifyChildNodeInserted): Check the forbidden-ness more precisely. Here, we check against
3837         insertionPoint since EventAllowedScope checks against the root node.
3838         * dom/Document.cpp:
3839         (WebCore::Document::adoptNode): Assert the node to be adopted has not been inserted back, or else
3840         remove() had resulted in an exception before calling TreeScope::adoptIfNeeded.
3841         * dom/Element.cpp:
3842         (WebCore::Element::childrenChanged):
3843         * dom/NoEventDispatchAssertion.h:
3844         (WebCore::NoEventDispatchAssertion::isEventDispatchForbidden): Added a new variant that takes a node.
3845         If this node is a descendent of a node "marked as safe" by EventAllowedScope, then we don't consider
3846         the event dispatch to be forbidden.
3847         (WebCore::NoEventDispatchAssertion::dropTemporarily): Deleted.
3848         (WebCore::NoEventDispatchAssertion::restoreDropped): Deleted.
3849         (WebCore::NoEventDispatchAssertion::EventAllowedScope): Added. A RAII object which marks descendants of
3850         a given node as "safe" for the purpose of checking isEventDispatchForbidden.
3851         (WebCore::NoEventDispatchAssertion::EventAllowedScope::EventAllowedScope): Added. There can be a chain
3852         of EventAllowedScope objects in the stack. s_currentScope points to the most recently instantiated
3853         RAII object, and each instance remembers prior instance. 
3854         (WebCore::NoEventDispatchAssertion::EventAllowedScope::~EventAllowedScope): Added.
3855         (WebCore::NoEventDispatchAssertion::EventAllowedScope::isAllowedNode): Added. Returns true if the given
3856         node is a descendent of any node held by instances of EventAllowedScope.
3857         (WebCore::NoEventDispatchAssertion::EventAllowedScope::isAllowedNodeInternal): Added. A helper function
3858         for isAllowedNode.
3859         * dom/Node.cpp:
3860         (WebCore::Node::dispatchSubtreeModifiedEvent): Check the forbidden-ness more precisely.
3861         * dom/ScriptElement.cpp:
3862         (WebCore::ScriptElement::childrenChanged): Only prepare the script if we've inserted nodes.
3863         (WebCore::ScriptElement::executeClassicScript): Assert isEventDispatchForbidden is false since running
3864         arbitrary author scripts can, indeed, result dispatch any events.
3865         * dom/ScriptElement.h:
3866         * html/HTMLElement.cpp:
3867         (WebCore::textToFragment): Made this a static local function and not return an exception since there
3868         is no way appendChild called in this function can throw an exception.
3869         (WebCore::HTMLElement::setInnerText): Create EventAllowedScope for the fragment. It's called called by
3870         HTMLTextAreaElement's childrenChanged to update its UA shadow tree, and it's dispatching as event on
3871         a new fragment can't execute arbitrary scripts since it has never been exposed to author scripts.
3872         Because of the precise-ness of this check, this does not disable the assertion for "this" element.
3873         HTMLTextFormControlElement::setInnerTextValue explicitly creates another EventAllowedScope to mark
3874         the shadow tree into which the fragment is inserted safe.
3875         (WebCore::HTMLElement::setOuterText):
3876         * html/HTMLElement.h:
3877         * html/HTMLScriptElement.cpp:
3878         (WebCore::HTMLScriptElement::childrenChanged):
3879         * html/HTMLTextFormControlElement.cpp:
3880         (WebCore::HTMLTextFormControlElement::setInnerTextValue): See above (setInnerText).
3881         * html/track/VTTCue.cpp:
3882         (WebCore::VTTCue::createCueRenderingTree): Create EventAllowedScope for the cloned fragment here since
3883         the VTT tree is never exposed to author scripts.
3884         (WebCore::VTTCue::updateDisplayTree): Ditto.
3885         * loader/cache/CachedSVGFont.cpp:
3886         (WebCore::CachedSVGFont::ensureCustomFontData): Use EventAllowedScope to disable assertions only on
3887         the new SVG document we just created instead of disabling for all DOM trees.
3888         * svg/SVGScriptElement.cpp:
3889         (WebCore::SVGScriptElement::childrenChanged):
3890
3891 2017-02-09  Andreas Kling  <akling@apple.com>
3892
3893         Document should always have a Settings.
3894         <https://webkit.org/b/120172>
3895
3896         Reviewed by Antti Koivisto.
3897
3898         Since a Document can't move between Frames, and it's either frameless
3899         or partnered with a Frame provided at construction time, we know that
3900         it will never need to switch between different Settings objects either.
3901
3902         Give Document a Ref<Settings> that contains either the Frame's Settings
3903         or a default-constructed Settings object if frameless.
3904         Document::settings() is promoted to a reference getter.
3905
3906         The bulk of this patch is removing now-unnecessary null checks.
3907
3908         * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
3909         (WebCore::WebKitMediaKeySession::mediaKeysStorageDirectory):
3910         * Modules/plugins/PluginReplacement.h:
3911         (WebCore::ReplacementPlugin::isEnabledBySettings):
3912         * Modules/plugins/QuickTimePluginReplacement.h:
3913         * Modules/plugins/QuickTimePluginReplacement.mm:
3914         (WebCore::QuickTimePluginReplacement::isEnabledBySettings):
3915         * Modules/plugins/YouTubePluginReplacement.cpp:
3916         (WebCore::YouTubePluginReplacement::isEnabledBySettings):
3917         * Modules/plugins/YouTubePluginReplacement.h:
3918         * Modules/webaudio/AudioContext.cpp:
3919         (WebCore::AudioContext::constructCommon):
3920         * bindings/js/CachedScriptFetcher.cpp:
3921         (WebCore::CachedScriptFetcher::requestScriptWithCache):
3922         * css/CSSFontFace.cpp:
3923         (WebCore::CSSFontFace::appendSources):
3924         (WebCore::CSSFontFace::webFontsShouldAlwaysFallBack):
3925         * css/CSSFontSelector.cpp:
3926         (WebCore::CSSFontSelector::fallbackFontCount):
3927         (WebCore::CSSFontSelector::fallbackFontAt):
3928         * css/StyleBuilderConverter.h:
3929         (WebCore::StyleBuilderConverter::convertResize):
3930         * css/StyleBuilderCustom.h:
3931         (WebCore::StyleBuilderCustom::applyValueFontFamily):
3932         * css/StyleResolver.cpp:
3933         (WebCore::StyleResolver::StyleResolver):
3934         (WebCore::StyleResolver::defaultStyleForElement):
3935         (WebCore::StyleResolver::adjustRenderStyle):
3936         (WebCore::StyleResolver::checkForGenericFamilyChange):
3937         (WebCore::StyleResolver::initializeFontStyle):
3938         * css/StyleResolver.h:
3939         (WebCore::StyleResolver::settings):
3940         (WebCore::StyleResolver::documentSettings): Deleted.
3941         * css/parser/CSSParser.cpp:
3942         (WebCore::CSSParserContext::CSSParserContext):
3943         * dom/Document.cpp:
3944         (WebCore::Document::Document):
3945         (WebCore::Document::setReadyState):
3946         (WebCore::Document::setVisualUpdatesAllowed):
3947         (WebCore::Document::defaultCharsetForLegacyBindings):
3948         (WebCore::Document::recalcStyle):
3949         (WebCore::Document::implicitClose):
3950         (WebCore::Document::minimumLayoutDelay):
3951         (WebCore::Document::setDomain):
3952         (WebCore::Document::audioPlaybackRequiresUserGesture):
3953         (WebCore::Document::videoPlaybackRequiresUserGesture):
3954         (WebCore::Document::storageBlockingStateDidChange):
3955         (WebCore::Document::isTelephoneNumberParsingEnabled):
3956         (WebCore::Document::initSecurityContext):
3957         (WebCore::Document::initDNSPrefetch):
3958         (WebCore::Document::getCachedLocale):
3959         (WebCore::Document::shouldEnforceContentDispositionAttachmentSandbox):
3960         (WebCore::Document::settings): Deleted.
3961         * dom/Document.h:
3962         (WebCore::Document::settings):
3963         * dom/Element.cpp:
3964         (WebCore::subpixelMetricsEnabled):
3965         * dom/ExtensionStyleSheets.cpp:
3966         (WebCore::ExtensionStyleSheets::pageUserSheet):
3967         * dom/ScriptExecutionContext.cpp:
3968         (WebCore::ScriptExecutionContext::dispatchErrorEvent):
3969         * dom/ScriptableDocumentParser.cpp:
3970         (WebCore::ScriptableDocumentParser::ScriptableDocumentParser):
3971         * dom/ScriptedAnimationController.cpp:
3972         (WebCore::ScriptedAnimationController::requestAnimationFrameEnabled):
3973         * dom/make_names.pl:
3974         (printConstructorInterior):
3975         * editing/Editor.cpp:
3976         * editing/markup.cpp:
3977         (WebCore::createMarkupInternal):
3978         * html/FTPDirectoryDocument.cpp:
3979         (WebCore::createTemplateDocumentData):
3980         * html/HTMLAnchorElement.cpp:
3981         (WebCore: