Remove the code guarded by STYLE_SCOPED
[WebKit-https.git] / Source / WebCore / testing / InternalSettings.cpp
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  * Copyright (C) 2013 Apple Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "InternalSettings.h"
29
30 #include "CaptionUserPreferences.h"
31 #include "Document.h"
32 #include "ExceptionCode.h"
33 #include "FrameView.h"
34 #include "Language.h"
35 #include "LocaleToScriptMapping.h"
36 #include "MainFrame.h"
37 #include "Page.h"
38 #include "PageGroup.h"
39 #include "RuntimeEnabledFeatures.h"
40 #include "Settings.h"
41 #include "Supplementable.h"
42 #include "TextRun.h"
43
44 #if ENABLE(INPUT_TYPE_COLOR)
45 #include "ColorChooser.h"
46 #endif
47
48 #define InternalSettingsGuardForSettingsReturn(returnValue) \
49     if (!settings()) { \
50         ec = INVALID_ACCESS_ERR; \
51         return returnValue; \
52     }
53
54 #define InternalSettingsGuardForSettings()  \
55     if (!settings()) { \
56         ec = INVALID_ACCESS_ERR; \
57         return; \
58     }
59
60 #define InternalSettingsGuardForPage() \
61     if (!page()) { \
62         ec = INVALID_ACCESS_ERR; \
63         return; \
64     }
65
66 namespace WebCore {
67
68 InternalSettings::Backup::Backup(Settings& settings)
69     : m_originalCSSExclusionsEnabled(RuntimeEnabledFeatures::sharedFeatures().cssExclusionsEnabled())
70     , m_originalCSSShapesEnabled(RuntimeEnabledFeatures::sharedFeatures().cssShapesEnabled())
71     , m_originalCSSVariablesEnabled(settings.cssVariablesEnabled())
72 #if ENABLE(SHADOW_DOM)
73     , m_originalShadowDOMEnabled(RuntimeEnabledFeatures::sharedFeatures().shadowDOMEnabled())
74     , m_originalAuthorShadowDOMForAnyElementEnabled(RuntimeEnabledFeatures::sharedFeatures().authorShadowDOMForAnyElementEnabled())
75 #endif
76     , m_originalEditingBehavior(settings.editingBehaviorType())
77 #if ENABLE(TEXT_AUTOSIZING)
78     , m_originalTextAutosizingEnabled(settings.textAutosizingEnabled())
79     , m_originalTextAutosizingWindowSizeOverride(settings.textAutosizingWindowSizeOverride())
80     , m_originalTextAutosizingFontScaleFactor(settings.textAutosizingFontScaleFactor())
81 #endif
82     , m_originalMediaTypeOverride(settings.mediaTypeOverride())
83     , m_originalCanvasUsesAcceleratedDrawing(settings.canvasUsesAcceleratedDrawing())
84     , m_originalMockScrollbarsEnabled(settings.mockScrollbarsEnabled())
85     , m_langAttributeAwareFormControlUIEnabled(RuntimeEnabledFeatures::sharedFeatures().langAttributeAwareFormControlUIEnabled())
86     , m_imagesEnabled(settings.areImagesEnabled())
87     , m_minimumTimerInterval(settings.minDOMTimerInterval())
88 #if ENABLE(VIDEO_TRACK)
89     , m_shouldDisplaySubtitles(settings.shouldDisplaySubtitles())
90     , m_shouldDisplayCaptions(settings.shouldDisplayCaptions())
91     , m_shouldDisplayTextDescriptions(settings.shouldDisplayTextDescriptions())
92 #endif
93     , m_defaultVideoPosterURL(settings.defaultVideoPosterURL())
94     , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings.timeWithoutMouseMovementBeforeHidingControls())
95     , m_useLegacyBackgroundSizeShorthandBehavior(settings.useLegacyBackgroundSizeShorthandBehavior())
96     , m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
97 {
98 }
99
100 void InternalSettings::Backup::restoreTo(Settings& settings)
101 {
102     RuntimeEnabledFeatures::sharedFeatures().setCSSExclusionsEnabled(m_originalCSSExclusionsEnabled);
103     RuntimeEnabledFeatures::sharedFeatures().setCSSShapesEnabled(m_originalCSSShapesEnabled);
104     settings.setCSSVariablesEnabled(m_originalCSSVariablesEnabled);
105 #if ENABLE(SHADOW_DOM)
106     RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(m_originalShadowDOMEnabled);
107     RuntimeEnabledFeatures::sharedFeatures().setAuthorShadowDOMForAnyElementEnabled(m_originalAuthorShadowDOMForAnyElementEnabled);
108 #endif
109     settings.setEditingBehaviorType(m_originalEditingBehavior);
110
111     for (auto iter = m_standardFontFamilies.begin(); iter != m_standardFontFamilies.end(); ++iter)
112         settings.setStandardFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
113     m_standardFontFamilies.clear();
114
115     for (auto iter = m_fixedFontFamilies.begin(); iter != m_fixedFontFamilies.end(); ++iter)
116         settings.setFixedFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
117     m_fixedFontFamilies.clear();
118
119     for (auto iter = m_serifFontFamilies.begin(); iter != m_serifFontFamilies.end(); ++iter)
120         settings.setSerifFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
121     m_serifFontFamilies.clear();
122
123     for (auto iter = m_sansSerifFontFamilies.begin(); iter != m_sansSerifFontFamilies.end(); ++iter)
124         settings.setSansSerifFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
125     m_sansSerifFontFamilies.clear();
126
127     for (auto iter = m_cursiveFontFamilies.begin(); iter != m_cursiveFontFamilies.end(); ++iter)
128         settings.setCursiveFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
129     m_cursiveFontFamilies.clear();
130
131     for (auto iter = m_fantasyFontFamilies.begin(); iter != m_fantasyFontFamilies.end(); ++iter)
132         settings.setFantasyFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
133     m_fantasyFontFamilies.clear();
134
135     for (auto iter = m_pictographFontFamilies.begin(); iter != m_pictographFontFamilies.end(); ++iter)
136         settings.setPictographFontFamily(iter->value, static_cast<UScriptCode>(iter->key));
137     m_pictographFontFamilies.clear();
138
139 #if ENABLE(TEXT_AUTOSIZING)
140     settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
141     settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
142     settings.setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
143 #endif
144     settings.setMediaTypeOverride(m_originalMediaTypeOverride);
145     settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing);
146     settings.setMockScrollbarsEnabled(m_originalMockScrollbarsEnabled);
147     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled);
148     settings.setImagesEnabled(m_imagesEnabled);
149     settings.setMinDOMTimerInterval(m_minimumTimerInterval);
150 #if ENABLE(VIDEO_TRACK)
151     settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
152     settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
153     settings.setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
154 #endif
155     settings.setDefaultVideoPosterURL(m_defaultVideoPosterURL);
156     settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
157     settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
158     settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
159 }
160
161 // We can't use RefCountedSupplement because that would try to make InternalSettings RefCounted
162 // and InternalSettings is already RefCounted via its base class, InternalSettingsGenerated.
163 // Instead, we manually make InternalSettings supplement Page.
164 class InternalSettingsWrapper : public Supplement<Page> {
165 public:
166     explicit InternalSettingsWrapper(Page* page)
167         : m_internalSettings(InternalSettings::create(page)) { }
168     virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); }
169 #if !ASSERT_DISABLED
170     virtual bool isRefCountedWrapper() const OVERRIDE { return true; }
171 #endif
172     InternalSettings* internalSettings() const { return m_internalSettings.get(); }
173
174 private:
175     RefPtr<InternalSettings> m_internalSettings;
176 };
177
178 const char* InternalSettings::supplementName()
179 {
180     return "InternalSettings";
181 }
182
183 InternalSettings* InternalSettings::from(Page* page)
184 {
185     if (!Supplement<Page>::from(page, supplementName()))
186         Supplement<Page>::provideTo(page, supplementName(), adoptPtr(new InternalSettingsWrapper(page)));
187     return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, supplementName()))->internalSettings();
188 }
189
190 InternalSettings::~InternalSettings()
191 {
192 }
193
194 InternalSettings::InternalSettings(Page* page)
195     : InternalSettingsGenerated(page)
196     , m_page(page)
197     , m_backup(page->settings())
198 {
199 }
200
201 void InternalSettings::resetToConsistentState()
202 {
203     page()->setPageScaleFactor(1, IntPoint(0, 0));
204     page()->setCanStartMedia(true);
205
206     m_backup.restoreTo(*settings());
207     m_backup = Backup(*settings());
208
209     InternalSettingsGenerated::resetToConsistentState();
210 }
211
212 Settings* InternalSettings::settings() const
213 {
214     if (!page())
215         return 0;
216     return &page()->settings();
217 }
218
219 void InternalSettings::setMockScrollbarsEnabled(bool enabled, ExceptionCode& ec)
220 {
221     InternalSettingsGuardForSettings();
222     settings()->setMockScrollbarsEnabled(enabled);
223 }
224
225 static bool urlIsWhitelistedForSetShadowDOMEnabled(const String& url)
226 {
227     // This check is just for preventing fuzzers from crashing because of unintended API calls.
228     // You can list your test if needed.
229     return notFound != url.find("fast/dom/shadow/content-shadow-unknown.html")
230         || notFound != url.find("fast/dom/shadow/insertion-points-with-shadow-disabled.html");
231 }
232
233 void InternalSettings::setShadowDOMEnabled(bool enabled, ExceptionCode& ec)
234 {
235     if (!urlIsWhitelistedForSetShadowDOMEnabled(page()->mainFrame().document()->url().string())) {
236         ec = INVALID_ACCESS_ERR;
237         return;
238     }
239
240 #if ENABLE(SHADOW_DOM)
241     RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(enabled);
242 #else
243     // Even SHADOW_DOM is off, InternalSettings allows setShadowDOMEnabled(false) to
244     // have broader test coverage. But it cannot be setShadowDOMEnabled(true).
245     if (enabled)
246         ec = INVALID_ACCESS_ERR;
247 #endif
248 }
249
250 void InternalSettings::setAuthorShadowDOMForAnyElementEnabled(bool isEnabled)
251 {
252 #if ENABLE(SHADOW_DOM)
253     RuntimeEnabledFeatures::sharedFeatures().setAuthorShadowDOMForAnyElementEnabled(isEnabled);
254 #else
255     UNUSED_PARAM(isEnabled);
256 #endif
257 }
258
259 void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionCode& ec)
260 {
261 #if ENABLE(TOUCH_EVENTS)
262     InternalSettingsGuardForSettings();
263     settings()->setTouchEventEmulationEnabled(enabled);
264 #else
265     UNUSED_PARAM(enabled);
266     UNUSED_PARAM(ec);
267 #endif
268 }
269
270 void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionCode& ec)
271 {
272     InternalSettingsGuardForSettings();
273     UScriptCode code = scriptNameToCode(script);
274     if (code == USCRIPT_INVALID_CODE)
275         return;
276     m_backup.m_standardFontFamilies.add(code, settings()->standardFontFamily(code));
277     settings()->setStandardFontFamily(family, code);
278 }
279
280 void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
281 {
282     InternalSettingsGuardForSettings();
283     UScriptCode code = scriptNameToCode(script);
284     if (code == USCRIPT_INVALID_CODE)
285         return;
286     m_backup.m_serifFontFamilies.add(code, settings()->serifFontFamily(code));
287     settings()->setSerifFontFamily(family, code);
288 }
289
290 void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
291 {
292     InternalSettingsGuardForSettings();
293     UScriptCode code = scriptNameToCode(script);
294     if (code == USCRIPT_INVALID_CODE)
295         return;
296     m_backup.m_sansSerifFontFamilies.add(code, settings()->sansSerifFontFamily(code));
297     settings()->setSansSerifFontFamily(family, code);
298 }
299
300 void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionCode& ec)
301 {
302     InternalSettingsGuardForSettings();
303     UScriptCode code = scriptNameToCode(script);
304     if (code == USCRIPT_INVALID_CODE)
305         return;
306     m_backup.m_fixedFontFamilies.add(code, settings()->fixedFontFamily(code));
307     settings()->setFixedFontFamily(family, code);
308 }
309
310 void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionCode& ec)
311 {
312     InternalSettingsGuardForSettings();
313     UScriptCode code = scriptNameToCode(script);
314     if (code == USCRIPT_INVALID_CODE)
315         return;
316     m_backup.m_cursiveFontFamilies.add(code, settings()->cursiveFontFamily(code));
317     settings()->setCursiveFontFamily(family, code);
318 }
319
320 void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionCode& ec)
321 {
322     InternalSettingsGuardForSettings();
323     UScriptCode code = scriptNameToCode(script);
324     if (code == USCRIPT_INVALID_CODE)
325         return;
326     m_backup.m_fantasyFontFamilies.add(code, settings()->fantasyFontFamily(code));
327     settings()->setFantasyFontFamily(family, code);
328 }
329
330 void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionCode& ec)
331 {
332     InternalSettingsGuardForSettings();
333     UScriptCode code = scriptNameToCode(script);
334     if (code == USCRIPT_INVALID_CODE)
335         return;
336     m_backup.m_pictographFontFamilies.add(code, settings()->pictographFontFamily(code));
337     settings()->setPictographFontFamily(family, code);
338 }
339
340 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
341 {
342 #if ENABLE(TEXT_AUTOSIZING)
343     InternalSettingsGuardForSettings();
344     settings()->setTextAutosizingEnabled(enabled);
345 #else
346     UNUSED_PARAM(enabled);
347     UNUSED_PARAM(ec);
348 #endif
349 }
350
351 void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode& ec)
352 {
353 #if ENABLE(TEXT_AUTOSIZING)
354     InternalSettingsGuardForSettings();
355     settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height));
356 #else
357     UNUSED_PARAM(width);
358     UNUSED_PARAM(height);
359     UNUSED_PARAM(ec);
360 #endif
361 }
362
363 void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionCode& ec)
364 {
365     InternalSettingsGuardForSettings();
366     settings()->setMediaTypeOverride(mediaType);
367 }
368
369 void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode& ec)
370 {
371 #if ENABLE(TEXT_AUTOSIZING)
372     InternalSettingsGuardForSettings();
373     settings()->setTextAutosizingFontScaleFactor(fontScaleFactor);
374 #else
375     UNUSED_PARAM(fontScaleFactor);
376     UNUSED_PARAM(ec);
377 #endif
378 }
379
380 void InternalSettings::setCSSExclusionsEnabled(bool enabled, ExceptionCode& ec)
381 {
382     UNUSED_PARAM(ec);
383     RuntimeEnabledFeatures::sharedFeatures().setCSSExclusionsEnabled(enabled);
384 }
385
386 void InternalSettings::setCSSShapesEnabled(bool enabled, ExceptionCode& ec)
387 {
388     UNUSED_PARAM(ec);
389     RuntimeEnabledFeatures::sharedFeatures().setCSSShapesEnabled(enabled);
390 }
391
392 void InternalSettings::setCSSVariablesEnabled(bool enabled, ExceptionCode& ec)
393 {
394     InternalSettingsGuardForSettings();
395     settings()->setCSSVariablesEnabled(enabled);
396 }
397
398 bool InternalSettings::cssVariablesEnabled(ExceptionCode& ec)
399 {
400     InternalSettingsGuardForSettingsReturn(false);
401     return settings()->cssVariablesEnabled();
402 }
403
404 void InternalSettings::setCanStartMedia(bool enabled, ExceptionCode& ec)
405 {
406     InternalSettingsGuardForSettings();
407     m_page->setCanStartMedia(enabled);
408 }
409
410 void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionCode& ec)
411 {
412     InternalSettingsGuardForSettings();
413     if (equalIgnoringCase(editingBehavior, "win"))
414         settings()->setEditingBehaviorType(EditingWindowsBehavior);
415     else if (equalIgnoringCase(editingBehavior, "mac"))
416         settings()->setEditingBehaviorType(EditingMacBehavior);
417     else if (equalIgnoringCase(editingBehavior, "unix"))
418         settings()->setEditingBehaviorType(EditingUnixBehavior);
419     else
420         ec = SYNTAX_ERR;
421 }
422
423 void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
424 {
425     InternalSettingsGuardForSettings();
426
427 #if ENABLE(VIDEO_TRACK)
428     if (!page())
429         return;
430     CaptionUserPreferences* captionPreferences = page()->group().captionPreferences();
431
432     if (equalIgnoringCase(kind, "Subtitles"))
433         captionPreferences->setUserPrefersSubtitles(enabled);
434     else if (equalIgnoringCase(kind, "Captions"))
435         captionPreferences->setUserPrefersCaptions(enabled);
436     else if (equalIgnoringCase(kind, "TextDescriptions"))
437         captionPreferences->setUserPrefersTextDescriptions(enabled);
438     else
439         ec = SYNTAX_ERR;
440 #else
441     UNUSED_PARAM(kind);
442     UNUSED_PARAM(enabled);
443 #endif
444 }
445
446 bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
447 {
448     InternalSettingsGuardForSettingsReturn(false);
449
450 #if ENABLE(VIDEO_TRACK)
451     if (!page())
452         return false;
453     CaptionUserPreferences* captionPreferences = page()->group().captionPreferences();
454
455     if (equalIgnoringCase(kind, "Subtitles"))
456         return captionPreferences->userPrefersSubtitles();
457     if (equalIgnoringCase(kind, "Captions"))
458         return captionPreferences->userPrefersCaptions();
459     if (equalIgnoringCase(kind, "TextDescriptions"))
460         return captionPreferences->userPrefersTextDescriptions();
461
462     ec = SYNTAX_ERR;
463     return false;
464 #else
465     UNUSED_PARAM(kind);
466     return false;
467 #endif
468 }
469
470 void InternalSettings::setStorageBlockingPolicy(const String& mode, ExceptionCode& ec)
471 {
472     InternalSettingsGuardForSettings();
473
474     if (mode == "AllowAll")
475         settings()->setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
476     else if (mode == "BlockThirdParty")
477         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
478     else if (mode == "BlockAll")
479         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
480     else
481         ec = SYNTAX_ERR;
482 }
483
484 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled)
485 {
486     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(enabled);
487 }
488
489 void InternalSettings::setImagesEnabled(bool enabled, ExceptionCode& ec)
490 {
491     InternalSettingsGuardForSettings();
492     settings()->setImagesEnabled(enabled);
493 }
494
495 void InternalSettings::setMinimumTimerInterval(double intervalInSeconds, ExceptionCode& ec)
496 {
497     InternalSettingsGuardForSettings();
498     settings()->setMinDOMTimerInterval(intervalInSeconds);
499 }
500
501 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec)
502 {
503     InternalSettingsGuardForSettings();
504     settings()->setDefaultVideoPosterURL(url);
505 }
506
507 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec)
508 {
509     InternalSettingsGuardForSettings();
510     settings()->setTimeWithoutMouseMovementBeforeHidingControls(time);
511 }
512
513 void InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode& ec)
514 {
515     InternalSettingsGuardForSettings();
516     settings()->setUseLegacyBackgroundSizeShorthandBehavior(enabled);
517 }
518
519 void InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled, ExceptionCode& ec)
520 {
521     InternalSettingsGuardForSettings();
522     settings()->setAutoscrollForDragAndDropEnabled(enabled);
523 }
524
525 }