InternalSettings.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. #ifndef InternalSettings_h
  27. #define InternalSettings_h
  28. #include "EditingBehaviorTypes.h"
  29. #include "IntSize.h"
  30. #include "InternalSettingsGenerated.h"
  31. #include <wtf/PassRefPtr.h>
  32. #include <wtf/RefCounted.h>
  33. #include <wtf/text/WTFString.h>
  34. namespace WebCore {
  35. typedef int ExceptionCode;
  36. class Frame;
  37. class Document;
  38. class Page;
  39. class Settings;
  40. class InternalSettings : public InternalSettingsGenerated {
  41. public:
  42. class Backup {
  43. public:
  44. explicit Backup(Settings*);
  45. void restoreTo(Settings*);
  46. bool m_originalCSSExclusionsEnabled;
  47. bool m_originalCSSShapesEnabled;
  48. bool m_originalCSSVariablesEnabled;
  49. #if ENABLE(SHADOW_DOM)
  50. bool m_originalShadowDOMEnabled;
  51. bool m_originalAuthorShadowDOMForAnyElementEnabled;
  52. #endif
  53. #if ENABLE(STYLE_SCOPED)
  54. bool m_originalStyleScoped;
  55. #endif
  56. EditingBehaviorType m_originalEditingBehavior;
  57. #if ENABLE(TEXT_AUTOSIZING)
  58. bool m_originalTextAutosizingEnabled;
  59. IntSize m_originalTextAutosizingWindowSizeOverride;
  60. float m_originalTextAutosizingFontScaleFactor;
  61. #endif
  62. String m_originalMediaTypeOverride;
  63. #if ENABLE(DIALOG_ELEMENT)
  64. bool m_originalDialogElementEnabled;
  65. #endif
  66. bool m_originalCanvasUsesAcceleratedDrawing;
  67. bool m_originalMockScrollbarsEnabled;
  68. bool m_originalUsesOverlayScrollbars;
  69. bool m_langAttributeAwareFormControlUIEnabled;
  70. bool m_imagesEnabled;
  71. double m_minimumTimerInterval;
  72. #if ENABLE(VIDEO_TRACK)
  73. bool m_shouldDisplaySubtitles;
  74. bool m_shouldDisplayCaptions;
  75. bool m_shouldDisplayTextDescriptions;
  76. #endif
  77. String m_defaultVideoPosterURL;
  78. bool m_originalTimeWithoutMouseMovementBeforeHidingControls;
  79. bool m_useLegacyBackgroundSizeShorthandBehavior;
  80. };
  81. static PassRefPtr<InternalSettings> create(Page* page)
  82. {
  83. return adoptRef(new InternalSettings(page));
  84. }
  85. static InternalSettings* from(Page*);
  86. void hostDestroyed() { m_page = 0; }
  87. virtual ~InternalSettings();
  88. void resetToConsistentState();
  89. void setMockScrollbarsEnabled(bool enabled, ExceptionCode&);
  90. void setUsesOverlayScrollbars(bool enabled, ExceptionCode&);
  91. void setTouchEventEmulationEnabled(bool enabled, ExceptionCode&);
  92. void setShadowDOMEnabled(bool enabled, ExceptionCode&);
  93. void setAuthorShadowDOMForAnyElementEnabled(bool);
  94. void setStyleScopedEnabled(bool);
  95. void setStandardFontFamily(const String& family, const String& script, ExceptionCode&);
  96. void setSerifFontFamily(const String& family, const String& script, ExceptionCode&);
  97. void setSansSerifFontFamily(const String& family, const String& script, ExceptionCode&);
  98. void setFixedFontFamily(const String& family, const String& script, ExceptionCode&);
  99. void setCursiveFontFamily(const String& family, const String& script, ExceptionCode&);
  100. void setFantasyFontFamily(const String& family, const String& script, ExceptionCode&);
  101. void setPictographFontFamily(const String& family, const String& script, ExceptionCode&);
  102. void setTextAutosizingEnabled(bool enabled, ExceptionCode&);
  103. void setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode&);
  104. void setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode&);
  105. void setMediaTypeOverride(const String& mediaType, ExceptionCode&);
  106. void setCSSExclusionsEnabled(bool enabled, ExceptionCode&);
  107. void setCSSShapesEnabled(bool enabled, ExceptionCode&);
  108. void setCSSVariablesEnabled(bool enabled, ExceptionCode&);
  109. bool cssVariablesEnabled(ExceptionCode&);
  110. void setCanStartMedia(bool, ExceptionCode&);
  111. void setEditingBehavior(const String&, ExceptionCode&);
  112. void setDialogElementEnabled(bool, ExceptionCode&);
  113. void setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode&);
  114. bool shouldDisplayTrackKind(const String& kind, ExceptionCode&);
  115. void setStorageBlockingPolicy(const String&, ExceptionCode&);
  116. void setLangAttributeAwareFormControlUIEnabled(bool);
  117. void setImagesEnabled(bool enabled, ExceptionCode&);
  118. void setMinimumTimerInterval(double intervalInSeconds, ExceptionCode&);
  119. void setDefaultVideoPosterURL(const String& url, ExceptionCode&);
  120. void setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode&);
  121. void setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode&);
  122. private:
  123. explicit InternalSettings(Page*);
  124. Settings* settings() const;
  125. Page* page() const { return m_page; }
  126. static const char* supplementName();
  127. Page* m_page;
  128. Backup m_backup;
  129. };
  130. } // namespace WebCore
  131. #endif