OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 settings->setLayerSquashingEnabled(m_originalLayerSquashingEnabled); | 106 settings->setLayerSquashingEnabled(m_originalLayerSquashingEnabled); |
107 settings->setPasswordGenerationDecorationEnabled(m_originalPasswordGeneratio
nDecorationEnabled); | 107 settings->setPasswordGenerationDecorationEnabled(m_originalPasswordGeneratio
nDecorationEnabled); |
108 settings->genericFontFamilySettings().reset(); | 108 settings->genericFontFamilySettings().reset(); |
109 } | 109 } |
110 | 110 |
111 // We can't use RefCountedSupplement because that would try to make InternalSett
ings RefCounted | 111 // We can't use RefCountedSupplement because that would try to make InternalSett
ings RefCounted |
112 // and InternalSettings is already RefCounted via its base class, InternalSettin
gsGenerated. | 112 // and InternalSettings is already RefCounted via its base class, InternalSettin
gsGenerated. |
113 // Instead, we manually make InternalSettings supplement Page. | 113 // Instead, we manually make InternalSettings supplement Page. |
114 class InternalSettingsWrapper : public Supplement<Page> { | 114 class InternalSettingsWrapper : public Supplement<Page> { |
115 public: | 115 public: |
116 explicit InternalSettingsWrapper(Page* page) | 116 explicit InternalSettingsWrapper(Page& page) |
117 : m_internalSettings(InternalSettings::create(page)) { } | 117 : m_internalSettings(InternalSettings::create(page)) { } |
118 virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); } | 118 virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); } |
119 #if !ASSERT_DISABLED | 119 #if !ASSERT_DISABLED |
120 virtual bool isRefCountedWrapper() const OVERRIDE { return true; } | 120 virtual bool isRefCountedWrapper() const OVERRIDE { return true; } |
121 #endif | 121 #endif |
122 InternalSettings* internalSettings() const { return m_internalSettings.get()
; } | 122 InternalSettings* internalSettings() const { return m_internalSettings.get()
; } |
123 | 123 |
124 private: | 124 private: |
125 RefPtr<InternalSettings> m_internalSettings; | 125 RefPtr<InternalSettings> m_internalSettings; |
126 }; | 126 }; |
127 | 127 |
128 const char* InternalSettings::supplementName() | 128 const char* InternalSettings::supplementName() |
129 { | 129 { |
130 return "InternalSettings"; | 130 return "InternalSettings"; |
131 } | 131 } |
132 | 132 |
133 InternalSettings* InternalSettings::from(Page* page) | 133 InternalSettings* InternalSettings::from(Page& page) |
134 { | 134 { |
135 if (!Supplement<Page>::from(page, supplementName())) | 135 if (!Supplement<Page>::from(page, supplementName())) |
136 Supplement<Page>::provideTo(page, supplementName(), adoptPtr(new Interna
lSettingsWrapper(page))); | 136 Supplement<Page>::provideTo(page, supplementName(), adoptPtr(new Interna
lSettingsWrapper(page))); |
137 return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, su
pplementName()))->internalSettings(); | 137 return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, su
pplementName()))->internalSettings(); |
138 } | 138 } |
139 | 139 |
140 InternalSettings::~InternalSettings() | 140 InternalSettings::~InternalSettings() |
141 { | 141 { |
142 } | 142 } |
143 | 143 |
144 InternalSettings::InternalSettings(Page* page) | 144 InternalSettings::InternalSettings(Page& page) |
145 : InternalSettingsGenerated(page) | 145 : InternalSettingsGenerated(&page) |
146 , m_page(page) | 146 , m_page(&page) |
147 , m_backup(&page->settings()) | 147 , m_backup(&page.settings()) |
148 { | 148 { |
149 } | 149 } |
150 | 150 |
151 void InternalSettings::resetToConsistentState() | 151 void InternalSettings::resetToConsistentState() |
152 { | 152 { |
153 page()->setPageScaleFactor(1, IntPoint(0, 0)); | 153 page()->setPageScaleFactor(1, IntPoint(0, 0)); |
154 | 154 |
155 m_backup.restoreTo(settings()); | 155 m_backup.restoreTo(settings()); |
156 m_backup = Backup(settings()); | 156 m_backup = Backup(settings()); |
157 m_backup.m_originalTextAutosizingEnabled = settings()->textAutosizingEnabled
(); | 157 m_backup.m_originalTextAutosizingEnabled = settings()->textAutosizingEnabled
(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 settings()->setDefaultVideoPosterURL(url); | 357 settings()->setDefaultVideoPosterURL(url); |
358 } | 358 } |
359 | 359 |
360 void InternalSettings::setPasswordGenerationDecorationEnabled(bool enabled, Exce
ptionState& exceptionState) | 360 void InternalSettings::setPasswordGenerationDecorationEnabled(bool enabled, Exce
ptionState& exceptionState) |
361 { | 361 { |
362 InternalSettingsGuardForSettings(); | 362 InternalSettingsGuardForSettings(); |
363 settings()->setPasswordGenerationDecorationEnabled(enabled); | 363 settings()->setPasswordGenerationDecorationEnabled(enabled); |
364 } | 364 } |
365 | 365 |
366 } | 366 } |
OLD | NEW |