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