Commit 17523501 authored by akling@apple.com's avatar akling@apple.com

<https://webkit.org/b/119903> Make Settings ref-counted (and let Frame keep a ref!)

Reviewed by Geoff Garen.

Let Frame hold a RefPtr<Settings> so Frame::settings() isn't forced to go through Page.
It now also returns a reference, as it can never be null.

Removed 8.8 million lines of null-checking as a result.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154219 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c09dc63d
2013-08-16 Andreas Kling <akling@apple.com>
<https://webkit.org/b/119903> Make Settings ref-counted (and let Frame keep a ref!)
Reviewed by Geoff Garen.
Let Frame hold a RefPtr<Settings> so Frame::settings() isn't forced to go through Page.
It now also returns a reference, as it can never be null.
Removed 8.8 million lines of null-checking as a result.
2013-08-16 Ryosuke Niwa <rniwa@webkit.org>
<https://webkit.org/b/119536> Refactor highestEditableRoot to avoid a redundant call to rendererIsEditable
......@@ -1588,7 +1588,6 @@ __ZNK7WebCore5Frame16frameScaleFactorEv
__ZNK7WebCore5Frame18documentTypeStringEv
__ZNK7WebCore5Frame25trackedRepaintRectsAsTextEv
__ZNK7WebCore5Frame31displayStringModifiedByEncodingERKN3WTF6StringE
__ZNK7WebCore5Frame8settingsEv
__ZNK7WebCore5Range11startOffsetERi
__ZNK7WebCore5Range12endContainerERi
__ZNK7WebCore5Range12pastLastNodeEv
......
......@@ -645,8 +645,7 @@ static bool isTextWithCaret(AccessibilityObject* coreObject)
if (!frame)
return false;
Settings* settings = frame->settings();
if (!settings || !settings->caretBrowsingEnabled())
if (!frame->settings().caretBrowsingEnabled())
return false;
// Check text objects and paragraphs only.
......
......@@ -51,8 +51,7 @@ bool ScriptController::canExecuteScripts(ReasonForCallingCanExecuteScripts reaso
return true;
}
Settings* settings = m_frame->settings();
const bool allowed = m_frame->loader().client()->allowScript(settings && settings->isScriptEnabled());
const bool allowed = m_frame->loader().client()->allowScript(m_frame->settings().isScriptEnabled());
if (!allowed && reason == AboutToExecuteScript)
m_frame->loader().client()->didNotAllowScript();
return allowed;
......
......@@ -160,10 +160,7 @@ bool JSDOMWindowBase::javaScriptExperimentsEnabled(const JSGlobalObject* object)
Frame* frame = thisObject->impl()->frame();
if (!frame)
return false;
Settings* settings = frame->settings();
if (!settings)
return false;
return settings->javaScriptExperimentsEnabled();
return frame->settings().javaScriptExperimentsEnabled();
}
void JSDOMWindowBase::willRemoveFromWindowShell()
......
......@@ -501,12 +501,10 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue value)
// To avoid breaking old widgets, make "var location =" in a top-level frame create
// a property named "location" instead of performing a navigation (<rdar://problem/5688039>).
if (Frame* activeFrame = activeDOMWindow(exec)->frame()) {
if (Settings* settings = activeFrame->settings()) {
if (settings->usesDashboardBackwardCompatibilityMode() && !activeFrame->tree()->parent()) {
if (BindingSecurity::shouldAllowAccessToDOMWindow(exec, impl()))
putDirect(exec->vm(), Identifier(exec, "location"), value);
return;
}
if (activeFrame->settings().usesDashboardBackwardCompatibilityMode() && !activeFrame->tree()->parent()) {
if (BindingSecurity::shouldAllowAccessToDOMWindow(exec, impl()))
putDirect(exec->vm(), Identifier(exec, "location"), value);
return;
}
}
#endif
......
......@@ -1994,8 +1994,10 @@ sub GenerateImplementation
AddToImplIncludes("Frame.h");
AddToImplIncludes("Settings.h");
my $enable_function = ToMethodName($attribute->signature->extendedAttributes->{"EnabledBySetting"}) . "Enabled";
push(@implContent, " Settings* settings = castedThis->impl()->frame() ? castedThis->impl()->frame()->settings() : 0;\n");
push(@implContent, " if (!settings || !settings->$enable_function())\n");
push(@implContent, " if (!castedThis->impl()->frame())\n");
push(@implContent, " return jsUndefined();\n");
push(@implContent, " Settings& settings = castedThis->impl()->frame()->settings();\n");
push(@implContent, " if (!settings.$enable_function())\n");
push(@implContent, " return jsUndefined();\n");
}
}
......
......@@ -460,8 +460,10 @@ JSValue jsTestObjConstructorTestSubObj(ExecState* exec, JSValue slotBase, Proper
JSValue jsTestObjTestSubObjEnabledBySettingConstructor(ExecState* exec, JSValue slotBase, PropertyName)
{
JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
Settings* settings = castedThis->impl()->frame() ? castedThis->impl()->frame()->settings() : 0;
if (!settings || !settings->testSettingEnabled())
if (!castedThis->impl()->frame())
return jsUndefined();
Settings& settings = castedThis->impl()->frame()->settings();
if (!settings.testSettingEnabled())
return jsUndefined();
return JSTestSubObj::getConstructor(exec, castedThis->globalObject());
}
......
......@@ -214,7 +214,7 @@ void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace* fontFaceRule)
foundSVGFont = item->isSVGFontFaceSrc() || item->svgFontFaceElement();
#endif
if (!item->isLocal()) {
Settings* settings = m_document ? m_document->frame() ? m_document->frame()->settings() : 0 : 0;
Settings* settings = m_document ? m_document->frame() ? &m_document->frame()->settings() : 0 : 0;
bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
if (allowDownloading && item->isSupportedFormat() && m_document) {
CachedFont* cachedFont = item->cachedFont(m_document);
......@@ -370,27 +370,25 @@ static PassRefPtr<FontData> fontDataForGenericFamily(Document* document, const F
if (!document || !document->frame())
return 0;
const Settings* settings = document->frame()->settings();
if (!settings)
return 0;
const Settings& settings = document->frame()->settings();
AtomicString genericFamily;
UScriptCode script = fontDescription.script();
if (familyName == serifFamily)
genericFamily = settings->serifFontFamily(script);
genericFamily = settings.serifFontFamily(script);
else if (familyName == sansSerifFamily)
genericFamily = settings->sansSerifFontFamily(script);
genericFamily = settings.sansSerifFontFamily(script);
else if (familyName == cursiveFamily)
genericFamily = settings->cursiveFontFamily(script);
genericFamily = settings.cursiveFontFamily(script);
else if (familyName == fantasyFamily)
genericFamily = settings->fantasyFontFamily(script);
genericFamily = settings.fantasyFontFamily(script);
else if (familyName == monospaceFamily)
genericFamily = settings->fixedFontFamily(script);
genericFamily = settings.fixedFontFamily(script);
else if (familyName == pictographFamily)
genericFamily = settings->pictographFontFamily(script);
genericFamily = settings.pictographFontFamily(script);
else if (familyName == standardFamily)
genericFamily = settings->standardFontFamily(script);
genericFamily = settings.standardFontFamily(script);
if (!genericFamily.isEmpty())
return fontCache()->getCachedFontData(fontDescription, genericFamily);
......
......@@ -635,7 +635,7 @@ enum PointerDeviceType { TouchPointer, MousePointer, NoPointer, UnknownPointer }
static PointerDeviceType leastCapablePrimaryPointerDeviceType(Frame* frame)
{
if (frame->settings()->deviceSupportsTouch())
if (frame->settings().deviceSupportsTouch())
return TouchPointer;
// FIXME: We should also try to determine if we know we have a mouse.
......
......@@ -367,7 +367,7 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
#if ENABLE(VIDEO)
// Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument
// Key system is not applicable here.
DOMImplementationSupportsTypeClient client(frame && frame->settings() && frame->settings()->needsSiteSpecificQuirks(), url.host());
DOMImplementationSupportsTypeClient client(frame && frame->settings().needsSiteSpecificQuirks(), url.host());
if (MediaPlayer::supportsType(ContentType(type), String(), url, &client))
return MediaDocument::create(frame, url);
#endif
......
......@@ -1650,7 +1650,7 @@ Page* Document::page() const
Settings* Document::settings() const
{
return m_frame ? m_frame->settings() : 0;
return m_frame ? &m_frame->settings() : 0;
}
PassRefPtr<Range> Document::createRange()
......
......@@ -182,10 +182,9 @@ VisibleSelection Editor::selectionForCommand(Event* event)
// Function considers Mac editing behavior a fallback when Page or Settings is not available.
EditingBehavior Editor::behavior() const
{
if (!m_frame || !m_frame->settings())
if (!m_frame)
return EditingBehavior(EditingMacBehavior);
return EditingBehavior(m_frame->settings()->editingBehaviorType());
return EditingBehavior(m_frame->settings().editingBehaviorType());
}
EditorClient* Editor::client() const
......@@ -2118,7 +2117,7 @@ void Editor::markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textC
return;
RefPtr<Range> paragraphRange = paragraphToCheck.paragraphRange();
bool asynchronous = m_frame && m_frame->settings() && m_frame->settings()->asynchronousSpellCheckingEnabled() && !shouldShowCorrectionPanel;
bool asynchronous = m_frame && m_frame->settings().asynchronousSpellCheckingEnabled() && !shouldShowCorrectionPanel;
// In asynchronous mode, we intentionally check paragraph-wide sentence.
RefPtr<SpellCheckRequest> request = SpellCheckRequest::create(resolveTextCheckingTypeMask(textCheckingOptions), TextCheckingProcessIncremental, asynchronous ? paragraphRange : rangeToCheck, paragraphRange);
......@@ -2631,7 +2630,7 @@ String Editor::selectedText() const
String Editor::selectedTextForClipboard() const
{
if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageText())
if (m_frame->settings().selectionIncludesAltImageText())
return selectedText(TextIteratorEmitsImageAltText);
return selectedText();
}
......@@ -2989,7 +2988,7 @@ void Editor::respondToChangedSelection(const VisibleSelection& oldSelection, Fra
if (isContinuousSpellCheckingEnabled) {
VisibleSelection newAdjacentWords;
VisibleSelection newSelectedSentence;
bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
bool caretBrowsing = m_frame->settings().caretBrowsingEnabled();
if (m_frame->selection()->selection().isContentEditable() || caretBrowsing) {
VisiblePosition newStart(m_frame->selection()->selection().visibleStart());
newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWordIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary));
......
......@@ -1172,8 +1172,7 @@ static bool supportedCopyCut(Frame* frame)
if (!frame)
return false;
Settings* settings = frame->settings();
bool defaultValue = settings && settings->javaScriptCanAccessClipboard();
bool defaultValue = frame->settings().javaScriptCanAccessClipboard();
EditorClient* client = frame->editor().client();
return client ? client->canCopyCut(frame, defaultValue) : defaultValue;
......@@ -1184,8 +1183,7 @@ static bool supportedPaste(Frame* frame)
if (!frame)
return false;
Settings* settings = frame->settings();
bool defaultValue = settings && settings->javaScriptCanAccessClipboard() && settings->DOMPasteAllowed();
bool defaultValue = frame->settings().javaScriptCanAccessClipboard() && frame->settings().DOMPasteAllowed();
EditorClient* client = frame->editor().client();
return client ? client->canPaste(frame, defaultValue) : defaultValue;
......@@ -1207,7 +1205,7 @@ static bool enabledVisibleSelection(Frame* frame, Event* event, EditorCommandSou
static bool caretBrowsingEnabled(Frame* frame)
{
return frame->settings() && frame->settings()->caretBrowsingEnabled();
return frame->settings().caretBrowsingEnabled();
}
static EditorCommandSource dummyEditorCommandSource = static_cast<EditorCommandSource>(0);
......
......@@ -560,8 +560,7 @@ void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direct
VisiblePosition FrameSelection::positionForPlatform(bool isGetStart) const
{
Settings* settings = m_frame ? m_frame->settings() : 0;
if (settings && settings->editingBehaviorType() == EditingMacBehavior)
if (m_frame && m_frame->settings().editingBehaviorType() == EditingMacBehavior)
return isGetStart ? m_selection.visibleStart() : m_selection.visibleEnd();
// Linux and Windows always extend selections from the extent endpoint.
// FIXME: VisibleSelection should be fixed to ensure as an invariant that
......@@ -1413,7 +1412,7 @@ bool CaretBase::shouldRepaintCaret(const RenderView* view, bool isContentEditabl
{
ASSERT(view);
Frame* frame = view->frameView() ? &view->frameView()->frame() : 0; // The frame where the selection started.
bool caretBrowsing = frame && frame->settings() && frame->settings()->caretBrowsingEnabled();
bool caretBrowsing = frame && frame->settings().caretBrowsingEnabled();
return (caretBrowsing || isContentEditable);
}
......@@ -1770,7 +1769,7 @@ void FrameSelection::updateAppearance()
#if ENABLE(TEXT_CARET)
bool caretRectChangedOrCleared = recomputeCaretRect();
bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
bool caretBrowsing = m_frame->settings().caretBrowsingEnabled();
bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing) && forwardPosition.isNull();
// If the caret moved, stop the blink timer so we can restart with a
......@@ -1884,7 +1883,7 @@ void FrameSelection::setFocusedElementIfNeeded()
if (isNone() || !isFocused())
return;
bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
bool caretBrowsing = m_frame->settings().caretBrowsingEnabled();
if (caretBrowsing) {
if (Element* anchor = enclosingAnchorElement(base())) {
m_frame->page()->focusController().setFocusedElement(anchor, m_frame);
......@@ -2037,7 +2036,7 @@ void FrameSelection::setSelectionFromNone()
// entire WebView is editable or designMode is on for this document).
Document* document = m_frame->document();
bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
bool caretBrowsing = m_frame->settings().caretBrowsingEnabled();
if (!isNone() || !(document->rendererIsEditable() || caretBrowsing))
return;
......@@ -2064,8 +2063,9 @@ bool FrameSelection::dispatchSelectStart()
inline bool FrameSelection::visualWordMovementEnabled() const
{
Settings* settings = m_frame ? m_frame->settings() : 0;
return settings && settings->visualWordMovementEnabled();
if (!m_frame)
return false;
return m_frame->settings().visualWordMovementEnabled();
}
void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor)
......
......@@ -141,7 +141,7 @@ void SpellChecker::timerFiredToProcessQueuedRequest(Timer<SpellChecker>*)
bool SpellChecker::isAsynchronousEnabled() const
{
return m_frame->settings() && m_frame->settings()->asynchronousSpellCheckingEnabled();
return m_frame->settings().asynchronousSpellCheckingEnabled();
}
bool SpellChecker::canCheckAsynchronously(Range* range) const
......
......@@ -683,12 +683,7 @@ bool unifiedTextCheckerEnabled(const Frame* frame)
{
if (!frame)
return false;
const Settings* settings = frame->settings();
if (!settings)
return false;
return settings->unifiedTextCheckerEnabled();
return frame->settings().unifiedTextCheckerEnabled();
}
}
......@@ -191,11 +191,9 @@ bool HTMLEmbedElement::rendererIsNeeded(const NodeRenderingContext& context)
}
#if ENABLE(DASHBOARD_SUPPORT)
// Workaround for <rdar://problem/6642221>.
if (Settings* settings = frame->settings()) {
if (settings->usesDashboardBackwardCompatibilityMode())
return true;
}
// Workaround for <rdar://problem/6642221>.
if (frame->settings().usesDashboardBackwardCompatibilityMode())
return true;
#endif
return HTMLPlugInImageElement::rendererIsNeeded(context);
......
......@@ -1131,7 +1131,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
// When using caret browsing, we want to be able to move the focus
// out of the select element when user hits a left or right arrow key.
const Frame* frame = document()->frame();
if (frame && frame->settings() && frame->settings()->caretBrowsingEnabled()) {
if (frame && frame->settings().caretBrowsingEnabled()) {
if (keyIdentifier == "Left" || keyIdentifier == "Right")
return;
}
......
......@@ -130,8 +130,7 @@ static float pageZoomFactor(const Document* document)
void ImageDocumentParser::appendBytes(DocumentWriter*, const char*, size_t)
{
Frame* frame = document()->frame();
Settings* settings = frame->settings();
if (!frame->loader().client()->allowImage(!settings || settings->areImagesEnabled(), document()->url()))
if (!frame->loader().client()->allowImage(frame->settings().areImagesEnabled(), document()->url()))
return;
CachedImage* cachedImage = document()->cachedImage();
......
......@@ -110,9 +110,6 @@ void PluginDocumentParser::appendBytes(DocumentWriter*, const char*, size_t)
Frame* frame = document()->frame();
if (!frame)
return;
Settings* settings = frame->settings();
if (!settings)
return;
document()->updateLayout();
......
......@@ -411,11 +411,10 @@ PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElemen
Frame* frame = document->frame();
if (!frame)
return nullptr;
Settings* settings = frame->settings();
// The FrameLoaderClient might creation of a new WebGL context despite the page settings; in
// particular, if WebGL contexts were lost one or more times via the GL_ARB_robustness extension.
if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled())) {
if (!frame->loader().client()->allowWebGL(frame->settings().webGLEnabled())) {
canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Web page was not allowed to create a WebGL context."));
return nullptr;
}
......@@ -424,7 +423,7 @@ PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElemen
GraphicsContext3D::Attributes attributes = attrs ? attrs->attributes() : GraphicsContext3D::Attributes();
if (attributes.antialias) {
if (settings && !settings->openGLMultisamplingEnabled())
if (!frame->settings().openGLMultisamplingEnabled())
attributes.antialias = false;
}
......@@ -5820,7 +5819,7 @@ void WebGLRenderingContext::maybeRestoreContext(Timer<WebGLRenderingContext>*)
if (!frame)
return;
if (!frame->loader().client()->allowWebGL(frame->settings() && frame->settings()->webGLEnabled()))
if (!frame->loader().client()->allowWebGL(frame->settings().webGLEnabled()))
return;
FrameView* view = frame->view();
......
......@@ -239,8 +239,7 @@ void XSSAuditor::init(Document* document, XSSAuditorDelegate* auditorDelegate)
m_state = Initialized;
if (Frame* frame = document->frame())
if (Settings* settings = frame->settings())
m_isEnabled = settings->xssAuditorEnabled();
m_isEnabled = frame->settings().xssAuditorEnabled();
if (!m_isEnabled)
return;
......
......@@ -434,10 +434,8 @@ void InspectorPageAgent::enable(ErrorString*)
m_state->setBoolean(PageAgentState::pageAgentEnabled, true);
m_instrumentingAgents->setInspectorPageAgent(this);
if (Frame* frame = mainFrame()) {
if (Settings* settings = frame->settings())
m_originalScriptExecutionDisabled = !settings->isScriptEnabled();
}
if (Frame* frame = mainFrame())
m_originalScriptExecutionDisabled = !frame->settings().isScriptEnabled();
}
void InspectorPageAgent::disable(ErrorString*)
......@@ -840,8 +838,7 @@ void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl
Frame* frame = mainFrame();
if (frame) {
disabledByScriptController = !frame->script().canExecuteScripts(NotAboutToExecuteScript);
if (frame->settings())
disabledInSettings = !frame->settings()->isScriptEnabled();
disabledInSettings = !frame->settings().isScriptEnabled();
}
if (!disabledByScriptController) {
......@@ -861,12 +858,9 @@ void InspectorPageAgent::setScriptExecutionDisabled(ErrorString*, bool value)
if (!mainFrame())
return;
Settings* settings = mainFrame()->settings();
if (settings) {
m_ignoreScriptsEnabledNotification = true;
settings->setScriptEnabled(!value);
m_ignoreScriptsEnabledNotification = false;
}
m_ignoreScriptsEnabledNotification = true;
mainFrame()->settings().setScriptEnabled(!value);
m_ignoreScriptsEnabledNotification = false;
}
void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world)
......@@ -1171,8 +1165,8 @@ void InspectorPageAgent::updateViewMetrics(int width, int height, double fontSca
void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled)
{
m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled);
if (mainFrame() && mainFrame()->settings())
mainFrame()->settings()->setTouchEventEmulationEnabled(enabled);
if (mainFrame())
mainFrame()->settings().setTouchEventEmulationEnabled(enabled);
}
#endif
......
......@@ -626,8 +626,7 @@ void DocumentLoader::responseReceived(CachedResource* resource, const ResourceRe
#if ENABLE(FTPDIR)
// Respect the hidden FTP Directory Listing pref so it can be tested even if the policy delegate might otherwise disallow it
Settings* settings = m_frame->settings();
if (settings && settings->forceFTPDirectoryListings() && m_response.mimeType() == "application/x-ftp-directory") {
if (m_frame->settings().forceFTPDirectoryListings() && m_response.mimeType() == "application/x-ftp-directory") {
continueAfterContentPolicy(PolicyUse);
return;
}
......@@ -940,7 +939,7 @@ bool DocumentLoader::isLoadingInAPISense() const
// Once a frame has loaded, we no longer need to consider subresources,
// but we still need to consider subframes.
if (frameLoader()->state() != FrameStateComplete) {
if (m_frame->settings()->needsIsLoadingInAPISenseQuirk() && !m_subresourceLoaders.isEmpty())
if (m_frame->settings().needsIsLoadingInAPISenseQuirk() && !m_subresourceLoaders.isEmpty())
return true;
Document* doc = m_frame->document();
......@@ -1176,7 +1175,7 @@ bool DocumentLoader::scheduleArchiveLoad(ResourceLoader* loader, const ResourceR
#if ENABLE(WEB_ARCHIVE)
case Archive::WebArchive:
// WebArchiveDebugMode means we fail loads instead of trying to fetch them from the network if they're not in the archive.
return m_frame->settings() && m_frame->settings()->webArchiveDebugModeEnabled() && ArchiveFactory::isArchiveMimeType(responseMIMEType());
return m_frame->settings().webArchiveDebugModeEnabled() && ArchiveFactory::isArchiveMimeType(responseMIMEType());
#endif
#if ENABLE(MHTML)
case Archive::MHTML:
......
......@@ -169,25 +169,21 @@ void DocumentWriter::begin(const KURL& urlReference, bool dispatch, Document* ow
TextResourceDecoder* DocumentWriter::createDecoderIfNeeded()
{
if (!m_decoder) {
if (Settings* settings = m_frame->settings()) {
m_decoder = TextResourceDecoder::create(m_mimeType,
settings->defaultTextEncodingName(),
settings->usesEncodingDetector());
Frame* parentFrame = m_frame->tree()->parent();
// Set the hint encoding to the parent frame encoding only if
// the parent and the current frames share the security origin.
// We impose this condition because somebody can make a child frame
// containing a carefully crafted html/javascript in one encoding
// that can be mistaken for hintEncoding (or related encoding) by
// an auto detector. When interpreted in the latter, it could be
// an attack vector.
// FIXME: This might be too cautious for non-7bit-encodings and
// we may consider relaxing this later after testing.
if (canReferToParentFrameEncoding(m_frame, parentFrame))
m_decoder->setHintEncoding(parentFrame->document()->decoder());
} else
m_decoder = TextResourceDecoder::create(m_mimeType, String());
m_decoder = TextResourceDecoder::create(m_mimeType,
m_frame->settings().defaultTextEncodingName(),
m_frame->settings().usesEncodingDetector());
Frame* parentFrame = m_frame->tree()->parent();
// Set the hint encoding to the parent frame encoding only if
// the parent and the current frames share the security origin.
// We impose this condition because somebody can make a child frame
// containing a carefully crafted html/javascript in one encoding
// that can be mistaken for hintEncoding (or related encoding) by
// an auto detector. When interpreted in the latter, it could be
// an attack vector.
// FIXME: This might be too cautious for non-7bit-encodings and
// we may consider relaxing this later after testing.
if (canReferToParentFrameEncoding(m_frame, parentFrame))
m_decoder->setHintEncoding(parentFrame->document()->decoder());
if (m_encoding.isEmpty()) {
if (canReferToParentFrameEncoding(m_frame, parentFrame))
m_decoder->setEncoding(parentFrame->document()->inputEncoding(), TextResourceDecoder::EncodingFromParentFrame);
......
......@@ -2503,8 +2503,7 @@ void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadTyp
// Only set fallback array if it's still empty (later attempts may be incorrect, see bug 117818).
if (request.responseContentDispositionEncodingFallbackArray().isEmpty()) {
// Always try UTF-8. If that fails, try frame encoding (if any) and then the default.
Settings* settings = m_frame->settings();
request.setResponseContentDispositionEncodingFallbackArray("UTF-8", m_frame->document()->encoding(), settings ? settings->defaultTextEncodingName() : String());
request.setResponseContentDispositionEncodingFallbackArray("UTF-8", m_frame->document()->encoding(), m_frame->settings().defaultTextEncodingName());
}
}
......@@ -3422,7 +3421,7 @@ PassRefPtr<Frame> createWindow(Frame* openerFrame, Frame* lookupFrame, const Fra
requestWithReferrer.resourceRequest().setHTTPReferrer(referrer);
FrameLoader::addHTTPOriginIfNeeded(requestWithReferrer.resourceRequest(), openerFrame->loader().outgoingOrigin());
if (openerFrame->settings() && !openerFrame->settings()->supportsMultipleWindows()) {
if (!openerFrame->settings().supportsMultipleWindows()) {
created = false;
return openerFrame;
}
......
......@@ -362,8 +362,7 @@ void HistoryController::updateForStandardLoad(HistoryUpdateType updateType)
FrameLoader& frameLoader = m_frame->loader();
Settings* settings = m_frame->settings();
bool needPrivacy = !settings || settings->privateBrowsingEnabled();
bool needPrivacy = m_frame->settings().privateBrowsingEnabled();
const KURL& historyURL = frameLoader.documentLoader()->urlForHistory();
if (!frameLoader.documentLoader()->isClientRedirect()) {
......@@ -400,8 +399,7 @@ void HistoryController::updateForRedirectWithLockedBackForwardList()
LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", m_frame->loader().documentLoader()->title().string().utf8().data());
#endif
Settings* settings = m_frame->settings();
bool needPrivacy = !settings || settings->privateBrowsingEnabled();
bool needPrivacy = m_frame->settings().privateBrowsingEnabled();
const KURL& historyURL = m_frame->loader().documentLoader()->urlForHistory();
if (m_frame->loader().documentLoader()->isClientRedirect()) {
......@@ -449,8 +447,7 @@ void HistoryController::updateForClientRedirect()
m_currentItem->clearScrollPoint();
}
Settings* settings = m_frame->settings();
bool needPrivacy = !settings || settings->privateBrowsingEnabled();
bool needPrivacy = m_frame->settings().privateBrowsingEnabled();
const KURL& historyURL = m_frame->loader().documentLoader()->urlForHistory();
if (!historyURL.isEmpty() && !needPrivacy) {
......@@ -542,8 +539,7 @@ void HistoryController::updateForSameDocumentNavigation()
if (m_frame->document()->url().isEmpty())
return;
Settings* settings = m_frame->settings();
if (!settings || settings->privateBrowsingEnabled())
if (m_frame->settings().privateBrowsingEnabled())
return;
Page* page = m_frame->page();
......@@ -871,8 +867,7 @@ void HistoryController::pushState(PassRefPtr<SerializedScriptValue> stateObject,
page->backForward()->addItem(topItem.release());
Settings* settings = m_frame->settings();
if (!settings || settings->privateBrowsingEnabled())
if (m_frame->settings().privateBrowsingEnabled())
return;
addVisitedLink(page, KURL(ParsedURLString, urlString));
......@@ -892,8 +887,7 @@ void HistoryController::replaceState(PassRefPtr<SerializedScriptValue> stateObje
m_currentItem->setFormData(0);
m_currentItem->setFormContentType(String());
Settings* settings = m_frame->settings();
if (!settings || settings->privateBrowsingEnabled())
if (m_frame->settings().privateBrowsingEnabled())
return;
ASSERT(m_frame->page());
......
......@@ -68,8 +68,7 @@ bool MixedContentChecker::canDisplayInsecureContent(SecurityOrigin* securityOrig
if (!isMixedContent(securityOrigin, url))
return true;
Settings* settings = m_frame->settings();
bool allowed = client()->allowDisplayingInsecureContent(settings && settings->allowDisplayOfInsecureContent(), securityOrigin, url);
bool allowed = client()->allowDisplayingInsecureContent(m_frame->settings().allowDisplayOfInsecureContent(), securityOrigin, url);
logWarning(allowed, "displayed", url);
if (allowed)
......@@ -83,8 +82,7 @@ bool MixedContentChecker::canRunInsecureContent(SecurityOrigin* securityOrigin,
if (!isMixedContent(securityOrigin, url))
return true;